浏览代码

* a ppcppc can be build again

peter 23 年之前
父节点
当前提交
51688dade3

+ 11 - 9
compiler/powerpc/cgcpu.pas

@@ -42,8 +42,7 @@ unit cgcpu;
         procedure a_paramaddr_ref(list : taasmoutput;const r : treference;nr : longint);override;
 
 
-        procedure a_call_name(list : taasmoutput;const s : string;
-          offset : longint);override;
+        procedure a_call_name(list : taasmoutput;const s : string);override;
 
         procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; a: AWord; reg: TRegister); override;
         procedure a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister); override;
@@ -70,7 +69,6 @@ unit cgcpu;
           l : tasmlabel);override;
         procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); override;
 
-        procedure a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel); override;
         procedure a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel); override;
 
         procedure g_flags2reg(list: taasmoutput; const f: TResFlags; reg: TRegister); override;
@@ -93,6 +91,8 @@ unit cgcpu;
 
         private
 
+        procedure a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
+
         procedure g_return_from_proc_sysv(list : taasmoutput;parasize : aword);
         procedure g_return_from_proc_mac(list : taasmoutput;parasize : aword);
 
@@ -226,8 +226,7 @@ const
 
 { calling a code fragment by name }
 
-    procedure tcgppc.a_call_name(list : taasmoutput;const s : string;
-      offset : longint);
+    procedure tcgppc.a_call_name(list : taasmoutput;const s : string);
 
       begin
  { save our RTOC register value. Only necessary when doing pointer based    }
@@ -730,7 +729,7 @@ const
         list.concat(taicpu.op_reg_reg_const(A_SUBFIC,R_12,R_12,
           -localsize));
         { establish new alignment }
-        list.concat(taicpu.op_reg_reg_reg(A_STWUX,STACK_POINTER,STACK_POINTER_REG,R_12));
+        list.concat(taicpu.op_reg_reg_reg(A_STWUX,STACK_POINTER_REG,STACK_POINTER_REG,R_12));
         a_reg_dealloc(list,R_12);
         { save floating-point registers }
         { !!! has to be optimized: only save registers that are used }
@@ -789,7 +788,7 @@ const
         a_reg_alloc(list,R_0);
         list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_CR));
         list.concat(taicpu.op_reg_ref(A_STW,R_0,
-          new_reference(stack_pointer,LA_CR)));
+          new_reference(stack_pointer_reg,LA_CR)));
         a_reg_dealloc(list,R_0);
         { save pointer to incoming arguments }
         list.concat(taicpu.op_reg_reg_const(A_ORI,R_31,STACK_POINTER_REG,0));
@@ -980,7 +979,7 @@ const
            end
          else
            a_jmp_cond(list,OC_AE,hl);
-         a_call_name(list,'FPC_OVERFLOW',0);
+         a_call_name(list,'FPC_OVERFLOW');
          a_label(list,hl);
       end;
 
@@ -1174,7 +1173,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.13  2002-04-20 21:41:51  carl
+  Revision 1.14  2002-05-13 19:52:46  peter
+    * a ppcppc can be build again
+
+  Revision 1.13  2002/04/20 21:41:51  carl
   * renamed some constants
 
   Revision 1.12  2002/04/06 18:13:01  jonas

+ 17 - 1
compiler/powerpc/cpuasm.pas

@@ -80,6 +80,9 @@ type
      destructor destroy;override;
   end;
 
+    procedure InitAsm;
+    procedure DoneAsm;
+
 
 implementation
 
@@ -410,10 +413,23 @@ implementation
         inherited destroy;
       end;
 
+
+    procedure InitAsm;
+      begin
+      end;
+
+
+    procedure DoneAsm;
+      begin
+      end;
+
 end.
 {
   $Log$
-  Revision 1.3  2001-12-29 15:28:58  jonas
+  Revision 1.4  2002-05-13 19:52:46  peter
+    * a ppcppc can be build again
+
+  Revision 1.3  2001/12/29 15:28:58  jonas
     * powerpc/cgcpu.pas compiles :)
     * several powerpc-related fixes
     * cpuasm unit is now based on common tainst unit

