authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2022-11-25 01:51:55+01:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2023-04-09 01:51:47+02:00
log6dc1fafe9882bdfb063c9bc02149c4a97fcaa2b5
tree60c6e7b4d5ac2812733e87d97c67a72e142f0aa2
parent17de4a88e9d494cfd7e07ab5277b5e335a2dc9e3
signaturelock-open Commit is signed but in an unrecognized format.

std: add generic target for spirv

This adds a general target for SPIR-V compilation. Previously there was not any target machine defined for SPIR-V. TODO is to reword the features for this target. We don't really need the full list of capabilities in the features, we should only put a few features here which we can actually use during code generation.

2 files changed, 10 insertions(+), 0 deletions(-)

lib/std/target.zig+2
......@@ -1329,6 +1329,7 @@ pub const Target = struct {
13291329 .amdgcn => comptime allCpusFromDecls(amdgpu.cpu),
13301330 .riscv32, .riscv64 => comptime allCpusFromDecls(riscv.cpu),
13311331 .sparc, .sparc64, .sparcel => comptime allCpusFromDecls(sparc.cpu),
1332 .spirv32, .spirv64 => comptime allCpusFromDecls(spirv.cpu),
13321333 .s390x => comptime allCpusFromDecls(s390x.cpu),
13331334 .x86, .x86_64 => comptime allCpusFromDecls(x86.cpu),
13341335 .xtensa => comptime allCpusFromDecls(xtensa.cpu),
......@@ -1392,6 +1393,7 @@ pub const Target = struct {
13921393 .amdgcn => &amdgpu.cpu.generic,
13931394 .riscv32 => &riscv.cpu.generic_rv32,
13941395 .riscv64 => &riscv.cpu.generic_rv64,
1396 .spirv32, .spirv64 => &spirv.cpu.generic,
13951397 .sparc, .sparcel => &sparc.cpu.generic,
13961398 .sparc64 => &sparc.cpu.v9, // 64-bit SPARC needs v9 as the baseline
13971399 .s390x => &s390x.cpu.generic,
lib/std/target/spirv.zig+8
......@@ -2081,3 +2081,11 @@ pub const all_features = blk: {
20812081 }
20822082 break :blk result;
20832083};
2084
2085pub const cpu = struct {
2086 pub const generic = CpuModel{
2087 .name = "generic",
2088 .llvm_name = "generic",
2089 .features = featureSet(&[_]Feature{}),
2090 };
2091};