Browse Source

* fsqrt is an optional instruction in the ppc architecture and isn't
implemented by any current ppc afaik, so use the generic sqrt routine
instead (adapted so it works with compilerproc)

Jonas Maebe 22 years ago
parent
commit
df5e0bbfc6
3 changed files with 24 additions and 29 deletions
  1. 6 23
      compiler/powerpc/nppcinl.pas
  2. 12 2
      rtl/inc/genmath.inc
  3. 6 4
      rtl/powerpc/math.inc

+ 6 - 23
compiler/powerpc/nppcinl.pas

@@ -37,10 +37,8 @@ interface
           }
           }
           function first_abs_real: tnode; override;
           function first_abs_real: tnode; override;
           function first_sqr_real: tnode; override;
           function first_sqr_real: tnode; override;
-          function first_sqrt_real: tnode; override;
           procedure second_abs_real; override;
           procedure second_abs_real; override;
           procedure second_sqr_real; override;
           procedure second_sqr_real; override;
-          procedure second_sqrt_real; override;
        private
        private
           procedure load_fpu_location;
           procedure load_fpu_location;
        end;
        end;
@@ -84,18 +82,6 @@ implementation
         first_sqr_real := nil;
         first_sqr_real := nil;
       end;
       end;
 
 
-     function tppcinlinenode.first_sqrt_real : tnode;
-      begin
-        expectloc:=LOC_FPUREGISTER;
-        registers32:=left.registers32;
-        registersfpu:=max(left.registersfpu,1);
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
-        first_sqrt_real := nil;
-      end;
-
-
        { load the FPU into the an fpu register }
        { load the FPU into the an fpu register }
        procedure tppcinlinenode.load_fpu_location;
        procedure tppcinlinenode.load_fpu_location;
          begin
          begin
@@ -140,20 +126,17 @@ implementation
            left.location.register,left.location.register));
            left.location.register,left.location.register));
        end;
        end;
 
 
-     procedure tppcinlinenode.second_sqrt_real;
-       begin
-         location.loc:=LOC_FPUREGISTER;
-         load_fpu_location;
-         exprasmlist.concat(taicpu.op_reg_reg(A_FSQRT,location.register,
-           left.location.register));
-       end;
-
 begin
 begin
    cinlinenode:=tppcinlinenode;
    cinlinenode:=tppcinlinenode;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2003-04-23 12:35:35  florian
+  Revision 1.6  2003-05-24 13:39:32  jonas
+    * fsqrt is an optional instruction in the ppc architecture and isn't
+      implemented by any current ppc afaik, so use the generic sqrt routine
+      instead (adapted so it works with compilerproc)
+
+  Revision 1.5  2003/04/23 12:35:35  florian
     * fixed several issues with powerpc
     * fixed several issues with powerpc
     + applied a patch from Jonas for nested function calls (PowerPC only)
     + applied a patch from Jonas for nested function calls (PowerPC only)
     * ...
     * ...

+ 12 - 2
rtl/inc/genmath.inc

@@ -455,7 +455,7 @@ Function float32_to_int32_round_to_zero( a: Float32 ): longint;
 
 
 
 
 {$ifndef FPC_SYSTEM_HAS_SQRT}
 {$ifndef FPC_SYSTEM_HAS_SQRT}
-    function sqrt(d:Real):Real;[internconst:in_const_sqrt];
+    function sqrt(d:Real):Real;[internconst:in_const_sqrt]; [public, alias: 'FPC_SQRT_REAL'];
     {*****************************************************************}
     {*****************************************************************}
     { Square root                                                     }
     { Square root                                                     }
     {*****************************************************************}
     {*****************************************************************}
@@ -511,6 +511,11 @@ Function float32_to_int32_round_to_zero( a: Float32 ): longint;
           sqrt := d;
           sqrt := d;
        end;
        end;
     end;
     end;
+
+{$ifdef hascompilerproc}
+    function fpc_sqrt_real(d:Real):Real;compilerproc; external name 'FPC_SQRT_REAL';
+{$endif hascompilerproc}
+
 {$endif}
 {$endif}
 
 
 
 
@@ -1083,7 +1088,12 @@ Function float32_to_int32_round_to_zero( a: Float32 ): longint;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2003-05-23 22:58:31  jonas
+  Revision 1.14  2003-05-24 13:39:32  jonas
+    * fsqrt is an optional instruction in the ppc architecture and isn't
+      implemented by any current ppc afaik, so use the generic sqrt routine
+      instead (adapted so it works with compilerproc)
+
+  Revision 1.13  2003/05/23 22:58:31  jonas
     * added longint typecase to odd(smallint_var) call to avoid overload
     * added longint typecase to odd(smallint_var) call to avoid overload
       problem
       problem
 
 

+ 6 - 4
rtl/powerpc/math.inc

@@ -35,9 +35,6 @@ const
     {$define FPC_SYSTEM_HAS_SQR}
     {$define FPC_SYSTEM_HAS_SQR}
     function sqr(d : extended) : extended;[internproc:in_sqr_extended];
     function sqr(d : extended) : extended;[internproc:in_sqr_extended];
 
 
-    {$define FPC_SYSTEM_HAS_SQRT}
-    function sqrt(d : extended) : extended;[internproc:in_sqrt_extended];
-
     {
     {
     function arctan(d : extended) : extended;[internconst:in_arctan_extended];
     function arctan(d : extended) : extended;[internconst:in_arctan_extended];
       begin
       begin
@@ -427,7 +424,12 @@ end ['R0','R3','F0','F1','F2','F3'];
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.22  2003-05-16 16:04:33  jonas
+  Revision 1.23  2003-05-24 13:39:32  jonas
+    * fsqrt is an optional instruction in the ppc architecture and isn't
+      implemented by any current ppc afaik, so use the generic sqrt routine
+      instead (adapted so it works with compilerproc)
+
+  Revision 1.22  2003/05/16 16:04:33  jonas
     * fixed round() (almost the same as trunc)
     * fixed round() (almost the same as trunc)
 
 
   Revision 1.21  2003/05/11 18:09:45  jonas
   Revision 1.21  2003/05/11 18:09:45  jonas