Use i386-cpuinfo.c on all i386 targets

libgcc:
	* config.host (i[34567]86-*-linux*, x86_64-*-linux*)
	(i[34567]86-*-kfreebsd*-gnu, x86_64-*-kfreebsd*-gnu)
	(i[34567]86-*-knetbsd*-gnu, i[34567]86-*-gnu*): Move
	i386/t-cpuinfo ...
	(i[34567]86-*-*, x86_64-*-*): ... here.

	* config/i386/libgcc-bsd.ver (GCC_4.8.0): New version.
	* config/i386/libgcc-sol2.ver (GCC_4.8.0): New version.

	* config/i386/i386-cpuinfo.c: Rename to ...
	* config/i386/cpuinfo.c: ... this.
	* config/i386/t-cpuinfo (LIB2ADD): Reflect this.

	* configure.ac (AC_CONFIG_HEADER): Call for auto-target.h.
	(libgcc_cv_init_priority): New test.
	* configure: Regenerate.
	* config.in: New file.
	* Makefile.in (clean): Rename config.h to auto-target.h.
	(config.h): Likewise.
	(stamp-h): Likewise.

	* config/i386/cpuinfo.c (auto-target.h): Include.
	(CONSTRUCTOR_PRIORITY): Define.
	(__cpu_indicator_init): Use it.

	gcc
	* doc/extend.texi (X86 Built-in Functions, __builtin_cpu_init):
	Document requirement to call in constructors.

	* config/i386/i386.c: Update comments for i386-cpuinfo.c name
	change.

From-SVN: r187365
This commit is contained in:
Rainer Orth 2012-05-10 08:51:39 +00:00 committed by Rainer Orth
parent 638d20652b
commit aca06c900e
14 changed files with 345 additions and 57 deletions

View File

@ -1,3 +1,11 @@
2012-05-10 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* doc/extend.texi (X86 Built-in Functions, __builtin_cpu_init):
Document requirement to call in constructors.
* config/i386/i386.c: Update comments for i386-cpuinfo.c name
change.
2012-05-10 Richard Guenther <rguenther@suse.de>
* tree.h (TYPE_IS_SIZETYPE): Remove.

View File

