Custom legalization for global_addr.
The code to compute the address of a global variable depends on the kind of variable, so custom legalization is required. - Add a legalizer::globalvar module which exposes an expand_global_addr() function. This module is likely to grow as we add more types of global variables. - Add a ArgumentPurpose::VMContext enumerator. This is used to represent special 'vmctx' arguments that are used as base pointers for vmctx globals.
This commit is contained in:
@@ -373,7 +373,7 @@ calling convention:
|
||||
retlist : arglist
|
||||
arg : type [argext] [argspecial]
|
||||
argext : "uext" | "sext"
|
||||
argspecial: "sret" | "link" | "fp" | "csr"
|
||||
argspecial: "sret" | "link" | "fp" | "csr" | "vmctx"
|
||||
callconv : `string`
|
||||
|
||||
Arguments and return values have flags whose meaning is mostly target
|
||||
|
||||
29
cranelift/filetests/isa/intel/legalize-memory.cton
Normal file
29
cranelift/filetests/isa/intel/legalize-memory.cton
Normal file
@@ -0,0 +1,29 @@
|
||||
; Test the legalization of memory objects.
|
||||
test legalizer
|
||||
set is_64bit
|
||||
isa intel
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function %vmctx(i64 vmctx) -> i64 {
|
||||
gv1 = vmctx-16
|
||||
|
||||
ebb1(v1: i64):
|
||||
v2 = global_addr.i64 gv1
|
||||
; check: $v2 = iadd_imm $v1, -16
|
||||
return v2
|
||||
; check: return $v2
|
||||
}
|
||||
|
||||
function %deref(i64 vmctx) -> i64 {
|
||||
gv1 = vmctx-16
|
||||
gv2 = deref(gv1)+32
|
||||
|
||||
ebb1(v1: i64):
|
||||
v2 = global_addr.i64 gv2
|
||||
; check: $(a1=$V) = iadd_imm $v1, -16
|
||||
; check: $(p1=$V) = load.i64 $a1
|
||||
; check: $v2 = iadd_imm $p1, 32
|
||||
return v2
|
||||
; check: return $v2
|
||||
}
|
||||
Reference in New Issue
Block a user