CVS: gcc/gcc-3.3/gcc/config/msp430 msp430.c, 1.95, 1.96 msp430.h, 1.43, 1.44

Chris Liechti <[email protected]> Thu, 29 May 2008 01:10:12 -0700
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/gcc/gcc-3.3/gcc/config/msp430
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10197/gcc/config/msp430

Modified Files:
	msp430.c msp430.h 
Log Message:
fixing -ffunction-sections and -fdata-sections (Grant)
improve readablity of asm outut by adding some whitespace


Index: msp430.c
===================================================================
RCS file: /cvsroot/mspgcc/gcc/gcc-3.3/gcc/config/msp430/msp430.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -w -d -r1.95 -r1.96
--- msp430.c	22 May 2008 16:06:02 -0000	1.95
+++ msp430.c	29 May 2008 08:10:04 -0000	1.96
@@ -858,14 +858,7 @@
   /* naked function discards everything */
   if (msp430_naked_function_p (current_function_decl))
     {
-      fprintf (file, "/* prologue: naked */\n");
-      fprintf (file, ".L__FrameSize_%s=0x%x\n", fnname, size);
-      return;
-    }
-
-  if (msp430_naked_function_p (current_function_decl))
-    {
-      fprintf (file, "/* prologue: naked */\n");
+      fprintf (file, "\t/* prologue: naked */\n");
       fprintf (file, ".L__FrameSize_%s=0x%x\n", fnname, size);
       return;
     }
@@ -883,7 +876,7 @@
 	}
     }
 
-  fprintf (file, "/* prologue: frame size = %d */\n", size);
+  fprintf (file, "\t/* prologue: frame size = %d */\n", size);
   fprintf (file, ".L__FrameSize_%s=0x%x\n", fnname, size);
 
 
@@ -1028,7 +1021,7 @@
 	}
     }
 
-  fprintf (file, "/* prologue end (size=%d) */\n", prologue_size);
+  fprintf (file, "\t/* prologue end (size=%d) */\n\n", prologue_size);
 }
 
 
@@ -1060,13 +1053,13 @@
 
   if (msp430_task_function_p (current_function_decl))
     {
-      fprintf (file, "/* epilogue: empty, task functions never return */\n");
+      fprintf (file, "\n\t/* epilogue: empty, task functions never return */\n");
       return;
     }
 
   if (msp430_naked_function_p (current_function_decl))
     {
-      fprintf (file, "/* epilogue: naked */\n");
+      fprintf (file, "\n\t/* epilogue: naked */\n");
       return;
     }
 
@@ -1077,7 +1070,7 @@
 	  fprintf (file, "\t%s\n", msp430_emit_return (NULL, NULL, NULL));
 	  epilogue_size++;
 	}
-      fprintf (file, "/* epilogue: not required */\n");
+      fprintf (file, "\n\t/* epilogue: not required */\n");
       goto done_epilogue;
     }
 
@@ -1086,7 +1079,7 @@
   if (cfp && interrupt_func_p)
     cfp = 0;
 
-  fprintf (file, "/* epilogue: frame size=%d */\n", size);
+  fprintf (file, "\n\t/* epilogue: frame size=%d */\n", size);
 
   if (main_p)
     {
@@ -1172,9 +1165,9 @@
 	}
     }
 
-  fprintf (file, "/* epilogue end (size=%d) */\n", epilogue_size);
+  fprintf (file, "\t/* epilogue end (size=%d) */\n", epilogue_size);
 done_epilogue:
