Commit d34fae26d5

Andrew Kelley <andrew@ziglang.org>
2024-04-26 07:52:15
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.
1 parent 109ec72
Changed files (6)
lib/std/Target/arm.zig
@@ -187,7 +187,6 @@ pub const Feature = enum {
     v9_3a,
     v9_4a,
     v9_5a,
-    v9_5a,
     v9a,
     vfp2,
     vfp2sp,
lib/std/Target/x86.zig
@@ -1523,85 +1523,6 @@ pub const cpu = struct {
             .xsaves,
         }),
     };
-    pub const arrowlake_s = CpuModel{
-        .name = "arrowlake_s",
-        .llvm_name = "arrowlake_s",
-        .features = featureSet(&[_]Feature{
-            .@"64bit",
-            .adx,
-            .allow_light_256_bit,
-            .avxifma,
-            .avxneconvert,
-            .avxvnni,
-            .avxvnniint16,
-            .avxvnniint8,
-            .bmi,
-            .bmi2,
-            .cldemote,
-            .clflushopt,
-            .clwb,
-            .cmov,
-            .cmpccxadd,
-            .crc32,
-            .cx16,
-            .enqcmd,
-            .f16c,
-            .false_deps_perm,
-            .false_deps_popcnt,
-            .fast_15bytenop,
-            .fast_gather,
-            .fast_scalar_fsqrt,
-            .fast_shld_rotate,
-            .fast_variable_crosslane_shuffle,
-            .fast_variable_perlane_shuffle,
-            .fast_vector_fsqrt,
-            .fma,
-            .fsgsbase,
-            .fxsr,
-            .gfni,
-            .hreset,
-            .idivq_to_divl,
-            .invpcid,
-            .lzcnt,
-            .macrofusion,
-            .mmx,
-            .movbe,
-            .movdir64b,
-            .movdiri,
-            .no_bypass_delay_blend,
-            .no_bypass_delay_mov,
-            .no_bypass_delay_shuffle,
-            .nopl,
-            .pconfig,
-            .pku,
-            .popcnt,
-            .prefer_movmsk_over_vtest,
-            .prfchw,
-            .ptwrite,
-            .rdpid,
-            .rdrnd,
-            .rdseed,
-            .sahf,
-            .serialize,
-            .sha,
-            .sha512,
-            .shstk,
-            .slow_3ops_lea,
-            .sm3,
-            .sm4,
-            .tuning_fast_imm_vector_shift,
-            .uintr,
-            .vaes,
-            .vpclmulqdq,
-            .vzeroupper,
-            .waitpkg,
-            .widekl,
-            .x87,
-            .xsavec,
-            .xsaveopt,
-            .xsaves,
-        }),
-    };
     pub const athlon = CpuModel{
         .name = "athlon",
         .llvm_name = "athlon",
lib/std/Target.zig
@@ -169,6 +169,7 @@ pub const Os = struct {
                 .vulkan,
                 .plan9,
                 .illumos,
+                .serenity,
                 .other,
                 => .none,
 
@@ -177,6 +178,7 @@ pub const Os = struct {
                 .ios,
                 .tvos,
                 .watchos,
+                .xros,
                 .netbsd,
                 .openbsd,
                 .dragonfly,
@@ -389,6 +391,7 @@ pub const Os = struct {
                 .vulkan,
                 .plan9,
                 .illumos,
+                .serenity,
                 .other,
                 => .{ .none = {} },
 
@@ -431,6 +434,7 @@ pub const Os = struct {
                         .max = .{ .major = 17, .minor = 1, .patch = 0 },
                     },
                 },
+                .xros => @panic("TODO what version is xros on right now?"),
                 .netbsd => .{
                     .semver = .{
                         .min = .{ .major = 8, .minor = 0, .patch = 0 },
@@ -527,11 +531,13 @@ pub const Os = struct {
             .ios,
             .tvos,
             .watchos,
+            .xros,
             .dragonfly,
             .openbsd,
             .haiku,
             .solaris,
             .illumos,
+            .serenity,
             => true,
 
             .linux,
@@ -685,11 +691,13 @@ pub const Abi = enum {
             .ios,
             .tvos,
             .watchos,
+            .xros,
             .driverkit,
             .shadermodel,
             .liteos, // TODO: audit this
             .solaris,
             .illumos,
+            .serenity,
             => .none,
         };
     }
@@ -1179,6 +1187,7 @@ pub const Cpu = struct {
                 .s390x => .S390,
                 .ve => .NONE,
                 .spu_2 => .SPU_2,
+                .spirv => .NONE,
                 .spirv32 => .NONE,
                 .spirv64 => .NONE,
                 .loongarch32 => .NONE,
@@ -1295,6 +1304,7 @@ pub const Cpu = struct {
                 .ve,
                 .spu_2,
                 // GPU bitness is opaque. For now, assume little endian.
+                .spirv,
                 .spirv32,
                 .spirv64,
                 .dxil,
@@ -1419,6 +1429,7 @@ pub const Cpu = struct {
         }
 
         fn allCpusFromDecls(comptime cpus: type) []const *const Cpu.Model {
+            @setEvalBranchQuota(2000);
             const decls = @typeInfo(cpus).Struct.decls;
             var array: [decls.len]*const Cpu.Model = undefined;
             for (decls, 0..) |decl, i| {
@@ -1753,6 +1764,7 @@ pub const DynamicLinker = struct {
                 .nvptx64,
                 .spu_2,
                 .avr,
+                .spirv,
                 .spirv32,
                 .spirv64,
                 => none,
@@ -1794,6 +1806,7 @@ pub const DynamicLinker = struct {
             .tvos,
             .watchos,
             .macos,
+            .xros,
             => init("/usr/lib/dyld"),
 
             // Operating systems in this list have been verified as not having a standard
@@ -1808,6 +1821,7 @@ pub const DynamicLinker = struct {
             .vulkan,
             .other,
             .plan9,
+            .serenity,
             => none,
 
             // TODO revisit when multi-arch for Haiku is available
@@ -1921,6 +1935,7 @@ pub fn maxIntAlignment(target: Target) u16 {
         .spir,
         .kalimba,
         .renderscript32,
+        .spirv,
         .spirv32,
         .shave,
         .le64,
@@ -2012,6 +2027,8 @@ pub fn ptrBitWidth_cpu_abi(cpu: Cpu, abi: Abi) u16 {
         => 64,
 
         .sparc => if (std.Target.sparc.featureSetHas(cpu.features, .v9)) 64 else 32,
+
+        .spirv => @panic("TODO what should this value be?"),
     };
 }
 
@@ -2360,7 +2377,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
             },
         },
 
-        .macos, .ios, .tvos, .watchos => switch (c_type) {
+        .macos, .ios, .tvos, .watchos, .xros => switch (c_type) {
             .char => return 8,
             .short, .ushort => return 16,
             .int, .uint, .float => return 32,
@@ -2440,6 +2457,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
         .driverkit,
         .shadermodel,
         .liteos,
+        .serenity,
         => @panic("TODO specify the C integer and float type sizes for this OS"),
     }
 }
@@ -2547,6 +2565,8 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {
             .wasm32,
             .wasm64,
             => 16,
+
+            .spirv => @panic("TODO what should this value be?"),
         }),
     );
 }
@@ -2673,6 +2693,8 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
             .wasm32,
             .wasm64,
             => 16,
+
+            .spirv => @panic("TODO what should this value be?"),
         }),
     );
 }
src/codegen/llvm.zig
@@ -92,6 +92,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
         .hsail64 => "hsail64",
         .spir => "spir",
         .spir64 => "spir64",
+        .spirv => "spirv",
         .spirv32 => "spirv32",
         .spirv64 => "spirv64",
         .kalimba => "kalimba",
@@ -109,8 +110,6 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
 
     const llvm_os = switch (target.os.tag) {
         .freestanding => "unknown",
-        .ananas => "ananas",
-        .cloudabi => "cloudabi",
         .dragonfly => "dragonfly",
         .freebsd => "freebsd",
         .fuchsia => "fuchsia",
@@ -123,7 +122,6 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
         .windows => "windows",
         .zos => "zos",
         .haiku => "haiku",
-        .minix => "minix",
         .rtems => "rtems",
         .nacl => "nacl",
         .aix => "aix",
@@ -134,7 +132,6 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
         .ps5 => "ps5",
         .elfiamcu => "elfiamcu",
         .mesa3d => "mesa3d",
-        .contiki => "contiki",
         .amdpal => "amdpal",
         .hermit => "hermit",
         .hurd => "hurd",
@@ -148,10 +145,17 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
         .driverkit => "driverkit",
         .shadermodel => "shadermodel",
         .liteos => "liteos",
+        .xros => "xros",
+        .serenity => "serenity",
+        .vulkan => "vulkan",
+
         .opencl,
         .glsl450,
-        .vulkan,
         .plan9,
+        .ananas,
+        .cloudabi,
+        .minix,
+        .contiki,
         .other,
         => "unknown",
     };
@@ -216,10 +220,18 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
 
 pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
     return switch (os_tag) {
-        .freestanding, .other, .opencl, .glsl450, .vulkan, .plan9 => .UnknownOS,
+        .freestanding,
+        .other,
+        .opencl,
+        .glsl450,
+        .plan9,
+        .ananas,
+        .cloudabi,
+        .minix,
+        .contiki,
+        => .UnknownOS,
+
         .windows, .uefi => .Win32,
-        .ananas => .Ananas,
-        .cloudabi => .CloudABI,
         .dragonfly => .DragonFly,
         .freebsd => .FreeBSD,
         .fuchsia => .Fuchsia,
@@ -233,7 +245,6 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
         .solaris, .illumos => .Solaris,
         .zos => .ZOS,
         .haiku => .Haiku,
-        .minix => .Minix,
         .rtems => .RTEMS,
         .nacl => .NaCl,
         .aix => .AIX,
@@ -245,8 +256,8 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
         .elfiamcu => .ELFIAMCU,
         .tvos => .TvOS,
         .watchos => .WatchOS,
+        .xros => .XROS,
         .mesa3d => .Mesa3D,
-        .contiki => .Contiki,
         .amdpal => .AMDPAL,
         .hermit => .HermitCore,
         .hurd => .Hurd,
@@ -255,6 +266,8 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
         .driverkit => .DriverKit,
         .shadermodel => .ShaderModel,
         .liteos => .LiteOS,
+        .vulkan => .Vulkan,
+        .serenity => .Serenity,
     };
 }
 
@@ -310,6 +323,9 @@ pub fn targetArch(arch_tag: std.Target.Cpu.Arch) llvm.ArchType {
         .hsail64 => .hsail64,
         .spir => .spir,
         .spir64 => .spir64,
+        .spirv => .spirv,
+        .spirv32 => .spirv32,
+        .spirv64 => .spirv64,
         .kalimba => .kalimba,
         .shave => .shave,
         .lanai => .lanai,
@@ -318,7 +334,7 @@ pub fn targetArch(arch_tag: std.Target.Cpu.Arch) llvm.ArchType {
         .renderscript32 => .renderscript32,
         .renderscript64 => .renderscript64,
         .ve => .ve,
-        .spu_2, .spirv32, .spirv64 => .UnknownArch,
+        .spu_2 => .UnknownArch,
     };
 }
 
@@ -11969,6 +11985,9 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
         .shave,
         .spir,
         .spir64,
+        .spirv,
+        .spirv32,
+        .spirv64,
         .kalimba,
         .renderscript32,
         .renderscript64,
@@ -11978,7 +11997,5 @@ pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
         => {},
 
         .spu_2 => unreachable, // LLVM does not support this backend
-        .spirv32 => unreachable, // LLVM does not support this backend
-        .spirv64 => unreachable, // LLVM does not support this backend
     }
 }
src/Module.zig
@@ -5976,6 +5976,8 @@ pub fn atomicPtrAlignment(
         => 128,
 
         .x86_64 => if (std.Target.x86.featureSetHas(target.cpu.features, .cx16)) 128 else 64,
+
+        .spirv => @panic("TODO what should this value be?"),
     };
 
     const int_ty = switch (ty.zigTypeTag(mod)) {
src/target.zig
@@ -159,6 +159,7 @@ pub fn hasLlvmSupport(target: std.Target, ofmt: std.Target.ObjectFormat) bool {
         .hsail64,
         .spir,
         .spir64,
+        .spirv,
         .spirv32,
         .spirv64,
         .kalimba,