authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-04-25 22:52:15-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-08 19:37:28-07:00
logd34fae26d5bb556debf6b0a1d570ae936331a74b
tree6ffd356e09537093b381f0c130fcc66b1fd46fb9
parent109ec729247443200c2ba614f6acb0b991e44b4d

LLVM 18 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. * add to various target OS switches. Some of the values I was unsure of and added TODO panics, for example in the case of spirv CPU arch.

6 files changed, 56 insertions(+), 94 deletions(-)

lib/std/Target.zig+23-1
...@@ -169,6 +169,7 @@ pub const Os = struct {...@@ -169,6 +169,7 @@ pub const Os = struct {
169 .vulkan,169 .vulkan,
170 .plan9,170 .plan9,
171 .illumos,171 .illumos,
172 .serenity,
172 .other,173 .other,
173 => .none,174 => .none,
174175
...@@ -177,6 +178,7 @@ pub const Os = struct {...@@ -177,6 +178,7 @@ pub const Os = struct {
177 .ios,178 .ios,
178 .tvos,179 .tvos,
179 .watchos,180 .watchos,
181 .xros,
180 .netbsd,182 .netbsd,
181 .openbsd,183 .openbsd,
182 .dragonfly,184 .dragonfly,
...@@ -389,6 +391,7 @@ pub const Os = struct {...@@ -389,6 +391,7 @@ pub const Os = struct {
389 .vulkan,391 .vulkan,
390 .plan9,392 .plan9,
391 .illumos,393 .illumos,
394 .serenity,
392 .other,395 .other,
393 => .{ .none = {} },396 => .{ .none = {} },
394397
...@@ -431,6 +434,7 @@ pub const Os = struct {...@@ -431,6 +434,7 @@ pub const Os = struct {
431 .max = .{ .major = 17, .minor = 1, .patch = 0 },434 .max = .{ .major = 17, .minor = 1, .patch = 0 },
432 },435 },
433 },436 },
437 .xros => @panic("TODO what version is xros on right now?"),
434 .netbsd => .{438 .netbsd => .{
435 .semver = .{439 .semver = .{
436 .min = .{ .major = 8, .minor = 0, .patch = 0 },440 .min = .{ .major = 8, .minor = 0, .patch = 0 },
...@@ -527,11 +531,13 @@ pub const Os = struct {...@@ -527,11 +531,13 @@ pub const Os = struct {
527 .ios,531 .ios,
528 .tvos,532 .tvos,
529 .watchos,533 .watchos,
534 .xros,
530 .dragonfly,535 .dragonfly,
531 .openbsd,536 .openbsd,
532 .haiku,537 .haiku,
533 .solaris,538 .solaris,
534 .illumos,539 .illumos,
540 .serenity,
535 => true,541 => true,
536542
537 .linux,543 .linux,
...@@ -685,11 +691,13 @@ pub const Abi = enum {...@@ -685,11 +691,13 @@ pub const Abi = enum {
685 .ios,691 .ios,
686 .tvos,692 .tvos,
687 .watchos,693 .watchos,
694 .xros,
688 .driverkit,695 .driverkit,
689 .shadermodel,696 .shadermodel,
690 .liteos, // TODO: audit this697 .liteos, // TODO: audit this
691 .solaris,698 .solaris,
692 .illumos,699 .illumos,
700 .serenity,
693 => .none,701 => .none,
694 };702 };
695 }703 }
...@@ -1179,6 +1187,7 @@ pub const Cpu = struct {...@@ -1179,6 +1187,7 @@ pub const Cpu = struct {
1179 .s390x => .S390,1187 .s390x => .S390,
1180 .ve => .NONE,1188 .ve => .NONE,
1181 .spu_2 => .SPU_2,1189 .spu_2 => .SPU_2,
1190 .spirv => .NONE,
1182 .spirv32 => .NONE,1191 .spirv32 => .NONE,
1183 .spirv64 => .NONE,1192 .spirv64 => .NONE,
1184 .loongarch32 => .NONE,1193 .loongarch32 => .NONE,
...@@ -1295,6 +1304,7 @@ pub const Cpu = struct {...@@ -1295,6 +1304,7 @@ pub const Cpu = struct {
1295 .ve,1304 .ve,
1296 .spu_2,1305 .spu_2,
1297 // GPU bitness is opaque. For now, assume little endian.1306 // GPU bitness is opaque. For now, assume little endian.
1307 .spirv,
1298 .spirv32,1308 .spirv32,
1299 .spirv64,1309 .spirv64,
1300 .dxil,1310 .dxil,
...@@ -1419,6 +1429,7 @@ pub const Cpu = struct {...@@ -1419,6 +1429,7 @@ pub const Cpu = struct {
1419 }1429 }
14201430
1421 fn allCpusFromDecls(comptime cpus: type) []const *const Cpu.Model {1431 fn allCpusFromDecls(comptime cpus: type) []const *const Cpu.Model {
1432 @setEvalBranchQuota(2000);
1422 const decls = @typeInfo(cpus).Struct.decls;1433 const decls = @typeInfo(cpus).Struct.decls;
1423 var array: [decls.len]*const Cpu.Model = undefined;1434 var array: [decls.len]*const Cpu.Model = undefined;
1424 for (decls, 0..) |decl, i| {1435 for (decls, 0..) |decl, i| {
...@@ -1753,6 +1764,7 @@ pub const DynamicLinker = struct {...@@ -1753,6 +1764,7 @@ pub const DynamicLinker = struct {
1753 .nvptx64,1764 .nvptx64,
1754 .spu_2,1765 .spu_2,
1755 .avr,1766 .avr,
1767 .spirv,
1756 .spirv32,1768 .spirv32,
1757 .spirv64,1769 .spirv64,
1758 => none,1770 => none,
...@@ -1794,6 +1806,7 @@ pub const DynamicLinker = struct {...@@ -1794,6 +1806,7 @@ pub const DynamicLinker = struct {
1794 .tvos,1806 .tvos,
1795 .watchos,1807 .watchos,
1796 .macos,1808 .macos,
1809 .xros,
1797 => init("/usr/lib/dyld"),1810 => init("/usr/lib/dyld"),
17981811
1799 // Operating systems in this list have been verified as not having a standard1812 // Operating systems in this list have been verified as not having a standard
...@@ -1808,6 +1821,7 @@ pub const DynamicLinker = struct {...@@ -1808,6 +1821,7 @@ pub const DynamicLinker = struct {
1808 .vulkan,1821 .vulkan,
1809 .other,1822 .other,
1810 .plan9,1823 .plan9,
1824 .serenity,
1811 => none,1825 => none,
18121826
1813 // TODO revisit when multi-arch for Haiku is available1827 // TODO revisit when multi-arch for Haiku is available
...@@ -1921,6 +1935,7 @@ pub fn maxIntAlignment(target: Target) u16 {...@@ -1921,6 +1935,7 @@ pub fn maxIntAlignment(target: Target) u16 {
1921 .spir,1935 .spir,
1922 .kalimba,1936 .kalimba,
1923 .renderscript32,1937 .renderscript32,
1938 .spirv,
1924 .spirv32,1939 .spirv32,
1925 .shave,1940 .shave,
1926 .le64,1941 .le64,
...@@ -2012,6 +2027,8 @@ pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 {...@@ -2012,6 +2027,8 @@ pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 {
2012 => 64,2027 => 64,
20132028
2014 .sparc => if (std.Target.sparc.featureSetHas(cpu.features, .v9)) 64 else 32,2029 .sparc => if (std.Target.sparc.featureSetHas(cpu.features, .v9)) 64 else 32,
2030
2031 .spirv => @panic("TODO what should this value be?"),
2015 };2032 };
2016}2033}
20172034
...@@ -2360,7 +2377,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {...@@ -2360,7 +2377,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
2360 },2377 },
2361 },2378 },
23622379
2363 .macos, .ios, .tvos, .watchos => switch (c_type) {2380 .macos, .ios, .tvos, .watchos, .xros => switch (c_type) {
2364 .char => return 8,2381 .char => return 8,
2365 .short, .ushort => return 16,2382 .short, .ushort => return 16,
2366 .int, .uint, .float => return 32,2383 .int, .uint, .float => return 32,
...@@ -2440,6 +2457,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {...@@ -2440,6 +2457,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
2440 .driverkit,2457 .driverkit,
2441 .shadermodel,2458 .shadermodel,
2442 .liteos,2459 .liteos,
2460 .serenity,
2443 => @panic("TODO specify the C integer and float type sizes for this OS"),2461 => @panic("TODO specify the C integer and float type sizes for this OS"),
2444 }2462 }
2445}2463}
...@@ -2547,6 +2565,8 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {...@@ -2547,6 +2565,8 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {
2547 .wasm32,2565 .wasm32,
2548 .wasm64,2566 .wasm64,
2549 => 16,2567 => 16,
2568
2569 .spirv => @panic("TODO what should this value be?"),
2550 }),2570 }),
2551 );2571 );
2552}2572}
...@@ -2673,6 +2693,8 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {...@@ -2673,6 +2693,8 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
2673 .wasm32,2693 .wasm32,
2674 .wasm64,2694 .wasm64,
2675 => 16,2695 => 16,
2696
2697 .spirv => @panic("TODO what should this value be?"),
2676 }),2698 }),
2677 );2699 );
2678}2700}
lib/std/Target/arm.zig-1
...@@ -187,7 +187,6 @@ pub const Feature = enum {...@@ -187,7 +187,6 @@ pub const Feature = enum {
187 v9_3a,187 v9_3a,
188 v9_4a,188 v9_4a,
189 v9_5a,189 v9_5a,
190 v9_5a,
191 v9a,190 v9a,
192 vfp2,191 vfp2,
193 vfp2sp,192 vfp2sp,
lib/std/Target/x86.zig-79
...@@ -1523,85 +1523,6 @@ pub const cpu = struct {...@@ -1523,85 +1523,6 @@ pub const cpu = struct {
1523 .xsaves,1523 .xsaves,
1524 }),1524 }),
1525 };1525 };
1526 pub const arrowlake_s = CpuModel{
1527 .name = "arrowlake_s",
1528 .llvm_name = "arrowlake_s",
1529 .features = featureSet(&[_]Feature{
1530 .@"64bit",
1531 .adx,
1532 .allow_light_256_bit,
1533 .avxifma,
1534 .avxneconvert,
1535 .avxvnni,
1536 .avxvnniint16,
1537 .avxvnniint8,
1538 .bmi,
1539 .bmi2,
1540 .cldemote,
1541 .clflushopt,
1542 .clwb,
1543 .cmov,
1544 .cmpccxadd,
1545 .crc32,
1546 .cx16,
1547 .enqcmd,
1548 .f16c,
1549 .false_deps_perm,
1550 .false_deps_popcnt,
1551 .fast_15bytenop,
1552 .fast_gather,
1553 .fast_scalar_fsqrt,
1554 .fast_shld_rotate,
1555 .fast_variable_crosslane_shuffle,
1556 .fast_variable_perlane_shuffle,
1557 .fast_vector_fsqrt,
1558 .fma,
1559 .fsgsbase,
1560 .fxsr,
1561 .gfni,
1562 .hreset,
1563 .idivq_to_divl,
1564 .invpcid,
1565 .lzcnt,
1566 .macrofusion,
1567 .mmx,
1568 .movbe,
1569 .movdir64b,
1570 .movdiri,
1571 .no_bypass_delay_blend,
1572 .no_bypass_delay_mov,
1573 .no_bypass_delay_shuffle,
1574 .nopl,
1575 .pconfig,
1576 .pku,
1577 .popcnt,
1578 .prefer_movmsk_over_vtest,
1579 .prfchw,
1580 .ptwrite,
1581 .rdpid,
1582 .rdrnd,
1583 .rdseed,
1584 .sahf,
1585 .serialize,
1586 .sha,
1587 .sha512,
1588 .shstk,
1589 .slow_3ops_lea,
1590 .sm3,
1591 .sm4,
1592 .tuning_fast_imm_vector_shift,
1593 .uintr,
1594 .vaes,
1595 .vpclmulqdq,
1596 .vzeroupper,
1597 .waitpkg,
1598 .widekl,
1599 .x87,
1600 .xsavec,
1601 .xsaveopt,
1602 .xsaves,
1603 }),
1604 };
1605 pub const athlon = CpuModel{1526 pub const athlon = CpuModel{
1606 .name = "athlon",1527 .name = "athlon",
1607 .llvm_name = "athlon",1528 .llvm_name = "athlon",
src/Module.zig+2
...@@ -5976,6 +5976,8 @@ pub fn atomicPtrAlignment(...@@ -5976,6 +5976,8 @@ pub fn atomicPtrAlignment(
5976 => 128,5976 => 128,
59775977
5978 .x86_64 => if (std.Target.x86.featureSetHas(target.cpu.features, .cx16)) 128 else 64,5978 .x86_64 => if (std.Target.x86.featureSetHas(target.cpu.features, .cx16)) 128 else 64,
5979
5980 .spirv => @panic("TODO what should this value be?"),
5979 };5981 };
59805982
5981 const int_ty = switch (ty.zigTypeTag(mod)) {5983 const int_ty = switch (ty.zigTypeTag(mod)) {
src/codegen/llvm.zig+30-13
...@@ -92,6 +92,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {...@@ -92,6 +92,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
92 .hsail64 => "hsail64",92 .hsail64 => "hsail64",
93 .spir => "spir",93 .spir => "spir",
94 .spir64 => "spir64",94 .spir64 => "spir64",
95 .spirv => "spirv",
95 .spirv32 => "spirv32",96 .spirv32 => "spirv32",
96 .spirv64 => "spirv64",97 .spirv64 => "spirv64",
97 .kalimba => "kalimba",98 .kalimba => "kalimba",
...@@ -109,8 +110,6 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {...@@ -109,8 +110,6 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
109110
110 const llvm_os = switch (target.os.tag) {111 const llvm_os = switch (target.os.tag) {
111 .freestanding => "unknown",112 .freestanding => "unknown",
112 .ananas => "ananas",
113 .cloudabi => "cloudabi",
114 .dragonfly => "dragonfly",113 .dragonfly => "dragonfly",
115 .freebsd => "freebsd",114 .freebsd => "freebsd",
116 .fuchsia => "fuchsia",115 .fuchsia => "fuchsia",
...@@ -123,7 +122,6 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {...@@ -123,7 +122,6 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
123 .windows => "windows",122 .windows => "windows",
124 .zos => "zos",123 .zos => "zos",
125 .haiku => "haiku",124 .haiku => "haiku",
126 .minix => "minix",
127 .rtems => "rtems",125 .rtems => "rtems",
128 .nacl => "nacl",126 .nacl => "nacl",
129 .aix => "aix",127 .aix => "aix",
...@@ -134,7 +132,6 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {...@@ -134,7 +132,6 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
134 .ps5 => "ps5",132 .ps5 => "ps5",
135 .elfiamcu => "elfiamcu",133 .elfiamcu => "elfiamcu",
136 .mesa3d => "mesa3d",134 .mesa3d => "mesa3d",
137 .contiki => "contiki",
138 .amdpal => "amdpal",135 .amdpal => "amdpal",
139 .hermit => "hermit",136 .hermit => "hermit",
140 .hurd => "hurd",137 .hurd => "hurd",
...@@ -148,10 +145,17 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {...@@ -148,10 +145,17 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
148 .driverkit => "driverkit",145 .driverkit => "driverkit",
149 .shadermodel => "shadermodel",146 .shadermodel => "shadermodel",
150 .liteos => "liteos",147 .liteos => "liteos",
148 .xros => "xros",
149 .serenity => "serenity",
150 .vulkan => "vulkan",
151
151 .opencl,152 .opencl,
152 .glsl450,153 .glsl450,
153 .vulkan,
154 .plan9,154 .plan9,
155 .ananas,
156 .cloudabi,
157 .minix,
158 .contiki,
155 .other,159 .other,
156 => "unknown",160 => "unknown",
157 };161 };
...@@ -216,10 +220,18 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {...@@ -216,10 +220,18 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
216220
217pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {221pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
218 return switch (os_tag) {222 return switch (os_tag) {
219 .freestanding, .other, .opencl, .glsl450, .vulkan, .plan9 => .UnknownOS,223 .freestanding,
224 .other,
225 .opencl,
226 .glsl450,
227 .plan9,
228 .ananas,
229 .cloudabi,
230 .minix,
231 .contiki,
232 => .UnknownOS,
233
220 .windows, .uefi => .Win32,234 .windows, .uefi => .Win32,
221 .ananas => .Ananas,
222 .cloudabi => .CloudABI,
223 .dragonfly => .DragonFly,235 .dragonfly => .DragonFly,
224 .freebsd => .FreeBSD,236 .freebsd => .FreeBSD,
225 .fuchsia => .Fuchsia,237 .fuchsia => .Fuchsia,
...@@ -233,7 +245,6 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {...@@ -233,7 +245,6 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
233 .solaris, .illumos => .Solaris,245 .solaris, .illumos => .Solaris,
234 .zos => .ZOS,246 .zos => .ZOS,
235 .haiku => .Haiku,247 .haiku => .Haiku,
236 .minix => .Minix,
237 .rtems => .RTEMS,248 .rtems => .RTEMS,
238 .nacl => .NaCl,249 .nacl => .NaCl,
239 .aix => .AIX,250 .aix => .AIX,
...@@ -245,8 +256,8 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {...@@ -245,8 +256,8 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
245 .elfiamcu => .ELFIAMCU,256 .elfiamcu => .ELFIAMCU,
246 .tvos => .TvOS,257 .tvos => .TvOS,
247 .watchos => .WatchOS,258 .watchos => .WatchOS,
259 .xros => .XROS,
248 .mesa3d => .Mesa3D,260 .mesa3d => .Mesa3D,
249 .contiki => .Contiki,
250 .amdpal => .AMDPAL,261 .amdpal => .AMDPAL,
251 .hermit => .HermitCore,262 .hermit => .HermitCore,
252 .hurd => .Hurd,263 .hurd => .Hurd,
...@@ -255,6 +266,8 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {...@@ -255,6 +266,8 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
255 .driverkit => .DriverKit,266 .driverkit => .DriverKit,
256 .shadermodel => .ShaderModel,267 .shadermodel => .ShaderModel,
257 .liteos => .LiteOS,268 .liteos => .LiteOS,
269 .vulkan => .Vulkan,
270 .serenity => .Serenity,
258 };271 };
259}272}
260273
...@@ -310,6 +323,9 @@ pub fn targetArch(arch_tag: std.Target.Cpu.Arch) llvm.ArchType {...@@ -310,6 +323,9 @@ pub fn targetArch(arch_tag: std.Target.Cpu.Arch) llvm.ArchType {
310 .hsail64 => .hsail64,323 .hsail64 => .hsail64,
311 .spir => .spir,324 .spir => .spir,
312 .spir64 => .spir64,325 .spir64 => .spir64,
326 .spirv => .spirv,
327 .spirv32 => .spirv32,
328 .spirv64 => .spirv64,
313 .kalimba => .kalimba,329 .kalimba => .kalimba,
314 .shave => .shave,330 .shave => .shave,
315 .lanai => .lanai,331 .lanai => .lanai,
...@@ -318,7 +334,7 @@ pub fn targetArch(arch_tag: std.Target.Cpu.Arch) llvm.ArchType {...@@ -318,7 +334,7 @@ pub fn targetArch(arch_tag: std.Target.Cpu.Arch) llvm.ArchType {
318 .renderscript32 => .renderscript32,334 .renderscript32 => .renderscript32,
319 .renderscript64 => .renderscript64,335 .renderscript64 => .renderscript64,
320 .ve => .ve,336 .ve => .ve,
321 .spu_2, .spirv32, .spirv64 => .UnknownArch,337 .spu_2 => .UnknownArch,
322 };338 };
323}339}
324340
...@@ -11969,6 +11985,9 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {...@@ -11969,6 +11985,9 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
11969 .shave,11985 .shave,
11970 .spir,11986 .spir,
11971 .spir64,11987 .spir64,
11988 .spirv,
11989 .spirv32,
11990 .spirv64,
11972 .kalimba,11991 .kalimba,
11973 .renderscript32,11992 .renderscript32,
11974 .renderscript64,11993 .renderscript64,
...@@ -11978,7 +11997,5 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {...@@ -11978,7 +11997,5 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
11978 => {},11997 => {},
1197911998
11980 .spu_2 => unreachable, // LLVM does not support this backend11999 .spu_2 => unreachable, // LLVM does not support this backend
11981 .spirv32 => unreachable, // LLVM does not support this backend
11982 .spirv64 => unreachable, // LLVM does not support this backend
11983 }12000 }
11984}12001}
src/target.zig+1
...@@ -159,6 +159,7 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool {...@@ -159,6 +159,7 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool {
159 .hsail64,159 .hsail64,
160 .spir,160 .spir,
161 .spir64,161 .spir64,
162 .spirv,
162 .spirv32,163 .spirv32,
163 .spirv64,164 .spirv64,
164 .kalimba,165 .kalimba,