aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/spirv/Module.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2024-04-04 23:03:01 +0200
committerRobin Voetter <robin@voetter.nl>2024-04-06 13:37:39 +0200
commit188922a5448417d1939023b1eab7f70fa1953dde (patch)
treed636f03bb030b070bc2e14aba4844f2e9c61cd4e /src/codegen/spirv/Module.zig
parent42c7e752e1eae7663068e9c52ad77f7383d977e9 (diff)
downloadzig-188922a5448417d1939023b1eab7f70fa1953dde.tar.gz
zig-188922a5448417d1939023b1eab7f70fa1953dde.zip
spirv: remove cache usage for constants
Diffstat (limited to 'src/codegen/spirv/Module.zig')
-rw-r--r--src/codegen/spirv/Module.zig34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig
index 2d3a79ffc9..eb1b2d41a0 100644
--- a/src/codegen/spirv/Module.zig
+++ b/src/codegen/spirv/Module.zig
@@ -435,28 +435,22 @@ pub fn arrayType(self: *Module, len: u32, elem_ty_ref: CacheRef) !CacheRef {
} });
}
-pub fn constInt(self: *Module, ty_ref: CacheRef, value: anytype) !IdRef {
- const ty = self.cache.lookup(ty_ref).int_type;
- const Value = Cache.Key.Int.Value;
- return try self.resolveId(.{ .int = .{
- .ty = ty_ref,
- .value = switch (ty.signedness) {
- .signed => Value{ .int64 = @intCast(value) },
- .unsigned => Value{ .uint64 = @intCast(value) },
- },
- } });
-}
-
-pub fn constUndef(self: *Module, ty_ref: CacheRef) !IdRef {
- return try self.resolveId(.{ .undef = .{ .ty = ty_ref } });
-}
-
-pub fn constNull(self: *Module, ty_ref: CacheRef) !IdRef {
- return try self.resolveId(.{ .null = .{ .ty = ty_ref } });
+pub fn constUndef(self: *Module, ty_id: IdRef) !IdRef {
+ const result_id = self.allocId();
+ try self.sections.types_globals_constants.emit(self.gpa, .OpUndef, .{
+ .id_result_type = ty_id,
+ .id_result = result_id,
+ });
+ return result_id;
}
-pub fn constBool(self: *Module, ty_ref: CacheRef, value: bool) !IdRef {
- return try self.resolveId(.{ .bool = .{ .ty = ty_ref, .value = value } });
+pub fn constNull(self: *Module, ty_id: IdRef) !IdRef {
+ const result_id = self.allocId();
+ try self.sections.types_globals_constants.emit(self.gpa, .OpConstantNull, .{
+ .id_result_type = ty_id,
+ .id_result = result_id,
+ });
+ return result_id;
}
pub fn constComposite(self: *Module, ty_ref: CacheRef, members: []const IdRef) !IdRef {