This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb/binutils-2_28-branch] RISC-V: Change CALL macro to use ra as the temporary address register
- From: Palmer Dabbelt <palmer at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 5 May 2017 18:35:23 -0000
- Subject: [binutils-gdb/binutils-2_28-branch] RISC-V: Change CALL macro to use ra as the temporary address register
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1e46401a6a0a1aab4865fd5e0d775c09d75215ca
commit 1e46401a6a0a1aab4865fd5e0d775c09d75215ca
Author: Michael Clark <michaeljclark@mac.com>
Date: Thu Apr 27 16:08:46 2017 +1200
RISC-V: Change CALL macro to use ra as the temporary address register
e.g.
1: auipc ra, %pcrel_hi(symbol)
jalr ra, %pcrel_lo(1b)(ra)
The use of ra instead of t1 for address construction provides an
opportunity for a microarchitecture to elide the write of the
destination address, and instead read the target address as an
immediate spread across the fused auipc+jalr pair. The link
register ra in the jalr overwrites the target address temporary.
Diff:
---
opcodes/ChangeLog | 5 +++++
opcodes/riscv-opc.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 2a5410a..5dfe166 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-01 Michael Clark <michaeljclark@mac.com>
+
+ * riscv-opc.c (riscv_opcodes) <call>: Use RA not T1 as a temporary
+ register.
+
2017-04-03 Palmer Dabbelt <palmer@dabbelt.com>
* riscv-dis.c (riscv_disassemble_insn): Change "_gp" to
diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c
index 2b18a1e..8343198 100644
--- a/opcodes/riscv-opc.c
+++ b/opcodes/riscv-opc.c
@@ -147,7 +147,7 @@ const struct riscv_opcode riscv_opcodes[] =
{"jal", "32C", "Ca", MATCH_C_JAL, MASK_C_JAL, match_opcode, INSN_ALIAS },
{"jal", "I", "a", MATCH_JAL | (X_RA << OP_SH_RD), MASK_JAL | MASK_RD, match_opcode, INSN_ALIAS },
{"call", "I", "d,c", (X_T1 << OP_SH_RS1), (int) M_CALL, match_never, INSN_MACRO },
-{"call", "I", "c", (X_T1 << OP_SH_RS1) | (X_RA << OP_SH_RD), (int) M_CALL, match_never, INSN_MACRO },
+{"call", "I", "c", (X_RA << OP_SH_RS1) | (X_RA << OP_SH_RD), (int) M_CALL, match_never, INSN_MACRO },
{"tail", "I", "c", (X_T1 << OP_SH_RS1), (int) M_CALL, match_never, INSN_MACRO },
{"jump", "I", "c,s", 0, (int) M_CALL, match_never, INSN_MACRO },
{"nop", "C", "", MATCH_C_ADDI, 0xffff, match_opcode, INSN_ALIAS },