浏览代码

* x87 optimized version of math.log2() for i8086, i386 and x86_64

git-svn-id: trunk@26266 -
nickysn 11 年之前
父节点
当前提交
4eb9043ac7
共有 4 个文件被更改,包括 32 次插入0 次删除
  1. 10 0
      rtl/i386/mathu.inc
  2. 10 0
      rtl/i8086/mathu.inc
  3. 2 0
      rtl/objpas/math.pp
  4. 10 0
      rtl/x86_64/mathu.inc

+ 10 - 0
rtl/i386/mathu.inc

@@ -74,6 +74,16 @@ function cotan(x : float) : float;assembler;
   end;
 
 
+{$define FPC_MATH_HAS_LOG2}
+function log2(x : float) : float;assembler;
+  asm
+    fld1
+    fldt x
+    fyl2x
+    fwait
+  end;
+
+
 {$define FPC_MATH_HAS_DIVMOD}
 procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: Word);assembler;
 asm

+ 10 - 0
rtl/i8086/mathu.inc

@@ -79,6 +79,16 @@ procedure sincos(theta : single;out sinus,cosinus : single);assembler;
   end;}
 
 
+{$define FPC_MATH_HAS_LOG2}
+function log2(x : float) : float;assembler;
+  asm
+    fld1
+    fld tbyte [x]
+    fyl2x
+    fwait
+  end;
+
+
 {//$define FPC_MATH_HAS_DIVMOD}
 {procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: Word);assembler;
 asm

+ 2 - 0
rtl/objpas/math.pp

@@ -851,10 +851,12 @@ function log10(x : float) : float;
     log10:=ln(x)*0.43429448190325182765;  { 1/ln(10) }
   end;
 
+{$ifndef FPC_MATH_HAS_LOG2}
 function log2(x : float) : float;
   begin
     log2:=ln(x)*1.4426950408889634079;    { 1/ln(2) }
   end;
+{$endif FPC_MATH_HAS_LOG2}
 
 function logn(n,x : float) : float;
   begin

+ 10 - 0
rtl/x86_64/mathu.inc

@@ -42,6 +42,16 @@ function cotan(x : float) : float;assembler;
     fdivp %st,%st(1)
     fwait
   end;
+
+
+{$define FPC_MATH_HAS_LOG2}
+function log2(x : float) : float;assembler;
+  asm
+    fld1
+    fldt x
+    fyl2x
+    fwait
+  end;
 {$endif FPC_HAS_TYPE_EXTENDED}