This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [4.7][google]Support for getting CPU type and feature information at run-time. (issue4893046)


Sri, please add a new api to do cpu_indicator initialization on demand
to be used in IFUNC context. Perhaps also add some debug check to make
sure no conflicting cpu model is set.

Ok for google branches for now while the discussion continues.

thanks,

David

On Thu, Aug 25, 2011 at 5:37 PM, Sriraman Tallam <tmsriram@google.com> wrote:
> Hi,
>
> ?Thanks for all the comments. I am attaching a new patch
> incorporating all of the changes mentioned, mainly :
>
> 1) Make __cpu_indicator_init a constructor in libgcc and guard to call
> it only once.
> 2) Add symbol versions.
> 3) Move all builtins to the i386 port.
> 4) Add check for atom processor.
> 5) No separate passes to fold the builtins.
>
> Please let me know what you think.
> Thanks,
> -Sri.
>
> ? ? ? ?* config/i386/i386.c (build_struct_with_one_bit_fields): 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.
> ? ? ? ?(TARGET_FOLD_BUILTIN): New macro.
> ? ? ? ?(IX86_BUILTIN_CPU_SUPPORTS_CMOV): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_SUPPORTS_MMX): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_SUPPORTS_POPCOUNT): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_SUPPORTS_SSE): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_SUPPORTS_SSE2): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_SUPPORTS_SSE3): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_SUPPORTS_SSSE3): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_SUPPORTS_SSE4_1): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_SUPPORTS_SSE4_2): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_IS_AMD): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_IS_INTEL): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_IS_INTEL_ATOM): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_IS_INTEL_CORE2): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_IS_INTEL_COREI7_NEHALEM): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_IS_INTEL_COREI7_WESTMERE): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_IS_INTEL_COREI7_SANDYBRIDGE): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_IS_AMDFAM10_BARCELONA): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_IS_AMDFAM10_SHANGHAI): New enum value.
> ? ? ? ?(IX86_BUILTIN_CPU_IS_AMDFAM10_ISTANBUL): New enum value.
> ? ? ? ?* config/i386/libgcc-glibc.ver (__cpu_indicator_init): Export symbol.
> ? ? ? ?(__cpu_model): Export symbol.
> ? ? ? ?(__cpu_features): Export symbol.
> ? ? ? ?* config/i386/i386-builtin-types.def: New function type.
>
> ? ? ? ?* 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
>
> ? ? ? ?* gcc.dg/builtin_target.c: New test.
>
>
>
>
> On Tue, Aug 23, 2011 at 4:35 AM, Michael Matz <matz@suse.de> wrote:
>> Hi,
>>
>> On Mon, 22 Aug 2011, H.J. Lu wrote:
>>
>>> > void __attribute__((constructor)) bla(void)
>>> > {
>>> > ?__cpu_indicator_init ();
>>> > }
>>> >
>>> > I don't see any complication.?
>>> >
>>>
>>> Order of constructors. ?A constructor may call functions
>>> which use __cpu_indicator.
>>
>> That's why I wrote also:
>>
>>> The initializer function has to be callable from pre-.init contexts, e.g.
>>> ifunc dispatchers.
>>
>> It obviously has to be guarded against multiple calls. ?The ctor in libgcc
>> would be mere convenience because then non-ctor code can rely on the data
>> being initialized, and only (potential) ctor code has to check and call
>> the init function on demand.
>>
>>
>> Ciao,
>> Michael.
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]