diff options
| author | Robin Voetter <robin@voetter.nl> | 2022-11-26 12:23:07 +0100 |
|---|---|---|
| committer | Robin Voetter <robin@voetter.nl> | 2023-04-09 01:51:48 +0200 |
| commit | 3eafe3033ef83e5b34e3ccbd6e803c7a046df390 (patch) | |
| tree | e62c8d20a421c95b7d145ea3da1d3a5c2cc0602d /src/codegen/spirv.zig | |
| parent | 5826a8a0640d79de83be131434ec91315e75087b (diff) | |
| download | zig-3eafe3033ef83e5b34e3ccbd6e803c7a046df390.tar.gz zig-3eafe3033ef83e5b34e3ccbd6e803c7a046df390.zip | |
spirv: improve storage efficiency for integer and float types
In practice there are only a few variations of these types allowed, so it
kind-of makes sense to write them all out. Because the types are hashed this
does not actually save all that many bytes in the long run, though. Perhaps
some of these types should be pre-registered?
Diffstat (limited to 'src/codegen/spirv.zig')
| -rw-r--r-- | src/codegen/spirv.zig | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index 93bb7b19f8..22045a282d 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -451,12 +451,7 @@ pub const DeclGen = struct { return self.todo("Implement {s} composite int type of {} bits", .{ @tagName(signedness), bits }); }; - const payload = try self.spv.arena.create(SpvType.Payload.Int); - payload.* = .{ - .width = backing_bits, - .signedness = signedness, - }; - return try self.spv.resolveType(SpvType.initPayload(&payload.base)); + return try self.spv.resolveType(try SpvType.int(self.spv.arena, signedness, backing_bits)); } /// Turn a Zig type into a SPIR-V Type, and return a reference to it. @@ -495,11 +490,7 @@ pub const DeclGen = struct { return self.fail("Floating point width of {} bits is not supported for the current SPIR-V feature set", .{bits}); } - const payload = try self.spv.arena.create(SpvType.Payload.Float); - payload.* = .{ - .width = bits, - }; - return try self.spv.resolveType(SpvType.initPayload(&payload.base)); + return try self.spv.resolveType(SpvType.float(bits)); }, .Fn => { // TODO: Put this somewhere in Sema.zig |
