blob: 79ad4afacbda76b4dd69f680501745b95bade316 [file] [log] [blame]
Colin Crossa6845402020-11-16 15:08:19 -08001// Copyright 2020 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package android
16
17import "fmt"
18
19var archVariants = map[ArchType][]string{
20 Arm: {
21 "armv7-a",
22 "armv7-a-neon",
23 "armv8-a",
24 "armv8-2a",
Colin Crossa6845402020-11-16 15:08:19 -080025 },
26 Arm64: {
Liz Kammer2c2afe22022-02-11 11:35:03 -050027 "armv8-a",
28 "armv8-a-branchprot",
29 "armv8-2a",
Colin Crossa6845402020-11-16 15:08:19 -080030 "armv8-2a-dotprod",
Colin Crossa6845402020-11-16 15:08:19 -080031 },
32 X86: {
33 "amberlake",
34 "atom",
35 "broadwell",
36 "haswell",
37 "icelake",
38 "ivybridge",
39 "kabylake",
40 "sandybridge",
41 "silvermont",
42 "skylake",
43 "stoneyridge",
44 "tigerlake",
45 "whiskeylake",
46 "x86_64",
47 },
48 X86_64: {
49 "amberlake",
50 "broadwell",
51 "haswell",
52 "icelake",
53 "ivybridge",
54 "kabylake",
55 "sandybridge",
56 "silvermont",
57 "skylake",
58 "stoneyridge",
59 "tigerlake",
60 "whiskeylake",
61 },
62}
63
Liz Kammer2c2afe22022-02-11 11:35:03 -050064var cpuVariants = map[ArchType][]string{
65 Arm: {
66 "cortex-a7",
67 "cortex-a8",
68 "cortex-a9",
69 "cortex-a15",
70 "cortex-a53",
71 "cortex-a53.a57",
72 "cortex-a55",
73 "cortex-a72",
74 "cortex-a73",
75 "cortex-a75",
76 "cortex-a76",
77 "krait",
78 "kryo",
79 "kryo385",
80 "exynos-m1",
81 "exynos-m2",
82 },
83 Arm64: {
84 "cortex-a53",
85 "cortex-a55",
86 "cortex-a72",
87 "cortex-a73",
88 "cortex-a75",
89 "cortex-a76",
90 "kryo",
91 "kryo385",
92 "exynos-m1",
93 "exynos-m2",
94 },
95 X86: {},
96 X86_64: {},
97}
98
Colin Crossa6845402020-11-16 15:08:19 -080099var archFeatures = map[ArchType][]string{
100 Arm: {
101 "neon",
102 },
103 Arm64: {
104 "dotprod",
105 },
106 X86: {
107 "ssse3",
108 "sse4",
109 "sse4_1",
110 "sse4_2",
111 "aes_ni",
112 "avx",
113 "avx2",
114 "avx512",
115 "popcnt",
116 "movbe",
117 },
118 X86_64: {
119 "ssse3",
120 "sse4",
121 "sse4_1",
122 "sse4_2",
123 "aes_ni",
124 "avx",
125 "avx2",
126 "avx512",
127 "popcnt",
128 },
129}
130
131var archFeatureMap = map[ArchType]map[string][]string{
132 Arm: {
133 "armv7-a-neon": {
134 "neon",
135 },
136 "armv8-a": {
137 "neon",
138 },
139 "armv8-2a": {
140 "neon",
141 },
142 },
143 Arm64: {
144 "armv8-2a-dotprod": {
145 "dotprod",
146 },
147 },
148 X86: {
149 "amberlake": {
150 "ssse3",
151 "sse4",
152 "sse4_1",
153 "sse4_2",
154 "avx",
155 "avx2",
156 "aes_ni",
157 "popcnt",
158 },
159 "atom": {
160 "ssse3",
161 "movbe",
162 },
163 "broadwell": {
164 "ssse3",
165 "sse4",
166 "sse4_1",
167 "sse4_2",
168 "avx",
169 "avx2",
170 "aes_ni",
171 "popcnt",
172 },
173 "haswell": {
174 "ssse3",
175 "sse4",
176 "sse4_1",
177 "sse4_2",
178 "aes_ni",
179 "avx",
180 "popcnt",
181 "movbe",
182 },
183 "icelake": {
184 "ssse3",
185 "sse4",
186 "sse4_1",
187 "sse4_2",
188 "avx",
189 "avx2",
190 "avx512",
191 "aes_ni",
192 "popcnt",
193 },
194 "ivybridge": {
195 "ssse3",
196 "sse4",
197 "sse4_1",
198 "sse4_2",
199 "aes_ni",
200 "avx",
201 "popcnt",
202 },
203 "kabylake": {
204 "ssse3",
205 "sse4",
206 "sse4_1",
207 "sse4_2",
208 "avx",
209 "avx2",
210 "aes_ni",
211 "popcnt",
212 },
213 "sandybridge": {
214 "ssse3",
215 "sse4",
216 "sse4_1",
217 "sse4_2",
218 "popcnt",
219 },
220 "silvermont": {
221 "ssse3",
222 "sse4",
223 "sse4_1",
224 "sse4_2",
225 "aes_ni",
226 "popcnt",
227 "movbe",
228 },
229 "skylake": {
230 "ssse3",
231 "sse4",
232 "sse4_1",
233 "sse4_2",
234 "avx",
235 "avx2",
236 "avx512",
237 "aes_ni",
238 "popcnt",
239 },
240 "stoneyridge": {
241 "ssse3",
242 "sse4",
243 "sse4_1",
244 "sse4_2",
245 "aes_ni",
246 "avx",
247 "avx2",
248 "popcnt",
249 "movbe",
250 },
251 "tigerlake": {
252 "ssse3",
253 "sse4",
254 "sse4_1",
255 "sse4_2",
256 "avx",
257 "avx2",
258 "avx512",
259 "aes_ni",
260 "popcnt",
261 },
262 "whiskeylake": {
263 "ssse3",
264 "sse4",
265 "sse4_1",
266 "sse4_2",
267 "avx",
268 "avx2",
269 "avx512",
270 "aes_ni",
271 "popcnt",
272 },
273 "x86_64": {
274 "ssse3",
275 "sse4",
276 "sse4_1",
277 "sse4_2",
278 "popcnt",
279 },
280 },
281 X86_64: {
282 "amberlake": {
283 "ssse3",
284 "sse4",
285 "sse4_1",
286 "sse4_2",
287 "avx",
288 "avx2",
289 "aes_ni",
290 "popcnt",
291 },
292 "broadwell": {
293 "ssse3",
294 "sse4",
295 "sse4_1",
296 "sse4_2",
297 "avx",
298 "avx2",
299 "aes_ni",
300 "popcnt",
301 },
302 "haswell": {
303 "ssse3",
304 "sse4",
305 "sse4_1",
306 "sse4_2",
307 "aes_ni",
308 "avx",
309 "popcnt",
310 },
311 "icelake": {
312 "ssse3",
313 "sse4",
314 "sse4_1",
315 "sse4_2",
316 "avx",
317 "avx2",
318 "avx512",
319 "aes_ni",
320 "popcnt",
321 },
322 "ivybridge": {
323 "ssse3",
324 "sse4",
325 "sse4_1",
326 "sse4_2",
327 "aes_ni",
328 "avx",
329 "popcnt",
330 },
331 "kabylake": {
332 "ssse3",
333 "sse4",
334 "sse4_1",
335 "sse4_2",
336 "avx",
337 "avx2",
338 "aes_ni",
339 "popcnt",
340 },
341 "sandybridge": {
342 "ssse3",
343 "sse4",
344 "sse4_1",
345 "sse4_2",
346 "popcnt",
347 },
348 "silvermont": {
349 "ssse3",
350 "sse4",
351 "sse4_1",
352 "sse4_2",
353 "aes_ni",
354 "popcnt",
355 },
356 "skylake": {
357 "ssse3",
358 "sse4",
359 "sse4_1",
360 "sse4_2",
361 "avx",
362 "avx2",
363 "avx512",
364 "aes_ni",
365 "popcnt",
366 },
367 "stoneyridge": {
368 "ssse3",
369 "sse4",
370 "sse4_1",
371 "sse4_2",
372 "aes_ni",
373 "avx",
374 "avx2",
375 "popcnt",
376 },
377 "tigerlake": {
378 "ssse3",
379 "sse4",
380 "sse4_1",
381 "sse4_2",
382 "avx",
383 "avx2",
384 "avx512",
385 "aes_ni",
386 "popcnt",
387 },
388 "whiskeylake": {
389 "ssse3",
390 "sse4",
391 "sse4_1",
392 "sse4_2",
393 "avx",
394 "avx2",
395 "avx512",
396 "aes_ni",
397 "popcnt",
398 },
399 },
400}
401
402var defaultArchFeatureMap = map[OsType]map[ArchType][]string{}
403
404// RegisterDefaultArchVariantFeatures is called by files that define Toolchains to specify the
405// arch features that are available for the default arch variant. It must be called from an
406// init() function.
407func RegisterDefaultArchVariantFeatures(os OsType, arch ArchType, features ...string) {
408 checkCalledFromInit()
409
410 for _, feature := range features {
411 if !InList(feature, archFeatures[arch]) {
412 panic(fmt.Errorf("Invalid feature %q for arch %q variant \"\"", feature, arch))
413 }
414 }
415
416 if defaultArchFeatureMap[os] == nil {
417 defaultArchFeatureMap[os] = make(map[ArchType][]string)
418 }
419 defaultArchFeatureMap[os][arch] = features
420}