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:
@@ -165,6 +165,12 @@
|
||||
(rd WritableReg)
|
||||
(rm Reg))
|
||||
|
||||
;; Like `Move` but with a particular `PReg` source (for implementing CLIF
|
||||
;; instructions like `get_stack_pointer`).
|
||||
(MovPReg
|
||||
(rd WritableReg)
|
||||
(rm PReg))
|
||||
|
||||
;; A MOV[Z,N,K] with a 16-bit immediate.
|
||||
(MovWide
|
||||
(op MoveWideOp)
|
||||
@@ -2421,3 +2427,31 @@
|
||||
;; And finally, copy the preordained AtomicCASLoop output reg to its destination.
|
||||
;; Also, x24 and x28 are trashed.
|
||||
(mov64_from_real 27)))
|
||||
|
||||
;; Helper for emitting `MInst.MovPReg` instructions.
|
||||
(decl mov_preg (PReg) Reg)
|
||||
(rule (mov_preg src)
|
||||
(let ((dst WritableReg (temp_writable_reg $I64))
|
||||
(_ Unit (emit (MInst.MovPReg dst src))))
|
||||
dst))
|
||||
|
||||
(decl preg_sp () PReg)
|
||||
(extern constructor preg_sp preg_sp)
|
||||
|
||||
(decl preg_fp () PReg)
|
||||
(extern constructor preg_fp preg_fp)
|
||||
|
||||
(decl preg_link () PReg)
|
||||
(extern constructor preg_link preg_link)
|
||||
|
||||
(decl aarch64_sp () Reg)
|
||||
(rule (aarch64_sp)
|
||||
(mov_preg (preg_sp)))
|
||||
|
||||
(decl aarch64_fp () Reg)
|
||||
(rule (aarch64_fp)
|
||||
(mov_preg (preg_fp)))
|
||||
|
||||
(decl aarch64_link () Reg)
|
||||
(rule (aarch64_link)
|
||||
(mov_preg (preg_link)))
|
||||
|
||||
Reference in New Issue
Block a user