aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2024-03-31 19:05:54 +0200
committerRobin Voetter <robin@voetter.nl>2024-04-06 13:37:37 +0200
commit42c7e752e1eae7663068e9c52ad77f7383d977e9 (patch)
treea99443bbee26923de3fb0097b77b91e573232d33 /src/codegen/spirv.zig
parent39420838061a9049fbc889212836a9d4d2ab9af4 (diff)
downloadzig-42c7e752e1eae7663068e9c52ad77f7383d977e9.tar.gz
zig-42c7e752e1eae7663068e9c52ad77f7383d977e9.zip
spirv: id range helper
This allows us to more sanely allocate a continuous range of result-ids, and avoids a bunch of nasty casting code in a few places. Its currently not used very often, but will be useful in the future.
Diffstat (limited to 'src/codegen/spirv.zig')
-rw-r--r--src/codegen/spirv.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig
index a47497d89d..f2b630b331 100644
--- a/src/codegen/spirv.zig
+++ b/src/codegen/spirv.zig
@@ -5440,7 +5440,7 @@ const DeclGen = struct {
};
// First, pre-allocate the labels for the cases.
- const first_case_label = self.spv.allocIds(num_cases);
+ const case_labels = self.spv.allocIds(num_cases);
// We always need the default case - if zig has none, we will generate unreachable there.
const default = self.spv.allocId();
@@ -5471,7 +5471,7 @@ const DeclGen = struct {
const case_body = self.air.extra[case.end + items.len ..][0..case.data.body_len];
extra_index = case.end + case.data.items_len + case_body.len;
- const label: IdRef = @enumFromInt(@intFromEnum(first_case_label) + case_i);
+ const label = case_labels.at(case_i);
for (items) |item| {
const value = (try self.air.value(item, mod)) orelse unreachable;
@@ -5511,7 +5511,7 @@ const DeclGen = struct {
const case_body: []const Air.Inst.Index = @ptrCast(self.air.extra[case.end + items.len ..][0..case.data.body_len]);
extra_index = case.end + case.data.items_len + case_body.len;
- const label: IdResult = @enumFromInt(@intFromEnum(first_case_label) + case_i);
+ const label = case_labels.at(case_i);
try self.beginSpvBlock(label);