spirv: make constant handle float, errorset, errorunion

This is in preparation of removing indirect lowering again. Also
modifies constant() to accept a repr so that both direct as well
as indirect representations can be generated. Indirect is not yet
used, but will be used for globals.
This commit is contained in:
Robin Voetter
2023-05-20 18:02:30 +02:00
parent 65157d30ab
commit c92cc5798f
2 changed files with 77 additions and 14 deletions

View File

@@ -774,6 +774,16 @@ pub fn changePtrStorageClass(self: *Module, ptr_ty_ref: Type.Ref, new_storage_cl
return try self.resolveType(Type.initPayload(&payload.base));
}
pub fn constComposite(self: *Module, ty_ref: Type.Ref, members: []const IdRef) !IdRef {
const result_id = self.allocId();
try self.sections.types_globals_constants.emit(self.gpa, .OpSpecConstantComposite, .{
.id_result_type = self.typeId(ty_ref),
.id_result = result_id,
.constituents = members,
});
return result_id;
}
pub fn emitConstant(
self: *Module,
ty_id: IdRef,