Cranelift: Add instructions for getting the current stack/frame/return pointers (#4573)
* Cranelift: Add instructions for getting the current stack/frame pointers and return address This is the initial part of https://github.com/bytecodealliance/wasmtime/issues/4535 * x64: Remove `Amode::RbpOffset` and use `Amode::ImmReg` instead We just special case getting operands from `Amode`s now. * Fix s390x `get_return_address`; require `preserve_frame_pointers=true` * Assert that `Amode::ImmRegRegShift` doesn't use rbp/rsp * Handle non-allocatable registers in Amode::with_allocs * Use "stack" instead of "r15" on s390x * r14 is an allocatable register on s390x, so it shouldn't be used with `MovPReg`
This commit is contained in:
43
cranelift/filetests/filetests/isa/aarch64/fp_sp_pc.clif
Normal file
43
cranelift/filetests/filetests/isa/aarch64/fp_sp_pc.clif
Normal file
@@ -0,0 +1,43 @@
|
||||
test compile precise-output
|
||||
set preserve_frame_pointers=true
|
||||
target aarch64
|
||||
|
||||
function %fp() -> i64 {
|
||||
block0:
|
||||
v0 = get_frame_pointer.i64
|
||||
return v0
|
||||
}
|
||||
|
||||
; stp fp, lr, [sp, #-16]!
|
||||
; mov fp, sp
|
||||
; block0:
|
||||
; mov x0, fp
|
||||
; ldp fp, lr, [sp], #16
|
||||
; ret
|
||||
|
||||
function %sp() -> i64 {
|
||||
block0:
|
||||
v0 = get_stack_pointer.i64
|
||||
return v0
|
||||
}
|
||||
|
||||
; stp fp, lr, [sp, #-16]!
|
||||
; mov fp, sp
|
||||
; block0:
|
||||
; mov x0, sp
|
||||
; ldp fp, lr, [sp], #16
|
||||
; ret
|
||||
|
||||
function %return_address() -> i64 {
|
||||
block0:
|
||||
v0 = get_return_address.i64
|
||||
return v0
|
||||
}
|
||||
|
||||
; stp fp, lr, [sp, #-16]!
|
||||
; mov fp, sp
|
||||
; block0:
|
||||
; mov x0, lr
|
||||
; ldp fp, lr, [sp], #16
|
||||
; ret
|
||||
|
||||
Reference in New Issue
Block a user