blob: d68a0d1d14ccd8105dc8d57dc5de8adbcfe2df2a [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",
25 "cortex-a7",
26 "cortex-a8",
27 "cortex-a9",
28 "cortex-a15",
29 "cortex-a53",
30 "cortex-a53-a57",
31 "cortex-a55",
32 "cortex-a72",
33 "cortex-a73",
34 "cortex-a75",
35 "cortex-a76",
36 "krait",
37 "kryo",
38 "kryo385",
39 "exynos-m1",
40 "exynos-m2",
41 },
42 Arm64: {
43 "armv8_a",
Tamas Petzbca786d2021-01-20 18:56:33 +010044 "armv8_a_branchprot",
Colin Crossa6845402020-11-16 15:08:19 -080045 "armv8_2a",
46 "armv8-2a-dotprod",
47 "cortex-a53",
48 "cortex-a55",
49 "cortex-a72",
50 "cortex-a73",
51 "cortex-a75",
52 "cortex-a76",
53 "kryo",
54 "kryo385",
55 "exynos-m1",
56 "exynos-m2",
57 },
58 X86: {
59 "amberlake",
60 "atom",
61 "broadwell",
62 "haswell",
63 "icelake",
64 "ivybridge",
65 "kabylake",
66 "sandybridge",
67 "silvermont",
68 "skylake",
69 "stoneyridge",
70 "tigerlake",
71 "whiskeylake",
72 "x86_64",
73 },
74 X86_64: {
75 "amberlake",
76 "broadwell",
77 "haswell",
78 "icelake",
79 "ivybridge",
80 "kabylake",
81 "sandybridge",
82 "silvermont",
83 "skylake",
84 "stoneyridge",
85 "tigerlake",
86 "whiskeylake",
87 },
88}
89
90var archFeatures = map[ArchType][]string{
91 Arm: {
92 "neon",
93 },
94 Arm64: {
95 "dotprod",
96 },
97 X86: {
98 "ssse3",
99 "sse4",
100 "sse4_1",
101 "sse4_2",
102 "aes_ni",
103 "avx",
104 "avx2",
105 "avx512",
106 "popcnt",
107 "movbe",
108 },
109 X86_64: {
110 "ssse3",
111 "sse4",
112 "sse4_1",
113 "sse4_2",
114 "aes_ni",
115 "avx",
116 "avx2",
117 "avx512",
118 "popcnt",
119 },
120}
121
122var archFeatureMap = map[ArchType]map[string][]string{
123 Arm: {
124 "armv7-a-neon": {
125 "neon",
126 },
127 "armv8-a": {
128 "neon",
129 },
130 "armv8-2a": {
131 "neon",
132 },
133 },
134 Arm64: {
135 "armv8-2a-dotprod": {
136 "dotprod",
137 },
138 },
139 X86: {
140 "amberlake": {
141 "ssse3",
142 "sse4",
143 "sse4_1",
144 "sse4_2",
145 "avx",
146 "avx2",
147 "aes_ni",
148 "popcnt",
149 },
150 "atom": {
151 "ssse3",
152 "movbe",
153 },
154 "broadwell": {
155 "ssse3",
156 "sse4",
157 "sse4_1",
158 "sse4_2",
159 "avx",
160 "avx2",
161 "aes_ni",
162 "popcnt",
163 },
164 "haswell": {
165 "ssse3",
166 "sse4",
167 "sse4_1",
168 "sse4_2",
169 "aes_ni",
170 "avx",
171 "popcnt",
172 "movbe",
173 },
174 "icelake": {
175 "ssse3",
176 "sse4",
177 "sse4_1",
178 "sse4_2",
179 "avx",
180 "avx2",
181 "avx512",
182 "aes_ni",
183 "popcnt",
184 },
185 "ivybridge": {
186 "ssse3",
187 "sse4",
188 "sse4_1",
189 "sse4_2",
190 "aes_ni",
191 "avx",
192 "popcnt",
193 },
194 "kabylake": {
195 "ssse3",
196 "sse4",
197 "sse4_1",
198 "sse4_2",
199 "avx",
200 "avx2",
201 "aes_ni",
202 "popcnt",
203 },
204 "sandybridge": {
205 "ssse3",
206 "sse4",
207 "sse4_1",
208 "sse4_2",
209 "popcnt",
210 },
211 "silvermont": {
212 "ssse3",
213 "sse4",
214 "sse4_1",
215 "sse4_2",
216 "aes_ni",
217 "popcnt",
218 "movbe",
219 },
220 "skylake": {
221 "ssse3",
222 "sse4",
223 "sse4_1",
224 "sse4_2",
225 "avx",
226 "avx2",
227 "avx512",
228 "aes_ni",
229 "popcnt",
230 },
231 "stoneyridge": {
232 "ssse3",
233 "sse4",
234 "sse4_1",
235 "sse4_2",
236 "aes_ni",
237 "avx",
238 "avx2",
239 "popcnt",
240 "movbe",
241 },
242 "tigerlake": {
243 "ssse3",
244 "sse4",
245 "sse4_1",
246 "sse4_2",
247 "avx",
248 "avx2",
249 "avx512",
250 "aes_ni",
251 "popcnt",
252 },
253 "whiskeylake": {
254 "ssse3",
255 "sse4",
256 "sse4_1",
257 "sse4_2",
258 "avx",
259 "avx2",
260 "avx512",
261 "aes_ni",
262 "popcnt",
263 },
264 "x86_64": {
265 "ssse3",
266 "sse4",
267 "sse4_1",
268 "sse4_2",
269 "popcnt",
270 },
271 },
272 X86_64: {
273 "amberlake": {
274 "ssse3",
275 "sse4",
276 "sse4_1",
277 "sse4_2",
278 "avx",
279 "avx2",
280 "aes_ni",
281 "popcnt",
282 },
283 "broadwell": {
284 "ssse3",
285 "sse4",
286 "sse4_1",
287 "sse4_2",
288 "avx",
289 "avx2",
290 "aes_ni",
291 "popcnt",
292 },
293 "haswell": {
294 "ssse3",
295 "sse4",
296 "sse4_1",
297 "sse4_2",
298 "aes_ni",
299 "avx",
300 "popcnt",
301 },
302 "icelake": {
303 "ssse3",
304 "sse4",
305 "sse4_1",
306 "sse4_2",
307 "avx",
308 "avx2",
309 "avx512",
310 "aes_ni",
311 "popcnt",
312 },
313 "ivybridge": {
314 "ssse3",
315 "sse4",
316 "sse4_1",
317 "sse4_2",
318 "aes_ni",
319 "avx",
320 "popcnt",
321 },
322 "kabylake": {
323 "ssse3",
324 "sse4",
325 "sse4_1",
326 "sse4_2",
327 "avx",
328 "avx2",
329 "aes_ni",
330 "popcnt",
331 },
332 "sandybridge": {
333 "ssse3",
334 "sse4",
335 "sse4_1",
336 "sse4_2",
337 "popcnt",
338 },
339 "silvermont": {
340 "ssse3",
341 "sse4",
342 "sse4_1",
343 "sse4_2",
344 "aes_ni",
345 "popcnt",
346 },
347 "skylake": {
348 "ssse3",
349 "sse4",
350 "sse4_1",
351 "sse4_2",
352 "avx",
353 "avx2",
354 "avx512",
355 "aes_ni",
356 "popcnt",
357 },
358 "stoneyridge": {
359 "ssse3",
360 "sse4",
361 "sse4_1",
362 "sse4_2",
363 "aes_ni",
364 "avx",
365 "avx2",
366 "popcnt",
367 },
368 "tigerlake": {
369 "ssse3",
370 "sse4",
371 "sse4_1",
372 "sse4_2",
373 "avx",
374 "avx2",
375 "avx512",
376 "aes_ni",
377 "popcnt",
378 },
379 "whiskeylake": {
380 "ssse3",
381 "sse4",
382 "sse4_1",
383 "sse4_2",
384 "avx",
385 "avx2",
386 "avx512",
387 "aes_ni",
388 "popcnt",
389 },
390 },
391}
392
393var defaultArchFeatureMap = map[OsType]map[ArchType][]string{}
394
395// RegisterDefaultArchVariantFeatures is called by files that define Toolchains to specify the
396// arch features that are available for the default arch variant. It must be called from an
397// init() function.
398func RegisterDefaultArchVariantFeatures(os OsType, arch ArchType, features ...string) {
399 checkCalledFromInit()
400
401 for _, feature := range features {
402 if !InList(feature, archFeatures[arch]) {
403 panic(fmt.Errorf("Invalid feature %q for arch %q variant \"\"", feature, arch))
404 }
405 }
406
407 if defaultArchFeatureMap[os] == nil {
408 defaultArchFeatureMap[os] = make(map[ArchType][]string)
409 }
410 defaultArchFeatureMap[os][arch] = features
411}