Remove the return_reg instruction.
RISC architectures that take a return address in a register can use a special-purpose `link` return value to do so.
This commit is contained in:
@@ -386,7 +386,6 @@ preamble`:
|
||||
|
||||
.. autoinst:: call
|
||||
.. autoinst:: x_return
|
||||
.. autoinst:: return_reg
|
||||
|
||||
This simple example illustrates direct function calls and signatures::
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ isa riscv
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function f(i32) {
|
||||
function f() {
|
||||
sig0 = signature(i32) -> i32
|
||||
; check: sig0 = signature(i32 [%x10]) -> i32 [%x10]
|
||||
|
||||
@@ -27,6 +27,6 @@ function f(i32) {
|
||||
sig5 = signature(i64x4)
|
||||
; check: sig5 = signature(i32 [%x10], i32 [%x11], i32 [%x12], i32 [%x13], i32 [%x14], i32 [%x15], i32 [%x16], i32 [%x17])
|
||||
|
||||
ebb0(v0: i32):
|
||||
return_reg v0
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ ebb0(v1: i32, v2: i32):
|
||||
; check: [R#10c]
|
||||
; sameln: $v12 = imul
|
||||
|
||||
return_reg v1
|
||||
return
|
||||
; check: [Iret#19]
|
||||
; sameln: return_reg
|
||||
; sameln: return
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ ebb0(v1: i32, v2: i32):
|
||||
v3 = iadd v1, v2
|
||||
; check: [R#0c,%x0]
|
||||
; sameln: iadd
|
||||
return_reg v3
|
||||
return
|
||||
}
|
||||
|
||||
@@ -155,25 +155,6 @@ x_return = Instruction(
|
||||
""",
|
||||
ins=rvals, is_return=True, is_terminator=True)
|
||||
|
||||
raddr = Operand('raddr', iAddr, doc='Return address')
|
||||
|
||||
return_reg = Instruction(
|
||||
'return_reg', r"""
|
||||
Return from the function to a return address held in a register.
|
||||
|
||||
Unconditionally transfer control to the calling function, passing the
|
||||
provided return values. The list of return values must match the
|
||||
function signature's return types.
|
||||
|
||||
This instruction should only be used by ISA-specific epilogue lowering
|
||||
code. It is equivalent to :inst:`return`, but the return address is
|
||||
provided explicitly in a register. This style of return instruction is
|
||||
used by RISC architectures such as ARM and RISC-V. A normal
|
||||
:inst:`return` will be legalized into this instruction on these
|
||||
architectures.
|
||||
""",
|
||||
ins=(raddr, rvals), is_return=True, is_terminator=True)
|
||||
|
||||
FN = Operand(
|
||||
'FN',
|
||||
entities.func_ref,
|
||||
|
||||
@@ -109,9 +109,8 @@ for inst, f3 in [
|
||||
RV32.enc(inst.b1, SBzero, BRANCH(f3))
|
||||
RV64.enc(inst.b1, SBzero, BRANCH(f3))
|
||||
|
||||
# Returns are a special case of JALR.
|
||||
# Note: Return stack predictors will only recognize this as a return when the
|
||||
# return address is provided in `x1`. We may want a special encoding to enforce
|
||||
# that.
|
||||
RV32.enc(base.return_reg.i32, Iret, JALR())
|
||||
RV64.enc(base.return_reg.i64, Iret, JALR())
|
||||
# Returns are a special case of JALR using %x1 to hold the return address.
|
||||
# The return address is provided by a special-purpose `link` return value that
|
||||
# is added by legalize_signature().
|
||||
RV32.enc(base.x_return, Iret, JALR())
|
||||
RV64.enc(base.x_return, Iret, JALR())
|
||||
|
||||
Reference in New Issue
Block a user