Parcourir la source

* typecheck_real_to_currency: generate inline round() node instead of direct call to fpc_round_real, this allows target-specific processing to take place and possibly emit more efficient code.
* Provide x86_64 SSE versions of fpc_trunc_real and fpc_round_real, strictly they are not necessary after the above change to code generation, but it still reduces size of system unit by avoiding compilation of related generic code.

git-svn-id: trunk@25735 -

sergei il y a 11 ans
Parent
commit
90d66595c2
2 fichiers modifiés avec 17 ajouts et 3 suppressions
  1. 2 3
      compiler/ncnv.pas
  2. 15 0
      rtl/x86_64/math.inc

+ 2 - 3
compiler/ncnv.pas

@@ -294,7 +294,7 @@ implementation
       globtype,systems,constexp,
       cutils,verbose,globals,widestr,
       symconst,symdef,symsym,symtable,
-      ncon,ncal,nset,nadd,nmem,nmat,nbas,nutils,
+      ncon,ncal,nset,nadd,nmem,nmat,nbas,nutils,ninl,
       cgbase,procinfo,
       htypechk,pass_1,cpuinfo;
 
@@ -1428,8 +1428,7 @@ implementation
           result:=cordconstnode.create(round(trealconstnode(left).value_real),resultdef,false)
         else
           begin
-            result:=ccallnode.createinternres('fpc_round_real',
-              ccallparanode.create(left,nil),resultdef);
+            result:=cinlinenode.create(in_round_real,false,left);
             left:=nil;
           end;
       end;

+ 15 - 0
rtl/x86_64/math.inc

@@ -272,4 +272,19 @@ const
            power:=exp(ln(bas)*expo);
       end;
     {$endif FPC_SYSTEM_HAS_POWER}
+
+{$else FPC_HAS_TYPE_EXTENDED}
+
+    {$define FPC_SYSTEM_HAS_TRUNC}
+    function fpc_trunc_real(d : ValReal) : int64;compilerproc; assembler; nostackframe;
+      asm
+        cvttsd2si   %xmm0,%rax;
+      end;
+
+    {$define FPC_SYSTEM_HAS_ROUND}
+    function fpc_round_real(d : ValReal) : int64;compilerproc; assembler; nostackframe;
+      asm
+        cvtsd2si   %xmm0,%rax;
+      end;
+
 {$endif FPC_HAS_TYPE_EXTENDED}