This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[PATCH] VAX: Use gcc_{assert,unreachable}


Hi!

This patch moves the VAX backend pieces away from abort() over to use
gcc_assert() and gcc_unreachable() instead.  The vax.c part is from
Nathan Sidwell's patch, the vax.md part is from mine (because this
wasn't covered by Nathan's patch).

2005-04-27  Nathan Sidwell  <nathan@codesourcery.com>
2005-05-01  Jan-Benedict Glaw  <jbglaw@lug-owl.de>
	gcc/config/vax/
	* vax.c: (print_operand_address) Use gcc_unreachable()/gcc_assert().
	(rev_cond_name) Likewise.
	(vax_float_literal) Likewise.
	* vax.md: Likewise.

diff -Nurp src-gcc-fresh/gcc/config/vax/vax.c src-gcc-hacked/gcc/config/vax/vax.c
--- src-gcc-fresh/gcc/config/vax/vax.c	2005-04-28 23:43:46.000000000 +0200
+++ src-gcc-hacked/gcc/config/vax/vax.c	2005-05-01 13:48:30.000000000 +0200
@@ -269,7 +269,7 @@ print_operand_address (FILE * file, regi
 	  addr = XEXP (addr, 1);
 	}
       else
-	abort ();
+	gcc_unreachable ();
 
       if (GET_CODE (addr) == REG)
 	{
@@ -280,8 +280,9 @@ print_operand_address (FILE * file, regi
 	}
       else if (GET_CODE (addr) == MULT)
 	ireg = addr;
-      else if (GET_CODE (addr) == PLUS)
+      else
 	{
+	  gcc_assert (GET_CODE (addr) == PLUS);
 	  if (CONSTANT_ADDRESS_P (XEXP (addr, 0))
 	      || GET_CODE (XEXP (addr, 0)) == MEM)
 	    {
@@ -289,10 +290,11 @@ print_operand_address (FILE * file, regi
 		{
 		  if (GET_CODE (offset) == CONST_INT)
 		    offset = plus_constant (XEXP (addr, 0), INTVAL (offset));
-		  else if (GET_CODE (XEXP (addr, 0)) == CONST_INT)
-		    offset = plus_constant (offset, INTVAL (XEXP (addr, 0)));
 		  else
-		    abort ();
+		    {
+		      gcc_assert (GET_CODE (XEXP (addr, 0)) == CONST_INT);
+		      offset = plus_constant (offset, INTVAL (XEXP (addr, 0)));
+		    }
 		}
 	      offset = XEXP (addr, 0);
 	    }
@@ -303,14 +305,12 @@ print_operand_address (FILE * file, regi
 	      else
 		reg1 = XEXP (addr, 0);
 	    }
-	  else if (GET_CODE (XEXP (addr, 0)) == MULT)
+	  else
 	    {
-	      if (ireg)
-		abort ();
+	      gcc_assert (GET_CODE (XEXP (addr, 0)) == MULT);
+	      gcc_assert (!ireg);
 	      ireg = XEXP (addr, 0);
 	    }
-	  else
-	    abort ();
 
 	  if (CONSTANT_ADDRESS_P (XEXP (addr, 1))
 	      || GET_CODE (XEXP (addr, 1)) == MEM)
@@ -319,10 +319,11 @@ print_operand_address (FILE * file, regi
 		{
 		  if (GET_CODE (offset) == CONST_INT)
 		    offset = plus_constant (XEXP (addr, 1), INTVAL (offset));
-		  else if (GET_CODE (XEXP (addr, 1)) == CONST_INT)
-		    offset = plus_constant (offset, INTVAL (XEXP (addr, 1)));
 		  else
-		    abort ();
+		    {
+		      gcc_assert (GET_CODE (XEXP (addr, 1)) == CONST_INT);
+		      offset = plus_constant (offset, INTVAL (XEXP (addr, 1)));
+		    }
 		}
 	      offset = XEXP (addr, 1);
 	    }
@@ -333,25 +334,20 @@ print_operand_address (FILE * file, regi
 	      else
 		reg1 = XEXP (addr, 1);
 	    }
-	  else if (GET_CODE (XEXP (addr, 1)) == MULT)
+	  else
 	    {
-	      if (ireg)
-		abort ();
+	      gcc_assert (GET_CODE (XEXP (addr, 1)) == MULT);
+	      gcc_assert (!ireg);
 	      ireg = XEXP (addr, 1);
 	    }
-	  else
-	    abort ();
 	}
-      else
-	abort ();
 
       /* If REG1 is nonzero, figure out if it is a base or index register.  */
       if (reg1)
 	{
 	  if (breg != 0 || (offset && GET_CODE (offset) == MEM))
 	    {
-	      if (ireg)
-		abort ();
+	      gcc_assert (!ireg);
 	      ireg = reg1;
 	    }
 	  else
@@ -368,8 +364,7 @@ print_operand_address (FILE * file, regi
 	{
 	  if (GET_CODE (ireg) == MULT)
 	    ireg = XEXP (ireg, 0);
-	  if (GET_CODE (ireg) != REG)
-	    abort ();
+	  gcc_assert (GET_CODE (ireg) == REG);
 	  fprintf (file, "[%s]", reg_names[REGNO (ireg)]);
 	}
       break;
@@ -406,7 +401,7 @@ rev_cond_name (rtx op)
       return "lssu";
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -432,12 +427,13 @@ vax_float_literal(register rtx c)
   for (i = 0; i < 7; i++)
     {
       int x = 1 << i;
+      bool ok;
       REAL_VALUE_FROM_INT (s, x, 0, mode);
 
       if (REAL_VALUES_EQUAL (r, s))
 	return 1;
-      if (!exact_real_inverse (mode, &s))
-	abort ();
+      ok = exact_real_inverse (mode, &s);
+      gcc_assert (ok);
       if (REAL_VALUES_EQUAL (r, s))
 	return 1;
     }
diff -Nurp src-gcc-fresh/gcc/config/vax/vax.md src-gcc-hacked/gcc/config/vax/vax.md
--- src-gcc-fresh/gcc/config/vax/vax.md	2005-05-01 13:46:49.000000000 +0200
+++ src-gcc-hacked/gcc/config/vax/vax.md	2005-05-01 14:17:15.000000000 +0200
@@ -1205,8 +1205,7 @@
 			    (match_operand:SI 3 "immediate_operand" "")))])]
   ""
 {
-  if (INTVAL (operands[3]) > 255 * 4 || INTVAL (operands[3]) % 4)
-    abort ();
+  gcc_assert (INTVAL (operands[3]) <= 255 * 4 && INTVAL (operands[3]) % 4 == 0);
 
   /* Operand 1 is the number of bytes to be popped by DW_CFA_GNU_args_size
      during EH unwinding.  We must include the argument count pushed by
@@ -1234,8 +1233,7 @@
 			    (match_operand:SI 4 "immediate_operand" "")))])]
   ""
 {
-  if (INTVAL (operands[4]) > 255 * 4 || INTVAL (operands[4]) % 4)
-    abort ();
+  gcc_assert (INTVAL (operands[4]) <= 255 * 4 && INTVAL (operands[4]) % 4 == 0);
 
   /* Operand 2 is the number of bytes to be popped by DW_CFA_GNU_args_size
      during EH unwinding.  We must include the argument count pushed by

MfG, JBG

-- 
AWEK microdata GmbH -- Am Wellbach 4 -- 33609 Bielefeld


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