mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-13 11:20:55 +08:00
RISC-V: Emit better warning for unknown CSR.
gas/ * config/tc-riscv.c (check_absolute_expr): Expand comment. New parameter maybe_csr. If maybe_csr and O_symbol, print CSR name. (riscv_ip): Add new argument to check_absolute_expr calls. * testsuite/gas/riscv/bad-csr.d: New. * testsuite/gas/riscv/bad-csr.l: New. * testsuite/gas/riscv/bad-csr.s: New.
This commit is contained in:
gas
@ -1,3 +1,12 @@
|
|||||||
|
2018-03-16 Jim Wilson <jimw@sifive.com>
|
||||||
|
|
||||||
|
* config/tc-riscv.c (check_absolute_expr): Expand comment. New
|
||||||
|
parameter maybe_csr. If maybe_csr and O_symbol, print CSR name.
|
||||||
|
(riscv_ip): Add new argument to check_absolute_expr calls.
|
||||||
|
* testsuite/gas/riscv/bad-csr.d: New.
|
||||||
|
* testsuite/gas/riscv/bad-csr.l: New.
|
||||||
|
* testsuite/gas/riscv/bad-csr.s: New.
|
||||||
|
|
||||||
2018-03-14 Kito Cheng <kito.cheng@gmail.com>
|
2018-03-14 Kito Cheng <kito.cheng@gmail.com>
|
||||||
|
|
||||||
* config/tc-riscv.c (opcode_name_list): New.
|
* config/tc-riscv.c (opcode_name_list): New.
|
||||||
|
@ -993,13 +993,18 @@ normalize_constant_expr (expressionS *ex)
|
|||||||
- 0x80000000);
|
- 0x80000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fail if an expression is not a constant. */
|
/* Fail if an expression EX is not a constant. IP is the instruction using EX.
|
||||||
|
MAYBE_CSR is true if the symbol may be an unrecognized CSR name. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_absolute_expr (struct riscv_cl_insn *ip, expressionS *ex)
|
check_absolute_expr (struct riscv_cl_insn *ip, expressionS *ex,
|
||||||
|
bfd_boolean maybe_csr)
|
||||||
{
|
{
|
||||||
if (ex->X_op == O_big)
|
if (ex->X_op == O_big)
|
||||||
as_bad (_("unsupported large constant"));
|
as_bad (_("unsupported large constant"));
|
||||||
|
else if (maybe_csr && ex->X_op == O_symbol)
|
||||||
|
as_bad (_("unknown CSR `%s'"),
|
||||||
|
S_GET_NAME (ex->X_add_symbol));
|
||||||
else if (ex->X_op != O_constant)
|
else if (ex->X_op != O_constant)
|
||||||
as_bad (_("Instruction %s requires absolute expression"),
|
as_bad (_("Instruction %s requires absolute expression"),
|
||||||
ip->insn_mo->name);
|
ip->insn_mo->name);
|
||||||
@ -1744,7 +1749,7 @@ rvc_lui:
|
|||||||
|
|
||||||
case '<': /* Shift amount, 0 - 31. */
|
case '<': /* Shift amount, 0 - 31. */
|
||||||
my_getExpression (imm_expr, s);
|
my_getExpression (imm_expr, s);
|
||||||
check_absolute_expr (ip, imm_expr);
|
check_absolute_expr (ip, imm_expr, FALSE);
|
||||||
if ((unsigned long) imm_expr->X_add_number > 31)
|
if ((unsigned long) imm_expr->X_add_number > 31)
|
||||||
as_bad (_("Improper shift amount (%lu)"),
|
as_bad (_("Improper shift amount (%lu)"),
|
||||||
(unsigned long) imm_expr->X_add_number);
|
(unsigned long) imm_expr->X_add_number);
|
||||||
@ -1755,7 +1760,7 @@ rvc_lui:
|
|||||||
|
|
||||||
case '>': /* Shift amount, 0 - (XLEN-1). */
|
case '>': /* Shift amount, 0 - (XLEN-1). */
|
||||||
my_getExpression (imm_expr, s);
|
my_getExpression (imm_expr, s);
|
||||||
check_absolute_expr (ip, imm_expr);
|
check_absolute_expr (ip, imm_expr, FALSE);
|
||||||
if ((unsigned long) imm_expr->X_add_number >= xlen)
|
if ((unsigned long) imm_expr->X_add_number >= xlen)
|
||||||
as_bad (_("Improper shift amount (%lu)"),
|
as_bad (_("Improper shift amount (%lu)"),
|
||||||
(unsigned long) imm_expr->X_add_number);
|
(unsigned long) imm_expr->X_add_number);
|
||||||
@ -1766,7 +1771,7 @@ rvc_lui:
|
|||||||
|
|
||||||
case 'Z': /* CSRRxI immediate. */
|
case 'Z': /* CSRRxI immediate. */
|
||||||
my_getExpression (imm_expr, s);
|
my_getExpression (imm_expr, s);
|
||||||
check_absolute_expr (ip, imm_expr);
|
check_absolute_expr (ip, imm_expr, FALSE);
|
||||||
if ((unsigned long) imm_expr->X_add_number > 31)
|
if ((unsigned long) imm_expr->X_add_number > 31)
|
||||||
as_bad (_("Improper CSRxI immediate (%lu)"),
|
as_bad (_("Improper CSRxI immediate (%lu)"),
|
||||||
(unsigned long) imm_expr->X_add_number);
|
(unsigned long) imm_expr->X_add_number);
|
||||||
@ -1781,7 +1786,7 @@ rvc_lui:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
my_getExpression (imm_expr, s);
|
my_getExpression (imm_expr, s);
|
||||||
check_absolute_expr (ip, imm_expr);
|
check_absolute_expr (ip, imm_expr, TRUE);
|
||||||
if ((unsigned long) imm_expr->X_add_number > 0xfff)
|
if ((unsigned long) imm_expr->X_add_number > 0xfff)
|
||||||
as_bad (_("Improper CSR address (%lu)"),
|
as_bad (_("Improper CSR address (%lu)"),
|
||||||
(unsigned long) imm_expr->X_add_number);
|
(unsigned long) imm_expr->X_add_number);
|
||||||
|
3
gas/testsuite/gas/riscv/bad-csr.d
Normal file
3
gas/testsuite/gas/riscv/bad-csr.d
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#as:
|
||||||
|
#source: bad-csr.s
|
||||||
|
#error-output: bad-csr.l
|
2
gas/testsuite/gas/riscv/bad-csr.l
Normal file
2
gas/testsuite/gas/riscv/bad-csr.l
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.*: Assembler messages:
|
||||||
|
.*: Error: unknown CSR `nonexistent'
|
1
gas/testsuite/gas/riscv/bad-csr.s
Normal file
1
gas/testsuite/gas/riscv/bad-csr.s
Normal file
@ -0,0 +1 @@
|
|||||||
|
csrr a0, nonexistent
|
Reference in New Issue
Block a user