mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
SPIR-V: Initial architecture definitions and setup
This commit is contained in:
parent
9a6babf482
commit
ab607d455e
@ -57,6 +57,7 @@ pub const Target = struct {
|
||||
wasi,
|
||||
emscripten,
|
||||
uefi,
|
||||
opencl, // SPIR-V on OpenCL
|
||||
other,
|
||||
|
||||
pub fn isDarwin(tag: Tag) bool {
|
||||
@ -248,6 +249,7 @@ pub const Target = struct {
|
||||
.wasi,
|
||||
.emscripten,
|
||||
.uefi,
|
||||
.opencl,
|
||||
.other,
|
||||
=> return .{ .none = {} },
|
||||
|
||||
@ -403,6 +405,7 @@ pub const Target = struct {
|
||||
.wasi,
|
||||
.emscripten,
|
||||
.uefi,
|
||||
.opencl,
|
||||
.other,
|
||||
=> false,
|
||||
};
|
||||
@ -421,6 +424,7 @@ pub const Target = struct {
|
||||
pub const powerpc = @import("target/powerpc.zig");
|
||||
pub const riscv = @import("target/riscv.zig");
|
||||
pub const sparc = @import("target/sparc.zig");
|
||||
pub const spirv = @import("target/spirv.zig");
|
||||
pub const systemz = @import("target/systemz.zig");
|
||||
pub const wasm = @import("target/wasm.zig");
|
||||
pub const x86 = @import("target/x86.zig");
|
||||
@ -493,6 +497,8 @@ pub const Target = struct {
|
||||
.wasi,
|
||||
.emscripten,
|
||||
=> return .musl,
|
||||
.opencl, // TODO: Where should this go?
|
||||
=> return .none,
|
||||
}
|
||||
}
|
||||
|
||||
@ -528,6 +534,7 @@ pub const Target = struct {
|
||||
macho,
|
||||
wasm,
|
||||
c,
|
||||
spirv,
|
||||
hex,
|
||||
raw,
|
||||
};
|
||||
@ -744,6 +751,8 @@ pub const Target = struct {
|
||||
// Stage1 currently assumes that architectures above this comment
|
||||
// map one-to-one with the ZigLLVM_ArchType enum.
|
||||
spu_2,
|
||||
spirv32,
|
||||
spirv64,
|
||||
|
||||
pub fn isARM(arch: Arch) bool {
|
||||
return switch (arch) {
|
||||
@ -857,6 +866,8 @@ pub const Target = struct {
|
||||
.s390x => ._S390,
|
||||
.ve => ._NONE,
|
||||
.spu_2 => ._SPU_2,
|
||||
.spirv32 => ._NONE,
|
||||
.spirv64 => ._NONE,
|
||||
};
|
||||
}
|
||||
|
||||
@ -914,6 +925,8 @@ pub const Target = struct {
|
||||
.s390x => .Unknown,
|
||||
.ve => .Unknown,
|
||||
.spu_2 => .Unknown,
|
||||
.spirv32 => .Unknown,
|
||||
.spirv64 => .Unknown,
|
||||
};
|
||||
}
|
||||
|
||||
@ -957,6 +970,9 @@ pub const Target = struct {
|
||||
.shave,
|
||||
.ve,
|
||||
.spu_2,
|
||||
// GPU bitness is opaque. For now, assume little endian.
|
||||
.spirv32,
|
||||
.spirv64,
|
||||
=> .Little,
|
||||
|
||||
.arc,
|
||||
@ -1012,6 +1028,7 @@ pub const Target = struct {
|
||||
.wasm32,
|
||||
.renderscript32,
|
||||
.aarch64_32,
|
||||
.spirv32,
|
||||
=> return 32,
|
||||
|
||||
.aarch64,
|
||||
@ -1035,6 +1052,7 @@ pub const Target = struct {
|
||||
.sparcv9,
|
||||
.s390x,
|
||||
.ve,
|
||||
.spirv64,
|
||||
=> return 64,
|
||||
}
|
||||
}
|
||||
@ -1057,6 +1075,7 @@ pub const Target = struct {
|
||||
.i386, .x86_64 => "x86",
|
||||
.nvptx, .nvptx64 => "nvptx",
|
||||
.wasm32, .wasm64 => "wasm",
|
||||
.spirv32, .spirv64 => "spir-v",
|
||||
else => @tagName(arch),
|
||||
};
|
||||
}
|
||||
@ -1347,6 +1366,7 @@ pub const Target = struct {
|
||||
.uefi,
|
||||
.windows,
|
||||
.emscripten,
|
||||
.opencl,
|
||||
.other,
|
||||
=> return false,
|
||||
else => return true,
|
||||
@ -1482,6 +1502,8 @@ pub const Target = struct {
|
||||
.nvptx64,
|
||||
.spu_2,
|
||||
.avr,
|
||||
.spirv32,
|
||||
.spirv64,
|
||||
=> return result,
|
||||
|
||||
// TODO go over each item in this list and either move it to the above list, or
|
||||
@ -1524,6 +1546,7 @@ pub const Target = struct {
|
||||
.windows,
|
||||
.emscripten,
|
||||
.wasi,
|
||||
.opencl,
|
||||
.other,
|
||||
=> return result,
|
||||
|
||||
|
||||
@ -141,6 +141,7 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro
|
||||
.Lib => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}),
|
||||
},
|
||||
.c => return std.fmt.allocPrint(allocator, "{s}.c", .{root_name}),
|
||||
.spirv => return std.fmt.allocPrint(allocator, "{s}.spv", .{root_name}),
|
||||
.hex => return std.fmt.allocPrint(allocator, "{s}.ihex", .{root_name}),
|
||||
.raw => return std.fmt.allocPrint(allocator, "{s}.bin", .{root_name}),
|
||||
}
|
||||
|
||||
@ -130,6 +130,7 @@ pub const CrossTarget = struct {
|
||||
.wasi,
|
||||
.emscripten,
|
||||
.uefi,
|
||||
.opencl,
|
||||
.other,
|
||||
=> {
|
||||
self.os_version_min = .{ .none = {} };
|
||||
@ -730,6 +731,7 @@ pub const CrossTarget = struct {
|
||||
.wasi,
|
||||
.emscripten,
|
||||
.uefi,
|
||||
.opencl,
|
||||
.other,
|
||||
=> return error.InvalidOperatingSystemVersion,
|
||||
|
||||
|
||||
@ -133,6 +133,7 @@ pub const File = struct {
|
||||
macho: MachO.TextBlock,
|
||||
c: C.DeclBlock,
|
||||
wasm: void,
|
||||
spirv: void,
|
||||
};
|
||||
|
||||
pub const LinkFn = union {
|
||||
@ -141,6 +142,7 @@ pub const File = struct {
|
||||
macho: MachO.SrcFn,
|
||||
c: C.FnBlock,
|
||||
wasm: ?Wasm.FnData,
|
||||
spirv: void,
|
||||
};
|
||||
|
||||
pub const Export = union {
|
||||
@ -149,6 +151,7 @@ pub const File = struct {
|
||||
macho: MachO.Export,
|
||||
c: void,
|
||||
wasm: void,
|
||||
spirv: void,
|
||||
};
|
||||
|
||||
/// For DWARF .debug_info.
|
||||
@ -177,6 +180,7 @@ pub const File = struct {
|
||||
.macho => &(try MachO.createEmpty(allocator, options)).base,
|
||||
.wasm => &(try Wasm.createEmpty(allocator, options)).base,
|
||||
.c => unreachable, // Reported error earlier.
|
||||
.spirv => return error.SpirVObjectFormatUnimplemented,
|
||||
.hex => return error.HexObjectFormatUnimplemented,
|
||||
.raw => return error.RawObjectFormatUnimplemented,
|
||||
};
|
||||
@ -192,6 +196,7 @@ pub const File = struct {
|
||||
.macho => &(try MachO.createEmpty(allocator, options)).base,
|
||||
.wasm => &(try Wasm.createEmpty(allocator, options)).base,
|
||||
.c => unreachable, // Reported error earlier.
|
||||
.spirv => return error.SpirVObjectFormatUnimplemented,
|
||||
.hex => return error.HexObjectFormatUnimplemented,
|
||||
.raw => return error.RawObjectFormatUnimplemented,
|
||||
};
|
||||
@ -207,6 +212,7 @@ pub const File = struct {
|
||||
.macho => &(try MachO.openPath(allocator, sub_path, options)).base,
|
||||
.wasm => &(try Wasm.openPath(allocator, sub_path, options)).base,
|
||||
.c => &(try C.openPath(allocator, sub_path, options)).base,
|
||||
.spirv => return error.SpirVObjectFormatUnimplemented,
|
||||
.hex => return error.HexObjectFormatUnimplemented,
|
||||
.raw => return error.RawObjectFormatUnimplemented,
|
||||
};
|
||||
@ -595,6 +601,7 @@ pub const File = struct {
|
||||
macho,
|
||||
c,
|
||||
wasm,
|
||||
spirv,
|
||||
};
|
||||
|
||||
pub const ErrorFlags = struct {
|
||||
@ -605,6 +612,7 @@ pub const File = struct {
|
||||
pub const Coff = @import("link/Coff.zig");
|
||||
pub const Elf = @import("link/Elf.zig");
|
||||
pub const MachO = @import("link/MachO.zig");
|
||||
pub const SpirV = @import("link/SpirV.zig");
|
||||
pub const Wasm = @import("link/Wasm.zig");
|
||||
};
|
||||
|
||||
|
||||
@ -3597,6 +3597,7 @@ pub const CType = enum {
|
||||
.amdpal,
|
||||
.hermit,
|
||||
.hurd,
|
||||
.opencl,
|
||||
=> @panic("TODO specify the C integer and float type sizes for this OS"),
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user