This is the mail archive of the gcc@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]

Re: [buildrobot] sparc64-linux broken


On Mon, Apr 21, 2014 at 05:51:04PM -0400, Michael Meissner wrote:
> On Mon, Apr 21, 2014 at 08:02:39PM +0200, Jakub Jelinek wrote:
> > Sure, we could change this to use mode_size_inline ((enum machine_mode) (MODE))
> > in the macro instead, but I'd say for GCC codebase it is better if we fix
> > the few users of these macros that pass an int rather than enum machine_mode
> > to these macros.
> 
> I fixed the powerpc (PR 60876), and while it would have been nice to have
> tested this against more backends, it was fairly simple to go through the
> GET_MODE_SIZE's and make them type correct.  For the PowerPC, it tended to be
> in code of the form:
> 
> 	for (m = 0; m < NUM_MACHINE_MODES; ++m)
> 	  {
> 	    // ...
> 	    if (GET_MODE_SIZE (m)) ...
> 	  }
> 
> and the fix was to do something like:
> 
> 	for (m = 0; m < NUM_MACHINE_MODES; ++m)
> 	  {
> 	    enum machine_mode m2 = (enum machine_mode)m;
> 	    // ...
> 	    if (GET_MODE_SIZE (m2)) ...
> 	  }
> 
> It reminds me when I was in the original ANSI C committee that made the 1989
> ANSI and 1990 ISO C standards, we debated making enum's more first class
> citizens, so you could do ++/-- on them, but the committee tended to be divided
> into 3 camps, one that wanted to delete enums altogether, one that wanted them
> as int constants, and one that wanted more type checking.

I've committed following fix as obvious after testing it with a
x86_64->sparc64-linux cross-compiler.

2014-04-22  Jakub Jelinek  <jakub@redhat.com>

	PR target/60910
	* config/sparc/sparc.c (sparc_init_modes): Pass enum machine_mode
	value instead of int to GET_MODE_CLASS and GET_MODE_SIZE macros.

--- gcc/config/sparc/sparc.c.jj	2014-04-17 14:49:04.000000000 +0200
+++ gcc/config/sparc/sparc.c	2014-04-22 09:21:52.192036251 +0200
@@ -4821,47 +4821,48 @@ sparc_init_modes (void)
 
   for (i = 0; i < NUM_MACHINE_MODES; i++)
     {
-      switch (GET_MODE_CLASS (i))
+      enum machine_mode m = (enum machine_mode) i;
+      switch (GET_MODE_CLASS (m))
 	{
 	case MODE_INT:
 	case MODE_PARTIAL_INT:
 	case MODE_COMPLEX_INT:
-	  if (GET_MODE_SIZE (i) < 4)
+	  if (GET_MODE_SIZE (m) < 4)
 	    sparc_mode_class[i] = 1 << (int) H_MODE;
-	  else if (GET_MODE_SIZE (i) == 4)
+	  else if (GET_MODE_SIZE (m) == 4)
 	    sparc_mode_class[i] = 1 << (int) S_MODE;
-	  else if (GET_MODE_SIZE (i) == 8)
+	  else if (GET_MODE_SIZE (m) == 8)
 	    sparc_mode_class[i] = 1 << (int) D_MODE;
-	  else if (GET_MODE_SIZE (i) == 16)
+	  else if (GET_MODE_SIZE (m) == 16)
 	    sparc_mode_class[i] = 1 << (int) T_MODE;
-	  else if (GET_MODE_SIZE (i) == 32)
+	  else if (GET_MODE_SIZE (m) == 32)
 	    sparc_mode_class[i] = 1 << (int) O_MODE;
 	  else
 	    sparc_mode_class[i] = 0;
 	  break;
 	case MODE_VECTOR_INT:
-	  if (GET_MODE_SIZE (i) == 4)
+	  if (GET_MODE_SIZE (m) == 4)
 	    sparc_mode_class[i] = 1 << (int) SF_MODE;
-	  else if (GET_MODE_SIZE (i) == 8)
+	  else if (GET_MODE_SIZE (m) == 8)
 	    sparc_mode_class[i] = 1 << (int) DF_MODE;
 	  else
 	    sparc_mode_class[i] = 0;
 	  break;
 	case MODE_FLOAT:
 	case MODE_COMPLEX_FLOAT:
-	  if (GET_MODE_SIZE (i) == 4)
+	  if (GET_MODE_SIZE (m) == 4)
 	    sparc_mode_class[i] = 1 << (int) SF_MODE;
-	  else if (GET_MODE_SIZE (i) == 8)
+	  else if (GET_MODE_SIZE (m) == 8)
 	    sparc_mode_class[i] = 1 << (int) DF_MODE;
-	  else if (GET_MODE_SIZE (i) == 16)
+	  else if (GET_MODE_SIZE (m) == 16)
 	    sparc_mode_class[i] = 1 << (int) TF_MODE;
-	  else if (GET_MODE_SIZE (i) == 32)
+	  else if (GET_MODE_SIZE (m) == 32)
 	    sparc_mode_class[i] = 1 << (int) OF_MODE;
 	  else
 	    sparc_mode_class[i] = 0;
 	  break;
 	case MODE_CC:
-	  if (i == (int) CCFPmode || i == (int) CCFPEmode)
+	  if (m == CCFPmode || m == CCFPEmode)
 	    sparc_mode_class[i] = 1 << (int) CCFP_MODE;
 	  else
 	    sparc_mode_class[i] = 1 << (int) CC_MODE;


	Jakub


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