@@ -1775,24 +1775,31 @@ def GetGlobalOp : CIR_Op<"get_global",
1775
1775
[Pure, DeclareOpInterfaceMethods<SymbolUserOpInterface>]> {
1776
1776
let summary = "Get the address of a global variable";
1777
1777
let description = [{
1778
- The `cir.get_global` operation retrieves the address pointing to a
1779
- named global variable. If the global variable is marked constant, writing
1780
- to the resulting address (such as through a `cir.store` operation) is
1781
- undefined. Resulting type must always be a `!cir.ptr<...>` type.
1778
+ The `cir.get_global` operation retrieves the address pointing to a
1779
+ named global variable. If the global variable is marked constant, writing
1780
+ to the resulting address (such as through a `cir.store` operation) is
1781
+ undefined. Resulting type must always be a `!cir.ptr<...>` type.
1782
1782
1783
- Example:
1783
+ Addresses of thread local globals can only be retrieved if this operation
1784
+ is marked `thread_local`, which indicates the address isn't constant.
1784
1785
1785
- ```mlir
1786
- %x = cir.get_global @foo : !cir.ptr<i32>
1787
- ```
1786
+ Example:
1787
+ ```mlir
1788
+ %x = cir.get_global @foo : !cir.ptr<i32>
1789
+ ...
1790
+ %y = cir.get_global thread_local @batata : !cir.ptr<i32>
1791
+ ```
1788
1792
}];
1789
1793
1790
- let arguments = (ins FlatSymbolRefAttr:$name);
1794
+ let arguments = (ins FlatSymbolRefAttr:$name, UnitAttr:$tls );
1791
1795
let results = (outs Res<CIR_PointerType, "", []>:$addr);
1792
1796
1793
1797
// FIXME: we should not be printing `cir.ptr` below, that should come
1794
1798
// from the pointer type directly.
1795
- let assemblyFormat = "$name `:` `cir.ptr` type($addr) attr-dict";
1799
+ let assemblyFormat = [{
1800
+ (`thread_local` $tls^)?
1801
+ $name `:` `cir.ptr` type($addr) attr-dict
1802
+ }];
1796
1803
1797
1804
// `GetGlobalOp` is fully verified by its traits.
1798
1805
let hasVerifier = 0;
0 commit comments