This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mipsisa32-unknown-elf-as: Error: too large constant specified


Ian Lance Taylor wrote:
> Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de> writes:
> 
> > > IMHO the right solution is to fix these 32 bit values after each
> > > call of my_getExpression().
> > 
> > Well, that's my take of it.
> 
> Hmmm.  It currently works to pass O_big to case 'I'.  Your patch would
> change that.  There is a bunch of code in load_register() to handle
> O_big.  Are we sure it is correct to discard that code?
> 
> > +  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;
> > +    }
> 
> If X_add_number is a 64-bit value, then it doesn't make sense to check
> whether it is negative in the 64-bit sense and then try to negate it
> in the 32-bit sense.  I think you mean to write
>   if ((ex->X_add_number & 0x80000000) != 0)

Thanks for spotting those.


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): Likewise.


--- source-orig/gas/config/tc-mips.c	Wed Oct  8 20:54:10 2003
+++ source/gas/config/tc-mips.c	Wed Oct 15 18:39:01 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 & 0x80000000) != 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
@@ -8561,7 +8580,16 @@ do_msbd:
 		  my_getExpression (&imm2_expr, s);
 		  if (imm2_expr.X_op != O_big
 		      && imm2_expr.X_op != O_constant)
-		  insn_error = _("absolute expression required");
+		    insn_error = _("absolute expression required");
+		  if (imm2_expr.X_op == O_constant && HAVE_32BIT_GPRS)
+		    {
+		      if ((imm2_expr.X_add_number & 0x80000000) != 0)
+			imm2_expr.X_add_number = ((imm2_expr.X_add_number
+						   + 0x80000000)
+						  & 0xffffffff) - 0x80000000;
+		      else
+			imm2_expr.X_add_number &= 0xffffffff;
+		    }
 		  s = expr_end;
 		  continue;
 
@@ -9050,6 +9078,15 @@ do_msbd:
 	      if (imm_expr.X_op != O_big
 		  && imm_expr.X_op != O_constant)
 		insn_error = _("absolute expression required");
+	      if (imm2_expr.X_op == O_constant && HAVE_32BIT_GPRS)
+		{
+		  if ((imm2_expr.X_add_number & 0x80000000) != 0)
+		    imm2_expr.X_add_number = ((imm2_expr.X_add_number
+					       + 0x80000000)
+					      & 0xffffffff) - 0x80000000;
+		  else
+		    imm2_expr.X_add_number &= 0xffffffff;
+		}
 	      s = expr_end;
 	      continue;
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]