From 09739ad762e9cf144f8004cdaf60d293dfd62d9a Mon Sep 17 00:00:00 2001 From: xleroy Date: Sat, 24 Nov 2012 16:38:28 +0000 Subject: Add __builtin_fcti (double -> int conversion w/ round to nearest) git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2071 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- powerpc/CBuiltins.ml | 4 ++++ powerpc/PrintAsm.ml | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/powerpc/CBuiltins.ml b/powerpc/CBuiltins.ml index b9fc0648..ff1715b7 100644 --- a/powerpc/CBuiltins.ml +++ b/powerpc/CBuiltins.ml @@ -56,6 +56,10 @@ let builtins = { (TFloat(FDouble, []), [TFloat(FDouble, []); TFloat(FDouble, []); TFloat(FDouble, [])], false); + "__builtin_fcti", + (TInt(IInt, []), + [TFloat(FDouble, [])], + false); (* Memory accesses *) "__builtin_read16_reversed", (TInt(IUShort, []), [TPtr(TInt(IUShort, [AConst]), [])], false); diff --git a/powerpc/PrintAsm.ml b/powerpc/PrintAsm.ml index 5bfd3eeb..3ef3c744 100644 --- a/powerpc/PrintAsm.ml +++ b/powerpc/PrintAsm.ml @@ -447,6 +447,11 @@ let print_builtin_inline oc name args res = fprintf oc " fres %a, %a\n" freg res freg a1 | "__builtin_fsel", [FR a1; FR a2; FR a3], FR res -> fprintf oc " fsel %a, %a, %a, %a\n" freg res freg a1 freg a2 freg a3 + | "__builtin_fcti", [FR a1], IR res -> + fprintf oc " fctiw %a, %a\n" freg FPR13 freg a1; + fprintf oc " stfdu %a, -8(%a)\n" freg FPR13 ireg GPR1; + fprintf oc " lwz %a, 4(%a)\n" ireg res ireg GPR1; + fprintf oc " addi %a, %a, 8\n" ireg GPR1 ireg GPR1 (* Memory accesses *) | "__builtin_read16_reversed", [IR a1], IR res -> fprintf oc " lhbrx %a, %a, %a\n" ireg res ireg_or_zero GPR0 ireg a1 -- cgit