On Tue, Aug 16, 2011 at 2:06 PM, H.J. Lu <hjl.to...@gmail.com> wrote: > On Tue, Aug 16, 2011 at 1:50 PM, Sriraman Tallam <tmsri...@google.com> wrote: >> Support for getting CPU type and feature information at run-time. >> >> The following patch provides support for finding the platform type at >> run-time, like cpu type and features supported. The multi-versioning >> framework will use the builtins added to dispatch the right function >> version. Please refer to http://gcc.gnu.org/ml/gcc/2011-08/msg00298.html for >> details on function multi-versioning usability. >> >> * tree-pass.h (pass_tree_fold_builtin_target): New pass. >> * builtins.def (BUILT_IN_TARGET_SUPPORTS_CMOV): New builtin. >> (BUILT_IN_TARGET_SUPPORTS_MMX): New builtin. >> (BUILT_IN_TARGET_SUPPORTS_POPCOUNT): New builtin. >> (BUILT_IN_TARGET_SUPPORTS_SSE): New builtin. >> (BUILT_IN_TARGET_SUPPORTS_SSE2): New builtin. >> (BUILT_IN_TARGET_SUPPORTS_SSE3): New builtin. >> (BUILT_IN_TARGET_SUPPORTS_SSSE3): New builtin. >> (BUILT_IN_TARGET_SUPPORTS_SSE4_1): New builtin. >> (BUILT_IN_TARGET_SUPPORTS_SSE4_2): New builtin. >> (BUILT_IN_TARGET_IS_AMD): New builtin. >> (BUILT_IN_TARGET_IS_INTEL): New builtin. >> (BUILT_IN_TARGET_IS_COREI7_NEHALEM): New builtin. >> (BUILT_IN_TARGET_IS_COREI7_WESTMERE): New builtin. >> (BUILT_IN_TARGET_IS_COREI7_SANDYBRIDGE): New builtin. > > Can you add Intel Atom?
Yes, I will. There is probably a lot more that is interesting which I missed and will add if somebody sees fit. > >> (BUILT_IN_TARGET_IS_AMDFAM10_BARCELONA): New builtin. >> (BUILT_IN_TARGET_IS_AMDFAM10_SHANGHAI): New builtin. >> (BUILT_IN_TARGET_IS_AMDFAM10_ISTANBUL): New builtin. >> * mversn-dispatch.c (do_fold_builtin_target): New function. >> (gate_fold_builtin_target): New function. >> (pass_tree_fold_builtin_target): New pass. >> * timevar.def (TV_FOLD_BUILTIN_TARGET): New var. >> * passes.c (init_optimization_passes): Add new pass to pass list. >> * config/i386/i386.c (build_struct_with_one_bit_fields): New function. >> (make_var_decl): New function. >> (get_field_from_struct): New function. >> (make_constructor_to_get_target_type): New function. >> (fold_builtin_target): New function. >> (ix86_fold_builtin): New function. >> (TARGET_FOLD_BUILTIN): New macro. >> >> * gcc.dg/builtin_target.c: New test. >> >> * config/i386/i386-cpuinfo.c: New file. >> * config/i386/t-cpuinfo: New file. >> * config.host: Add t-cpuinfo to link i386-cpuinfo.o with libgcc >> > >> +static void >> +get_intel_cpu (unsigned int family, unsigned int model, unsigned int >> brand_id) >> +{ >> + /* Parse family and model only if brand ID is 0. */ >> + if (brand_id == 0) >> + { >> + switch (family) >> + { >> + case 0x5: >> + __cpu_type = PROCESSOR_PENTIUM; >> + break; >> + case 0x6: >> + switch (model) >> + { >> + case 0x1a: >> + case 0x1e: >> + case 0x1f: >> + case 0x2e: >> + /* Nehalem. */ >> + __cpu_type = PROCESSOR_COREI7_NEHALEM; >> + __cpu_model.__cpu_is_corei7_nehalem = 1; >> + break; >> + case 0x25: >> + case 0x2c: >> + case 0x2f: >> + /* Westmere. */ >> + __cpu_type = PROCESSOR_COREI7_WESTMERE; >> + __cpu_model.__cpu_is_corei7_westmere = 1; >> + break; >> + case 0x2a: >> + /* Sandy Bridge. */ >> + __cpu_type = PROCESSOR_COREI7_SANDYBRIDGE; >> + __cpu_model.__cpu_is_corei7_sandybridge = 1; >> + break; >> + case 0x17: >> + case 0x1d: >> + /* Penryn. */ >> + case 0x0f: >> + /* Merom. */ >> + __cpu_type = PROCESSOR_CORE2; >> + break; >> + default: >> + __cpu_type = PROCESSOR_INTEL_GENERIC; >> + break; >> + } >> + break; >> + default: >> + /* We have no idea. */ >> + __cpu_type = PROCESSOR_INTEL_GENERIC; >> + break; >> + } >> + } >> +} >> + > > Please see config/i386/driver-i386.c for Intel CPU detection. > I will try to make it up to date. For example, I added > model 0x2d, 0x1c, 0x26, I used the code in config/i386/driver-i386.c was used as reference. Thanks, -Sri. > > Thanks. > > -- > H.J. >