1
0
forked from M-Labs/nac3

nac3core: use signed extension to convert i32 to i64

This commit is contained in:
ychenfo 2022-03-06 04:49:02 +08:00
parent 42fbe8e383
commit 8602852241

View File

@ -255,9 +255,7 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
let arg_ty = fun.0.args[0].ty;
let arg = args[0].1.clone().to_basic_value_enum(ctx, generator)?;
Ok(
if ctx.unifier.unioned(arg_ty, boolean)
|| ctx.unifier.unioned(arg_ty, int32)
{
if ctx.unifier.unioned(arg_ty, boolean) {
Some(
ctx.builder
.build_int_z_extend(
@ -267,6 +265,16 @@ pub fn get_builtins(primitives: &mut (PrimitiveStore, Unifier)) -> BuiltinInfo {
)
.into(),
)
} else if ctx.unifier.unioned(arg_ty, int32) {
Some(
ctx.builder
.build_int_s_extend(
arg.into_int_value(),
ctx.ctx.i64_type(),
"sext",
)
.into(),
)
} else if ctx.unifier.unioned(arg_ty, int64) {
Some(arg)
} else if ctx.unifier.unioned(arg_ty, float) {