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]

[PATCH] Boolize darwin's target files, and clean up and fix compat testcases


Sorry for combining the patches for these three things but I was just doing them at the same time.
If you want them sent separately I can do that as well.


To fix some of the compat testcases on Darwin, the size outputted for the .comm and .lcomm
cannot be zero, Geoff Keating caught some of these cases already, I found some more where
it needed to be fixed.


To help out for fixing part of the darwin back-end so that it will only find out if the
function needs a stub only when outputting the symbol, I made two new functions,
machopic_define_data_name and machopic_define_function_name which right now just do the
same as machopic_define_name just to do.


I also combined the if statements in a couple of the defines so that it can be easier to
understand what was going on.


OK? Bootstrapped on powerpc-apple-darwin with no regressions and all of compat testcases
pass now.


Thanks,
Andrew Pinski

ChangeLog:
	* config/darwin-protos.h (name_needs_quotes):
	Change return type to bool.
	(machopic_operand_p): Likewise.
	(machopic_name_defined_p): Likewise.
	(machopic_ident_defined_p): Likewise.
	(machopic_define_name): Remove.
	(machopic_define_data_name): Declare.
	(machopic_define_function_name): Declare.
	* config/darwin.c (name_needs_quotes):
	Change return type to bool.
	(machopic_ident_defined_p): Likewise.
	(machopic_data_defined_p): Likewise.
	(machopic_name_defined_p): Likewise.
	(machopic_define_name): Remove.
	(machopic_define_data_name): New function.
	(machopic_define_function_name): New function.
	(machopic_stub_name): Boolize.
	(machopic_operand_p): Change return type to bool.
	(darwin_asm_named_section): Do not use
	SECTION_FORMAT_STRING.
	(darwin_emit_unwind_label): Boolize.
	* config/darwin.h (ASM_DECLARE_OBJECT_NAME):
	Combine the ifs and call machopic_define_data_name
	instead of machopic_define_name.
	(ASM_DECLARE_FUNCTION_NAME): Combine the ifs
	and call machopic_define_function_name
	instead of machopic_define_name.
	(ASM_OUTPUT_ALIGNED_DECL_LOCAL): Size cannot be 0.
	Combine the ifs and call machopic_define_data_name
	instead of machopic_define_name.
	* config/rs6000/darwin.h (SECTION_FORMAT_STRING):
	Remove.
	(ASM_OUTPUT_COMMON): Size cannot 0 and reformat.
	


Patch: ? temp.darwin.txt Index: darwin-protos.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/darwin-protos.h,v retrieving revision 1.34 diff -u -p -r1.34 darwin-protos.h --- darwin-protos.h 12 Mar 2004 17:08:58 -0000 1.34 +++ darwin-protos.h 12 Apr 2004 13:27:23 -0000 @@ -18,7 +18,7 @@ along with GCC; see the file COPYING. I the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

-extern int name_needs_quotes (const char *);
+extern bool name_needs_quotes (const char *);

extern void machopic_validate_stub_or_non_lazy_ptr (const char *, int);

@@ -40,7 +40,7 @@ extern void mod_term_section (void);

#ifdef RTX_CODE

-extern int machopic_operand_p (rtx);
+extern bool machopic_operand_p (rtx);
 extern enum machopic_addr_class machopic_classify_name (const char*);

 extern rtx machopic_indirect_data_reference (rtx, rtx);
@@ -55,9 +55,10 @@ extern void machopic_asm_out_destructor

 extern enum machopic_addr_class machopic_classify_ident (tree);
 extern void machopic_define_ident (tree);
-extern void machopic_define_name (const char*);
-extern int machopic_name_defined_p (const char*);
-extern int machopic_ident_defined_p (tree);
+extern void machopic_define_data_name (const char*);
+extern void machopic_define_function_name (const char*);
+extern bool machopic_name_defined_p (const char*);
+extern bool machopic_ident_defined_p (tree);
 extern void darwin_encode_section_info (tree, rtx, int);
 extern const char *darwin_strip_name_encoding (const char *);

Index: darwin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.c,v
retrieving revision 1.66
diff -u -p -r1.66 darwin.c
--- darwin.c	9 Apr 2004 19:57:44 -0000	1.66
+++ darwin.c	12 Apr 2004 13:27:23 -0000
@@ -43,12 +43,12 @@ Boston, MA 02111-1307, USA.  */
 #include "tm_p.h"
 #include "errors.h"

-static int machopic_data_defined_p (const char *);
+static bool machopic_data_defined_p (const char *);
 static void update_non_lazy_ptrs (const char *);
 static void update_stubs (const char *);
 static const char *machopic_non_lazy_ptr_name (const char*);

