Commit a3d77bdba9
Changed files (2)
src
codegen
spirv
link
src/codegen/spirv/Module.zig
@@ -103,15 +103,12 @@ pub const EntryPoint = struct {
/// The declaration that should be exported.
decl_index: Decl.Index,
/// The name of the kernel to be exported.
- name: []const u8,
+ name: CacheString,
};
/// A general-purpose allocator which may be used to allocate resources for this module
gpa: Allocator,
-/// An arena allocator used to store things that have the same lifetime as this module.
-arena: Allocator,
-
/// Module layout, according to SPIR-V Spec section 2.4, "Logical Layout of a Module".
sections: struct {
/// Capability instructions
@@ -176,10 +173,9 @@ globals: struct {
section: Section = .{},
} = .{},
-pub fn init(gpa: Allocator, arena: Allocator) Module {
+pub fn init(gpa: Allocator) Module {
return .{
.gpa = gpa,
- .arena = arena,
.next_result_id = 1, // 0 is an invalid SPIR-V result id, so start counting at 1.
};
}
@@ -321,7 +317,7 @@ fn entryPoints(self: *Module) !Section {
try entry_points.emit(self.gpa, .OpEntryPoint, .{
.execution_model = .Kernel,
.entry_point = entry_point_id,
- .name = entry_point.name,
+ .name = self.cache.getString(entry_point.name).?,
.interface = interface.items,
});
}
@@ -641,7 +637,7 @@ pub fn endGlobal(self: *Module, global_index: Decl.Index, begin_inst: u32, resul
pub fn declareEntryPoint(self: *Module, decl_index: Decl.Index, name: []const u8) !void {
try self.entry_points.append(self.gpa, .{
.decl_index = decl_index,
- .name = try self.arena.dupe(u8, name),
+ .name = try self.resolveString(name),
});
}
src/link/SpirV.zig
@@ -46,7 +46,6 @@ const IdResult = spec.IdResult;
base: link.File,
spv: SpvModule,
-spv_arena: ArenaAllocator,
decl_link: codegen.DeclLinkMap,
anon_decl_link: codegen.AnonDeclLinkMap,
@@ -60,11 +59,10 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*SpirV {
.allocator = gpa,
},
.spv = undefined,
- .spv_arena = ArenaAllocator.init(gpa),
.decl_link = codegen.DeclLinkMap.init(self.base.allocator),
.anon_decl_link = codegen.AnonDeclLinkMap.init(self.base.allocator),
};
- self.spv = SpvModule.init(gpa, self.spv_arena.allocator());
+ self.spv = SpvModule.init(gpa);
errdefer self.deinit();
// TODO: Figure out where to put all of these
@@ -102,7 +100,6 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option
pub fn deinit(self: *SpirV) void {
self.spv.deinit();
- self.spv_arena.deinit();
self.decl_link.deinit();
self.anon_decl_link.deinit();
}
@@ -196,7 +193,9 @@ pub fn flushModule(self: *SpirV, comp: *Compilation, prog_node: *std.Progress.No
// executor. This is not really an important thing though, so we can just dump it in any old
// nonsemantic instruction. For now, just put it in OpSourceExtension with a special name.
- var error_info = std.ArrayList(u8).init(self.spv.arena);
+ var error_info = std.ArrayList(u8).init(self.spv.gpa);
+ defer error_info.deinit();
+
try error_info.appendSlice("zig_errors");
const module = self.base.options.module.?;
for (module.global_error_set.keys()) |name_nts| {