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]

Re: Patch for arm/pe warnings


 > From: Richard Earnshaw <rearnsha@arm.com>
 > 
 > 
 > > 	(HOST_INT, HOST_UINT): Check ANSI_PROTOTYPES and __GNUC__<3,
 > > 	not __STDC__.
 > 
 > No, I would rather this whole hackery went.


Alright, here's a patch which removes HOST_INT/HOST_UINT.  I tried to
follow what the 2.95 arm.[ch] did in terms of whether to leave the
numeric constant naked or use a HWI cast.  Tested by recompiling cc1
on a cross to arm-unknown-pe.

Ok to install?

		--Kaveh


2001-10-20  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* arm.h (HOST_INT, HOST_UINT): Delete.  Remove all uses.
	* arm.c (HOST_INT, HOST_UINT): Likewise.

diff -rup orig/egcs-CVS20011020/gcc/config/arm/arm.c egcs-CVS20011020/gcc/config/arm/arm.c
--- orig/egcs-CVS20011020/gcc/config/arm/arm.c	Sun Oct  7 12:26:59 2001
+++ egcs-CVS20011020/gcc/config/arm/arm.c	Sat Oct 20 15:29:45 2001
@@ -933,14 +933,14 @@ int
 const_ok_for_arm (i)
      HOST_WIDE_INT i;
 {
-  unsigned HOST_WIDE_INT mask = ~HOST_UINT (0xFF);
+  unsigned HOST_WIDE_INT mask = ~(unsigned HOST_WIDE_INT)0xFF;
 
   /* For machines with >32 bit HOST_WIDE_INT, the bits above bit 31 must 
      be all zero, or all one.  */
-  if ((i & ~HOST_UINT (0xffffffff)) != 0
-      && ((i & ~HOST_UINT (0xffffffff)) 
-	  != ((~HOST_UINT (0))
-	      & ~HOST_UINT (0xffffffff))))
+  if ((i & ~(unsigned HOST_WIDE_INT) 0xffffffff) != 0
+      && ((i & ~(unsigned HOST_WIDE_INT) 0xffffffff)
+	  != ((~(unsigned HOST_WIDE_INT) 0)
+	      & ~(unsigned HOST_WIDE_INT) 0xffffffff)))
     return FALSE;
   
   /* Fast return for 0 and powers of 2 */
@@ -949,12 +949,12 @@ const_ok_for_arm (i)
 
   do
     {
-      if ((i & mask & HOST_UINT (0xffffffff)) == 0)
+      if ((i & mask & (unsigned HOST_WIDE_INT) 0xffffffff) == 0)
         return TRUE;
       mask =
-	  (mask << 2) | ((mask & HOST_UINT (0xffffffff))
-			 >> (32 - 2)) | ~(HOST_UINT (0xffffffff));
-    } while (mask != ~HOST_UINT (0xFF));
+	  (mask << 2) | ((mask & (unsigned HOST_WIDE_INT) 0xffffffff)
+			  >> (32 - 2)) | ~(unsigned HOST_WIDE_INT) 0xffffffff;
+    } while (mask != ~(unsigned HOST_WIDE_INT) 0xFF);
 
   return FALSE;
 }
