See #144 for discussion. - Add a new GlobalVar entity type both in Python and Rust. - Define a UnaryGlobalVar instruction format containing a GlobalVar reference. - Add a globalvar.rs module defining the GlobalVarData with support for 'vmctx' and 'deref' global variable kinds. Langref: Add a section about global variables and the global_addr instruction. Parser: Add support for the UnaryGlobalVar instruction format as well as global variable declarations in the preamble.
38 lines
743 B
Plaintext
38 lines
743 B
Plaintext
test cat
|
|
test verifier
|
|
|
|
function %vmglobal() -> i32 {
|
|
gv3 = vmctx+16
|
|
; check: $gv3 = vmctx+16
|
|
gv4 = vmctx+0
|
|
; check: $gv4 = vmctx
|
|
; not: +0
|
|
gv5 = vmctx -256
|
|
; check: $gv5 = vmctx-256
|
|
ebb0:
|
|
v1 = global_addr.i32 gv3
|
|
; check: $v1 = global_addr.i32 $gv3
|
|
return v1
|
|
}
|
|
|
|
function %deref() -> i32 {
|
|
gv3 = vmctx+16
|
|
gv4 = deref(gv3)-32
|
|
; check: $gv4 = deref($gv3)-32
|
|
ebb0:
|
|
v1 = global_addr.i32 gv4
|
|
; check: $v1 = global_addr.i32 $gv4
|
|
return v1
|
|
}
|
|
|
|
; Refer to a global variable before it's been declared.
|
|
function %backref() -> i32 {
|
|
gv1 = deref(gv2)-32
|
|
; check: $gv1 = deref($gv2)-32
|
|
gv2 = vmctx+16
|
|
; check: $gv2 = vmctx+16
|
|
ebb0:
|
|
v1 = global_addr.i32 gv1
|
|
return v1
|
|
}
|