Skip to content

Commit

Permalink
Merge pull request #21019 from alexrp/target-os-cleanup
Browse files Browse the repository at this point in the history
`std.Target`: Remove `minix` and `liteos`, rename `glsl450` to `opengl`, and some minor housekeeping
  • Loading branch information
andrewrk authored Aug 12, 2024
2 parents 82b0f44 + 9f1fb45 commit f988cea
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 109 deletions.
4 changes: 1 addition & 3 deletions lib/compiler/aro/aro/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down
157 changes: 74 additions & 83 deletions lib/std/Target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -142,7 +149,6 @@ pub const Os = struct {
.ps3,
.zos,
.haiku,
.minix,
.rtems,
.aix,
.cuda,
Expand All @@ -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,
Expand Down Expand Up @@ -373,7 +378,6 @@ pub const Os = struct {
.ps3,
.zos,
.haiku,
.minix,
.rtems,
.aix,
.cuda,
Expand All @@ -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,
Expand Down Expand Up @@ -571,7 +574,6 @@ pub const Os = struct {
.fuchsia,
.ps3,
.zos,
.minix,
.rtems,
.aix,
.cuda,
Expand All @@ -589,10 +591,9 @@ pub const Os = struct {
.emscripten,
.driverkit,
.shadermodel,
.liteos,
.uefi,
.opencl,
.glsl450,
.opengl,
.vulkan,
.plan9,
.other,
Expand Down Expand Up @@ -676,7 +677,6 @@ pub const Abi = enum {
.dragonfly,
.ps3,
.zos,
.minix,
.rtems,
.aix,
.cuda,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -1656,7 +1651,7 @@ pub inline fn hasDynamicLinker(target: Target) bool {
.windows,
.emscripten,
.opencl,
.glsl450,
.opengl,
.vulkan,
.plan9,
.other,
Expand Down Expand Up @@ -1824,7 +1819,7 @@ pub const DynamicLinker = struct {
.emscripten,
.wasi,
.opencl,
.glsl450,
.opengl,
.vulkan,
.other,
.plan9,
Expand All @@ -1838,7 +1833,6 @@ pub const DynamicLinker = struct {
.fuchsia,
.ps3,
.zos,
.minix,
.rtems,
.aix,
.cuda,
Expand All @@ -1854,7 +1848,6 @@ pub const DynamicLinker = struct {
.hurd,
.driverkit,
.shadermodel,
.liteos,
=> none,
};
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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"),
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/std/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit f988cea

Please sign in to comment.