diff options
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/c.zig | 7 | ||||
| -rw-r--r-- | src/codegen/llvm.zig | 26 | ||||
| -rw-r--r-- | src/codegen/spirv.zig | 4 |
3 files changed, 19 insertions, 18 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 11c899bdd2..f54ae7f76d 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -163,14 +163,14 @@ pub const Object = struct { /// This data is available both when outputting .c code and when outputting an .h file. pub const DeclGen = struct { - gpa: *std.mem.Allocator, + gpa: std.mem.Allocator, module: *Module, decl: *Decl, fwd_decl: std.ArrayList(u8), error_msg: ?*Module.ErrorMsg, /// The key of this map is Type which has references to typedefs_arena. typedefs: TypedefMap, - typedefs_arena: *std.mem.Allocator, + typedefs_arena: std.mem.Allocator, fn fail(dg: *DeclGen, comptime format: []const u8, args: anytype) error{ AnalysisFail, OutOfMemory } { @setCold(true); @@ -390,6 +390,7 @@ pub const DeclGen = struct { // Fall back to generic implementation. var arena = std.heap.ArenaAllocator.init(dg.module.gpa); defer arena.deinit(); + const arena_allocator = arena.allocator(); try writer.writeAll("{"); var index: usize = 0; @@ -397,7 +398,7 @@ pub const DeclGen = struct { const elem_ty = ty.elemType(); while (index < len) : (index += 1) { if (index != 0) try writer.writeAll(","); - const elem_val = try val.elemValue(&arena.allocator, index); + const elem_val = try val.elemValue(arena_allocator, index); try dg.renderValue(writer, elem_ty, elem_val); } if (ty.sentinel()) |sentinel_val| { diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 21fa0187e3..4600c2e07e 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -23,7 +23,7 @@ const LazySrcLoc = Module.LazySrcLoc; const Error = error{ OutOfMemory, CodegenFail }; -pub fn targetTriple(allocator: *Allocator, target: std.Target) ![:0]u8 { +pub fn targetTriple(allocator: Allocator, target: std.Target) ![:0]u8 { const llvm_arch = switch (target.cpu.arch) { .arm => "arm", .armeb => "armeb", @@ -190,14 +190,14 @@ pub const Object = struct { std.hash_map.default_max_load_percentage, ); - pub fn create(gpa: *Allocator, sub_path: []const u8, options: link.Options) !*Object { + pub fn create(gpa: Allocator, sub_path: []const u8, options: link.Options) !*Object { const obj = try gpa.create(Object); errdefer gpa.destroy(obj); obj.* = try Object.init(gpa, sub_path, options); return obj; } - pub fn init(gpa: *Allocator, sub_path: []const u8, options: link.Options) !Object { + pub fn init(gpa: Allocator, sub_path: []const u8, options: link.Options) !Object { const context = llvm.Context.create(); errdefer context.dispose(); @@ -287,7 +287,7 @@ pub const Object = struct { }; } - pub fn deinit(self: *Object, gpa: *Allocator) void { + pub fn deinit(self: *Object, gpa: Allocator) void { self.target_machine.dispose(); self.llvm_module.dispose(); self.context.dispose(); @@ -297,13 +297,13 @@ pub const Object = struct { self.* = undefined; } - pub fn destroy(self: *Object, gpa: *Allocator) void { + pub fn destroy(self: *Object, gpa: Allocator) void { self.deinit(gpa); gpa.destroy(self); } fn locPath( - arena: *Allocator, + arena: Allocator, opt_loc: ?Compilation.EmitLoc, cache_directory: Compilation.Directory, ) !?[*:0]u8 { @@ -331,7 +331,7 @@ pub const Object = struct { var arena_allocator = std.heap.ArenaAllocator.init(comp.gpa); defer arena_allocator.deinit(); - const arena = &arena_allocator.allocator; + const arena = arena_allocator.allocator(); const mod = comp.bin_file.options.module.?; const cache_dir = mod.zig_cache_artifact_directory; @@ -554,7 +554,7 @@ pub const DeclGen = struct { object: *Object, module: *Module, decl: *Module.Decl, - gpa: *Allocator, + gpa: Allocator, err_msg: ?*Module.ErrorMsg, fn todo(self: *DeclGen, comptime format: []const u8, args: anytype) Error { @@ -779,7 +779,7 @@ pub const DeclGen = struct { // The Type memory is ephemeral; since we want to store a longer-lived // reference, we need to copy it here. - gop.key_ptr.* = try t.copy(&dg.object.type_map_arena.allocator); + gop.key_ptr.* = try t.copy(dg.object.type_map_arena.allocator()); const opaque_obj = t.castTag(.@"opaque").?.data; const name = try opaque_obj.getFullyQualifiedName(gpa); @@ -837,7 +837,7 @@ pub const DeclGen = struct { // The Type memory is ephemeral; since we want to store a longer-lived // reference, we need to copy it here. - gop.key_ptr.* = try t.copy(&dg.object.type_map_arena.allocator); + gop.key_ptr.* = try t.copy(dg.object.type_map_arena.allocator()); const struct_obj = t.castTag(.@"struct").?.data; @@ -871,7 +871,7 @@ pub const DeclGen = struct { // The Type memory is ephemeral; since we want to store a longer-lived // reference, we need to copy it here. - gop.key_ptr.* = try t.copy(&dg.object.type_map_arena.allocator); + gop.key_ptr.* = try t.copy(dg.object.type_map_arena.allocator()); const union_obj = t.cast(Type.Payload.Union).?.data; const target = dg.module.getTarget(); @@ -1621,7 +1621,7 @@ pub const DeclGen = struct { }; pub const FuncGen = struct { - gpa: *Allocator, + gpa: Allocator, dg: *DeclGen, air: Air, liveness: Liveness, @@ -2485,7 +2485,7 @@ pub const FuncGen = struct { var arena_allocator = std.heap.ArenaAllocator.init(self.gpa); defer arena_allocator.deinit(); - const arena = &arena_allocator.allocator; + const arena = arena_allocator.allocator(); const llvm_params_len = args.len; const llvm_param_types = try arena.alloc(*const llvm.Type, llvm_params_len); diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index 67faf32471..39363064a7 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -70,7 +70,7 @@ pub fn writeInstructionWithString(code: *std.ArrayList(Word), opcode: Opcode, ar /// of data which needs to be persistent over different calls to Decl code generation. pub const SPIRVModule = struct { /// A general-purpose allocator which may be used to allocate temporary resources required for compilation. - gpa: *Allocator, + gpa: Allocator, /// The parent module. module: *Module, @@ -103,7 +103,7 @@ pub const SPIRVModule = struct { /// just the ones for OpLine. Note that OpLine needs the result of OpString, and not that of OpSource. file_names: std.StringHashMap(ResultId), - pub fn init(gpa: *Allocator, module: *Module) SPIRVModule { + pub fn init(gpa: Allocator, module: *Module) SPIRVModule { return .{ .gpa = gpa, .module = module, |
