[RFC-PATCH] VAX: Introduce CONST_INT_P()

Jan-Benedict Glaw jbglaw@lug-owl.de
Thu Mar 16 14:04:00 GMT 2006


Hi!

This introduces the new macro/predicate CONST_INT_P(), which can be
used in places where we currently use something like

	GET_CODE (foo) == CONST_INT

Since I specifically care about the VAX code, I also converted all
applicable users of gcc/config/vax/* .  If there's interest around,
I'd probably also send equal patches for the other backends and core
code.

MfG, JBG

-- 
Jan-Benedict Glaw       jbglaw@lug-owl.de    . +49-172-7608481             _ O _
"Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg  _ _ O
 für einen Freien Staat voll Freier Bürger"  | im Internet! |   im Irak!   O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
-------------- next part --------------
2006-03-16  Jan-Benedict Glaw  <jbglaw@lug-owl.de>

	gcc/
	* rtl.h (CONST_INT_P): Define.
	* config/vax/vax.c (print_operand_address): Use CONST_INT_P()
	instead of GET_CODE(x) == CONST_INT.
	(vax_rtx_costs): Likewise.
	(vax_output_int_move): Likewise.
	(vax_output_int_add): Likewise.
	(legitimate_constant_address_p): Likewise.
	(index_term_p): Likewise.
	* config/vax/vax.h (PRINT_OPERAND): Likewise.
	* config/vax/vax.md (and<mode>3): Likewise.
	(ashrsi3): Likewise.
	(extv): Likewise.
	(movstricthi): Likewise.
	(movstrictqi): Likewise.
	(rotrsi3): Likewise.
	(five unnamed insns): Likewise.

diff -Nurp src-gcc-fresh/gcc/rtl.h src-gcc-hacked/gcc/rtl.h
--- src-gcc-fresh/gcc/rtl.h	2006-03-11 23:18:11.000000000 +0100
+++ src-gcc-hacked/gcc/rtl.h	2006-03-15 23:45:09.000000000 +0100
@@ -361,6 +361,9 @@ struct rtvec_def GTY(()) {
 /* Predicate yielding nonzero iff X is an rtx for a memory location.  */
 #define MEM_P(X) (GET_CODE (X) == MEM)
 
