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