diff options
| author | Robin Voetter <robin@voetter.nl> | 2023-05-29 03:30:38 +0200 |
|---|---|---|
| committer | Robin Voetter <robin@voetter.nl> | 2023-05-30 19:43:36 +0200 |
| commit | 96a66d14a16a89f759c1ed86a61cef710e3a7d05 (patch) | |
| tree | 433f348b1873fa3d65434ff1a76b676505665284 /src/codegen/spirv/Module.zig | |
| parent | 76aa1fffb7a06f0be0d803cb3379f3102c0b2590 (diff) | |
| download | zig-96a66d14a16a89f759c1ed86a61cef710e3a7d05.tar.gz zig-96a66d14a16a89f759c1ed86a61cef710e3a7d05.zip | |
spirv: TypeConstantCache
Diffstat (limited to 'src/codegen/spirv/Module.zig')
| -rw-r--r-- | src/codegen/spirv/Module.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/codegen/spirv/Module.zig b/src/codegen/spirv/Module.zig index 5e7e6508fa..d5c293d912 100644 --- a/src/codegen/spirv/Module.zig +++ b/src/codegen/spirv/Module.zig @@ -125,6 +125,8 @@ sections: struct { // OpModuleProcessed - skip for now. /// Annotation instructions (OpDecorate etc). annotations: Section = .{}, + /// Type and constant declarations that are generated by the TypeConstantCache. + types_and_constants: Section = .{}, /// Type declarations, constants, global variables /// Below this section, OpLine and OpNoLine is allowed. types_globals_constants: Section = .{}, @@ -182,6 +184,7 @@ pub fn deinit(self: *Module) void { self.sections.debug_strings.deinit(self.gpa); self.sections.debug_names.deinit(self.gpa); self.sections.annotations.deinit(self.gpa); + self.sections.types_and_constants(self.gpa); self.sections.types_globals_constants.deinit(self.gpa); self.sections.functions.deinit(self.gpa); @@ -334,6 +337,7 @@ pub fn flush(self: *Module, file: std.fs.File) !void { self.sections.debug_strings.toWords(), self.sections.debug_names.toWords(), self.sections.annotations.toWords(), + self.sections.types_constants.toWords(), self.sections.types_globals_constants.toWords(), globals.toWords(), self.sections.functions.toWords(), @@ -883,3 +887,12 @@ pub fn declareEntryPoint(self: *Module, decl_index: Decl.Index, name: []const u8 .name = try self.arena.dupe(u8, name), }); } + +pub fn debugName(self: *Module, target: IdResult, comptime fmt: []const u8, args: anytype) !void { + const name = try std.fmt.allocPrint(self.gpa, fmt, args); + defer self.gpa.free(name); + try debug.emit(self.gpa, .OpName, .{ + .target = result_id, + .name = name, + }); +} |
