PATCH: MS bitfield layout support for w32 targets

Danny Smith danny_r_smith_2001@yahoo.co.nz
Wed Mar 27 02:46:00 GMT 2002


Hello,

The attached patch adds -mms-bitfields as a new target switch for cygwin
and
mingw32. This switch provides w32 targets with option to use MS-compatable
storage layout for bitfields in structures, as introduced by Alexandre
Oliva
in SH5 port (refer http://gcc.gnu.org/ml/gcc-patches/2002-02/msg00402.html
). 

Bootstapped and tested on i586-pc-mingw32.

OK for mainline?

2002-03-27  Danny Smith  <dannysmith@users.sourceforge.net>

	* config/i386/cygwin.h (MASK_MS_BITFIELD_LAYOUT): New mask for
	target switch -mms-bitfields.
	(TARGET_USE_MS_BITFIELD_LAYOUT): New define, using mask.
	(SUBTARGET_SWITCHES): Set mask, document -mms-bitfield switch.
	* config/i386/i386.c (ix86_ms_bitfield_layout_p): Add new hook
	function for TARGET_MS_BITFIELD_LAYOUT_P returning ...
	(TARGET_USE_MS_BITFIELD_LAYOUT): Define to 0 if not defined
	by subtarget.

Index: config/i386/cygwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/cygwin.h,v
retrieving revision 1.65
diff -u -p -r1.65 cygwin.h
--- cygwin.h	2002/03/27 09:51:53	1.65
+++ cygwin.h	2002/03/27 10:00:07
@@ -34,9 +34,14 @@ Boston, MA 02111-1307, USA.  */
 
 /* Masks for subtarget switches used by other files.  */
 #define MASK_NOP_FUN_DLLIMPORT 0x08000000 /* Ignore dllimport for
functions */
+#define MASK_MS_BITFIELD_LAYOUT 0x10000000 /* Use MS bitfield layout */
 
 /* Used in winnt.c.  */
 #define TARGET_NOP_FUN_DLLIMPORT (target_flags & MASK_NOP_FUN_DLLIMPORT)
+/* Tell i386.c to put a target-specific specialization of
+   ms_bitfield_layout_p in struct gcc_target targetm.  */
+#define TARGET_USE_MS_BITFIELD_LAYOUT  \
+  (target_flags & MASK_MS_BITFIELD_LAYOUT)	
 
 #undef  SUBTARGET_SWITCHES
 #define SUBTARGET_SWITCHES \
@@ -50,7 +55,11 @@ Boston, MA 02111-1307, USA.  */
 { "nop-fun-dllimport",	  MASK_NOP_FUN_DLLIMPORT,		\
   N_("Ignore dllimport for functions") }, 			\
 { "no-nop-fun-dllimport", -MASK_NOP_FUN_DLLIMPORT, "" },	\
-{ "threads",		  0, N_("Use Mingw-specific thread support") },
+{ "threads",		  0, N_("Use Mingw-specific thread support") },	\
+{ "ms-bitfields",	  MASK_MS_BITFIELD_LAYOUT, 		\
+  N_("Use MS bitfield layout") },				\
+{ "no-ms-bitfields",	  -MASK_MS_BITFIELD_LAYOUT,		\
+  N_("Don't use MS bitfield layout") },
 
 #undef CPP_PREDEFINES
 #define CPP_PREDEFINES "-D_X86_=1 -Asystem=winnt"
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.376
diff -u -p -r1.376 i386.c
--- i386.c	2002/03/22 20:15:06	1.376
+++ i386.c	2002/03/27 10:00:30
@@ -723,6 +723,7 @@ static int ix86_comp_type_attributes PAR
 const struct attribute_spec ix86_attribute_table[];
 static tree ix86_handle_cdecl_attribute PARAMS ((tree *, tree, tree, int,
bool *));
 static tree ix86_handle_regparm_attribute PARAMS ((tree *, tree, tree,
int, bool *));
+static bool ix86_ms_bitfield_layout_p PARAMS ((tree));
 
 #ifdef DO_GLOBAL_CTORS_BODY
 static void ix86_svr3_asm_out_constructor PARAMS ((rtx, int));
@@ -819,6 +820,9 @@ static enum x86_64_reg_class merge_class
 #undef TARGET_SCHED_REORDER
 #define TARGET_SCHED_REORDER ix86_sched_reorder
 
+#undef TARGET_MS_BITFIELD_LAYOUT_P
+#define TARGET_MS_BITFIELD_LAYOUT_P ix86_ms_bitfield_layout_p
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 

 /* Sometimes certain combinations of command options do not make
@@ -12457,4 +12461,15 @@ x86_order_regs_for_local_alloc ()
       at all.  */
    while (pos < FIRST_PSEUDO_REGISTER)
      reg_alloc_order [pos++] = 0;
+}
+
+#ifndef TARGET_USE_MS_BITFIELD_LAYOUT
+#define TARGET_USE_MS_BITFIELD_LAYOUT 0
+#endif
+
+static bool
+ix86_ms_bitfield_layout_p (record_type)
+     tree record_type ATTRIBUTE_UNUSED;
+{
+  return TARGET_USE_MS_BITFIELD_LAYOUT;
 }

http://www.sold.com.au - SOLD.com.au Auctions
- 1,000s of Bargains!



More information about the Gcc-patches mailing list