From c16818d6239a34ff211186a2e165777e17a847da Mon Sep 17 00:00:00 2001 From: antlilja Date: Mon, 19 Feb 2024 23:12:52 +0100 Subject: [PATCH] Add LLVM bindings for parsing LLVM bitcode --- src/codegen/llvm/bindings.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/codegen/llvm/bindings.zig b/src/codegen/llvm/bindings.zig index d7144b36ce..862fd8266f 100644 --- a/src/codegen/llvm/bindings.zig +++ b/src/codegen/llvm/bindings.zig @@ -17,6 +17,14 @@ pub const Bool = enum(c_int) { }; pub const AttributeIndex = c_uint; +pub const MemoryBuffer = opaque { + pub const createMemoryBufferWithMemoryRange = LLVMCreateMemoryBufferWithMemoryRange; + pub const dispose = LLVMDisposeMemoryBuffer; + + extern fn LLVMCreateMemoryBufferWithMemoryRange(InputData: [*]const u8, InputDataLength: usize, BufferName: ?[*:0]const u8, RequiresNullTerminator: Bool) *MemoryBuffer; + extern fn LLVMDisposeMemoryBuffer(MemBuf: *MemoryBuffer) void; +}; + /// Make sure to use the *InContext functions instead of the global ones. pub const Context = opaque { pub const create = LLVMContextCreate; @@ -25,6 +33,9 @@ pub const Context = opaque { pub const dispose = LLVMContextDispose; extern fn LLVMContextDispose(C: *Context) void; + pub const parseBitcodeInContext2 = LLVMParseBitcodeInContext2; + extern fn LLVMParseBitcodeInContext2(C: *Context, MemBuf: *MemoryBuffer, OutModule: **Module) Bool; + pub const createEnumAttribute = LLVMCreateEnumAttribute; extern fn LLVMCreateEnumAttribute(C: *Context, KindID: c_uint, Val: u64) *Attribute;