aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2024-02-01 16:58:52 +0000
committerMatthew Lugg <mlugg@mlugg.co.uk>2024-02-02 11:02:03 +0000
commit9eda6ccefce370c76209ea50dd57fe65bfe25536 (patch)
treed5b4af496b8a6d1811788557d85e340ce26ef2bc /src/codegen/spirv.zig
parent5a3ae38f3b79a69cb6f4ad28934a51165cae2ef1 (diff)
downloadzig-9eda6ccefce370c76209ea50dd57fe65bfe25536.tar.gz
zig-9eda6ccefce370c76209ea50dd57fe65bfe25536.zip
InternPool: use separate key for slices
This change eliminates some problematic recursive logic in InternPool, and provides a safer API.
Diffstat (limited to 'src/codegen/spirv.zig')
-rw-r--r--src/codegen/spirv.zig18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig
index fd7d2ed8d3..6c058308df 100644
--- a/src/codegen/spirv.zig
+++ b/src/codegen/spirv.zig
@@ -855,18 +855,12 @@ const DeclGen = struct {
const int_ty = ty.intTagType(mod);
return try self.constant(int_ty, int_val, repr);
},
- .ptr => |ptr| {
- const ptr_ty = switch (ptr.len) {
- .none => ty,
- else => ty.slicePtrFieldType(mod),
- };
- const ptr_id = try self.constantPtr(ptr_ty, val);
- if (ptr.len == .none) {
- return ptr_id;
- }
-
- const len_id = try self.constant(Type.usize, Value.fromInterned(ptr.len), .indirect);
- return try self.constructStruct(
+ .ptr => return self.constantPtr(ty, val),
+ .slice => |slice| {
+ const ptr_ty = ty.slicePtrFieldType(mod);
+ const ptr_id = try self.constantPtr(ptr_ty, Value.fromInterned(slice.ptr));
+ const len_id = try self.constant(Type.usize, Value.fromInterned(slice.len), .indirect);
+ return self.constructStruct(
ty,
&.{ ptr_ty, Type.usize },
&.{ ptr_id, len_id },