浏览代码

* merged fsqrt(s) support to common powerpc unit, activate for ppc32
if -Op970 is used (still default for ppc64, since default cpu there
is already ppc970)

git-svn-id: branches/fpc_2_3@6391 -

Jonas Maebe 18 年之前
父节点
当前提交
9e783c1979
共有 5 个文件被更改,包括 66 次插入95 次删除
  1. 0 1
      .gitattributes
  2. 17 3
      compiler/powerpc/agppcgas.pas
  3. 1 1
      compiler/powerpc64/cpunode.pas
  4. 0 79
      compiler/powerpc64/nppcinl.pas
  5. 48 11
      compiler/ppcgen/ngppcinl.pas

+ 0 - 1
.gitattributes

@@ -348,7 +348,6 @@ compiler/powerpc64/itcpugas.pas svneol=native#text/plain
 compiler/powerpc64/nppcadd.pas svneol=native#text/plain
 compiler/powerpc64/nppccal.pas svneol=native#text/plain
 compiler/powerpc64/nppccnv.pas svneol=native#text/plain
-compiler/powerpc64/nppcinl.pas -text
 compiler/powerpc64/nppcld.pas svneol=native#text/plain
 compiler/powerpc64/nppcmat.pas svneol=native#text/plain
 compiler/powerpc64/ppcins.dat -text

+ 17 - 3
compiler/powerpc/agppcgas.pas

@@ -38,11 +38,12 @@ unit agppcgas;
     type
       TPPCGNUAssembler=class(TGNUassembler)
         constructor create(smart: boolean); override;
-        procedure WriteExtraHeader;override;
+        procedure WriteExtraHeader; override;
       end;
 
       TPPCAppleGNUAssembler=class(TAppleGNUassembler)
         constructor create(smart: boolean); override;
+        function MakeCmdLine: TCmdStr; override;
       end;
 
 
@@ -57,7 +58,7 @@ unit agppcgas;
        cutils,globals,verbose,
        cgbase,cgutils,systems,
        assemble,
-       itcpugas,
+       itcpugas,cpuinfo,
        aasmcpu;
 
 {****************************************************************************}
@@ -93,6 +94,19 @@ unit agppcgas;
       end;
 
 
+    function TPPCAppleGNUAssembler.MakeCmdLine: TCmdStr;
+      begin
+        result := inherited MakeCmdLine;
+        case current_settings.cputype of
+          cpu_PPC7400:
+            Replace(result,'$ARCH','ppc7400');
+          cpu_PPC970:
+            Replace(result,'$ARCH','ppc970');
+          else
+            Replace(result,'$ARCH','ppc')
+        end;
+      end;
+
 {****************************************************************************}
 {                  Helper routines for Instruction Writer                    }
 {****************************************************************************}
@@ -389,7 +403,7 @@ unit agppcgas;
 
             idtxt  : 'AS-Darwin';
             asmbin : 'as';
-            asmcmd : '-o $OBJ $ASM -arch ppc';
+            asmcmd : '-o $OBJ $ASM -arch $ARCH';
             supported_target : system_any;
             flags : [af_allowdirect,af_needar,af_smartlink_sections,af_supports_dwarf];
             labelprefix : 'L';

+ 1 - 1
compiler/powerpc64/cpunode.pas

@@ -40,7 +40,7 @@ uses
   //       nppcflw,
   //       nppcmem,
   ngppcset,
-  ngppcinl, nppcinl,
+  ngppcinl,
   //       nppcopt,
   nppcmat,
   nppccnv,

+ 0 - 79
compiler/powerpc64/nppcinl.pas

