diff options
| author | Robin Voetter <robin@voetter.nl> | 2022-12-01 23:26:02 +0100 |
|---|---|---|
| committer | Robin Voetter <robin@voetter.nl> | 2023-04-09 01:51:51 +0200 |
| commit | 34b98ee372f8974e21cd34b3ca7588b13d93e31a (patch) | |
| tree | efd4176707e500d7521fd90a9515ba24ee6e84c7 /src/codegen/spirv/Module.zig | |
| parent | f1229e0f00114e38001df8b57725de9c3e13a06d (diff) | |
| download | zig-34b98ee372f8974e21cd34b3ca7588b13d93e31a.tar.gz zig-34b98ee372f8974e21cd34b3ca7588b13d93e31a.zip | |
spirv: start lowering non-function decls
Start to lower decls which are not functions. These generate
an OpVariable instruction by which they can be used later on.
Diffstat (limited to 'src/codegen/spirv/Module.zig')
| -rw-r--r-- | src/codegen/spirv/Module.zig | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig index b9bae9972f..803276d78c 100644 --- a/src/codegen/spirv/Module.zig +++ b/src/codegen/spirv/Module.zig @@ -353,7 +353,8 @@ pub fn emitType(self: *Module, ty: Type) error{OutOfMemory}!IdResultType { const size_type = Type.initTag(.u32); const size_type_id = try self.resolveTypeId(size_type); - const length_id = try self.emitConstant(size_type_id, .{ .uint32 = info.length }); + const length_id = self.allocId(); + try self.emitConstant(size_type_id, length_id, .{ .uint32 = info.length }); try types.emit(self.gpa, .OpTypeArray, .{ .id_result = result_id, @@ -558,15 +559,14 @@ fn decorateStruct(self: *Module, target: IdRef, info: *const Type.Payload.Struct pub fn emitConstant( self: *Module, ty_id: spec.IdRef, + result_id: IdRef, value: spec.LiteralContextDependentNumber, -) !IdRef { - const result_id = self.allocId(); +) !void { try self.sections.types_globals_constants.emit(self.gpa, .OpConstant, .{ .id_result_type = ty_id, .id_result = result_id, .value = value, }); - return result_id; } /// Decorate a result-id. |
