commit c16818d6239a34ff211186a2e165777e17a847da (tree)
parent d3055480ec27de9107678fc9e2ac9075633f1384
Author: antlilja <liljaanton2001@gmail.com>
Date: Mon, 19 Feb 2024 23:12:52 +0100
Add LLVM bindings for parsing LLVM bitcode
Diffstat:
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git 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;