@@ -1,79 +0,0 @@
-{
-    Copyright (c) 1998-2007 by Free Pascal development team
-
-    Generate PowerPC64 inline nodes
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-unit nppcinl;
-
-{$i fpcdefs.inc}
-
-interface
-
-    uses
-       node,ninl,ncginl,ngppcinl;
-
-    type
-       tppc64inlinenode = class(tgppcinlinenode)
-         function first_sqrt_real: tnode; override;
-         procedure second_sqrt_real; override;
-       end;
-
-implementation
-
-    uses
-      cutils,globals,verbose,
-      aasmtai,aasmdata,aasmcpu,
-      symconst,symdef,
-      defutil,
-      cgbase,pass_2,
-      cpubase,ncgutil,
-      cgutils,cgobj,rgobj;
-
-
-{*****************************************************************************
-                              tppc64inlinenode
-*****************************************************************************}
-function tppc64inlinenode.first_sqrt_real : tnode;
-begin
-  expectloc:=LOC_FPUREGISTER;
-  registersint:=left.registersint;
-  registersfpu:=max(left.registersfpu,1);
-  first_sqrt_real := nil;
-end;
-
-procedure tppc64inlinenode.second_sqrt_real;
-begin
-  location.loc:=LOC_FPUREGISTER;
-  load_fpu_location;
-  case left.location.size of
-  OS_F32:
-    current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FSQRTS,location.register,
-      left.location.register));
-  OS_F64:
-    current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FSQRT,location.register,
-      left.location.register));
-  else
-    inherited;
-  end;
-end;
-
-
-begin
-   cinlinenode:=tppc64inlinenode;
-end.

+ 48 - 11
compiler/ppcgen/ngppcinl.pas

@@ -34,8 +34,10 @@ interface
             so that the code generator will actually generate
             these nodes.
           }
+          function first_sqrt_real: tnode; override;
           function first_abs_real: tnode; override;
           function first_sqr_real: tnode; override;
+          procedure second_sqrt_real; override;
           procedure second_abs_real; override;
           procedure second_sqr_real; override;
           procedure second_prefetch;override;
@@ -51,7 +53,7 @@ implementation
       symconst,symdef,
       defutil,
       cgbase,pass_2,
-      cpubase,ncgutil,
+      cpubase,cpuinfo,ncgutil,
       cgutils,cgobj,rgobj;
 
 
@@ -59,7 +61,21 @@ implementation
                               tgppcinlinenode
 *****************************************************************************}
 
-     function tgppcinlinenode.first_abs_real : tnode;
+    function tgppcinlinenode.first_sqrt_real : tnode;
+      begin
+        if (current_settings.cputype >= cpu_PPC970) then
+          begin
+            expectloc:=LOC_FPUREGISTER;
+            registersint:=left.registersint;
+            registersfpu:=max(left.registersfpu,1);
+            first_sqrt_real := nil;
+          end
+        else
+          result:=inherited first_sqrt_real;
+      end;
+
+    
+    function tgppcinlinenode.first_abs_real : tnode;
       begin
         expectloc:=LOC_FPUREGISTER;
         registersint:=left.registersint;
@@ -70,6 +86,7 @@ implementation
         first_abs_real := nil;
       end;
 
+
      function tgppcinlinenode.first_sqr_real : tnode;
       begin
         expectloc:=LOC_FPUREGISTER;
@@ -82,15 +99,34 @@ implementation
       end;
 
 
-       { load the FPU into the an fpu register }
-       procedure tgppcinlinenode.load_fpu_location;
-         begin
-           location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
-           secondpass(left);
-           location_force_fpureg(current_asmdata.CurrAsmList,left.location,true);
-           location.loc := LOC_FPUREGISTER;
-           location.register := cg.getfpuregister(current_asmdata.CurrAsmList,OS_F64);
-         end;
+     { load the FPU into the an fpu register }
+     procedure tgppcinlinenode.load_fpu_location;
+       begin
+         location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
+         secondpass(left);
+         location_force_fpureg(current_asmdata.CurrAsmList,left.location,true);
+         location.loc := LOC_FPUREGISTER;
+         location.register := cg.getfpuregister(current_asmdata.CurrAsmList,OS_F64);
+       end;
+
+
+    procedure tgppcinlinenode.second_sqrt_real;
+      begin
+        if (current_settings.cputype < cpu_PPC970) then
+          internalerror(2007020910);
+        location.loc:=LOC_FPUREGISTER;
+        load_fpu_location;
+        case left.location.size of
+          OS_F32:
+            current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FSQRTS,location.register,
+              left.location.register));
+          OS_F64:
+            current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_FSQRT,location.register,
+              left.location.register));
+          else
+            inherited;
+        end;
+      end;
 
 
      procedure tgppcinlinenode.second_abs_real;
@@ -101,6 +137,7 @@ implementation
            left.location.register));
        end;
 
+
      procedure tgppcinlinenode.second_sqr_real;
        var
          op: tasmop;