From 5739da6d813788688df97ddae6c720c6e466068c Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 19 Aug 2013 19:30:37 +0000 Subject: gas/ * config/tc-mips.c (match_expression): Report uses of registers here. Add a "must be an immediate expression" error. Handle elided offsets here rather than... (match_int_operand): ...here. gas/testsuite/ * gas/mips/octeon-ill.l: Adjust expected output. * gas/mips/lui-1.l, gas/mips/lui-1.s: Add more cases. --- gas/config/tc-mips.c | 59 +++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 31 deletions(-) (limited to 'gas/config') diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index afa86be512..99369b9370 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -4325,37 +4325,38 @@ static bfd_boolean match_expression (struct mips_arg_info *arg, expressionS *value, bfd_reloc_code_real_type *r) { - if (arg->token->type == OT_INTEGER) + /* If the next token is a '(' that was parsed as being part of a base + expression, assume we have an elided offset. The later match will fail + if this turns out to be wrong. */ + if (arg->token->type == OT_CHAR && arg->token->u.ch == '(') { - *value = arg->token->u.integer.value; - memcpy (r, arg->token->u.integer.relocs, 3 * sizeof (*r)); - ++arg->token; + value->X_op = O_constant; + value->X_add_number = 0; + r[0] = r[1] = r[2] = BFD_RELOC_UNUSED; return TRUE; } - /* Error-reporting is more consistent if we treat registers as O_register - rather than rejecting them outright. "$1", "($1)" and "(($1))" are - then handled in the same way. */ - if (arg->token->type == OT_REG) + /* Reject register-based expressions such as "0+$2" and "(($2))". + For plain registers the default error seems more appropriate. */ + if (arg->token->type == OT_INTEGER + && arg->token->u.integer.value.X_op == O_register) { - value->X_add_number = arg->token->u.regno; - ++arg->token; + set_insn_error (arg->argnum, _("register value used as expression")); + return FALSE; } - else if (arg->token[0].type == OT_CHAR - && arg->token[0].u.ch == '(' - && arg->token[1].type == OT_REG - && arg->token[2].type == OT_CHAR - && arg->token[2].u.ch == ')') + + if (arg->token->type == OT_INTEGER) { - value->X_add_number = arg->token[1].u.regno; - arg->token += 3; + *value = arg->token->u.integer.value; + memcpy (r, arg->token->u.integer.relocs, 3 * sizeof (*r)); + ++arg->token; + return TRUE; } - else - return FALSE; - value->X_op = O_register; - r[0] = r[1] = r[2] = BFD_RELOC_UNUSED; - return TRUE; + set_insn_error_i + (arg->argnum, _("operand %d must be an immediate expression"), + arg->argnum); + return FALSE; } /* Try to get a constant expression from the next tokens in ARG. Consume @@ -4561,15 +4562,11 @@ match_int_operand (struct mips_arg_info *arg, if (arg->lax_max) max_val = ((1 << operand_base->size) - 1) << operand->shift; - if (arg->token->type == OT_CHAR && arg->token->u.ch == '(') - /* Assume we have an elided offset. The later match will fail - if this turns out to be wrong. */ - sval = 0; - else if (operand_base->lsb == 0 - && operand_base->size == 16 - && operand->shift == 0 - && operand->bias == 0 - && (operand->max_val == 32767 || operand->max_val == 65535)) + if (operand_base->lsb == 0 + && operand_base->size == 16 + && operand->shift == 0 + && operand->bias == 0 + && (operand->max_val == 32767 || operand->max_val == 65535)) { /* The operand can be relocated. */ if (!match_expression (arg, &offset_expr, offset_reloc)) -- cgit v1.2.1