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