Add a new kind of GlobalVar for symbolic addresses.

These addresses will allow referencing C/C++/Rust-style global variables
by name directly.
This commit is contained in:
Dan Gohman
2017-10-27 13:27:10 -07:00
parent c2665385b1
commit 6fc45b070a
5 changed files with 48 additions and 7 deletions

View File

@@ -563,6 +563,16 @@ runtime data structures.
variable.
:result GV: Global variable.
.. inst:: GV = globalsym name
Declare a global variable at a symbolic address.
The address of GV is symbolic and will be assigned a relocation, so that
it can be resolved by a later linking phase.
:arg name: External name.
:result GV: Global variable.
.. autoinst:: global_addr

View File

@@ -36,6 +36,20 @@ ebb0:
return v1
}
function %sym() -> i32 {
gv0 = globalsym %something
; check: $gv0 = globalsym %something
gv1 = globalsym #d0bad180d0b5d182d0bed0bd
; check: $gv1 = globalsym #d0bad180d0b5d182d0bed0bd
ebb0:
v0 = global_addr.i32 gv0
; check: $v0 = global_addr.i32 $gv0
v1 = global_addr.i32 gv1
; check: $v1 = global_addr.i32 $gv1
v2 = bxor v0, v1
return v2
}
; Declare static heaps.
function %sheap(i32) -> i64 {
heap1 = static reserved_reg, min 0x1_0000, bound 0x1_0000_0000, guard 0x8000_0000