diff --git a/lib/compiler/aro/aro/target.zig b/lib/compiler/aro/aro/target.zig index a8767233024dd1465c3ce4ddd350ca21c6dab40b..87b362aeb1f5b2f208de06d496bb75a168fc256e 100644 --- a/lib/compiler/aro/aro/target.zig +++ b/lib/compiler/aro/aro/target.zig @@ -626,7 +626,6 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 { .windows => "windows", .zos => "zos", .haiku => "haiku", - .minix => "minix", .rtems => "rtems", .aix => "aix", .cuda => "cuda", @@ -650,9 +649,8 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 { .visionos => "xros", .driverkit => "driverkit", .shadermodel => "shadermodel", - .liteos => "liteos", .opencl, - .glsl450, + .opengl, .vulkan, .plan9, .other, diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 759c1156c38b9f341b7aa24bd7f8b9ccec125f71..3471dc2c1efd0e8c61bfa0199bf8e07ea6449ca0 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -17,53 +17,60 @@ pub const Os = struct { pub const Tag = enum { freestanding, - dragonfly, - freebsd, + other, + + contiki, + elfiamcu, fuchsia, - ios, + hermit, + + aix, + haiku, + hurd, linux, - ps3, - macos, + plan9, + rtems, + serenity, + zos, + + dragonfly, + freebsd, netbsd, openbsd, + + driverkit, + ios, + macos, + tvos, + visionos, + watchos, + + illumos, solaris, - uefi, + windows, - zos, - haiku, - minix, - rtems, - aix, - cuda, - nvcl, - amdhsa, + uefi, + + ps3, ps4, ps5, - elfiamcu, - tvos, - watchos, - driverkit, - visionos, - mesa3d, - contiki, - amdpal, - hermit, - hurd, - wasi, + emscripten, - shadermodel, - liteos, - serenity, + wasi, + + amdhsa, + amdpal, + cuda, + mesa3d, + nvcl, opencl, - glsl450, + opengl, + shadermodel, vulkan, - plan9, - illumos, - other, // LLVM tags deliberately omitted: - // - kfreebsd // - darwin + // - kfreebsd // - nacl pub inline fn isDarwin(tag: Tag) bool { @@ -142,7 +149,6 @@ pub const Os = struct { .ps3, .zos, .haiku, - .minix, .rtems, .aix, .cuda, @@ -159,10 +165,9 @@ pub const Os = struct { .emscripten, .driverkit, .shadermodel, - .liteos, .uefi, .opencl, // TODO: OpenCL versions - .glsl450, // TODO: GLSL versions + .opengl, // TODO: GLSL versions .vulkan, .plan9, .illumos, @@ -373,7 +378,6 @@ pub const Os = struct { .ps3, .zos, .haiku, - .minix, .rtems, .aix, .cuda, @@ -390,10 +394,9 @@ pub const Os = struct { .emscripten, .driverkit, .shadermodel, - .liteos, .uefi, .opencl, // TODO: OpenCL versions - .glsl450, // TODO: GLSL versions + .opengl, // TODO: GLSL versions .vulkan, .plan9, .illumos, @@ -571,7 +574,6 @@ pub const Os = struct { .fuchsia, .ps3, .zos, - .minix, .rtems, .aix, .cuda, @@ -589,10 +591,9 @@ pub const Os = struct { .emscripten, .driverkit, .shadermodel, - .liteos, .uefi, .opencl, - .glsl450, + .opengl, .vulkan, .plan9, .other, @@ -676,7 +677,6 @@ pub const Abi = enum { .dragonfly, .ps3, .zos, - .minix, .rtems, .aix, .cuda, @@ -704,9 +704,8 @@ pub const Abi = enum { .wasi, .emscripten, => .musl, - .liteos => .ohos, - .opencl, // TODO: SPIR-V ABIs with Linkage capability - .glsl450, + .opencl, + .opengl, .vulkan, .plan9, // TODO specify abi .macos, @@ -1001,17 +1000,22 @@ pub const Cpu = struct { }; pub const Arch = enum { + amdgcn, + arc, arm, armeb, + thumb, + thumbeb, aarch64, aarch64_be, - arc, avr, bpfel, bpfeb, csky, dxil, hexagon, + kalimba, + lanai, loongarch32, loongarch64, m68k, @@ -1020,51 +1024,46 @@ pub const Cpu = struct { mips64, mips64el, msp430, + nvptx, + nvptx64, powerpc, powerpcle, powerpc64, powerpc64le, - amdgcn, riscv32, riscv64, + s390x, sparc, sparc64, - s390x, - thumb, - thumbeb, - x86, - x86_64, - xcore, - xtensa, - nvptx, - nvptx64, spirv, spirv32, spirv64, - kalimba, - lanai, + spu_2, + ve, wasm32, wasm64, - ve, - spu_2, + x86, + x86_64, + xcore, + xtensa, // LLVM tags deliberately omitted: // - aarch64_32 - // - r600 - // - sparcel - // - tce - // - tcele - // - le32 - // - le64 // - amdil // - amdil64 + // - le32 + // - le64 + // - r600 // - hsail // - hsail64 - // - spir - // - spir64 - // - shave // - renderscript32 // - renderscript64 + // - shave + // - sparcel + // - spir + // - spir64 + // - tce + // - tcele pub inline fn isX86(arch: Arch) bool { return switch (arch) { @@ -1539,12 +1538,12 @@ pub const Cpu = struct { pub fn baseline(arch: Arch) *const Model { return switch (arch) { .arm, .armeb, .thumb, .thumbeb => &arm.cpu.baseline, - .hexagon => &hexagon.cpu.hexagonv60, + .hexagon => &hexagon.cpu.hexagonv60, // gcc/clang do not have a generic hexagon model. .riscv32 => &riscv.cpu.baseline_rv32, .riscv64 => &riscv.cpu.baseline_rv64, .x86 => &x86.cpu.pentium4, .nvptx, .nvptx64 => &nvptx.cpu.sm_20, - .s390x => &s390x.cpu.arch8, + .s390x => &s390x.cpu.arch8, // gcc/clang do not have a generic s390x model. .sparc => &sparc.cpu.v9, // glibc does not work with 'plain' v8. .loongarch64 => &loongarch.cpu.loongarch64, @@ -1624,10 +1623,6 @@ pub inline fn isGnuLibC(target: Target) bool { return target.os.tag.isGnuLibC(target.abi); } -pub inline fn supportsNewStackCall(target: Target) bool { - return !target.cpu.arch.isWasm(); -} - pub inline fn isSpirV(target: Target) bool { return target.cpu.arch.isSpirV(); } @@ -1656,7 +1651,7 @@ pub inline fn hasDynamicLinker(target: Target) bool { .windows, .emscripten, .opencl, - .glsl450, + .opengl, .vulkan, .plan9, .other, @@ -1824,7 +1819,7 @@ pub const DynamicLinker = struct { .emscripten, .wasi, .opencl, - .glsl450, + .opengl, .vulkan, .other, .plan9, @@ -1838,7 +1833,6 @@ pub const DynamicLinker = struct { .fuchsia, .ps3, .zos, - .minix, .rtems, .aix, .cuda, @@ -1854,7 +1848,6 @@ pub const DynamicLinker = struct { .hurd, .driverkit, .shadermodel, - .liteos, => none, }; } @@ -2139,7 +2132,6 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 { .illumos, .haiku, .fuchsia, - .minix, .serenity, => switch (target.cpu.arch) { .msp430 => switch (c_type) { @@ -2341,10 +2333,9 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 { .contiki, .hermit, .hurd, - .glsl450, + .opengl, .driverkit, .shadermodel, - .liteos, => @panic("TODO specify the C integer and float type sizes for this OS"), } } diff --git a/lib/std/c.zig b/lib/std/c.zig index e006420f5ce77783c1ac165f9b4feb3702f34e95..92d36dd13586c955cd7190ba80ba4751666b041d 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -6619,7 +6619,7 @@ pub const Stat = switch (native_os) { }; pub const pthread_mutex_t = switch (native_os) { - .linux, .minix => extern struct { + .linux => extern struct { data: [data_len]u8 align(@alignOf(usize)) = [_]u8{0} ** data_len, const data_len = switch (native_abi) { @@ -6716,7 +6716,7 @@ pub const pthread_cond_t = switch (native_os) { magic: u16 = 0x4356, data: u64 = 0, }, - .fuchsia, .minix, .emscripten => extern struct { + .fuchsia, .emscripten => extern struct { data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48, }, else => void, diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 8170055b46a1e40f7c579ece3a6b22c1ca272673..6453ea04a323da4b162bffb1c6319612ea3af534 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -110,7 +110,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 { .netbsd => "netbsd", .openbsd => "openbsd", .solaris, .illumos => "solaris", - .windows => "windows", + .windows, .uefi => "windows", .zos => "zos", .haiku => "haiku", .rtems => "rtems", @@ -128,21 +128,18 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 { .hurd => "hurd", .wasi => "wasi", .emscripten => "emscripten", - .uefi => "windows", .macos => "macosx", .ios => "ios", .tvos => "tvos", .watchos => "watchos", .driverkit => "driverkit", .shadermodel => "shadermodel", - .liteos => "liteos", .visionos => "xros", .serenity => "serenity", .vulkan => "vulkan", - .glsl450, + .opengl, .plan9, - .minix, .contiki, .other, => "unknown", @@ -207,15 +204,7 @@ 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, - .plan9, - .minix, - .contiki, - => .UnknownOS, - + .freestanding => .UnknownOS, .windows, .uefi => .Win32, .dragonfly => .DragonFly, .freebsd => .FreeBSD, @@ -234,6 +223,7 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType { .cuda => .CUDA, .nvcl => .NVCL, .amdhsa => .AMDHSA, + .opencl => .UnknownOS, // https://llvm.org/docs/SPIRVUsage.html#target-triples .ps4 => .PS4, .ps5 => .PS5, .elfiamcu => .ELFIAMCU, @@ -248,9 +238,14 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType { .emscripten => .Emscripten, .driverkit => .DriverKit, .shadermodel => .ShaderModel, - .liteos => .LiteOS, .vulkan => .Vulkan, .serenity => .Serenity, + + .opengl, + .plan9, + .contiki, + .other, + => .UnknownOS, }; } diff --git a/src/link/SpirV.zig b/src/link/SpirV.zig index e97c80c3feb6662aefc03a0d92adc8a4113f5fff..57e69ed860e217b96d3b837b8744a7e8968ee5a2 100644 --- a/src/link/SpirV.zig +++ b/src/link/SpirV.zig @@ -85,7 +85,7 @@ pub fn createEmpty( } switch (target.os.tag) { - .opencl, .glsl450, .vulkan => {}, + .opencl, .opengl, .vulkan => {}, else => unreachable, // Caught by Compilation.Config.resolve. } @@ -290,7 +290,7 @@ fn writeCapabilities(spv: *SpvModule, target: std.Target) !void { // TODO: Integrate with a hypothetical feature system const caps: []const spec.Capability = switch (target.os.tag) { .opencl => &.{ .Kernel, .Addresses, .Int8, .Int16, .Int64, .Float64, .Float16, .Vector16, .GenericPointer }, - .glsl450 => &.{.Shader}, + .opengl => &.{.Shader}, .vulkan => &.{ .Shader, .VariablePointersStorageBuffer, .Int8, .Int16, .Int64, .Float64, .Float16 }, else => unreachable, // TODO }; @@ -311,13 +311,13 @@ fn writeMemoryModel(spv: *SpvModule, target: std.Target) !void { .spirv64 => spec.AddressingModel.Physical64, else => unreachable, // TODO }, - .glsl450, .vulkan => spec.AddressingModel.Logical, + .opengl, .vulkan => spec.AddressingModel.Logical, else => unreachable, // TODO }; const memory_model: spec.MemoryModel = switch (target.os.tag) { .opencl => .OpenCL, - .glsl450 => .GLSL450, + .opengl => .GLSL450, .vulkan => .GLSL450, else => unreachable, }; diff --git a/test/llvm_targets.zig b/test/llvm_targets.zig index 71dc9e30a387597a2b2d85a9c2eb22fc7cc84840..76b9e668fa8c8fea0a114e824ba843b8c6a0b720 100644 --- a/test/llvm_targets.zig +++ b/test/llvm_targets.zig @@ -90,10 +90,10 @@ const targets = [_]std.Target.Query{ .{ .cpu_arch = .sparc64, .os_tag = .freestanding, .abi = .none }, .{ .cpu_arch = .sparc64, .os_tag = .linux, .abi = .gnu }, //.{ .cpu_arch = .spirv32, .os_tag = .opencl, .abi = .none }, - //.{ .cpu_arch = .spirv32, .os_tag = .glsl450, .abi = .none }, + //.{ .cpu_arch = .spirv32, .os_tag = .opengl, .abi = .none }, //.{ .cpu_arch = .spirv32, .os_tag = .vulkan, .abi = .none }, //.{ .cpu_arch = .spirv64, .os_tag = .opencl, .abi = .none }, - //.{ .cpu_arch = .spirv64, .os_tag = .glsl450, .abi = .none }, + //.{ .cpu_arch = .spirv64, .os_tag = .opengl, .abi = .none }, //.{ .cpu_arch = .spirv64, .os_tag = .vulkan, .abi = .none }, .{ .cpu_arch = .thumb, .os_tag = .freestanding, .abi = .none }, .{ .cpu_arch = .thumbeb, .os_tag = .freestanding, .abi = .none },