瀏覽代碼

* moved (unfinished) routines related to writing taicpu's to ppu files
from x86/aasmcpu to aasmtai and (new) aasmsym, so that when they're
finished they're available for all targets
* added dummy implementation of tai_cpu_abstract.pass1 and pass2 so there
are no more hundreds of warnings on non-x86 about constructing taicpu
instances with abstract methods

git-svn-id: trunk@5787 -

Jonas Maebe 18 年之前
父節點
當前提交
a23fa2e81e

+ 1 - 0
.gitattributes

@@ -8,6 +8,7 @@ compiler/Makefile.fpc svneol=native#text/plain
 compiler/README -text
 compiler/README -text
 compiler/aasmbase.pas svneol=native#text/plain
 compiler/aasmbase.pas svneol=native#text/plain
 compiler/aasmdata.pas svneol=native#text/plain
 compiler/aasmdata.pas svneol=native#text/plain
+compiler/aasmsym.pas svneol=native#text/plain
 compiler/aasmtai.pas svneol=native#text/plain
 compiler/aasmtai.pas svneol=native#text/plain
 compiler/aggas.pas svneol=native#text/plain
 compiler/aggas.pas svneol=native#text/plain
 compiler/alpha/aasmcpu.pas svneol=native#text/plain
 compiler/alpha/aasmcpu.pas svneol=native#text/plain

+ 71 - 0
compiler/aasmsym.pas

@@ -0,0 +1,71 @@
+{
+    Copyright (c) 1998-2007 by Florian Klaempfl and Peter Vreman
+
+    Contains abstract assembler instructions for all processor
+    types, including routines which depend on the symbol table.
+    These cannot be in aasmtai, because the symbol table units
+    depend on that one.
+
+    * Portions of this code was inspired by the NASM sources
+      The Netwide Assembler is Copyright (c) 1996 Simon Tatham and
+      Julian Hall. All rights reserved.
+
+    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 aasmsym;
+
+{$i fpcdefs.inc}
+
+interface
+
+    uses
+      aasmtai;
+
+    type
+      tai_cpu_abstract_sym = class(tai_cpu_abstract)
+      protected
+         procedure ppubuildderefimploper(var o:toper);override;
+         procedure ppuderefoper(var o:toper);override;
+      end;
+
+implementation
+
+    uses
+      symsym;
+
+
+    procedure tai_cpu_abstract_sym.ppubuildderefimploper(var o:toper);
+      begin
+        case o.typ of
+          top_local :
+            o.localoper^.localsymderef.build(tlocalvarsym(o.localoper^.localsym));
+        end;
+      end;
+
+
+    procedure tai_cpu_abstract_sym.ppuderefoper(var o:toper);
+      begin
+        case o.typ of
+          top_ref :
+            begin
+            end;
+          top_local :
+            o.localoper^.localsym:=tlocalvarsym(o.localoper^.localsymderef.resolve);
+        end;
+      end;
+
+end.

+ 93 - 4
compiler/aasmtai.pas

@@ -557,8 +557,8 @@ interface
         }
         }
         tai_cpu_abstract = class(tailineinfo)
         tai_cpu_abstract = class(tailineinfo)
         protected
         protected
-           procedure ppuloadoper(ppufile:tcompilerppufile;var o:toper);virtual;abstract;
-           procedure ppuwriteoper(ppufile:tcompilerppufile;const o:toper);virtual;abstract;
+           procedure ppuloadoper(ppufile:tcompilerppufile;var o:toper);virtual;
+           procedure ppuwriteoper(ppufile:tcompilerppufile;const o:toper);virtual;
            procedure ppubuildderefimploper(var o:toper);virtual;abstract;
            procedure ppubuildderefimploper(var o:toper);virtual;abstract;
            procedure ppuderefoper(var o:toper);virtual;abstract;
            procedure ppuderefoper(var o:toper);virtual;abstract;
         public
         public
@@ -599,8 +599,8 @@ interface
            function spilling_get_operation_type(opnr: longint): topertype;virtual;
            function spilling_get_operation_type(opnr: longint): topertype;virtual;
            function spilling_get_operation_type_ref(opnr: longint; reg: tregister): topertype;virtual;
            function spilling_get_operation_type_ref(opnr: longint; reg: tregister): topertype;virtual;
 
 
-           function  Pass1(objdata:TObjData):longint;virtual;abstract;
-           procedure Pass2(objdata:TObjData);virtual;abstract;
+           function  Pass1(objdata:TObjData):longint;virtual;
+           procedure Pass2(objdata:TObjData);virtual;
 
 
            procedure resetpass1; virtual;
            procedure resetpass1; virtual;
            procedure resetpass2; virtual;
            procedure resetpass2; virtual;
