summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ia32/CBuiltins.ml4
-rw-r--r--ia32/PrintAsm.ml19
2 files changed, 22 insertions, 1 deletions
diff --git a/ia32/CBuiltins.ml b/ia32/CBuiltins.ml
index d077fe5..14a2f10 100644
--- a/ia32/CBuiltins.ml
+++ b/ia32/CBuiltins.ml
@@ -24,5 +24,9 @@ let builtins = {
(* Float arithmetic *)
"__builtin_fsqrt",
(TFloat(FDouble, []), [TFloat(FDouble, [])], false);
+ "__builtin_fmax",
+ (TFloat(FDouble, []), [TFloat(FDouble, []); TFloat(FDouble, [])], false);
+ "__builtin_fmin",
+ (TFloat(FDouble, []), [TFloat(FDouble, []); TFloat(FDouble, [])], false);
]
}
diff --git a/ia32/PrintAsm.ml b/ia32/PrintAsm.ml
index e75032c..f614e97 100644
--- a/ia32/PrintAsm.ml
+++ b/ia32/PrintAsm.ml
@@ -241,7 +241,24 @@ let print_builtin_inlined oc name args res =
fprintf oc " andpd %a, %a\n" raw_symbol "__absd_mask" freg res
| "__builtin_fsqrt", [FR a1], FR res ->
fprintf oc " sqrtsd %a, %a\n" freg a1 freg res
- (* Also: fmax, fmin *)
+ | "__builtin_fmax", [FR a1; FR a2], FR res ->
+ if res = a1 then
+ fprintf oc " maxsd %a, %a\n" freg a2 freg res
+ else if res = a2 then
+ fprintf oc " maxsd %a, %a\n" freg a1 freg res
+ else begin
+ fprintf oc " movsd %a, %a\n" freg a1 freg res;
+ fprintf oc " maxsd %a, %a\n" freg a2 freg res
+ end
+ | "__builtin_fmin", [FR a1; FR a2], FR res ->
+ if res = a1 then
+ fprintf oc " minsd %a, %a\n" freg a2 freg res
+ else if res = a2 then
+ fprintf oc " minsd %a, %a\n" freg a1 freg res
+ else begin
+ fprintf oc " movsd %a, %a\n" freg a1 freg res;
+ fprintf oc " minsd %a, %a\n" freg a2 freg res
+ end
| _ ->
invalid_arg ("unrecognized builtin " ^ name)
end;