| author | |
| committer | |
| log | cb1ac0bb2fb95424118404160704d53a3ff2a2c0 |
| tree | b4d5593706a2030c025cd76be5fab12951ab2a72 |
| parent | 3b465ebec59ee942b6c490ada2f81902ec047d7f |
| signature |
At bare minimum, the compiler expects std.Target.<arch>.cpu.generic to work for
any given architecture when generating the builtin module. So rather than try to
hack that into working when the affected modules are omitted, just actually keep
them.
This affected lanai and xcore.4 files changed, 86 insertions(+), 9 deletions(-)
lib/std/Target.zig+8| ... | ... | @@ -633,6 +633,7 @@ pub const avr = @import("Target/avr.zig"); |
| 633 | 633 | pub const bpf = @import("Target/bpf.zig"); |
| 634 | 634 | pub const csky = @import("Target/csky.zig"); |
| 635 | 635 | pub const hexagon = @import("Target/hexagon.zig"); |
| 636 | pub const lanai = @import("Target/lanai.zig"); | |
| 636 | 637 | pub const loongarch = @import("Target/loongarch.zig"); |
| 637 | 638 | pub const m68k = @import("Target/m68k.zig"); |
| 638 | 639 | pub const mips = @import("Target/mips.zig"); |
| ... | ... | @@ -646,6 +647,7 @@ pub const s390x = @import("Target/s390x.zig"); |
| 646 | 647 | pub const ve = @import("Target/ve.zig"); |
| 647 | 648 | pub const wasm = @import("Target/wasm.zig"); |
| 648 | 649 | pub const x86 = @import("Target/x86.zig"); |
| 650 | pub const xcore = @import("Target/xcore.zig"); | |
| 649 | 651 | pub const xtensa = @import("Target/xtensa.zig"); |
| 650 | 652 | |
| 651 | 653 | pub const Abi = enum { |
| ... | ... | @@ -1410,6 +1412,7 @@ pub const Cpu = struct { |
| 1410 | 1412 | .bpfel, .bpfeb => &bpf.all_features, |
| 1411 | 1413 | .csky => &csky.all_features, |
| 1412 | 1414 | .hexagon => &hexagon.all_features, |
| 1415 | .lanai => &lanai.all_features, | |
| 1413 | 1416 | .loongarch32, .loongarch64 => &loongarch.all_features, |
| 1414 | 1417 | .m68k => &m68k.all_features, |
| 1415 | 1418 | .mips, .mipsel, .mips64, .mips64el => &mips.all_features, |
| ... | ... | @@ -1421,6 +1424,7 @@ pub const Cpu = struct { |
| 1421 | 1424 | .spirv, .spirv32, .spirv64 => &spirv.all_features, |
| 1422 | 1425 | .s390x => &s390x.all_features, |
| 1423 | 1426 | .x86, .x86_64 => &x86.all_features, |
| 1427 | .xcore => &xcore.all_features, | |
| 1424 | 1428 | .xtensa => &xtensa.all_features, |
| 1425 | 1429 | .nvptx, .nvptx64 => &nvptx.all_features, |
| 1426 | 1430 | .ve => &ve.all_features, |
| ... | ... | @@ -1440,6 +1444,7 @@ pub const Cpu = struct { |
| 1440 | 1444 | .bpfel, .bpfeb => comptime allCpusFromDecls(bpf.cpu), |
| 1441 | 1445 | .csky => comptime allCpusFromDecls(csky.cpu), |
| 1442 | 1446 | .hexagon => comptime allCpusFromDecls(hexagon.cpu), |
| 1447 | .lanai => comptime allCpusFromDecls(lanai.cpu), | |
| 1443 | 1448 | .loongarch32, .loongarch64 => comptime allCpusFromDecls(loongarch.cpu), |
| 1444 | 1449 | .m68k => comptime allCpusFromDecls(m68k.cpu), |
| 1445 | 1450 | .mips, .mipsel, .mips64, .mips64el => comptime allCpusFromDecls(mips.cpu), |
| ... | ... | @@ -1451,6 +1456,7 @@ pub const Cpu = struct { |
| 1451 | 1456 | .spirv, .spirv32, .spirv64 => comptime allCpusFromDecls(spirv.cpu), |
| 1452 | 1457 | .s390x => comptime allCpusFromDecls(s390x.cpu), |
| 1453 | 1458 | .x86, .x86_64 => comptime allCpusFromDecls(x86.cpu), |
| 1459 | .xcore => comptime allCpusFromDecls(xcore.cpu), | |
| 1454 | 1460 | .xtensa => comptime allCpusFromDecls(xtensa.cpu), |
| 1455 | 1461 | .nvptx, .nvptx64 => comptime allCpusFromDecls(nvptx.cpu), |
| 1456 | 1462 | .ve => comptime allCpusFromDecls(ve.cpu), |
| ... | ... | @@ -1525,6 +1531,7 @@ pub const Cpu = struct { |
| 1525 | 1531 | .avr => &avr.cpu.avr2, |
| 1526 | 1532 | .bpfel, .bpfeb => &bpf.cpu.generic, |
| 1527 | 1533 | .hexagon => &hexagon.cpu.generic, |
| 1534 | .lanai => &lanai.cpu.generic, | |
| 1528 | 1535 | .loongarch32 => &loongarch.cpu.generic_la32, |
| 1529 | 1536 | .loongarch64 => &loongarch.cpu.generic_la64, |
| 1530 | 1537 | .m68k => &m68k.cpu.generic, |
| ... | ... | @@ -1547,6 +1554,7 @@ pub const Cpu = struct { |
| 1547 | 1554 | .nvptx, .nvptx64 => &nvptx.cpu.sm_20, |
| 1548 | 1555 | .ve => &ve.cpu.generic, |
| 1549 | 1556 | .wasm32, .wasm64 => &wasm.cpu.generic, |
| 1557 | .xcore => &xcore.cpu.generic, | |
| 1550 | 1558 | |
| 1551 | 1559 | else => &S.generic_model, |
| 1552 | 1560 | }; |
lib/std/Target/lanai.zig created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | //! This file is auto-generated by tools/update_cpu_features.zig. | |
| 2 | ||
| 3 | const std = @import("../std.zig"); | |
| 4 | const CpuFeature = std.Target.Cpu.Feature; | |
| 5 | const CpuModel = std.Target.Cpu.Model; | |
| 6 | ||
| 7 | pub const Feature = enum {}; | |
| 8 | ||
| 9 | pub const featureSet = CpuFeature.FeatureSetFns(Feature).featureSet; | |
| 10 | pub const featureSetHas = CpuFeature.FeatureSetFns(Feature).featureSetHas; | |
| 11 | pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; | |
| 12 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; | |
| 13 | ||
| 14 | pub const all_features = blk: { | |
| 15 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 16 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); | |
| 17 | var result: [len]CpuFeature = undefined; | |
| 18 | const ti = @typeInfo(Feature); | |
| 19 | for (&result, 0..) |*elem, i| { | |
| 20 | elem.index = i; | |
| 21 | elem.name = ti.@"enum".fields[i].name; | |
| 22 | } | |
| 23 | break :blk result; | |
| 24 | }; | |
| 25 | ||
| 26 | pub const cpu = struct { | |
| 27 | pub const generic = CpuModel{ | |
| 28 | .name = "generic", | |
| 29 | .llvm_name = "generic", | |
| 30 | .features = featureSet(&[_]Feature{}), | |
| 31 | }; | |
| 32 | pub const v11 = CpuModel{ | |
| 33 | .name = "v11", | |
| 34 | .llvm_name = "v11", | |
| 35 | .features = featureSet(&[_]Feature{}), | |
| 36 | }; | |
| 37 | }; |
lib/std/Target/xcore.zig created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | //! This file is auto-generated by tools/update_cpu_features.zig. | |
| 2 | ||
| 3 | const std = @import("../std.zig"); | |
| 4 | const CpuFeature = std.Target.Cpu.Feature; | |
| 5 | const CpuModel = std.Target.Cpu.Model; | |
| 6 | ||
| 7 | pub const Feature = enum {}; | |
| 8 | ||
| 9 | pub const featureSet = CpuFeature.FeatureSetFns(Feature).featureSet; | |
| 10 | pub const featureSetHas = CpuFeature.FeatureSetFns(Feature).featureSetHas; | |
| 11 | pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny; | |
| 12 | pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll; | |
| 13 | ||
| 14 | pub const all_features = blk: { | |
| 15 | const len = @typeInfo(Feature).@"enum".fields.len; | |
| 16 | std.debug.assert(len <= CpuFeature.Set.needed_bit_count); | |
| 17 | var result: [len]CpuFeature = undefined; | |
| 18 | const ti = @typeInfo(Feature); | |
| 19 | for (&result, 0..) |*elem, i| { | |
| 20 | elem.index = i; | |
| 21 | elem.name = ti.@"enum".fields[i].name; | |
| 22 | } | |
| 23 | break :blk result; | |
| 24 | }; | |
| 25 | ||
| 26 | pub const cpu = struct { | |
| 27 | pub const generic = CpuModel{ | |
| 28 | .name = "generic", | |
| 29 | .llvm_name = "generic", | |
| 30 | .features = featureSet(&[_]Feature{}), | |
| 31 | }; | |
| 32 | pub const xs1b_generic = CpuModel{ | |
| 33 | .name = "xs1b_generic", | |
| 34 | .llvm_name = "xs1b-generic", | |
| 35 | .features = featureSet(&[_]Feature{}), | |
| 36 | }; | |
| 37 | }; |
tools/update_cpu_features.zig+4-9| ... | ... | @@ -1563,12 +1563,6 @@ fn processOneTarget(job: Job) anyerror!void { |
| 1563 | 1563 | |
| 1564 | 1564 | const zig_code_basename = try std.fmt.allocPrint(arena, "{s}.zig", .{llvm_target.zig_name}); |
| 1565 | 1565 | |
| 1566 | if (all_features.items.len == 0) { | |
| 1567 | // We represent this with an empty file. | |
| 1568 | try target_dir.deleteTree(zig_code_basename); | |
| 1569 | return; | |
| 1570 | } | |
| 1571 | ||
| 1572 | 1566 | var zig_code_file = try target_dir.createFile(zig_code_basename, .{}); |
| 1573 | 1567 | defer zig_code_file.close(); |
| 1574 | 1568 | |
| ... | ... | @@ -1583,11 +1577,12 @@ fn processOneTarget(job: Job) anyerror!void { |
| 1583 | 1577 | \\const CpuModel = std.Target.Cpu.Model; |
| 1584 | 1578 | \\ |
| 1585 | 1579 | \\pub const Feature = enum { |
| 1586 | \\ | |
| 1587 | 1580 | ); |
| 1588 | 1581 | |
| 1589 | for (all_features.items) |feature| { | |
| 1590 | try w.print(" {p},\n", .{std.zig.fmtId(feature.zig_name)}); | |
| 1582 | for (all_features.items, 0..) |feature, i| { | |
| 1583 | try w.print("\n {p},", .{std.zig.fmtId(feature.zig_name)}); | |
| 1584 | ||
| 1585 | if (i == all_features.items.len - 1) try w.writeAll("\n"); | |
| 1591 | 1586 | } |
| 1592 | 1587 | |
| 1593 | 1588 | try w.writeAll( |