authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-17 05:42:03+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-17 06:01:45+02:00
log156fac4665b8084d54970d4a94b640ef94ec6160
treed45e1f2484673d0347ea5286c9467c7100b0a193
parent9dd1d03c94fe7df997d13686dccdab2ff7420770
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

llvm: update data layout strings for spirv


3 files changed, 13 insertions(+), 23 deletions(-)

lib/std/zig/llvm/Builder.zig+6-3
......@@ -542,10 +542,13 @@ pub const DataLayout = struct {
542542 "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
543543 },
544544 .spirv32 => switch (target.os.tag) {
545 .vulkan, .opengl => "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1",
546 else => "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1",
545 .vulkan, .opengl => "e-ve-i64:64-n8:16:32:64-G10",
546 else => "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1",
547547 },
548 .spirv64 => "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1",
548 .spirv64 => if (target.os.tag == .amdhsa)
549 "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n32:64-S32-G1-P4-A0"
550 else
551 "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1",
549552 .wasm32 => if (target.os.tag == .emscripten)
550553 "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-f128:64-n32:64-S128-ni:1:10:20"
551554 else
src/codegen/llvm.zig-20
......@@ -4452,26 +4452,6 @@ pub fn toLlvmAddressSpace(address_space: std.lang.AddressSpace, target: *const s
44524452 };
44534453}
44544454
4455/// On some targets, global values that are in the generic address space must be generated into a
4456/// different address space, and then cast back to the generic address space.
4457fn llvmDefaultGlobalAddressSpace(target: *const std.Target) Builder.AddrSpace {
4458 return switch (target.cpu.arch) {
4459 // On amdgcn, globals must be explicitly allocated and uploaded so that the program can access
4460 // them.
4461 .amdgcn => Builder.AddrSpace.amdgpu.global,
4462 else => .default,
4463 };
4464}
4465
4466/// Return the actual address space that a value should be stored in if its a global address space.
4467/// When a value is placed in the resulting address space, it needs to be cast back into wanted_address_space.
4468fn toLlvmGlobalAddressSpace(wanted_address_space: std.lang.AddressSpace, target: *const std.Target) Builder.AddrSpace {
4469 return switch (wanted_address_space) {
4470 .generic => llvmDefaultGlobalAddressSpace(target),
4471 else => |as| toLlvmAddressSpace(as, target),
4472 };
4473}
4474
44754455/// We need to insert extra padding if LLVM's isn't enough.
44764456/// However we don't want to ever call LLVMABIAlignmentOfType or
44774457/// LLVMABISizeOfType because these functions will trip assertions
test/llvm_targets.zig+7
......@@ -260,6 +260,13 @@ const targets = [_]std.Target.Query{
260260 .{ .cpu_arch = .sparc64, .os_tag = .openbsd, .abi = .none },
261261 .{ .cpu_arch = .sparc64, .os_tag = .rtems, .abi = .none },
262262
263 // .{ .cpu_arch = .spirv32, .os_tag = .opencl, .abi = .none },
264 // .{ .cpu_arch = .spirv32, .os_tag = .opengl, .abi = .none },
265 // .{ .cpu_arch = .spirv32, .os_tag = .vulkan, .abi = .none },
266 // .{ .cpu_arch = .spirv64, .os_tag = .amdhsa, .abi = .none },
267 // .{ .cpu_arch = .spirv64, .os_tag = .opencl, .abi = .none },
268 // .{ .cpu_arch = .spirv64, .os_tag = .vulkan, .abi = .none },
269
263270 .{ .cpu_arch = .thumb, .os_tag = .freestanding, .abi = .eabi },
264271 .{ .cpu_arch = .thumb, .os_tag = .freestanding, .abi = .eabihf },
265272 .{ .cpu_arch = .thumb, .os_tag = .fuchsia, .abi = .eabihf },