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
This commit is contained in:
Andrew Kelley 2023-08-11 16:41:20 -07:00
parent 1861036f3b
commit 62a12e0631
7 changed files with 86 additions and 20 deletions

View File

@ -260,6 +260,7 @@ pub const Target = struct {
.emscripten,
.driverkit,
.shadermodel,
.liteos,
.uefi,
.opencl, // TODO: OpenCL versions
.glsl450, // TODO: GLSL versions
@ -396,7 +397,7 @@ pub const Target = struct {
/// On Darwin, we always link libSystem which contains libc.
/// Similarly on FreeBSD and NetBSD we always link system libc
/// since this is the stable syscall interface.
pub inline fn requiresLibC(os: Os) bool {
pub fn requiresLibC(os: Os) bool {
return switch (os.tag) {
.freebsd,
.netbsd,
@ -438,6 +439,7 @@ pub const Target = struct {
.emscripten,
.driverkit,
.shadermodel,
.liteos,
.uefi,
.opencl,
.glsl450,
@ -566,6 +568,7 @@ pub const Target = struct {
.watchos,
.driverkit,
.shadermodel,
.liteos, // TODO: audit this
=> return .none,
}
}
@ -976,7 +979,7 @@ pub const Target = struct {
return error.UnknownCpuModel;
}
pub inline fn toElfMachine(arch: Arch) std.elf.EM {
pub fn toElfMachine(arch: Arch) std.elf.EM {
return switch (arch) {
.avr => .AVR,
.msp430 => .MSP430,
@ -1041,7 +1044,7 @@ pub const Target = struct {
};
}
pub inline fn toCoffMachine(arch: Arch) std.coff.MachineType {
pub fn toCoffMachine(arch: Arch) std.coff.MachineType {
return switch (arch) {
.avr => .Unknown,
.msp430 => .Unknown,
@ -1106,7 +1109,7 @@ pub const Target = struct {
};
}
pub inline fn endian(arch: Arch) std.builtin.Endian {
pub fn endian(arch: Arch) std.builtin.Endian {
return switch (arch) {
.avr,
.arm,
@ -1177,7 +1180,7 @@ pub const Target = struct {
}
/// Returns whether this architecture supports the address space
pub inline fn supportsAddressSpace(arch: Arch, address_space: std.builtin.AddressSpace) bool {
pub fn supportsAddressSpace(arch: Arch, address_space: std.builtin.AddressSpace) bool {
const is_nvptx = arch == .nvptx or arch == .nvptx64;
const is_spirv = arch == .spirv32 or arch == .spirv64;
const is_gpu = is_nvptx or is_spirv or arch == .amdgcn;
@ -1715,6 +1718,7 @@ pub const Target = struct {
.hurd,
.driverkit,
.shadermodel,
.liteos,
=> return result,
}
}
@ -1743,7 +1747,7 @@ pub const Target = struct {
};
}
pub inline fn maxIntAlignment(target: Target) u16 {
pub fn maxIntAlignment(target: Target) u16 {
return switch (target.cpu.arch) {
.avr => 1,
.msp430 => 2,
@ -1833,7 +1837,7 @@ pub const Target = struct {
};
}
pub inline fn ptrBitWidth(target: Target) u16 {
pub fn ptrBitWidth(target: Target) u16 {
switch (target.abi) {
.gnux32, .muslx32, .gnuabin32, .gnuilp32 => return 32,
.gnuabi64 => return 64,
@ -1910,7 +1914,7 @@ pub const Target = struct {
}
}
pub inline fn stackAlignment(target: Target) u16 {
pub fn stackAlignment(target: Target) u16 {
return switch (target.cpu.arch) {
.m68k => 2,
.amdgcn => 4,
@ -1955,7 +1959,7 @@ pub const Target = struct {
/// Default signedness of `char` for the native C compiler for this target
/// Note that char signedness is implementation-defined and many compilers provide
/// an option to override the default signedness e.g. GCC's -funsigned-char / -fsigned-char
pub inline fn charSignedness(target: Target) std.builtin.Signedness {
pub fn charSignedness(target: Target) std.builtin.Signedness {
switch (target.cpu.arch) {
.aarch64,
.aarch64_32,
@ -1994,7 +1998,7 @@ pub const Target = struct {
longdouble,
};
pub inline fn c_type_byte_size(t: Target, c_type: CType) u16 {
pub fn c_type_byte_size(t: Target, c_type: CType) u16 {
return switch (c_type) {
.char,
.short,
@ -2020,7 +2024,7 @@ pub const Target = struct {
};
}
pub inline fn c_type_bit_size(target: Target, c_type: CType) u16 {
pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
switch (target.os.tag) {
.freestanding, .other => switch (target.cpu.arch) {
.msp430 => switch (c_type) {
@ -2330,11 +2334,12 @@ pub const Target = struct {
.vulkan,
.driverkit,
.shadermodel,
.liteos,
=> @panic("TODO specify the C integer and float type sizes for this OS"),
}
}
pub inline fn c_type_alignment(target: Target, c_type: CType) u16 {
pub fn c_type_alignment(target: Target, c_type: CType) u16 {
// Overrides for unusual alignments
switch (target.cpu.arch) {
.avr => return 1,
@ -2441,7 +2446,7 @@ pub const Target = struct {
);
}
pub inline fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
// Overrides for unusual alignments
switch (target.cpu.arch) {
.arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) {

View File

@ -3079,7 +3079,7 @@ pub const cpu = struct {
.btst16,
}),
};
pub const i805 = CpuModel{
pub const @"i805" = CpuModel{
.name = "i805",
.llvm_name = "i805",
.features = featureSet(&[_]Feature{

View File

@ -47,7 +47,7 @@ pub const Feature = enum {
sm_87,
sm_89,
sm_90,
sm_90,
sm_90a,
};
pub const featureSet = CpuFeature.feature_set_fns(Feature).featureSet;
@ -269,9 +269,9 @@ pub const all_features = blk: {
.description = "Target SM 90",
.dependencies = featureSet(&[_]Feature{}),
};
result[@intFromEnum(Feature.sm_90)] = .{
.llvm_name = "sm_90",
.description = "Target SM 90",
result[@intFromEnum(Feature.sm_90a)] = .{
.llvm_name = "sm_90a",
.description = "Target SM 90a",
.dependencies = featureSet(&[_]Feature{}),
};
const ti = @typeInfo(Feature);
@ -447,7 +447,7 @@ pub const cpu = struct {
.llvm_name = "sm_90a",
.features = featureSet(&[_]Feature{
.ptx80,
.sm_90,
.sm_90a,
}),
};
};

View File

@ -3569,6 +3569,64 @@ pub const cpu = struct {
.xsaves,
}),
};
pub const skylake_avx512 = CpuModel{
.name = "skylake_avx512",
.llvm_name = "skylake-avx512",
.features = featureSet(&[_]Feature{
.@"64bit",
.adx,
.aes,
.allow_light_256_bit,
.avx512bw,
.avx512cd,
.avx512dq,
.avx512vl,
.bmi,
.bmi2,
.clflushopt,
.clwb,
.cmov,
.crc32,
.cx16,
.ermsb,
.false_deps_popcnt,
.fast_15bytenop,
.fast_gather,
.fast_scalar_fsqrt,
.fast_shld_rotate,
.fast_variable_crosslane_shuffle,
.fast_variable_perlane_shuffle,
.fast_vector_fsqrt,
.faster_shift_than_shuffle,
.fsgsbase,
.fxsr,
.idivq_to_divl,
.invpcid,
.lzcnt,
.macrofusion,
.mmx,
.movbe,
.no_bypass_delay_blend,
.no_bypass_delay_mov,
.no_bypass_delay_shuffle,
.nopl,
.pclmul,
.pku,
.popcnt,
.prefer_256_bit,
.prfchw,
.rdrnd,
.rdseed,
.sahf,
.slow_3ops_lea,
.tuning_fast_imm_vector_shift,
.vzeroupper,
.x87,
.xsavec,
.xsaveopt,
.xsaves,
}),
};
pub const slm = CpuModel{
.name = "slm",
.llvm_name = "slm",

View File

@ -132,6 +132,7 @@ fn updateOsVersionRange(self: *CrossTarget, os: Target.Os) void {
.emscripten,
.driverkit,
.shadermodel,
.liteos,
.uefi,
.opencl,
.glsl450,
@ -734,6 +735,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
.plan9,
.driverkit,
.shadermodel,
.liteos,
.other,
=> return error.InvalidOperatingSystemVersion,

View File

@ -148,6 +148,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
.watchos => "watchos",
.driverkit => "driverkit",
.shadermodel => "shadermodel",
.liteos => "liteos",
.opencl,
.glsl450,
.vulkan,
@ -254,6 +255,7 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
.emscripten => .Emscripten,
.driverkit => .DriverKit,
.shadermodel => .ShaderModel,
.liteos => .LiteOS,
};
}

View File

@ -945,7 +945,6 @@ const llvm_targets = [_]LlvmTarget{
"core_5th_gen_avx_tsx",
"mic_avx512",
"skylake_avx512",
"skylake-avx512",
"icelake_client",
"icelake_server",
"graniterapids_d",