Bläddra i källkod

* merged agx64att and ag386att to x86/agx86att

florian 22 år sedan
förälder
incheckning
ad2f6d6dab

+ 5 - 2
compiler/i386/aasmcpu.pas

@@ -211,7 +211,7 @@ implementation
 
      uses
        cutils,
-       ag386att;
+       agx86att;
 
 {*****************************************************************************
                               Instruction table
@@ -1959,7 +1959,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.17  2003-04-22 14:33:38  peter
+  Revision 1.18  2003-04-25 12:04:31  florian
+    * merged agx64att and ag386att to x86/agx86att
+
+  Revision 1.17  2003/04/22 14:33:38  peter
     * removed some notes/hints
 
   Revision 1.16  2003/04/22 10:09:35  daniel

+ 5 - 2
compiler/i386/cputarg.pas

@@ -72,7 +72,7 @@ implementation
 **************************************}
 
     {$ifndef NOAG386ATT}
-      ,ag386att
+      ,agx86att
     {$endif}
     {$ifndef NOAG386NSM}
       ,ag386nsm
@@ -88,7 +88,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.10  2003-03-23 23:33:10  hajny
+  Revision 1.11  2003-04-25 12:04:31  florian
+    * merged agx64att and ag386att to x86/agx86att
+
+  Revision 1.10  2003/03/23 23:33:10  hajny
     + emx target added
 
   Revision 1.9  2002/05/18 13:34:22  peter

+ 5 - 2
compiler/i386/ra386.pas

@@ -81,7 +81,7 @@ implementation
 
 uses
   globtype,globals,systems,verbose,
-  cpuinfo,ag386att;
+  cpuinfo,agx86att;
 
 {$define ATTOP}
 {$define INTELOP}
@@ -680,7 +680,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.29  2003-02-19 22:00:16  daniel
+  Revision 1.30  2003-04-25 12:04:31  florian
+    * merged agx64att and ag386att to x86/agx86att
+
+  Revision 1.29  2003/02/19 22:00:16  daniel
     * Code generator converted to new register notation
     - Horribily outdated todo.txt removed
 

+ 5 - 2
compiler/i386/ra386att.pas

@@ -48,7 +48,7 @@ Implementation
        nbas,
        { parser }
        scanner,
-       ra386,ag386att,rautils
+       ra386,agx86att,rautils
        ;
 
 type
@@ -2133,7 +2133,10 @@ finalization
 end.
 {
   $Log$
-  Revision 1.41  2003-04-21 20:05:10  peter
+  Revision 1.42  2003-04-25 12:04:31  florian
+    * merged agx64att and ag386att to x86/agx86att
+
+  Revision 1.41  2003/04/21 20:05:10  peter
     * removed some ie checks
 
   Revision 1.40  2003/03/18 18:15:53  peter

+ 5 - 2
compiler/i386/radirect.pas

@@ -51,7 +51,7 @@ interface
        { codegen }
        cgbase,
        { constants }
-       ag386att,
+       agx86att,
        cpubase
        ;
 
@@ -308,7 +308,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.7  2003-04-21 20:05:10  peter
+  Revision 1.8  2003-04-25 12:04:31  florian
+    * merged agx64att and ag386att to x86/agx86att
+
+  Revision 1.7  2003/04/21 20:05:10  peter
     * removed some ie checks
 
   Revision 1.6  2003/01/08 18:43:57  daniel

+ 81 - 19
compiler/i386/ag386att.pas → compiler/x86/agx86att.pas

@@ -22,7 +22,7 @@
 }
 { This unit implements an asmoutput class for i386 AT&T syntax
 }
-unit ag386att;
+unit agx86att;
 
 {$i fpcdefs.inc}
 
@@ -34,7 +34,7 @@ interface
       aasmbase,aasmtai,aasmcpu,assemble,aggas;
 
     type
-      T386ATTAssembler=class(TGNUassembler)
+      Tx86ATTAssembler=class(TGNUassembler)
       private
         procedure WriteReference(var ref : treference);
         procedure WriteOper(const o:toper);
@@ -46,13 +46,35 @@ interface
     TAttSuffix = (AttSufNONE,AttSufINT,AttSufFPU,AttSufFPUint);
 
     const
+{$ifdef x86_64}
+      gas_op2str:op2strtable={$i x64att.inc}
+      gas_needsuffix:array[tasmop] of TAttSuffix={$i x64atts.inc}
+{$else x86_64}
       gas_op2str:op2strtable={$i i386att.inc}
       gas_needsuffix:array[tasmop] of TAttSuffix={$i i386atts.inc}
