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:
@@ -21,6 +21,7 @@ use crate::{
|
||||
isa::unwind::UnwindInst,
|
||||
machinst::{InsnOutput, LowerCtx, VCodeConstant, VCodeConstantData},
|
||||
};
|
||||
use regalloc2::PReg;
|
||||
use std::boxed::Box;
|
||||
use std::cell::Cell;
|
||||
use std::convert::TryFrom;
|
||||
@@ -603,6 +604,11 @@ where
|
||||
MemArg::reg_plus_off(stack_reg(), base + off, MemFlags::trusted())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn memarg_initial_sp_offset(&mut self, off: i64) -> MemArg {
|
||||
MemArg::InitialSPOffset { off }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn memarg_symbol(&mut self, name: ExternalName, offset: i32, flags: MemFlags) -> MemArg {
|
||||
MemArg::Symbol {
|
||||
@@ -670,6 +676,11 @@ where
|
||||
fn emit(&mut self, inst: &MInst) -> Unit {
|
||||
self.lower_ctx.emit(inst.clone());
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn preg_stack(&mut self) -> PReg {
|
||||
stack_reg().to_real_reg().unwrap().into()
|
||||
}
|
||||
}
|
||||
|
||||
/// Zero-extend the low `from_bits` bits of `value` to a full u64.
|
||||
|
||||
Reference in New Issue
Block a user