On Mon, Apr 23, 2012 at 6:59 PM, Sriraman Tallam <tmsri...@google.com> wrote:
> * config/i386/i386.c (build_processor_features_struct): New function. > (build_processor_model_struct): New function. > (make_var_decl): New function. > (get_field_from_struct): New function. > (fold_builtin_target): New function. > (ix86_fold_builtin): New function. > (ix86_expand_builtin): Expand new builtins by folding them. > (make_cpu_type_builtin): New functions. > (ix86_init_platform_type_builtins): Make the new builtins. > (ix86_init_builtins): Make new builtins to detect CPU type. > (TARGET_FOLD_BUILTIN): New macro. > (IX86_BUILTIN_CPU_INIT): New enum value. > (IX86_BUILTIN_CPU_IS): New enum value. > (IX86_BUILTIN_CPU_SUPPORTS): New enum value. > * config/i386/i386-builtin-types.def: New function type. > * testsuite/gcc.target/builtin_target.c: New testcase. > * doc/extend.texi: Document builtins. > > * libgcc/config/i386/i386-cpuinfo.c: New file. > * libgcc/config/i386/t-cpuinfo: New file. > * libgcc/config.host: Include t-cpuinfo. > * libgcc/config/i386/libgcc-glibc.ver: Version symbols __cpu_model > and __cpu_features. A couple of typos in the documentation: +@deftypefn {Built-in Function} void __builtin_cpu_init (void) +This function runs the CPU detection code to check the type of CPU and the features +supported. This builtin needs to be invoked along with the builtins to check CPU type +and features, @code{__builtin_cpu_is} and @code{__builtin_cpu_supports}, only when used +used in a function that will be executed before any constructors are called. The used used +@item bdver1 +AMD family 15h Bulldozer version 1. + +@item bdver2 +AMD family 15h Bulldozer version 1. Ehm .... +@deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature}) +This function returns @code{1}, if the runtime cpu supports @var{feature} + and returns @code{0} otherwise. The following features can be detected: In the testcases, return value of the builtin is checked for < 0. If this signals an error, then please mention negative return and its meaning. +@deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname}) +This function returns @code{1}, if the runtime cpu is of type @var{cpuname} + and returns @code{0} otherwise. The following cpu names can be detected: Also here. I also think that this is very useful feature and deserves an entry in gcc-4.8 changes at http://gcc.gnu.org/gcc-4.8/changes.html . Uros.