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 {
169169 .vulkan,
170170 .plan9,
171171 .illumos,
172 .serenity,
172173 .other,
173174 => .none,
174175
......@@ -177,6 +178,7 @@ pub const Os = struct {
177178 .ios,
178179 .tvos,
179180 .watchos,
181 .xros,
180182 .netbsd,
181183 .openbsd,
182184 .dragonfly,
......@@ -389,6 +391,7 @@ pub const Os = struct {
389391 .vulkan,
390392 .plan9,
391393 .illumos,
394 .serenity,
392395 .other,
393396 => .{ .none = {} },
394397
......@@ -431,6 +434,7 @@ pub const Os = struct {
431434 .max = .{ .major = 17, .minor = 1, .patch = 0 },
432435 },
433436 },
437 .xros => @panic("TODO what version is xros on right now?"),
434438 .netbsd => .{
435439 .semver = .{
436440 .min = .{ .major = 8, .minor = 0, .patch = 0 },
......@@ -527,11 +531,13 @@ pub const Os = struct {
527531 .ios,
528532 .tvos,
529533 .watchos,
534 .xros,
530535 .dragonfly,
531536 .openbsd,
532537 .haiku,
533538 .solaris,
534539 .illumos,
540 .serenity,
535541 => true,
536542
537543 .linux,
......@@ -685,11 +691,13 @@ pub const Abi = enum {
685691 .ios,
686692 .tvos,
687693 .watchos,
694 .xros,
688695 .driverkit,
689696 .shadermodel,
690697 .liteos, // TODO: audit this
691698 .solaris,
692699 .illumos,
700 .serenity,
693701 => .none,
694702 };
695703 }
......@@ -1179,6 +1187,7 @@ pub const Cpu = struct {
11791187 .s390x => .S390,
11801188 .ve => .NONE,
11811189 .spu_2 => .SPU_2,
1190 .spirv => .NONE,
11821191 .spirv32 => .NONE,
11831192 .spirv64 => .NONE,
11841193 .loongarch32 => .NONE,
......@@ -1295,6 +1304,7 @@ pub const Cpu = struct {
12951304 .ve,
12961305 .spu_2,
12971306 // GPU bitness is opaque. For now, assume little endian.
1307 .spirv,
12981308 .spirv32,
12991309 .spirv64,
13001310 .dxil,
......@@ -1419,6 +1429,7 @@ pub const Cpu = struct {
14191429 }
14201430
14211431 fn allCpusFromDecls(comptime cpus: type) []const *const Cpu.Model {
1432 @setEvalBranchQuota(2000);
14221433 const decls = @typeInfo(cpus).Struct.decls;
14231434 var array: [decls.len]*const Cpu.Model = undefined;
14241435 for (decls, 0..) |decl, i| {
......@@ -1753,6 +1764,7 @@ pub const DynamicLinker = struct {
17531764 .nvptx64,
17541765 .spu_2,
17551766 .avr,
1767 .spirv,
17561768 .spirv32,
17571769 .spirv64,
17581770 => none,
......@@ -1794,6 +1806,7 @@ pub const DynamicLinker = struct {
17941806 .tvos,
17951807 .watchos,
17961808 .macos,
1809 .xros,
17971810 => init("/usr/lib/dyld"),
17981811
17991812 // Operating systems in this list have been verified as not having a standard
......@@ -1808,6 +1821,7 @@ pub const DynamicLinker = struct {
18081821 .vulkan,
18091822 .other,
18101823 .plan9,
1824 .serenity,
18111825 => none,
18121826
18131827 // TODO revisit when multi-arch for Haiku is available
......@@ -1921,6 +1935,7 @@ pub fn maxIntAlignment(target: Target) u16 {
19211935 .spir,
19221936 .kalimba,
19231937 .renderscript32,
1938 .spirv,
19241939 .spirv32,
19251940 .shave,
19261941 .le64,
......@@ -2012,6 +2027,8 @@ pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 {
20122027 => 64,
20132028
20142029 .sparc => if (std.Target.sparc.featureSetHas(cpu.features, .v9)) 64 else 32,
2030
2031 .spirv => @panic("TODO what should this value be?"),
20152032 };
20162033}
20172034
......@@ -2360,7 +2377,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
23602377 },
23612378 },
23622379
2363 .macos, .ios, .tvos, .watchos => switch (c_type) {
2380 .macos, .ios, .tvos, .watchos, .xros => switch (c_type) {
23642381 .char => return 8,
23652382 .short, .ushort => return 16,
23662383 .int, .uint, .float => return 32,
......@@ -2440,6 +2457,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
24402457 .driverkit,
24412458 .shadermodel,
24422459 .liteos,
2460 .serenity,
24432461 => @panic("TODO specify the C integer and float type sizes for this OS"),
24442462 }
24452463}
......@@ -2547,6 +2565,8 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {
25472565 .wasm32,
25482566 .wasm64,
25492567 => 16,
2568
2569 .spirv => @panic("TODO what should this value be?"),
25502570 }),
25512571 );
25522572}
......@@ -2673,6 +2693,8 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
26732693 .wasm32,
26742694 .wasm64,
26752695 => 16,
2696
2697 .spirv => @panic("TODO what should this value be?"),
26762698 }),
26772699 );
26782700}
lib/std/Target/arm.zig-1
......@@ -187,7 +187,6 @@ pub const Feature = enum {
187187 v9_3a,
188188 v9_4a,
189189 v9_5a,
190 v9_5a,
191190 v9a,
192191 vfp2,
193192 vfp2sp,
lib/std/Target/x86.zig-79
......@@ -1523,85 +1523,6 @@ pub const cpu = struct {
15231523 .xsaves,
15241524 }),
15251525 };
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 };
16051526 pub const athlon = CpuModel{
16061527 .name = "athlon",
16071528 .llvm_name = "athlon",
src/Module.zig+2
......@@ -5976,6 +5976,8 @@ pub fn atomicPtrAlignment(
59765976 => 128,
59775977
59785978 .x86_64 => if (std.Target.x86.featureSetHas(target.cpu.features, .cx16)) 128 else 64,
5979
5980 .spirv => @panic("TODO what should this value be?"),
59795981 };
59805982
59815983 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 {
9292 .hsail64 => "hsail64",
9393 .spir => "spir",
9494 .spir64 => "spir64",
95 .spirv => "spirv",
9596 .spirv32 => "spirv32",
9697 .spirv64 => "spirv64",
9798 .kalimba => "kalimba",
......@@ -109,8 +110,6 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
109110
110111 const llvm_os = switch (target.os.tag) {
111112 .freestanding => "unknown",
112 .ananas => "ananas",
113 .cloudabi => "cloudabi",
114113 .dragonfly => "dragonfly",
115114 .freebsd => "freebsd",
116115 .fuchsia => "fuchsia",
......@@ -123,7 +122,6 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
123122 .windows => "windows",
124123 .zos => "zos",
125124 .haiku => "haiku",
126 .minix => "minix",
127125 .rtems => "rtems",
128126 .nacl => "nacl",
129127 .aix => "aix",
......@@ -134,7 +132,6 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
134132 .ps5 => "ps5",
135133 .elfiamcu => "elfiamcu",
136134 .mesa3d => "mesa3d",
137 .contiki => "contiki",
138135 .amdpal => "amdpal",
139136 .hermit => "hermit",
140137 .hurd => "hurd",
......@@ -148,10 +145,17 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
148145 .driverkit => "driverkit",
149146 .shadermodel => "shadermodel",
150147 .liteos => "liteos",
148 .xros => "xros",
149 .serenity => "serenity",
150 .vulkan => "vulkan",
151
151152 .opencl,
152153 .glsl450,
153 .vulkan,
154154 .plan9,
155 .ananas,
156 .cloudabi,
157 .minix,
158 .contiki,
155159 .other,
156160 => "unknown",
157161 };
......@@ -216,10 +220,18 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
216220
217221pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
218222 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
220234 .windows, .uefi => .Win32,
221 .ananas => .Ananas,
222 .cloudabi => .CloudABI,
223235 .dragonfly => .DragonFly,
224236 .freebsd => .FreeBSD,
225237 .fuchsia => .Fuchsia,
......@@ -233,7 +245,6 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
233245 .solaris, .illumos => .Solaris,
234246 .zos => .ZOS,
235247 .haiku => .Haiku,
236 .minix => .Minix,
237248 .rtems => .RTEMS,
238249 .nacl => .NaCl,
239250 .aix => .AIX,
......@@ -245,8 +256,8 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
245256 .elfiamcu => .ELFIAMCU,
246257 .tvos => .TvOS,
247258 .watchos => .WatchOS,
259 .xros => .XROS,
248260 .mesa3d => .Mesa3D,
249 .contiki => .Contiki,
250261 .amdpal => .AMDPAL,
251262 .hermit => .HermitCore,
252263 .hurd => .Hurd,
......@@ -255,6 +266,8 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
255266 .driverkit => .DriverKit,
256267 .shadermodel => .ShaderModel,
257268 .liteos => .LiteOS,
269 .vulkan => .Vulkan,
270 .serenity => .Serenity,
258271 };
259272}
260273
......@@ -310,6 +323,9 @@ pub fn targetArch(arch_tag: std.Target.Cpu.Arch) llvm.ArchType {
310323 .hsail64 => .hsail64,
311324 .spir => .spir,
312325 .spir64 => .spir64,
326 .spirv => .spirv,
327 .spirv32 => .spirv32,
328 .spirv64 => .spirv64,
313329 .kalimba => .kalimba,
314330 .shave => .shave,
315331 .lanai => .lanai,
......@@ -318,7 +334,7 @@ pub fn targetArch(arch_tag: std.Target.Cpu.Arch) llvm.ArchType {
318334 .renderscript32 => .renderscript32,
319335 .renderscript64 => .renderscript64,
320336 .ve => .ve,
321 .spu_2, .spirv32, .spirv64 => .UnknownArch,
337 .spu_2 => .UnknownArch,
322338 };
323339}
324340
......@@ -11969,6 +11985,9 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
1196911985 .shave,
1197011986 .spir,
1197111987 .spir64,
11988 .spirv,
11989 .spirv32,
11990 .spirv64,
1197211991 .kalimba,
1197311992 .renderscript32,
1197411993 .renderscript64,
......@@ -11978,7 +11997,5 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
1197811997 => {},
1197911998
1198011999 .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
1198312000 }
1198412001}
src/target.zig+1
......@@ -159,6 +159,7 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool {
159159 .hsail64,
160160 .spir,
161161 .spir64,
162 .spirv,
162163 .spirv32,
163164 .spirv64,
164165 .kalimba,