+{$endif x86_64}
 
       gas_reg2str : reg2strtable = ('',
+      {$ifdef x86_64}
+         '%rax','%rcx','%rdx','%rbx','%rsp','%rbp','%rsi','%rdi',
+         '%r8','%r9','%r10','%r11','%r12','%r13','%r14','%r15','%rip',
+      {$endif x86_64}
         '%eax','%ecx','%edx','%ebx','%esp','%ebp','%esi','%edi',
+      {$ifdef x86_64}
+         '%r8d','%r9d','%r10d','%r11d','%r12d','%r13d','%r14d','%r15d',
+      {$endif x86_64}
         '%ax','%cx','%dx','%bx','%sp','%bp','%si','%di',
-        '%al','%cl','%dl','%bl','%ah','%ch','%bh','%dh',
+      {$ifdef x86_64}
+         '%r8w','%r9w','%r10w','%r11w','%r12w','%r13w','%r14w','%r15w',
+      {$endif x86_64}
+        '%al','%cl','%dl','%bl',
+      {$ifdef x86_64}
+        '%spl','%bpl','%sil','%dil',
+        '%r8b','%r9b','%r10b','%r11b','%r12b','%r13b','%r14b','%r15b',
+      {$endif x86_64}
+        '%ah','%ch','%bh','%dh',
+      {$ifdef x86_64}
+      {$endif x86_64}
         '%cs','%ds','%es','%ss','%fs','%gs',
         '%st','%st(0)','%st(1)','%st(2)','%st(3)','%st(4)','%st(5)','%st(6)','%st(7)',
         '%dr0','%dr1','%dr2','%dr3','%dr6','%dr7',
@@ -60,11 +82,14 @@ interface
         '%tr3','%tr4','%tr5','%tr6','%tr7',
         '%mm0','%mm1','%mm2','%mm3','%mm4','%mm5','%mm6','%mm7',
         '%xmm0','%xmm1','%xmm2','%xmm3','%xmm4','%xmm5','%xmm6','%xmm7'
+      {$ifdef x86_64}
+        ,'%xmm8','%xmm9','%xmm10','%xmm11','%xmm12','%xmm13','%xmm14','%xmm15'
+      {$endif x86_64}
        );
-       
+
      regname_count=45;
      regname_count_bsstart=32;
-     
+
      gas_regname2regnum:array[0..regname_count-1] of regname2regnumrec=(
         (name:'%ah';     number:NR_AH),
         (name:'%al';     number:NR_AL),
@@ -113,15 +138,24 @@ interface
         (name:'%tr7';    number:NR_DR7)
      );
 
+{$ifdef x86_64}
+     gas_opsize2str : array[topsize] of string[2] = ('',
+       'b','w','l','bw','bl','wl','bq','wq','lq',
+       's','l','q',
+       's','l','t','d','q','v','x',
+       '','',''
+     );
+{$else x86_64}
      gas_opsize2str : array[topsize] of string[2] = ('',
        'b','w','l','bw','bl','wl',
        's','l','q',
        's','l','t','d','q','v','',
        '','',''
      );
+{$endif x86_64}
 
      function gas_regnum_search(const s:string):Tnewregister;
-       
+
 
   implementation
 
@@ -131,10 +165,10 @@ interface
 
 
 {****************************************************************************
-                            TI386ATTASMOUTPUT
+                            TX86ATTASMOUTPUT
  ****************************************************************************}
 
-    procedure T386AttAssembler.WriteReference(var ref : treference);
+    procedure Tx86AttAssembler.WriteReference(var ref : treference);
       begin
         with ref do
          begin
@@ -189,7 +223,7 @@ interface
       end;
 
 
-    procedure T386AttAssembler.WriteOper(const o:toper);
+    procedure Tx86AttAssembler.WriteOper(const o:toper);
       begin
         case o.typ of
           top_reg :
@@ -222,7 +256,7 @@ interface
       end;
 
 
-    procedure T386AttAssembler.WriteOper_jmp(const o:toper);
+    procedure Tx86AttAssembler.WriteOper_jmp(const o:toper);
       begin
         case o.typ of
           top_reg :
@@ -253,7 +287,7 @@ interface
       end;
 
 
-    procedure T386AttAssembler.WriteInstruction(hp: tai);
+    procedure Tx86AttAssembler.WriteInstruction(hp: tai);
       var
        op       : tasmop;
        calljmp  : boolean;