+/* Prediacte yielding nonzero iff X is an rtx for a constant integer.  */
+#define CONST_INT_P(X) (GET_CODE (X) == CONST_INT)
+
 /* Predicate yielding nonzero iff X is a label insn.  */
 #define LABEL_P(X) (GET_CODE (X) == CODE_LABEL)
 
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	2006-03-15 23:43:55.000000000 +0100
+++ src-gcc-hacked/gcc/config/vax/vax.c	2006-03-16 00:04:46.000000000 +0100
@@ -288,11 +288,11 @@ print_operand_address (FILE * file, rtx 
 	    {
 	      if (offset)
 		{
-		  if (GET_CODE (offset) == CONST_INT)
+		  if (CONST_INT_P (offset))
 		    offset = plus_constant (XEXP (addr, 0), INTVAL (offset));
 		  else
 		    {
-		      gcc_assert (GET_CODE (XEXP (addr, 0)) == CONST_INT);
+		      gcc_assert (CONST_INT_P (XEXP (addr, 0)));
 		      offset = plus_constant (offset, INTVAL (XEXP (addr, 0)));
 		    }
 		}
@@ -317,11 +317,11 @@ print_operand_address (FILE * file, rtx 
 	    {
 	      if (offset)
 		{
-		  if (GET_CODE (offset) == CONST_INT)
+		  if (CONST_INT_P (offset))
 		    offset = plus_constant (XEXP (addr, 1), INTVAL (offset));
 		  else
 		    {
-		      gcc_assert (GET_CODE (XEXP (addr, 1)) == CONST_INT);
+		      gcc_assert (CONST_INT_P (XEXP (addr, 1)));
 		      offset = plus_constant (offset, INTVAL (XEXP (addr, 1)));
 		    }
 		}
@@ -669,7 +669,7 @@ vax_rtx_costs (rtx x, int code, int oute
     case ROTATE:
     case ROTATERT:
       *total = 6;		/* 5 on VAX 2, 4 on VAX 9000 */
-      if (GET_CODE (XEXP (x, 1)) == CONST_INT)
+      if (CONST_INT_P (XEXP (x, 1)))
 	fmt = "e"; 		/* all constant rotate counts are short */
       break;
 
@@ -677,7 +677,7 @@ vax_rtx_costs (rtx x, int code, int oute
     case MINUS:
       *total = (mode == DFmode) ? 13 : 8; /* 6/8 on VAX 9000, 16/15 on VAX 2 */
       /* Small integer operands can use subl2 and addl2.  */
-      if ((GET_CODE (XEXP (x, 1)) == CONST_INT)
+      if ((CONST_INT_P (XEXP (x, 1)))
 	  && (unsigned HOST_WIDE_INT)(INTVAL (XEXP (x, 1)) + 63) < 127)
 	fmt = "e";
       break;
@@ -690,7 +690,7 @@ vax_rtx_costs (rtx x, int code, int oute
     case AND:
       /* AND is special because the first operand is complemented.  */
       *total = 3;
-      if (GET_CODE (XEXP (x, 0)) == CONST_INT)
+      if (CONST_INT_P (XEXP (x, 0)))
 	{
 	  if ((unsigned HOST_WIDE_INT)~INTVAL (XEXP (x, 0)) > 63)
 	    *total = 4;
@@ -917,7 +917,7 @@ vax_output_int_move (rtx insn ATTRIBUTE_
 	}
       if (operands[1] == const0_rtx)
 	return "clrl %0";
-      if (GET_CODE (operands[1]) == CONST_INT
+      if (CONST_INT_P (operands[1])
 	  && (unsigned) INTVAL (operands[1]) >= 64)
 	{
 	  int i = INTVAL (operands[1]);
@@ -937,7 +937,7 @@ vax_output_int_move (rtx insn ATTRIBUTE_
       return "movl %1,%0";
 
     case HImode:
-      if (GET_CODE (operands[1]) == CONST_INT)
+      if (CONST_INT_P (operands[1]))
 	{
 	  int i = INTVAL (operands[1]);
 	  if (i == 0)
@@ -952,7 +952,7 @@ vax_output_int_move (rtx insn ATTRIBUTE_
       return "movw %1,%0";
 
     case QImode:
-      if (GET_CODE (operands[1]) == CONST_INT)
+      if (CONST_INT_P (operands[1]))
 	{
 	  int i = INTVAL (operands[1]);
 	  if (i == 0)
@@ -994,10 +994,10 @@ vax_output_int_add (rtx insn ATTRIBUTE_U
 	    return "incl %0";
 	  if (operands[2] == constm1_rtx)
 	    return "decl %0";
-	  if (GET_CODE (operands[2]) == CONST_INT
+	  if (CONST_INT_P (operands[2])
 	      && (unsigned) (- INTVAL (operands[2])) < 64)
 	    return "subl2 $%n2,%0";
-	  if (GET_CODE (operands[2]) == CONST_INT
+	  if (CONST_INT_P (operands[2])
 	      && (unsigned) INTVAL (operands[2]) >= 64
 	      && REG_P (operands[1])
 	      && ((INTVAL (operands[2]) < 32767 && INTVAL (operands[2]) > -32768)
@@ -1009,18 +1009,18 @@ vax_output_int_add (rtx insn ATTRIBUTE_U
       if (rtx_equal_p (operands[0], operands[2]))
 	return "addl2 %1,%0";
 
-      if (GET_CODE (operands[2]) == CONST_INT
+      if (CONST_INT_P (operands[2])
 	  && INTVAL (operands[2]) < 32767
 	  && INTVAL (operands[2]) > -32768
 	  && REG_P (operands[1])
 	  && push_operand (operands[0], SImode))
 	return "pushab %c2(%1)";
 
-      if (GET_CODE (operands[2]) == CONST_INT
+      if (CONST_INT_P (operands[2])
 	  && (unsigned) (- INTVAL (operands[2])) < 64)
 	return "subl3 $%n2,%1,%0";
 
-      if (GET_CODE (operands[2]) == CONST_INT
+      if (CONST_INT_P (operands[2])
 	  && (unsigned) INTVAL (operands[2]) >= 64
 	  && REG_P (operands[1])
 	  && ((INTVAL (operands[2]) < 32767 && INTVAL (operands[2]) > -32768)
@@ -1040,14 +1040,14 @@ vax_output_int_add (rtx insn ATTRIBUTE_U
 	    return "incw %0";
 	  if (operands[2] == constm1_rtx)
 	    return "decw %0";
-	  if (GET_CODE (operands[2]) == CONST_INT
+	  if (CONST_INT_P (operands[2])
 	      && (unsigned) (- INTVAL (operands[2])) < 64)
 	    return "subw2 $%n2,%0";
 	  return "addw2 %2,%0";
 	}
       if (rtx_equal_p (operands[0], operands[2]))
 	return "addw2 %1,%0";
-      if (GET_CODE (operands[2]) == CONST_INT
+      if (CONST_INT_P (operands[2])
 	  && (unsigned) (- INTVAL (operands[2])) < 64)
 	return "subw3 $%n2,%1,%0";
       return "addw3 %1,%2,%0";
@@ -1059,14 +1059,14 @@ vax_output_int_add (rtx insn ATTRIBUTE_U
 	    return "incb %0";
 	  if (operands[2] == constm1_rtx)
 	    return "decb %0";
-	  if (GET_CODE (operands[2]) == CONST_INT
+	  if (CONST_INT_P (operands[2])
 	      && (unsigned) (- INTVAL (operands[2])) < 64)
 	    return "subb2 $%n2,%0";
 	  return "addb2 %2,%0";
 	}
       if (rtx_equal_p (operands[0], operands[2]))
 	return "addb2 %1,%0";
-      if (GET_CODE (operands[2]) == CONST_INT
+      if (CONST_INT_P (operands[2])
 	  && (unsigned) (- INTVAL (operands[2])) < 64)
 	return "subb3 $%n2,%1,%0";
       return "addb3 %1,%2,%0";
@@ -1103,7 +1103,7 @@ int
 legitimate_constant_address_p (rtx x)
 {
   return (GET_CODE (x) == LABEL_REF || GET_CODE (x) == SYMBOL_REF
-	  || GET_CODE (x) == CONST_INT || GET_CODE (x) == CONST
+	  || CONST_INT_P (x) || GET_CODE (x) == CONST
 	  || GET_CODE (x) == HIGH);
 }
 
@@ -1217,12 +1217,12 @@ index_term_p (rtx prod, enum machine_mod
   xfoo0 = XEXP (prod, 0);
   xfoo1 = XEXP (prod, 1);
 
-  if (GET_CODE (xfoo0) == CONST_INT
+  if (CONST_INT_P (xfoo0)
       && INTVAL (xfoo0) == (int)GET_MODE_SIZE (mode)
       && INDEX_REGISTER_P (xfoo1, strict))
     return 1;
 
-  if (GET_CODE (xfoo1) == CONST_INT
+  if (CONST_INT_P (xfoo1)
       && INTVAL (xfoo1) == (int)GET_MODE_SIZE (mode)
       && INDEX_REGISTER_P (xfoo0, strict))
     return 1;
diff -Nurp src-gcc-fresh/gcc/config/vax/vax.h src-gcc-hacked/gcc/config/vax/vax.h
--- src-gcc-fresh/gcc/config/vax/vax.h	2006-03-15 23:43:55.000000000 +0100
+++ src-gcc-hacked/gcc/config/vax/vax.h	2006-03-15 23:48:51.000000000 +0100
@@ -872,24 +872,24 @@ VAX operand formatting codes:
     fputs (REGISTER_PREFIX, FILE);					\
   else if (CODE == 'C')							\
     fputs (rev_cond_name (X), FILE);					\
-  else if (CODE == 'D' && GET_CODE (X) == CONST_INT && INTVAL (X) < 0)	\
+  else if (CODE == 'D' && CONST_INT_P (X) && INTVAL (X) < 0)		\
     fprintf (FILE, "$" NEG_HWI_PRINT_HEX16, INTVAL (X));		\
-  else if (CODE == 'P' && GET_CODE (X) == CONST_INT)			\
+  else if (CODE == 'P' && CONST_INT_P (X))				\
     fprintf (FILE, "$" HOST_WIDE_INT_PRINT_DEC, INTVAL (X) + 1);	\
-  else if (CODE == 'N' && GET_CODE (X) == CONST_INT)			\
+  else if (CODE == 'N' && CONST_INT_P (X))				\
     fprintf (FILE, "$" HOST_WIDE_INT_PRINT_DEC, ~ INTVAL (X));		\
   /* rotl instruction cannot deal with negative arguments.  */		\
-  else if (CODE == 'R' && GET_CODE (X) == CONST_INT)			\
+  else if (CODE == 'R' && CONST_INT_P (X))				\
     fprintf (FILE, "$" HOST_WIDE_INT_PRINT_DEC, 32 - INTVAL (X));	\
-  else if (CODE == 'H' && GET_CODE (X) == CONST_INT)			\
+  else if (CODE == 'H' && CONST_INT_P (X))				\
     fprintf (FILE, "$%d", (int) (0xffff & ~ INTVAL (X)));		\
-  else if (CODE == 'h' && GET_CODE (X) == CONST_INT)			\
+  else if (CODE == 'h' && CONST_INT_P (X))				\
     fprintf (FILE, "$%d", (short) - INTVAL (x));			\
-  else if (CODE == 'B' && GET_CODE (X) == CONST_INT)			\
+  else if (CODE == 'B' && CONST_INT_P (X))				\
     fprintf (FILE, "$%d", (int) (0xff & ~ INTVAL (X)));			\
-  else if (CODE == 'b' && GET_CODE (X) == CONST_INT)			\
+  else if (CODE == 'b' && CONST_INT_P (X))				\
     fprintf (FILE, "$%d", (int) (0xff & - INTVAL (X)));			\
-  else if (CODE == 'M' && GET_CODE (X) == CONST_INT)			\
+  else if (CODE == 'M' && CONST_INT_P (X))				\
     fprintf (FILE, "$%d", ~((1 << INTVAL (x)) - 1));			\
   else if (REG_P (X))							\
     fprintf (FILE, "%s", reg_names[REGNO (X)]);				\
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	2006-03-15 23:43:55.000000000 +0100
+++ src-gcc-hacked/gcc/config/vax/vax.md	2006-03-16 00:00:53.000000000 +0100
@@ -152,7 +152,7 @@
   ""
   "*
 {
-  if (GET_CODE (operands[1]) == CONST_INT)
+  if (CONST_INT_P (operands[1]))
     {
       int i = INTVAL (operands[1]);
       if (i == 0)
@@ -173,7 +173,7 @@
   ""
   "*
 {
-  if (GET_CODE (operands[1]) == CONST_INT)
+  if (CONST_INT_P (operands[1]))
     {
       int i = INTVAL (operands[1]);
       if (i == 0)
@@ -528,14 +528,14 @@
   rtx op1 = operands[1];
 
   /* If there is a constant argument, complement that one.  */
-  if (GET_CODE (operands[2]) == CONST_INT && GET_CODE (op1) != CONST_INT)
+  if (CONST_INT_P (operands[2]) && !CONST_INT_P (op1))
     {
       operands[1] = operands[2];
       operands[2] = op1;
       op1 = operands[1];
     }
 
-  if (GET_CODE (op1) == CONST_INT)
+  if (CONST_INT_P (op1))
     operands[1] = GEN_INT (~INTVAL (op1));
   else
     operands[1] = expand_unop (<MODE>mode, one_cmpl_optab, op1, 0, 1);
@@ -621,7 +621,7 @@
   ""
   "
 {
-  if (GET_CODE (operands[2]) != CONST_INT)
+  if (!CONST_INT_P (operands[2]))
     operands[2] = gen_rtx_NEG (QImode, negate_rtx (QImode, operands[2]));
 }")
 
@@ -649,7 +649,7 @@
   if (operands[2] == const1_rtx && rtx_equal_p (operands[0], operands[1]))
     return \"addl2 %0,%0\";
   if (REG_P (operands[1])
-      && GET_CODE (operands[2]) == CONST_INT)
+      && CONST_INT_P (operands[2]))
     {
       int i = INTVAL (operands[2]);
       if (i == 1)
@@ -715,7 +715,7 @@
   ""
   "
 {
-  if (GET_CODE (operands[2]) != CONST_INT)
+  if (!CONST_INT_P (operands[2]))
     operands[2] = gen_rtx_NEG (QImode, negate_rtx (QImode, operands[2]));
 }")
 
@@ -871,7 +871,8 @@
   ""
   "*
 {
-  if (GET_CODE (operands[3]) != CONST_INT || GET_CODE (operands[2]) != CONST_INT
+  if (!CONST_INT_P (operands[3])
+      || !CONST_INT_P (operands[2])
       || !REG_P (operands[0])
       || (INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16))
     return \"extv %3,%2,%1,%0\";
@@ -888,7 +889,8 @@
   ""
   "*
 {
-  if (GET_CODE (operands[3]) != CONST_INT || GET_CODE (operands[2]) != CONST_INT
+  if (!CONST_INT_P (operands[3])
+      || !CONST_INT_P (operands[2])
       || !REG_P (operands[0]))
     return \"extzv %3,%2,%1,%0\";
   if (INTVAL (operands[2]) == 8)
@@ -934,8 +936,9 @@
   ""
   "*
 {
-  if (!REG_P (operands[0]) || GET_CODE (operands[2]) != CONST_INT
-      || GET_CODE (operands[3]) != CONST_INT
+  if (!REG_P (operands[0])
+      || !CONST_INT_P (operands[2])
+      || !CONST_INT_P (operands[3])
       || (INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16)
       || INTVAL (operands[2]) + INTVAL (operands[3]) > 32
       || side_effects_p (operands[1])
@@ -963,8 +966,9 @@
   ""
   "*
 {
-  if (!REG_P (operands[0]) || GET_CODE (operands[2]) != CONST_INT
-      || GET_CODE (operands[3]) != CONST_INT
+  if (!REG_P (operands[0])
+      || !CONST_INT_P (operands[2])
+      || !CONST_INT_P (operands[3])
       || INTVAL (operands[2]) + INTVAL (operands[3]) > 32
       || side_effects_p (operands[1])
       || (MEM_P (operands[1])
@@ -1151,7 +1155,7 @@
    (set (match_dup 0)
 	(plus:SI (match_dup 0)
 		 (const_int 1)))]
-  "!TARGET_UNIX_ASM && GET_CODE (operands[1]) == CONST_INT"
+  "!TARGET_UNIX_ASM && CONST_INT_P (operands[1])"
   "jaoblss %P1,%0,%l2")
 
 (define_insn ""
@@ -1178,7 +1182,7 @@
    (set (match_dup 0)
 	(plus:SI (match_dup 0)
 		 (const_int 1)))]
-  "!TARGET_UNIX_ASM && GET_CODE (operands[1]) == CONST_INT"
+  "!TARGET_UNIX_ASM && CONST_INT_P (operands[1])"
   "jaobleq %P1,%0,%l2")
 
 ;; Something like a sob insn, but compares against -1.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060316/3db826f5/attachment.sig>


More information about the Gcc-patches mailing list