summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog.mx3267
-rw-r--r--gcc/config.gcc56
-rw-r--r--gcc/config/i386/biarch64.h2
-rw-r--r--gcc/config/i386/biarchx32.h28
-rw-r--r--gcc/config/i386/i386.c60
-rw-r--r--gcc/config/i386/i386.h4
-rw-r--r--gcc/config/i386/i386.opt8
-rw-r--r--gcc/config/i386/linux64.h9
8 files changed, 209 insertions, 25 deletions
diff --git a/gcc/ChangeLog.mx32 b/gcc/ChangeLog.mx32
new file mode 100644
index 00000000000..a362f0782b3
--- /dev/null
+++ b/gcc/ChangeLog.mx32
@@ -0,0 +1,67 @@
+2012-06-26 H.J. Lu <hongjiu.lu@intel.com>
+
+ * config/i386/biarch64.h (TARGET_64BIT_DEFAULT): Replace
+ OPTION_MASK_ISA_X86_64 with OPTION_MASK_ABI_64.
+
+ * config/i386/biarchx32.h (TARGET_64BIT_DEFAULT): Replace
+ OPTION_MASK_ISA_X32 with OPTION_MASK_ABI_X32.
+
+ * config/i386/i386.c (isa_opts): Remove -m64.
+ (ix86_target_string): Properly handle -m32/-m64/-mx32.
+ (ix86_option_override_internal): Properly set OPTION_MASK_ISA_64BIT,
+ OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32.
+
+ * config/i386/i386.h (TARGET_X32): Replace OPTION_ISA_X32
+ with OPTION_ABI_X32. Moved after TARGET_LP64.
+ (TARGET_LP64): Changed to OPTION_ABI_64.
+
+ * config/i386/i386.opt (m64): Replace ISA_64BIT with ABI_64.
+ (mx32): Replace ISA_X32 with ABI_X32.
+
+2011-12-12 H.J. Lu <hongjiu.lu@intel.com>
+
+ * config.gcc: Check --with-multilib-list for x86-64 Linux targets
+ only if multilib is enabled.
+
+2011-12-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ * config/i386/biarch64.h (TARGET_64BIT_DEFAULT): Re-order.
+
+ * config/i386/biarchx32.h (TARGET_64BIT_DEFAULT): Replace
+ OPTION_MASK_ISA_X86_64 with OPTION_MASK_ISA_64BIT.
+
+ * config/i386/i386.c (ix86_option_override_internal): Properly
+ handle -m32, -m64 and -mx32.
+
+ * config/i386/i386.h (TARGET_LP64): Changed to TARGET_X86_64.
+
+ * config/i386/i386.opt (m32): Changed back to ISA_64BIT.
+ (m64): Replace ISA_64BIT with ISA_X86_64.
+ (mx86-64): Replace ISA_X86_64 with ISA_64BIT.
+
+2011-12-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ * config.gcc: Also support --with-abi={mx32|m64}.
+
+2011-12-07 H.J. Lu <hongjiu.lu@intel.com>
+
+ * config.gcc: For --with-abi=x32 or --with-multilib-list=mx32,
+ use i386/biarchx32.h instead of i386/biarch64.h.
+ (supported_defaults): Add abi for i[34567]86-*-* and x86_64-*-*.
+
+ * config/i386/biarch64.h (TARGET_64BIT_DEFAULT): Add
+ OPTION_MASK_ISA_X86_64.
+
+ * config/i386/biarchx32.h: New.
+
+ * config/i386/i386.c (ix86_option_override_internal): Properly
+ set OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32.
+
+ * config/i386/i386.h (TARGET_X86_64): New.
+
+ * config/i386/i386.opt (m32): Replace ISA_64BIT with ISA_X86_64.
+ (mx86-64): New.
+
+ * config/i386/linux64.h (SPEC_64): Support TARGET_BI_ARCH == 2.
+ (SPEC_X32): Likewise.
+ (MULTILIB_DEFAULTS): Likewise.
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 24c93d96952..0a7038324f6 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -450,6 +450,10 @@ fi
case ${target} in
i[34567]86-*-*)
+ if test "x$with_abi" != x; then
+ echo "This target does not support --with-abi."
+ exit 1
+ fi
if test "x$enable_cld" = xyes; then
tm_defines="${tm_defines} USE_IX86_CLD=1"
fi
@@ -459,7 +463,24 @@ i[34567]86-*-*)
tm_file="vxworks-dummy.h ${tm_file}"
;;
x86_64-*-*)
- tm_file="i386/biarch64.h ${tm_file}"
+ case ${with_abi} in
+ "")
+ if test "x$with_multilib_list" = xmx32; then
+ tm_file="i386/biarchx32.h ${tm_file}"
+ else
+ tm_file="i386/biarch64.h ${tm_file}"
+ fi
+ ;;
+ 64 | m64)
+ tm_file="i386/biarch64.h ${tm_file}"
+ ;;
+ x32 | mx32)
+ tm_file="i386/biarchx32.h ${tm_file}"
+ ;;
+ *)
+ echo "Unknown ABI used in --with-abi=$with_abi"
+ exit 1
+ esac
if test "x$enable_cld" = xyes; then
tm_defines="${tm_defines} USE_IX86_CLD=1"
fi
@@ -1328,21 +1349,24 @@ x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu)
esac
tmake_file="${tmake_file} i386/t-linux64 i386/t-crtstuff i386/t-crtpc i386/t-crtfm t-dfprules"
x86_multilibs="${with_multilib_list}"
- if test "$x86_multilibs" = "default"; then
- x86_multilibs="m64,m32"
+ if test "x$enable_multilib" = "xyes"; then
+ x86_multilibs="${with_multilib_list}"
+ if test "$x86_multilibs" = "default"; then
+ x86_multilibs="m64,m32"
+ fi
+ x86_multilibs=`echo $x86_multilibs | sed -e 's/,/ /g'`
+ for x86_multilib in ${x86_multilibs}; do
+ case ${x86_multilib} in
+ m32 | m64 | mx32)
+ TM_MULTILIB_CONFIG="${TM_MULTILIB_CONFIG},${x86_multilib}"
+ ;;
+ *)
+ echo "--with-multilib-list=${x86_with_multilib} not supported."
+ exit 1
+ esac
+ done
+ TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
fi
- x86_multilibs=`echo $x86_multilibs | sed -e 's/,/ /g'`
- for x86_multilib in ${x86_multilibs}; do
- case ${x86_multilib} in
- m32 | m64 | mx32)
- TM_MULTILIB_CONFIG="${TM_MULTILIB_CONFIG},${x86_multilib}"
- ;;
- *)
- echo "--with-multilib-list=${x86_with_multilib} not supported."
- exit 1
- esac
- done
- TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
;;
i[34567]86-pc-msdosdjgpp*)
xm_file=i386/xm-djgpp.h
@@ -3389,7 +3413,7 @@ case "${target}" in
;;
i[34567]86-*-* | x86_64-*-*)
- supported_defaults="arch arch_32 arch_64 cpu cpu_32 cpu_64 tune tune_32 tune_64"
+ supported_defaults="abi arch arch_32 arch_64 cpu cpu_32 cpu_64 tune tune_32 tune_64"
for which in arch arch_32 arch_64 cpu cpu_32 cpu_64 tune tune_32 tune_64; do
eval "val=\$with_$which"
case ${val} in
diff --git a/gcc/config/i386/biarch64.h b/gcc/config/i386/biarch64.h
index 629ec980d19..0c3811e3f33 100644
--- a/gcc/config/i386/biarch64.h
+++ b/gcc/config/i386/biarch64.h
@@ -25,5 +25,5 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
-#define TARGET_64BIT_DEFAULT OPTION_MASK_ISA_64BIT
+#define TARGET_64BIT_DEFAULT (OPTION_MASK_ISA_64BIT | OPTION_MASK_ABI_64)
#define TARGET_BI_ARCH 1
diff --git a/gcc/config/i386/biarchx32.h b/gcc/config/i386/biarchx32.h
new file mode 100644
index 00000000000..69d672216ac
--- /dev/null
+++ b/gcc/config/i386/biarchx32.h
@@ -0,0 +1,28 @@
+/* Make configure files to produce biarch compiler defaulting to x32 mode.
+ This file must be included very first, while the OS specific file later
+ to overwrite otherwise wrong defaults.
+ Copyright (C) 2012 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#define TARGET_64BIT_DEFAULT (OPTION_MASK_ISA_64BIT | OPTION_MASK_ABI_X32)
+#define TARGET_BI_ARCH 2
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 8c4049febac..aa51739c884 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3084,7 +3084,6 @@ ix86_target_string (int isa, int flags, const char *arch, const char *tune,
preceding options while match those first. */
static struct ix86_target_opts isa_opts[] =
{
- { "-m64", OPTION_MASK_ISA_64BIT },
{ "-mfma4", OPTION_MASK_ISA_FMA4 },
{ "-mfma", OPTION_MASK_ISA_FMA },
{ "-mxop", OPTION_MASK_ISA_XOP },
@@ -3154,6 +3153,7 @@ ix86_target_string (int isa, int flags, const char *arch, const char *tune,
size_t len;
size_t line_len;
size_t sep_len;
+ const char *abi;
memset (opts, '\0', sizeof (opts));
@@ -3171,6 +3171,21 @@ ix86_target_string (int isa, int flags, const char *arch, const char *tune,
opts[num++][1] = tune;
}
+ /* Add -m32/-m64/-mx32. */
+ if ((isa & OPTION_MASK_ISA_64BIT) != 0)
+ {
+ if ((isa & OPTION_MASK_ABI_64) != 0)
+ abi = "-m64";
+ else
+ abi = "-mx32";
+ isa &= ~ (OPTION_MASK_ISA_64BIT
+ | OPTION_MASK_ABI_64
+ | OPTION_MASK_ABI_X32);
+ }
+ else
+ abi = "-m32";
+ opts[num++][0] = abi;
+
/* Pick out the options in isa options. */
for (i = 0; i < ARRAY_SIZE (isa_opts); i++)
{
@@ -3496,6 +3511,46 @@ ix86_option_override_internal (bool main_args_p)
sw = "attribute";
}
+ /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if
+ TARGET_64BIT_DEFAULT is true and TARGET_64BIT is false. */
+ if (TARGET_64BIT_DEFAULT && !TARGET_64BIT)
+ ix86_isa_flags &= ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
+#ifdef TARGET_BI_ARCH
+ else
+ {
+#if TARGET_BI_ARCH == 1
+ /* When TARGET_BI_ARCH == 1, by default, OPTION_MASK_ABI_64
+ is on and OPTION_MASK_ABI_X32 is off. We turn off
+ OPTION_MASK_ABI_64 if OPTION_MASK_ABI_X32 is turned on by
+ -mx32. */
+ if (TARGET_X32)
+ ix86_isa_flags &= ~OPTION_MASK_ABI_64;
+#else
+ /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ABI_X32 is
+ on and OPTION_MASK_ABI_64 is off. We turn off
+ OPTION_MASK_ABI_X32 if OPTION_MASK_ABI_64 is turned on by
+ -m64. */
+ if (TARGET_LP64)
+ ix86_isa_flags &= ~OPTION_MASK_ABI_X32;
+#endif
+ }
+#endif
+
+ if (TARGET_X32)
+ {
+ /* Always turn on OPTION_MASK_ISA_64BIT and turn off
+ OPTION_MASK_ABI_64 for TARGET_X32. */
+ ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
+ ix86_isa_flags &= ~OPTION_MASK_ABI_64;
+ }
+ else if (TARGET_LP64)
+ {
+ /* Always turn on OPTION_MASK_ISA_64BIT and turn off
+ OPTION_MASK_ABI_X32 for TARGET_LP64. */
+ ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
+ ix86_isa_flags &= ~OPTION_MASK_ABI_X32;
+ }
+
#ifdef SUBTARGET_OVERRIDE_OPTIONS
SUBTARGET_OVERRIDE_OPTIONS;
#endif
@@ -3504,9 +3559,6 @@ ix86_option_override_internal (bool main_args_p)
SUBSUBTARGET_OVERRIDE_OPTIONS;
#endif
- if (TARGET_X32)
- ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
-
/* -fPIC is the default for x86_64. */
if (TARGET_MACHO && TARGET_64BIT)
flag_pic = 2;
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 12600e9d080..67cae2cc85b 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -42,7 +42,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* Redefines for option macros. */
#define TARGET_64BIT OPTION_ISA_64BIT
-#define TARGET_X32 OPTION_ISA_X32
#define TARGET_MMX OPTION_ISA_MMX
#define TARGET_3DNOW OPTION_ISA_3DNOW
#define TARGET_3DNOW_A OPTION_ISA_3DNOW_A
@@ -73,7 +72,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define TARGET_RDRND OPTION_ISA_RDRND
#define TARGET_F16C OPTION_ISA_F16C
-#define TARGET_LP64 (TARGET_64BIT && !TARGET_X32)
+#define TARGET_LP64 OPTION_ABI_64
+#define TARGET_X32 OPTION_ABI_X32
/* SSE4.1 defines round instructions */
#define OPTION_MASK_ISA_ROUND OPTION_MASK_ISA_SSE4_1
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index 2ba9f2babb4..f67b5eb3270 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -277,13 +277,17 @@ Target RejectNegative Negative(m64) Report InverseMask(ISA_64BIT) Var(ix86_isa_f
Generate 32bit i386 code
m64
-Target RejectNegative Negative(mx32) Report Mask(ISA_64BIT) Var(ix86_isa_flags) Save
+Target RejectNegative Negative(mx32) Report Mask(ABI_64) Var(ix86_isa_flags) Save
Generate 64bit x86-64 code
mx32
-Target RejectNegative Negative(m32) Report Mask(ISA_X32) Var(ix86_isa_flags) Save
+Target RejectNegative Negative(m32) Report Mask(ABI_X32) Var(ix86_isa_flags) Save
Generate 32bit x86-64 code
+mx86-64
+Target Undocumented Mask(ISA_64BIT) Var(ix86_isa_flags) Save
+Generate 32bit or 64bit x86-64 code
+
mmmx
Target Report Mask(ISA_MMX) Var(ix86_isa_flags) Save
Support MMX built-in functions
diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
index de8654c2802..f777d1b6415 100644
--- a/gcc/config/i386/linux64.h
+++ b/gcc/config/i386/linux64.h
@@ -68,8 +68,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if TARGET_64BIT_DEFAULT
#define SPEC_32 "m32"
+#if TARGET_BI_ARCH == 2
+#define SPEC_64 "m64"
+#define SPEC_X32 "m32|m64:;"
+#else
#define SPEC_64 "m32|mx32:;"
#define SPEC_X32 "mx32"
+#endif
#else
#define SPEC_32 "m64|mx32:;"
#define SPEC_64 "m64"
@@ -105,7 +110,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
#if TARGET_64BIT_DEFAULT
+#if TARGET_BI_ARCH == 2
+#define MULTILIB_DEFAULTS { "mx32" }
+#else
#define MULTILIB_DEFAULTS { "m64" }
+#endif
#else
#define MULTILIB_DEFAULTS { "m32" }
#endif