-  fprintf (file, "/* function %s size %d (%d) */\n", current_function_name,
+  fprintf (file, "\t/* function %s size %d (%d) */\n", current_function_name,
 	   prologue_size + function_size + epilogue_size, function_size);
 
   commands_in_file += prologue_size + function_size + epilogue_size;
@@ -2049,27 +2042,20 @@
   const char *name, *prefix;
   char *string;
   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-  /* Strip off any encoding in name.  */
   STRIP_NAME_ENCODING (name, name);
 
-  if (TREE_CODE (decl) == FUNCTION_DECL)
-    {
-      if (flag_function_sections)
+  if ((TREE_CODE (decl) == FUNCTION_DECL) || DECL_READONLY_SECTION (decl, 0))
 	prefix = ".text.";
+  else if ((DECL_INITIAL (decl) == 0) || (DECL_INITIAL (decl) == error_mark_node))
+    prefix = ".bss.";
       else
-	prefix = ".text";
-    }
-  else
-    abort ();
+    prefix = ".data.";
 
-  if (flag_function_sections)
-    {
       len = strlen (name) + strlen (prefix);
       string = alloca (len + 1);
       sprintf (string, "%s%s", prefix, name);
       DECL_SECTION_NAME (decl) = build_string (len, string);
     }
-}
 
 
 /* Output section name to file FILE

Index: msp430.h
===================================================================
RCS file: /cvsroot/mspgcc/gcc/gcc-3.3/gcc/config/msp430/msp430.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -w -d -r1.43 -r1.44
--- msp430.h	28 May 2008 13:07:46 -0000	1.43
+++ msp430.h	29 May 2008 08:10:05 -0000	1.44
@@ -127,6 +127,9 @@
 #define OVERRIDE_OPTIONS msp430_override_options()
 
 #define CAN_DEBUG_WITHOUT_FP
+/* Define this macro if debugging can be performed even without a
+   frame pointer.  If this macro is defined, GNU CC will turn on the
+   `-fomit-frame-pointer' option whenever `-O' is specified.  */
 
 #define BITS_BIG_ENDIAN 0
 #define BYTES_BIG_ENDIAN 0
@@ -2064,56 +2067,89 @@
 		asm_fprintf ((FILE), "%U%s", (NAME));	\
 } while(0)
 
+/* macros to output uninitialized variable definitions */
 
+/* Return a non-zero value if DECL has a section attribute.  */
+#define IN_NAMED_SECTION(DECL)                                           \
+  ((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL)    \
+   && DECL_SECTION_NAME (DECL) != NULL_TREE)
 
+/* macro to output uninitialized varible in normal case where -fno-common is not specified */
 
-#define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)	\
-do {							\
+#undef  ASM_OUTPUT_ALIGNED_DECL_COMMON
+#define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN)   \
+  do                                                                    \
+    {                                                                   \
      char *p = NAME;					\
      if(*p == '*' || *p == '@' ) p++;			\
      if(*p >= '0' && *p <= '9' ) break;			\
-     fputs ("\t.global\t__do_clear_bss\n\t.comm ", (STREAM));			\
-     assemble_name ((STREAM), (NAME));			\
-     fprintf ((STREAM), ",%d%s", (SIZE), (SIZE)>1?",2\n":"\n");\
-} while (0)
-/* A C statement (sans semicolon) to output to the stdio stream
-   STREAM the assembler definition of a common-label named NAME whose
-   size is SIZE bytes.  The variable ROUNDED is the size rounded up
-   to whatever alignment the caller wants.
-
-   Use the expression `assemble_name (STREAM, NAME)' to output the
-   name itself; before and after that, output the additional
-   assembler syntax for defining the name, and a newline.
-
-   This macro controls how the assembler definitions of uninitialized
-   common global variables are output.  */
+      if (IN_NAMED_SECTION (DECL))                                      \
+        {                                                               \
+          /* case where -fdata-sections is specified */                 \
+          fputs ("\t.global\t__do_clear_bss\n", (FILE));                \
+          named_section (DECL, NULL, 0);                                \
+          ASM_GLOBALIZE_LABEL (FILE, NAME);                             \
+          ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT));  \
+          last_assemble_variable_decl = DECL;                           \
+          ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL);                   \
+          ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1);                      \
+        }                                                               \
+      else                                                              \
+        {                                                               \
+          /* default case */                                            \
+          fputs ("\t.global\t__do_clear_bss\n\t.comm ", (FILE));        \
+          assemble_name ((FILE), (NAME));                               \
+          fprintf ((FILE), ",%d%s", (SIZE), (SIZE)>1?",2\n":"\n");      \
+        }                                                               \
+    }                                                                   \
+  while (0)
 
-#define ASM_OUTPUT_BSS(FILE, DECL, NAME, SIZE, ROUNDED)			\
-  asm_output_bss ((FILE), (DECL), (NAME), (SIZE), (ROUNDED))
 
