zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 6dc1fafe9882bdfb063c9bc02149c4a97fcaa2b5 (tree)
parent 17de4a88e9d494cfd7e07ab5277b5e335a2dc9e3
Author: Robin Voetter <robin@voetter.nl>
Date:   Fri, 25 Nov 2022 01:51:55 +0100

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.

Diffstat:
Mlib/std/target.zig | 2++
Mlib/std/target/spirv.zig | 8++++++++
2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/lib/std/target.zig b/lib/std/target.zig @@ -1329,6 +1329,7 @@ pub const Target = struct { .amdgcn => comptime allCpusFromDecls(amdgpu.cpu), .riscv32, .riscv64 => comptime allCpusFromDecls(riscv.cpu), .sparc, .sparc64, .sparcel => comptime allCpusFromDecls(sparc.cpu), + .spirv32, .spirv64 => comptime allCpusFromDecls(spirv.cpu), .s390x => comptime allCpusFromDecls(s390x.cpu), .x86, .x86_64 => comptime allCpusFromDecls(x86.cpu), .xtensa => comptime allCpusFromDecls(xtensa.cpu), @@ -1392,6 +1393,7 @@ pub const Target = struct { .amdgcn => &amdgpu.cpu.generic, .riscv32 => &riscv.cpu.generic_rv32, .riscv64 => &riscv.cpu.generic_rv64, + .spirv32, .spirv64 => &spirv.cpu.generic, .sparc, .sparcel => &sparc.cpu.generic, .sparc64 => &sparc.cpu.v9, // 64-bit SPARC needs v9 as the baseline .s390x => &s390x.cpu.generic, diff --git a/lib/std/target/spirv.zig b/lib/std/target/spirv.zig @@ -2081,3 +2081,11 @@ pub const all_features = blk: { } break :blk result; }; + +pub const cpu = struct { + pub const generic = CpuModel{ + .name = "generic", + .llvm_name = "generic", + .features = featureSet(&[_]Feature{}), + }; +};