authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-02-27 17:26:06-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-02-27 17:26:06-07:00
log85ab1b01e73d9b616f8af3951c132920e61be731
tree86e689469e4c674b235a649a49603470f72cfdf8
parente02acc028825ec83951946e4947883c2c96211ce

tools/update_cpu_features: add a "flatten" feature

and use it to clean up aarch64 target CPU features

2 files changed, 455 insertions(+), 163 deletions(-)

lib/std/target/aarch64.zig+243-145
...@@ -1,14 +1,10 @@...@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: MIT1//! This file is auto-generated by tools/update_cpu_features.zig.
2// Copyright (c) 2015-2021 Zig Contributors2
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.
6const std = @import("../std.zig");3const std = @import("../std.zig");
7const CpuFeature = std.Target.Cpu.Feature;4const CpuFeature = std.Target.Cpu.Feature;
8const CpuModel = std.Target.Cpu.Model;5const CpuModel = std.Target.Cpu.Model;
96
10pub const Feature = enum {7pub const Feature = enum {
11 a34,
12 a65,8 a65,
13 a76,9 a76,
14 aes,10 aes,
...@@ -17,8 +13,6 @@ pub const Feature = enum {...@@ -17,8 +13,6 @@ pub const Feature = enum {
17 altnzcv,13 altnzcv,
18 am,14 am,
19 amvs,15 amvs,
20 apple_a10,
21 apple_a11,
22 apple_a12,16 apple_a12,
23 apple_a13,17 apple_a13,
24 apple_a7,18 apple_a7,
...@@ -26,6 +20,7 @@ pub const Feature = enum {...@@ -26,6 +20,7 @@ pub const Feature = enum {
26 arith_cbz_fusion,20 arith_cbz_fusion,
27 balance_fp_ops,21 balance_fp_ops,
28 bf16,22 bf16,
23 brbe,
29 bti,24 bti,
30 call_saved_x10,25 call_saved_x10,
31 call_saved_x11,26 call_saved_x11,
...@@ -39,8 +34,11 @@ pub const Feature = enum {...@@ -39,8 +34,11 @@ pub const Feature = enum {
39 ccdp,34 ccdp,
40 ccidx,35 ccidx,
41 ccpp,36 ccpp,
37 cmp_bcc_fusion,
42 complxnum,38 complxnum,
43 context_id_rel2,39 contextidr_el2,
40 cortex_a78c,
41 cortex_r82,
44 crc,42 crc,
45 crypto,43 crypto,
46 custom_cheap_as_move,44 custom_cheap_as_move,
...@@ -50,14 +48,14 @@ pub const Feature = enum {...@@ -50,14 +48,14 @@ pub const Feature = enum {
50 ecv,48 ecv,
51 ete,49 ete,
52 exynos_cheap_as_move,50 exynos_cheap_as_move,
53 exynosm4,51 exynos_m4,
54 f32mm,52 f32mm,
55 f64mm,53 f64mm,
56 fgt,54 fgt,
57 fmi,55 flagm,
58 force_32bit_jump_tables,56 force_32bit_jump_tables,
59 fp_armv8,
60 fp16fml,57 fp16fml,
58 fp_armv8,
61 fptoint,59 fptoint,
62 fullfp16,60 fullfp16,
63 fuse_address,61 fuse_address,
...@@ -68,9 +66,11 @@ pub const Feature = enum {...@@ -68,9 +66,11 @@ pub const Feature = enum {
68 fuse_literals,66 fuse_literals,
69 harden_sls_blr,67 harden_sls_blr,
70 harden_sls_retbr,68 harden_sls_retbr,
69 hcx,
71 i8mm,70 i8mm,
72 jsconv,71 jsconv,
73 lor,72 lor,
73 ls64,
74 lse,74 lse,
75 lsl_fast,75 lsl_fast,
76 mpam,76 mpam,
...@@ -83,9 +83,9 @@ pub const Feature = enum {...@@ -83,9 +83,9 @@ pub const Feature = enum {
83 no_neg_immediates,83 no_neg_immediates,
84 nv,84 nv,
85 outline_atomics,85 outline_atomics,
86 pa,
87 pan,86 pan,
88 pan_rwv,87 pan_rwv,
88 pauth,
89 perfmon,89 perfmon,
90 pmu,90 pmu,
91 predictable_select_expensive,91 predictable_select_expensive,
...@@ -129,6 +129,7 @@ pub const Feature = enum {...@@ -129,6 +129,7 @@ pub const Feature = enum {
129 slow_strqro_store,129 slow_strqro_store,
130 sm4,130 sm4,
131 spe,131 spe,
132 spe_eef,
132 specrestrict,133 specrestrict,
133 ssbs,134 ssbs,
134 strict_align,135 strict_align,
...@@ -151,15 +152,18 @@ pub const Feature = enum {...@@ -151,15 +152,18 @@ pub const Feature = enum {
151 use_experimental_zeroing_pseudos,152 use_experimental_zeroing_pseudos,
152 use_postra_scheduler,153 use_postra_scheduler,
153 use_reciprocal_square_root,154 use_reciprocal_square_root,
154 v8a,
155 v8_1a,155 v8_1a,
156 v8_2a,156 v8_2a,
157 v8_3a,157 v8_3a,
158 v8_4a,158 v8_4a,
159 v8_5a,159 v8_5a,
160 v8_6a,160 v8_6a,
161 v8_7a,
162 v8a,
161 v8r,163 v8r,
162 vh,164 vh,
165 wfxt,
166 xs,
163 zcm,167 zcm,
164 zcz,168 zcz,
165 zcz_fp,169 zcz_fp,
...@@ -174,26 +178,16 @@ pub const all_features = blk: {...@@ -174,26 +178,16 @@ pub const all_features = blk: {
174 const len = @typeInfo(Feature).Enum.fields.len;178 const len = @typeInfo(Feature).Enum.fields.len;
175 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);179 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
176 var result: [len]CpuFeature = undefined;180 var result: [len]CpuFeature = undefined;
177 result[@enumToInt(Feature.a34)] = .{
178 .llvm_name = "a35",
179 .description = "Cortex-A34 ARM processors",
180 .dependencies = featureSet(&[_]Feature{
181 .crc,
182 .crypto,
183 .perfmon,
184 .v8a,
185 }),
186 };
187 result[@enumToInt(Feature.a65)] = .{181 result[@enumToInt(Feature.a65)] = .{
188 .llvm_name = "a65",182 .llvm_name = "a65",
189 .description = "Cortex-A65 ARM processors",183 .description = "Cortex-A65 ARM processors",
190 .dependencies = featureSet(&[_]Feature{184 .dependencies = featureSet(&[_]Feature{
191 .crypto,185 .crypto,
192 .dotprod,186 .dotprod,
193 .fp_armv8,
194 .fullfp16,187 .fullfp16,
195 .neon,188 .fuse_address,
196 .ras,189 .fuse_aes,
190 .fuse_literals,
197 .rcpc,191 .rcpc,
198 .ssbs,192 .ssbs,
199 .v8_2a,193 .v8_2a,
...@@ -206,6 +200,7 @@ pub const all_features = blk: {...@@ -206,6 +200,7 @@ pub const all_features = blk: {
206 .crypto,200 .crypto,
207 .dotprod,201 .dotprod,
208 .fullfp16,202 .fullfp16,
203 .fuse_aes,
209 .rcpc,204 .rcpc,
210 .ssbs,205 .ssbs,
211 .v8_2a,206 .v8_2a,
...@@ -245,49 +240,6 @@ pub const all_features = blk: {...@@ -245,49 +240,6 @@ pub const all_features = blk: {
245 .am,240 .am,
246 }),241 }),
247 };242 };
248 result[@enumToInt(Feature.apple_a10)] = .{
249 .llvm_name = "apple-a10",
250 .description = "Apple A10",
251 .dependencies = featureSet(&[_]Feature{
252 .alternate_sextload_cvt_f32_pattern,
253 .arith_bcc_fusion,
254 .arith_cbz_fusion,
255 .crc,
256 .crypto,
257 .disable_latency_sched_heuristic,
258 .fp_armv8,
259 .fuse_aes,
260 .fuse_crypto_eor,
261 .lor,
262 .neon,
263 .pan,
264 .perfmon,
265 .rdm,
266 .vh,
267 .zcm,
268 .zcz,
269 }),
270 };
271 result[@enumToInt(Feature.apple_a11)] = .{
272 .llvm_name = "apple-a11",
273 .description = "Apple A11",
274 .dependencies = featureSet(&[_]Feature{
275 .alternate_sextload_cvt_f32_pattern,
276 .arith_bcc_fusion,
277 .arith_cbz_fusion,
278 .crypto,
279 .disable_latency_sched_heuristic,
280 .fp_armv8,
281 .fullfp16,
282 .fuse_aes,
283 .fuse_crypto_eor,
284 .neon,
285 .perfmon,
286 .v8_2a,
287 .zcm,
288 .zcz,
289 }),
290 };
291 result[@enumToInt(Feature.apple_a12)] = .{243 result[@enumToInt(Feature.apple_a12)] = .{
292 .llvm_name = "apple-a12",244 .llvm_name = "apple-a12",
293 .description = "Apple A12",245 .description = "Apple A12",
...@@ -297,11 +249,9 @@ pub const all_features = blk: {...@@ -297,11 +249,9 @@ pub const all_features = blk: {
297 .arith_cbz_fusion,249 .arith_cbz_fusion,
298 .crypto,250 .crypto,
299 .disable_latency_sched_heuristic,251 .disable_latency_sched_heuristic,
300 .fp_armv8,
301 .fullfp16,252 .fullfp16,
302 .fuse_aes,253 .fuse_aes,
303 .fuse_crypto_eor,254 .fuse_crypto_eor,
304 .neon,
305 .perfmon,255 .perfmon,
306 .v8_3a,256 .v8_3a,
307 .zcm,257 .zcm,
...@@ -317,12 +267,9 @@ pub const all_features = blk: {...@@ -317,12 +267,9 @@ pub const all_features = blk: {
317 .arith_cbz_fusion,267 .arith_cbz_fusion,
318 .crypto,268 .crypto,
319 .disable_latency_sched_heuristic,269 .disable_latency_sched_heuristic,
320 .fp_armv8,
321 .fp16fml,270 .fp16fml,
322 .fullfp16,
323 .fuse_aes,271 .fuse_aes,
324 .fuse_crypto_eor,272 .fuse_crypto_eor,
325 .neon,
326 .perfmon,273 .perfmon,
327 .sha3,274 .sha3,
328 .v8_4a,275 .v8_4a,
...@@ -339,10 +286,8 @@ pub const all_features = blk: {...@@ -339,10 +286,8 @@ pub const all_features = blk: {
339 .arith_cbz_fusion,286 .arith_cbz_fusion,
340 .crypto,287 .crypto,
341 .disable_latency_sched_heuristic,288 .disable_latency_sched_heuristic,
342 .fp_armv8,
343 .fuse_aes,289 .fuse_aes,
344 .fuse_crypto_eor,290 .fuse_crypto_eor,
345 .neon,
346 .perfmon,291 .perfmon,
347 .zcm,292 .zcm,
348 .zcz,293 .zcz,
...@@ -369,6 +314,11 @@ pub const all_features = blk: {...@@ -369,6 +314,11 @@ pub const all_features = blk: {
369 .description = "Enable BFloat16 Extension",314 .description = "Enable BFloat16 Extension",
370 .dependencies = featureSet(&[_]Feature{}),315 .dependencies = featureSet(&[_]Feature{}),
371 };316 };
317 result[@enumToInt(Feature.brbe)] = .{
318 .llvm_name = "brbe",
319 .description = "Enable Branch Record Buffer Extension",
320 .dependencies = featureSet(&[_]Feature{}),
321 };
372 result[@enumToInt(Feature.bti)] = .{322 result[@enumToInt(Feature.bti)] = .{
373 .llvm_name = "bti",323 .llvm_name = "bti",
374 .description = "Enable Branch Target Identification",324 .description = "Enable Branch Target Identification",
...@@ -434,6 +384,11 @@ pub const all_features = blk: {...@@ -434,6 +384,11 @@ pub const all_features = blk: {
434 .description = "Enable v8.2 data Cache Clean to Point of Persistence",384 .description = "Enable v8.2 data Cache Clean to Point of Persistence",
435 .dependencies = featureSet(&[_]Feature{}),385 .dependencies = featureSet(&[_]Feature{}),
436 };386 };
387 result[@enumToInt(Feature.cmp_bcc_fusion)] = .{
388 .llvm_name = "cmp-bcc-fusion",
389 .description = "CPU fuses cmp+bcc operations",
390 .dependencies = featureSet(&[_]Feature{}),
391 };
437 result[@enumToInt(Feature.complxnum)] = .{392 result[@enumToInt(Feature.complxnum)] = .{
438 .llvm_name = "complxnum",393 .llvm_name = "complxnum",
439 .description = "Enable v8.3-A Floating-point complex number support",394 .description = "Enable v8.3-A Floating-point complex number support",
...@@ -441,11 +396,38 @@ pub const all_features = blk: {...@@ -441,11 +396,38 @@ pub const all_features = blk: {
441 .neon,396 .neon,
442 }),397 }),
443 };398 };
444 result[@enumToInt(Feature.context_id_rel2)] = .{399 result[@enumToInt(Feature.contextidr_el2)] = .{
445 .llvm_name = "CONTEXTIDREL2",400 .llvm_name = "CONTEXTIDREL2",
446 .description = "Enable RW operand CONTEXTIDR_EL2",401 .description = "Enable RW operand Context ID Register (EL2)",
447 .dependencies = featureSet(&[_]Feature{}),402 .dependencies = featureSet(&[_]Feature{}),
448 };403 };
404 result[@enumToInt(Feature.cortex_a78c)] = .{
405 .llvm_name = "cortex-a78c",
406 .description = "Cortex-A78C ARM processors",
407 .dependencies = featureSet(&[_]Feature{
408 .cmp_bcc_fusion,
409 .crypto,
410 .dotprod,
411 .flagm,
412 .fp16fml,
413 .fuse_aes,
414 .pauth,
415 .perfmon,
416 .rcpc,
417 .spe,
418 .ssbs,
419 .use_postra_scheduler,
420 .v8_2a,
421 }),
422 };
423 result[@enumToInt(Feature.cortex_r82)] = .{
424 .llvm_name = "cortex-r82",
425 .description = "Cortex-R82 ARM Processors",
426 .dependencies = featureSet(&[_]Feature{
427 .use_postra_scheduler,
428 .v8r,
429 }),
430 };
449 result[@enumToInt(Feature.crc)] = .{431 result[@enumToInt(Feature.crc)] = .{
450 .llvm_name = "crc",432 .llvm_name = "crc",
451 .description = "Enable ARMv8 CRC-32 checksum instructions",433 .description = "Enable ARMv8 CRC-32 checksum instructions",
...@@ -456,7 +438,6 @@ pub const all_features = blk: {...@@ -456,7 +438,6 @@ pub const all_features = blk: {
456 .description = "Enable cryptographic instructions",438 .description = "Enable cryptographic instructions",
457 .dependencies = featureSet(&[_]Feature{439 .dependencies = featureSet(&[_]Feature{
458 .aes,440 .aes,
459 .neon,
460 .sha2,441 .sha2,
461 }),442 }),
462 };443 };
...@@ -499,7 +480,7 @@ pub const all_features = blk: {...@@ -499,7 +480,7 @@ pub const all_features = blk: {
499 .custom_cheap_as_move,480 .custom_cheap_as_move,
500 }),481 }),
501 };482 };
502 result[@enumToInt(Feature.exynosm4)] = .{483 result[@enumToInt(Feature.exynos_m4)] = .{
503 .llvm_name = "exynosm4",484 .llvm_name = "exynosm4",
504 .description = "Samsung Exynos-M4 processors",485 .description = "Samsung Exynos-M4 processors",
505 .dependencies = featureSet(&[_]Feature{486 .dependencies = featureSet(&[_]Feature{
...@@ -541,8 +522,8 @@ pub const all_features = blk: {...@@ -541,8 +522,8 @@ pub const all_features = blk: {
541 .description = "Enable fine grained virtualization traps extension",522 .description = "Enable fine grained virtualization traps extension",
542 .dependencies = featureSet(&[_]Feature{}),523 .dependencies = featureSet(&[_]Feature{}),
543 };524 };
544 result[@enumToInt(Feature.fmi)] = .{525 result[@enumToInt(Feature.flagm)] = .{
545 .llvm_name = "fmi",526 .llvm_name = "flagm",
546 .description = "Enable v8.4-A Flag Manipulation Instructions",527 .description = "Enable v8.4-A Flag Manipulation Instructions",
547 .dependencies = featureSet(&[_]Feature{}),528 .dependencies = featureSet(&[_]Feature{}),
548 };529 };
...@@ -551,11 +532,6 @@ pub const all_features = blk: {...@@ -551,11 +532,6 @@ pub const all_features = blk: {
551 .description = "Force jump table entries to be 32-bits wide except at MinSize",532 .description = "Force jump table entries to be 32-bits wide except at MinSize",
552 .dependencies = featureSet(&[_]Feature{}),533 .dependencies = featureSet(&[_]Feature{}),
553 };534 };
554 result[@enumToInt(Feature.fp_armv8)] = .{
555 .llvm_name = "fp-armv8",
556 .description = "Enable ARMv8 FP",
557 .dependencies = featureSet(&[_]Feature{}),
558 };
559 result[@enumToInt(Feature.fp16fml)] = .{535 result[@enumToInt(Feature.fp16fml)] = .{
560 .llvm_name = "fp16fml",536 .llvm_name = "fp16fml",
561 .description = "Enable FP16 FML instructions",537 .description = "Enable FP16 FML instructions",
...@@ -563,6 +539,11 @@ pub const all_features = blk: {...@@ -563,6 +539,11 @@ pub const all_features = blk: {
563 .fullfp16,539 .fullfp16,
564 }),540 }),
565 };541 };
542 result[@enumToInt(Feature.fp_armv8)] = .{
543 .llvm_name = "fp-armv8",
544 .description = "Enable ARMv8 FP",
545 .dependencies = featureSet(&[_]Feature{}),
546 };
566 result[@enumToInt(Feature.fptoint)] = .{547 result[@enumToInt(Feature.fptoint)] = .{
567 .llvm_name = "fptoint",548 .llvm_name = "fptoint",
568 .description = "Enable FRInt[32|64][Z|X] instructions that round a floating-point number to an integer (in FP format) forcing it to fit into a 32- or 64-bit int",549 .description = "Enable FRInt[32|64][Z|X] instructions that round a floating-point number to an integer (in FP format) forcing it to fit into a 32- or 64-bit int",
...@@ -615,6 +596,11 @@ pub const all_features = blk: {...@@ -615,6 +596,11 @@ pub const all_features = blk: {
615 .description = "Harden against straight line speculation across RET and BR instructions",596 .description = "Harden against straight line speculation across RET and BR instructions",
616 .dependencies = featureSet(&[_]Feature{}),597 .dependencies = featureSet(&[_]Feature{}),
617 };598 };
599 result[@enumToInt(Feature.hcx)] = .{
600 .llvm_name = "hcx",
601 .description = "Enable Armv8.7-A HCRX_EL2 system register",
602 .dependencies = featureSet(&[_]Feature{}),
603 };
618 result[@enumToInt(Feature.i8mm)] = .{604 result[@enumToInt(Feature.i8mm)] = .{
619 .llvm_name = "i8mm",605 .llvm_name = "i8mm",
620 .description = "Enable Matrix Multiply Int8 Extension",606 .description = "Enable Matrix Multiply Int8 Extension",
...@@ -632,6 +618,11 @@ pub const all_features = blk: {...@@ -632,6 +618,11 @@ pub const all_features = blk: {
632 .description = "Enables ARM v8.1 Limited Ordering Regions extension",618 .description = "Enables ARM v8.1 Limited Ordering Regions extension",
633 .dependencies = featureSet(&[_]Feature{}),619 .dependencies = featureSet(&[_]Feature{}),
634 };620 };
621 result[@enumToInt(Feature.ls64)] = .{
622 .llvm_name = "ls64",
623 .description = "Enable Armv8.7-A LD64B/ST64B Accelerator Extension",
624 .dependencies = featureSet(&[_]Feature{}),
625 };
635 result[@enumToInt(Feature.lse)] = .{626 result[@enumToInt(Feature.lse)] = .{
636 .llvm_name = "lse",627 .llvm_name = "lse",
637 .description = "Enable ARMv8.1 Large System Extension (LSE) atomic instructions",628 .description = "Enable ARMv8.1 Large System Extension (LSE) atomic instructions",
...@@ -665,9 +656,7 @@ pub const all_features = blk: {...@@ -665,9 +656,7 @@ pub const all_features = blk: {
665 .dependencies = featureSet(&[_]Feature{656 .dependencies = featureSet(&[_]Feature{
666 .crypto,657 .crypto,
667 .dotprod,658 .dotprod,
668 .fp_armv8,
669 .fullfp16,659 .fullfp16,
670 .neon,
671 .rcpc,660 .rcpc,
672 .ssbs,661 .ssbs,
673 .v8_2a,662 .v8_2a,
...@@ -679,9 +668,7 @@ pub const all_features = blk: {...@@ -679,9 +668,7 @@ pub const all_features = blk: {
679 .dependencies = featureSet(&[_]Feature{668 .dependencies = featureSet(&[_]Feature{
680 .crypto,669 .crypto,
681 .dotprod,670 .dotprod,
682 .fp_armv8,
683 .fullfp16,671 .fullfp16,
684 .neon,
685 .rcpc,672 .rcpc,
686 .spe,673 .spe,
687 .ssbs,674 .ssbs,
...@@ -696,9 +683,7 @@ pub const all_features = blk: {...@@ -696,9 +683,7 @@ pub const all_features = blk: {
696 .ete,683 .ete,
697 .i8mm,684 .i8mm,
698 .mte,685 .mte,
699 .sve2,
700 .sve2_bitperm,686 .sve2_bitperm,
701 .trbe,
702 .v8_5a,687 .v8_5a,
703 }),688 }),
704 };689 };
...@@ -709,12 +694,9 @@ pub const all_features = blk: {...@@ -709,12 +694,9 @@ pub const all_features = blk: {
709 .bf16,694 .bf16,
710 .ccdp,695 .ccdp,
711 .crypto,696 .crypto,
712 .fp_armv8,
713 .fp16fml,697 .fp16fml,
714 .fullfp16,
715 .fuse_aes,698 .fuse_aes,
716 .i8mm,699 .i8mm,
717 .neon,
718 .perfmon,700 .perfmon,
719 .rand,701 .rand,
720 .spe,702 .spe,
...@@ -731,7 +713,7 @@ pub const all_features = blk: {...@@ -731,7 +713,7 @@ pub const all_features = blk: {
731 };713 };
732 result[@enumToInt(Feature.nv)] = .{714 result[@enumToInt(Feature.nv)] = .{
733 .llvm_name = "nv",715 .llvm_name = "nv",
734 .description = "Enable v8.4-A Nested Virtualization extension",716 .description = "Enable v8.4-A Nested Virtualization Enchancement",
735 .dependencies = featureSet(&[_]Feature{}),717 .dependencies = featureSet(&[_]Feature{}),
736 };718 };
737 result[@enumToInt(Feature.outline_atomics)] = .{719 result[@enumToInt(Feature.outline_atomics)] = .{
...@@ -739,11 +721,6 @@ pub const all_features = blk: {...@@ -739,11 +721,6 @@ pub const all_features = blk: {
739 .description = "Enable out of line atomics to support LSE instructions",721 .description = "Enable out of line atomics to support LSE instructions",
740 .dependencies = featureSet(&[_]Feature{}),722 .dependencies = featureSet(&[_]Feature{}),
741 };723 };
742 result[@enumToInt(Feature.pa)] = .{
743 .llvm_name = "pa",
744 .description = "Enable v8.3-A Pointer Authentication extension",
745 .dependencies = featureSet(&[_]Feature{}),
746 };
747 result[@enumToInt(Feature.pan)] = .{724 result[@enumToInt(Feature.pan)] = .{
748 .llvm_name = "pan",725 .llvm_name = "pan",
749 .description = "Enables ARM v8.1 Privileged Access-Never extension",726 .description = "Enables ARM v8.1 Privileged Access-Never extension",
...@@ -756,6 +733,11 @@ pub const all_features = blk: {...@@ -756,6 +733,11 @@ pub const all_features = blk: {
756 .pan,733 .pan,
757 }),734 }),
758 };735 };
736 result[@enumToInt(Feature.pauth)] = .{
737 .llvm_name = "pauth",
738 .description = "Enable v8.3-A Pointer Authentication extension",
739 .dependencies = featureSet(&[_]Feature{}),
740 };
759 result[@enumToInt(Feature.perfmon)] = .{741 result[@enumToInt(Feature.perfmon)] = .{
760 .llvm_name = "perfmon",742 .llvm_name = "perfmon",
761 .description = "Enable ARMv8 PMUv3 Performance Monitors extension",743 .description = "Enable ARMv8 PMUv3 Performance Monitors extension",
...@@ -949,7 +931,6 @@ pub const all_features = blk: {...@@ -949,7 +931,6 @@ pub const all_features = blk: {
949 .llvm_name = "sha3",931 .llvm_name = "sha3",
950 .description = "Enable SHA512 and SHA3 support",932 .description = "Enable SHA512 and SHA3 support",
951 .dependencies = featureSet(&[_]Feature{933 .dependencies = featureSet(&[_]Feature{
952 .neon,
953 .sha2,934 .sha2,
954 }),935 }),
955 };936 };
...@@ -980,6 +961,11 @@ pub const all_features = blk: {...@@ -980,6 +961,11 @@ pub const all_features = blk: {
980 .description = "Enable Statistical Profiling extension",961 .description = "Enable Statistical Profiling extension",
981 .dependencies = featureSet(&[_]Feature{}),962 .dependencies = featureSet(&[_]Feature{}),
982 };963 };
964 result[@enumToInt(Feature.spe_eef)] = .{
965 .llvm_name = "spe-eef",
966 .description = "Enable extra register in the Statistical Profiling Extension",
967 .dependencies = featureSet(&[_]Feature{}),
968 };
983 result[@enumToInt(Feature.specrestrict)] = .{969 result[@enumToInt(Feature.specrestrict)] = .{
984 .llvm_name = "specrestrict",970 .llvm_name = "specrestrict",
985 .description = "Enable architectural speculation restriction",971 .description = "Enable architectural speculation restriction",
...@@ -998,7 +984,9 @@ pub const all_features = blk: {...@@ -998,7 +984,9 @@ pub const all_features = blk: {
998 result[@enumToInt(Feature.sve)] = .{984 result[@enumToInt(Feature.sve)] = .{
999 .llvm_name = "sve",985 .llvm_name = "sve",
1000 .description = "Enable Scalable Vector Extension (SVE) instructions",986 .description = "Enable Scalable Vector Extension (SVE) instructions",
1001 .dependencies = featureSet(&[_]Feature{}),987 .dependencies = featureSet(&[_]Feature{
988 .fullfp16,
989 }),
1002 };990 };
1003 result[@enumToInt(Feature.sve2)] = .{991 result[@enumToInt(Feature.sve2)] = .{
1004 .llvm_name = "sve2",992 .llvm_name = "sve2",
...@@ -1103,14 +1091,6 @@ pub const all_features = blk: {...@@ -1103,14 +1091,6 @@ pub const all_features = blk: {
1103 .description = "Use the reciprocal square root approximation",1091 .description = "Use the reciprocal square root approximation",
1104 .dependencies = featureSet(&[_]Feature{}),1092 .dependencies = featureSet(&[_]Feature{}),
1105 };1093 };
1106 result[@enumToInt(Feature.v8a)] = .{
1107 .llvm_name = null,
1108 .description = "Support ARM v8a instructions",
1109 .dependencies = featureSet(&[_]Feature{
1110 .fp_armv8,
1111 .neon,
1112 }),
1113 };
1114 result[@enumToInt(Feature.v8_1a)] = .{1094 result[@enumToInt(Feature.v8_1a)] = .{
1115 .llvm_name = "v8.1a",1095 .llvm_name = "v8.1a",
1116 .description = "Support ARM v8.1a instructions",1096 .description = "Support ARM v8.1a instructions",
...@@ -1120,8 +1100,8 @@ pub const all_features = blk: {...@@ -1120,8 +1100,8 @@ pub const all_features = blk: {
1120 .lse,1100 .lse,
1121 .pan,1101 .pan,
1122 .rdm,1102 .rdm,
1123 .vh,
1124 .v8a,1103 .v8a,
1104 .vh,
1125 }),1105 }),
1126 };1106 };
1127 result[@enumToInt(Feature.v8_2a)] = .{1107 result[@enumToInt(Feature.v8_2a)] = .{
...@@ -1142,7 +1122,7 @@ pub const all_features = blk: {...@@ -1142,7 +1122,7 @@ pub const all_features = blk: {
1142 .ccidx,1122 .ccidx,
1143 .complxnum,1123 .complxnum,
1144 .jsconv,1124 .jsconv,
1145 .pa,1125 .pauth,
1146 .rcpc,1126 .rcpc,
1147 .v8_2a,1127 .v8_2a,
1148 }),1128 }),
...@@ -1154,7 +1134,7 @@ pub const all_features = blk: {...@@ -1154,7 +1134,7 @@ pub const all_features = blk: {
1154 .am,1134 .am,
1155 .dit,1135 .dit,
1156 .dotprod,1136 .dotprod,
1157 .fmi,1137 .flagm,
1158 .mpam,1138 .mpam,
1159 .nv,1139 .nv,
1160 .pmu,1140 .pmu,
...@@ -1192,13 +1172,73 @@ pub const all_features = blk: {...@@ -1192,13 +1172,73 @@ pub const all_features = blk: {
1192 .v8_5a,1172 .v8_5a,
1193 }),1173 }),
1194 };1174 };
1175 result[@enumToInt(Feature.v8_7a)] = .{
1176 .llvm_name = "v8.7a",
1177 .description = "Support ARM v8.7a instructions",
1178 .dependencies = featureSet(&[_]Feature{
1179 .hcx,
1180 .v8_6a,
1181 .wfxt,
1182 .xs,
1183 }),
1184 };
1185 result[@enumToInt(Feature.v8a)] = .{
1186 .llvm_name = null,
1187 .description = "Support ARM v8a instructions",
1188 .dependencies = featureSet(&[_]Feature{
1189 .neon,
1190 }),
1191 };
1192 result[@enumToInt(Feature.v8r)] = .{
1193 .llvm_name = "v8r",
1194 .description = "Support ARM v8r instructions",
1195 .dependencies = featureSet(&[_]Feature{
1196 .ccidx,
1197 .ccpp,
1198 .complxnum,
1199 .contextidr_el2,
1200 .crc,
1201 .dit,
1202 .dotprod,
1203 .flagm,
1204 .fp16fml,
1205 .jsconv,
1206 .lse,
1207 .pan_rwv,
1208 .pauth,
1209 .perfmon,
1210 .predres,
1211 .ras,
1212 .rcpc_immo,
1213 .rdm,
1214 .sb,
1215 .sel2,
1216 .sha3,
1217 .sm4,
1218 .specrestrict,
1219 .ssbs,
1220 .tlb_rmi,
1221 .tracev8_4,
1222 .uaops,
1223 }),
1224 };
1195 result[@enumToInt(Feature.vh)] = .{1225 result[@enumToInt(Feature.vh)] = .{
1196 .llvm_name = "vh",1226 .llvm_name = "vh",
1197 .description = "Enables ARM v8.1 Virtual Host extension",1227 .description = "Enables ARM v8.1 Virtual Host extension",
1198 .dependencies = featureSet(&[_]Feature{1228 .dependencies = featureSet(&[_]Feature{
1199 .context_id_rel2,1229 .contextidr_el2,
1200 }),1230 }),
1201 };1231 };
1232 result[@enumToInt(Feature.wfxt)] = .{
1233 .llvm_name = "wfxt",
1234 .description = "Enable Armv8.7-A WFET and WFIT instruction",
1235 .dependencies = featureSet(&[_]Feature{}),
1236 };
1237 result[@enumToInt(Feature.xs)] = .{
1238 .llvm_name = "xs",
1239 .description = "Enable Armv8.7-A limited-TLB-maintenance instruction",
1240 .dependencies = featureSet(&[_]Feature{}),
1241 };
1202 result[@enumToInt(Feature.zcm)] = .{1242 result[@enumToInt(Feature.zcm)] = .{
1203 .llvm_name = "zcm",1243 .llvm_name = "zcm",
1204 .description = "Has zero-cycle register moves",1244 .description = "Has zero-cycle register moves",
...@@ -1240,11 +1280,11 @@ pub const cpu = struct {...@@ -1240,11 +1280,11 @@ pub const cpu = struct {
1240 .name = "a64fx",1280 .name = "a64fx",
1241 .llvm_name = "a64fx",1281 .llvm_name = "a64fx",
1242 .features = featureSet(&[_]Feature{1282 .features = featureSet(&[_]Feature{
1283 .aggressive_fma,
1284 .arith_bcc_fusion,
1243 .complxnum,1285 .complxnum,
1244 .fp_armv8,
1245 .fullfp16,
1246 .neon,
1247 .perfmon,1286 .perfmon,
1287 .predictable_select_expensive,
1248 .sha2,1288 .sha2,
1249 .sve,1289 .sve,
1250 .use_postra_scheduler,1290 .use_postra_scheduler,
...@@ -1255,14 +1295,39 @@ pub const cpu = struct {...@@ -1255,14 +1295,39 @@ pub const cpu = struct {
1255 .name = "apple_a10",1295 .name = "apple_a10",
1256 .llvm_name = "apple-a10",1296 .llvm_name = "apple-a10",
1257 .features = featureSet(&[_]Feature{1297 .features = featureSet(&[_]Feature{
1258 .apple_a10,1298 .alternate_sextload_cvt_f32_pattern,
1299 .arith_bcc_fusion,
1300 .arith_cbz_fusion,
1301 .crc,
1302 .crypto,
1303 .disable_latency_sched_heuristic,
1304 .fuse_aes,
1305 .fuse_crypto_eor,
1306 .lor,
1307 .pan,
1308 .perfmon,
1309 .rdm,
1310 .vh,
1311 .zcm,
1312 .zcz,
1259 }),1313 }),
1260 };1314 };
1261 pub const apple_a11 = CpuModel{1315 pub const apple_a11 = CpuModel{
1262 .name = "apple_a11",1316 .name = "apple_a11",
1263 .llvm_name = "apple-a11",1317 .llvm_name = "apple-a11",
1264 .features = featureSet(&[_]Feature{1318 .features = featureSet(&[_]Feature{
1265 .apple_a11,1319 .alternate_sextload_cvt_f32_pattern,
1320 .arith_bcc_fusion,
1321 .arith_cbz_fusion,
1322 .crypto,
1323 .disable_latency_sched_heuristic,
1324 .fullfp16,
1325 .fuse_aes,
1326 .fuse_crypto_eor,
1327 .perfmon,
1328 .v8_2a,
1329 .zcm,
1330 .zcz,
1266 }),1331 }),
1267 };1332 };
1268 pub const apple_a12 = CpuModel{1333 pub const apple_a12 = CpuModel{
...@@ -1279,6 +1344,37 @@ pub const cpu = struct {...@@ -1279,6 +1344,37 @@ pub const cpu = struct {
1279 .apple_a13,1344 .apple_a13,
1280 }),1345 }),
1281 };1346 };
1347 pub const apple_a14 = CpuModel{
1348 .name = "apple_a14",
1349 .llvm_name = "apple-a14",
1350 .features = featureSet(&[_]Feature{
1351 .aggressive_fma,
1352 .alternate_sextload_cvt_f32_pattern,
1353 .altnzcv,
1354 .arith_bcc_fusion,
1355 .arith_cbz_fusion,
1356 .ccdp,
1357 .crypto,
1358 .disable_latency_sched_heuristic,
1359 .fp16fml,
1360 .fptoint,
1361 .fuse_address,
1362 .fuse_aes,
1363 .fuse_arith_logic,
1364 .fuse_crypto_eor,
1365 .fuse_csel,
1366 .fuse_literals,
1367 .perfmon,
1368 .predres,
1369 .sb,
1370 .sha3,
1371 .specrestrict,
1372 .ssbs,
1373 .v8_4a,
1374 .zcm,
1375 .zcz,
1376 }),
1377 };
1282 pub const apple_a7 = CpuModel{1378 pub const apple_a7 = CpuModel{
1283 .name = "apple_a7",1379 .name = "apple_a7",
1284 .llvm_name = "apple-a7",1380 .llvm_name = "apple-a7",
...@@ -1327,7 +1423,6 @@ pub const cpu = struct {...@@ -1327,7 +1423,6 @@ pub const cpu = struct {
1327 .features = featureSet(&[_]Feature{1423 .features = featureSet(&[_]Feature{
1328 .crypto,1424 .crypto,
1329 .fullfp16,1425 .fullfp16,
1330 .neon,
1331 .v8_2a,1426 .v8_2a,
1332 }),1427 }),
1333 };1428 };
...@@ -1335,14 +1430,20 @@ pub const cpu = struct {...@@ -1335,14 +1430,20 @@ pub const cpu = struct {
1335 .name = "cortex_a34",1430 .name = "cortex_a34",
1336 .llvm_name = "cortex-a34",1431 .llvm_name = "cortex-a34",
1337 .features = featureSet(&[_]Feature{1432 .features = featureSet(&[_]Feature{
1338 .a34,1433 .crc,
1434 .crypto,
1435 .perfmon,
1436 .v8a,
1339 }),1437 }),
1340 };1438 };
1341 pub const cortex_a35 = CpuModel{1439 pub const cortex_a35 = CpuModel{
1342 .name = "cortex_a35",1440 .name = "cortex_a35",
1343 .llvm_name = "cortex-a35",1441 .llvm_name = "cortex-a35",
1344 .features = featureSet(&[_]Feature{1442 .features = featureSet(&[_]Feature{
1345 .a34,1443 .crc,
1444 .crypto,
1445 .perfmon,
1446 .v8a,
1346 }),1447 }),
1347 };1448 };
1348 pub const cortex_a53 = CpuModel{1449 pub const cortex_a53 = CpuModel{
...@@ -1410,6 +1511,7 @@ pub const cpu = struct {...@@ -1410,6 +1511,7 @@ pub const cpu = struct {
1410 .crc,1511 .crc,
1411 .crypto,1512 .crypto,
1412 .fuse_aes,1513 .fuse_aes,
1514 .fuse_literals,
1413 .perfmon,1515 .perfmon,
1414 .v8a,1516 .v8a,
1415 }),1517 }),
...@@ -1456,11 +1558,11 @@ pub const cpu = struct {...@@ -1456,11 +1558,11 @@ pub const cpu = struct {
1456 .name = "cortex_a77",1558 .name = "cortex_a77",
1457 .llvm_name = "cortex-a77",1559 .llvm_name = "cortex-a77",
1458 .features = featureSet(&[_]Feature{1560 .features = featureSet(&[_]Feature{
1561 .cmp_bcc_fusion,
1459 .crypto,1562 .crypto,
1460 .dotprod,1563 .dotprod,
1461 .fp_armv8,
1462 .fullfp16,1564 .fullfp16,
1463 .neon,1565 .fuse_aes,
1464 .rcpc,1566 .rcpc,
1465 .v8_2a,1567 .v8_2a,
1466 }),1568 }),
...@@ -1469,12 +1571,11 @@ pub const cpu = struct {...@@ -1469,12 +1571,11 @@ pub const cpu = struct {
1469 .name = "cortex_a78",1571 .name = "cortex_a78",
1470 .llvm_name = "cortex-a78",1572 .llvm_name = "cortex-a78",
1471 .features = featureSet(&[_]Feature{1573 .features = featureSet(&[_]Feature{
1574 .cmp_bcc_fusion,
1472 .crypto,1575 .crypto,
1473 .dotprod,1576 .dotprod,
1474 .fp_armv8,
1475 .fullfp16,1577 .fullfp16,
1476 .fuse_aes,1578 .fuse_aes,
1477 .neon,
1478 .perfmon,1579 .perfmon,
1479 .rcpc,1580 .rcpc,
1480 .spe,1581 .spe,
...@@ -1483,24 +1584,29 @@ pub const cpu = struct {...@@ -1483,24 +1584,29 @@ pub const cpu = struct {
1483 .v8_2a,1584 .v8_2a,
1484 }),1585 }),
1485 };1586 };
1587 pub const cortex_a78c = CpuModel{
1588 .name = "cortex_a78c",
1589 .llvm_name = "cortex-a78c",
1590 .features = featureSet(&[_]Feature{
1591 .cortex_a78c,
1592 }),
1593 };
1486 pub const cortex_r82 = CpuModel{1594 pub const cortex_r82 = CpuModel{
1487 .name = "cortex_r82",1595 .name = "cortex_r82",
1488 .llvm_name = "cortex-r82",1596 .llvm_name = "cortex-r82",
1489 .features = featureSet(&[_]Feature{1597 .features = featureSet(&[_]Feature{
1490 .use_postra_scheduler,1598 .cortex_r82,
1491 .v8r,
1492 }),1599 }),
1493 };1600 };
1494 pub const cortex_x1 = CpuModel{1601 pub const cortex_x1 = CpuModel{
1495 .name = "cortex_x1",1602 .name = "cortex_x1",
1496 .llvm_name = "cortex-x1",1603 .llvm_name = "cortex-x1",
1497 .features = featureSet(&[_]Feature{1604 .features = featureSet(&[_]Feature{
1605 .cmp_bcc_fusion,
1498 .crypto,1606 .crypto,
1499 .dotprod,1607 .dotprod,
1500 .fp_armv8,
1501 .fullfp16,1608 .fullfp16,
1502 .fuse_aes,1609 .fuse_aes,
1503 .neon,
1504 .perfmon,1610 .perfmon,
1505 .rcpc,1611 .rcpc,
1506 .spe,1612 .spe,
...@@ -1574,14 +1680,14 @@ pub const cpu = struct {...@@ -1574,14 +1680,14 @@ pub const cpu = struct {
1574 .name = "exynos_m4",1680 .name = "exynos_m4",
1575 .llvm_name = "exynos-m4",1681 .llvm_name = "exynos-m4",
1576 .features = featureSet(&[_]Feature{1682 .features = featureSet(&[_]Feature{
1577 .exynosm4,1683 .exynos_m4,
1578 }),1684 }),
1579 };1685 };
1580 pub const exynos_m5 = CpuModel{1686 pub const exynos_m5 = CpuModel{
1581 .name = "exynos_m5",1687 .name = "exynos_m5",
1582 .llvm_name = "exynos-m5",1688 .llvm_name = "exynos-m5",
1583 .features = featureSet(&[_]Feature{1689 .features = featureSet(&[_]Feature{
1584 .exynosm4,1690 .exynos_m4,
1585 }),1691 }),
1586 };1692 };
1587 pub const falkor = CpuModel{1693 pub const falkor = CpuModel{
...@@ -1607,9 +1713,9 @@ pub const cpu = struct {...@@ -1607,9 +1713,9 @@ pub const cpu = struct {
1607 .features = featureSet(&[_]Feature{1713 .features = featureSet(&[_]Feature{
1608 .ete,1714 .ete,
1609 .fuse_aes,1715 .fuse_aes,
1716 .neon,
1610 .perfmon,1717 .perfmon,
1611 .use_postra_scheduler,1718 .use_postra_scheduler,
1612 .v8a,
1613 }),1719 }),
1614 };1720 };
1615 pub const kryo = CpuModel{1721 pub const kryo = CpuModel{
...@@ -1623,8 +1729,8 @@ pub const cpu = struct {...@@ -1623,8 +1729,8 @@ pub const cpu = struct {
1623 .perfmon,1729 .perfmon,
1624 .predictable_select_expensive,1730 .predictable_select_expensive,
1625 .use_postra_scheduler,1731 .use_postra_scheduler,
1626 .zcz,
1627 .v8a,1732 .v8a,
1733 .zcz,
1628 }),1734 }),
1629 };1735 };
1630 pub const neoverse_e1 = CpuModel{1736 pub const neoverse_e1 = CpuModel{
...@@ -1688,9 +1794,7 @@ pub const cpu = struct {...@@ -1688,9 +1794,7 @@ pub const cpu = struct {
1688 .features = featureSet(&[_]Feature{1794 .features = featureSet(&[_]Feature{
1689 .aggressive_fma,1795 .aggressive_fma,
1690 .arith_bcc_fusion,1796 .arith_bcc_fusion,
1691 .crc,
1692 .crypto,1797 .crypto,
1693 .lse,
1694 .predictable_select_expensive,1798 .predictable_select_expensive,
1695 .use_postra_scheduler,1799 .use_postra_scheduler,
1696 .v8_1a,1800 .v8_1a,
...@@ -1703,12 +1807,7 @@ pub const cpu = struct {...@@ -1703,12 +1807,7 @@ pub const cpu = struct {
1703 .aggressive_fma,1807 .aggressive_fma,
1704 .arith_bcc_fusion,1808 .arith_bcc_fusion,
1705 .balance_fp_ops,1809 .balance_fp_ops,
1706 .crc,
1707 .crypto,1810 .crypto,
1708 .fp_armv8,
1709 .lse,
1710 .neon,
1711 .pa,
1712 .perfmon,1811 .perfmon,
1713 .predictable_select_expensive,1812 .predictable_select_expensive,
1714 .strict_align,1813 .strict_align,
...@@ -1761,7 +1860,6 @@ pub const cpu = struct {...@@ -1761,7 +1860,6 @@ pub const cpu = struct {
1761 .custom_cheap_as_move,1860 .custom_cheap_as_move,
1762 .dotprod,1861 .dotprod,
1763 .fp16fml,1862 .fp16fml,
1764 .fullfp16,
1765 .fuse_aes,1863 .fuse_aes,
1766 .perfmon,1864 .perfmon,
1767 .spe,1865 .spe,
tools/update_cpu_features.zig+212-18
...@@ -8,7 +8,11 @@ const assert = std.debug.assert;...@@ -8,7 +8,11 @@ const assert = std.debug.assert;
88
9const FeatureOverride = struct {9const FeatureOverride = struct {
10 llvm_name: []const u8,10 llvm_name: []const u8,
11 /// If true, completely omit the feature; as if it does not exist.
11 omit: bool = false,12 omit: bool = false,
13 /// If true, omit the feature, but all the dependencies of the feature
14 /// are added in its place.
15 flatten: bool = false,
12 zig_name: ?[]const u8 = null,16 zig_name: ?[]const u8 = null,
13 desc: ?[]const u8 = null,17 desc: ?[]const u8 = null,
14 extra_deps: []const []const u8 = &.{},18 extra_deps: []const []const u8 = &.{},
...@@ -25,6 +29,7 @@ const Feature = struct {...@@ -25,6 +29,7 @@ const Feature = struct {
25 zig_name: []const u8,29 zig_name: []const u8,
26 desc: []const u8,30 desc: []const u8,
27 deps: []const []const u8,31 deps: []const []const u8,
32 flatten: bool = false,
28};33};
2934
30const LlvmTarget = struct {35const LlvmTarget = struct {
...@@ -68,6 +73,8 @@ const llvm_targets = [_]LlvmTarget{...@@ -68,6 +73,8 @@ const llvm_targets = [_]LlvmTarget{
68 .{73 .{
69 .llvm_name = "exynosm3",74 .llvm_name = "exynosm3",
70 .zig_name = "exynos_m3",75 .zig_name = "exynos_m3",
76 .flatten = true,
77 .extra_deps = &.{"v8a"},
71 },78 },
72 .{79 .{
73 .llvm_name = "exynosm4",80 .llvm_name = "exynosm4",
...@@ -77,6 +84,117 @@ const llvm_targets = [_]LlvmTarget{...@@ -77,6 +84,117 @@ const llvm_targets = [_]LlvmTarget{
77 .llvm_name = "v8.1a",84 .llvm_name = "v8.1a",
78 .extra_deps = &.{"v8a"},85 .extra_deps = &.{"v8a"},
79 },86 },
87 .{
88 .llvm_name = "a35",
89 .flatten = true,
90 .extra_deps = &.{"v8a"},
91 },
92 .{
93 .llvm_name = "a53",
94 .flatten = true,
95 .extra_deps = &.{"v8a"},
96 },
97 .{
98 .llvm_name = "a55",
99 .flatten = true,
100 },
101 .{
102 .llvm_name = "a57",
103 .flatten = true,
104 .extra_deps = &.{"v8a"},
105 },
106 .{
107 .llvm_name = "a64fx",
108 .flatten = true,
109 },
110 .{
111 .llvm_name = "a72",
112 .flatten = true,
113 .extra_deps = &.{"v8a"},
114 },
115 .{
116 .llvm_name = "a73",
117 .flatten = true,
118 .extra_deps = &.{"v8a"},
119 },
120 .{
121 .llvm_name = "a75",
122 .flatten = true,
123 },
124 .{
125 .llvm_name = "a77",
126 .flatten = true,
127 },
128 .{
129 .llvm_name = "apple-a10",
130 .flatten = true,
131 },
132 .{
133 .llvm_name = "apple-a11",
134 .flatten = true,
135 },
136 .{
137 .llvm_name = "apple-a14",
138 .flatten = true,
139 },
140 .{
141 .llvm_name = "carmel",
142 .flatten = true,
143 },
144 .{
145 .llvm_name = "cortex-a78",
146 .flatten = true,
147 },
148 .{
149 .llvm_name = "cortex-x1",
150 .flatten = true,
151 },
152 .{
153 .llvm_name = "falkor",
154 .flatten = true,
155 .extra_deps = &.{"v8a"},
156 },
157 .{
158 .llvm_name = "kryo",
159 .flatten = true,
160 .extra_deps = &.{"v8a"},
161 },
162 .{
163 .llvm_name = "saphira",
164 .flatten = true,
165 },
166 .{
167 .llvm_name = "thunderx",
168 .flatten = true,
169 .extra_deps = &.{"v8a"},
170 },
171 .{
172 .llvm_name = "thunderx2t99",
173 .flatten = true,
174 },
175 .{
176 .llvm_name = "thunderx3t110",
177 .flatten = true,
178 },
179 .{
180 .llvm_name = "thunderxt81",
181 .flatten = true,
182 .extra_deps = &.{"v8a"},
183 },
184 .{
185 .llvm_name = "thunderxt83",
186 .flatten = true,
187 .extra_deps = &.{"v8a"},
188 },
189 .{
190 .llvm_name = "thunderxt88",
191 .flatten = true,
192 .extra_deps = &.{"v8a"},
193 },
194 .{
195 .llvm_name = "tsv110",
196 .flatten = true,
197 },
80 },198 },
81 .extra_features = &.{199 .extra_features = &.{
82 .{200 .{
...@@ -85,6 +203,43 @@ const llvm_targets = [_]LlvmTarget{...@@ -85,6 +203,43 @@ const llvm_targets = [_]LlvmTarget{
85 .deps = &.{ "fp_armv8", "neon" },203 .deps = &.{ "fp_armv8", "neon" },
86 },204 },
87 },205 },
206 .extra_cpus = &.{
207 .{
208 .llvm_name = null,
209 .zig_name = "exynos_m1",
210 .features = &.{
211 "crc",
212 "crypto",
213 "exynos_cheap_as_move",
214 "force_32bit_jump_tables",
215 "fuse_aes",
216 "perfmon",
217 "slow_misaligned_128store",
218 "slow_paired_128",
219 "use_postra_scheduler",
220 "use_reciprocal_square_root",
221 "v8a",
222 "zcz_fp",
223 },
224 },
225 .{
226 .llvm_name = null,
227 .zig_name = "exynos_m2",
228 .features = &.{
229 "crc",
230 "crypto",
231 "exynos_cheap_as_move",
232 "force_32bit_jump_tables",
233 "fuse_aes",
234 "perfmon",
235 "slow_misaligned_128store",
236 "slow_paired_128",
237 "use_postra_scheduler",
238 "v8a",
239 "zcz_fp",
240 },
241 },
242 },
88 },243 },
89 .{244 .{
90 .zig_name = "amdgpu",245 .zig_name = "amdgpu",
...@@ -374,22 +529,32 @@ fn processOneTarget(job: Job) anyerror!void {...@@ -374,22 +529,32 @@ fn processOneTarget(job: Job) anyerror!void {
374 const llvm_name = kv.value.Object.get("Name").?.String;529 const llvm_name = kv.value.Object.get("Name").?.String;
375 if (llvm_name.len == 0) continue;530 if (llvm_name.len == 0) continue;
376531
377 var zig_name = (try llvmNameToZigName(arena, llvm_target, llvm_name)) orelse532 var zig_name = try llvmNameToZigName(arena, llvm_name);
378 continue :root_it;
379 var desc = kv.value.Object.get("Desc").?.String;533 var desc = kv.value.Object.get("Desc").?.String;
380 var deps = std.ArrayList([]const u8).init(arena);534 var deps = std.ArrayList([]const u8).init(arena);
535 var omit = false;
536 var flatten = false;
381 const implies = kv.value.Object.get("Implies").?.Array;537 const implies = kv.value.Object.get("Implies").?.Array;
382 for (implies.items) |imply| {538 for (implies.items) |imply| {
383 const other_key = imply.Object.get("def").?.String;539 const other_key = imply.Object.get("def").?.String;
384 const other_obj = &root_map.getEntry(other_key).?.value.Object;540 const other_obj = &root_map.getEntry(other_key).?.value.Object;
385 const other_llvm_name = other_obj.get("Name").?.String;541 const other_llvm_name = other_obj.get("Name").?.String;
386 const other_zig_name = (try llvmNameToZigName(arena, llvm_target, other_llvm_name)) orelse continue;542 const other_zig_name = (try llvmNameToZigNameOmit(
543 arena,
544 llvm_target,
545 other_llvm_name,
546 )) orelse continue;
387 try deps.append(other_zig_name);547 try deps.append(other_zig_name);
388 }548 }
389 for (llvm_target.feature_overrides) |feature_override| {549 for (llvm_target.feature_overrides) |feature_override| {
390 if (mem.eql(u8, llvm_name, feature_override.llvm_name)) {550 if (mem.eql(u8, llvm_name, feature_override.llvm_name)) {
391 if (feature_override.omit) {551 if (feature_override.omit) {
392 continue :root_it;552 // Still put the feature into the table so that we can
553 // expand dependencies for the feature overrides marked `flatten`.
554 omit = true;
555 }
556 if (feature_override.flatten) {
557 flatten = true;
393 }558 }
394 if (feature_override.zig_name) |override_name| {559 if (feature_override.zig_name) |override_name| {
395 zig_name = override_name;560 zig_name = override_name;
...@@ -408,16 +573,18 @@ fn processOneTarget(job: Job) anyerror!void {...@@ -408,16 +573,18 @@ fn processOneTarget(job: Job) anyerror!void {
408 .zig_name = zig_name,573 .zig_name = zig_name,
409 .desc = desc,574 .desc = desc,
410 .deps = deps.items,575 .deps = deps.items,
576 .flatten = flatten,
411 };577 };
412 try features_table.put(zig_name, feature);578 try features_table.put(zig_name, feature);
413 try all_features.append(feature);579 if (!omit and !flatten) {
580 try all_features.append(feature);
581 }
414 }582 }
415 if (hasSuperclass(&kv.value.Object, "Processor")) {583 if (hasSuperclass(&kv.value.Object, "Processor")) {
416 const llvm_name = kv.value.Object.get("Name").?.String;584 const llvm_name = kv.value.Object.get("Name").?.String;
417 if (llvm_name.len == 0) continue;585 if (llvm_name.len == 0) continue;
418586
419 var zig_name = (try llvmNameToZigName(arena, llvm_target, llvm_name)) orelse587 var zig_name = try llvmNameToZigName(arena, llvm_name);
420 continue :root_it;
421 var deps = std.ArrayList([]const u8).init(arena);588 var deps = std.ArrayList([]const u8).init(arena);
422 const features = kv.value.Object.get("Features").?.Array;589 const features = kv.value.Object.get("Features").?.Array;
423 for (features.items) |feature| {590 for (features.items) |feature| {
...@@ -425,7 +592,11 @@ fn processOneTarget(job: Job) anyerror!void {...@@ -425,7 +592,11 @@ fn processOneTarget(job: Job) anyerror!void {
425 const feature_obj = &root_map.getEntry(feature_key).?.value.Object;592 const feature_obj = &root_map.getEntry(feature_key).?.value.Object;
426 const feature_llvm_name = feature_obj.get("Name").?.String;593 const feature_llvm_name = feature_obj.get("Name").?.String;
427 if (feature_llvm_name.len == 0) continue;594 if (feature_llvm_name.len == 0) continue;
428 const feature_zig_name = (try llvmNameToZigName(arena, llvm_target, feature_llvm_name)) orelse continue;595 const feature_zig_name = (try llvmNameToZigNameOmit(
596 arena,
597 llvm_target,
598 feature_llvm_name,
599 )) orelse continue;
429 try deps.append(feature_zig_name);600 try deps.append(feature_zig_name);
430 }601 }
431 const tune_features = kv.value.Object.get("TuneFeatures").?.Array;602 const tune_features = kv.value.Object.get("TuneFeatures").?.Array;
...@@ -434,7 +605,11 @@ fn processOneTarget(job: Job) anyerror!void {...@@ -434,7 +605,11 @@ fn processOneTarget(job: Job) anyerror!void {
434 const feature_obj = &root_map.getEntry(feature_key).?.value.Object;605 const feature_obj = &root_map.getEntry(feature_key).?.value.Object;
435 const feature_llvm_name = feature_obj.get("Name").?.String;606 const feature_llvm_name = feature_obj.get("Name").?.String;
436 if (feature_llvm_name.len == 0) continue;607 if (feature_llvm_name.len == 0) continue;
437 const feature_zig_name = (try llvmNameToZigName(arena, llvm_target, feature_llvm_name)) orelse continue;608 const feature_zig_name = (try llvmNameToZigNameOmit(
609 arena,
610 llvm_target,
611 feature_llvm_name,
612 )) orelse continue;
438 try deps.append(feature_zig_name);613 try deps.append(feature_zig_name);
439 }614 }
440 for (llvm_target.feature_overrides) |feature_override| {615 for (llvm_target.feature_overrides) |feature_override| {
...@@ -549,7 +724,7 @@ fn processOneTarget(job: Job) anyerror!void {...@@ -549,7 +724,7 @@ fn processOneTarget(job: Job) anyerror!void {
549 }724 }
550 var deps_set = std.StringHashMap(void).init(arena);725 var deps_set = std.StringHashMap(void).init(arena);
551 for (feature.deps) |dep| {726 for (feature.deps) |dep| {
552 try deps_set.put(dep, {});727 try putDep(&deps_set, features_table, dep);
553 }728 }
554 try pruneFeatures(arena, features_table, &deps_set);729 try pruneFeatures(arena, features_table, &deps_set);
555 var dependencies = std.ArrayList([]const u8).init(arena);730 var dependencies = std.ArrayList([]const u8).init(arena);
...@@ -594,7 +769,7 @@ fn processOneTarget(job: Job) anyerror!void {...@@ -594,7 +769,7 @@ fn processOneTarget(job: Job) anyerror!void {
594 for (all_cpus.items) |cpu| {769 for (all_cpus.items) |cpu| {
595 var deps_set = std.StringHashMap(void).init(arena);770 var deps_set = std.StringHashMap(void).init(arena);
596 for (cpu.features) |feature_zig_name| {771 for (cpu.features) |feature_zig_name| {
597 try deps_set.put(feature_zig_name, {});772 try putDep(&deps_set, features_table, feature_zig_name);
598 }773 }
599 try pruneFeatures(arena, features_table, &deps_set);774 try pruneFeatures(arena, features_table, &deps_set);
600 var cpu_features = std.ArrayList([]const u8).init(arena);775 var cpu_features = std.ArrayList([]const u8).init(arena);
...@@ -679,7 +854,16 @@ fn asciiLessThan(context: void, a: []const u8, b: []const u8) bool {...@@ -679,7 +854,16 @@ fn asciiLessThan(context: void, a: []const u8, b: []const u8) bool {
679 return std.ascii.lessThanIgnoreCase(a, b);854 return std.ascii.lessThanIgnoreCase(a, b);
680}855}
681856
682fn llvmNameToZigName(857fn llvmNameToZigName(arena: *mem.Allocator, llvm_name: []const u8) ![]const u8 {
858 const duped = try arena.dupe(u8, llvm_name);
859 for (duped) |*byte| switch (byte.*) {
860 '-', '.' => byte.* = '_',
861 else => continue,
862 };
863 return duped;
864}
865
866fn llvmNameToZigNameOmit(
683 arena: *mem.Allocator,867 arena: *mem.Allocator,
684 llvm_target: LlvmTarget,868 llvm_target: LlvmTarget,
685 llvm_name: []const u8,869 llvm_name: []const u8,
...@@ -690,12 +874,7 @@ fn llvmNameToZigName(...@@ -690,12 +874,7 @@ fn llvmNameToZigName(
690 return feature_override.zig_name orelse break;874 return feature_override.zig_name orelse break;
691 }875 }
692 }876 }
693 const duped = try arena.dupe(u8, llvm_name);877 return try llvmNameToZigName(arena, llvm_name);
694 for (duped) |*byte| switch (byte.*) {
695 '-', '.' => byte.* = '_',
696 else => continue,
697 };
698 return duped;
699}878}
700879
701fn hasSuperclass(obj: *json.ObjectMap, class_name: []const u8) bool {880fn hasSuperclass(obj: *json.ObjectMap, class_name: []const u8) bool {
...@@ -744,3 +923,18 @@ fn walkFeatures(...@@ -744,3 +923,18 @@ fn walkFeatures(
744 try walkFeatures(features_table, deletion_set, other_feature);923 try walkFeatures(features_table, deletion_set, other_feature);
745 }924 }
746}925}
926
927fn putDep(
928 deps_set: *std.StringHashMap(void),
929 features_table: std.StringHashMap(Feature),
930 zig_feature_name: []const u8,
931) error{OutOfMemory}!void {
932 const feature = features_table.get(zig_feature_name).?;
933 if (feature.flatten) {
934 for (feature.deps) |dep| {
935 try putDep(deps_set, features_table, dep);
936 }
937 } else {
938 try deps_set.put(zig_feature_name, {});
939 }
940}