@ -27665,7 +27665,7 @@ ix86_init_mmx_sse_builtins (void)
}
/* This builds the processor_model struct type defined in
libgcc/config/i386/i386-cpuinfo.c */
libgcc/config/i386/cpuinfo.c */
static tree
build_processor_model_struct (void)
@ -27725,7 +27725,7 @@ make_var_decl (tree type, const char *name)
}
/* FNDECL is a __builtin_cpu_is or a __builtin_cpu_supports call that is folded
into an integer defined in libgcc/config/i386/i386-cpuinfo.c */
into an integer defined in libgcc/config/i386/cpuinfo.c */
static tree
fold_builtin_cpu (tree fndecl, tree *args)
@ -27735,8 +27735,7 @@ fold_builtin_cpu (tree fndecl, tree *args)
DECL_FUNCTION_CODE (fndecl);
tree param_string_cst = NULL;
/* This is the order of bit-fields in __processor_features in
i386-cpuinfo.c */
/* This is the order of bit-fields in __processor_features in cpuinfo.c */
enum processor_features
{
F_CMOV = 0,
@ -27754,7 +27753,7 @@ fold_builtin_cpu (tree fndecl, tree *args)
};
/* These are the values for vendor types and cpu types and subtypes
in i386-cpuinfo.c. Cpu types and subtypes should be subtracted by
in cpuinfo.c. Cpu types and subtypes should be subtracted by
the corresponding start value. */
enum processor_model
{

View File

@ -9449,8 +9449,9 @@ executed before any constructors are called. The CPU detection code is
automatically executed in a very high priority constructor.
For example, this function has to be used in @code{ifunc} resolvers which
check for CPU type using the builtins, @code{__builtin_cpu_is}
and @code{__builtin_cpu_supports}.
check for CPU type using the builtins @code{__builtin_cpu_is}
and @code{__builtin_cpu_supports}, or in constructors on targets which
don't support constructor priority.
@smallexample
static void (*resolve_memcpy (void)) (void)

View File

@ -1,3 +1,30 @@
2012-05-10 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* config.host (i[34567]86-*-linux*, x86_64-*-linux*)
(i[34567]86-*-kfreebsd*-gnu, x86_64-*-kfreebsd*-gnu)
(i[34567]86-*-knetbsd*-gnu, i[34567]86-*-gnu*): Move
i386/t-cpuinfo ...
(i[34567]86-*-*, x86_64-*-*): ... here.
* config/i386/libgcc-bsd.ver (GCC_4.8.0): New version.
* config/i386/libgcc-sol2.ver (GCC_4.8.0): New version.
* config/i386/i386-cpuinfo.c: Rename to ...
* config/i386/cpuinfo.c: ... this.
* config/i386/t-cpuinfo (LIB2ADD): Reflect this.
* configure.ac (AC_CONFIG_HEADER): Call for auto-target.h.
(libgcc_cv_init_priority): New test.
* configure: Regenerate.
* config.in: New file.
* Makefile.in (clean): Rename config.h to auto-target.h.
(config.h): Likewise.
(stamp-h): Likewise.
* config/i386/cpuinfo.c (auto-target.h): Include.
(CONSTRUCTOR_PRIORITY): Define.
(__cpu_indicator_init): Use it.
2012-05-09 H.J. Lu <hongjiu.lu@intel.com>
* longlong.h: Use a URL instead of an FSF postal address.

View File

@ -121,7 +121,7 @@ installcheck:
.PHONY: all clean
clean:
-rm -f config.h libgcc_tm.h stamp-h stmp-ldirs libgcc.map
-rm -f auto-target.h libgcc_tm.h stamp-h stmp-ldirs libgcc.map
-rm -f *$(objext)
-rm -f *.dep
-rm -f *.a
@ -139,9 +139,9 @@ Makefile: $(srcdir)/Makefile.in config.status
# Depending on Makefile makes sure that config.status has been re-run
# if needed. This prevents problems with parallel builds.
config.h: stamp-h ; @true
auto-target.h: stamp-h ; @true
stamp-h: $(srcdir)/config.in config.status Makefile
CONFIG_FILES= CONFIG_HEADERS=config.h:$(srcdir)/config.in $(SHELL) ./config.status
CONFIG_FILES= CONFIG_HEADERS=auto-target.h:$(srcdir)/config.in $(SHELL) ./config.status
config.status: $(srcdir)/configure $(srcdir)/config.host
$(SHELL) ./config.status --recheck

View File

@ -1123,12 +1123,18 @@ mep*-*-*)
;;
esac
case ${host} in
i[34567]86-*-* | x86_64-*-*)
tmake_file="${tmake_file} i386/t-cpuinfo"
;;
esac
case ${host} in
i[34567]86-*-linux* | x86_64-*-linux* | \
i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu | \
i[34567]86-*-knetbsd*-gnu | \
i[34567]86-*-gnu*)
tmake_file="${tmake_file} t-tls i386/t-linux i386/t-cpuinfo"
tmake_file="${tmake_file} t-tls i386/t-linux"
if test "$libgcc_cv_cfi" = "yes"; then
tmake_file="${tmake_file} t-stack i386/t-stack-i386"
fi

70
libgcc/config.in Normal file
View File

@ -0,0 +1,70 @@
/* config.in. Generated from configure.ac by autoheader. */
/* Define to 1 if the target assembler supports thread-local storage. */
#undef HAVE_CC_TLS
/* Define if _Unwind_GetIPInfo is available. */
#undef HAVE_GETIPINFO
/* Define if the compiler supports init priority. */
#undef HAVE_INIT_PRIORITY
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if the C compiler is configured for setjmp/longjmp exceptions. */
#undef LIBGCC_SJLJ_EXCEPTIONS
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* The size of `double', as computed by sizeof. */
#undef SIZEOF_DOUBLE
/* The size of `long double', as computed by sizeof. */
#undef SIZEOF_LONG_DOUBLE
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if the target use emutls for thread-local storage. */
#undef USE_EMUTLS

View File

