[PATCH] MIPS gas: Fix macro expansions for .set noat

Thiemo Seufer ica2_ts@csv.ica.uni-stuttgart.de
Thu Feb 17 07:10:00 GMT 2005


Maciej W. Rozycki wrote:
> On Wed, 16 Feb 2005, Thiemo Seufer wrote:
> 
> > >  More comments about that change -- as I understand our policy wrt $at 
> > > being used with ".set noat" in effect is to go for it regardless and only 
> > > issue a warning (that can be converted to an error with --fatal-warnings).  
> > > Therefore we shouldn't use as_bad() in this case.
> > 
> > IMHO it should be an error if the result can't work at all. I don't
> > see a case where overwriting the base register before its use could
> > be the programmers intention.
> 
>  I do agree it's of questionable use and I proposed changing it a few 
> years ago, but I got a response as I expressed above.  Then if it's to be 
> done, it should be done consistently for all cases -- replacing respective 
> as_warn() calls with as_bad() ones should be the right way.

Hm, OTOH it could simply be sloppy coding, and falling over it
is not necessarily the right thing to do. I plan to commit the
appended patch, it partially reverts the earlier change.

Comments?


Thiemo


2005-02-16  Thiemo Seufer  <seufer@csv.ica.uni-stuttgart.de>

	/gas/ChangeLog
	* config/tc-mips.c (macro): Don't fail but warn on $at uses
	after .set noat, it may only be sloppy coding.  Don't try to
	avoid $at use by sacrificing the target register before it is
	stored, it won't work.

	/gas/testsuite/ChangeLog
	* gas/mips/noat-1.s, gas/mips/noat-1.d, gas/mips/noat-2.s,
	gas/mips/noat2.l, gas/mips/noat-3.s, gas/mips/noat-3.l,
	gas/mips/noat-4.s, gas/mips/noat-4.l, gas/mips/noat-5.s,
	gas/mips/noat-5.l, gas/mips/noat-6.s, gas/mips/noat-6.l,
	gas/mips/noat-7.s, gas/mips/noat-7.l: New files, testcases for
	.set noat and macro expansion.
	* gas/mips/mips.exp: Run new testcases.


Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.282
diff -u -p -r1.282 tc-mips.c
--- gas/config/tc-mips.c	16 Feb 2005 15:49:13 -0000	1.282
+++ gas/config/tc-mips.c	16 Feb 2005 23:26:33 -0000
@@ -5761,23 +5761,14 @@ macro (struct mips_cl_insn *ip)
     case M_LWU_AB:
       s = "lwu";
     ld:
-      /* XXX Why don't we try to use AT for all expansions? */
-      if (!mips_opts.noat && (breg == treg || coproc || lr))
+      if (breg == treg || coproc || lr)
 	{
 	  tempreg = AT;
 	  used_at = 1;
 	}
-      else if (breg == treg
-	       && (offset_expr.X_op != O_constant
-		   || (offset_expr.X_add_number > 0x7fff
-		       || offset_expr.X_add_number < -0x8000)))
-	{
-	  as_bad(_("load expansion needs $at register"));
-	}
       else
 	{
 	  tempreg = treg;
-	  used_at = 0;
 	}
       goto ld_st;
     case M_SB_AB:
@@ -5847,23 +5838,8 @@ macro (struct mips_cl_insn *ip)
     case M_SDR_AB:
       s = "sdr";
     st:
-      if (!mips_opts.noat)
-	{
-	  tempreg = AT;
-	  used_at = 1;
-	}
-      else if (breg == treg
-	       && (offset_expr.X_op != O_constant
-		   || (offset_expr.X_add_number > 0x7fff
-		       || offset_expr.X_add_number < -0x8000)))
-	{
-	  as_bad(_("store expansion needs $at register"));
-	}
-      else
-	{
-	  tempreg = treg;
-	  used_at = 0;
-	}
+      tempreg = AT;
+      used_at = 1;
     ld_st:
       /* Itbl support may require additional care here.  */
       if (mask == M_LWC1_AB
Index: gas/testsuite/gas/mips/mips.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/mips.exp,v
retrieving revision 1.98
diff -u -p -r1.98 mips.exp
--- gas/testsuite/gas/mips/mips.exp	15 Feb 2005 19:57:53 -0000	1.98
+++ gas/testsuite/gas/mips/mips.exp	16 Feb 2005 23:26:35 -0000
@@ -738,4 +738,12 @@ if { [istarget mips*-*-*] } then {
 	run_dump_test "macro-warn-1-n32"
 	run_dump_test "macro-warn-2-n32"
     }
+
+    run_dump_test "noat-1"
+    run_list_test "noat-2" ""
+    run_list_test "noat-3" ""
+    run_list_test "noat-4" ""
+    run_list_test "noat-5" ""
+    run_list_test "noat-6" ""
+    run_list_test "noat-7" ""
 }
