authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-11 16:41:20-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-09-19 09:37:31-07:00
log62a12e06315ce4c2eaadfc33bf32eb4af9417ba8
tree292516689088d985bb014be0a93b8f6fc1913f54
parent1861036f3b61828d0b7641dcce65f37e516fd3f6

LLVM 17 std lib updates and fixes

* some manual fixes to generated CPU features code. in the future it would be nice to make the script do those automatically. I suspect the sm_90a thing is a bug in LLVM. * add liteos to various target OS switches. I know nothing about this OS; someone will need to work specifically on support for this OS when the time comes to support it properly in zig. * while waiting for the compiler, I went ahead and made more conservative choices about when to use `inline` in std/Target.zig

7 files changed, 86 insertions(+), 20 deletions(-)

lib/std/target.zig+18-13
......@@ -260,6 +260,7 @@ pub const Target = struct {
260260 .emscripten,
261261 .driverkit,
262262 .shadermodel,
263 .liteos,
263264 .uefi,
264265 .opencl, // TODO: OpenCL versions
265266 .glsl450, // TODO: GLSL versions
......@@ -396,7 +397,7 @@ pub const Target = struct {
396397 /// On Darwin, we always link libSystem which contains libc.
397398 /// Similarly on FreeBSD and NetBSD we always link system libc
398399 /// since this is the stable syscall interface.
399 pub inline fn requiresLibC(os: Os) bool {
400 pub fn requiresLibC(os: Os) bool {
400401 return switch (os.tag) {
401402 .freebsd,
402403 .netbsd,
......@@ -438,6 +439,7 @@ pub const Target = struct {
438439 .emscripten,
439440 .driverkit,
440441 .shadermodel,
442 .liteos,
441443 .uefi,
442444 .opencl,
443445 .glsl450,
......@@ -566,6 +568,7 @@ pub const Target = struct {
566568 .watchos,
567569 .driverkit,
568570 .shadermodel,
571 .liteos, // TODO: audit this
569572 => return .none,
570573 }
571574 }
......@@ -976,7 +979,7 @@ pub const Target = struct {
976979 return error.UnknownCpuModel;
977980 }
978981
979 pub inline fn toElfMachine(arch: Arch) std.elf.EM {
982 pub fn toElfMachine(arch: Arch) std.elf.EM {
980983 return switch (arch) {
981984 .avr => .AVR,
982985 .msp430 => .MSP430,
......@@ -1041,7 +1044,7 @@ pub const Target = struct {
10411044 };
10421045 }
10431046
1044 pub inline fn toCoffMachine(arch: Arch) std.coff.MachineType {
1047 pub fn toCoffMachine(arch: Arch) std.coff.MachineType {
10451048 return switch (arch) {
10461049 .avr => .Unknown,
10471050 .msp430 => .Unknown,
......@@ -1106,7 +1109,7 @@ pub const Target = struct {
11061109 };
11071110 }
11081111
1109 pub inline fn endian(arch: Arch) std.builtin.Endian {
1112 pub fn endian(arch: Arch) std.builtin.Endian {
11101113 return switch (arch) {
11111114 .avr,
11121115 .arm,
......@@ -1177,7 +1180,7 @@ pub const Target = struct {
11771180 }
11781181
11791182 /// Returns whether this architecture supports the address space
1180 pub inline fn supportsAddressSpace(arch: Arch, address_space: std.builtin.AddressSpace) bool {
1183 pub fn supportsAddressSpace(arch: Arch, address_space: std.builtin.AddressSpace) bool {
11811184 const is_nvptx = arch == .nvptx or arch == .nvptx64;
11821185 const is_spirv = arch == .spirv32 or arch == .spirv64;
11831186 const is_gpu = is_nvptx or is_spirv or arch == .amdgcn;
......@@ -1715,6 +1718,7 @@ pub const Target = struct {
17151718 .hurd,
17161719 .driverkit,
17171720 .shadermodel,
1721 .liteos,
17181722 => return result,
17191723 }
17201724 }
......@@ -1743,7 +1747,7 @@ pub const Target = struct {
17431747 };
17441748 }
17451749
1746 pub inline fn maxIntAlignment(target: Target) u16 {
1750 pub fn maxIntAlignment(target: Target) u16 {
17471751 return switch (target.cpu.arch) {
17481752 .avr => 1,
17491753 .msp430 => 2,
......@@ -1833,7 +1837,7 @@ pub const Target = struct {
18331837 };
18341838 }
18351839
1836 pub inline fn ptrBitWidth(target: Target) u16 {
1840 pub fn ptrBitWidth(target: Target) u16 {
18371841 switch (target.abi) {
18381842 .gnux32, .muslx32, .gnuabin32, .gnuilp32 => return 32,
18391843 .gnuabi64 => return 64,
......@@ -1910,7 +1914,7 @@ pub const Target = struct {
19101914 }
19111915 }
19121916
1913 pub inline fn stackAlignment(target: Target) u16 {
1917 pub fn stackAlignment(target: Target) u16 {
19141918 return switch (target.cpu.arch) {
19151919 .m68k => 2,
19161920 .amdgcn => 4,
......@@ -1955,7 +1959,7 @@ pub const Target = struct {
19551959 /// Default signedness of `char` for the native C compiler for this target
19561960 /// Note that char signedness is implementation-defined and many compilers provide
19571961 /// an option to override the default signedness e.g. GCC's -funsigned-char / -fsigned-char
1958 pub inline fn charSignedness(target: Target) std.builtin.Signedness {
1962 pub fn charSignedness(target: Target) std.builtin.Signedness {
19591963 switch (target.cpu.arch) {
19601964 .aarch64,
19611965 .aarch64_32,
......@@ -1994,7 +1998,7 @@ pub const Target = struct {
19941998 longdouble,
19951999 };
19962000
1997 pub inline fn c_type_byte_size(t: Target, c_type: CType) u16 {
2001 pub fn c_type_byte_size(t: Target, c_type: CType) u16 {
19982002 return switch (c_type) {
19992003 .char,
20002004 .short,
......@@ -2020,7 +2024,7 @@ pub const Target = struct {
20202024 };
20212025 }
20222026
2023 pub inline fn c_type_bit_size(target: Target, c_type: CType) u16 {
2027 pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
20242028 switch (target.os.tag) {
20252029 .freestanding, .other => switch (target.cpu.arch) {
20262030 .msp430 => switch (c_type) {
......@@ -2330,11 +2334,12 @@ pub const Target = struct {
23302334 .vulkan,
23312335 .driverkit,
23322336 .shadermodel,
2337 .liteos,
23332338 => @panic("TODO specify the C integer and float type sizes for this OS"),
23342339 }
23352340 }
23362341
2337 pub inline fn c_type_alignment(target: Target, c_type: CType) u16 {
2342 pub fn c_type_alignment(target: Target, c_type: CType) u16 {
23382343 // Overrides for unusual alignments
23392344 switch (target.cpu.arch) {
23402345 .avr => return 1,
......@@ -2441,7 +2446,7 @@ pub const Target = struct {
24412446 );
24422447 }
24432448
2444 pub inline fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
2449 pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
24452450 // Overrides for unusual alignments
24462451 switch (target.cpu.arch) {
24472452 .arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) {
lib/std/target/csky.zig+1-1
......@@ -3079,7 +3079,7 @@ pub const cpu = struct {
30793079 .btst16,
30803080 }),
30813081 };
3082 pub const i805 = CpuModel{
3082 pub const @"i805" = CpuModel{
30833083 .name = "i805",
30843084 .llvm_name = "i805",
30853085 .features = featureSet(&[_]Feature{
lib/std/target/nvptx.zig+5-5
......@@ -47,7 +47,7 @@ pub const Feature = enum {
4747 sm_87,
4848 sm_89,
4949 sm_90,
50 sm_90,
50 sm_90a,
5151};
5252
5353pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
......@@ -269,9 +269,9 @@ pub const all_features = blk: {
269269 .description = "Target SM 90",
270270 .dependencies = featureSet(&[_]Feature{}),
271271 };
272 result[@intFromEnum(Feature.sm_90)] = .{
273 .llvm_name = "sm_90",
274 .description = "Target SM 90",
272 result[@intFromEnum(Feature.sm_90a)] = .{
273 .llvm_name = "sm_90a",
274 .description = "Target SM 90a",
275275 .dependencies = featureSet(&[_]Feature{}),
276276 };
277277 const ti = @typeInfo(Feature);
......@@ -447,7 +447,7 @@ pub const cpu = struct {
447447 .llvm_name = "sm_90a",
448448 .features = featureSet(&[_]Feature{
449449 .ptx80,
450 .sm_90,
450 .sm_90a,
451451 }),
452452 };
453453};
lib/std/target/x86.zig+58
......@@ -3569,6 +3569,64 @@ pub const cpu = struct {
35693569 .xsaves,
35703570 }),
35713571 };
3572 pub const skylake_avx512 = CpuModel{
3573 .name = "skylake_avx512",
3574 .llvm_name = "skylake-avx512",
3575 .features = featureSet(&[_]Feature{
3576 .@"64bit",
3577 .adx,
3578 .aes,
3579 .allow_light_256_bit,
3580 .avx512bw,
3581 .avx512cd,
3582 .avx512dq,
3583 .avx512vl,
3584 .bmi,
3585 .bmi2,
3586 .clflushopt,
3587 .clwb,
3588 .cmov,
3589 .crc32,
3590 .cx16,
3591 .ermsb,
3592 .false_deps_popcnt,
3593 .fast_15bytenop,
3594 .fast_gather,
3595 .fast_scalar_fsqrt,
3596 .fast_shld_rotate,
3597 .fast_variable_crosslane_shuffle,
3598 .fast_variable_perlane_shuffle,
3599 .fast_vector_fsqrt,
3600 .faster_shift_than_shuffle,
3601 .fsgsbase,
3602 .fxsr,
3603 .idivq_to_divl,
3604 .invpcid,
3605 .lzcnt,
3606 .macrofusion,
3607 .mmx,
3608 .movbe,
3609 .no_bypass_delay_blend,
3610 .no_bypass_delay_mov,
3611 .no_bypass_delay_shuffle,
3612 .nopl,
3613 .pclmul,
3614 .pku,
3615 .popcnt,
3616 .prefer_256_bit,
3617 .prfchw,
3618 .rdrnd,
3619 .rdseed,
3620 .sahf,
3621 .slow_3ops_lea,
3622 .tuning_fast_imm_vector_shift,
3623 .vzeroupper,
3624 .x87,
3625 .xsavec,
3626 .xsaveopt,
3627 .xsaves,
3628 }),
3629 };
35723630 pub const slm = CpuModel{
35733631 .name = "slm",
35743632 .llvm_name = "slm",
lib/std/zig/CrossTarget.zig+2
......@@ -132,6 +132,7 @@ fn updateOsVersionRange(self: *CrossTarget, os: Target.Os) void {
132132 .emscripten,
133133 .driverkit,
134134 .shadermodel,
135 .liteos,
135136 .uefi,
136137 .opencl,
137138 .glsl450,
......@@ -734,6 +735,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
734735 .plan9,
735736 .driverkit,
736737 .shadermodel,
738 .liteos,
737739 .other,
738740 => return error.InvalidOperatingSystemVersion,
739741
src/codegen/llvm.zig+2
......@@ -148,6 +148,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
148148 .watchos => "watchos",
149149 .driverkit => "driverkit",
150150 .shadermodel => "shadermodel",
151 .liteos => "liteos",
151152 .opencl,
152153 .glsl450,
153154 .vulkan,
......@@ -254,6 +255,7 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
254255 .emscripten => .Emscripten,
255256 .driverkit => .DriverKit,
256257 .shadermodel => .ShaderModel,
258 .liteos => .LiteOS,
257259 };
258260}
259261
tools/update_cpu_features.zig-1
......@@ -945,7 +945,6 @@ const llvm_targets = [_]LlvmTarget{
945945 "core_5th_gen_avx_tsx",
946946 "mic_avx512",
947947 "skylake_avx512",
948 "skylake-avx512",
949948 "icelake_client",
950949 "icelake_server",
951950 "graniterapids_d",