| author | |
| committer | |
| log | 02c138fe7011346ebab5e4b24ba0f8575bb52173 |
| tree | 5f59ca5e6e25d700dd3aa9d1ea1f9be577bdb1a6 |
| parent | b2b87b590011d8df52874e3f9bd1f88d1b0189d1 |
6 files changed, 48 insertions(+), 5 deletions(-)
lib/std/target.zig+15-3| ... | ... | @@ -57,7 +57,9 @@ pub const Target = struct { |
| 57 | 57 | wasi, |
| 58 | 58 | emscripten, |
| 59 | 59 | uefi, |
| 60 | opencl, // SPIR-V on OpenCL | |
| 60 | opencl, | |
| 61 | glsl450, | |
| 62 | vulkan, | |
| 61 | 63 | other, |
| 62 | 64 | |
| 63 | 65 | pub fn isDarwin(tag: Tag) bool { |
| ... | ... | @@ -249,7 +251,9 @@ pub const Target = struct { |
| 249 | 251 | .wasi, |
| 250 | 252 | .emscripten, |
| 251 | 253 | .uefi, |
| 252 | .opencl, | |
| 254 | .opencl, // TODO: OpenCL versions | |
| 255 | .glsl450, // TODO: GLSL versions | |
| 256 | .vulkan, | |
| 253 | 257 | .other, |
| 254 | 258 | => return .{ .none = {} }, |
| 255 | 259 | |
| ... | ... | @@ -406,6 +410,8 @@ pub const Target = struct { |
| 406 | 410 | .emscripten, |
| 407 | 411 | .uefi, |
| 408 | 412 | .opencl, |
| 413 | .glsl450, | |
| 414 | .vulkan, | |
| 409 | 415 | .other, |
| 410 | 416 | => false, |
| 411 | 417 | }; |
| ... | ... | @@ -497,7 +503,9 @@ pub const Target = struct { |
| 497 | 503 | .wasi, |
| 498 | 504 | .emscripten, |
| 499 | 505 | => return .musl, |
| 500 | .opencl, // TODO: Where should this go? | |
| 506 | .opencl, // TODO: SPIR-V ABIs with Linkage capability | |
| 507 | .glsl450, | |
| 508 | .vulkan, | |
| 501 | 509 | => return .none, |
| 502 | 510 | } |
| 503 | 511 | } |
| ... | ... | @@ -1367,6 +1375,8 @@ pub const Target = struct { |
| 1367 | 1375 | .windows, |
| 1368 | 1376 | .emscripten, |
| 1369 | 1377 | .opencl, |
| 1378 | .glsl450, | |
| 1379 | .vulkan, | |
| 1370 | 1380 | .other, |
| 1371 | 1381 | => return false, |
| 1372 | 1382 | else => return true, |
| ... | ... | @@ -1547,6 +1557,8 @@ pub const Target = struct { |
| 1547 | 1557 | .emscripten, |
| 1548 | 1558 | .wasi, |
| 1549 | 1559 | .opencl, |
| 1560 | .glsl450, | |
| 1561 | .vulkan, | |
| 1550 | 1562 | .other, |
| 1551 | 1563 | => return result, |
| 1552 | 1564 |
lib/std/zig/cross_target.zig+4| ... | ... | @@ -131,6 +131,8 @@ pub const CrossTarget = struct { |
| 131 | 131 | .emscripten, |
| 132 | 132 | .uefi, |
| 133 | 133 | .opencl, |
| 134 | .glsl450, | |
| 135 | .vulkan, | |
| 134 | 136 | .other, |
| 135 | 137 | => { |
| 136 | 138 | self.os_version_min = .{ .none = {} }; |
| ... | ... | @@ -732,6 +734,8 @@ pub const CrossTarget = struct { |
| 732 | 734 | .emscripten, |
| 733 | 735 | .uefi, |
| 734 | 736 | .opencl, |
| 737 | .glsl450, | |
| 738 | .vulkan, | |
| 735 | 739 | .other, |
| 736 | 740 | => return error.InvalidOperatingSystemVersion, |
| 737 | 741 |
src/codegen/llvm.zig+5| ... | ... | @@ -69,6 +69,8 @@ pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 { |
| 69 | 69 | .renderscript64 => "renderscript64", |
| 70 | 70 | .ve => "ve", |
| 71 | 71 | .spu_2 => return error.LLVMBackendDoesNotSupportSPUMarkII, |
| 72 | .spirv32 => return error.LLVMBackendDoesNotSupportSPIRV, | |
| 73 | .spirv64 => return error.LLVMBackendDoesNotSupportSPIRV, | |
| 72 | 74 | }; |
| 73 | 75 | // TODO Add a sub-arch for some architectures depending on CPU features. |
| 74 | 76 | |
| ... | ... | @@ -109,6 +111,9 @@ pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 { |
| 109 | 111 | .wasi => "wasi", |
| 110 | 112 | .emscripten => "emscripten", |
| 111 | 113 | .uefi => "windows", |
| 114 | .opencl => return error.LLVMBackendDoesNotSupportOpenCL, | |
| 115 | .glsl450 => return error.LLVMBackendDoesNotSupportGLSL450, | |
| 116 | .vulkan => return error.LLVMBackendDoesNotSupportVulkan, | |
| 112 | 117 | .other => "unknown", |
| 113 | 118 | }; |
| 114 | 119 |
src/link/SpirV.zig+20| ... | ... | @@ -12,6 +12,8 @@ const trace = @import("../tracy.zig").trace; |
| 12 | 12 | const build_options = @import("build_options"); |
| 13 | 13 | const spec = @import("../codegen/spirv/spec.zig"); |
| 14 | 14 | |
| 15 | //! SPIR-V Documentation: https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html | |
| 16 | ||
| 15 | 17 | pub const FnData = struct { |
| 16 | 18 | id: ?u32 = null, |
| 17 | 19 | code: std.ArrayListUnmanaged(u32) = .{}, |
| ... | ... | @@ -32,6 +34,22 @@ pub fn createEmpty(gpa: *Allocator, options: link.Options) !*SpirV { |
| 32 | 34 | .allocator = gpa, |
| 33 | 35 | }, |
| 34 | 36 | }; |
| 37 | ||
| 38 | // TODO: Figure out where to put all of these | |
| 39 | switch (options.target.cpu.arch) { | |
| 40 | .spirv32, .spirv64 => {}, | |
| 41 | else => return error.TODOArchNotSupported, | |
| 42 | } | |
| 43 | ||
| 44 | switch (options.target.os.tag) { | |
| 45 | .opencl, .glsl450, .vulkan => {}, | |
| 46 | else => return error.TODOOsNotSupported, | |
| 47 | } | |
| 48 | ||
| 49 | if (options.target.abi != .none) { | |
| 50 | return error.TODOAbiNotSupported; | |
| 51 | } | |
| 52 | ||
| 35 | 53 | return spirv; |
| 36 | 54 | } |
| 37 | 55 | |
| ... | ... | @@ -119,6 +137,8 @@ pub fn flushModule(self: *SpirV, comp: *Compilation) !void { |
| 119 | 137 | switch (decl.typed_value) { |
| 120 | 138 | .most_recent => |tvm| { |
| 121 | 139 | const fn_data = &decl.fn_link.spirv; |
| 140 | ||
| 141 | // TODO: This could probably be more efficient. | |
| 122 | 142 | for (fn_data.code.items) |word| { |
| 123 | 143 | try writer.writeIntLittle(u32, word); |
| 124 | 144 | } |
src/target.zig+2-2| ... | ... | @@ -189,7 +189,7 @@ pub fn supportsStackProbing(target: std.Target) bool { |
| 189 | 189 | |
| 190 | 190 | pub fn osToLLVM(os_tag: std.Target.Os.Tag) llvm.OSType { |
| 191 | 191 | return switch (os_tag) { |
| 192 | .freestanding, .other => .UnknownOS, | |
| 192 | .freestanding, .other, .opencl, .glsl450, .vulkan => .UnknownOS, | |
| 193 | 193 | .windows, .uefi => .Win32, |
| 194 | 194 | .ananas => .Ananas, |
| 195 | 195 | .cloudabi => .CloudABI, |
| ... | ... | @@ -280,7 +280,7 @@ pub fn archToLLVM(arch_tag: std.Target.Cpu.Arch) llvm.ArchType { |
| 280 | 280 | .renderscript32 => .renderscript32, |
| 281 | 281 | .renderscript64 => .renderscript64, |
| 282 | 282 | .ve => .ve, |
| 283 | .spu_2 => .UnknownArch, | |
| 283 | .spu_2, .spirv32, .spirv64 => .UnknownArch, | |
| 284 | 284 | }; |
| 285 | 285 | } |
| 286 | 286 |
src/type.zig+2| ... | ... | @@ -3598,6 +3598,8 @@ pub const CType = enum { |
| 3598 | 3598 | .hermit, |
| 3599 | 3599 | .hurd, |
| 3600 | 3600 | .opencl, |
| 3601 | .glsl450, | |
| 3602 | .vulkan, | |
| 3601 | 3603 | => @panic("TODO specify the C integer and float type sizes for this OS"), |
| 3602 | 3604 | } |
| 3603 | 3605 | } |