Define stack_load, stack_store, and stack_addr instructions.
This commit is contained in:
@@ -489,33 +489,8 @@ simply represent a contiguous sequence of bytes in the stack frame.
|
||||
:flag align(N): Request at least N bytes alignment.
|
||||
:result SS: Stack slot index.
|
||||
|
||||
.. inst:: a = stack_load SS, Offset
|
||||
|
||||
Load a value from a stack slot at the constant offset.
|
||||
|
||||
This is a polymorphic instruction that can load any value type which has a
|
||||
memory representation.
|
||||
|
||||
The offset is an immediate constant, not an SSA value. The memory access
|
||||
cannot go out of bounds, i.e. ``sizeof(a) + Offset <= sizeof(SS)``.
|
||||
|
||||
:arg SS: Stack slot declared with :inst:`stack_slot`.
|
||||
:arg Offset: Immediate non-negative offset.
|
||||
:result T a: Value loaded.
|
||||
|
||||
.. inst:: stack_store x, SS, Offset
|
||||
|
||||
Store a value to a stack slot at a constant offset.
|
||||
|
||||
This is a polymorphic instruction that can store any value type with a
|
||||
memory representation.
|
||||
|
||||
The offset is an immediate constant, not an SSA value. The memory access
|
||||
cannot go out of bounds, i.e. ``sizeof(a) + Offset <= sizeof(SS)``.
|
||||
|
||||
:arg T x: Value to be stored.
|
||||
:arg SS: Stack slot declared with :inst:`stack_slot`.
|
||||
:arg Offset: Immediate non-negative offset.
|
||||
.. autoinst:: stack_load
|
||||
.. autoinst:: stack_store
|
||||
|
||||
The dedicated stack access instructions are easy for the compiler to reason
|
||||
about because stack slots and offsets are fixed at compile time. For example,
|
||||
@@ -525,16 +500,7 @@ and stack slot alignments.
|
||||
It can be necessary to escape from the safety of the restricted instructions by
|
||||
taking the address of a stack slot.
|
||||
|
||||
.. inst:: a = stack_addr SS, Offset
|
||||
|
||||
Get the address of a stack slot.
|
||||
|
||||
Compute the absolute address of a byte in a stack slot. The offset must
|
||||
refer to a byte inside the stack slot: ``0 <= Offset < sizeof(SS)``.
|
||||
|
||||
:arg SS: Stack slot declared with :inst:`stack_slot`.
|
||||
:arg Offset: Immediate non-negative offset.
|
||||
:result iPtr a: Address.
|
||||
.. autoinst:: stack_addr
|
||||
|
||||
The :inst:`stack_addr` instruction can be used to macro-expand the stack access
|
||||
instructions before instruction selection::
|
||||
|
||||
@@ -93,3 +93,24 @@ ebb0(vx0: i32, vx1: f32):
|
||||
; nextln: v0 = bitcast.i8x4 vx0
|
||||
; nextln: v1 = bitcast.i32 vx1
|
||||
; nextln: }
|
||||
|
||||
; Stack slot references
|
||||
function stack() {
|
||||
ss10 = stack_slot 8
|
||||
ss2 = stack_slot 4
|
||||
|
||||
ebb0:
|
||||
v1 = stack_load.i32 ss10
|
||||
v2 = stack_load.i32 ss10+4
|
||||
stack_store v1, ss10+2
|
||||
stack_store v2, ss2
|
||||
}
|
||||
; sameln: function stack() {
|
||||
; nextln: $ss10 = stack_slot 8
|
||||
; nextln: $ss2 = stack_slot 4
|
||||
|
||||
; check: ebb0:
|
||||
; nextln: $v1 = stack_load.i32 $ss10
|
||||
; nextln: $v2 = stack_load.i32 $ss10+4
|
||||
; nextln: stack_store $v1, $ss10+2
|
||||
; nextln: stack_store $v2, $ss2
|
||||
|
||||
Reference in New Issue
Block a user