From: H.J. Lu Date: Thu, 7 Jul 2011 15:38:34 +0000 (+0000) Subject: Initial x32 support. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f0ea75811ae63b50e6c06ad694a993a8182ba012;p=gcc.git Initial x32 support. 2011-07-07 H.J. Lu * config.gcc: Support --with-multilib-list for x86 Linux targets. * configure.ac: Mention x86-64 for --with-multilib-list. * configure: Regenerated. * config/i386/gnu-user64.h (SPEC_64): Support x32. (SPEC_32): Likewise. (ASM_SPEC): Likewise. (LINK_SPEC): Likewise. (TARGET_THREAD_SSP_OFFSET): Likewise. (TARGET_THREAD_SPLIT_STACK_OFFSET): Likewise. (SPEC_X32): New. * config/i386/i386.h (TARGET_X32): New. (TARGET_LP64): New. (LONG_TYPE_SIZE): Likewise. (POINTER_SIZE): Likewise. (POINTERS_EXTEND_UNSIGNED): Likewise. (OPT_ARCH64): Support x32. (OPT_ARCH32): Likewise. * config/i386/i386.opt (mx32): New. * config/i386/kfreebsd-gnu64.h (GNU_USER_LINK_EMULATIONX32): New. (GLIBC_DYNAMIC_LINKERX32): Likewise. * config/i386/linux64.h (GNU_USER_LINK_EMULATIONX32): Likewise. (GLIBC_DYNAMIC_LINKERX32): Likewise. * config/linux.h (UCLIBC_DYNAMIC_LINKERX32): New. (BIONIC_DYNAMIC_LINKERX32): Likewise. (GNU_USER_DYNAMIC_LINKERX32): Likewise. * config/i386/t-linux64: Support TM_MULTILIB_CONFIG. * doc/install.texi: Document --with-multilib-list for Linux/x86-64. * doc/invoke.texi: Document -mx32. From-SVN: r175984 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1c481de1f58..35d8859c58a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,45 @@ +2011-07-07 H.J. Lu + + * config.gcc: Support --with-multilib-list for x86 Linux + targets. + + * configure.ac: Mention x86-64 for --with-multilib-list. + * configure: Regenerated. + + * config/i386/gnu-user64.h (SPEC_64): Support x32. + (SPEC_32): Likewise. + (ASM_SPEC): Likewise. + (LINK_SPEC): Likewise. + (TARGET_THREAD_SSP_OFFSET): Likewise. + (TARGET_THREAD_SPLIT_STACK_OFFSET): Likewise. + (SPEC_X32): New. + + * config/i386/i386.h (TARGET_X32): New. + (TARGET_LP64): New. + (LONG_TYPE_SIZE): Likewise. + (POINTER_SIZE): Likewise. + (POINTERS_EXTEND_UNSIGNED): Likewise. + (OPT_ARCH64): Support x32. + (OPT_ARCH32): Likewise. + + * config/i386/i386.opt (mx32): New. + + * config/i386/kfreebsd-gnu64.h (GNU_USER_LINK_EMULATIONX32): New. + (GLIBC_DYNAMIC_LINKERX32): Likewise. + * config/i386/linux64.h (GNU_USER_LINK_EMULATIONX32): Likewise. + (GLIBC_DYNAMIC_LINKERX32): Likewise. + + * config/linux.h (UCLIBC_DYNAMIC_LINKERX32): New. + (BIONIC_DYNAMIC_LINKERX32): Likewise. + (GNU_USER_DYNAMIC_LINKERX32): Likewise. + + * config/i386/t-linux64: Support TM_MULTILIB_CONFIG. + + * doc/install.texi: Document --with-multilib-list for + Linux/x86-64. + + * doc/invoke.texi: Document -mx32. + 2011-07-07 Richard Sandiford * doc/invoke.texi (mwords-little-endian): Deprecate. diff --git a/gcc/config.gcc b/gcc/config.gcc index c590577f485..f8d7274f349 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1281,6 +1281,22 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i tm_file="${tm_file} i386/x86-64.h i386/gnu-user64.h i386/linux64.h" tm_defines="${tm_defines} TARGET_BI_ARCH=1" tmake_file="${tmake_file} i386/t-linux64" + 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/^,//'` need_64bit_hwint=yes need_64bit_isa=yes case X"${with_cpu}" in @@ -1319,6 +1335,22 @@ x86_64-*-linux* | x86_64-*-kfreebsd*-gnu | x86_64-*-knetbsd*-gnu) x86_64-*-knetbsd*-gnu) tm_file="${tm_file} knetbsd-gnu.h" ;; 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" + 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 diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h index b069975ef19..954f3b2ff24 100644 --- a/gcc/config/i386/gnu-user64.h +++ b/gcc/config/i386/gnu-user64.h @@ -58,25 +58,31 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #if TARGET_64BIT_DEFAULT #define SPEC_32 "m32" -#define SPEC_64 "!m32" +#define SPEC_64 "m32|mx32:;" +#define SPEC_X32 "mx32" #else -#define SPEC_32 "!m64" +#define SPEC_32 "m64|mx32:;" #define SPEC_64 "m64" +#define SPEC_X32 "mx32" #endif #undef ASM_SPEC -#define ASM_SPEC "%{" SPEC_32 ":--32} %{" SPEC_64 ":--64} \ +#define ASM_SPEC "%{" SPEC_32 ":--32} \ + %{" SPEC_64 ":--64} \ + %{" SPEC_X32 ":--x32} \ %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}" #undef LINK_SPEC #define LINK_SPEC "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \ %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \ + %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \ %{shared:-shared} \ %{!shared: \ %{!static: \ %{rdynamic:-export-dynamic} \ %{" SPEC_32 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "} \ - %{" SPEC_64 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}} \ + %{" SPEC_64 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \ + %{" SPEC_X32 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKERX32 "}} \ %{static:-static}}" /* Similar to standard GNU userspace, but adding -ffast-math support. */ @@ -110,10 +116,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #ifdef TARGET_LIBC_PROVIDES_SSP /* i386 glibc provides __stack_chk_guard in %gs:0x14, + x32 glibc provides it in %fs:0x18. x86_64 glibc provides it in %fs:0x28. */ -#define TARGET_THREAD_SSP_OFFSET (TARGET_64BIT ? 0x28 : 0x14) +#define TARGET_THREAD_SSP_OFFSET \ + (TARGET_64BIT ? (TARGET_X32 ? 0x18 : 0x28) : 0x14) /* We steal the last transactional memory word. */ #define TARGET_CAN_SPLIT_STACK -#define TARGET_THREAD_SPLIT_STACK_OFFSET (TARGET_64BIT ? 0x70 : 0x30) +#define TARGET_THREAD_SPLIT_STACK_OFFSET \ + (TARGET_64BIT ? (TARGET_X32 ? 0x40 : 0x70) : 0x30) #endif diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index a1ac6b656da..8cef4e7c02a 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -42,6 +42,7 @@ 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 @@ -72,6 +73,7 @@ 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) /* SSE4.1 defines round instructions */ #define OPTION_MASK_ISA_ROUND OPTION_MASK_ISA_SSE4_1 @@ -516,8 +518,8 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); #define OPT_ARCH64 "!m32" #define OPT_ARCH32 "m32" #else -#define OPT_ARCH64 "m64" -#define OPT_ARCH32 "!m64" +#define OPT_ARCH64 "m64|mx32" +#define OPT_ARCH32 "m64|mx32:;" #endif /* Support for configure-time defaults of some command line options. @@ -637,6 +639,8 @@ enum target_cpu_default #define SHORT_TYPE_SIZE 16 #define INT_TYPE_SIZE 32 +#define LONG_TYPE_SIZE (TARGET_X32 ? 32 : BITS_PER_WORD) +#define POINTER_SIZE (TARGET_X32 ? 32 : BITS_PER_WORD) #define LONG_LONG_TYPE_SIZE 64 #define FLOAT_TYPE_SIZE 32 #define DOUBLE_TYPE_SIZE 64 @@ -1742,6 +1746,13 @@ do { \ between pointers and any other objects of this machine mode. */ #define Pmode (TARGET_64BIT ? 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 + greater then zero if they are zero-extended and less then zero if the + ptr_extend instruction should be used. */ + +#define POINTERS_EXTEND_UNSIGNED 1 + /* A function address in a call instruction is a byte address (for indexing purposes) so give the MEM rtx a byte's mode. */ diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index 9886b7bbce4..8dea93e74c0 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -398,9 +398,13 @@ Target RejectNegative Negative(m64) Report InverseMask(ISA_64BIT) Var(ix86_isa_f Generate 32bit i386 code m64 -Target RejectNegative Negative(m32) Report Mask(ISA_64BIT) Var(ix86_isa_flags) Save +Target RejectNegative Negative(mx32) Report Mask(ISA_64BIT) Var(ix86_isa_flags) Save Generate 64bit x86-64 code +mx32 +Target RejectNegative Negative(m32) Report Mask(ISA_X32) Var(ix86_isa_flags) Save +Generate 32bit 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/kfreebsd-gnu64.h b/gcc/config/i386/kfreebsd-gnu64.h index c3798a5c591..2085ca5fe6f 100644 --- a/gcc/config/i386/kfreebsd-gnu64.h +++ b/gcc/config/i386/kfreebsd-gnu64.h @@ -21,6 +21,8 @@ along with GCC; see the file COPYING3. If not see #define GNU_USER_LINK_EMULATION32 "elf_i386_fbsd" #define GNU_USER_LINK_EMULATION64 "elf_x86_64_fbsd" +#define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64_fbsd" #define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1" #define GLIBC_DYNAMIC_LINKER64 "/lib/ld-kfreebsd-x86-64.so.1" +#define GLIBC_DYNAMIC_LINKERX32 "/lib/ld-kfreebsd-x32.so.1" diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h index 5d332246cb5..5b0a212cece 100644 --- a/gcc/config/i386/linux64.h +++ b/gcc/config/i386/linux64.h @@ -26,6 +26,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define GNU_USER_LINK_EMULATION32 "elf_i386" #define GNU_USER_LINK_EMULATION64 "elf_x86_64" +#define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64" #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2" #define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2" +#define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2" diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64 index 5d5a476cf5d..ea8f5e9d7ae 100644 --- a/gcc/config/i386/t-linux64 +++ b/gcc/config/i386/t-linux64 @@ -1,4 +1,5 @@ -# Copyright (C) 2002, 2005, 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 2002, 2005, 2007, 2008, 2011 +# Free Software Foundation, Inc. # # This file is part of GCC. # @@ -23,9 +24,19 @@ # it doesn't tell anything about the 32bit libraries on those systems. Set # MULTILIB_OSDIRNAMES according to what is found on the target. -MULTILIB_OPTIONS = m64/m32 -MULTILIB_DIRNAMES = 64 32 -MULTILIB_OSDIRNAMES = ../lib64 $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib) +# To support i386, x86-64 and x32 libraries, the directory structrue +# should be: +# +# /lib has i386 libraries. +# /lib64 has x86-64 libraries. +# /libx32 has x32 libraries. +# +comma=, +MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG)) +MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS))) +MULTILIB_OSDIRNAMES = m64=../lib64 +MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib) +MULTILIB_OSDIRNAMES+= mx32=../libx32 LIBGCC = stmp-multilib INSTALL_LIBGCC = install-multilib diff --git a/gcc/config/linux.h b/gcc/config/linux.h index fc897b189fc..dbbeea5c7fd 100644 --- a/gcc/config/linux.h +++ b/gcc/config/linux.h @@ -77,9 +77,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0" #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0" #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0" +#define UCLIBC_DYNAMIC_LINKERX32 "/lib/ldx32-uClibc.so.0" #define BIONIC_DYNAMIC_LINKER "/system/bin/linker" #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker" #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64" +#define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32" #define GNU_USER_DYNAMIC_LINKER \ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \ @@ -90,6 +92,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define GNU_USER_DYNAMIC_LINKER64 \ CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \ BIONIC_DYNAMIC_LINKER64) +#define GNU_USER_DYNAMIC_LINKERX32 \ + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \ + BIONIC_DYNAMIC_LINKERX32) /* Determine whether the entire c99 runtime is present in the runtime library. */ diff --git a/gcc/configure b/gcc/configure index 3c717c086b7..9fb43170185 100755 --- a/gcc/configure +++ b/gcc/configure @@ -1655,7 +1655,7 @@ Optional Packages: --with-specs=SPECS add SPECS to driver command-line processing --with-pkgversion=PKG Use PKG in the version string in place of "GCC" --with-bugurl=URL Direct users to URL to report a bug - --with-multilib-list select multilibs (SH only) + --with-multilib-list select multilibs (SH and x86-64 only) --with-gnu-ld assume the C compiler uses GNU ld default=no --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir diff --git a/gcc/configure.ac b/gcc/configure.ac index f899991083d..c2163bf70d5 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -795,7 +795,7 @@ esac], [enable_languages=c]) AC_ARG_WITH(multilib-list, -[AS_HELP_STRING([--with-multilib-list], [select multilibs (SH only)])], +[AS_HELP_STRING([--with-multilib-list], [select multilibs (SH and x86-64 only)])], :, with_multilib_list=default) diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index f93413fb7b8..833b4c935d7 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -1049,8 +1049,10 @@ sysv, aix. @item --with-multilib-list=@var{list} @itemx --without-multilib-list Specify what multilibs to build. -Currently only implemented for sh*-*-*. +Currently only implemented for sh*-*-* and x86-64-*-linux*. +@table @code +@item sh*-*-* @var{list} is a comma separated list of CPU names. These must be of the form @code{sh*} or @code{m*} (in which case they match the compiler option for that processor). The list should not contain any endian options - @@ -1082,6 +1084,16 @@ only little endian SH4AL: --with-multilib-list=sh4al,!mb/m4al @end smallexample +@item x86-64-*-linux* +@var{list} is a comma separated list of @code{m32}, @code{m64} and +@code{mx32} to enable 32-bit, 64-bit and x32 run-time libraries, +respectively. If @var{list} is empty, then there will be no multilibs +and only the default run-time library will be enabled. + +If @option{--with-multilib-list} is not given, then only 32-bit and +64-bit run-time libraries will be enabled. +@end table + @item --with-endian=@var{endians} Specify what endians to use. Currently only implemented for sh*-*-*. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index c8ec451510b..f146cc565a5 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -610,7 +610,7 @@ Objective-C and Objective-C++ Dialects}. -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 --m32 -m64 -mlarge-data-threshold=@var{num} @gol +-m32 -m64 -mx32 -mlarge-data-threshold=@var{num} @gol -msse2avx -mfentry -m8bit-idiv @gol -mavx256-split-unaligned-load -mavx256-split-unaligned-store} @@ -12853,15 +12853,19 @@ on AMD x86-64 processors in 64-bit environments. @table @gcctabopt @item -m32 @itemx -m64 +@itemx -mx32 @opindex m32 @opindex m64 +@opindex mx32 Generate code for a 32-bit or 64-bit environment. -The 32-bit environment sets int, long and pointer to 32 bits and +The @option{-m32} option sets int, long and pointer to 32 bits and generates code that runs on any i386 system. -The 64-bit environment sets int to 32 bits and long and pointer -to 64 bits and generates code for AMD's x86-64 architecture. For -darwin only the -m64 option turns off the @option{-fno-pic} and -@option{-mdynamic-no-pic} options. +The @option{-m64} option sets int to 32 bits and long and pointer +to 64 bits and generates code for AMD's x86-64 architecture. +The @option{-mx32} option sets int, long and pointer to 32 bits and +generates code for AMD's x86-64 architecture. +For darwin only the @option{-m64} option turns off the @option{-fno-pic} +and @option{-mdynamic-no-pic} options. @item -mno-red-zone @opindex mno-red-zone