@@ -271,7 +305,7 @@ interface
         if (Taicpu(hp).oper[0].typ=top_reg) and
             (Taicpu(hp).oper[0].reg.enum>lastreg) then
           internalerror(200301081);
-          
+
         if (not calljmp) and
             (gas_needsuffix[op]<>AttSufNONE) and
             (op<>A_FNSTSW) and (op<>A_FSTSW) and
@@ -306,12 +340,12 @@ interface
 
 
      function gas_regnum_search(const s:string):Tnewregister;
-     
+
      {Searches the register number that belongs to the register in s.
       s must be in uppercase!.}
-     
+
      var i,p:byte;
-     
+
      begin
         {Binary search.}
         p:=0;
@@ -333,6 +367,26 @@ interface
 *****************************************************************************}
 
     const
+{$ifdef x86_64}
+       as_x86_64_as_info : tasminfo =
+          (
+            id     : as_x86_64_as;
+            idtxt  : 'AS';
+            asmbin : 'as';
+            asmcmd : '-o $OBJ $ASM';
+            supported_target : system_any;
+            outputbinary: false;
+            allowdirect : true;
+            needar : true;
+            labelprefix_only_inside_procedure : false;
+            labelprefix : '.L';
+            comment : '# ';
+            secnames : ('',
+              '.text','.data','.bss',
+              '','','','','','',
+              '.stab','.stabstr','COMMON')
+          );
+{$else x86_64}
        as_i386_as_info : tasminfo =
           (
             id     : as_gas;
@@ -391,15 +445,23 @@ interface
                 '.section .idata$6','.section .idata$7','.section .edata',
               '.stab','.stabstr','COMMON')
           );
+{$endif x86_64}
 
 initialization
