aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorJim Wilson <jimw@sifive.com>2018-12-07 12:31:05 -0800
committerJim Wilson <jimw@sifive.com>2018-12-07 12:31:05 -0800
commitf50fabe4f66534c9addacddeaa439e8d164eadda (patch)
tree626e34486c1f82beb99131a9895c65e4c61c2ced /gas
parent8bebfcda34f2ea883fa6b87e748ad8a5f72b352f (diff)
downloadgdb-f50fabe4f66534c9addacddeaa439e8d164eadda.zip
gdb-f50fabe4f66534c9addacddeaa439e8d164eadda.tar.gz
gdb-f50fabe4f66534c9addacddeaa439e8d164eadda.tar.bz2
RISC-V: Fix 4-arg add parsing.
PR gas/23956 gas/ * config/tc-riscv.c (validate_riscv_insn) <'1'>: New case. (percent_op_null): New. (riscv_ip) <'j'>: Set imm_reloc before p. <'1'>: New case. <'0'>: Use percent_op_null and don't set imm_reloc. <alu_op>: Handle *args == '1'. * testsuite/gas/riscv/tprel-add.d: New. * testsuite/gas/riscv/tprel-add.l: New. * testsuite/gas/riscv/tprel-add.s: New. opcodes/ * riscv-opc.c (riscv_opcodes) <"add">: Use 1 not 0 for fourth arg.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog13
-rw-r--r--gas/config/tc-riscv.c15
-rw-r--r--gas/testsuite/gas/riscv/tprel-add.d3
-rw-r--r--gas/testsuite/gas/riscv/tprel-add.l4
-rw-r--r--gas/testsuite/gas/riscv/tprel-add.s11
5 files changed, 43 insertions, 3 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 72ae3bc..10eede5 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,16 @@
+2018-12-07 Jim Wilson <jimw@sifive.com>
+
+ PR gas/23956
+ * config/tc-riscv.c (validate_riscv_insn) <'1'>: New case.
+ (percent_op_null): New.
+ (riscv_ip) <'j'>: Set imm_reloc before p.
+ <'1'>: New case.
+ <'0'>: Use percent_op_null and don't set imm_reloc.
+ <alu_op>: Handle *args == '1'.
+ * testsuite/gas/riscv/tprel-add.d: New.
+ * testsuite/gas/riscv/tprel-add.l: New.
+ * testsuite/gas/riscv/tprel-add.s: New.
+
2018-12-06 Alan Modra <amodra@gmail.com>
* config/tc-ppc.c (md_assemble): Adjust relocs for VLE before
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 92ddf80..9e2035b 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -637,6 +637,7 @@ validate_riscv_insn (const struct riscv_opcode *opc, int length)
case '[': break;
case ']': break;
case '0': break;
+ case '1': break;
case 'F': /* funct */
switch (c = *p++)
{
@@ -1198,6 +1199,11 @@ static const struct percent_op_match percent_op_rtype[] =
{0, 0}
};
+static const struct percent_op_match percent_op_null[] =
+{
+ {0, 0}
+};
+
/* Return true if *STR points to a relocation operator. When returning true,
move *STR over the operator and store its relocation code in *RELOC.
Leave both *STR and *RELOC alone when returning false. */
@@ -1878,8 +1884,8 @@ rvc_lui:
continue;
case 'j': /* Sign-extended immediate. */
- *imm_reloc = BFD_RELOC_RISCV_LO12_I;
p = percent_op_itype;
+ *imm_reloc = BFD_RELOC_RISCV_LO12_I;
goto alu_op;
case 'q': /* Store displacement. */
p = percent_op_stype;
@@ -1889,9 +1895,11 @@ rvc_lui:
p = percent_op_itype;
*imm_reloc = BFD_RELOC_RISCV_LO12_I;
goto load_store;
- case '0': /* AMO "displacement," which must be zero. */
+ case '1': /* 4-operand add, must be %tprel_add. */
p = percent_op_rtype;
- *imm_reloc = BFD_RELOC_UNUSED;
+ goto alu_op;
+ case '0': /* AMO "displacement," which must be zero. */
+ p = percent_op_null;
load_store:
if (riscv_handle_implicit_zero_offset (imm_expr, s))
continue;
@@ -1904,6 +1912,7 @@ alu_op:
normalize_constant_expr (imm_expr);
if (imm_expr->X_op != O_constant
|| (*args == '0' && imm_expr->X_add_number != 0)
+ || (*args == '1')
|| imm_expr->X_add_number >= (signed)RISCV_IMM_REACH/2
|| imm_expr->X_add_number < -(signed)RISCV_IMM_REACH/2)
break;
diff --git a/gas/testsuite/gas/riscv/tprel-add.d b/gas/testsuite/gas/riscv/tprel-add.d
new file mode 100644
index 0000000..d81c1e2
--- /dev/null
+++ b/gas/testsuite/gas/riscv/tprel-add.d
@@ -0,0 +1,3 @@
+#as: -march=rv32ia
+#source tprel-add.s
+#error_output: tprel-add.l
diff --git a/gas/testsuite/gas/riscv/tprel-add.l b/gas/testsuite/gas/riscv/tprel-add.l
new file mode 100644
index 0000000..74bb535
--- /dev/null
+++ b/gas/testsuite/gas/riscv/tprel-add.l
@@ -0,0 +1,4 @@
+.*: Assembler messages:
+.*: Error: bad expression
+.*: Error: illegal operands `amoadd.w x8,x9,%tprel_add\(i\)\(x10\)'
+.*: Error: illegal operands `add a5,a5,tp,0'
diff --git a/gas/testsuite/gas/riscv/tprel-add.s b/gas/testsuite/gas/riscv/tprel-add.s
new file mode 100644
index 0000000..15d748d
--- /dev/null
+++ b/gas/testsuite/gas/riscv/tprel-add.s
@@ -0,0 +1,11 @@
+ # Don't allow tprel_add in amoadd.
+ amoadd.w x8,x9,%tprel_add(i)(x10)
+ # Do require tprel_add in 4-operand add.
+ add a5,a5,tp,0
+ .globl i
+ .section .tbss,"awT",@nobits
+ .align 2
+ .type i, @object
+ .size i, 4
+i:
+ .zero 4