@ -20,8 +20,16 @@ along with GCC; see the file COPYING3. If not see
#include "cpuid.h"
#include "tsystem.h"
#include "auto-target.h"
int __cpu_indicator_init (void) __attribute__ ((constructor (101)));
#ifdef HAVE_INIT_PRIORITY
#define CONSTRUCTOR_PRIORITY (101)
#else
#define CONSTRUCTOR_PRIORITY
#endif
int __cpu_indicator_init (void)
__attribute__ ((constructor CONSTRUCTOR_PRIORITY));
enum vendor_signatures
{
@ -253,7 +261,7 @@ __get_cpuid_output (unsigned int __level,
the priority set. However, it still runs after ifunc initializers and
needs to be called explicitly there. */
int __attribute__ ((constructor (101)))
int __attribute__ ((constructor CONSTRUCTOR_PRIORITY))
__cpu_indicator_init (void)
{
unsigned int eax, ebx, ecx, edx;

View File

@ -1,4 +1,4 @@
# Copyright (C) 2010 Free Software Foundation, Inc.
# Copyright (C) 2010, 2012 Free Software Foundation, Inc.
#
# This file is part of GCC.
#
@ -106,3 +106,7 @@ GCC_4.6.0 {
__trunctfxf2
__unordtf2
}
GCC_4.8.0 {
__cpu_model
}

View File

@ -1,4 +1,4 @@
# Copyright (C) 2008, 2010 Free Software Foundation, Inc.
# Copyright (C) 2008, 2010, 2012 Free Software Foundation, Inc.
#
# This file is part of GCC.
#

View File

@ -1,4 +1,4 @@
# Copyright (C) 2010 Free Software Foundation, Inc.
# Copyright (C) 2010, 2012 Free Software Foundation, Inc.
#
# This file is part of GCC.
#
@ -106,3 +106,7 @@ GCC_4.5.0 {
__trunctfxf2
__unordtf2
}
GCC_4.8.0 {
__cpu_model
}

View File

@ -1 +1 @@
LIB2ADD += $(srcdir)/config/i386/i386-cpuinfo.c
LIB2ADD += $(srcdir)/config/i386/cpuinfo.c

231
libgcc/configure vendored
View File

@ -2176,6 +2176,8 @@ ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
ac_config_headers="$ac_config_headers auto-target.h:config.in"
# Check whether --enable-shared was given.
if test "${enable_shared+set}" = set; then :
@ -4756,6 +4758,38 @@ if test "$enable_tls $gcc_cv_use_emutls" = "yes yes"; then
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for init priority support" >&5
$as_echo_n "checking for init priority support... " >&6; }
if test "${libgcc_cv_init_priority+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
void ip (void) __attribute__ ((constructor (1)));
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
libgcc_cv_init_priority=yes
else
libgcc_cv_init_priority=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_init_priority" >&5
$as_echo "$libgcc_cv_init_priority" >&6; }
if test $libgcc_cv_init_priority = yes; then
$as_echo "#define HAVE_INIT_PRIORITY 1" >>confdefs.h
fi
# Conditionalize the sfp-machine.h header for this target machine.
if test -z "${sfp_machine_header}"; then
sfp_machine_header=$cpu_type/sfp-machine.h
@ -4902,43 +4936,7 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
# Transform confdefs.h into DEFS.
# Protect against shell expansion while executing Makefile rules.
# Protect against Makefile macro expansion.
#
# If the first sed substitution is executed (which looks for macros that
# take arguments), then branch to the quote section. Otherwise,
# look for a macro that doesn't take arguments.
ac_script='
:mline
/\\$/{
N
s,\\\n,,
b mline
}
t clear
:clear
s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g
t quote
s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g
t quote
b any
:quote
s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g
s/\[/\\&/g
s/\]/\\&/g
s/\$/$$/g
H
:any
${
g
s/^\n//
s/\n/ /g
p
}
'
DEFS=`sed -n "$ac_script" confdefs.h`
DEFS=-DHAVE_CONFIG_H
ac_libobjs=
ac_ltlibobjs=
@ -5382,11 +5380,15 @@ case $ac_config_files in *"
"*) set x $ac_config_files; shift; ac_config_files=$*;;
esac
case $ac_config_headers in *"
"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
esac
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
# Files that config.status was made for.
config_files="$ac_config_files"
config_headers="$ac_config_headers"
config_links="$ac_config_links"
config_commands="$ac_config_commands"
@ -5408,10 +5410,15 @@ Usage: $0 [OPTION]... [TAG]...
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
instantiate the configuration file FILE
--header=FILE[:TEMPLATE]
instantiate the configuration header FILE
Configuration files:
$config_files
Configuration headers:
$config_headers
Configuration links:
$config_links
@ -5473,7 +5480,18 @@ do
esac
as_fn_append CONFIG_FILES " '$ac_optarg'"
ac_need_defaults=false;;
--he | --h | --help | --hel | -h )
--header | --heade | --head | --hea )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
as_fn_append CONFIG_HEADERS " '$ac_optarg'"
ac_need_defaults=false;;
--he | --h)
# Conflict between --help and --header
as_fn_error "ambiguous option: \`$1'
Try \`$0 --help' for more information.";;
--help | --hel | -h )
$as_echo "$ac_cs_usage"; exit ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
@ -5542,6 +5560,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"auto-target.h") CONFIG_HEADERS="$CONFIG_HEADERS auto-target.h:config.in" ;;
"enable-execute-stack.c") CONFIG_LINKS="$CONFIG_LINKS enable-execute-stack.c:$enable_execute_stack" ;;
"unwind.h") CONFIG_LINKS="$CONFIG_LINKS unwind.h:$unwind_header" ;;
"md-unwind-support.h") CONFIG_LINKS="$CONFIG_LINKS md-unwind-support.h:config/$md_unwind_header" ;;
@ -5561,6 +5580,7 @@ done
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
test "${CONFIG_LINKS+set}" = set || CONFIG_LINKS=$config_links
test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
fi
@ -5740,8 +5760,116 @@ fi
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
fi # test -n "$CONFIG_FILES"
# Set up the scripts for CONFIG_HEADERS section.
# No need to generate them if there are no CONFIG_HEADERS.
# This happens for instance with `./config.status Makefile'.
if test -n "$CONFIG_HEADERS"; then
cat >"$tmp/defines.awk" <<\_ACAWK ||
BEGIN {
_ACEOF
eval set X " :F $CONFIG_FILES :L $CONFIG_LINKS :C $CONFIG_COMMANDS"
# Transform confdefs.h into an awk script `defines.awk', embedded as
# here-document in config.status, that substitutes the proper values into
# config.h.in to produce config.h.
# Create a delimiter string that does not exist in confdefs.h, to ease
# handling of long lines.
ac_delim='%!_!# '
for ac_last_try in false false :; do
ac_t=`sed -n "/$ac_delim/p" confdefs.h`
if test -z "$ac_t"; then
break
elif $ac_last_try; then
as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
# For the awk script, D is an array of macro values keyed by name,
# likewise P contains macro parameters if any. Preserve backslash
# newline sequences.
ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
sed -n '
s/.\{148\}/&'"$ac_delim"'/g
t rset
:rset
s/^[ ]*#[ ]*define[ ][ ]*/ /
t def
d
:def
s/\\$//
t bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3"/p
s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
d
:bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3\\\\\\n"\\/p
t cont
s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
t cont
d
:cont
n
s/.\{148\}/&'"$ac_delim"'/g
t clear
:clear
s/\\$//
t bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/"/p
d
:bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
b cont
' <confdefs.h | sed '
s/'"$ac_delim"'/"\\\
"/g' >>$CONFIG_STATUS || ac_write_fail=1
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
for (key in D) D_is_set[key] = 1
FS = ""
}
/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
line = \$ 0
split(line, arg, " ")
if (arg[1] == "#") {
defundef = arg[2]
mac1 = arg[3]
} else {
defundef = substr(arg[1], 2)
mac1 = arg[2]
}
split(mac1, mac2, "(") #)
macro = mac2[1]
prefix = substr(line, 1, index(line, defundef) - 1)
if (D_is_set[macro]) {
# Preserve the white space surrounding the "#".
print prefix "define", macro P[macro] D[macro]
next
} else {
# Replace #undef with comments. This is necessary, for example,
# in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it.
if (defundef == "undef") {
print "/*", prefix defundef, macro, "*/"
next
}
}
}
{ print }
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
as_fn_error "could not setup config headers machinery" "$LINENO" 5
fi # test -n "$CONFIG_HEADERS"
eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :L $CONFIG_LINKS :C $CONFIG_COMMANDS"
shift
for ac_tag
do
@ -5953,7 +6081,30 @@ which seems to be undefined. Please make sure it is defined." >&2;}
esac \
|| as_fn_error "could not create $ac_file" "$LINENO" 5
;;
:H)
#
# CONFIG_HEADER
#
if test x"$ac_file" != x-; then
{
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
} >"$tmp/config.h" \
|| as_fn_error "could not create $ac_file" "$LINENO" 5
if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
$as_echo "$as_me: $ac_file is unchanged" >&6;}
else
rm -f "$ac_file"
mv "$tmp/config.h" "$ac_file" \
|| as_fn_error "could not create $ac_file" "$LINENO" 5
fi
else
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
|| as_fn_error "could not create -" "$LINENO" 5
fi
;;
:L)
#
# CONFIG_LINK

View File

@ -39,6 +39,7 @@ else
fi
AC_SUBST(libgcc_topdir)
AC_CONFIG_AUX_DIR($libgcc_topdir)
AC_CONFIG_HEADER(auto-target.h:config.in)
AC_ARG_ENABLE(shared,
[ --disable-shared don't provide a shared libgcc],
@ -327,6 +328,15 @@ if test "$enable_tls $gcc_cv_use_emutls" = "yes yes"; then
fi
AC_SUBST(set_use_emutls)
AC_CACHE_CHECK(for init priority support, libgcc_cv_init_priority, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,
[[void ip (void) __attribute__ ((constructor (1)));]])],
[libgcc_cv_init_priority=yes],[libgcc_cv_init_priority=no])])
if test $libgcc_cv_init_priority = yes; then
AC_DEFINE(HAVE_INIT_PRIORITY, 1,
[Define if the compiler supports init priority.])
fi
# Conditionalize the sfp-machine.h header for this target machine.
if test -z "${sfp_machine_header}"; then
sfp_machine_header=$cpu_type/sfp-machine.h