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:
Nick Fitzgerald
2022-08-02 14:37:17 -07:00
committed by GitHub
parent 6b4e6523f7
commit 42bba452a6
28 changed files with 484 additions and 24 deletions

View File

@@ -1296,6 +1296,43 @@ pub(crate) fn define(
.other_side_effects(true),
);
ig.push(
Inst::new(
"get_frame_pointer",
r#"
Get the address in the frame pointer register.
Usage of this instruction requires setting `preserve_frame_pointers` to `true`.
"#,
&formats.nullary,
)
.operands_out(vec![addr]),
);
ig.push(
Inst::new(
"get_stack_pointer",
r#"
Get the address in the stack pointer register.
"#,
&formats.nullary,
)
.operands_out(vec![addr]),
);
ig.push(
Inst::new(
"get_return_address",
r#"
Get the PC where this function will transfer control to when it returns.
Usage of this instruction requires setting `preserve_frame_pointers` to `true`.
"#,
&formats.nullary,
)
.operands_out(vec![addr]),
);
let TableOffset = &TypeVar::new(
"TableOffset",
"An unsigned table offset",