@@ -2319,6 +2319,95 @@ implementation
       end;
       end;
 
 
 
 
+   function tai_cpu_abstract.Pass1(objdata:TObjData):longint;
+      begin
+      end;
+
+
+    procedure tai_cpu_abstract.Pass2(objdata:TObjData);
+      begin
+      end;
+
+
+    procedure tai_cpu_abstract.ppuloadoper(ppufile:tcompilerppufile;var o:toper);
+      begin
+        o.typ:=toptype(ppufile.getbyte);
+        o.ot:=ppufile.getlongint;
+        case o.typ of
+          top_reg :
+            ppufile.getdata(o.reg,sizeof(Tregister));
+          top_ref :
+            begin
+              new(o.ref);
+{$ifdef x86}
+              ppufile.getdata(o.ref^.segment,sizeof(Tregister));
+{$endif x86}
+              ppufile.getdata(o.ref^.base,sizeof(Tregister));
+              ppufile.getdata(o.ref^.index,sizeof(Tregister));
+              ppufile.getdata(o.ref^.refaddr,sizeof(o.ref^.refaddr));;
+              o.ref^.scalefactor:=ppufile.getbyte;
+              o.ref^.offset:=ppufile.getaint;
+              o.ref^.symbol:=ppufile.getasmsymbol;
+              o.ref^.relsymbol:=ppufile.getasmsymbol;
+            end;
+          top_const :
+            o.val:=ppufile.getaint;
+          top_local :
+            begin
+              new(o.localoper);
+              with o.localoper^ do
+                begin
+                  ppufile.getderef(localsymderef);
+                  localsymofs:=ppufile.getaint;
+                  localindexreg:=tregister(ppufile.getlongint);
+                  localscale:=ppufile.getbyte;
+                  localgetoffset:=(ppufile.getbyte<>0);
+                end;
+            end;
+          else
+            internalerror(2007010210);
+        end;
+      end;
+
+
+    procedure tai_cpu_abstract.ppuwriteoper(ppufile:tcompilerppufile;const o:toper);
+      begin
+        ppufile.putbyte(byte(o.typ));
+        ppufile.putlongint(o.ot);
+        case o.typ of
+          top_reg :
+            ppufile.putdata(o.reg,sizeof(Tregister));
+          top_ref :
+            begin
+{$ifdef x86}
+              ppufile.putdata(o.ref^.segment,sizeof(Tregister));
+{$endif x86}
+              ppufile.putdata(o.ref^.base,sizeof(Tregister));
+              ppufile.putdata(o.ref^.index,sizeof(Tregister));
+              ppufile.putdata(o.ref^.refaddr,sizeof(o.ref^.refaddr));
+              ppufile.putbyte(o.ref^.scalefactor);
+              ppufile.putaint(o.ref^.offset);
+              ppufile.putasmsymbol(o.ref^.symbol);
+              ppufile.putasmsymbol(o.ref^.relsymbol);
+            end;
+          top_const :
+            ppufile.putaint(o.val);
+          top_local :
+            begin
+              with o.localoper^ do
+                begin
+                  ppufile.putderef(localsymderef);
+                  ppufile.putaint(localsymofs);
+                  ppufile.putlongint(longint(localindexreg));
+                  ppufile.putbyte(localscale);
+                  ppufile.putbyte(byte(localgetoffset));
+                end;
+            end;
+          else
+            internalerror(2007010211);
+        end;
+      end;
+
 {****************************************************************************
 {****************************************************************************
                               tai_align_abstract
                               tai_align_abstract
  ****************************************************************************}
  ****************************************************************************}

+ 2 - 2
compiler/alpha/aasmcpu.pas

@@ -30,7 +30,7 @@ unit aasmcpu;
 
 
     uses
     uses
        aasmbase,globals,verbose,
        aasmbase,globals,verbose,
-       cpubase,aasmtai,aasmdata;
+       cpubase,aasmtai,aasmdata,aasmsym;
 
 
     type
     type
       tai_frame = class(tai)
       tai_frame = class(tai)
@@ -45,7 +45,7 @@ unit aasmcpu;
         end;
         end;
 
 
 
 
-      taicpu = class(taicpu_abstract)
+      taicpu = class(tai_cpu_abstract_sym)
          constructor op_none(op : tasmop);
          constructor op_none(op : tasmop);
 
 
          constructor op_reg(op : tasmop;_op1 : tregister);
          constructor op_reg(op : tasmop;_op1 : tregister);

+ 2 - 2
compiler/arm/aasmcpu.pas

@@ -27,7 +27,7 @@ interface
 
 
 uses
 uses
   cclasses,globtype,globals,verbose,
   cclasses,globtype,globals,verbose,
