[clang] [CIR] Upstream support for cir.get_global (PR #135095)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 9 16:50:35 PDT 2025


================
@@ -1279,6 +1279,37 @@ def GlobalOp : CIR_Op<"global"> {
   let hasVerifier = 1;
 }
 
+//===----------------------------------------------------------------------===//
+// GetGlobalOp
+//===----------------------------------------------------------------------===//
+
+def GetGlobalOp : CIR_Op<"get_global",
+    [Pure, DeclareOpInterfaceMethods<SymbolUserOpInterface>]> {
+  let summary = "Get the address of a global variable";
+  let description = [{
+    The `cir.get_global` operation retrieves the address pointing to a
+    named global variable. If the global variable is marked constant, writing
+    to the resulting address (such as through a `cir.store` operation) is
+    undefined. Resulting type must always be a `!cir.ptr<...>` type with the
----------------
erichkeane wrote:

```suggestion
    undefined. The resulting type must always be a `!cir.ptr<...>` type with the
```

https://github.com/llvm/llvm-project/pull/135095


More information about the cfe-commits mailing list