diff --git a/src/codegen/spirv/Assembler.zig b/src/codegen/spirv/Assembler.zig index 6e77818fa51034795f7459cbc8e6ea61f63df9a8..3a35bc4db9931bb77796832e8c9df45fe58e0017 100644 --- a/src/codegen/spirv/Assembler.zig +++ b/src/codegen/spirv/Assembler.zig @@ -753,7 +753,7 @@ fn parseContextDependentNumber(self: *Assembler) !void { const tok = self.currentToken(); const result_type_ref = try self.resolveTypeRef(self.inst.operands.items[0].ref_id); - const result_type = self.spv.type_cache.keys()[result_type_ref]; + const result_type = self.spv.type_cache.keys()[@enumToInt(result_type_ref)]; switch (result_type.tag()) { .int => { const int = result_type.castTag(.int).?; diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig index 3562e87be49b3223c772d8e13d9c4209bf1be3c1..2b62bcaf0e1782522a3cbf3320fc1c41fb674c29 100644 --- a/src/codegen/spirv/Module.zig +++ b/src/codegen/spirv/Module.zig @@ -216,7 +216,7 @@ pub fn resolveType(self: *Module, ty: Type) !Type.Ref { result.value_ptr.* = try self.emitType(ty); } - return result.index; + return @intToEnum(Type.Ref, result.index); } pub fn resolveTypeId(self: *Module, ty: Type) !IdRef { @@ -226,12 +226,12 @@ pub fn resolveTypeId(self: *Module, ty: Type) !IdRef { /// Get the result-id of a particular type, by reference. Asserts type_ref is valid. pub fn typeResultId(self: Module, type_ref: Type.Ref) IdResultType { - return self.type_cache.values()[type_ref]; + return self.type_cache.values()[@enumToInt(type_ref)]; } /// Get the result-id of a particular type as IdRef, by Type.Ref. Asserts type_ref is valid. pub fn typeRefId(self: Module, type_ref: Type.Ref) IdRef { - return self.type_cache.values()[type_ref].toRef(); + return self.type_cache.values()[@enumToInt(type_ref)].toRef(); } /// Unconditionally emit a spir-v type into the appropriate section. diff --git a/src/codegen/spirv/type.zig b/src/codegen/spirv/type.zig index dc993b62ffb2c262a98d72c9829edb66130bb109..5ec013cb0a58489d4aa1aab76c077f95c7f7266e 100644 --- a/src/codegen/spirv/type.zig +++ b/src/codegen/spirv/type.zig @@ -11,7 +11,7 @@ pub const Type = extern union { ptr_otherwise: *Payload, /// A reference to another SPIR-V type. - pub const Ref = usize; + pub const Ref = enum(u32) { _ }; pub fn initTag(comptime small_tag: Tag) Type { comptime assert(@enumToInt(small_tag) < Tag.no_payload_count);