]>
Commit | Line | Data |
---|---|---|
792317cc | 1 | /* Get CPU type and Features for x86 processors. |
7adcbafe | 2 | Copyright (C) 2012-2022 Free Software Foundation, Inc. |
792317cc ST |
3 | Contributed by Sriraman Tallam (tmsriram@google.com) |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 3, or (at your option) any later | |
10 | version. | |
11 | ||
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
16 | ||
46549c20 MK |
17 | Under Section 7 of GPL version 3, you are granted additional |
18 | permissions described in the GCC Runtime Library Exception, version | |
19 | 3.1, as published by the Free Software Foundation. | |
20 | ||
21 | You should have received a copy of the GNU General Public License and | |
22 | a copy of the GCC Runtime Library Exception along with this program; | |
23 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
24 | <http://www.gnu.org/licenses/>. */ | |
792317cc ST |
25 | |
26 | #include "cpuid.h" | |
27 | #include "tsystem.h" | |
aca06c90 | 28 | #include "auto-target.h" |
1890f2f0 L |
29 | #include "common/config/i386/i386-cpuinfo.h" |
30 | #include "common/config/i386/cpuinfo.h" | |
792317cc | 31 | |
aca06c90 RO |
32 | #ifdef HAVE_INIT_PRIORITY |
33 | #define CONSTRUCTOR_PRIORITY (101) | |
34 | #else | |
35 | #define CONSTRUCTOR_PRIORITY | |
36 | #endif | |
37 | ||
38 | int __cpu_indicator_init (void) | |
39 | __attribute__ ((constructor CONSTRUCTOR_PRIORITY)); | |
792317cc | 40 | |
792317cc | 41 | |
31cfd832 | 42 | struct __processor_model __cpu_model = { }; |
ae6dca8c JJ |
43 | /* We want to move away from __cpu_model in libgcc_s.so.1 and the |
44 | size of __cpu_model is part of ABI. So, new features that don't | |
45 | fit into __cpu_model.__cpu_features[0] go into extra variables | |
1890f2f0 | 46 | in libgcc.a only, preferably hidden. |
4f0e90fa | 47 | |
1890f2f0 L |
48 | NB: Since older 386-builtins.c accesses __cpu_features2 as scalar or |
49 | smaller array, it can only access the first few elements. */ | |
50 | unsigned int __cpu_features2[SIZE_OF_CPU_FEATURES]; | |
792317cc | 51 | |
792317cc ST |
52 | /* A constructor function that is sets __cpu_model and __cpu_features with |
53 | the right values. This needs to run only once. This constructor is | |
54 | given the highest priority and it should run before constructors without | |
55 | the priority set. However, it still runs after ifunc initializers and | |
56 | needs to be called explicitly there. */ | |
57 | ||
aca06c90 | 58 | int __attribute__ ((constructor CONSTRUCTOR_PRIORITY)) |
792317cc ST |
59 | __cpu_indicator_init (void) |
60 | { | |
1890f2f0 L |
61 | struct __processor_model2 cpu_model2; |
62 | return cpu_indicator_init (&__cpu_model, &cpu_model2, | |
63 | __cpu_features2); | |
792317cc | 64 | } |
abd0cdc9 L |
65 | |
66 | #if defined SHARED && defined USE_ELF_SYMVER | |
67 | __asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0"); | |
68 | __asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0"); | |
69 | #endif |