| ... | ... | @@ -38,7 +38,7 @@ pub const FnData = struct { |
| 38 | 38 | base: link.File, |
| 39 | 39 | |
| 40 | 40 | // TODO: Does this file need to support multiple independent modules? |
| 41 | | spirv_module: codegen.SPIRVModule = .{}, |
| 41 | spirv_module: codegen.SPIRVModule, |
| 42 | 42 | |
| 43 | 43 | pub fn createEmpty(gpa: *Allocator, options: link.Options) !*SpirV { |
| 44 | 44 | const spirv = try gpa.create(SpirV); |
| ... | ... | @@ -49,6 +49,7 @@ pub fn createEmpty(gpa: *Allocator, options: link.Options) !*SpirV { |
| 49 | 49 | .file = null, |
| 50 | 50 | .allocator = gpa, |
| 51 | 51 | }, |
| 52 | .spirv_module = codegen.SPIRVModule.init(gpa), |
| 52 | 53 | }; |
| 53 | 54 | |
| 54 | 55 | // TODO: Figure out where to put all of these |
| ... | ... | @@ -87,6 +88,7 @@ pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Optio |
| 87 | 88 | } |
| 88 | 89 | |
| 89 | 90 | pub fn deinit(self: *SpirV) void { |
| 91 | self.spirv_module.deinit(); |
| 90 | 92 | } |
| 91 | 93 | |
| 92 | 94 | pub fn updateDecl(self: *SpirV, module: *Module, decl: *Module.Decl) !void { |
| ... | ... | @@ -116,9 +118,12 @@ pub fn updateDeclExports( |
| 116 | 118 | ) !void {} |
| 117 | 119 | |
| 118 | 120 | pub fn freeDecl(self: *SpirV, decl: *Module.Decl) void { |
| 119 | | decl.fn_link.spirv.code.deinit(self.base.allocator); |
| 121 | var fn_data = decl.fn_link.spirv; |
| 122 | fn_data.code.deinit(self.base.allocator); |
| 123 | if (fn_data.id) |id| self.spirv_module.freeId(id); |
| 120 | 124 | decl.fn_link.spirv = undefined; |
| 121 | 125 | } |
| 126 | |
| 122 | 127 | pub fn flush(self: *SpirV, comp: *Compilation) !void { |
| 123 | 128 | if (build_options.have_llvm and self.base.options.use_lld) { |
| 124 | 129 | return error.LLD_LinkingIsTODO_ForSpirV; // TODO: LLD Doesn't support SpirV at all. |
| ... | ... | @@ -137,8 +142,8 @@ pub fn flushModule(self: *SpirV, comp: *Compilation) !void { |
| 137 | 142 | var binary = std.ArrayList(u32).init(self.base.allocator); |
| 138 | 143 | defer binary.deinit(); |
| 139 | 144 | |
| 140 | | // Note: The order of adding functions to the final binary |
| 141 | | // follows the SPIR-V logical moduel format! |
| 145 | // Note: The order of adding sections to the final binary |
| 146 | // follows the SPIR-V logical module format! |
| 142 | 147 | |
| 143 | 148 | try binary.appendSlice(&[_]u32{ |
| 144 | 149 | spec.magic_number, |