diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/llvm_backend.zig | 6 | ||||
| -rw-r--r-- | src/llvm_bindings.zig | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/llvm_backend.zig b/src/llvm_backend.zig index 0a203777fc..d56233a503 100644 --- a/src/llvm_backend.zig +++ b/src/llvm_backend.zig @@ -312,6 +312,7 @@ pub const LLVMIRModule = struct { .arg => try self.genArg(inst.castTag(.arg).?), .alloc => try self.genAlloc(inst.castTag(.alloc).?), .store => try self.genStore(inst.castTag(.store).?), + .load => try self.genLoad(inst.castTag(.load).?), .dbg_stmt => blk: { // TODO: implement debug info break :blk null; @@ -396,6 +397,11 @@ pub const LLVMIRModule = struct { return null; } + fn genLoad(self: *LLVMIRModule, inst: *Inst.UnOp) !?*const llvm.ValueRef { + const ptr_val = try self.resolveInst(inst.operand); + return self.builder.buildLoad(ptr_val, ""); + } + fn genBreakpoint(self: *LLVMIRModule, inst: *Inst.NoOp) !?*const llvm.ValueRef { // TODO: Store this function somewhere such that we dont have to add it again const fn_type = llvm.TypeRef.functionType(llvm.voidType(), null, 0, false); diff --git a/src/llvm_bindings.zig b/src/llvm_bindings.zig index f7da7c34ad..133415d634 100644 --- a/src/llvm_bindings.zig +++ b/src/llvm_bindings.zig @@ -125,6 +125,9 @@ pub const BuilderRef = opaque { pub const buildStore = LLVMBuildStore; extern fn LLVMBuildStore(*const BuilderRef, Val: *const ValueRef, Ptr: *const ValueRef) *const ValueRef; + + pub const buildLoad = LLVMBuildLoad; + extern fn LLVMBuildLoad(*const BuilderRef, PointerVal: *const ValueRef, Name: [*:0]const u8) *const ValueRef; }; pub const BasicBlockRef = opaque { |
