mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
Implement int and float subtraction
This commit is contained in:
parent
9fcfa90bff
commit
df78068e81
5 changed files with 39 additions and 2 deletions
|
@ -559,13 +559,20 @@ fn call_by_name<'a, B: Backend>(
|
|||
|
||||
builder.ins().fadd(a, b)
|
||||
}
|
||||
Symbol::NUM_SUB => {
|
||||
Symbol::INT_SUB | Symbol::NUM_SUB => {
|
||||
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().isub(a, b)
|
||||
}
|
||||
Symbol::FLOAT_SUB => {
|
||||
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().fsub(a, b)
|
||||
}
|
||||
Symbol::NUM_MUL => {
|
||||
debug_assert!(args.len() == 2);
|
||||
let a = build_arg(&args[0], env, scope, module, builder, procs);
|
||||
|
|
|
@ -558,7 +558,7 @@ fn call_with_args<'a, 'ctx, 'env>(
|
|||
|
||||
BasicValueEnum::FloatValue(float_val)
|
||||
}
|
||||
Symbol::NUM_SUB => {
|
||||
Symbol::INT_SUB | Symbol::NUM_SUB => {
|
||||
debug_assert!(args.len() == 2);
|
||||
|
||||
let int_val = env.builder.build_int_sub(
|
||||
|
@ -569,6 +569,17 @@ fn call_with_args<'a, 'ctx, 'env>(
|
|||
|
||||
BasicValueEnum::IntValue(int_val)
|
||||
}
|
||||
Symbol::FLOAT_SUB => {
|
||||
debug_assert!(args.len() == 2);
|
||||
|
||||
let float_val = env.builder.build_float_sub(
|
||||
args[0].into_float_value(),
|
||||
args[1].into_float_value(),
|
||||
"sub_f64",
|
||||
);
|
||||
|
||||
BasicValueEnum::FloatValue(float_val)
|
||||
}
|
||||
Symbol::NUM_MUL => {
|
||||
debug_assert!(args.len() == 2);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue