Add -maddress-mode=short|long for x86
authorH.J. Lu <hongjiu.lu@intel.com>
Wed, 14 Mar 2012 22:20:17 +0000 (22:20 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Wed, 14 Mar 2012 22:20:17 +0000 (15:20 -0700)
2012-03-14  H.J. Lu  <hongjiu.lu@intel.com>

PR target/50797
* config/i386/i386-opts.h (pmode): New.

* config/i386/i386.c (ix86_option_override_internal): Properly
check and set ix86_pmode.

* config/i386/i386.h (Pmode): Check ix86_pmode instead of
TARGET_64BIT.

* config/i386/i386.opt (maddress-mode=): New.

* doc/invoke.texi: Document -maddress-mode=short|long for x86.

From-SVN: r185396

gcc/ChangeLog
gcc/config/i386/i386-opts.h
gcc/config/i386/i386.c
gcc/config/i386/i386.h
gcc/config/i386/i386.opt
gcc/doc/invoke.texi

index 6034f74465717fbc7700ee4b1892c10cf3980a72..5999104d6cc0bd6a942a73ed4a3599c4029d16a9 100644 (file)
@@ -1,3 +1,18 @@
+2012-03-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/50797
+       * config/i386/i386-opts.h (pmode): New.
+
+       * config/i386/i386.c (ix86_option_override_internal): Properly
+       check and set ix86_pmode.
+
+       * config/i386/i386.h (Pmode): Check ix86_pmode instead of
+       TARGET_64BIT.
+
+       * config/i386/i386.opt (maddress-mode=): New.
+
+       * doc/invoke.texi: Document -maddress-mode=short|long for x86.
+
 2012-03-14  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * dwarf2cfi.c (def_cfa_0): Remove MIPS_DEBUGGING_INFO handling.
index 3cc2253c3c2698ca7d2c586fe969ae8f9068754a..eea85fd8a26851da38c733fbb66d6030922257e5 100644 (file)
@@ -71,6 +71,11 @@ enum cmodel {
   CM_LARGE_PIC /* No assumptions.  */
 };
 
+enum pmode {
+  PMODE_SI,    /* Pmode == SImode. */
+  PMODE_DI     /* Pmode == DImode. */
+};
+
 enum asm_dialect {
   ASM_ATT,
   ASM_INTEL
index c5c16e59278b4cd95c5489d428783e30e8297484..fec125a68b392ffc40596664cb83d354bdaaf62f 100644 (file)
@@ -3172,6 +3172,17 @@ ix86_option_override_internal (bool main_args_p)
   else
     ix86_arch_specified = 1;
 
+  if (global_options_set.x_ix86_pmode)
+    {
+      if ((TARGET_LP64 && ix86_pmode == PMODE_SI)
+          || (!TARGET_64BIT && ix86_pmode == PMODE_DI))
+       error ("address mode %qs not supported in the %s bit mode",
+              TARGET_64BIT ? "short" : "long",
+              TARGET_64BIT ? "64" : "32");
+    }
+  else
+    ix86_pmode = TARGET_LP64 ? PMODE_DI : PMODE_SI;
+
   if (!global_options_set.x_ix86_abi)
     ix86_abi = DEFAULT_ABI;
 
index c7d645eef65aa22b07415aacb5d603ae33b381e3..9e5ac00fb78750bd806e17ca68b07776b9311f1a 100644 (file)
@@ -1748,7 +1748,7 @@ do {                                                      \
 /* Specify the machine mode that pointers have.
    After generation of rtl, the compiler makes no further distinction
    between pointers and any other objects of this machine mode.  */
-#define Pmode (TARGET_64BIT ? DImode : SImode)
+#define Pmode (ix86_pmode == PMODE_DI ? DImode : SImode)
 
 /* A C expression whose value is zero if pointers that need to be extended
    from being `POINTER_SIZE' bits wide to `Pmode' are sign-extended and
index 1d8dc44e72fae4bb19706d5d3466c0f2bae5ab37..29f1082b2d1076ec3bd48b4b1df094885ed129e1 100644 (file)
@@ -159,6 +159,20 @@ Enum(cmodel) String(32) Value(CM_32)
 EnumValue
 Enum(cmodel) String(kernel) Value(CM_KERNEL)
 
+maddress-mode=
+Target RejectNegative Joined Enum(pmode) Var(ix86_pmode) Init(PMODE_SI)
+Use given address mode
+
+Enum
+Name(pmode) Type(enum pmode)
+Known address mode (for use with the -maddress-mode= option):
+
+EnumValue
+Enum(pmode) String(short) Value(PMODE_SI)
+
+EnumValue
+Enum(pmode) String(long) Value(PMODE_DI)
+
 mcpu=
 Target RejectNegative Joined Undocumented Alias(mtune=) Warn(%<-mcpu=%> is deprecated; use %<-mtune=%> or %<-march=%> instead)
 
index 94bfd239c04ed9805e90a26d548bfebb42f700e9..cf23ced85c96ad515d7b3794476427fbaa4ee3a6 100644 (file)
@@ -634,7 +634,7 @@ Objective-C and Objective-C++ Dialects}.
 -mveclibabi=@var{type} -mvect8-ret-in-mem @gol
 -mpc32 -mpc64 -mpc80 -mstackrealign @gol
 -momit-leaf-frame-pointer  -mno-red-zone -mno-tls-direct-seg-refs @gol
--mcmodel=@var{code-model} -mabi=@var{name} @gol
+-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} @gol
 -m32 -m64 -mx32 -mlarge-data-threshold=@var{num} @gol
 -msse2avx -mfentry -m8bit-idiv @gol
 -mavx256-split-unaligned-load -mavx256-split-unaligned-store}
@@ -13929,6 +13929,18 @@ be statically or dynamically linked.
 @opindex mcmodel=large
 Generate code for the large model.  This model makes no assumptions
 about addresses and sizes of sections.
+
+@item -maddress-mode=long
+@opindex maddress-mode=long
+Generate code for long address mode.  This is only supported for 64-bit
+and x32 environments.  It is the default address mode for 64-bit
+environments.
+
+@item -maddress-mode=short
+@opindex maddress-mode=short
+Generate code for short address mode.  This is only supported for 32-bit
+and x32 environments.  It is the default address mode for 32-bit and
+x32 environments.
 @end table
 
 @node i386 and x86-64 Windows Options