File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -1107,7 +1107,12 @@ Global Variables
1107
1107
1108
1108
SIL representation of a global variable.
1109
1109
1110
- FIXME: to be written.
1110
+ Global variable access is performed by the ``alloc_global `` and ``global_addr ``
1111
+ SIL instructions. Prior to performing any access on the global, the
1112
+ ``alloc_global `` instruction must be performed to initialize the storage.
1113
+
1114
+ Once a global's storage has been initialized, ``global_addr `` is used to
1115
+ project the value.
1111
1116
1112
1117
Dataflow Errors
1113
1118
---------------
@@ -1719,6 +1724,20 @@ behavior if the value buffer is currently allocated.
1719
1724
1720
1725
The type operand must be a lowered object type.
1721
1726
1727
+ alloc_global
1728
+ ````````````
1729
+
1730
+ ::
1731
+
1732
+ sil-instruction ::= 'alloc_global' sil-global-name
1733
+
1734
+ alloc_global @foo
1735
+
1736
+ Initialize the storage for a global variable. This instruction has
1737
+ undefined behavior if the global variable has already been initialized.
1738
+
1739
+ The type operand must be a lowered object type.
1740
+
1722
1741
dealloc_stack
1723
1742
`````````````
1724
1743
::
@@ -2384,15 +2403,18 @@ function_ref
2384
2403
Creates a reference to a SIL function.
2385
2404
2386
2405
global_addr
2387
- ```````````````
2406
+ ```````````
2388
2407
2389
2408
::
2390
2409
2391
2410
sil-instruction ::= 'global_addr' sil-global-name ':' sil-type
2392
2411
2393
2412
%1 = global_addr @foo : $*Builtin.Word
2394
2413
2395
- Creates a reference to the address of a global variable.
2414
+ Creates a reference to the address of a global variable which has been
2415
+ previously initialized by ``alloc_global ``. It is undefined behavior to
2416
+ perform this operation on a global variable which has not been
2417
+ initialized.
2396
2418
2397
2419
integer_literal
2398
2420
```````````````
You can’t perform that action at this time.
0 commit comments