-  aasmbase,aasmtai,aasmdata,
+  aasmbase,aasmtai,aasmdata,aasmsym,
   ogbase,
   ogbase,
   symtype,
   symtype,
   cpubase,cpuinfo,cgbase,cgutils;
   cpubase,cpuinfo,cgbase,cgutils;
@@ -153,7 +153,7 @@ uses
       InsTabCache : PInsTabCache;
       InsTabCache : PInsTabCache;
 
 
     type
     type
-      taicpu = class(tai_cpu_abstract)
+      taicpu = class(tai_cpu_abstract_sym)
          oppostfix : TOpPostfix;
          oppostfix : TOpPostfix;
          roundingmode : troundingmode;
          roundingmode : troundingmode;
          procedure loadshifterop(opidx:longint;const so:tshifterop);
          procedure loadshifterop(opidx:longint;const so:tshifterop);

+ 2 - 2
compiler/m68k/aasmcpu.pas

@@ -26,7 +26,7 @@ unit aasmcpu;
 interface
 interface
 
 
 uses
 uses
-  cclasses,aasmtai,aasmdata,
+  cclasses,aasmtai,aasmdata,aasmsym,
   aasmbase,globals,verbose,symtype,
   aasmbase,globals,verbose,symtype,
   cpubase,cpuinfo,cgbase,cgutils;
   cpubase,cpuinfo,cgbase,cgutils;
 
 
@@ -38,7 +38,7 @@ const
   O_MOV_DEST = 1;
   O_MOV_DEST = 1;
 type
 type
 
 
-  taicpu = class(tai_cpu_abstract)
+  taicpu = class(tai_cpu_abstract_sym)
      opsize : topsize;
      opsize : topsize;
      constructor op_none(op : tasmop);
      constructor op_none(op : tasmop);
      constructor op_none(op : tasmop;_size : topsize);
      constructor op_none(op : tasmop;_size : topsize);

+ 2 - 3
compiler/ppcgen/aasmcpu.pas

@@ -27,7 +27,7 @@ interface
 
 
 uses
 uses
   globtype,verbose,
   globtype,verbose,
-  aasmbase,aasmtai,aasmdata,
+  aasmbase,aasmtai,aasmdata,aasmsym,
   cpubase,cgbase,cgutils;
   cpubase,cgbase,cgutils;
 
 
     const
     const
@@ -38,7 +38,7 @@ uses
 
 
 
 
     type
     type
-      taicpu = class(tai_cpu_abstract)
+      taicpu = class(tai_cpu_abstract_sym)
          constructor op_none(op : tasmop);
          constructor op_none(op : tasmop);
 
 
          constructor op_reg(op : tasmop;_op1 : tregister);
          constructor op_reg(op : tasmop;_op1 : tregister);
@@ -81,7 +81,6 @@ uses
 
 
          procedure loadbool(opidx:aint;_b:boolean);
          procedure loadbool(opidx:aint;_b:boolean);
 
 
-
          function is_same_reg_move(regtype: Tregistertype):boolean; override;
          function is_same_reg_move(regtype: Tregistertype):boolean; override;
 
 
          { register spilling code }
          { register spilling code }

+ 2 - 2
compiler/sparc/aasmcpu.pas

@@ -28,7 +28,7 @@ interface
 uses
 uses
   cclasses,
   cclasses,
   globtype,globals,verbose,
   globtype,globals,verbose,
-  aasmbase,aasmtai,aasmdata,
+  aasmbase,aasmtai,aasmdata,aasmsym,
   cgbase,cgutils,cpubase,cpuinfo;
   cgbase,cgutils,cpubase,cpuinfo;
 
 
     const
     const
@@ -38,7 +38,7 @@ uses
       O_MOV_DEST = 1;
       O_MOV_DEST = 1;
 
 
     type
     type
-      taicpu = class(tai_cpu_abstract)
+      taicpu = class(tai_cpu_abstract_sym)
          delayslot_annulled : boolean;   { conditinal opcode with ,a }
          delayslot_annulled : boolean;   { conditinal opcode with ,a }
          constructor op_none(op : tasmop);
          constructor op_none(op : tasmop);
 
 

+ 2 - 98
compiler/x86/aasmcpu.pas

@@ -34,7 +34,7 @@ interface
       cpubase,
       cpubase,
       cgbase,cgutils,
       cgbase,cgutils,
       symtype,
       symtype,
-      aasmbase,aasmtai,aasmdata,
+      aasmbase,aasmtai,aasmdata,aasmsym,
       ogbase;
       ogbase;
 
 
     const
     const
@@ -192,7 +192,7 @@ interface
          function calculatefillbuf(var buf : tfillbuffer):pchar;override;
          function calculatefillbuf(var buf : tfillbuffer):pchar;override;
       end;
       end;
 
 
