From 22b4c9e1a9595bd94ada4c500a430e2668ffcd07 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 23 Oct 2021 19:46:48 -0700 Subject: stage2: implement more C pointer Sema and comptime ptr arith --- src/codegen/llvm.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/codegen') diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 3a01440135..aa0a99ea6c 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1106,7 +1106,7 @@ pub const DeclGen = struct { return parent_ptr.constInBoundsGEP(&indices, indices.len); } }, - .null_value => { + .null_value, .zero => { const llvm_type = try self.llvmType(tv.ty); return llvm_type.constNull(); }, @@ -3180,8 +3180,9 @@ pub const FuncGen = struct { const inst_ty = self.air.typeOfIndex(inst); const llvm_dest_ty = try self.dg.llvmType(inst_ty); - // TODO look into pulling this logic out into a different AIR instruction than bitcast - if (operand_ty.zigTypeTag() == .Vector and inst_ty.zigTypeTag() == .Array) { + if (operand_ty.zigTypeTag() == .Int and inst_ty.zigTypeTag() == .Pointer) { + return self.builder.buildIntToPtr(operand, llvm_dest_ty, ""); + } else if (operand_ty.zigTypeTag() == .Vector and inst_ty.zigTypeTag() == .Array) { const target = self.dg.module.getTarget(); const elem_ty = operand_ty.childType(); if (!isByRef(inst_ty)) { -- cgit v1.2.3