authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2022-08-20 12:42:27+02:00
committergravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2022-10-12 20:34:41+02:00
log3392de87dcf516ed2e3fd1904372195bdc75c0eb
treeb87b51283d6a78c708de7a9ee75b4acabfcf0d24
parent5859d8458f919676be804835aaeb3ed844a67542
signaturelock-open Commit is signed but in an unrecognized format.

allow global/local/shared address spaces on amdgcn


2 files changed, 12 insertions(+), 2 deletions(-)

src/Sema.zig+4-2
...@@ -30303,13 +30303,15 @@ pub fn analyzeAddrspace(...@@ -30303,13 +30303,15 @@ pub fn analyzeAddrspace(
30303 const address_space = addrspace_tv.val.toEnum(std.builtin.AddressSpace);30303 const address_space = addrspace_tv.val.toEnum(std.builtin.AddressSpace);
30304 const target = sema.mod.getTarget();30304 const target = sema.mod.getTarget();
30305 const arch = target.cpu.arch;30305 const arch = target.cpu.arch;
30306 const is_gpu = arch == .nvptx or arch == .nvptx64;30306 const is_nv = arch == .nvptx or arch == .nvptx64;
30307 const is_gpu = is_nv or arch == .amdgcn;
3030730308
30308 const supported = switch (address_space) {30309 const supported = switch (address_space) {
30309 .generic => true,30310 .generic => true,
30310 .gs, .fs, .ss => (arch == .i386 or arch == .x86_64) and ctx == .pointer,30311 .gs, .fs, .ss => (arch == .i386 or arch == .x86_64) and ctx == .pointer,
30311 // TODO: check that .shared and .local are left uninitialized30312 // TODO: check that .shared and .local are left uninitialized
30312 .global, .param, .shared, .local => is_gpu,30313 .param => is_nv,
30314 .global, .shared, .local => is_gpu,
30313 .constant => is_gpu and (ctx == .constant),30315 .constant => is_gpu and (ctx == .constant),
30314 };30316 };
3031530317
src/codegen/llvm.zig+8
...@@ -2659,6 +2659,14 @@ pub const DeclGen = struct {...@@ -2659,6 +2659,14 @@ pub const DeclGen = struct {
2659 .local => llvm.address_space.nvptx.local,2659 .local => llvm.address_space.nvptx.local,
2660 else => unreachable,2660 else => unreachable,
2661 },2661 },
2662 .amdgcn => switch (address_space) {
2663 .generic => llvm.address_space.flat,
2664 .global => llvm.address_space.amdgpu.global,
2665 .constant => llvm.address_space.amdgpu.constant,
2666 .shared => llvm.address_space.amdgpu.local,
2667 .local => llvm.address_space.amdgpu.private,
2668 else => unreachable,
2669 }.
2662 else => switch (address_space) {2670 else => switch (address_space) {
2663 .generic => llvm.address_space.default,2671 .generic => llvm.address_space.default,
2664 else => unreachable,2672 else => unreachable,