aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-10-23 19:46:48 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-10-23 19:47:32 -0700
commit22b4c9e1a9595bd94ada4c500a430e2668ffcd07 (patch)
tree325e312f063422e19b0427373194b703b8cc3b53 /src/codegen/llvm.zig
parentee98d8700818aa667137e3aa580b16df2ba6d680 (diff)
downloadzig-22b4c9e1a9595bd94ada4c500a430e2668ffcd07.tar.gz
zig-22b4c9e1a9595bd94ada4c500a430e2668ffcd07.zip
stage2: implement more C pointer Sema and comptime ptr arith
Diffstat (limited to 'src/codegen/llvm.zig')
-rw-r--r--src/codegen/llvm.zig7
1 files changed, 4 insertions, 3 deletions
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)) {