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]

[resend] MIPS: Trap instructions in division/multiply expansions


Hello,

 I'm sending the proposal again.  Since the original mail, I happened to
identify GNU gettext as a real user of SIGFPE for integer division by
zero.  They incorporate a workaround for broken systems that signal
SIGTRAP or SIGILL instead, but it doesn't justify gas generating bad code. 

 As I understand from the feedback, Irix' as emits correct code, but the
kernel doesn't try to interpret trap/break codes.  Linux does, though, and
without a proper code it can't really tell the reason of a trap.  Others
don't care (otherwise they would provide a comment).  It would be weird to
insist on a zero code, anyway. 

 I think the fix should go to 2.13 as well.

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

---------- Forwarded message ----------
Message-ID: <Pine.GSO.3.96.1020708230512.6296Q-100000@delta.ds2.pg.gda.pl>
Date: Mon, 8 Jul 2002 23:17:06 +0200 (MET DST)
From: "Maciej W. Rozycki" <macro@ds2.pg.gda.pl>
To: binutils@sources.redhat.com
Subject: [patch] MIPS: Trap instructions in division/multiply expansions

Hello,

 I believe it would be correct to embed a non-zero code in trap
instructions used in division/multiply macro expansions, similarly to how
breakpoint codes (6 and 7) are used in the non-trap versions.  The
following patch implements it.  At least MIPS/Linux extracts these codes
from both break and trap opcodes and uses them to determine whether
SIGTRAP or SIGFPE should be sent.  Any comments? 

2002-07-08  Maciej W. Rozycki  <macro@ds2.pg.gda.pl>

	* config/tc-mips.c (macro): Use codes 6 and 7 in trap instructions
	used in division/multiply macro expansions similarly to how they
	are used in the variants with break instructions.
	(macro2): Likewise.

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

binutils-2.12.90-20020702-mips-div-trap.patch
diff -up --recursive --new-file binutils-2.12.90-20020702.macro/gas/config/tc-mips.c binutils-2.12.90-20020702/gas/config/tc-mips.c
--- binutils-2.12.90-20020702.macro/gas/config/tc-mips.c	2002-06-15 03:25:24.000000000 +0000
+++ binutils-2.12.90-20020702/gas/config/tc-mips.c	2002-07-07 19:33:50.000000000 +0000
@@ -4256,7 +4256,7 @@ macro (ip)
 	  as_warn (_("Divide by zero."));
 	  if (mips_trap)
 	    macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "teq",
-			 "s,t", 0, 0);
+			 "s,t,q", 0, 0, 7);
 	  else
 	    macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "break",
 			 "c", 7);
@@ -4269,7 +4269,7 @@ macro (ip)
       if (mips_trap)
 	{
 	  macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "teq",
-		       "s,t", treg, 0);
+		       "s,t,q", treg, 0, 7);
 	  macro_build ((char *) NULL, &icnt, (expressionS *) NULL,
 		       dbl ? "ddiv" : "div", "z,s,t", sreg, treg);
 	}
@@ -4305,7 +4305,7 @@ macro (ip)
       if (mips_trap)
 	{
 	  macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "teq",
-		       "s,t", sreg, AT);
+		       "s,t,q", sreg, AT, 6);
 	  /* We want to close the noreorder block as soon as possible, so
 	     that later insns are available for delay slot filling.  */
 	  --mips_opts.noreorder;
@@ -4368,7 +4368,7 @@ macro (ip)
 	  as_warn (_("Divide by zero."));
 	  if (mips_trap)
 	    macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "teq",
-			 "s,t", 0, 0);
+			 "s,t,q", 0, 0, 7);
 	  else
 	    macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "break",
 			 "c", 7);
@@ -4424,7 +4424,7 @@ macro (ip)
       if (mips_trap)
 	{
 	  macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "teq",
-		       "s,t", treg, 0);
+		       "s,t,q", treg, 0, 7);
 	  macro_build ((char *) NULL, &icnt, (expressionS *) NULL, s, "z,s,t",
 		       sreg, treg);
 	  /* We want to close the noreorder block as soon as possible, so
@@ -6571,8 +6571,8 @@ macro2 (ip)
       macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "mfhi", "d",
 		   AT);
       if (mips_trap)
-	macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "tne", "s,t",
-		     dreg, AT);
+	macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "tne",
+		     "s,t,q", dreg, AT, 6);
       else
 	{
 	  expr1.X_add_number = 8;
@@ -6610,8 +6610,8 @@ macro2 (ip)
       macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "mflo", "d",
 		   dreg);
       if (mips_trap)
-	macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "tne", "s,t",
-		     AT, 0);
+	macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "tne",
+		     "s,t,q", AT, 0, 6);
       else
 	{
 	  expr1.X_add_number = 8;



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