diff options
| author | Timon Kruiper <timonkruiper@gmail.com> | 2021-03-08 00:09:03 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-03-20 15:10:44 -0700 |
| commit | a710368054096889385562addaed2d16f0705332 (patch) | |
| tree | 66cc9673d9bd3ddd914aafeee964d50e55cf4d50 /src/link/Coff.zig | |
| parent | 56677f2f2da41af5999b84b7f740d7bc463d1032 (diff) | |
| download | zig-a710368054096889385562addaed2d16f0705332.tar.gz zig-a710368054096889385562addaed2d16f0705332.zip | |
stage2: restructure LLVM backend
The LLVM backend is now structured into 3 different structs, namely
Object, DeclGen and FuncGen. Object represents an object that is
generated by the LLVM backend. DeclGen is responsible for generating
a decl and FuncGen is responsible for generating llvm instructions
from tzir in a function.
Diffstat (limited to 'src/link/Coff.zig')
| -rw-r--r-- | src/link/Coff.zig | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 308164ac95..33c37f8efe 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -34,7 +34,7 @@ pub const base_tag: link.File.Tag = .coff; const msdos_stub = @embedFile("msdos-stub.bin"); /// If this is not null, an object file is created by LLVM and linked with LLD afterwards. -llvm_ir_module: ?*llvm_backend.LLVMIRModule = null, +llvm_object: ?*llvm_backend.Object = null, base: link.File, ptr_width: PtrWidth, @@ -129,7 +129,7 @@ pub fn openPath(allocator: *Allocator, sub_path: []const u8, options: link.Optio const self = try createEmpty(allocator, options); errdefer self.base.destroy(); - self.llvm_ir_module = try llvm_backend.LLVMIRModule.create(allocator, sub_path, options); + self.llvm_object = try llvm_backend.Object.create(allocator, sub_path, options); return self; } @@ -413,7 +413,7 @@ pub fn createEmpty(gpa: *Allocator, options: link.Options) !*Coff { } pub fn allocateDeclIndexes(self: *Coff, decl: *Module.Decl) !void { - if (self.llvm_ir_module) |_| return; + if (self.llvm_object) |_| return; try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1); @@ -660,7 +660,7 @@ pub fn updateDecl(self: *Coff, module: *Module, decl: *Module.Decl) !void { defer tracy.end(); if (build_options.have_llvm) - if (self.llvm_ir_module) |llvm_ir_module| return try llvm_ir_module.updateDecl(module, decl); + if (self.llvm_object) |llvm_object| return try llvm_object.updateDecl(module, decl); const typed_value = decl.typed_value.most_recent.typed_value; if (typed_value.val.tag() == .extern_fn) { @@ -720,7 +720,7 @@ pub fn updateDecl(self: *Coff, module: *Module, decl: *Module.Decl) !void { } pub fn freeDecl(self: *Coff, decl: *Module.Decl) void { - if (self.llvm_ir_module) |_| return; + if (self.llvm_object) |_| return; // Appending to free lists is allowed to fail because the free lists are heuristics based anyway. self.freeTextBlock(&decl.link.coff); @@ -728,7 +728,7 @@ pub fn freeDecl(self: *Coff, decl: *Module.Decl) void { } pub fn updateDeclExports(self: *Coff, module: *Module, decl: *Module.Decl, exports: []const *Module.Export) !void { - if (self.llvm_ir_module) |_| return; + if (self.llvm_object) |_| return; for (exports) |exp| { if (exp.options.section) |section_name| { @@ -771,7 +771,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation) !void { defer tracy.end(); if (build_options.have_llvm) - if (self.llvm_ir_module) |llvm_ir_module| return try llvm_ir_module.flushModule(comp); + if (self.llvm_object) |llvm_object| return try llvm_object.flushModule(comp); if (self.text_section_size_dirty) { // Write the new raw size in the .text header @@ -1308,7 +1308,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { } pub fn getDeclVAddr(self: *Coff, decl: *const Module.Decl) u64 { - assert(self.llvm_ir_module == null); + assert(self.llvm_object == null); return self.text_section_virtual_address + decl.link.coff.text_offset; } @@ -1318,7 +1318,7 @@ pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl: *Module.Decl) !v pub fn deinit(self: *Coff) void { if (build_options.have_llvm) - if (self.llvm_ir_module) |ir_module| ir_module.deinit(self.base.allocator); + if (self.llvm_object) |ir_module| ir_module.deinit(self.base.allocator); self.text_block_free_list.deinit(self.base.allocator); self.offset_table.deinit(self.base.allocator); |
