diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-11-30 18:48:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-30 18:48:31 -0800 |
| commit | 7355a201336c8e3892427e5932fe5cdd46cf96df (patch) | |
| tree | 4ccec922634586847d02f2324d0db75f25200188 /src/codegen/llvm.zig | |
| parent | dd62a6d2e8de522187fd096354e7156cca1821c5 (diff) | |
| parent | 066eaa5e9cbfde172449f6d95bb884c7d86ac10c (diff) | |
| download | zig-7355a201336c8e3892427e5932fe5cdd46cf96df.tar.gz zig-7355a201336c8e3892427e5932fe5cdd46cf96df.zip | |
Merge pull request #10055 from leecannon/allocator_refactor
Allocgate
Diffstat (limited to 'src/codegen/llvm.zig')
| -rw-r--r-- | src/codegen/llvm.zig | 26 |
1 files changed, 13 insertions, 13 deletions
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); |
