diff options
author | Jim Wilson <jimw@sifive.com> | 2018-12-07 12:31:05 -0800 |
---|---|---|
committer | Jim Wilson <jimw@sifive.com> | 2018-12-07 12:31:05 -0800 |
commit | f50fabe4f66534c9addacddeaa439e8d164eadda (patch) | |
tree | 626e34486c1f82beb99131a9895c65e4c61c2ced /gas/config/tc-riscv.c | |
parent | 8bebfcda34f2ea883fa6b87e748ad8a5f72b352f (diff) | |
download | gdb-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/config/tc-riscv.c')
-rw-r--r-- | gas/config/tc-riscv.c | 15 |
1 files changed, 12 insertions, 3 deletions
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; |