llvm: convert global assembly

This commit is contained in:
Jacob Young 2023-07-23 06:15:26 -04:00
parent 533111e849
commit 3fc2e36de2
3 changed files with 631 additions and 543 deletions

View File

@ -1034,15 +1034,11 @@ pub const Object = struct {
fn genModuleLevelAssembly(object: *Object) !void {
const mod = object.module;
if (mod.global_assembly.count() == 0) return;
var buffer = std.ArrayList(u8).init(mod.gpa);
defer buffer.deinit();
var it = mod.global_assembly.iterator();
while (it.next()) |kv| {
try buffer.appendSlice(kv.value_ptr.*);
try buffer.append('\n');
}
object.llvm_module.setModuleInlineAsm2(buffer.items.ptr, buffer.items.len - 1);
const writer = object.builder.setModuleAsm();
var it = mod.global_assembly.valueIterator();
while (it.next()) |assembly| try writer.print("{s}\n", .{assembly.*});
try object.builder.finishModuleAsm();
}
fn resolveExportExternCollisions(object: *Object) !void {

File diff suppressed because it is too large Load Diff

View File

@ -540,7 +540,7 @@ pub const Module = opaque {
pub const createDIBuilder = ZigLLVMCreateDIBuilder;
extern fn ZigLLVMCreateDIBuilder(module: *Module, allow_unresolved: bool) *DIBuilder;
pub const setModuleInlineAsm2 = LLVMSetModuleInlineAsm2;
pub const setModuleInlineAsm = LLVMSetModuleInlineAsm2;
extern fn LLVMSetModuleInlineAsm2(M: *Module, Asm: [*]const u8, Len: usize) void;
pub const printModuleToFile = LLVMPrintModuleToFile;