@@ -1101,7 +1101,7 @@ arm_gen_constant (code, mode, val, targe
   int set_zero_bit_copies = 0;
   int insns = 0;
   unsigned HOST_WIDE_INT temp1, temp2;
-  unsigned HOST_WIDE_INT remainder = val & HOST_UINT (0xffffffff);
+  unsigned HOST_WIDE_INT remainder = val & 0xffffffff;
 
   /* Find out which operations are safe for a given CODE.  Also do a quick
      check for degenerate cases; these can occur when DImode operations
@@ -1120,7 +1120,7 @@ arm_gen_constant (code, mode, val, targe
       break;
 
     case IOR:
-      if (remainder == HOST_UINT (0xffffffff))
+      if (remainder == 0xffffffff)
 	{
 	  if (generate)
 	    emit_insn (gen_rtx_SET (VOIDmode, target,
@@ -1144,7 +1144,7 @@ arm_gen_constant (code, mode, val, targe
 	    emit_insn (gen_rtx_SET (VOIDmode, target, const0_rtx));
 	  return 1;
 	}
-      if (remainder == HOST_UINT (0xffffffff))
+      if (remainder == 0xffffffff)
 	{
 	  if (reload_completed && rtx_equal_p (target, source))
 	    return 0;
@@ -1164,7 +1164,7 @@ arm_gen_constant (code, mode, val, targe
 	    emit_insn (gen_rtx_SET (VOIDmode, target, source));
 	  return 1;
 	}
-      if (remainder == HOST_UINT (0xffffffff))
+      if (remainder == 0xffffffff)
 	{
 	  if (generate)
 	    emit_insn (gen_rtx_SET (VOIDmode, target,
@@ -1292,16 +1292,15 @@ arm_gen_constant (code, mode, val, targe
 	 word.  We only look for the simplest cases, to do more would cost
 	 too much.  Be careful, however, not to generate this when the
 	 alternative would take fewer insns.  */
-      if (val & HOST_UINT (0xffff0000))
+      if (val & 0xffff0000)
 	{
-	  temp1 = remainder & HOST_UINT (0xffff0000);
+	  temp1 = remainder & 0xffff0000;
 	  temp2 = remainder & 0x0000ffff;
 
 	  /* Overlaps outside this range are best done using other methods.  */
 	  for (i = 9; i < 24; i++)
 	    {
-	      if ((((temp2 | (temp2 << i))
-		    & HOST_UINT (0xffffffff)) == remainder)
+	      if ((((temp2 | (temp2 << i)) & 0xffffffff) == remainder)
 		  && !const_ok_for_arm (temp2))
 		{
 		  rtx new_src = (subtargets
@@ -1439,11 +1438,11 @@ arm_gen_constant (code, mode, val, targe
       /* See if two shifts will do 2 or more insn's worth of work.  */
       if (clear_sign_bit_copies >= 16 && clear_sign_bit_copies < 24)
 	{
-	  HOST_WIDE_INT shift_mask = (((HOST_UINT (0xffffffff))
+	  HOST_WIDE_INT shift_mask = ((0xffffffff
 				       << (32 - clear_sign_bit_copies))
-				      & HOST_UINT (0xffffffff));
+				      & 0xffffffff);
 
-	  if ((remainder | shift_mask) != HOST_UINT (0xffffffff))
+	  if ((remainder | shift_mask) != 0xffffffff)
 	    {
 	      if (generate)
 		{
@@ -1476,7 +1475,7 @@ arm_gen_constant (code, mode, val, targe
 	{
 	  HOST_WIDE_INT shift_mask = (1 << clear_zero_bit_copies) - 1;
 	  
-	  if ((remainder | shift_mask) != HOST_UINT (0xffffffff))
+	  if ((remainder | shift_mask) != 0xffffffff)
 	    {
 	      if (generate)
 		{
@@ -1518,9 +1517,9 @@ arm_gen_constant (code, mode, val, targe
       num_bits_set++;
 
   if (code == AND || (can_invert && num_bits_set > 16))
-    remainder = (~remainder) & HOST_UINT (0xffffffff);
+    remainder = (~remainder) & 0xffffffff;
   else if (code == PLUS && num_bits_set > 16)
-    remainder = (-remainder) & HOST_UINT (0xffffffff);
+    remainder = (-remainder) & 0xffffffff;
   else
     {
       can_invert = 0;
@@ -1671,7 +1670,7 @@ arm_canonicalize_comparison (code, op1)
 
     case GT:
     case LE:
-      if (i != (((HOST_UINT (1)) << (HOST_BITS_PER_WIDE_INT - 1)) - 1)
+      if (i != ((((unsigned HOST_WIDE_INT) 1) << (HOST_BITS_PER_WIDE_INT - 1)) - 1)
 	  && (const_ok_for_arm (i + 1) || const_ok_for_arm (-(i + 1))))
 	{
 	  *op1 = GEN_INT (i + 1);
@@ -1681,7 +1680,7 @@ arm_canonicalize_comparison (code, op1)
 
     case GE:
     case LT:
-      if (i != ((HOST_UINT (1)) << (HOST_BITS_PER_WIDE_INT - 1))
+      if (i != (((unsigned HOST_WIDE_INT) 1) << (HOST_BITS_PER_WIDE_INT - 1))
 	  && (const_ok_for_arm (i - 1) || const_ok_for_arm (-(i - 1))))
 	{
 	  *op1 = GEN_INT (i - 1);
@@ -1691,7 +1690,7 @@ arm_canonicalize_comparison (code, op1)
 
     case GTU:
     case LEU:
-      if (i != ~(HOST_UINT (0))
+      if (i != ~((unsigned HOST_WIDE_INT) 0)
 	  && (const_ok_for_arm (i + 1) || const_ok_for_arm (-(i + 1))))
 	{
 	  *op1 = GEN_INT (i + 1);
@@ -2714,7 +2713,7 @@ arm_rtx_costs (x, code, outer)
       if (GET_CODE (XEXP (x, 1)) == CONST_INT)
 	{
 	  unsigned HOST_WIDE_INT i = (INTVAL (XEXP (x, 1))
-				      & HOST_UINT (0xffffffff));
+				      & (unsigned HOST_WIDE_INT) 0xffffffff);
 	  int add_cost = const_ok_for_arm (i) ? 4 : 8;
 	  int j;
 	  
@@ -4885,9 +4884,9 @@ arm_reload_in_hi (operands)
       if (lo == 4095)
 	lo &= 0x7ff;
 
-      hi = ((((offset - lo) & HOST_INT (0xffffffff))
-	     ^ HOST_INT (0x80000000))
-	    -  HOST_INT (0x80000000));
+      hi = ((((offset - lo) & (HOST_WIDE_INT) 0xffffffff)
+	     ^ (HOST_WIDE_INT) 0x80000000)
+	    - (HOST_WIDE_INT) 0x80000000);
 
       if (hi + lo != offset)
 	abort ();
@@ -5027,9 +5026,9 @@ arm_reload_out_hi (operands)
       if (lo == 4095)
 	lo &= 0x7ff;
 
-      hi = ((((offset - lo) & HOST_INT (0xffffffff))
-	     ^ HOST_INT (0x80000000))
-	    - HOST_INT (0x80000000));
+      hi = ((((offset - lo) & (HOST_WIDE_INT) 0xffffffff)
+	     ^ (HOST_WIDE_INT) 0x80000000)
+	    - (HOST_WIDE_INT) 0x80000000);
 
       if (hi + lo != offset)
 	abort ();
@@ -6748,7 +6747,7 @@ output_multi_immediate (operands, instr1
      HOST_WIDE_INT n;
 {
 #if HOST_BITS_PER_WIDE_INT > 32
-  n &= HOST_UINT (0xffffffff);
+  n &= 0xffffffff;
 #endif
 
   if (n == 0)
@@ -6897,7 +6896,7 @@ int_log2 (power)
 {
   HOST_WIDE_INT shift = 0;
 
-  while ((((HOST_INT (1)) << shift) & power) == 0)
+  while ((((HOST_WIDE_INT) 1 << shift) & power) == 0)
     {
       if (shift > 31)
 	abort ();
@@ -7325,7 +7324,7 @@ arm_poke_function_name (stream, name)
   
   ASM_OUTPUT_ASCII (stream, name, length);
   ASM_OUTPUT_ALIGN (stream, 2);
-  x = GEN_INT (HOST_UINT(0xff000000) + alignlength);
+  x = GEN_INT ((unsigned HOST_WIDE_INT) 0xff000000 + alignlength);
   ASM_OUTPUT_INT (stream, x);
 }
 
diff -rup orig/egcs-CVS20011020/gcc/config/arm/arm.h egcs-CVS20011020/gcc/config/arm/arm.h
--- orig/egcs-CVS20011020/gcc/config/arm/arm.h	Fri Oct 19 15:40:19 2001
+++ egcs-CVS20011020/gcc/config/arm/arm.h	Sat Oct 20 15:38:26 2001
@@ -1253,9 +1253,9 @@ enum reg_class
 	  else								   \
 	    break;							   \
 									   \
-	  high = ((((val - low) & HOST_UINT (0xffffffff))		   \
-		   ^ HOST_UINT (0x80000000))				   \
-		  - HOST_UINT (0x80000000));				   \
+	  high = ((((val - low) & (unsigned HOST_WIDE_INT) 0xffffffff)	   \
+		   ^ (unsigned HOST_WIDE_INT) 0x80000000)		   \
+		  - (unsigned HOST_WIDE_INT) 0x80000000);		   \
 	  /* Check for overflow or zero */				   \
 	  if (low == 0 || high == 0 || (high + low != val))		   \
 	    break;							   \
@@ -2662,22 +2662,12 @@ extern int making_const_table;
 #define PRINT_OPERAND(STREAM, X, CODE)  \
   arm_print_operand (STREAM, X, CODE)
 
-/* Create an [unsigned] host sized integer declaration that
-   avoids compiler warnings.  */
-#ifdef __STDC__
-#define HOST_INT(x)  ((signed HOST_WIDE_INT) x##UL)
-#define HOST_UINT(x) ((unsigned HOST_WIDE_INT) x##UL)
-#else
-#define HOST_INT(x)  ((HOST_WIDE_INT) x)
-#define HOST_UINT(x) ((unsigned HOST_WIDE_INT) x)
-#endif
-
 #define ARM_SIGN_EXTEND(x)  ((HOST_WIDE_INT)			\
   (HOST_BITS_PER_WIDE_INT <= 32 ? (unsigned HOST_WIDE_INT) (x)	\
-   : ((((unsigned HOST_WIDE_INT)(x)) & HOST_UINT (0xffffffff)) |\
-      ((((unsigned HOST_WIDE_INT)(x)) & HOST_UINT (0x80000000))	\
-       ? ((~ HOST_UINT (0))					\
-	  & ~ HOST_UINT(0xffffffff))				\
+   : ((((unsigned HOST_WIDE_INT)(x)) & (unsigned HOST_WIDE_INT) 0xffffffff) |\
+      ((((unsigned HOST_WIDE_INT)(x)) & (unsigned HOST_WIDE_INT) 0x80000000) \
+       ? ((~ (unsigned HOST_WIDE_INT) 0)			\
+	  & ~ (unsigned HOST_WIDE_INT) 0xffffffff)		\
        : 0))))
 
 /* Output the address of an operand.  */


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