diff options
Diffstat (limited to 'src/codegen/llvm.zig')
| -rw-r--r-- | src/codegen/llvm.zig | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 94fb1de8c4..0ba14f98ba 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -325,17 +325,17 @@ pub const DeclGen = struct { fn genDecl(self: *DeclGen) !void { const decl = self.decl; - const typed_value = decl.typed_value.most_recent.typed_value; + assert(decl.has_tv); - log.debug("gen: {s} type: {}, value: {}", .{ decl.name, typed_value.ty, typed_value.val }); + log.debug("gen: {s} type: {}, value: {}", .{ decl.name, decl.ty, decl.val }); - if (typed_value.val.castTag(.function)) |func_payload| { + if (decl.val.castTag(.function)) |func_payload| { const func = func_payload.data; const llvm_func = try self.resolveLLVMFunction(func.owner_decl); // This gets the LLVM values from the function and stores them in `self.args`. - const fn_param_len = func.owner_decl.typed_value.most_recent.typed_value.ty.fnParamLen(); + const fn_param_len = func.owner_decl.ty.fnParamLen(); var args = try self.gpa.alloc(*const llvm.Value, fn_param_len); for (args) |*arg, i| { @@ -368,7 +368,7 @@ pub const DeclGen = struct { defer fg.deinit(); try fg.genBody(func.body); - } else if (typed_value.val.castTag(.extern_fn)) |extern_fn| { + } else if (decl.val.castTag(.extern_fn)) |extern_fn| { _ = try self.resolveLLVMFunction(extern_fn.data); } else { _ = try self.resolveGlobalDecl(decl); @@ -380,7 +380,8 @@ pub const DeclGen = struct { // TODO: do we want to store this in our own datastructure? if (self.llvmModule().getNamedFunction(func.name)) |llvm_fn| return llvm_fn; - const zig_fn_type = func.typed_value.most_recent.typed_value.ty; + assert(func.has_tv); + const zig_fn_type = func.ty; const return_type = zig_fn_type.fnReturnType(); const fn_param_len = zig_fn_type.fnParamLen(); @@ -415,11 +416,11 @@ pub const DeclGen = struct { // TODO: do we want to store this in our own datastructure? if (self.llvmModule().getNamedGlobal(decl.name)) |val| return val; - const typed_value = decl.typed_value.most_recent.typed_value; + assert(decl.has_tv); // TODO: remove this redundant `getLLVMType`, it is also called in `genTypedValue`. - const llvm_type = try self.getLLVMType(typed_value.ty); - const val = try self.genTypedValue(typed_value, null); + const llvm_type = try self.getLLVMType(decl.ty); + const val = try self.genTypedValue(.{ .ty = decl.ty, .val = decl.val }, null); const global = self.llvmModule().addGlobal(llvm_type, decl.name); llvm.setInitializer(global, val); @@ -688,7 +689,8 @@ pub const FuncGen = struct { else unreachable; - const zig_fn_type = fn_decl.typed_value.most_recent.typed_value.ty; + assert(fn_decl.has_tv); + const zig_fn_type = fn_decl.ty; const llvm_fn = try self.dg.resolveLLVMFunction(fn_decl); const num_args = inst.args.len; |
