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/Module.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/Module.zig')
| -rw-r--r-- | src/codegen/spirv/Module.zig | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig index 2b62bcaf0e..6998d13f42 100644 --- a/src/codegen/spirv/Module.zig +++ b/src/codegen/spirv/Module.zig @@ -250,21 +250,30 @@ pub fn emitType(self: *Module, ty: Type) !IdResultType { switch (ty.tag()) { .void => try types.emit(self.gpa, .OpTypeVoid, result_id_operand), .bool => try types.emit(self.gpa, .OpTypeBool, result_id_operand), - .int => { - const signedness: spec.LiteralInteger = switch (ty.payload(.int).signedness) { + .u8, + .u16, + .u32, + .u64, + .i8, + .i16, + .i32, + .i64, + .int, + => { + const signedness: spec.LiteralInteger = switch (ty.intSignedness()) { .unsigned => 0, .signed => 1, }; try types.emit(self.gpa, .OpTypeInt, .{ .id_result = result_id, - .width = ty.payload(.int).width, + .width = ty.intFloatBits(), .signedness = signedness, }); }, - .float => try types.emit(self.gpa, .OpTypeFloat, .{ + .f16, .f32, .f64 => try types.emit(self.gpa, .OpTypeFloat, .{ .id_result = result_id, - .width = ty.payload(.float).width, + .width = ty.intFloatBits(), }), .vector => try types.emit(self.gpa, .OpTypeVector, .{ .id_result = result_id, |
