[Mlir-commits] [mlir] [MLIR][LLVM] Support for indirectbr (PR #135092)
Tobias Gysi
llvmlistbot at llvm.org
Wed Apr 9 23:46:11 PDT 2025
================
@@ -1705,6 +1705,65 @@ def LLVM_BlockTagOp : LLVM_Op<"blocktag"> {
let hasVerifier = 0;
}
+//===----------------------------------------------------------------------===//
+// IndirectBrOp
+//===----------------------------------------------------------------------===//
+
+def LLVM_IndirectBrOp : LLVM_TerminatorOp<"indirectbr",
+ [SameVariadicOperandSize, DeclareOpInterfaceMethods<BranchOpInterface>,
+ Pure]> {
+ let description = [{
+ Transfer control flow to address in `$addr`. A list of possible target
+ blocks in `$successors` can be provided and maybe used as a hint in LLVM:
+
+ ```mlir
+ ...
+ llvm.func @g(...
+ %dest = llvm.blockaddress <function = @g, tag = <id = 0>> : !llvm.ptr
+ llvm.indirectbr %dest : !llvm.ptr, [
+ ^head
+ ]
+ ^head:
+ llvm.blocktag <id = 0>
+ llvm.return %arg0 : i32
+ ...
+ ```
+
+ It also supports a list of operands that can be passed to a target block:
+
+ ```mlir
+ llvm.indirectbr %dest : !llvm.ptr, [
+ ^head(%arg0 : i32),
+ ^tail(%arg1 : i32)
+ ]
----------------
gysit wrote:
```suggestion
llvm.indirectbr %dest : !llvm.ptr, [
^head(%arg0 : i32),
^tail(%arg1 : i32)
]
```
ultra nit: adapted the format to above.
https://github.com/llvm/llvm-project/pull/135092
More information about the Mlir-commits
mailing list