-#define ASM_OUTPUT_LOCAL(STREAM, NAME, SIZE, ROUNDED)	\
-do {							\
+/* macro to output uninitialized variable when -fno-common _is_ specified */
+#undef  ASM_OUTPUT_ALIGNED_BSS
+#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)   \
+  do                                                                    \
+    {                                                                   \
      char *p = NAME;					\
      if(*p == '*' || *p == '@' ) p++;			\
      if(*p >= '0' && *p <= '9' ) break;			\
-     fputs ("\t.local ", (STREAM));			\
-     assemble_name ((STREAM), (NAME));			\
-     fputs ("\n",(STREAM));				\
-     fputs ("\t.comm ", (STREAM));                     	\
-     assemble_name ((STREAM), (NAME));			\
-     fprintf ((STREAM), ",%d%s", (SIZE),(SIZE)>1?",2\n":"\n");\
-} while (0)
-/* A C statement (sans semicolon) to output to the stdio stream
-   STREAM the assembler definition of a local-common-label named NAME
-   whose size is SIZE bytes.  The variable ROUNDED is the size
-   rounded up to whatever alignment the caller wants.
+      if (IN_NAMED_SECTION (DECL))                                      \
+        {                                                               \
+          fputs ("\t.global\t__do_clear_bss\n", (FILE));                \
+          named_section (DECL, NULL, 0);                                \
+        }                                                               \
+      else                                                              \
+        bss_section ();                                                 \
+                                                                        \
+      ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT));      \
+                                                                        \
+      last_assemble_variable_decl = DECL;                               \
+      ASM_DECLARE_OBJECT_NAME (FILE, NAME, DECL);                       \
+      ASM_OUTPUT_SKIP (FILE, SIZE ? SIZE : 1);                          \
+    }                                                                   \
+  while (0)
 
-   Use the expression `assemble_name (STREAM, NAME)' to output the
-   name itself; before and after that, output the additional
-   assembler syntax for defining the name, and a newline.
 
-   This macro controls how the assembler definitions of uninitialized
-   static variables are output.  */
+#undef  ASM_OUTPUT_ALIGNED_DECL_LOCAL
+#define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN)    \
+  do                                                                    \
+    {                                                                   \
+      char *p = NAME;                                                   \
+      if(*p == '*' || *p == '@' ) p++;                                  \
+      if(*p >= '0' && *p <= '9' ) break;                                \
+      if ((DECL) != NULL && IN_NAMED_SECTION (DECL))                    \
+        {                                                               \
+          fputs ("\t.global\t__do_clear_bss\n", (FILE));                \
+          named_section (DECL, NULL, 0);                                \
+        }                                                               \
+      else                                                              \
+        bss_section ();                                                 \
+                                                                        \
+      ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT));      \
+      ASM_OUTPUT_LABEL (FILE, NAME);                                    \
+      fprintf (FILE, "\t.space\t%d\n", SIZE);                           \
+    }                                                                   \
+  while (0)
 
 #define BSS_SECTION_ASM_OP	"\t.global\t__do_clear_bss\n\t.section\t.bss"
 /* If defined, a C expression whose value is a string containing the
@@ -2290,6 +2326,9 @@
 
 #define ASM_GLOBALIZE_LABEL(STREAM, NAME)	\
 do {						\
+  char *p = NAME;                               \
+  if(*p == '*' || *p == '@' ) p++;              \
+  if(*p >= '0' && *p <= '9' ) break;            \
   fprintf (STREAM, ".global\t");		\
   assemble_name (STREAM, NAME);			\
   fprintf (STREAM, "\n");			\
@@ -3325,13 +3364,12 @@
 #endif
 
 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
+#define DWARF2_DEBUGGING_INFO 1
+#define OBJECT_FORMAT_ELF
 
 #define DBX_REGISTER_NUMBER(r) (r)
 
 /* Get the standard ELF stabs definitions.  */
 #include "dbxelf.h"
 
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-#define DWARF2_DEBUGGING_INFO 1
-#define OBJECT_FORMAT_ELF
 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/