This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: mipsisa32-unknown-elf-as: Error: too large constant specified
Thiemo Seufer wrote:
[snip]
> > Ian wrote:
> >
> > >With the patch I sent out, code like this will assemble without a
> > >warning on a 32-bit target:
> > > and $2, $2, 0xffffffffe0000000
> > >which is somewhat dubious.
> > >
> >
> >
> > Oh I don't know - that's a valid 32-bit immediate with 64-bit sign
> > extension. The more ugly thing is that it would allow:
> >
> > and $2,$2,0xffffffff1f000000
> >
> > But I'm prepared to look the other way if you are. :-)
>
> Another example is
>
> ld $2, 0xffffffff1fffffff
>
> , where it silently discards the upper 32 bits. This is the reason
> why I disallowed it. It never occured to me the complement operator
> would produce such a result. :-)
>
> IMHO the right solution is to fix these 32 bit values after each
> call of my_getExpression().
Well, that's my take of it.
Thiemo
2003-10-15 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
/gas/ChangeLog
* config/tc-mips.c (check_absolute_expr): Unset high bits set by
32/64 bit unaware gas expression evaluation.
(mips_ip): Use check_absolute_expr.
diff -aurpNX /bigdisk/src/gcc-exclude source-orig/gas/config/tc-mips.c source/gas/config/tc-mips.c
--- source-orig/gas/config/tc-mips.c Wed Oct 8 20:54:10 2003
+++ source/gas/config/tc-mips.c Wed Oct 15 10:49:28 2003
@@ -3338,6 +3348,15 @@ check_absolute_expr (struct mips_cl_insn
as_bad (_("unsupported large constant"));
else if (ex->X_op != O_constant)
as_bad (_("Instruction %s requires absolute expression"), ip->insn_mo->name);
+
+ if (ex->X_op == O_constant && HAVE_32BIT_GPRS)
+ {
+ if (ex->X_add_number < 0)
+ ex->X_add_number = ((ex->X_add_number + 0x80000000) & 0xffffffff)
+ - 0x80000000;
+ else
+ ex->X_add_number &= 0xffffffff;
+ }
}
/* Count the leading zeroes by performing a binary chop. This is a
@@ -8559,9 +8578,7 @@ do_msbd:
case 'I':
/* "+I" is like "I", except that imm2_expr is used. */
my_getExpression (&imm2_expr, s);
- if (imm2_expr.X_op != O_big
- && imm2_expr.X_op != O_constant)
- insn_error = _("absolute expression required");
+ check_absolute_expr (ip, &imm2_expr);
s = expr_end;
continue;
@@ -9047,9 +9064,7 @@ do_msbd:
case 'I':
my_getExpression (&imm_expr, s);
- if (imm_expr.X_op != O_big
- && imm_expr.X_op != O_constant)
- insn_error = _("absolute expression required");
+ check_absolute_expr (ip, &imm_expr);
s = expr_end;
continue;