stage2 llvm backend: implement const inttoptr

This commit is contained in:
Andrew Kelley committed 2021-08-12 10:48:54 -07:00
1 parent a0670e748e
commit 6eecc4af99
5 files changed
+921 -906

No files matched your search

+5
View File
@@ -768,6 +768,11 @@ pub const DeclGen = struct {
};
return self.context.constStruct(&fields, fields.len, .False);
},
.int_u64 => {
const llvm_usize = try self.llvmType(Type.initTag(.usize));
const llvm_int = llvm_usize.constInt(tv.val.toUnsignedInt(), .False);
return llvm_int.constIntToPtr(try self.llvmType(tv.ty));
},
else => |tag| return self.todo("implement const of pointer type '{}' ({})", .{ tv.ty, tag }),
},
.Array => {
+3
View File
@@ -130,6 +130,9 @@ pub const Value = opaque {
pub const constBitCast = LLVMConstBitCast;
extern fn LLVMConstBitCast(ConstantVal: *const Value, ToType: *const Type) *const Value;
pub const constIntToPtr = LLVMConstIntToPtr;
extern fn LLVMConstIntToPtr(ConstantVal: *const Value, ToType: *const Type) *const Value;
};
pub const Type = opaque {