aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2013-08-19 19:30:37 +0000
committerRichard Sandiford <rdsandiford@googlemail.com>2013-08-19 19:30:37 +0000
commitd436c1c2e8898405f7d58660baac71798f9fc90a (patch)
tree66e485d8d6b0cd67a6690cfcb21021cb94d9c5ff /gas
parent1a00e61226b3ff5d9be22992b7c4bf15bda6edb2 (diff)
downloadgdb-d436c1c2e8898405f7d58660baac71798f9fc90a.zip
gdb-d436c1c2e8898405f7d58660baac71798f9fc90a.tar.gz
gdb-d436c1c2e8898405f7d58660baac71798f9fc90a.tar.bz2
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.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog7
-rw-r--r--gas/config/tc-mips.c59
-rw-r--r--gas/testsuite/ChangeLog5
-rw-r--r--gas/testsuite/gas/mips/lui-1.l5
-rw-r--r--gas/testsuite/gas/mips/lui-1.s3
-rw-r--r--gas/testsuite/gas/mips/octeon-ill.l8
6 files changed, 51 insertions, 36 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index d6ab086..397a538 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,12 @@
2013-08-19 Richard Sandiford <rdsandiford@googlemail.com>
+ * 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.
+
+2013-08-19 Richard Sandiford <rdsandiford@googlemail.com>
+
* config/tc-mips.c (mips_arg_info): Remove soft_match.
(match_out_of_range, match_not_constant): New functions.
(match_const_int): Remove fallback parameter and check for soft_match.
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index afa86be..99369b9 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))
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index 128facd..03e804a 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2013-08-19 Richard Sandiford <rdsandiford@googlemail.com>
+ * gas/mips/octeon-ill.l: Adjust expected output.
+ * gas/mips/lui-1.l, gas/mips/lui-1.s: Add more cases.
+
+2013-08-19 Richard Sandiford <rdsandiford@googlemail.com>
+
* gas/mips/ext-ill.l, gas/mips/lui-1.l, gas/mips/mips16e-64.l,
gas/mips/mips32r2-ill-fp64.l, gas/mips/mips32r2-ill-nofp.l,
gas/mips/mips32r2-ill.l, gas/mips/mips64r2-ill.l,
diff --git a/gas/testsuite/gas/mips/lui-1.l b/gas/testsuite/gas/mips/lui-1.l
index d2f0c2d..2cabcb9 100644
--- a/gas/testsuite/gas/mips/lui-1.l
+++ b/gas/testsuite/gas/mips/lui-1.l
@@ -2,4 +2,7 @@
.*\.s:5: Error: operand 2 out of range `lui \$2,-1'
.*\.s:6: Error: operand 2 out of range `lui \$2,65536'
.*\.s:7: Error: bignum invalid
-.*\.s:8: Error: register value used as expression
+.*\.s:8: Error: operand 2 must be an immediate expression `lui \$2,\$3'
+.*\.s:9: Error: Illegal operands `lui \$2,\(\$3\)'
+.*\.s:10: Error: register value used as expression `lui \$2,0\+\$3'
+.*\.s:11: Error: register value used as expression `lui \$2,\(\(\$3\)\)'
diff --git a/gas/testsuite/gas/mips/lui-1.s b/gas/testsuite/gas/mips/lui-1.s
index 226b005..d4b6590 100644
--- a/gas/testsuite/gas/mips/lui-1.s
+++ b/gas/testsuite/gas/mips/lui-1.s
@@ -6,3 +6,6 @@ foo:
lui $2, 65536
lui $2, 0x10000000000000000
lui $2, $3
+ lui $2, ($3)
+ lui $2, 0+$3
+ lui $2, (($3))
diff --git a/gas/testsuite/gas/mips/octeon-ill.l b/gas/testsuite/gas/mips/octeon-ill.l
index 1664e31..ef98b77 100644
--- a/gas/testsuite/gas/mips/octeon-ill.l
+++ b/gas/testsuite/gas/mips/octeon-ill.l
@@ -30,10 +30,10 @@
.*:43: Error: Opcode not supported on this processor.*
.*:45: Error: operand 2 out of range `dmfc2 \$2,0x10000'
.*:46: Error: operand 2 out of range `dmtc2 \$2,0x12345'
-.*:47: Error: operand 2 must be constant `dmfc2 \$9,\$12'
-.*:48: Error: operand 2 must be constant `dmfc2 \$4,\$15,4'
-.*:49: Error: operand 2 must be constant `dmtc2 \$16,\$8'
-.*:50: Error: operand 2 must be constant `dmtc2 \$22,\$7,\$4'
+.*:47: Error: operand 2 must be an immediate expression `dmfc2 \$9,\$12'
+.*:48: Error: operand 2 must be an immediate expression `dmfc2 \$4,\$15,4'
+.*:49: Error: operand 2 must be an immediate expression `dmtc2 \$16,\$8'
+.*:50: Error: operand 2 must be an immediate expression `dmtc2 \$22,\$7,\$4'
.*:52: Error: operand 3 out of range `exts \$26,26,32'
.*:54: Error: operand 3 out of range `exts32 \$7,\$21,32,10'
.*:55: Error: operand 4 out of range `exts32 \$31,\$13,3,29'