================
@@ -4800,4 +4800,37 @@ def CIR_AtomicClearOp : CIR_Op<"atomic.clear"> {
}];
}
+//===----------------------------------------------------------------------===//
+// BlockAddressOp
+//===----------------------------------------------------------------------===//
+
+def CIR_BlockAddressOp : CIR_Op<"blockaddress", [Pure]> {
+ let summary = "Get the address of a cir.label within a function";
+ let description = [{
+ The `cir.blockaddress` operation takes a function name and a label and
+ produces a pointer value that represents the address of that cir.label
within
+ the specified function.
+
+ This operation models GCC's "labels as values" extension (`&&label`), which
+ allows taking the address of a local label and using it as a computed
+ jump target (e.g., with `goto *addr;`).
+
+ Example:
+ ```mlir
+ %1 = cir.alloca !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>, ["ptr", init]
{alignment = 8 : i64}
+ %addr = cir.blockaddress("foo", "label") -> !cir.ptr<!cir.void>
+ cir.store align(8) %addr, %1 : !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>
+ cir.br ^bb1
+ ^bb1:
+ cir.label "label"
+ ```
+ }];
+
+ let arguments = (ins CIR_BlockAddrInfoAttr:$blockAddrInfo);
----------------
Andres-Salamanca wrote:
Done
https://github.com/llvm/llvm-project/pull/168151
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits