diff options
| author | gingerBill <bill@gingerbill.org> | 2021-05-31 20:38:10 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-05-31 20:38:10 +0100 |
| commit | b8d6dd4eb78a2ca27907a3f09c33c6b85ef6c8a0 (patch) | |
| tree | 0d86f8f1f7911ba4652d817327736645eef2d216 /src | |
| parent | 4d80f8598db5541ae9466799feaaa909398d53b4 (diff) | |
Fix #1004
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_builtin.cpp | 2 | ||||
| -rw-r--r-- | src/llvm_backend.cpp | 36 |
2 files changed, 2 insertions, 36 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index c67679f1c..b6dadb09a 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -1184,6 +1184,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 { Type *bt = base_type(operands[0].type); + if (are_types_identical(bt, t_f16)) add_package_dependency(c, "runtime", "min_f16"); if (are_types_identical(bt, t_f32)) add_package_dependency(c, "runtime", "min_f32"); if (are_types_identical(bt, t_f64)) add_package_dependency(c, "runtime", "min_f64"); @@ -1364,6 +1365,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 { Type *bt = base_type(operands[0].type); + if (are_types_identical(bt, t_f16)) add_package_dependency(c, "runtime", "max_f16"); if (are_types_identical(bt, t_f32)) add_package_dependency(c, "runtime", "max_f32"); if (are_types_identical(bt, t_f64)) add_package_dependency(c, "runtime", "max_f64"); diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index c31d1f34f..dbc059d5f 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -5600,37 +5600,11 @@ LLVMValueRef lb_const_f32(lbModule *m, f32 f, Type *type=t_f32) { lbValue lb_emit_min(lbProcedure *p, Type *t, lbValue x, lbValue y) { x = lb_emit_conv(p, x, t); y = lb_emit_conv(p, y, t); - - if (is_type_float(t)) { - i64 sz = 8*type_size_of(t); - auto args = array_make<lbValue>(permanent_allocator(), 2); - args[0] = x; - args[1] = y; - switch (sz) { - case 16: return lb_emit_runtime_call(p, "min_f16", args); - case 32: return lb_emit_runtime_call(p, "min_f32", args); - case 64: return lb_emit_runtime_call(p, "min_f64", args); - } - GB_PANIC("Unknown float type"); - } return lb_emit_select(p, lb_emit_comp(p, Token_Lt, x, y), x, y); } lbValue lb_emit_max(lbProcedure *p, Type *t, lbValue x, lbValue y) { x = lb_emit_conv(p, x, t); y = lb_emit_conv(p, y, t); - - if (is_type_float(t)) { - i64 sz = 8*type_size_of(t); - auto args = array_make<lbValue>(permanent_allocator(), 2); - args[0] = x; - args[1] = y; - switch (sz) { - case 16: return lb_emit_runtime_call(p, "max_f16", args); - case 32: return lb_emit_runtime_call(p, "max_f32", args); - case 64: return lb_emit_runtime_call(p, "max_f64", args); - } - GB_PANIC("Unknown float type"); - } return lb_emit_select(p, lb_emit_comp(p, Token_Gt, x, y), x, y); } @@ -9307,16 +9281,6 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, case 128: return lb_emit_runtime_call(p, "abs_complex128", args); } GB_PANIC("Unknown complex type"); - } else if (is_type_float(t)) { - i64 sz = 8*type_size_of(t); - auto args = array_make<lbValue>(permanent_allocator(), 1); - args[0] = x; - switch (sz) { - case 16: return lb_emit_runtime_call(p, "abs_f16", args); - case 32: return lb_emit_runtime_call(p, "abs_f32", args); - case 64: return lb_emit_runtime_call(p, "abs_f64", args); - } - GB_PANIC("Unknown float type"); } lbValue zero = lb_const_nil(p->module, t); lbValue cond = lb_emit_comp(p, Token_Lt, x, zero); |