diff --git a/docs/langref.rst b/docs/langref.rst index fce84d0cdf..008f2a74b1 100644 --- a/docs/langref.rst +++ b/docs/langref.rst @@ -386,7 +386,6 @@ preamble`: .. autoinst:: call .. autoinst:: x_return -.. autoinst:: return_reg This simple example illustrates direct function calls and signatures:: diff --git a/filetests/isa/riscv/abi.cton b/filetests/isa/riscv/abi.cton index d168fd768c..eba5609f3e 100644 --- a/filetests/isa/riscv/abi.cton +++ b/filetests/isa/riscv/abi.cton @@ -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 } diff --git a/filetests/isa/riscv/encoding.cton b/filetests/isa/riscv/encoding.cton index f6defe27bf..fdd3ee4329 100644 --- a/filetests/isa/riscv/encoding.cton +++ b/filetests/isa/riscv/encoding.cton @@ -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 } diff --git a/filetests/regalloc/basic.cton b/filetests/regalloc/basic.cton index 00e204f9b1..cbff589431 100644 --- a/filetests/regalloc/basic.cton +++ b/filetests/regalloc/basic.cton @@ -8,5 +8,5 @@ ebb0(v1: i32, v2: i32): v3 = iadd v1, v2 ; check: [R#0c,%x0] ; sameln: iadd - return_reg v3 + return } diff --git a/lib/cretonne/meta/base/instructions.py b/lib/cretonne/meta/base/instructions.py index a7c549ce93..3035f2b98e 100644 --- a/lib/cretonne/meta/base/instructions.py +++ b/lib/cretonne/meta/base/instructions.py @@ -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, diff --git a/lib/cretonne/meta/isa/riscv/encodings.py b/lib/cretonne/meta/isa/riscv/encodings.py index 294015b4ea..ffc848ef06 100644 --- a/lib/cretonne/meta/isa/riscv/encodings.py +++ b/lib/cretonne/meta/isa/riscv/encodings.py @@ -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())