Browse Source

binutils: rework jump pseudoisntruction

"jump" was renamed to "tail" (as in tail call) and may freely clobber a
t-register, as before.  A new "jump" was added that requires a second
argument, which is the scratch register it may clobber.

"tail" should be used for tail calls; "jump" should be used for
intraprocedural jumps more than 1 MiB away.
pull/94/head
Andrew Waterman 11 years ago
parent
commit
54ebdae379
  1. 17
      binutils/gas/config/tc-riscv.c
  2. 1
      binutils/include/opcode/riscv.h
  3. 5
      binutils/opcodes/riscv-opc.c
  4. 12
      gcc/gcc/config/riscv/riscv.md
  5. 2
      glibc/sysdeps/riscv/start.S
  6. 2
      newlib/libgloss/riscv/crt0.S

17
binutils/gas/config/tc-riscv.c

@ -935,13 +935,10 @@ load_const (int reg, expressionS *ep)
static void
macro (struct riscv_cl_insn *ip)
{
unsigned int rd, rs1, rs2;
int mask;
rd = (ip->insn_opcode >> OP_SH_RD) & OP_MASK_RD;
rs1 = (ip->insn_opcode >> OP_SH_RS1) & OP_MASK_RS1;
rs2 = (ip->insn_opcode >> OP_SH_RS2) & OP_MASK_RS2;
mask = ip->insn_mo->mask;
int rd = (ip->insn_opcode >> OP_SH_RD) & OP_MASK_RD;
int rs1 = (ip->insn_opcode >> OP_SH_RS1) & OP_MASK_RS1;
int rs2 = (ip->insn_opcode >> OP_SH_RS2) & OP_MASK_RS2;
int mask = ip->insn_mo->mask;
switch (mask)
{
@ -1055,13 +1052,7 @@ macro (struct riscv_cl_insn *ip)
BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_S);
break;
case M_JUMP:
rd = 0;
goto do_call;
case M_CALL:
rd = X_RA;
do_call:
rs1 = reg_lookup_assert ("t0", RCLASS_GPR);
riscv_call (rd, rs1, &offset_expr, offset_reloc);
break;

1
binutils/include/opcode/riscv.h

@ -297,7 +297,6 @@ enum
M_FSW,
M_FSD,
M_CALL,
M_JUMP,
M_J,
M_LI,
M_VF,

5
binutils/opcodes/riscv-opc.c

@ -175,8 +175,9 @@ const struct riscv_opcode riscv_builtin_opcodes[] =
{"j", "I", "a", MATCH_JAL, MASK_JAL | MASK_RD, match_opcode, INSN_ALIAS },
{"jal", "I", "a", MATCH_JAL | (X_RA << OP_SH_RD), MASK_JAL | MASK_RD, match_opcode, INSN_ALIAS|WR_xd },
{"jal", "I", "d,a", MATCH_JAL, MASK_JAL, match_opcode, WR_xd },
{"call", "I", "c", 0, (int) M_CALL, match_never, INSN_MACRO },
{"jump", "I", "c", 0, (int) M_JUMP, match_never, INSN_MACRO },
{"call", "I", "c", (X_T0 << OP_SH_RS1) | (X_RA << OP_SH_RD), (int) M_CALL, match_never, INSN_MACRO },
{"tail", "I", "c", (X_T0 << OP_SH_RS1), (int) M_CALL, match_never, INSN_MACRO },
{"jump", "I", "c,s", 0, (int) M_CALL, match_never, INSN_MACRO },
{"jr", "I", "s", MATCH_JALR, MASK_JALR | MASK_RD | MASK_IMM, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 },
{"jr", "I", "s,j", MATCH_JALR, MASK_JALR | MASK_RD, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 },
{"jalr", "I", "s", MATCH_JALR | (X_RA << OP_SH_RD), MASK_JALR | MASK_RD | MASK_IMM, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 },

12
gcc/gcc/config/riscv/riscv.md

@ -2286,8 +2286,8 @@
(match_operand 1 "" ""))]
"SIBLING_CALL_P (insn)"
{ return REG_P (operands[0]) ? "jr\t%0"
: absolute_symbolic_operand (operands[0], VOIDmode) ? "jump\t%0"
: "jump\t%0@"; }
: absolute_symbolic_operand (operands[0], VOIDmode) ? "tail\t%0"
: "tail\t%0@"; }
[(set_attr "type" "call")])
(define_expand "sibcall_value"
@ -2307,8 +2307,8 @@
(match_operand 2 "" "")))]
"SIBLING_CALL_P (insn)"
{ return REG_P (operands[1]) ? "jr\t%1"
: absolute_symbolic_operand (operands[1], VOIDmode) ? "jump\t%1"
: "jump\t%1@"; }
: absolute_symbolic_operand (operands[1], VOIDmode) ? "tail\t%1"
: "tail\t%1@"; }
[(set_attr "type" "call")])
(define_insn "sibcall_value_multiple_internal"
@ -2321,8 +2321,8 @@
(clobber (match_scratch:SI 4 "=j,j"))]
"SIBLING_CALL_P (insn)"
{ return REG_P (operands[1]) ? "jr\t%1"
: absolute_symbolic_operand (operands[1], VOIDmode) ? "jump\t%1"
: "jump\t%1@"; }
: absolute_symbolic_operand (operands[1], VOIDmode) ? "tail\t%1"
: "tail\t%1@"; }
[(set_attr "type" "call")])
(define_expand "call"

2
glibc/sysdeps/riscv/start.S

@ -55,7 +55,7 @@ ENTRY(ENTRY_POINT)
lla a4, __libc_csu_fini
move a6, sp /* stack_end */
jump __libc_start_main@
tail __libc_start_main@
END(ENTRY_POINT)
/* Define a symbol for the first piece of initialized data. */

2
newlib/libgloss/riscv/crt0.S

@ -28,7 +28,7 @@ _start:
addi a1, sp, _RISCV_SZPTR/8 # a1 = argv
li a2, 0 # a2 = envp = NULL
call main
jump exit
tail exit
.global _init
.global _fini

Loading…
Cancel
Save