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] second patch for pragma for __attribute__ ((__ms_struct__))


Here's the updated patch. I noticed we need a lot of OPT_* in darwin- c.c, but I'll do that as a separate one. This patch actually touches a bit more of i386.c and rs6000.c than the previous one because of the functions, but it's probably the right way to do it as well.

-eric

2006-04-24 Eric Christopher <echristo@apple.com>

	* config/darwin-c.c (darwin_pragma_ms_struct): New.
	* config/darwin-protos.h (darwin_pragma_ms_struct): Declare.
	* config/darwin.c (darwin_ms_struct): New.
	* config/darwin.h (darwin_ms_struct): Declare.
	(DARWIN_REGISTER_TARGET_PRAGMAS): Add ms_struct.
	* config/i386/i386.c (ix86_set_default_type_attributes): New.
	(TARGET_SET_DEFAULT_TYPE_ATTRIBUTES): Use.
	* config/rs6000/rs6000.c (rs6000_set_default_type_attributes):
	Set ms_struct based on pragma.

Index: config/darwin-c.c
===================================================================
--- config/darwin-c.c (revision 113224)
+++ config/darwin-c.c (working copy)
@@ -159,6 +159,27 @@ darwin_pragma_unused (cpp_reader *pfile
warning (0, "junk at end of '#pragma unused'");
}
+void
+darwin_pragma_ms_struct (cpp_reader *pfile ATTRIBUTE_UNUSED)
+{
+ const char *arg;
+ tree t;
+
+ if (pragma_lex (&t) != CPP_NAME)
+ BAD ("malformed '#pragma ms_struct', ignoring");
+ arg = IDENTIFIER_POINTER (t);
+
+ if (!strcmp (arg, "on"))
+ darwin_ms_struct = true;
+ else if (!strcmp (arg, "off") || !strcmp (arg, "reset"))
+ darwin_ms_struct = false;
+ else
+ warning (OPT_Wpragmas, "malformed '#pragma ms_struct {on|off| reset}', ignoring");
+
+ if (pragma_lex (&t) != CPP_EOF)
+ warning (OPT_Wpragmas, "junk at end of '#pragma ms_struct'");
+}
+
static struct {
size_t len;
const char *name;
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c (revision 113224)
+++ config/i386/i386.c (working copy)
@@ -1142,6 +1142,7 @@ static void ix86_compute_frame_layout (s
static int ix86_comp_type_attributes (tree, tree);
static int ix86_function_regparm (tree, tree);
const struct attribute_spec ix86_attribute_table[];
+static void ix86_set_default_type_attributes (tree);
static bool ix86_function_ok_for_sibcall (tree, tree);
static tree ix86_handle_cconv_attribute (tree *, tree, tree, int, bool *);
static int ix86_value_regno (enum machine_mode, tree, tree);
@@ -1211,6 +1212,8 @@ static section *x86_64_elf_select_sectio
/* Initialize the GCC target structure. */
#undef TARGET_ATTRIBUTE_TABLE
#define TARGET_ATTRIBUTE_TABLE ix86_attribute_table
+#undef TARGET_SET_DEFAULT_TYPE_ATTRIBUTES
+#define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES ix86_set_default_type_attributes
#if TARGET_DLLIMPORT_DECL_ATTRIBUTES
# undef TARGET_MERGE_DECL_ATTRIBUTES
# define TARGET_MERGE_DECL_ATTRIBUTES merge_dllimport_decl_attributes
@@ -2234,6 +2237,19 @@ const struct attribute_spec ix86_attribu
{ NULL, 0, 0, false, false, false, NULL }
};
+/* Set default attributes for various types. */
+static void
+ix86_set_default_type_attributes (tree type)
+{
+#if TARGET_MACHO
+ if (darwin_ms_struct
+ && TREE_CODE (type) == RECORD_TYPE)
+ TYPE_ATTRIBUTES (type) = tree_cons (get_identifier ("ms_struct"),
+ NULL_TREE,
+ TYPE_ATTRIBUTES (type));
+#endif
+}
+
/* Decide whether we can make a sibling call to a function. DECL is the
declaration of the function being targeted by the call and EXP is the
CALL_EXPR representing the call. */
Index: config/darwin-protos.h
===================================================================
--- config/darwin-protos.h (revision 113224)
+++ config/darwin-protos.h (working copy)
@@ -65,6 +65,7 @@ extern void darwin_emit_except_table_lab
extern void darwin_pragma_ignore (struct cpp_reader *);
extern void darwin_pragma_options (struct cpp_reader *);
extern void darwin_pragma_unused (struct cpp_reader *);
+extern void darwin_pragma_ms_struct (struct cpp_reader *);
extern void darwin_file_start (void);
extern void darwin_file_end (void);
Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c (revision 113224)
+++ config/rs6000/rs6000.c (working copy)
@@ -17528,6 +17528,14 @@ rs6000_set_default_type_attributes (tree
TYPE_ATTRIBUTES (type) = tree_cons (get_identifier ("longcall"),
NULL_TREE,
TYPE_ATTRIBUTES (type));
+
+#if TARGET_MACHO
+ if (darwin_ms_struct
+ && TREE_CODE (type) == RECORD_TYPE)
+ TYPE_ATTRIBUTES (type) = tree_cons (get_identifier ("ms_struct"),
+ NULL_TREE,
+ TYPE_ATTRIBUTES (type));
+#endif
}
/* Return a reference suitable for calling a function with the
Index: config/darwin.c
===================================================================
--- config/darwin.c (revision 113224)
+++ config/darwin.c (working copy)
@@ -46,6 +46,9 @@ Boston, MA 02110-1301, USA. */
#include "toplev.h"
#include "hashtab.h"
+/* Pragma for __attribute__ ((__ms_struct__)) */
+int darwin_ms_struct = false;
+
/* Darwin supports a feature called fix-and-continue, which is used
for rapid turn around debugging. When code is compiled with the
-mfix-and-continue flag, two changes are made to the generated code
Index: config/darwin.h
===================================================================
--- config/darwin.h (revision 113224)
+++ config/darwin.h (working copy)
@@ -80,6 +80,9 @@ Boston, MA 02110-1301, USA. */
#undef DEFAULT_PCC_STRUCT_RETURN
#define DEFAULT_PCC_STRUCT_RETURN 0
+/* True if pragma ms_struct is in effect. */
+extern GTY(()) int darwin_ms_struct;
+
/* This table intercepts weirdo options whose names would interfere
with normal driver conventions, and either translates them into
standardly-named options, or adds a 'Z' so that they can get to
@@ -830,6 +833,7 @@ enum machopic_addr_class {
c_register_pragma (0, "options", darwin_pragma_options); \
c_register_pragma (0, "segment", darwin_pragma_ignore); \
c_register_pragma (0, "unused", darwin_pragma_unused); \
+ c_register_pragma (0, "ms_struct", darwin_pragma_ms_struct); \
} while (0)
#undef ASM_APP_ON



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