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:
Jakob Stoklund Olesen
2017-04-19 16:08:16 -07:00
parent 315c858b48
commit 832247019b
6 changed files with 11 additions and 32 deletions

View File

@@ -386,7 +386,6 @@ preamble`:
.. autoinst:: call .. autoinst:: call
.. autoinst:: x_return .. autoinst:: x_return
.. autoinst:: return_reg
This simple example illustrates direct function calls and signatures:: This simple example illustrates direct function calls and signatures::

View File

@@ -4,7 +4,7 @@ isa riscv
; regex: V=v\d+ ; regex: V=v\d+
function f(i32) { function f() {
sig0 = signature(i32) -> i32 sig0 = signature(i32) -> i32
; check: sig0 = signature(i32 [%x10]) -> i32 [%x10] ; check: sig0 = signature(i32 [%x10]) -> i32 [%x10]
@@ -27,6 +27,6 @@ function f(i32) {
sig5 = signature(i64x4) sig5 = signature(i64x4)
; check: sig5 = signature(i32 [%x10], i32 [%x11], i32 [%x12], i32 [%x13], i32 [%x14], i32 [%x15], i32 [%x16], i32 [%x17]) ; check: sig5 = signature(i32 [%x10], i32 [%x11], i32 [%x12], i32 [%x13], i32 [%x14], i32 [%x15], i32 [%x16], i32 [%x17])
ebb0(v0: i32): ebb0:
return_reg v0 return
} }

View File

@@ -15,7 +15,7 @@ ebb0(v1: i32, v2: i32):
; check: [R#10c] ; check: [R#10c]
; sameln: $v12 = imul ; sameln: $v12 = imul
return_reg v1 return
; check: [Iret#19] ; check: [Iret#19]
; sameln: return_reg ; sameln: return
} }

View File

@@ -8,5 +8,5 @@ ebb0(v1: i32, v2: i32):
v3 = iadd v1, v2 v3 = iadd v1, v2
; check: [R#0c,%x0] ; check: [R#0c,%x0]
; sameln: iadd ; sameln: iadd
return_reg v3 return
} }

View File

@@ -155,25 +155,6 @@ x_return = Instruction(
""", """,
ins=rvals, is_return=True, is_terminator=True) 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 = Operand(
'FN', 'FN',
entities.func_ref, entities.func_ref,

View File

@@ -109,9 +109,8 @@ for inst, f3 in [
RV32.enc(inst.b1, SBzero, BRANCH(f3)) RV32.enc(inst.b1, SBzero, BRANCH(f3))
RV64.enc(inst.b1, SBzero, BRANCH(f3)) RV64.enc(inst.b1, SBzero, BRANCH(f3))
# Returns are a special case of JALR. # Returns are a special case of JALR using %x1 to hold the return address.
# Note: Return stack predictors will only recognize this as a return when the # The return address is provided by a special-purpose `link` return value that
# return address is provided in `x1`. We may want a special encoding to enforce # is added by legalize_signature().
# that. RV32.enc(base.x_return, Iret, JALR())
RV32.enc(base.return_reg.i32, Iret, JALR()) RV64.enc(base.x_return, Iret, JALR())
RV64.enc(base.return_reg.i64, Iret, JALR())