diff options
author | Claudiu Zissulescu <claziss@gmail.com> | 2020-07-07 16:01:48 +0300 |
---|---|---|
committer | Claudiu Zissulescu <claziss@gmail.com> | 2020-07-07 16:01:48 +0300 |
commit | 3128916d88bf1bf0e4688de1529f481d57bd331a (patch) | |
tree | b3e31e1ca4c79c195d189f04196b1b4e42c60ad0 /gas/config | |
parent | f337259fbd5ee31c6794158457dcd0d23e5c0f13 (diff) | |
download | gdb-3128916d88bf1bf0e4688de1529f481d57bd331a.zip gdb-3128916d88bf1bf0e4688de1529f481d57bd331a.tar.gz gdb-3128916d88bf1bf0e4688de1529f481d57bd331a.tar.bz2 |
arc: Improve error messages when assembling
gas/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* config/tc-arc.c (find_opcode_match): Add error messages.
* testsuite/gas/arc/add_s-err.s: Update test.
* testsuite/gas/arc/asm-errors.err: Likewise.
* testsuite/gas/arc/cpu-em-err.s: Likewise.
* testsuite/gas/arc/hregs-err.s: Likewise.
* testsuite/gas/arc/warn.s: Likewise.
Diffstat (limited to 'gas/config')
-rw-r--r-- | gas/config/tc-arc.c | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c index f8d469c..0a22d38 100644 --- a/gas/config/tc-arc.c +++ b/gas/config/tc-arc.c @@ -1758,8 +1758,9 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry, int ntok = *pntok; int got_cpu_match = 0; expressionS bktok[MAX_INSN_ARGS]; - int bkntok; + int bkntok, maxerridx = 0; expressionS emptyE; + const char *tmpmsg = NULL; arc_opcode_hash_entry_iterator_init (&iter); memset (&emptyE, 0, sizeof (emptyE)); @@ -1806,7 +1807,7 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry, { case ARC_OPERAND_ADDRTYPE: { - *errmsg = NULL; + tmpmsg = NULL; /* Check to be an address type. */ if (tok[tokidx].X_op != O_addrtype) @@ -1817,8 +1818,8 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry, address type. */ gas_assert (operand->insert != NULL); (*operand->insert) (0, tok[tokidx].X_add_number, - errmsg); - if (*errmsg != NULL) + &tmpmsg); + if (tmpmsg != NULL) goto match_failed; } break; @@ -1844,11 +1845,11 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry, /* Special handling? */ if (operand->insert) { - *errmsg = NULL; + tmpmsg = NULL; (*operand->insert)(0, regno (tok[tokidx].X_add_number), - errmsg); - if (*errmsg) + &tmpmsg); + if (tmpmsg) { if (operand->flags & ARC_OPERAND_IGNORE) { @@ -1957,26 +1958,35 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry, } if (val < min || val > max) - goto match_failed; + { + tmpmsg = _("immediate is out of bounds"); + goto match_failed; + } /* Check alignments. */ if ((operand->flags & ARC_OPERAND_ALIGNED32) && (val & 0x03)) - goto match_failed; + { + tmpmsg = _("immediate is not 32bit aligned"); + goto match_failed; + } if ((operand->flags & ARC_OPERAND_ALIGNED16) && (val & 0x01)) - goto match_failed; + { + tmpmsg = _("immediate is not 16bit aligned"); + goto match_failed; + } } else if (operand->flags & ARC_OPERAND_NCHK) { if (operand->insert) { - *errmsg = NULL; + tmpmsg = NULL; (*operand->insert)(0, tok[tokidx].X_add_number, - errmsg); - if (*errmsg) + &tmpmsg); + if (tmpmsg) goto match_failed; } else if (!(operand->flags & ARC_OPERAND_IGNORE)) @@ -1997,11 +2007,11 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry, regs |= get_register (tok[tokidx].X_op_symbol); if (operand->insert) { - *errmsg = NULL; + tmpmsg = NULL; (*operand->insert)(0, regs, - errmsg); - if (*errmsg) + &tmpmsg); + if (tmpmsg) goto match_failed; } else @@ -2044,7 +2054,11 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry, || t->X_op == O_absent || t->X_op == O_register || (t->X_add_number != tok[tokidx].X_add_number)) - goto match_failed; + { + tmpmsg = _("operand is not duplicate of the " + "previous one"); + goto match_failed; + } } t = &tok[tokidx]; break; @@ -2060,7 +2074,10 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry, /* Setup ready for flag parsing. */ if (!parse_opcode_flags (opcode, nflgs, first_pflag)) - goto match_failed; + { + tmpmsg = _("flag mismatch"); + goto match_failed; + } pr_debug ("flg"); /* Possible match -- did we use all of our input? */ @@ -2070,12 +2087,19 @@ find_opcode_match (const struct arc_opcode_hash_entry *entry, pr_debug ("\n"); return opcode; } + tmpmsg = _("too many arguments"); match_failed:; pr_debug ("\n"); /* Restore the original parameters. */ memcpy (tok, bktok, MAX_INSN_ARGS * sizeof (*tok)); ntok = bkntok; + if (tokidx >= maxerridx + && tmpmsg) + { + maxerridx = tokidx; + *errmsg = tmpmsg; + } } if (*pcpumatch) |