Index: gas/testsuite/gas/mips/noat-1.d
===================================================================
RCS file: gas/testsuite/gas/mips/noat-1.d
diff -N gas/testsuite/gas/mips/noat-1.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-1.d	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,15 @@
+#as: -32
+#objdump: -dr
+
+.*: +file format .*mips
+
+Disassembly of section \.text:
+
+00000000 <\.text>:
+   0:	8f7b7fff 	lw	k1,32767\(k1\)
+   4:	00000000 	nop
+   8:	8f7b8000 	lw	k1,-32768\(k1\)
+   c:	00000000 	nop
+  10:	af7b7fff 	sw	k1,32767\(k1\)
+  14:	af7b8000 	sw	k1,-32768\(k1\)
+	\.\.\.
Index: gas/testsuite/gas/mips/noat-1.s
===================================================================
RCS file: gas/testsuite/gas/mips/noat-1.s
diff -N gas/testsuite/gas/mips/noat-1.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-1.s	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,7 @@
+	.set noat
+	lw $27, 0x7fff($27)
+	lw $27, -0x8000($27)
+	sw $27, 0x7fff($27)
+	sw $27, -0x8000($27)
+
+	.space 8
Index: gas/testsuite/gas/mips/noat-2.l
===================================================================
RCS file: gas/testsuite/gas/mips/noat-2.l
diff -N gas/testsuite/gas/mips/noat-2.l
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-2.l	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,2 @@
+.*\.s: Assembler messages:
+.*\.s:2: Warning: Macro used \$at after "\.set noat"
Index: gas/testsuite/gas/mips/noat-2.s
===================================================================
RCS file: gas/testsuite/gas/mips/noat-2.s
diff -N gas/testsuite/gas/mips/noat-2.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-2.s	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,4 @@
+	.set noat
+	lw $27, 0x8000($27)
+
+	.space 8
Index: gas/testsuite/gas/mips/noat-3.l
===================================================================
RCS file: gas/testsuite/gas/mips/noat-3.l
diff -N gas/testsuite/gas/mips/noat-3.l
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-3.l	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,2 @@
+.*\.s: Assembler messages:
+.*\.s:2: Warning: Macro used \$at after "\.set noat"
Index: gas/testsuite/gas/mips/noat-3.s
===================================================================
RCS file: gas/testsuite/gas/mips/noat-3.s
diff -N gas/testsuite/gas/mips/noat-3.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-3.s	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,4 @@
+	.set noat
+	lw $27, -0x8001($27)
+
+	.space 8
Index: gas/testsuite/gas/mips/noat-4.l
===================================================================
RCS file: gas/testsuite/gas/mips/noat-4.l
diff -N gas/testsuite/gas/mips/noat-4.l
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-4.l	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,2 @@
+.*\.s: Assembler messages:
+.*\.s:2: Warning: Macro used \$at after "\.set noat"
Index: gas/testsuite/gas/mips/noat-4.s
===================================================================
RCS file: gas/testsuite/gas/mips/noat-4.s
diff -N gas/testsuite/gas/mips/noat-4.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-4.s	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,4 @@
+	.set noat
+	lw $27, symbol($27)
+
+	.space 8
Index: gas/testsuite/gas/mips/noat-5.l
===================================================================
RCS file: gas/testsuite/gas/mips/noat-5.l
diff -N gas/testsuite/gas/mips/noat-5.l
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-5.l	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,2 @@
+.*\.s: Assembler messages:
+.*\.s:2: Warning: Macro used \$at after "\.set noat"
Index: gas/testsuite/gas/mips/noat-5.s
===================================================================
RCS file: gas/testsuite/gas/mips/noat-5.s
diff -N gas/testsuite/gas/mips/noat-5.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-5.s	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,4 @@
+	.set noat
+	sw $27, 0x8000($27)
+
+	.space 8
Index: gas/testsuite/gas/mips/noat-6.l
===================================================================
RCS file: gas/testsuite/gas/mips/noat-6.l
diff -N gas/testsuite/gas/mips/noat-6.l
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-6.l	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,2 @@
+.*\.s: Assembler messages:
+.*\.s:2: Warning: Macro used \$at after "\.set noat"
Index: gas/testsuite/gas/mips/noat-6.s
===================================================================
RCS file: gas/testsuite/gas/mips/noat-6.s
diff -N gas/testsuite/gas/mips/noat-6.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-6.s	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,4 @@
+	.set noat
+	sw $27, -0x8001($27)
+
+	.space 8
Index: gas/testsuite/gas/mips/noat-7.l
===================================================================
RCS file: gas/testsuite/gas/mips/noat-7.l
diff -N gas/testsuite/gas/mips/noat-7.l
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-7.l	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,2 @@
+.*\.s: Assembler messages:
+.*\.s:2: Warning: Macro used \$at after "\.set noat"
Index: gas/testsuite/gas/mips/noat-7.s
===================================================================
RCS file: gas/testsuite/gas/mips/noat-7.s
diff -N gas/testsuite/gas/mips/noat-7.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/mips/noat-7.s	16 Feb 2005 23:26:35 -0000
@@ -0,0 +1,4 @@
+	.set noat
+	sw $27, symbol($27)
+
+	.space 8



More information about the Binutils mailing list