llvm v0.7.2

This commit is contained in:
xushiwei
2024-04-29 03:43:38 +08:00
parent cb507f43a7
commit 2986cb0c5f
3 changed files with 8 additions and 6 deletions

View File

@@ -510,19 +510,19 @@ func (b Builder) Convert(t Type, x Expr) (ret Expr) {
func castInt(b llvm.Builder, x llvm.Value, t llvm.Type) llvm.Value {
xt := x.Type()
if xt.TypeKind() == llvm.PointerTypeKind {
return b.CreatePtrToInt(x, t, "ptr2int")
return llvm.CreatePtrToInt(b, x, t)
}
if xt.IntTypeWidth() <= t.IntTypeWidth() {
return b.CreateIntCast(x, t, "castInt")
return llvm.CreateIntCast(b, x, t)
}
return b.CreateTrunc(x, t, "truncInt")
return llvm.CreateTrunc(b, x, t)
}
func castPtr(b llvm.Builder, x llvm.Value, t llvm.Type) llvm.Value {
if x.Type().TypeKind() == llvm.PointerTypeKind {
return b.CreatePointerCast(x, t, "castPtr")
return llvm.CreatePointerCast(b, x, t)
}
return b.CreateIntToPtr(x, t, "int2ptr")
return llvm.CreateIntToPtr(b, x, t)
}
// MakeInterface constructs an instance of an interface type from a