Float.div implemented, Int.div WIP-ish

This commit is contained in:
Mario Rogic 2020-03-08 18:32:48 +00:00
parent 17e9f0b8c3
commit a5c2844f54
4 changed files with 69 additions and 7 deletions

View file

@ -574,6 +574,20 @@ fn call_by_name<'a, B: Backend>(
builder.ins().ineg(num)
}
Symbol::FLOAT_DIV => {
debug_assert!(args.len() == 2);
let a = build_arg(&args[0], env, scope, module, builder, procs);
let b = build_arg(&args[1], env, scope, module, builder, procs);
builder.ins().fdiv(a, b)
}
// Symbol::INT_DIV => {
// debug_assert!(args.len() == 2);
// let a = build_arg(&args[0], env, scope, module, builder, procs);
// let b = build_arg(&args[1], env, scope, module, builder, procs);
//
// builder.ins().sdiv(a, b)
// }
Symbol::LIST_GET_UNSAFE => {
debug_assert!(args.len() == 2);

View file

@ -578,6 +578,28 @@ fn call_with_args<'a, 'ctx, 'env>(
BasicValueEnum::IntValue(int_val)
}
Symbol::FLOAT_DIV => {
debug_assert!(args.len() == 2);
let float_val = env.builder.build_float_div(
args[0].into_float_value(),
args[1].into_float_value(),
"DIV_F64",
);
BasicValueEnum::FloatValue(float_val)
}
// Symbol::INT_DIV => {
// debug_assert!(args.len() == 2);
//
// let int_val = env.builder.build_int_signed_div(
// args[0].into_int_value(),
// args[1].into_int_value(),
// "DIV_I64",
// );
//
// BasicValueEnum::IntValue(int_val)
// }
Symbol::LIST_GET_UNSAFE => {
debug_assert!(args.len() == 2);