-      taicpu = class(tai_cpu_abstract)
+      taicpu = class(tai_cpu_abstract_sym)
          opsize    : topsize;
          opsize    : topsize;
          constructor op_none(op : tasmop);
          constructor op_none(op : tasmop);
          constructor op_none(op : tasmop;_size : topsize);
          constructor op_none(op : tasmop;_size : topsize);
@@ -243,11 +243,6 @@ interface
          function is_same_reg_move(regtype: Tregistertype):boolean;override;
          function is_same_reg_move(regtype: Tregistertype):boolean;override;
          { register spilling code }
          { register spilling code }
          function spilling_get_operation_type(opnr: longint): topertype;override;
          function spilling_get_operation_type(opnr: longint): topertype;override;
-      protected
-         procedure ppuloadoper(ppufile:tcompilerppufile;var o:toper);override;
-         procedure ppuwriteoper(ppufile:tcompilerppufile;const o:toper);override;
-         procedure ppubuildderefimploper(var o:toper);override;
-         procedure ppuderefoper(var o:toper);override;
       private
       private
          { next fields are filled in pass1, so pass2 is faster }
          { next fields are filled in pass1, so pass2 is faster }
          insentry  : PInsEntry;
          insentry  : PInsEntry;
@@ -833,97 +828,6 @@ implementation
       end;
       end;
 
 
 
 
-    procedure taicpu.ppuloadoper(ppufile:tcompilerppufile;var o:toper);
-      begin
-        o.typ:=toptype(ppufile.getbyte);
-        o.ot:=ppufile.getlongint;
-        case o.typ of
-          top_reg :
-            ppufile.getdata(o.reg,sizeof(Tregister));
-          top_ref :
-            begin
-              new(o.ref);
-              ppufile.getdata(o.ref^.segment,sizeof(Tregister));
-              ppufile.getdata(o.ref^.base,sizeof(Tregister));
-              ppufile.getdata(o.ref^.index,sizeof(Tregister));
-              o.ref^.scalefactor:=ppufile.getbyte;
-              o.ref^.offset:=ppufile.getaint;
-              o.ref^.symbol:=ppufile.getasmsymbol;
-              o.ref^.relsymbol:=ppufile.getasmsymbol;
-            end;
-          top_const :
-            o.val:=ppufile.getaint;
-          top_local :
-            begin
-              new(o.localoper);
-              with o.localoper^ do
-                begin
-                  ppufile.getderef(localsymderef);
-                  localsymofs:=ppufile.getaint;
-                  localindexreg:=tregister(ppufile.getlongint);
-                  localscale:=ppufile.getbyte;
-                  localgetoffset:=(ppufile.getbyte<>0);
-                end;
-            end;
-        end;
-      end;
-
-
-    procedure taicpu.ppuwriteoper(ppufile:tcompilerppufile;const o:toper);
-      begin
-        ppufile.putbyte(byte(o.typ));
-        ppufile.putlongint(o.ot);
-        case o.typ of
-          top_reg :
-            ppufile.putdata(o.reg,sizeof(Tregister));
-          top_ref :
-            begin
-              ppufile.putdata(o.ref^.segment,sizeof(Tregister));
-              ppufile.putdata(o.ref^.base,sizeof(Tregister));
-              ppufile.putdata(o.ref^.index,sizeof(Tregister));
-              ppufile.putbyte(o.ref^.scalefactor);
-              ppufile.putaint(o.ref^.offset);
-              ppufile.putasmsymbol(o.ref^.symbol);
-              ppufile.putasmsymbol(o.ref^.relsymbol);
-            end;
-          top_const :
-            ppufile.putaint(o.val);
-          top_local :
-            begin
-              with o.localoper^ do
-                begin
-                  ppufile.putderef(localsymderef);
-                  ppufile.putaint(localsymofs);
-                  ppufile.putlongint(longint(localindexreg));
-                  ppufile.putbyte(localscale);
-                  ppufile.putbyte(byte(localgetoffset));
-                end;
-            end;
-        end;
-      end;
-
-
-    procedure taicpu.ppubuildderefimploper(var o:toper);
-      begin
-        case o.typ of
-          top_local :
-            o.localoper^.localsymderef.build(tlocalvarsym(o.localoper^.localsym));
-        end;
-      end;
-
-
-    procedure taicpu.ppuderefoper(var o:toper);
-      begin
-        case o.typ of
-          top_ref :
-            begin
-            end;
-          top_local :
-            o.localoper^.localsym:=tlocalvarsym(o.localoper^.localsymderef.resolve);
-        end;
-      end;
-
-
     procedure taicpu.CheckNonCommutativeOpcodes;
     procedure taicpu.CheckNonCommutativeOpcodes;
       begin
       begin
         { we need ATT order }
         { we need ATT order }