authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-12 16:06:57-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-08-12 16:06:57-07:00
logf988cea825c4b21d0864e7125287b12566079c39
tree1c814af0239ed542df9346be00a5b51b42e00ecd
parent82b0f447211d17a6431307c74a5eb6d36e770697
parent9f1fb45201e59945acc7e48fc394bba4064d52f5
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21019 from alexrp/target-os-cleanup

`std.Target`: Remove `minix` and `liteos`, rename `glsl450` to `opengl`, and some minor housekeeping

6 files changed, 93 insertions(+), 109 deletions(-)

lib/compiler/aro/aro/target.zig+1-3
......@@ -626,7 +626,6 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
626626 .windows => "windows",
627627 .zos => "zos",
628628 .haiku => "haiku",
629 .minix => "minix",
630629 .rtems => "rtems",
631630 .aix => "aix",
632631 .cuda => "cuda",
......@@ -650,9 +649,8 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
650649 .visionos => "xros",
651650 .driverkit => "driverkit",
652651 .shadermodel => "shadermodel",
653 .liteos => "liteos",
654652 .opencl,
655 .glsl450,
653 .opengl,
656654 .vulkan,
657655 .plan9,
658656 .other,
lib/std/Target.zig+74-83
......@@ -17,53 +17,60 @@ pub const Os = struct {
1717
1818 pub const Tag = enum {
1919 freestanding,
20 dragonfly,
21 freebsd,
20 other,
21
22 contiki,
23 elfiamcu,
2224 fuchsia,
23 ios,
25 hermit,
26
27 aix,
28 haiku,
29 hurd,
2430 linux,
25 ps3,
26 macos,
31 plan9,
32 rtems,
33 serenity,
34 zos,
35
36 dragonfly,
37 freebsd,
2738 netbsd,
2839 openbsd,
40
41 driverkit,
42 ios,
43 macos,
44 tvos,
45 visionos,
46 watchos,
47
48 illumos,
2949 solaris,
30 uefi,
50
3151 windows,
32 zos,
33 haiku,
34 minix,
35 rtems,
36 aix,
37 cuda,
38 nvcl,
39 amdhsa,
52 uefi,
53
54 ps3,
4055 ps4,
4156 ps5,
42 elfiamcu,
43 tvos,
44 watchos,
45 driverkit,
46 visionos,
47 mesa3d,
48 contiki,
49 amdpal,
50 hermit,
51 hurd,
52 wasi,
57
5358 emscripten,
54 shadermodel,
55 liteos,
56 serenity,
59 wasi,
60
61 amdhsa,
62 amdpal,
63 cuda,
64 mesa3d,
65 nvcl,
5766 opencl,
58 glsl450,
67 opengl,
68 shadermodel,
5969 vulkan,
60 plan9,
61 illumos,
62 other,
6370
6471 // LLVM tags deliberately omitted:
65 // - kfreebsd
6672 // - darwin
73 // - kfreebsd
6774 // - nacl
6875
6976 pub inline fn isDarwin(tag: Tag) bool {
......@@ -142,7 +149,6 @@ pub const Os = struct {
142149 .ps3,
143150 .zos,
144151 .haiku,
145 .minix,
146152 .rtems,
147153 .aix,
148154 .cuda,
......@@ -159,10 +165,9 @@ pub const Os = struct {
159165 .emscripten,
160166 .driverkit,
161167 .shadermodel,
162 .liteos,
163168 .uefi,
164169 .opencl, // TODO: OpenCL versions
165 .glsl450, // TODO: GLSL versions
170 .opengl, // TODO: GLSL versions
166171 .vulkan,
167172 .plan9,
168173 .illumos,
......@@ -373,7 +378,6 @@ pub const Os = struct {
373378 .ps3,
374379 .zos,
375380 .haiku,
376 .minix,
377381 .rtems,
378382 .aix,
379383 .cuda,
......@@ -390,10 +394,9 @@ pub const Os = struct {
390394 .emscripten,
391395 .driverkit,
392396 .shadermodel,
393 .liteos,
394397 .uefi,
395398 .opencl, // TODO: OpenCL versions
396 .glsl450, // TODO: GLSL versions
399 .opengl, // TODO: GLSL versions
397400 .vulkan,
398401 .plan9,
399402 .illumos,
......@@ -571,7 +574,6 @@ pub const Os = struct {
571574 .fuchsia,
572575 .ps3,
573576 .zos,
574 .minix,
575577 .rtems,
576578 .aix,
577579 .cuda,
......@@ -589,10 +591,9 @@ pub const Os = struct {
589591 .emscripten,
590592 .driverkit,
591593 .shadermodel,
592 .liteos,
593594 .uefi,
594595 .opencl,
595 .glsl450,
596 .opengl,
596597 .vulkan,
597598 .plan9,
598599 .other,
......@@ -676,7 +677,6 @@ pub const Abi = enum {
676677 .dragonfly,
677678 .ps3,
678679 .zos,
679 .minix,
680680 .rtems,
681681 .aix,
682682 .cuda,
......@@ -704,9 +704,8 @@ pub const Abi = enum {
704704 .wasi,
705705 .emscripten,
706706 => .musl,
707 .liteos => .ohos,
708 .opencl, // TODO: SPIR-V ABIs with Linkage capability
709 .glsl450,
707 .opencl,
708 .opengl,
710709 .vulkan,
711710 .plan9, // TODO specify abi
712711 .macos,
......@@ -1001,17 +1000,22 @@ pub const Cpu = struct {
10011000 };
10021001
10031002 pub const Arch = enum {
1003 amdgcn,
1004 arc,
10041005 arm,
10051006 armeb,
1007 thumb,
1008 thumbeb,
10061009 aarch64,
10071010 aarch64_be,
1008 arc,
10091011 avr,
10101012 bpfel,
10111013 bpfeb,
10121014 csky,
10131015 dxil,
10141016 hexagon,
1017 kalimba,
1018 lanai,
10151019 loongarch32,
10161020 loongarch64,
10171021 m68k,
......@@ -1020,51 +1024,46 @@ pub const Cpu = struct {
10201024 mips64,
10211025 mips64el,
10221026 msp430,
1027 nvptx,
1028 nvptx64,
10231029 powerpc,
10241030 powerpcle,
10251031 powerpc64,
10261032 powerpc64le,
1027 amdgcn,
10281033 riscv32,
10291034 riscv64,
1035 s390x,
10301036 sparc,
10311037 sparc64,
1032 s390x,
1033 thumb,
1034 thumbeb,
1035 x86,
1036 x86_64,
1037 xcore,
1038 xtensa,
1039 nvptx,
1040 nvptx64,
10411038 spirv,
10421039 spirv32,
10431040 spirv64,
1044 kalimba,
1045 lanai,
1041 spu_2,
1042 ve,
10461043 wasm32,
10471044 wasm64,
1048 ve,
1049 spu_2,
1045 x86,
1046 x86_64,
1047 xcore,
1048 xtensa,
10501049
10511050 // LLVM tags deliberately omitted:
10521051 // - aarch64_32
1053 // - r600
1054 // - sparcel
1055 // - tce
1056 // - tcele
1057 // - le32
1058 // - le64
10591052 // - amdil
10601053 // - amdil64
1054 // - le32
1055 // - le64
1056 // - r600
10611057 // - hsail
10621058 // - hsail64
1063 // - spir
1064 // - spir64
1065 // - shave
10661059 // - renderscript32
10671060 // - renderscript64
1061 // - shave
1062 // - sparcel
1063 // - spir
1064 // - spir64
1065 // - tce
1066 // - tcele
10681067
10691068 pub inline fn isX86(arch: Arch) bool {
10701069 return switch (arch) {
......@@ -1539,12 +1538,12 @@ pub const Cpu = struct {
15391538 pub fn baseline(arch: Arch) *const Model {
15401539 return switch (arch) {
15411540 .arm, .armeb, .thumb, .thumbeb => &arm.cpu.baseline,
1542 .hexagon => &hexagon.cpu.hexagonv60,
1541 .hexagon => &hexagon.cpu.hexagonv60, // gcc/clang do not have a generic hexagon model.
15431542 .riscv32 => &riscv.cpu.baseline_rv32,
15441543 .riscv64 => &riscv.cpu.baseline_rv64,
15451544 .x86 => &x86.cpu.pentium4,
15461545 .nvptx, .nvptx64 => &nvptx.cpu.sm_20,
1547 .s390x => &s390x.cpu.arch8,
1546 .s390x => &s390x.cpu.arch8, // gcc/clang do not have a generic s390x model.
15481547 .sparc => &sparc.cpu.v9, // glibc does not work with 'plain' v8.
15491548 .loongarch64 => &loongarch.cpu.loongarch64,
15501549
......@@ -1624,10 +1623,6 @@ pub inline fn isGnuLibC(target: Target) bool {
16241623 return target.os.tag.isGnuLibC(target.abi);
16251624}
16261625
1627pub inline fn supportsNewStackCall(target: Target) bool {
1628 return !target.cpu.arch.isWasm();
1629}
1630
16311626pub inline fn isSpirV(target: Target) bool {
16321627 return target.cpu.arch.isSpirV();
16331628}
......@@ -1656,7 +1651,7 @@ pub inline fn hasDynamicLinker(target: Target) bool {
16561651 .windows,
16571652 .emscripten,
16581653 .opencl,
1659 .glsl450,
1654 .opengl,
16601655 .vulkan,
16611656 .plan9,
16621657 .other,
......@@ -1824,7 +1819,7 @@ pub const DynamicLinker = struct {
18241819 .emscripten,
18251820 .wasi,
18261821 .opencl,
1827 .glsl450,
1822 .opengl,
18281823 .vulkan,
18291824 .other,
18301825 .plan9,
......@@ -1838,7 +1833,6 @@ pub const DynamicLinker = struct {
18381833 .fuchsia,
18391834 .ps3,
18401835 .zos,
1841 .minix,
18421836 .rtems,
18431837 .aix,
18441838 .cuda,
......@@ -1854,7 +1848,6 @@ pub const DynamicLinker = struct {
18541848 .hurd,
18551849 .driverkit,
18561850 .shadermodel,
1857 .liteos,
18581851 => none,
18591852 };
18601853 }
......@@ -2139,7 +2132,6 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
21392132 .illumos,
21402133 .haiku,
21412134 .fuchsia,
2142 .minix,
21432135 .serenity,
21442136 => switch (target.cpu.arch) {
21452137 .msp430 => switch (c_type) {
......@@ -2341,10 +2333,9 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
23412333 .contiki,
23422334 .hermit,
23432335 .hurd,
2344 .glsl450,
2336 .opengl,
23452337 .driverkit,
23462338 .shadermodel,
2347 .liteos,
23482339 => @panic("TODO specify the C integer and float type sizes for this OS"),
23492340 }
23502341}
lib/std/c.zig+2-2
......@@ -6619,7 +6619,7 @@ pub const Stat = switch (native_os) {
66196619};
66206620
66216621pub const pthread_mutex_t = switch (native_os) {
6622 .linux, .minix => extern struct {
6622 .linux => extern struct {
66236623 data: [data_len]u8 align(@alignOf(usize)) = [_]u8{0} ** data_len,
66246624
66256625 const data_len = switch (native_abi) {
......@@ -6716,7 +6716,7 @@ pub const pthread_cond_t = switch (native_os) {
67166716 magic: u16 = 0x4356,
67176717 data: u64 = 0,
67186718 },
6719 .fuchsia, .minix, .emscripten => extern struct {
6719 .fuchsia, .emscripten => extern struct {
67206720 data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48,
67216721 },
67226722 else => void,
src/codegen/llvm.zig+10-15
......@@ -110,7 +110,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
110110 .netbsd => "netbsd",
111111 .openbsd => "openbsd",
112112 .solaris, .illumos => "solaris",
113 .windows => "windows",
113 .windows, .uefi => "windows",
114114 .zos => "zos",
115115 .haiku => "haiku",
116116 .rtems => "rtems",
......@@ -128,21 +128,18 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
128128 .hurd => "hurd",
129129 .wasi => "wasi",
130130 .emscripten => "emscripten",
131 .uefi => "windows",
132131 .macos => "macosx",
133132 .ios => "ios",
134133 .tvos => "tvos",
135134 .watchos => "watchos",
136135 .driverkit => "driverkit",
137136 .shadermodel => "shadermodel",
138 .liteos => "liteos",
139137 .visionos => "xros",
140138 .serenity => "serenity",
141139 .vulkan => "vulkan",
142140
143 .glsl450,
141 .opengl,
144142 .plan9,
145 .minix,
146143 .contiki,
147144 .other,
148145 => "unknown",
......@@ -207,15 +204,7 @@ pub fn targetTriple(allocator: Allocator, target: std.Target) ![]const u8 {
207204
208205pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
209206 return switch (os_tag) {
210 .freestanding,
211 .other,
212 .opencl,
213 .glsl450,
214 .plan9,
215 .minix,
216 .contiki,
217 => .UnknownOS,
218
207 .freestanding => .UnknownOS,
219208 .windows, .uefi => .Win32,
220209 .dragonfly => .DragonFly,
221210 .freebsd => .FreeBSD,
......@@ -234,6 +223,7 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
234223 .cuda => .CUDA,
235224 .nvcl => .NVCL,
236225 .amdhsa => .AMDHSA,
226 .opencl => .UnknownOS, // https://llvm.org/docs/SPIRVUsage.html#target-triples
237227 .ps4 => .PS4,
238228 .ps5 => .PS5,
239229 .elfiamcu => .ELFIAMCU,
......@@ -248,9 +238,14 @@ pub fn targetOs(os_tag: std.Target.Os.Tag) llvm.OSType {
248238 .emscripten => .Emscripten,
249239 .driverkit => .DriverKit,
250240 .shadermodel => .ShaderModel,
251 .liteos => .LiteOS,
252241 .vulkan => .Vulkan,
253242 .serenity => .Serenity,
243
244 .opengl,
245 .plan9,
246 .contiki,
247 .other,
248 => .UnknownOS,
254249 };
255250}
256251
src/link/SpirV.zig+4-4
......@@ -85,7 +85,7 @@ pub fn createEmpty(
8585 }
8686
8787 switch (target.os.tag) {
88 .opencl, .glsl450, .vulkan => {},
88 .opencl, .opengl, .vulkan => {},
8989 else => unreachable, // Caught by Compilation.Config.resolve.
9090 }
9191
......@@ -290,7 +290,7 @@ fn writeCapabilities(spv: *SpvModule, target: std.Target) !void {
290290 // TODO: Integrate with a hypothetical feature system
291291 const caps: []const spec.Capability = switch (target.os.tag) {
292292 .opencl => &.{ .Kernel, .Addresses, .Int8, .Int16, .Int64, .Float64, .Float16, .Vector16, .GenericPointer },
293 .glsl450 => &.{.Shader},
293 .opengl => &.{.Shader},
294294 .vulkan => &.{ .Shader, .VariablePointersStorageBuffer, .Int8, .Int16, .Int64, .Float64, .Float16 },
295295 else => unreachable, // TODO
296296 };
......@@ -311,13 +311,13 @@ fn writeMemoryModel(spv: *SpvModule, target: std.Target) !void {
311311 .spirv64 => spec.AddressingModel.Physical64,
312312 else => unreachable, // TODO
313313 },
314 .glsl450, .vulkan => spec.AddressingModel.Logical,
314 .opengl, .vulkan => spec.AddressingModel.Logical,
315315 else => unreachable, // TODO
316316 };
317317
318318 const memory_model: spec.MemoryModel = switch (target.os.tag) {
319319 .opencl => .OpenCL,
320 .glsl450 => .GLSL450,
320 .opengl => .GLSL450,
321321 .vulkan => .GLSL450,
322322 else => unreachable,
323323 };
test/llvm_targets.zig+2-2
......@@ -90,10 +90,10 @@ const targets = [_]std.Target.Query{
9090 .{ .cpu_arch = .sparc64, .os_tag = .freestanding, .abi = .none },
9191 .{ .cpu_arch = .sparc64, .os_tag = .linux, .abi = .gnu },
9292 //.{ .cpu_arch = .spirv32, .os_tag = .opencl, .abi = .none },
93 //.{ .cpu_arch = .spirv32, .os_tag = .glsl450, .abi = .none },
93 //.{ .cpu_arch = .spirv32, .os_tag = .opengl, .abi = .none },
9494 //.{ .cpu_arch = .spirv32, .os_tag = .vulkan, .abi = .none },
9595 //.{ .cpu_arch = .spirv64, .os_tag = .opencl, .abi = .none },
96 //.{ .cpu_arch = .spirv64, .os_tag = .glsl450, .abi = .none },
96 //.{ .cpu_arch = .spirv64, .os_tag = .opengl, .abi = .none },
9797 //.{ .cpu_arch = .spirv64, .os_tag = .vulkan, .abi = .none },
9898 .{ .cpu_arch = .thumb, .os_tag = .freestanding, .abi = .none },
9999 .{ .cpu_arch = .thumbeb, .os_tag = .freestanding, .abi = .none },