+ 45 - 8
compiler/powerpc/cpubase.pas

@@ -66,6 +66,20 @@ const
   {$endif}
 {$endif}
 
+{*****************************************************************************
+                          Default generic sizes
+*****************************************************************************}
+
+   {# Defines the default address size for a processor, }
+   OS_ADDR = OS_32;
+   {# the natural int size for a processor,             }
+   OS_INT = OS_32;
+   {# the maximum float size for a processor,           }
+   OS_FLOAT = OS_F64;
+   {# the size of a vector register for a processor     }
+   OS_VECTOR = OS_M128;
+
+
 type
   TAsmOp=(A_None,
     { normal opcodes }
@@ -197,6 +211,20 @@ Const
     'XER','LR','CTR','FPSCR'
   );
 
+  std_reg2str : reg2strtable = ('',
+    'r0','r1','r2','r3','r4','r5','r6','r7','r8','r9','r10','r11','r12','r13',
+    'r14','r15','r16','r17','r18','r19','r20','r21','r22','r23','r24','r25',
+    'r26','r27','r28','r29','r30','r31',
+    'F0','F1','F2','F3','F4','F5','F6','F7', 'F8','F9','F10','F11','F12',
+    'F13','F14','F15','F16','F17', 'F18','F19','F20','F21','F22', 'F23','F24',
+    'F25','F26','F27','F28','F29','F30','F31',
+    'M0','M1','M2','M3','M4','M5','M6','M7','M8','M9','M10','M11','M12',
+    'M13','M14','M15','M16','M17','M18','M19','M20','M21','M22', 'M23','M24',
+    'M25','M26','M27','M28','M29','M30','M31',
+    'CR','CR0','CR1','CR2','CR3','CR4','CR5','CR6','CR7',
+    'XER','LR','CTR','FPSCR'
+  );
+
   { FIX ME !!!!!!!!! }
   ALL_REGISTERS = [R_0..R_FPSCR];
 
@@ -287,6 +315,7 @@ const
 *****************************************************************************}
 
 type
+  trefoptions=(ref_none,ref_parafixup,ref_localfixup,ref_selffixup);
 
   { since we have only 16 offsets, we need to be able to specify the high }
   { and low 16 bits of the address of a symbol                            }
@@ -301,6 +330,7 @@ type
      symbol      : tasmsymbol;
      symaddr     : trefsymaddr;
      offsetfixup : longint;
+     options     : trefoptions;
      alignment   : byte;
   end;
 
@@ -439,6 +469,9 @@ const
   self_pointer_reg  = R_9;
   accumulator      = R_3;
   accumulatorhigh  = R_4;
+{$warning I don't know the exact values, please check (PFV) }
+  fpuresultreg = R_F0;
+  mmresultreg = R_M0;
   max_scratch_regs = 3;
   scratch_regs: Array[1..max_scratch_regs] of TRegister = (R_11,R_12,R_31);
 
@@ -467,7 +500,8 @@ const
   LA_LR = 8;
  { offset in the linkage area for the saved RTOC register}
   LA_RTOC = 20;
-  
+
+
 {*****************************************************************************
                        GCC /ABI linking information
 *****************************************************************************}
@@ -475,20 +509,20 @@ const
   {# Registers which must be saved when calling a routine declared as
      cppdecl, cdecl, stdcall, safecall, palmossyscall. The registers
      saved should be the ones as defined in the target ABI and / or GCC.
-     
+
      This value can be deduced from CALLED_USED_REGISTERS array in the
      GCC source.
   }
   std_saved_registers = [R_13..R_29];
   {# Required parameter alignment when calling a routine declared as
      stdcall and cdecl. The alignment value should be the one defined
-     by GCC or the target ABI. 
-     
-     The value of this constant is equal to the constant 
+     by GCC or the target ABI.
+
+     The value of this constant is equal to the constant
      PARM_BOUNDARY / BITS_PER_UNIT in the GCC source.
-  }     
+  }
   std_param_align = 4;  { for 32-bit version only }
-  
+
 
 {*****************************************************************************
                                   Helpers
@@ -660,7 +694,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.9  2002-04-21 15:48:39  carl
+  Revision 1.10  2002-05-13 19:52:46  peter
+    * a ppcppc can be build again
+
+  Revision 1.9  2002/04/21 15:48:39  carl
   * some small updates according to i386 version
 
   Revision 1.8  2002/04/20 21:41:51  carl

+ 12 - 5
compiler/powerpc/cpuinfo.pas

@@ -19,9 +19,9 @@ Interface
 
 Type
    { Architecture word - Native unsigned type }
-   AWord = Dword;
+   AWord  = Cardinal;
+   PAWord = ^AWord;
 
-Type
    { this must be an ordinal type with the same size as a pointer }
    { to allow some dirty type casts for example when using        }
    { tconstsym.value                                              }
@@ -29,18 +29,25 @@ Type
    { pointer(-1) will result in a pointer with the value          }
    { $fffffffffffffff on a 32bit machine if the compiler uses     }
    { int64 constants internally (JM)                              }
-   TConstPtrUInt = DWord;
+   TConstPtrUInt = Cardinal;
 
 Const
-   { Size of native extended type }
+   {# Size of native extended floating point type }
    extended_size = 8;
+   {# Size of a pointer                           }
+   pointer_size  = 4;
+   {# Size of a multimedia register               }
+   mmreg_size = 16;
 
 Implementation
 
 end.
 {
   $Log$
-  Revision 1.3  2002-04-07 13:43:11  carl
+  Revision 1.4  2002-05-13 19:52:46  peter
+    * a ppcppc can be build again
+
+  Revision 1.3  2002/04/07 13:43:11  carl
   - moved type constant
 
   Revision 1.2  2001/12/29 15:28:58  jonas

+ 17 - 5
compiler/powerpc/cpunode.pas

@@ -29,16 +29,28 @@ unit cpunode;
   implementation
 
     uses
-       ncgbas,ncgflw,ncgcnv,ncgmem,ncgcon,
-       nppcld,nppcadd,nppccal,nppccon,nppcflw,nppcmat,nppcmem,
-       nppcset,nppcinl,nppcopt,
+//       nppcadd,
+//       nppccal,
+//       nppccon,
+//       nppcflw,
+       nppcmat,
+//       nppcmem,
+//       nppcset,
+//       nppcinl,
+//       nppcopt,
        { this not really a node }
-       nppcobj;
+//       nppcobj,
+       { generic nodes }
+       ncgbas,ncgld,ncgflw,ncgcnv,ncgmem,ncgcon
+       ;
 
 end.
 {
   $Log$
-  Revision 1.1  2002-04-06 18:13:02  jonas
+  Revision 1.2  2002-05-13 19:52:46  peter
+    * a ppcppc can be build again
+
+  Revision 1.1  2002/04/06 18:13:02  jonas
     * several powerpc-related additions and fixes
 
   Revision 1.6  2001/09/29 21:32:47  jonas

+ 186 - 0
compiler/powerpc/cpuswtch.pas

@@ -0,0 +1,186 @@
+{
+    $Id$
+    Copyright (c) 1998-2000 by Florian Klaempfl, Pierre Muller
+
+    interprets the commandline options which are powerpc specific
+
+    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 cpuswtch;
+
+{$i defines.inc}
+
+interface
+
+uses
+  options;
+
+type
+  toptionpowerpc=class(toption)
+    procedure interpret_proc_specific_options(const opt:string);override;
+  end;
+
+implementation
+
+uses
+  cutils,globtype,systems,globals;
+
+procedure toptionpowerpc.interpret_proc_specific_options(const opt:string);
+begin
+{$ifdef dummy}
+  More:=Upper(copy(opt,3,length(opt)-2));
+  case opt[2] of
+   'O' : Begin
+           j := 3;
+           While (j <= Length(Opt)) Do
+             Begin
+               case opt[j] of
+                 '-' :
+                   begin
+                     initglobalswitches:=initglobalswitches-[cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_littlesize,
+                       cs_regalloc,cs_uncertainopts];
+                     FillChar(ParaAlignment,sizeof(ParaAlignment),0);
+                   end;
+                 'a' :
+                   begin
+                     UpdateAlignmentStr(Copy(Opt,j+1,255),ParaAlignment);
+                     j:=length(Opt);
+                   end;
+                 'g' : initglobalswitches:=initglobalswitches+[cs_littlesize];
+                 'G' : initglobalswitches:=initglobalswitches-[cs_littlesize];
+                 'r' :
+                   begin
+                     initglobalswitches:=initglobalswitches+[cs_regalloc];
+                     Simplify_ppu:=false;
+                   end;
+                 'u' : initglobalswitches:=initglobalswitches+[cs_uncertainopts];
+                 '1' : initglobalswitches:=initglobalswitches-[cs_fastoptimize,cs_slowoptimize]+[cs_optimize];
+                 '2' : initglobalswitches:=initglobalswitches-[cs_slowoptimize]+[cs_optimize,cs_fastoptimize];
+                 '3' : initglobalswitches:=initglobalswitches+[cs_optimize,cs_fastoptimize,cs_slowoptimize];
+                 'p' :
+                   Begin
+                     If j < Length(Opt) Then
+                       Begin
+                         Case opt[j+1] Of
+                           '1': initoptprocessor := Class386;
+                           '2': initoptprocessor := ClassP5;
+                           '3': initoptprocessor := ClassP6
+                           Else IllegalPara(Opt)
+                         End;
+                         Inc(j);
+                       End
+                     Else IllegalPara(opt)
+                   End;
+{$ifdef USECMOV}
+                 's' :
+                   Begin
+                     If j < Length(Opt) Then
+                       Begin
+                         Case opt[j+1] Of
+                           '3': initspecificoptprocessor:=ClassP6
+                           Else IllegalPara(Opt)
+                         End;
+                         Inc(j);
+                       End
+                     Else IllegalPara(opt)
+                   End
+{$endif USECMOV}
+                 else IllegalPara(opt);
+               End;
+               Inc(j)
+             end;
+         end;
+   'R' : begin
+           if More='ATT' then
+            initasmmode:=asmmode_i386_att
+           else
+            if More='INTEL' then
+             initasmmode:=asmmode_i386_intel
+           else
+            if More='DIRECT' then
+             initasmmode:=asmmode_i386_direct
+           else
+            IllegalPara(opt);
+         end;
+  else
+   IllegalPara(opt);
+  end;
+{$endif dummy}
+end;
+
+
+initialization
+  coption:=toptionpowerpc;
+end.
+{
+  $Log$
+  Revision 1.1  2002-05-13 19:52:46  peter
+    * a ppcppc can be build again
+
+  Revision 1.4  2001/07/01 20:16:20  peter
+    * alignmentinfo record added
+    * -Oa argument supports more alignment settings that can be specified
+      per type: PROC,LOOP,VARMIN,VARMAX,CONSTMIN,CONSTMAX,RECORDMIN
+      RECORDMAX,LOCALMIN,LOCALMAX. It is possible to set the mimimum
+      required alignment and the maximum usefull alignment. The final
+      alignment will be choosen per variable size dependent on these
+      settings
+
+  Revision 1.3  2001/05/12 12:11:31  peter
+    * simplify_ppu is now the default, a recompile of the compiler now
+      only compiles pp.pas
+
+  Revision 1.2  2000/12/23 19:46:49  peter
+    * object to class conversion
+    * more verbosity for -vt and -vd
+    * -i options can be put after eachother so the Makefiles only need
+      to call fpc once for all info (will be twice as the first one will
+      be to check the version if fpc supports multiple info)
+
+  Revision 1.1  2000/11/30 22:42:50  florian
+  * renamed
+
+  Revision 1.1  2000/11/30 22:21:56  florian
+    * moved to i386
+
+  Revision 1.6  2000/10/24 10:40:53  jonas
+    + register renaming ("fixes" bug1088)
+    * changed command line options meanings for optimizer:
+        O2 now means peepholopts, CSE and register renaming in 1 pass
+        O3 is the same, but repeated until no further optimizations are
+          possible or until 5 passes have been done (to avoid endless loops)
+    * changed aopt386 so it does this looping
+    * added some procedures from csopt386 to the interface because they're
+      used by rropt386 as well
+    * some changes to csopt386 and daopt386 so that newly added instructions
+      by the CSE get optimizer info (they were simply skipped previously),
+      this fixes some bugs
+
+  Revision 1.5  2000/09/24 15:06:20  peter
+    * use defines.inc
+
+  Revision 1.4  2000/08/27 16:11:51  peter
+    * moved some util functions from globals,cobjects to cutils
+    * splitted files into finput,fmodule
+
+  Revision 1.3  2000/07/27 13:03:36  jonas
+    * release alignopts
+
+  Revision 1.2  2000/07/13 11:32:44  michael
+  + removed logs
+
+}

+ 55 - 0
compiler/powerpc/cputarg.pas

@@ -0,0 +1,55 @@
+{
+    $Id$
+    Copyright (c) 2001 by Peter Vreman
+
+    Includes the powerpc dependent target units
+
+    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 cputarg;
+
+{$i defines.inc}
+
+interface
+
+
+implementation
+
+    uses
+      systems { prevent a syntax error when nothing is included }
+
+{**************************************
+             Targets
+**************************************}
+
+    {$ifndef NOTARGETLINUX}
+      ,t_linux
+    {$endif}
+
+{**************************************
+             Assemblers
+**************************************}
+
+      ;
+
+end.
+{
+  $Log$
+  Revision 1.1  2002-05-13 19:52:46  peter
+    * a ppcppc can be build again
+
+}

+ 13 - 11
compiler/powerpc/nppcmat.pas

@@ -73,14 +73,13 @@ implementation
          numerator,
          divider,
          resultreg  : tregister;
-         saved      : boolean;
+         saved      : tmaybesave;
 
       begin
          secondpass(left);
-         saved:=maybe_savetotemp(right.registers32,left,is_64bitint(left.resulttype.def));
+         maybe_save(exprasmlist,right.registers32,left.location,saved);
          secondpass(right);
-         if saved then
-           restorefromtemp(left,is_64bitint(left.resulttype.def));
+         maybe_restore(exprasmlist,left.location,saved);
          set_location(location,left.location);
 
          resultreg := R_NO;
@@ -171,14 +170,13 @@ implementation
          op : topcg;
          asmop1, asmop2: tasmop;
          shiftval: aword;
-         saved : boolean;
+         saved : tmaybesave;
 
       begin
          secondpass(left);
-         saved:=maybe_savetotemp(right.registers32,left,is_64bitint(left.resulttype.def));
+         maybe_save(exprasmlist,right.registers32,left.location,saved);
          secondpass(right);
-         if saved then
-           restorefromtemp(left,is_64bitint(left.resulttype.def));
+         maybe_restore(exprasmlist,left.location,saved);
 
          if is_64bitint(left.resulttype.def) then
            begin
@@ -516,7 +514,7 @@ implementation
                   truelabel:=falselabel;
                   falselabel:=hl;
                   secondpass(left);
-                  maketojumpbool(left,lr_load_regvars);
+                  maketojumpbool(exprasmlist,left,lr_load_regvars);
                   hl:=truelabel;
                   truelabel:=falselabel;
                   falselabel:=hl;
@@ -524,7 +522,8 @@ implementation
               LOC_FLAGS :
                 begin
                   location.resflags:=left.location.resflags;
-!!!                  inverse_flags(left.location.resflags);
+{$warning !!!}
+//                  inverse_flags(left.location.resflags);
                 end;
               LOC_REGISTER, LOC_CREGISTER, LOC_REFERENCE, LOC_CREFERENCE :
                 begin
@@ -623,7 +622,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.4  2002-04-21 15:48:39  carl
+  Revision 1.5  2002-05-13 19:52:46  peter
+    * a ppcppc can be build again
+
+  Revision 1.4  2002/04/21 15:48:39  carl
   * some small updates according to i386 version
 
   Revision 1.3  2002/04/06 18:13:02  jonas