-int
+bool
 name_needs_quotes (const char *name)
 {
   int c;
@@ -170,7 +170,7 @@ machopic_classify_name (const char *name
   return machopic_classify_ident (get_identifier (name));
 }

-int
+bool
 machopic_ident_defined_p (tree ident)
 {
   switch (machopic_classify_ident (ident))
@@ -184,7 +184,7 @@ machopic_ident_defined_p (tree ident)
     }
 }

-static int
+static bool
 machopic_data_defined_p (const char *name)
 {
   switch (machopic_classify_ident (get_identifier (name)))
@@ -196,7 +196,7 @@ machopic_data_defined_p (const char *nam
     }
 }

-int
+bool
 machopic_name_defined_p (const char *name)
 {
   return machopic_ident_defined_p (get_identifier (name));
@@ -211,11 +211,18 @@ machopic_define_ident (tree ident)
 }

 void
-machopic_define_name (const char *name)
+machopic_define_data_name (const char *name)
 {
   machopic_define_ident (get_identifier (name));
 }

+void
+machopic_define_function_name (const char *name)
+{
+  machopic_define_ident (get_identifier (name));
+}
+
+
 static GTY(()) char * function_base;

 const char *
@@ -361,7 +368,7 @@ machopic_stub_name (const char *name)
     int bufferlen = 0;
     int namelen = strlen (name);
     tree ptr_name;
-    int needs_quotes = name_needs_quotes (name);
+    bool needs_quotes = name_needs_quotes (name);

buffer = alloca (namelen + 20);

