[PATCH/m68k] properly align within code

Roman Zippel zippel@linux-m68k.org
Wed Sep 19 20:21:00 GMT 2007


Hi,

If using some of -falign options with a larger alignment, no proper nop
instruction is inserted. The patch uses "move.l %a4,%a4" as nop (the
real nop has synchronizing properties).
This patch also has been previously posted, but uses now 
HAVE_GAS_BALIGN_AND_P2ALIGN to make sure .balignw is available, otherwise 
it simply disables the align switch.

bye, Roman

2007-01-30  Roman Zippel <zippel@linux-m68k.org>

	* config/m68k/m68k.h (ASM_OUTPUT_ALIGN_WITH_NOP): New, use
	"move.l %a4,%a4" to produce nops.
	* config/m68k/m68k.c (override_options): Reset align options,
	if neccessary align macro isn't avaible.

---
 gcc/config/m68k/linux.h |    7 +++++++
 gcc/config/m68k/m68k.c  |   13 +++++++++++++
 2 files changed, 20 insertions(+)

Index: gcc/gcc/config/m68k/linux.h
===================================================================
--- gcc.orig/gcc/config/m68k/linux.h
+++ gcc/gcc/config/m68k/linux.h
@@ -123,6 +123,13 @@ along with GCC; see the file COPYING3.  
   if ((LOG) > 0)						\
     fprintf ((FILE), "%s%u\n", ALIGN_ASM_OP, 1 << (LOG));
 
+#ifdef HAVE_GAS_BALIGN_AND_P2ALIGN
+/* Use "move.l %a4,%a4" to advance within code.  */
+#define ASM_OUTPUT_ALIGN_WITH_NOP(FILE,LOG)			\
+  if ((LOG) > 0)						\
+    fprintf ((FILE), "\t.balignw %u,0x284c\n", 1 << (LOG));
+#endif
+
 /* If defined, a C expression whose value is a string containing the
    assembler operation to identify the following data as uninitialized global
    data.  */
Index: gcc/gcc/config/m68k/m68k.c
===================================================================
--- gcc.orig/gcc/config/m68k/m68k.c
+++ gcc/gcc/config/m68k/m68k.c
@@ -618,6 +618,19 @@ override_options (void)
       gcc_unreachable ();
     }
 
+#ifndef ASM_OUTPUT_ALIGN_WITH_NOP
+  if (align_labels > 2)
+    {
+      warning (0, "-falign-labels=%d is not supported", align_labels);
+      align_labels = 0;
+    }
+  if (align_loops > 2)
+    {
+      warning (0, "-falign-loops=%d is not supported", align_loops);
+      align_loops = 0;
+    }
+#endif
+
   SUBTARGET_OVERRIDE_OPTIONS;
 
   /* Setup scheduling options.  */



More information about the Gcc-patches mailing list