-  RegisterAssembler(as_i386_as_info,T386ATTAssembler);
-  RegisterAssembler(as_i386_as_aout_info,T386ATTAssembler);
-  RegisterAssembler(as_i386_asw_info,T386ATTAssembler);
+{$ifdef x86_64}
+  RegisterAssembler(as_x86_64_as_info,Tx86ATTAssembler);
+{$else x86_64}
+  RegisterAssembler(as_i386_as_info,Tx86ATTAssembler);
+  RegisterAssembler(as_i386_as_aout_info,Tx86ATTAssembler);
+  RegisterAssembler(as_i386_asw_info,Tx86ATTAssembler);
+{$endif x86_64}
 end.
 {
   $Log$
-  Revision 1.31  2003-03-23 23:33:10  hajny
+  Revision 1.1  2003-04-25 12:04:31  florian
+    * merged agx64att and ag386att to x86/agx86att
+
+  Revision 1.31  2003/03/23 23:33:10  hajny
     + emx target added
 
   Revision 1.30  2003/02/19 22:00:15  daniel

+ 5 - 2
compiler/x86_64/aasmcpu.pas

@@ -210,7 +210,7 @@ implementation
 
      uses
        cutils,
-       agx64att;
+       agx86att;
 
 {*****************************************************************************
                               Instruction table
@@ -1808,7 +1808,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.6  2003-03-26 12:50:54  armin
+  Revision 1.7  2003-04-25 12:04:31  florian
+    * merged agx64att and ag386att to x86/agx86att
+
+  Revision 1.6  2003/03/26 12:50:54  armin
   * avoid problems with the ide in init/dome
 
   Revision 1.5  2003/01/05 13:36:53  florian

+ 0 - 300
compiler/x86_64/agx64att.pas

@@ -1,300 +0,0 @@
-{
-    $Id$
-    Copyright (c) 1998-2002 by Florian Klaempfl
-
-    This unit implements an asmoutput class for i386 AT&T syntax
-
-    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.
-
- ****************************************************************************
-}
-{ This unit implements an asmoutput class for x86-64 AT&T syntax
-}
-unit agx64att;
-
-{$i fpcdefs.inc}
-
-interface
-
-    uses
-      cclasses,cpubase,
-      globals,
-      aasmbase,aasmtai,aasmcpu,assemble,aggas;
-
-    type
-      Tx86_64ATTAssembler=class(TGNUassembler)
-      public
-        procedure WriteInstruction(hp: tai);override;
-      end;
-
-    TAttSuffix = (AttSufNONE,AttSufINT,AttSufFPU,AttSufFPUint);
-
-    const
-      gas_op2str:op2strtable={$i x64att.inc}
-      gas_needsuffix:array[tasmop] of TAttSuffix={$i x64atts.inc}
-
-      gas_reg2str : reg2strtable = ('',
-         '%rax','%rcx','%rdx','%rbx','%rsp','%rbp','%rsi','%rdi',
-         '%r8','%r9','%r10','%r11','%r12','%r13','%r14','%r15','%rip',
-         '%eax','%ecx','%edx','%ebx','%esp','%ebp','%esi','%edi',
-         '%r8d','%r9d','%r10d','%r11d','%r12d','%r13d','%r14d','%r15d',
-         '%ax','%cx','%dx','%bx','%sp','%bp','%si','%di',
-         '%r8w','%r9w','%r10w','%r11w','%r12w','%r13w','%r14w','%r15w',
-         '%al','%cl','%dl','%bl','%spl','%bpl','%sil','%dil',
-         '%r8b','%r9b','%r10b','%r11b','%r12b','%r13b','%r14b','%r15b',
-         '%ah','%ch','%bh','%dh',
-         '%cs','%ds','%es','%ss','%fs','%gs',
-         '%st','%st(0)','%st(1)','%st(2)','%st(3)','%st(4)','%st(5)','%st(6)','%st(7)',
-         '%dr0','%dr1','%dr2','%dr3','%dr6','%dr7',
-         '%cr0','%cr2','%cr3','%cr4',
-         '%tr3','%tr4','%tr5','%tr6','%tr7',
-         '%mm0','%mm1','%mm2','%mm3','%mm4','%mm5','%mm6','%mm7',
-         '%xmm0','%xmm1','%xmm2','%xmm3','%xmm4','%xmm5','%xmm6','%xmm7',
-         '%xmm8','%xmm9','%xmm10','%xmm11','%xmm12','%xmm13','%xmm14','%xmm15'
-       );
-
-     gas_opsize2str : array[topsize] of string[2] = ('',
-       'b','w','l','bw','bl','wl','bq','wq','lq',
-       's','l','q',
-       's','l','t','d','q','v','x',
-       '','',''
-     );
-
-  implementation
-
-    uses
-      cutils,systems,
-      verbose;
-
-
-
-    function getreferencestring(var ref : treference) : string;
-    var
-      s : string;
-    begin
-      with ref do
-       begin
-         inc(offset,offsetfixup);
-         offsetfixup:=0;
-       { have we a segment prefix ? }
-       { These are probably not correctly handled under GAS }
-       { should be replaced by coding the segment override  }
-       { directly! - DJGPP FAQ                              }
-         if segment<>R_NO then
-          s:=gas_reg2str[segment]+':'
-         else
-          s:='';
-         if assigned(symbol) then
-          s:=s+symbol.name;
-         if offset<0 then
-          s:=s+tostr(offset)
-         else
-          if (offset>0) then
-           begin
-             if assigned(symbol) then
-              s:=s+'+'+tostr(offset)
-             else
-              s:=s+tostr(offset);
-           end
-         else if (index=R_NO) and (base=R_NO) and not assigned(symbol) then
-           s:=s+'0';
-         if (index<>R_NO) and (base=R_NO) then
-          begin
-            s:=s+'(,'+gas_reg2str[index];
-            if scalefactor<>0 then
-             s:=s+','+tostr(scalefactor)+')'
-            else
-             s:=s+')';
-          end
-         else
-          if (index=R_NO) and (base<>R_NO) then
-           s:=s+'('+gas_reg2str[base]+')'
-          else
-           if (index<>R_NO) and (base<>R_NO) then
-            begin
-              s:=s+'('+gas_reg2str[base]+','+gas_reg2str[index];
-              if scalefactor<>0 then
-               s:=s+','+tostr(scalefactor)+')'
-              else
-               s := s+')';
-            end;
-       end;
-      getreferencestring:=s;
-    end;
-
-    function getopstr(const o:toper) : string;
-    var
-      hs : string;
-    begin
-      case o.typ of
-        top_reg :
-          getopstr:=gas_reg2str[o.reg];
-        top_ref :
-          getopstr:=getreferencestring(o.ref^);
-        top_const :
-          getopstr:='$'+tostr(longint(o.val));
-        top_symbol :
-          begin
-            if assigned(o.sym) then
-              hs:='$'+o.sym.name
-            else
-              hs:='$';
-            if o.symofs>0 then
-             hs:=hs+'+'+tostr(o.symofs)
-            else
-             if o.symofs<0 then
-              hs:=hs+tostr(o.symofs)
-            else
-             if not(assigned(o.sym)) then
-               hs:=hs+'0';
-            getopstr:=hs;
-          end;
-        else
-          internalerror(10001);
-      end;
-    end;
-
-    function getopstr_jmp(const o:toper) : string;
-    var
-      hs : string;
-    begin
-      case o.typ of
-        top_reg :
-          getopstr_jmp:='*'+gas_reg2str[o.reg];
-        top_ref :
-          getopstr_jmp:='*'+getreferencestring(o.ref^);
-        top_const :
-          getopstr_jmp:=tostr(longint(o.val));
-        top_symbol :
-          begin
-            hs:=o.sym.name;
-            if o.symofs>0 then
-             hs:=hs+'+'+tostr(o.symofs)
-            else
-             if o.symofs<0 then
-              hs:=hs+tostr(o.symofs);
-            getopstr_jmp:=hs;
-          end;
-        else
-          internalerror(10001);
-      end;
-    end;
-
-
-{****************************************************************************
-                            TI386ATTASMOUTPUT
- ****************************************************************************}
-
-
-
-    procedure Tx86_64AttAssembler. WriteInstruction(hp: tai);
-    var
-      op       : tasmop;
-      s        : string;
-      sep      : char;
-      calljmp  : boolean;
-      i        : integer;
-     begin
-       if hp.typ <> ait_instruction then exit;
-       taicpu(hp).SetOperandOrder(op_att);
-       op:=taicpu(hp).opcode;
-       calljmp:=is_calljmp(op);
-       { call maybe not translated to call }
-       s:=#9+gas_op2str[op]+cond2str[taicpu(hp).condition];
-       { suffix needed ?  fnstsw,fldcw don't support suffixes
-         with binutils 2.9.5 under linux }
-       if (not calljmp) and
-           (gas_needsuffix[op]<>AttSufNONE) and
-           (op<>A_FNSTSW) and (op<>A_FSTSW) and
-           (op<>A_FNSTCW) and (op<>A_FSTCW) and
-           (op<>A_FLDCW) and not(
-           (taicpu(hp).oper[0].typ=top_reg) and
-           (taicpu(hp).oper[0].reg in [R_ST..R_ST7])
-          ) then
-              s:=s+gas_opsize2str[taicpu(hp).opsize];
-       { process operands }
-       if taicpu(hp).ops<>0 then
-         begin
-           { call and jmp need an extra handling                          }
-           { this code is only called if jmp isn't a labeled instruction  }
-           { quick hack to overcome a problem with manglednames=255 chars }
-           if calljmp then
-              begin
-                AsmWrite(s+#9);
-                s:=getopstr_jmp(taicpu(hp).oper[0]);
-              end
-            else
-              begin
-                for i:=0 to taicpu(hp).ops-1 do
-                  begin
-                    if i=0 then
-                      sep:=#9
-                    else
-                      sep:=',';
-                    s:=s+sep+getopstr(taicpu(hp).oper[i])
-                  end;
-              end;
-         end;
-         AsmWriteLn(s);
-     end;
-
-
-{*****************************************************************************
-                                  Initialize
-*****************************************************************************}
-
-    const
-       as_x86_64_as_info : tasminfo =
-          (
-            id     : as_x86_64_as;
-            idtxt  : 'AS';
-            asmbin : 'as';
-            asmcmd : '-o $OBJ $ASM';
-            supported_target : system_any;
-            outputbinary: false;
-            allowdirect : true;
-            needar : true;
-            labelprefix_only_inside_procedure : false;
-            labelprefix : '.L';
-            comment : '# ';
-            secnames : ('',
-              '.text','.data','.bss',
-              '','','','','','',
-              '.stab','.stabstr','COMMON')
-          );
-
-
-initialization
-  RegisterAssembler(as_x86_64_as_info,Tx86_64ATTAssembler);
-end.
-{
-  $Log$
-  Revision 1.4  2003-01-05 13:36:54  florian
-    * x86-64 compiles
-    + very basic support for float128 type (x86-64 only)
-
-  Revision 1.3  2002/08/12 15:08:44  carl
-    + stab register indexes for powerpc (moved from gdb to cpubase)
-    + tprocessor enumeration moved to cpuinfo
-    + linker in target_info is now a class
-    * many many updates for m68k (will soon start to compile)
-    - removed some ifdef or correct them for correct cpu
-
-  Revision 1.2  2002/07/25 22:55:33  florian
-    * several fixes, small test units can be compiled
-
-  Revision 1.1  2002/07/24 22:38:15  florian
-    + initial release of x86-64 target code
-}