@@ -445,7 +452,7 @@ machopic_indirect_data_reference (rtx or
   if (GET_CODE (orig) == SYMBOL_REF)
     {
       const char *name = XSTR (orig, 0);
-      int defined = machopic_data_defined_p (name);
+      bool defined = machopic_data_defined_p (name);

       if (defined && MACHO_DYNAMIC_NO_PIC_P)
 	{
@@ -951,7 +958,7 @@ machopic_finish (FILE *asm_out_file)
     }
 }

-int
+bool
machopic_operand_p (rtx op)
{
if (MACHOPIC_JUST_INDIRECT)
@@ -1304,9 +1311,6 @@ darwin_globalize_label (FILE *stream, co
void
darwin_asm_named_section (const char *name, unsigned int flags ATTRIBUTE_UNUSED)
{
- if (flag_reorder_blocks_and_partition)
- fprintf (asm_out_file, SECTION_FORMAT_STRING, name);
- else
fprintf (asm_out_file, ".section %s\n", name);
}


@@ -1352,7 +1356,7 @@ darwin_emit_unwind_label(FILE *file, tre
   const char *suffix = ".eh";
   unsigned int suffix_len = 3;

-  int need_quotes = name_needs_quotes (base);
+  bool need_quotes = name_needs_quotes (base);
   int quotes_len = need_quotes ? 2 : 0;

char *lab = xmalloc (prefix_len + base_len + suffix_len + quotes_len + 1);
Index: darwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.h,v
retrieving revision 1.77
diff -u -p -r1.77 darwin.h
--- darwin.h 6 Apr 2004 18:44:08 -0000 1.77
+++ darwin.h 12 Apr 2004 13:27:23 -0000
@@ -401,8 +401,8 @@ do { text_section (); \


/* The RTTI data (e.g., __ti4name) is common and public (and static),
but it does need to be referenced via indirect PIC data pointers.
- The machopic_define_name calls are telling the machopic subsystem
- that the name *is* defined in this module, so it doesn't need to
+ The machopic_define_datename calls are telling the machopic subsystem
+ that the data name *is* defined in this module, so it doesn't need to
make them indirect. */


#undef ASM_DECLARE_OBJECT_NAME
@@ -411,17 +411,16 @@ do { text_section (); \
const char *xname = NAME; \
if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
- if (! DECL_ONE_ONLY (DECL) && ! DECL_WEAK (DECL)) \
- if ((TREE_STATIC (DECL) \
- && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
- || DECL_INITIAL (DECL)) \
- machopic_define_name (xname); \
- if ((TREE_STATIC (DECL) \
- && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
- || DECL_INITIAL (DECL)) \
- (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
+ if ((TREE_STATIC (DECL) \
+ && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
+ || DECL_INITIAL (DECL)) \
+ { \
+ if (! DECL_ONE_ONLY (DECL) && ! DECL_WEAK (DECL)) \
+ machopic_define_data_name (xname); \
+ (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
+ } \
ASM_OUTPUT_LABEL (FILE, xname); \
- /* Darwin doesn't support zero-size objects, so give them a \
+ /* Darwin doesn't support zero-size objects, so give them a \
byte. */ \
if (tree_low_cst (DECL_SIZE_UNIT (DECL), 1) == 0) \
assemble_zeros (1); \
@@ -432,15 +431,14 @@ do { text_section (); \
const char *xname = NAME; \
if (GET_CODE (XEXP (DECL_RTL (DECL), 0)) != SYMBOL_REF) \
xname = IDENTIFIER_POINTER (DECL_NAME (DECL)); \
- if (! DECL_ONE_ONLY (DECL) && ! DECL_WEAK (DECL)) \
- if ((TREE_STATIC (DECL) \
- && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
- || DECL_INITIAL (DECL)) \
- machopic_define_name (xname); \
if ((TREE_STATIC (DECL) \
- && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
+ && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
|| DECL_INITIAL (DECL)) \
- (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
+ { \
+ if (! DECL_ONE_ONLY (DECL) && ! DECL_WEAK (DECL)) \
+ machopic_define_function_name (xname); \
+ (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
+ } \
ASM_OUTPUT_LABEL (FILE, xname); \
} while (0)


@@ -460,7 +458,7 @@ do { text_section (); \
#define ASM_OUTPUT_LABELREF(FILE,NAME) \
do { \
const char *xname = darwin_strip_name_encoding (NAME); \
- if (! strcmp (xname, "<pic base>")) \
+ if (!strcmp (xname, "<pic base>")) \
machopic_output_function_base_name(FILE); \
else if (xname[0] == '&' || xname[0] == '*') \
{ \
@@ -505,18 +503,20 @@ do { text_section (); \
#undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
#define ASM_OUTPUT_ALIGNED_DECL_LOCAL(FILE, DECL, NAME, SIZE, ALIGN) \
do { \
+ unsigned HOST_WIDE_INT size1 = (SIZE); \
+ /* Darwin does not support .lcomm of size 0. */ \
+ size1 = size1 == 0 ? 1 : size1; \
fputs (".lcomm ", (FILE)); \
assemble_name ((FILE), (NAME)); \
- fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", (SIZE), \
+ fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n", size1, \
floor_log2 ((ALIGN) / BITS_PER_UNIT)); \
if ((DECL) && ((TREE_STATIC (DECL) \
&& (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
|| DECL_INITIAL (DECL))) \
- (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
- if ((DECL) && ((TREE_STATIC (DECL) \
- && (!DECL_COMMON (DECL) || !TREE_PUBLIC (DECL))) \
- || DECL_INITIAL (DECL))) \
- machopic_define_name (NAME); \
+ { \
+ (* targetm.encode_section_info) (DECL, DECL_RTL (DECL), false); \
+ machopic_define_data_name (NAME); \
+ } \
} while (0)


/* The maximum alignment which the object file format can support.
Index: rs6000/darwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/darwin.h,v
retrieving revision 1.52
diff -u -p -r1.52 darwin.h
--- rs6000/darwin.h 9 Apr 2004 19:57:46 -0000 1.52
+++ rs6000/darwin.h 12 Apr 2004 13:27:24 -0000
@@ -148,7 +148,6 @@ do { \
#define NORMAL_TEXT_SECTION_NAME "__TEXT,__text,regular,pure_instructions"
#define UNLIKELY_EXECUTED_TEXT_SECTION_NAME \
"__TEXT,__unlikely,regular,pure_instructions"
-#define SECTION_FORMAT_STRING ".section %s\n\t.align 2\n"


 /* Define cutoff for using external functions to save floating point.
    Currently on Darwin, always use inline stores.  */
@@ -203,11 +202,16 @@ do {									\
    symbol.  */
 /* ? */
 #undef  ASM_OUTPUT_ALIGNED_COMMON
-#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)	\
-  do { fputs (".comm ", (FILE));			\
-       RS6000_OUTPUT_BASENAME ((FILE), (NAME));		\
-       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
-		(SIZE)); } while (0)
+#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)	 \
+  do {							 \
+    unsigned HOST_WIDE_INT size1 = (SIZE);		 \
+    /* Darwin does not support 0 sized common.   */	 \
+    size1 = size1 == 0 ? 1 : size1;			 \
+    fputs (".comm ", (FILE));				 \
+    RS6000_OUTPUT_BASENAME ((FILE), (NAME));		 \
+    fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
+             size1);					 \
+    } while (0)

/* Override the standard rs6000 definition. */


Attachment: temp.darwin.txt
Description: Text document


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