stage2 llvm backend: implement const inttoptr

This commit is contained in:
Andrew Kelley
2021-08-11 13:59:34 -07:00
parent a0670e748e
commit 6eecc4af99
5 changed files with 921 additions and 906 deletions

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 => {

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 {