public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 04/20] MIPS/GAS: Spell out 0 referring to $0 as ZERO
@ 2010-12-02 19:18 Maciej W. Rozycki
  2010-12-02 19:19 ` Paul Koning
  0 siblings, 1 reply; 3+ messages in thread
From: Maciej W. Rozycki @ 2010-12-02 19:18 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: Catherine Moore, binutils

Hi,

 Here is a (supposedly) exhaustive change to macro() that makes $0 
register references in macro_build() and move_register() calls to be 
spelled as ZERO for better clarity and difference to places where an 
immediate value of 0 is referred to.  I have not changed other places, 
typically pieces of code like:

  treg = 0;

or:

  if (sreg == 0)

whose reference to $0 is obvious.

2010-12-02  Maciej W. Rozycki  <macro@codesourcery.com>

	gas/
	* config/tc-mips.c (macro): Replace 0 with ZERO in macro_build 
	and move_register calls referring to $0.

 OK to apply?

  Maciej

binutils-gas-mips-zero.diff
Index: binutils-fsf-trunk-quilt/gas/config/tc-mips.c
===================================================================
--- binutils-fsf-trunk-quilt.orig/gas/config/tc-mips.c	2010-12-01 21:05:49.000000000 +0000
+++ binutils-fsf-trunk-quilt/gas/config/tc-mips.c	2010-12-01 21:05:49.000000000 +0000
@@ -4960,7 +4960,7 @@ macro (struct mips_cl_insn *ip)
     beq_i:
       if (imm_expr.X_op == O_constant && imm_expr.X_add_number == 0)
 	{
-	  macro_build (&offset_expr, s, "s,t,p", sreg, 0);
+	  macro_build (&offset_expr, s, "s,t,p", sreg, ZERO);
 	  break;
 	}
       used_at = 1;
@@ -4983,7 +4983,7 @@ macro (struct mips_cl_insn *ip)
 	}
       used_at = 1;
       macro_build (NULL, "slt", "d,v,t", AT, sreg, treg);
-      macro_build (&offset_expr, likely ? "beql" : "beq", "s,t,p", AT, 0);
+      macro_build (&offset_expr, likely ? "beql" : "beq", "s,t,p", AT, ZERO);
       break;
 
     case M_BGTL_I:
@@ -5007,7 +5007,7 @@ macro (struct mips_cl_insn *ip)
 	  if (! likely)
 	    macro_build (NULL, "nop", "", 0);
 	  else
-	    macro_build (&offset_expr, "bnel", "s,t,p", 0, 0);
+	    macro_build (&offset_expr, "bnel", "s,t,p", ZERO, ZERO);
 	  break;
 	}
       if (imm_expr.X_op != O_constant)
@@ -5049,7 +5049,7 @@ macro (struct mips_cl_insn *ip)
 	}
       used_at = 1;
       set_at (sreg, 0);
-      macro_build (&offset_expr, likely ? "beql" : "beq", "s,t,p", AT, 0);
+      macro_build (&offset_expr, likely ? "beql" : "beq", "s,t,p", AT, ZERO);
       break;
 
     case M_BGEUL:
@@ -5060,12 +5060,12 @@ macro (struct mips_cl_insn *ip)
       if (sreg == 0)
 	{
 	  macro_build (&offset_expr, likely ? "beql" : "beq",
-		       "s,t,p", 0, treg);
+		       "s,t,p", ZERO, treg);
 	  break;
 	}
       used_at = 1;
       macro_build (NULL, "sltu", "d,v,t", AT, sreg, treg);
-      macro_build (&offset_expr, likely ? "beql" : "beq", "s,t,p", AT, 0);
+      macro_build (&offset_expr, likely ? "beql" : "beq", "s,t,p", AT, ZERO);
       break;
 
     case M_BGTUL_I:
@@ -5089,12 +5089,12 @@ macro (struct mips_cl_insn *ip)
       if (imm_expr.X_op == O_constant && imm_expr.X_add_number == 1)
 	{
 	  macro_build (&offset_expr, likely ? "bnel" : "bne",
-		       "s,t,p", sreg, 0);
+		       "s,t,p", sreg, ZERO);
 	  break;
 	}
       used_at = 1;
       set_at (sreg, 1);
-      macro_build (&offset_expr, likely ? "beql" : "beq", "s,t,p", AT, 0);
+      macro_build (&offset_expr, likely ? "beql" : "beq", "s,t,p", AT, ZERO);
       break;
 
     case M_BGTL:
@@ -5112,7 +5112,7 @@ macro (struct mips_cl_insn *ip)
 	}
       used_at = 1;
       macro_build (NULL, "slt", "d,v,t", AT, treg, sreg);
-      macro_build (&offset_expr, likely ? "bnel" : "bne", "s,t,p", AT, 0);
+      macro_build (&offset_expr, likely ? "bnel" : "bne", "s,t,p", AT, ZERO);
       break;
 
     case M_BGTUL:
@@ -5121,14 +5121,14 @@ macro (struct mips_cl_insn *ip)
       if (treg == 0)
 	{
 	  macro_build (&offset_expr, likely ? "bnel" : "bne",
-		       "s,t,p", sreg, 0);
+		       "s,t,p", sreg, ZERO);
 	  break;
 	}
       if (sreg == 0)
 	goto do_false;
       used_at = 1;
       macro_build (NULL, "sltu", "d,v,t", AT, treg, sreg);
-      macro_build (&offset_expr, likely ? "bnel" : "bne", "s,t,p", AT, 0);
+      macro_build (&offset_expr, likely ? "bnel" : "bne", "s,t,p", AT, ZERO);
       break;
 
     case M_BLEL:
@@ -5146,7 +5146,7 @@ macro (struct mips_cl_insn *ip)
 	}
       used_at = 1;
       macro_build (NULL, "slt", "d,v,t", AT, treg, sreg);
-      macro_build (&offset_expr, likely ? "beql" : "beq", "s,t,p", AT, 0);
+      macro_build (&offset_expr, likely ? "beql" : "beq", "s,t,p", AT, ZERO);
       break;
 
     case M_BLEL_I:
@@ -5184,7 +5184,7 @@ macro (struct mips_cl_insn *ip)
 	}
       used_at = 1;
       set_at (sreg, 0);
-      macro_build (&offset_expr, likely ? "bnel" : "bne", "s,t,p", AT, 0);
+      macro_build (&offset_expr, likely ? "bnel" : "bne", "s,t,p", AT, ZERO);
       break;
 
     case M_BLEUL:
@@ -5193,14 +5193,14 @@ macro (struct mips_cl_insn *ip)
       if (treg == 0)
 	{
 	  macro_build (&offset_expr, likely ? "beql" : "beq",
-		       "s,t,p", sreg, 0);
+		       "s,t,p", sreg, ZERO);
 	  break;
 	}
       if (sreg == 0)
 	goto do_true;
       used_at = 1;
       macro_build (NULL, "sltu", "d,v,t", AT, treg, sreg);
-      macro_build (&offset_expr, likely ? "beql" : "beq", "s,t,p", AT, 0);
+      macro_build (&offset_expr, likely ? "beql" : "beq", "s,t,p", AT, ZERO);
       break;
 
     case M_BLEUL_I:
@@ -5224,12 +5224,12 @@ macro (struct mips_cl_insn *ip)
       if (imm_expr.X_op == O_constant && imm_expr.X_add_number == 1)
 	{
 	  macro_build (&offset_expr, likely ? "beql" : "beq",
-		       "s,t,p", sreg, 0);
+		       "s,t,p", sreg, ZERO);
 	  break;
 	}
       used_at = 1;
       set_at (sreg, 1);
-      macro_build (&offset_expr, likely ? "bnel" : "bne", "s,t,p", AT, 0);
+      macro_build (&offset_expr, likely ? "bnel" : "bne", "s,t,p", AT, ZERO);
       break;
 
     case M_BLTL:
@@ -5247,7 +5247,7 @@ macro (struct mips_cl_insn *ip)
 	}
       used_at = 1;
       macro_build (NULL, "slt", "d,v,t", AT, sreg, treg);
-      macro_build (&offset_expr, likely ? "bnel" : "bne", "s,t,p", AT, 0);
+      macro_build (&offset_expr, likely ? "bnel" : "bne", "s,t,p", AT, ZERO);
       break;
 
     case M_BLTUL:
@@ -5258,12 +5258,12 @@ macro (struct mips_cl_insn *ip)
       if (sreg == 0)
 	{
 	  macro_build (&offset_expr, likely ? "bnel" : "bne",
-		       "s,t,p", 0, treg);
+		       "s,t,p", ZERO, treg);
 	  break;
 	}
       used_at = 1;
       macro_build (NULL, "sltu", "d,v,t", AT, sreg, treg);
-      macro_build (&offset_expr, likely ? "bnel" : "bne", "s,t,p", AT, 0);
+      macro_build (&offset_expr, likely ? "bnel" : "bne", "s,t,p", AT, ZERO);
       break;
 
     case M_DEXT:
@@ -5375,7 +5375,7 @@ macro (struct mips_cl_insn *ip)
 	{
 	  as_warn (_("Divide by zero."));
 	  if (mips_trap)
-	    macro_build (NULL, "teq", "s,t,q", 0, 0, 7);
+	    macro_build (NULL, "teq", "s,t,q", ZERO, ZERO, 7);
 	  else
 	    macro_build (NULL, "break", "c", 7);
 	  break;
@@ -5384,13 +5384,13 @@ macro (struct mips_cl_insn *ip)
       start_noreorder ();
       if (mips_trap)
 	{
-	  macro_build (NULL, "teq", "s,t,q", treg, 0, 7);
+	  macro_build (NULL, "teq", "s,t,q", treg, ZERO, 7);
 	  macro_build (NULL, dbl ? "ddiv" : "div", "z,s,t", sreg, treg);
 	}
       else
 	{
 	  expr1.X_add_number = 8;
-	  macro_build (&expr1, "bne", "s,t,p", treg, 0);
+	  macro_build (&expr1, "bne", "s,t,p", treg, ZERO);
 	  macro_build (NULL, dbl ? "ddiv" : "div", "z,s,t", sreg, treg);
 	  macro_build (NULL, "break", "c", 7);
 	}
@@ -5472,7 +5472,7 @@ macro (struct mips_cl_insn *ip)
 	{
 	  as_warn (_("Divide by zero."));
 	  if (mips_trap)
-	    macro_build (NULL, "teq", "s,t,q", 0, 0, 7);
+	    macro_build (NULL, "teq", "s,t,q", ZERO, ZERO, 7);
 	  else
 	    macro_build (NULL, "break", "c", 7);
 	  break;
@@ -5482,7 +5482,7 @@ macro (struct mips_cl_insn *ip)
 	  if (strcmp (s2, "mflo") == 0)
 	    move_register (dreg, sreg);
 	  else
-	    move_register (dreg, 0);
+	    move_register (dreg, ZERO);
 	  break;
 	}
       if (imm_expr.X_op == O_constant
@@ -5494,7 +5494,7 @@ macro (struct mips_cl_insn *ip)
 	      macro_build (NULL, dbl ? "dneg" : "neg", "d,w", dreg, sreg);
 	    }
 	  else
-	    move_register (dreg, 0);
+	    move_register (dreg, ZERO);
 	  break;
 	}
 
@@ -5523,7 +5523,7 @@ macro (struct mips_cl_insn *ip)
       start_noreorder ();
       if (mips_trap)
 	{
-	  macro_build (NULL, "teq", "s,t,q", treg, 0, 7);
+	  macro_build (NULL, "teq", "s,t,q", treg, ZERO, 7);
 	  macro_build (NULL, s, "z,s,t", sreg, treg);
 	  /* We want to close the noreorder block as soon as possible, so
 	     that later insns are available for delay slot filling.  */
@@ -5532,7 +5532,7 @@ macro (struct mips_cl_insn *ip)
       else
 	{
 	  expr1.X_add_number = 8;
-	  macro_build (&expr1, "bne", "s,t,p", treg, 0);
+	  macro_build (&expr1, "bne", "s,t,p", treg, ZERO);
 	  macro_build (NULL, s, "z,s,t", sreg, treg);
 
 	  /* We want to close the noreorder block as soon as possible, so
@@ -7476,11 +7476,11 @@ macro (struct mips_cl_insn *ip)
       macro_build (NULL, "mfhi", "d", AT);
       macro_build (NULL, "mflo", "d", dreg);
       if (mips_trap)
-	macro_build (NULL, "tne", "s,t,q", AT, 0, 6);
+	macro_build (NULL, "tne", "s,t,q", AT, ZERO, 6);
       else
 	{
 	  expr1.X_add_number = 8;
-	  macro_build (&expr1, "beq", "s,t,p", AT, 0);
+	  macro_build (&expr1, "beq", "s,t,p", AT, ZERO);
 	  macro_build (NULL, "nop", "", 0);
 	  macro_build (NULL, "break", "c", 6);
 	}
@@ -7504,7 +7504,7 @@ macro (struct mips_cl_insn *ip)
 	  break;
 	}
       used_at = 1;
-      macro_build (NULL, "dsubu", "d,v,t", AT, 0, treg);
+      macro_build (NULL, "dsubu", "d,v,t", AT, ZERO, treg);
       macro_build (NULL, "dsrlv", "d,t,s", AT, sreg, AT);
       macro_build (NULL, "dsllv", "d,t,s", dreg, sreg, treg);
       macro_build (NULL, "or", "d,v,t", dreg, dreg, AT);
@@ -7527,7 +7527,7 @@ macro (struct mips_cl_insn *ip)
 	  break;
 	}
       used_at = 1;
-      macro_build (NULL, "subu", "d,v,t", AT, 0, treg);
+      macro_build (NULL, "subu", "d,v,t", AT, ZERO, treg);
       macro_build (NULL, "srlv", "d,t,s", AT, sreg, AT);
       macro_build (NULL, "sllv", "d,t,s", dreg, sreg, treg);
       macro_build (NULL, "or", "d,v,t", dreg, dreg, AT);
@@ -7597,7 +7597,7 @@ macro (struct mips_cl_insn *ip)
 	  break;
 	}
       used_at = 1;
-      macro_build (NULL, "dsubu", "d,v,t", AT, 0, treg);
+      macro_build (NULL, "dsubu", "d,v,t", AT, ZERO, treg);
       macro_build (NULL, "dsllv", "d,t,s", AT, sreg, AT);
       macro_build (NULL, "dsrlv", "d,t,s", dreg, sreg, treg);
       macro_build (NULL, "or", "d,v,t", dreg, dreg, AT);
@@ -7610,7 +7610,7 @@ macro (struct mips_cl_insn *ip)
 	  break;
 	}
       used_at = 1;
-      macro_build (NULL, "subu", "d,v,t", AT, 0, treg);
+      macro_build (NULL, "subu", "d,v,t", AT, ZERO, treg);
       macro_build (NULL, "sllv", "d,t,s", AT, sreg, AT);
       macro_build (NULL, "srlv", "d,t,s", dreg, sreg, treg);
       macro_build (NULL, "or", "d,v,t", dreg, dreg, AT);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 04/20] MIPS/GAS: Spell out 0 referring to $0 as ZERO
  2010-12-02 19:18 [PATCH 04/20] MIPS/GAS: Spell out 0 referring to $0 as ZERO Maciej W. Rozycki
@ 2010-12-02 19:19 ` Paul Koning
  2010-12-02 23:57   ` Maciej W. Rozycki
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Koning @ 2010-12-02 19:19 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils


On Dec 2, 2010, at 2:17 PM, Maciej W. Rozycki wrote:

> Hi,
> 
> Here is a (supposedly) exhaustive change to macro() that makes $0 
> register references in macro_build() and move_register() calls to be 
> spelled as ZERO for better clarity and difference to places where an 
> immediate value of 0 is referred to.  I have not changed other places, 
> typically pieces of code like:
> 
>  treg = 0;
> 
> or:
> 
>  if (sreg == 0)
> 
> whose reference to $0 is obvious.

I wouldn't say those are a whole lot more obvious than the ones you did change...

	paul

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 04/20] MIPS/GAS: Spell out 0 referring to $0 as ZERO
  2010-12-02 19:19 ` Paul Koning
@ 2010-12-02 23:57   ` Maciej W. Rozycki
  0 siblings, 0 replies; 3+ messages in thread
From: Maciej W. Rozycki @ 2010-12-02 23:57 UTC (permalink / raw)
  To: Paul Koning; +Cc: binutils

On Thu, 2 Dec 2010, Paul Koning wrote:

> > Here is a (supposedly) exhaustive change to macro() that makes $0 
> > register references in macro_build() and move_register() calls to be 
> > spelled as ZERO for better clarity and difference to places where an 
> > immediate value of 0 is referred to.  I have not changed other places, 
> > typically pieces of code like:
> > 
> >  treg = 0;
> > 
> > or:
> > 
> >  if (sreg == 0)
> > 
> > whose reference to $0 is obvious.
> 
> I wouldn't say those are a whole lot more obvious than the ones you did 
> change...

 These variables refer to registers and their names make it unambiguous, 
but feel free to propose a follow-on patch -- I won't object such a 
change.

  Maciej

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-02 23:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-02 19:18 [PATCH 04/20] MIPS/GAS: Spell out 0 referring to $0 as ZERO Maciej W. Rozycki
2010-12-02 19:19 ` Paul Koning
2010-12-02 23:57   ` Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).