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]

Re: [patch,m68k] Get rid of #ifdef MOTOROLA


Gunther Nikl wrote:

As discussed with Gunther Nikl a few weeks days ago, this patch turns
most occurrences of "#ifdef MOTOROLA" in m68k.c to C statements
testing for its value.

Most is not good enough I am afraid. All occurrences must be converted and it seems you forgot the MD file. I also believe config.gcc must get adjusted since MOTOROLA is already present in some tm_defines.

Well, actually MOTOROLA will be _undefined_ in all files but m68k.c. It's only there that I define it conditionally to 0 if it is undefined.

In all other places, MOTOROLA is set to 1. Well, you're right about the
tm_defines. I'll see if it's possible to preset a value for it.

Otherwise, I could do this in m68k.c:

 /* Force a truth value for MOTOROLA.  */
 #ifdef MOTOROLA
 # undef MOTOROLA
 # define MOTOROLA 1
 #else
 # define MOTOROLA 0
 #endif


Regtesting on a MIT target would be highly desiderable before applying,
but I have no easy way to do it.

Since the MD file isn't converted I don't think I can test it. I have some comments on the patch.

You can. I'd suggest converting m68k.md later, because it's already a massive patch now, and the place where it makes most sense to do this change is m68k.c anyway.


diff -u -p -u -p -r1.119 m68k.c
--- gcc/config/m68k/m68k.c	30 Oct 2003 00:55:15 -0000	1.119
+++ gcc/config/m68k/m68k.c	7 Nov 2003 07:15:19 -0000
+#ifndef MOTOROLA
+#define MOTOROLA 0 /* Use the MIT syntax */
+#endif

I don't think this the correct way to define MOTOROLA if its not defined. It should be defined in m68k.h to a value used by the majority of targets. All other targets must provide the value through config.gcc.

I agree, but we can do that only when all of config/m68k/ has been converted. Wouldn't it be better to do it in two or more steps?


+/* The ASM_DOT macro allows easy string pasting to handle the differences
+   between MOTOROLA and MIT syntaxes in asm_fprintf().  */
+#if MOTOROLA
+# define ASM_DOT "."
+# define ASM_DOTW ".w"
+# define ASM_DOTL ".l"
+#else
+# define ASM_DOT ""
+# define ASM_DOTW ""
+# define ASM_DOTL ""
+#endif

This would have to be in m68k.h then. BTW, you should mention the fact that asm_fprintf doesn't handle "%." ;-)

Yeah... that would be the famous place where it would make sense to tell it at once ;-)


-#ifdef MOTOROLA
-	  fprintf (stream, "\tpea (%s)\n\tmove.l %s,%s\n",
-		   reg_names[FRAME_POINTER_REGNUM],
-		   reg_names[STACK_POINTER_REGNUM],
-		   reg_names[FRAME_POINTER_REGNUM]);
-#else
-	  fprintf (stream, "\tpea %s@\n\tmovel %s,%s\n",
-		   reg_names[FRAME_POINTER_REGNUM],
-		   reg_names[STACK_POINTER_REGNUM],
-		   reg_names[FRAME_POINTER_REGNUM]);
-#endif
-	}
+	fprintf (stream, MOTOROLA ?
+			   "\tpea (%s)\n\tmove.l %s,%s\n" :
+			   "\tpea %s@\n\tmovel %s,%s\n",
+		 reg_names[FRAME_POINTER_REGNUM],
+		 reg_names[STACK_POINTER_REGNUM],
+		 reg_names[FRAME_POINTER_REGNUM]);
     else if (fsize_with_regs < 0x8000)

I like this transformation but be careful with argument order.

Yes, it's not possible in all places. This one works by luck ;)




-      if (TARGET_COLDFIRE)
-        {
-#ifdef MOTOROLA
-          asm_fprintf (stream, "\t%Omove.l %I%d,%Ra1\n",
-		       -fsize - current_frame.offset);
-#else
-          asm_fprintf (stream, "\tmovel %I%d,%Ra1\n",
-		       -fsize - current_frame.offset);
-#endif
-        }
-      else
-        {
-#ifdef MOTOROLA
-          asm_fprintf (stream, "\t%Omove.l %I%wd,%Ra1\n", -fsize);
-#else
-          asm_fprintf (stream, "\tmovel %I%wd,%Ra1\n", -fsize);
-#endif
-        }
+      asm_fprintf (stream, "\t%Omove" ASM_DOT "l %I%wd,%Ra1\n",
+	           TARGET_COLDFIRE ? -fsize - current_frame.offset : -fsize);


  This might be wrong because the MOTOROLA case has %O and the non-MOTOROLA
  case doesn't have it.

%O replaces an opcode with its assembler specific version. It shouldn't affect MIT syntax output. On the countrary, we could take advantage of it to merge more instructions: those where the only difference is in the opcode name.

  Then I would prefer to adjust fsize before the printf
  since fsize is clobbered after that statement:

     fsize = 0, big = true;
   }

here.

You're right, the change you suggest would also allow me to move the ColdFire specific comment next to ColdFire specific code.


  Lastly, it might be a good idea to turn most other symbols used in
  #if[n]def into 0/1 defines eg. SGS, SGS_CMP_ORDER, USE_GAS, HPUX_ASM.
  That might be the next step.

Yes, I was planning to do that too, but then I noticed that the SGS assembler is only used by m68k-*-sysv and m68k-*-hp*, both of which are good candidates for obsoletion in 3.5. So it's probably not worth doing.

--
 // Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/  http://www.develer.com/




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