aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv/Module.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2022-12-10 01:25:28 +0100
committerRobin Voetter <robin@voetter.nl>2023-04-09 01:51:52 +0200
commit3c7f93aa69e495820448a17869bd4663ed396ff2 (patch)
tree960fe85215ded196739493e83dc903905102ff61 /src/codegen/spirv/Module.zig
parentfbe5f0c3459484babcf3d4ba6fe4901612a409bb (diff)
downloadzig-3c7f93aa69e495820448a17869bd4663ed396ff2.tar.gz
zig-3c7f93aa69e495820448a17869bd4663ed396ff2.zip
spirv: generic global pointers
Similar to function locals, taking the address of a global that does not have an explicit address space assigned to it should result in a generic pointer, not a global pointer. Also similar to function locals, they cannot be generated into the generic storage class, and so are generated into the global storage class and then cast to a generic pointer, using OpSpecConstantOp. Note that using OpSpecConstantOp results is only allowed by a hand full of other OpSpecConstant instructions - which is why we generate constant structs using OpSpecConstantComposite: These may use OpVariable and OpSpecConstantOp results, while OpConstantComposite may not.
Diffstat (limited to 'src/codegen/spirv/Module.zig')
-rw-r--r--src/codegen/spirv/Module.zig9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig
index 803276d78c..ff7ae29993 100644
--- a/src/codegen/spirv/Module.zig
+++ b/src/codegen/spirv/Module.zig
@@ -556,9 +556,16 @@ fn decorateStruct(self: *Module, target: IdRef, info: *const Type.Payload.Struct
}
}
+pub fn changePtrStorageClass(self: *Module, ptr_ty_ref: Type.Ref, new_storage_class: spec.StorageClass) !Type.Ref {
+ const payload = try self.arena.create(Type.Payload.Pointer);
+ payload.* = self.typeRefType(ptr_ty_ref).payload(.pointer).*;
+ payload.storage_class = new_storage_class;
+ return try self.resolveType(Type.initPayload(&payload.base));
+}
+
pub fn emitConstant(
self: *Module,
- ty_id: spec.IdRef,
+ ty_id: IdRef,
result_id: IdRef,
value: spec.LiteralContextDependentNumber,
) !void {