Browse Source

+ target_info.size_of_pointer -> pointer_size
+ some cleanup of unused types/variables
* move several constants from cpubase to their specific units
(where they are used)
+ att_Reg2str -> gas_reg2str
+ int_reg2str -> std_reg2str

carl 23 years ago
parent
commit
79b490d551

+ 40 - 6
compiler/i386/ag386att.pas

@@ -27,7 +27,7 @@ unit ag386att;
 interface
 
     uses
-      cclasses,
+      cclasses,cpubase,
       globals,
       aasm,assemble,aggas;
 
@@ -37,6 +37,32 @@ interface
         procedure WriteInstruction(hp: tai);  override;
       end;
 
+    TAttSuffix = (AttSufNONE,AttSufINT,AttSufFPU,AttSufFPUint);
+
+    const      
+      gas_op2str:op2strtable={$i i386att.inc}
+      gas_needsuffix:array[tasmop] of TAttSuffix={$i i386atts.inc}
+      
+      gas_reg2str : reg2strtable = ('',
+        '%eax','%ecx','%edx','%ebx','%esp','%ebp','%esi','%edi',
+        '%ax','%cx','%dx','%bx','%sp','%bp','%si','%di',
+        '%al','%cl','%dl','%bl','%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'
+       );
+      
+     gas_opsize2str : array[topsize] of string[2] = ('',
+       'b','w','l','bw','bl','wl',
+       's','l','q',
+       's','l','t','d','q','v',
+       '','',''
+     );
+
   implementation
 
     uses
@@ -46,7 +72,7 @@ interface
       dos,
 {$endif Delphi}
       cutils,globtype,systems,
-      fmodule,finput,verbose,cpubase,cpuasm,tainst
+      fmodule,finput,verbose,cpuasm,tainst
 {$ifdef GDB}
   {$ifdef delphi}
       ,sysutils
@@ -191,18 +217,18 @@ interface
        op:=taicpu(hp).opcode;
        calljmp:=is_calljmp(op);
        { call maybe not translated to call }
-       s:=#9+att_op2str[op]+cond2str[taicpu(hp).condition];
+       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
-           (att_needsuffix[op]<>AttSufNONE) 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+att_opsize2str[taicpu(hp).opsize];
+              s:=s+gas_opsize2str[taicpu(hp).opsize];
        { process operands }
        if taicpu(hp).ops<>0 then
          begin
@@ -326,7 +352,15 @@ initialization
 end.
 {
   $Log$
-  Revision 1.17  2002-04-14 16:58:04  carl
+  Revision 1.18  2002-04-15 19:12:10  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.17  2002/04/14 16:58:04  carl
   + move into aggas most of the stuff non-processor specific
 
   Revision 1.16  2002/04/10 08:07:55  jonas

+ 10 - 1
compiler/i386/ag386bin.pas

@@ -90,6 +90,7 @@ implementation
        ;
 
 
+
 {$ifdef GDB}
 
     procedure TInternalAssembler.convertstabs(p:pchar);
@@ -1033,7 +1034,15 @@ implementation
 end.
 {
   $Log$
-  Revision 1.7  2001-04-13 01:22:17  peter
+  Revision 1.8  2002-04-15 19:12:10  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.7  2001/04/13 01:22:17  peter
     * symtable change to classes
     * range check generation and errors fixed, make cycle DEBUG=1 works
     * memory leaks fixed

+ 19 - 8
compiler/i386/ag386int.pas

@@ -35,6 +35,9 @@ interface
         Function  DoAssemble:boolean;override;
         procedure WriteExternals;
       end;
+      
+
+      
 
   implementation
 
@@ -125,7 +128,7 @@ interface
           inc(offset,offsetfixup);
           offsetfixup:=0;
           if ref.segment<>R_NO then
-           s:=int_reg2str[segment]+':['
+           s:=std_reg2str[segment]+':['
           else
            s:='[';
          if assigned(symbol) then
@@ -141,7 +144,7 @@ interface
              s:=s+'+'
             else
              first:=false;
-             s:=s+int_reg2str[base];
+             s:=s+std_reg2str[base];
           end;
          if (index<>R_NO) then
            begin
@@ -149,7 +152,7 @@ interface
                s:=s+'+'
              else
                first:=false;
-             s:=s+int_reg2str[index];
+             s:=s+std_reg2str[index];
              if scalefactor<>0 then
                s:=s+'*'+tostr(scalefactor);
            end;
@@ -171,7 +174,7 @@ interface
     begin
       case o.typ of
         top_reg :
-          getopstr:=int_reg2str[o.reg];
+          getopstr:=std_reg2str[o.reg];
         top_const :
           getopstr:=tostr(longint(o.val));
         top_symbol :
@@ -234,7 +237,7 @@ interface
     begin
       case o.typ of
         top_reg :
-          getopstr_jmp:=int_reg2str[o.reg];
+          getopstr_jmp:=std_reg2str[o.reg];
         top_const :
           getopstr_jmp:=tostr(longint(o.val));
         top_symbol :
@@ -592,7 +595,7 @@ interface
                            (taicpu(hp).opcode =  A_REPZ) or
                            (taicpu(hp).opcode = A_REPNE)) then
                         Begin
-                          prefix:=int_op2str[taicpu(hp).opcode]+#9;
+                          prefix:=std_op2str[taicpu(hp).opcode]+#9;
                           hp:=tai(hp.next);
                         { this is theorically impossible... }
                           if hp=nil then
@@ -628,7 +631,7 @@ interface
                               end;
                            end;
                         end;
-                       AsmWriteLn(#9#9+prefix+int_op2str[taicpu(hp).opcode]+cond2str[taicpu(hp).condition]+suffix+s);
+                       AsmWriteLn(#9#9+prefix+std_op2str[taicpu(hp).opcode]+cond2str[taicpu(hp).condition]+suffix+s);
                      end;
 {$ifdef GDB}
              ait_stabn,
@@ -821,7 +824,15 @@ initialization
 end.
 {
   $Log$
-  Revision 1.16  2002-04-04 19:06:07  peter
+  Revision 1.17  2002-04-15 19:12:09  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.16  2002/04/04 19:06:07  peter
     * removed unused units
     * use tlocation.size in cg.a_*loc*() routines
 

+ 29 - 6
compiler/i386/ag386nsm.pas

@@ -35,6 +35,8 @@ interface
         procedure WriteAsmList;override;
         procedure WriteExternals;
       end;
+      
+      
 
   implementation
 
@@ -49,6 +51,19 @@ interface
     const
       line_length = 64;
 
+    int_nasmreg2str : reg2strtable = ('',
+     'eax','ecx','edx','ebx','esp','ebp','esi','edi',
+     'ax','cx','dx','bx','sp','bp','si','di',
+     'al','cl','dl','bl','ah','ch','bh','dh',
+     'cs','ds','es','ss','fs','gs',
+     'st0','st0','st1','st2','st3','st4','st5','st6','st7',
+     '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'
+   );
+
     var
       lastfileinfo : tfileposinfo;
       infile,
@@ -150,7 +165,7 @@ interface
           inc(offset,offsetfixup);
           offsetfixup:=0;
           if ref.segment<>R_NO then
-           s:='['+int_reg2str[segment]+':'
+           s:='['+std_reg2str[segment]+':'
           else
            s:='[';
          if assigned(symbol) then
@@ -164,7 +179,7 @@ interface
              s:=s+'+'
             else
              first:=false;
-             s:=s+int_reg2str[base];
+             s:=s+std_reg2str[base];
           end;
          if (index<>R_NO) then
            begin
@@ -172,7 +187,7 @@ interface
                s:=s+'+'
              else
                first:=false;
-             s:=s+int_reg2str[index];
+             s:=s+std_reg2str[index];
              if scalefactor<>0 then
                s:=s+'*'+tostr(scalefactor);
            end;
@@ -421,7 +436,7 @@ interface
            ait_regalloc :
              begin
                if (cs_asm_regalloc in aktglobalswitches) then
-                 AsmWriteLn(target_asm.comment+'Register '+gas_reg2str[tairegalloc(hp).reg]+
+                 AsmWriteLn(target_asm.comment+'Register '+std_reg2str[tairegalloc(hp).reg]+
                    allocstr[tairegalloc(hp).allocation]);
              end;
 
@@ -662,7 +677,7 @@ interface
                if taicpu(hp).opcode=A_FWAIT then
                 AsmWriteln(#9#9'DB'#9'09bh')
                else
-                AsmWriteLn(#9#9+{prefix+}int_op2str[taicpu(hp).opcode]+
+                AsmWriteLn(#9#9+{prefix+}std_op2str[taicpu(hp).opcode]+
                   cond2str[taicpu(hp).condition]+{suffix+}s);
              end;
 {$ifdef GDB}
@@ -883,7 +898,15 @@ initialization
 end.
 {
   $Log$
-  Revision 1.15  2002-04-14 16:58:41  carl
+  Revision 1.16  2002-04-15 19:12:09  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.15  2002/04/14 16:58:41  carl
   + att_reg2str -> gas_reg2str
 
   Revision 1.14  2002/04/04 18:27:37  carl

+ 99 - 4
compiler/i386/cpuasm.pas

@@ -46,6 +46,30 @@ uses
 
 const
   MaxPrefixes=4;
+  
+{*****************************************************************************
+                              Instruction table
+*****************************************************************************}
+
+type
+  tinsentry=packed record
+    opcode  : tasmop;
+    ops     : byte;
+    optypes : array[0..2] of longint;
+    code    : array[0..maxinfolen] of char;
+    flags   : longint;
+  end;
+  pinsentry=^tinsentry;
+
+  TInsTabCache=array[TasmOp] of longint;
+  PInsTabCache=^TInsTabCache;
+
+const
+  InsTab:array[0..instabentries-1] of TInsEntry={$i i386tab.inc}
+
+var
+  InsTabCache : PInsTabCache;
+{*****************************************************************************}
 
 type
   TOperandOrder = (op_intel,op_att);
@@ -123,13 +147,33 @@ type
      procedure Swatoperands;
 {$endif NOAG386BIN}
   end;
+  
+  procedure InitAsm;
+  procedure DoneAsm;
 
 
 implementation
 
 uses
   cutils,
-  ogbase;
+  ogbase,
+  ag386att;
+
+const  
+{ Convert reg to operand type }
+  reg_2_type:array[firstreg..lastreg] of longint = (OT_NONE,
+    OT_REG_EAX,OT_REG_ECX,OT_REG32,OT_REG32,OT_REG32,OT_REG32,OT_REG32,OT_REG32,
+    OT_REG_AX,OT_REG_CX,OT_REG_DX,OT_REG16,OT_REG16,OT_REG16,OT_REG16,OT_REG16,
+    OT_REG_AL,OT_REG_CL,OT_REG8,OT_REG8,OT_REG8,OT_REG8,OT_REG8,OT_REG8,
+    OT_REG_CS,OT_REG_DESS,OT_REG_DESS,OT_REG_DESS,OT_REG_FSGS,OT_REG_FSGS,
+    OT_FPU0,OT_FPU0,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,
+    OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,
+    OT_REG_CREG,OT_REG_CREG,OT_REG_CREG,OT_REG_CR4,
+    OT_REG_TREG,OT_REG_TREG,OT_REG_TREG,OT_REG_TREG,OT_REG_TREG,
+    OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,
+    OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG
+  );
+  
 
 
 {****************************************************************************
@@ -426,7 +470,7 @@ uses
         s : string;
         addsize : boolean;
       begin
-        s:='['+int_op2str[opcode];
+        s:='['+std_op2str[opcode];
         for i:=1to ops do
          begin
            if i=1 then
@@ -824,7 +868,7 @@ begin
 {$ifdef TP}
      Message1(asmw_e_opcode_not_in_table,'');
 {$else}
-     Message1(asmw_e_opcode_not_in_table,att_op2str[opcode]);
+     Message1(asmw_e_opcode_not_in_table,gas_op2str[opcode]);
 {$endif}
      exit;
    end;
@@ -1590,10 +1634,61 @@ begin
 end;
 {$endif NOAG386BIN}
 
+{*****************************************************************************
+                              Instruction table
+*****************************************************************************}
+
+    procedure BuildInsTabCache;
+{$ifndef NOAG386BIN}
+      var
+        i : longint;
+{$endif}
+      begin
+{$ifndef NOAG386BIN}
+        new(instabcache);
+        FillChar(instabcache^,sizeof(tinstabcache),$ff);
+        i:=0;
+        while (i<InsTabEntries) do
+         begin
+           if InsTabCache^[InsTab[i].OPcode]=-1 then
+            InsTabCache^[InsTab[i].OPcode]:=i;
+           inc(i);
+         end;
+{$endif NOAG386BIN}
+      end;
+
+
+    procedure InitAsm;
+      begin
+{$ifndef NOAG386BIN}
+        if not assigned(instabcache) then
+          BuildInsTabCache;
+{$endif NOAG386BIN}
+      end;
+
+
+    procedure DoneAsm;
+      begin
+{$ifndef NOAG386BIN}
+        if assigned(instabcache) then
+         dispose(instabcache);
+{$endif NOAG386BIN}
+      end;
+
+
+
 end.
 {
   $Log$
-  Revision 1.18  2002-04-02 17:11:33  peter
+  Revision 1.19  2002-04-15 19:12:09  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.18  2002/04/02 17:11:33  peter
     * tlocation,treference update
     * LOC_CONSTANT added for better constant handling
     * secondadd splitted in multiple routines

+ 49 - 232
compiler/i386/cpubase.pas

@@ -24,6 +24,10 @@
 
  ****************************************************************************
 }
+{# Base unit for processor information. This unit contains
+   enumerations of registers, opcodes, sizes, and other
+   such things which are processor specific.
+}
 unit cpubase;
 
 {$i defines.inc}
@@ -40,7 +44,6 @@ const
 
 { By default we want everything }
 {$define ATTOP}
-{$define ATTREG}
 {$define INTELOP}
 {$define ITTABLE}
 
@@ -187,46 +190,21 @@ const
      longint($80000000);  { if the instruction can change in a second pass }
 
 type
-  TAttSuffix = (AttSufNONE,AttSufINT,AttSufFPU,AttSufFPUint);
 
-  TAsmOp=
-{$i i386op.inc}
+  TAsmOp={$i i386op.inc}
 
+  {# This should define the array of instructions as string }
   op2strtable=array[tasmop] of string[11];
 
-  tstr2opentry = class(Tnamedindexitem)
-    op: TAsmOp;
-  end;
+Const
 
-const
+  {# First value of opcode enumeration }
   firstop = low(tasmop);
+  {# Last value of opcode enumeration  }
   lastop  = high(tasmop);
 
-  AsmPrefixes = 6;
-  AsmPrefix : array[0..AsmPrefixes-1] of TasmOP =(
-    A_LOCK,A_REP,A_REPE,A_REPNE,A_REPNZ,A_REPZ
-  );
-
-  AsmOverrides = 6;
-  AsmOverride : array[0..AsmOverrides-1] of TasmOP =(
-    A_SEGCS,A_SEGES,A_SEGDS,A_SEGFS,A_SEGGS,A_SEGSS
-  );
-
-
-{$ifdef INTELOP}
-  int_op2str:op2strtable=
-{$i i386int.inc}
-{$endif INTELOP}
 
-{$ifdef ATTOP}
-  att_op2str:op2strtable=
-{$i i386att.inc}
-{$endif ATTOP}
 
-{$ifdef ATTSUF}
-  att_needsuffix:array[tasmop] of TAttSuffix=
-{$i i386atts.inc}
-{$endif ATTSUF}
 
 
 {*****************************************************************************
@@ -264,14 +242,6 @@ const
     )
   );
 
-{$ifdef ATTOP}
-  att_opsize2str : array[topsize] of string[2] = ('',
-    'b','w','l','bw','bl','wl',
-    's','l','q',
-    's','l','t','d','q','v',
-    '','',''
-  );
-{$endif}
 
 
 {*****************************************************************************
@@ -297,22 +267,18 @@ const
     C_S,C_Z,C_NO,C_NP,C_NP,C_P,C_NS,C_NZ
   );
 
-const
-  CondAsmOps=3;
-  CondAsmOp:array[0..CondAsmOps-1] of TasmOp=(
-    A_CMOVcc, A_Jcc, A_SETcc
-  );
-  CondAsmOpStr:array[0..CondAsmOps-1] of string[4]=(
-    'CMOV','J','SET'
-  );
-
 
 {*****************************************************************************
                                   Registers
 *****************************************************************************}
 
 type
-  { enumeration for registers, don't change the order }
+  {# Enumeration for all possible registers for cpu. It 
+    is to note that all registers of the same type
+    (for example all FPU registers), should be grouped
+    together.
+  }
+  { don't change the order }
   { it's used by the register size conversions        }
   tregister = (R_NO,
     R_EAX,R_ECX,R_EDX,R_EBX,R_ESP,R_EBP,R_ESI,R_EDI,
@@ -327,12 +293,16 @@ type
     R_XMM0,R_XMM1,R_XMM2,R_XMM3,R_XMM4,R_XMM5,R_XMM6,R_XMM7
   );
 
+  {# Set type definition for registers }
   tregisterset = set of tregister;
 
+  {# Type definition for the array of string of register nnames }
   reg2strtable = array[tregister] of string[6];
 
 const
+  {# First register in the tregister enumeration }
   firstreg = low(tregister);
+  {# Last register in the tregister enumeration }
   lastreg  = high(tregister);
 
   firstsreg = R_CS;
@@ -342,36 +312,17 @@ const
   regset16bit : tregisterset = [R_AX..R_DI,R_CS..R_SS];
   regset32bit : tregisterset = [R_EAX..R_EDI];
 
-  { Convert reg to opsize }
-  reg_2_opsize:array[firstreg..lastreg] of topsize = (S_NO,
-    S_L,S_L,S_L,S_L,S_L,S_L,S_L,S_L,
-    S_W,S_W,S_W,S_W,S_W,S_W,S_W,S_W,
-    S_B,S_B,S_B,S_B,S_B,S_B,S_B,S_B,
-    S_W,S_W,S_W,S_W,S_W,S_W,
-    S_FL,S_FL,S_FL,S_FL,S_FL,S_FL,S_FL,S_FL,S_FL,
-    S_L,S_L,S_L,S_L,S_L,S_L,
-    S_L,S_L,S_L,S_L,
-    S_L,S_L,S_L,S_L,S_L,
-    S_D,S_D,S_D,S_D,S_D,S_D,S_D,S_D,
-    S_D,S_D,S_D,S_D,S_D,S_D,S_D,S_D
-  );
-
-  { Convert reg to operand type }
-  reg_2_type:array[firstreg..lastreg] of longint = (OT_NONE,
-    OT_REG_EAX,OT_REG_ECX,OT_REG32,OT_REG32,OT_REG32,OT_REG32,OT_REG32,OT_REG32,
-    OT_REG_AX,OT_REG_CX,OT_REG_DX,OT_REG16,OT_REG16,OT_REG16,OT_REG16,OT_REG16,
-    OT_REG_AL,OT_REG_CL,OT_REG8,OT_REG8,OT_REG8,OT_REG8,OT_REG8,OT_REG8,
-    OT_REG_CS,OT_REG_DESS,OT_REG_DESS,OT_REG_DESS,OT_REG_FSGS,OT_REG_FSGS,
-    OT_FPU0,OT_FPU0,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,
-    OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,
-    OT_REG_CREG,OT_REG_CREG,OT_REG_CREG,OT_REG_CR4,
-    OT_REG_TREG,OT_REG_TREG,OT_REG_TREG,OT_REG_TREG,OT_REG_TREG,
-    OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,
-    OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG
-  );
-
-{$ifdef INTELOP}
-  int_reg2str : reg2strtable = ('',
+  {# Standard opcode string table (for each tasmop enumeration). The
+     opcode strings should conform to the names as defined by the
+     processor manufacturer.
+  }
+  std_op2str:op2strtable={$i i386int.inc}
+
+  {# Standard register table (for each tregister enumeration). The
+     register strings should conform to the the names as defined
+     by the processor manufacturer
+  }
+  std_reg2str : reg2strtable = ('',
     'eax','ecx','edx','ebx','esp','ebp','esi','edi',
     'ax','cx','dx','bx','sp','bp','si','di',
     'al','cl','dl','bl','ah','ch','bh','dh',
@@ -384,34 +335,7 @@ const
     'xmm0','xmm1','xmm2','xmm3','xmm4','xmm5','xmm6','xmm7'
   );
 
-  int_nasmreg2str : reg2strtable = ('',
-    'eax','ecx','edx','ebx','esp','ebp','esi','edi',
-    'ax','cx','dx','bx','sp','bp','si','di',
-    'al','cl','dl','bl','ah','ch','bh','dh',
-    'cs','ds','es','ss','fs','gs',
-    'st0','st0','st1','st2','st3','st4','st5','st6','st7',
-    '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'
-  );
-{$endif}
 
-{$ifdef ATTREG}
-  gas_reg2str : reg2strtable = ('',
-    '%eax','%ecx','%edx','%ebx','%esp','%ebp','%esi','%edi',
-    '%ax','%cx','%dx','%bx','%sp','%bp','%si','%di',
-    '%al','%cl','%dl','%bl','%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'
-  );
-{$endif ATTREG}
 
 
 {*****************************************************************************
@@ -428,6 +352,7 @@ type
 type
   trefoptions=(ref_none,ref_parafixup,ref_localfixup,ref_selffixup);
 
+type
   { immediate/reference record }
   poperreference = ^treference;
   treference = packed record
@@ -439,9 +364,6 @@ type
      symbol      : tasmsymbol;
      offsetfixup : longint;
      options     : trefoptions;
-{$ifdef newcg}
-     alignment   : byte;
-{$endif newcg}
   end;
 
 {*****************************************************************************
@@ -467,17 +389,6 @@ type
                              Argument Classification
 *****************************************************************************}
 
-type
-  TArgClass = (
-     { the following classes should be defined by all processor implemnations }
-     AC_NOCLASS,
-     AC_MEMORY,
-     AC_INTEGER,
-     AC_FPU,
-     { the following argument classes are i386 specific }
-     AC_FPUUP,
-     AC_SSE,
-     AC_SSEUP);
 
 {*****************************************************************************
                                Generic Location
@@ -560,10 +471,8 @@ const
   firstsavemmreg = R_MM0;
   lastsavemmreg = R_MM7;
 
-  lowsavereg = R_EAX;
-  highsavereg = R_MM7;
 
-  ALL_REGISTERS = [lowsavereg..highsavereg];
+  ALL_REGISTERS = [firstreg..lastreg];
 
   lvaluelocations = [LOC_REFERENCE,LOC_CFPUREGISTER,
     LOC_CREGISTER,LOC_MMXREGISTER,LOC_CMMXREGISTER];
@@ -596,41 +505,15 @@ const
   LoReg = R_EAX;
   HiReg = R_BL;
 
-  cpuflags = [];
-
   { sizes }
-  pointersize   = 4;
+  pointer_size  = 4;
   extended_size = 10;
   mmreg_size = 8;
-  sizepostfix_pointer = S_L;
-
-
-{*****************************************************************************
-                              Instruction table
-*****************************************************************************}
 
-{$ifndef NOAG386BIN}
-type
-  tinsentry=packed record
-    opcode  : tasmop;
-    ops     : byte;
-    optypes : array[0..2] of longint;
-    code    : array[0..maxinfolen] of char;
-    flags   : longint;
-  end;
-  pinsentry=^tinsentry;
 
-  TInsTabCache=array[TasmOp] of longint;
-  PInsTabCache=^TInsTabCache;
-
-const
-  InsTab:array[0..instabentries-1] of TInsEntry=
-{$i i386tab.inc}
-
-var
-  InsTabCache : PInsTabCache;
-{$endif NOAG386BIN}
 
+  procedure InitCpu;
+  procedure DoneCpu;
 
 {*****************************************************************************
                    Opcode propeties (needed for optimizer)
@@ -674,13 +557,6 @@ const
 {$endif NOOPT}
 
 
-{*****************************************************************************
-                                  Init/Done
-*****************************************************************************}
-
-  procedure InitCpu;
-  procedure DoneCpu;
-
 {*****************************************************************************
                                   Helpers
 *****************************************************************************}
@@ -696,8 +572,6 @@ const
        maxintregs = maxvarregs;
        maxfpuregs = maxfpuvarregs;
 
-    function imm_2_type(l:longint):longint;
-
     { the following functions allow to convert registers }
     { for example reg8toreg32(R_AL) returns R_EAX        }
     { for example reg16toreg32(R_AL) gives an undefined  }
@@ -722,8 +596,6 @@ const
     { returns the operand prefix for a given register }
     function regsize(reg : tregister) : topsize;
 
-    function reg2str(r : tregister) : string;
-
     function is_calljmp(o:tasmop):boolean;
 
     procedure inverse_flags(var f: TResFlags);
@@ -742,36 +614,6 @@ implementation
                                   Helpers
 *****************************************************************************}
 
-    function imm_2_type(l:longint):longint;
-      begin
-        if (l>=-128) and (l<=127) then
-         imm_2_type:=OT_IMM8 or OT_SIGNED
-        else
-         if (l>=-255) and (l<=255) then
-          imm_2_type:=OT_IMM8
-        else
-         if (l>=-32768) and (l<=32767) then
-          imm_2_type:=OT_IMM16 or OT_SIGNED
-        else
-         if (l>=-65536) and (l<=65535) then
-          imm_2_type:=OT_IMM16 or OT_SIGNED
-         else
-          imm_2_type:=OT_IMM32;
-      end;
-
-    function reg2str(r : tregister) : string;
-      const
-         a : array[R_NO..R_BL] of string[3] =
-          ('','EAX','ECX','EDX','EBX','ESP','EBP','ESI','EDI',
-           'AX','CX','DX','BX','SP','BP','SI','DI',
-           'AL','CL','DL','BL');
-      begin
-         if r in [R_ST0..R_ST7] then
-           reg2str:='ST('+tostr(longint(r)-longint(R_ST0))+')'
-         else
-           reg2str:=a[r];
-      end;
-
 
     function is_calljmp(o:tasmop):boolean;
       begin
@@ -886,51 +728,26 @@ implementation
       end;
 
 
-{*****************************************************************************
-                              Instruction table
-*****************************************************************************}
-
-    procedure BuildInsTabCache;
-{$ifndef NOAG386BIN}
-      var
-        i : longint;
-{$endif}
-      begin
-{$ifndef NOAG386BIN}
-        new(instabcache);
-        FillChar(instabcache^,sizeof(tinstabcache),$ff);
-        i:=0;
-        while (i<InsTabEntries) do
-         begin
-           if InsTabCache^[InsTab[i].OPcode]=-1 then
-            InsTabCache^[InsTab[i].OPcode]:=i;
-           inc(i);
-         end;
-{$endif NOAG386BIN}
-      end;
-
-
     procedure InitCpu;
-      begin
-{$ifndef NOAG386BIN}
-        if not assigned(instabcache) then
-          BuildInsTabCache;
-{$endif NOAG386BIN}
-      end;
-
-
+     begin
+     end;
+     
     procedure DoneCpu;
-      begin
-{$ifndef NOAG386BIN}
-        if assigned(instabcache) then
-         dispose(instabcache);
-{$endif NOAG386BIN}
-      end;
+     begin
+     end;
 
 end.
 {
   $Log$
-  Revision 1.13  2002-04-14 16:59:41  carl
+  Revision 1.14  2002-04-15 19:12:09  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.13  2002/04/14 16:59:41  carl
   + att_reg2str -> gas_reg2str
 
   Revision 1.12  2002/04/02 17:11:34  peter

+ 24 - 16
compiler/i386/csopt386.pas

@@ -574,7 +574,7 @@ begin
                       exclude(regsUsable,regCounter);
 {$ifdef alignregdebug}
                       temp := Tai_asm_comment.Create(strpnew(
-                                gas_reg2str[regCounter]+' removed')));
+                                std_reg2str[regCounter]+' removed')));
                       temp.next := prev.next;
                       temp.previous := prev;
                       prev.next := temp;
@@ -624,7 +624,7 @@ begin
                       exclude(regsUsable,regCounter);
 {$ifdef alignregdebug}
                       temp := Tai_asm_comment.Create(strpnew(
-                                gas_reg2str[regCounter]+' removed')));
+                                std_reg2str[regCounter]+' removed')));
                       temp.next := next.next;
                       temp.previous := next;
                       next.next := temp;
@@ -667,7 +667,7 @@ begin
           break
         end;
 {$ifdef alignregdebug}
-  next := Tai_asm_comment.Create(strpnew(gas_reg2str[lastRemoved]+
+  next := Tai_asm_comment.Create(strpnew(std_reg2str[lastRemoved]+
                ' chosen as alignment register')));
   next.next := p.next;
   next.previous := p;
@@ -703,7 +703,7 @@ begin
 {$ifdef replaceregdebug}
   l := random(1000);
   hp := Tai_asm_comment.Create(strpnew(
-          'cleared '+gas_reg2str[reg]+' from here... '+tostr(l))));
+          'cleared '+std_reg2str[reg]+' from here... '+tostr(l))));
   hp.next := p;
   hp.previous := p.previous;
   p.previous := hp;
@@ -738,7 +738,7 @@ begin
   if assigned(p) then
     begin
       hp := Tai_asm_comment.Create(strpnew(
-        'cleared '+gas_reg2str[reg]+' till here... '+tostr(l))));
+        'cleared '+std_reg2str[reg]+' till here... '+tostr(l))));
       hp.next := p;
       hp.previous := p.previous;
       p.previous := hp;
@@ -759,7 +759,7 @@ begin
 {$ifdef replaceregdebug}
   l := random(1000);
   hp := Tai_asm_comment.Create(strpnew(
-          'restored '+gas_reg2str[reg]+' with data from here... '+tostr(l))));
+          'restored '+std_reg2str[reg]+' with data from here... '+tostr(l))));
   hp.next := p;
   hp.previous := p.previous;
   p.previous := hp;
@@ -784,7 +784,7 @@ begin
   if assigned(p) then
     begin
       hp := Tai_asm_comment.Create(strpnew(
-        'restored '+gas_reg2str[reg]+' till here... '+tostr(l))));
+        'restored '+std_reg2str[reg]+' till here... '+tostr(l))));
       hp.next := p;
       hp.previous := p.previous;
       p.previous := hp;
@@ -1171,7 +1171,7 @@ begin
     begin
 {$ifdef replaceregdebug}
       hp := Tai_asm_comment.Create(strpnew(
-        'replacing '+gas_reg2str[newreg]+' with '+gas_reg2str[orgreg]+
+        'replacing '+std_reg2str[newreg]+' with '+std_reg2str[orgreg]+
         ' from here...')));
       hp.next := p;
       hp.previous := p.previous;
@@ -1180,7 +1180,7 @@ begin
         hp.previous^.next := hp;
 
       hp := Tai_asm_comment.Create(strpnew(
-        'replaced '+gas_reg2str[newreg]+' with '+gas_reg2str[orgreg]+
+        'replaced '+std_reg2str[newreg]+' with '+std_reg2str[orgreg]+
         ' till here')));
       hp.next := endp.next;
       hp.previous := endp;
@@ -1243,7 +1243,7 @@ begin
      else
        begin
          hp := Tai_asm_comment.Create(strpnew(
-           'replacing '+gas_reg2str[newreg]+' with '+gas_reg2str[orgreg]+
+           'replacing '+std_reg2str[newreg]+' with '+std_reg2str[orgreg]+
            ' from here...')));
          hp.previous := p.previous;
          hp.next := p;
@@ -1252,7 +1252,7 @@ begin
           hp.previous^.next := hp;
 
       hp := Tai_asm_comment.Create(strpnew(
-        'replacing '+gas_reg2str[newreg]+' with '+gas_reg2str[orgreg]+
+        'replacing '+std_reg2str[newreg]+' with '+std_reg2str[orgreg]+
         ' failed here')));
       hp.next := endp.next;
       hp.previous := endp;
@@ -1460,7 +1460,7 @@ Begin
                               begin
 {$ifdef csdebug}
                                hp5 := Tai_asm_comment.Create(strpnew(
-                                 'cse checking '+gas_reg2str[Reg32(Taicpu(p).oper[1].reg)])));
+                                 'cse checking '+std_reg2str[Reg32(Taicpu(p).oper[1].reg)])));
                                insertLLItem(asml,p,p.next,hp5);
 {$endif csdebug}
                                If CheckSequence(p,prevSeq,Taicpu(p).oper[1].reg, Cnt, RegInfo, findPrevSeqs) And
@@ -1542,8 +1542,8 @@ Begin
               For RegCounter := R_EAX To R_EDI Do
                 If (RegCounter in RegInfo.RegsLoadedForRef) Then
                   Begin
-           hp5 := Tai_asm_comment.Create(strpnew('New: '+gas_reg2str[RegCounter]+', Old: '+
-                                                  gas_reg2str[RegInfo.New2OldReg[RegCounter]])));
+           hp5 := Tai_asm_comment.Create(strpnew('New: '+std_reg2str[RegCounter]+', Old: '+
+                                                  std_reg2str[RegInfo.New2OldReg[RegCounter]])));
            InsertLLItem(AsmL, Tai(hp2.previous), hp2, hp5);
                   End;
 {$EndIf CSDebug}
@@ -1983,8 +1983,16 @@ End.
 
 {
   $Log$
-  Revision 1.28  2002-04-14 17:00:49  carl
-  + att_reg2str -> gas_reg2str
+  Revision 1.29  2002-04-15 19:12:09  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.28  2002/04/14 17:00:49  carl
+  + att_reg2str -> std_reg2str
 
   Revision 1.27  2002/04/04 19:06:10  peter
     * removed unused units

+ 25 - 17
compiler/i386/daopt386.pas

@@ -1171,10 +1171,10 @@ Begin
   firstRemovedWasAlloc := false;
   first := true;
 {$ifdef allocregdebug}
-  hp := Tai_asm_comment.Create(strpnew('allocating '+gas_reg2str[reg]+
+  hp := Tai_asm_comment.Create(strpnew('allocating '+std_reg2str[reg]+
     ' from here...')));
   insertllitem(asml,p1.previous,p1,hp);
-  hp := Tai_asm_comment.Create(strpnew('allocated '+gas_reg2str[reg]+
+  hp := Tai_asm_comment.Create(strpnew('allocated '+std_reg2str[reg]+
     ' till here...')));
   insertllitem(asml,p2,p1.next,hp);
 {$endif allocregdebug}
@@ -1525,7 +1525,7 @@ Begin {checks whether two Taicpu instructions are equal}
                   Begin
                     RegInfo.RegsLoadedForRef := RegInfo.RegsLoadedForRef + [Base];
 {$ifdef csdebug}
-                    Writeln(gas_reg2str[base], ' added');
+                    Writeln(std_reg2str[base], ' added');
 {$endif csdebug}
                   end;
                 If Not(Index in [procinfo^.FramePointer,
@@ -1533,7 +1533,7 @@ Begin {checks whether two Taicpu instructions are equal}
                   Begin
                     RegInfo.RegsLoadedForRef := RegInfo.RegsLoadedForRef + [Index];
 {$ifdef csdebug}
-                    Writeln(gas_reg2str[index], ' added');
+                    Writeln(std_reg2str[index], ' added');
 {$endif csdebug}
                   end;
 
@@ -1544,7 +1544,7 @@ Begin {checks whether two Taicpu instructions are equal}
                   RegInfo.RegsLoadedForRef := RegInfo.RegsLoadedForRef -
                                                  [Reg32(Taicpu(p2).oper[1].reg)];
 {$ifdef csdebug}
-                  Writeln(gas_reg2str[Reg32(Taicpu(p2).oper[1].reg)], ' removed');
+                  Writeln(std_reg2str[Reg32(Taicpu(p2).oper[1].reg)], ' removed');
 {$endif csdebug}
                 end;
             InstructionsEquivalent :=
@@ -1891,7 +1891,7 @@ Begin
     top_reg:
       begin
 {$ifdef statedebug}
-        hp := Tai_asm_comment.Create(strpnew('destroying '+gas_reg2str[o.reg]));
+        hp := Tai_asm_comment.Create(strpnew('destroying '+std_reg2str[o.reg]));
         hp.next := Taiobj^.next;
         hp.previous := Taiobj;
         Taiobj^.next := hp;
@@ -1940,7 +1940,7 @@ Begin
           invalidateDependingRegs(p.optinfo,reg);
           pTaiprop(p.optinfo)^.regs[reg].memwrite := nil;
 {$ifdef StateDebug}
-          hp := Tai_asm_comment.Create(strpnew(gas_reg2str[reg]+': '+tostr(PTaiProp(p.optinfo)^.Regs[reg].WState)
+          hp := Tai_asm_comment.Create(strpnew(std_reg2str[reg]+': '+tostr(PTaiProp(p.optinfo)^.Regs[reg].WState)
                 + ' -- ' + tostr(PTaiProp(p.optinfo)^.Regs[reg].nrofmods))));
           InsertLLItem(AsmL, p, p.next, hp);
 {$endif StateDebug}
@@ -1948,12 +1948,12 @@ Begin
       Else
         Begin
 {$ifdef statedebug}
-          hp := Tai_asm_comment.Create(strpnew('destroying '+gas_reg2str[reg]));
+          hp := Tai_asm_comment.Create(strpnew('destroying '+std_reg2str[reg]));
           insertllitem(asml,p,p.next,hp);
 {$endif statedebug}
           DestroyReg(PTaiProp(p.optinfo), Reg, true);
 {$ifdef StateDebug}
-          hp := Tai_asm_comment.Create(strpnew(gas_reg2str[reg]+': '+tostr(PTaiProp(p.optinfo)^.Regs[reg].WState)));
+          hp := Tai_asm_comment.Create(strpnew(std_reg2str[reg]+': '+tostr(PTaiProp(p.optinfo)^.Regs[reg].WState)));
           InsertLLItem(AsmL, p, p.next, hp);
 {$endif StateDebug}
         End
@@ -2242,7 +2242,7 @@ Begin
                           Begin
 {$ifdef statedebug}
                             hp := Tai_asm_comment.Create(strpnew('destroying '+
-                              gas_reg2str[Taicpu(p).oper[1].reg])));
+                              std_reg2str[Taicpu(p).oper[1].reg])));
                             insertllitem(asml,p,p.next,hp);
 {$endif statedebug}
 
@@ -2270,7 +2270,7 @@ Begin
                           else
                             begin
 {$ifdef statedebug}
-                              hp := Tai_asm_comment.Create(strpnew('destroying & initing '+gas_reg2str[tmpreg]));
+                              hp := Tai_asm_comment.Create(strpnew('destroying & initing '+std_reg2str[tmpreg]));
                               insertllitem(asml,p,p.next,hp);
 {$endif statedebug}
                               destroyReg(curprop, tmpreg, true);
@@ -2283,7 +2283,7 @@ Begin
                                   end
                             end;
 {$ifdef StateDebug}
-                  hp := Tai_asm_comment.Create(strpnew(gas_reg2str[TmpReg]+': '+tostr(CurProp^.regs[TmpReg].WState)));
+                  hp := Tai_asm_comment.Create(strpnew(std_reg2str[TmpReg]+': '+tostr(CurProp^.regs[TmpReg].WState)));
                   InsertLLItem(AsmL, p, p.next, hp);
 {$endif StateDebug}
                           End;
@@ -2308,7 +2308,7 @@ Begin
                             Begin
                               TmpReg := Reg32(Taicpu(p).oper[1].reg);
 {$ifdef statedebug}
-          hp := Tai_asm_comment.Create(strpnew('destroying '+gas_reg2str[tmpreg]));
+          hp := Tai_asm_comment.Create(strpnew('destroying '+std_reg2str[tmpreg]));
           insertllitem(asml,p,p.next,hp);
 {$endif statedebug}
                               With CurProp^.regs[TmpReg] Do
@@ -2378,7 +2378,7 @@ Begin
                     begin
 {$ifdef statedebug}
                       hp := Tai_asm_comment.Create(strpnew('destroying & initing'+
-                        gas_reg2str[Taicpu(p).oper[1].reg])));
+                        std_reg2str[Taicpu(p).oper[1].reg])));
                       insertllitem(asml,p,p.next,hp);
 {$endif statedebug}
                       destroyreg(curprop,Taicpu(p).oper[1].reg,true);
@@ -2404,7 +2404,7 @@ Begin
                               ReadReg(CurProp, TCh2Reg(InstrProp.Ch[Cnt]));
 {$ifdef statedebug}
                             hp := Tai_asm_comment.Create(strpnew('destroying '+
-                              gas_reg2str[TCh2Reg(InstrProp.Ch[Cnt])])));
+                              std_reg2str[TCh2Reg(InstrProp.Ch[Cnt])])));
                             insertllitem(asml,p,p.next,hp);
 {$endif statedebug}
                             DestroyReg(CurProp, TCh2Reg(InstrProp.Ch[Cnt]), true);
@@ -2586,8 +2586,16 @@ End.
 
 {
   $Log$
-  Revision 1.29  2002-04-14 17:00:49  carl
-  + att_reg2str -> gas_reg2str
+  Revision 1.30  2002-04-15 19:12:09  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.29  2002/04/14 17:00:49  carl
+  + att_reg2str -> std_reg2str
 
   Revision 1.28  2002/04/02 17:11:34  peter
     * tlocation,treference update

+ 11 - 3
compiler/i386/n386mem.pas

@@ -87,7 +87,7 @@ implementation
               remove_non_regvars_from_loc(location,regstopush);
               rg.saveusedregisters(exprasmlist,pushed,regstopush);
 
-              tg.gettempofsizereference(exprasmlist,target_info.size_of_pointer,location.reference);
+              tg.gettempofsizereference(exprasmlist,pointer_size,location.reference);
 
               { determines the size of the mem block }
               push_int(tpointerdef(resulttype.def).pointertype.def.size);
@@ -140,7 +140,7 @@ implementation
 
          procedure saveleft;
          begin
-           tg.gettempofsizereference(exprasmlist,target_info.size_of_pointer,lefttemp);
+           tg.gettempofsizereference(exprasmlist,pointer_size,lefttemp);
            cg.a_load_loc_ref(exprasmlist,left.location,lefttemp);
            location_release(exprasmlist,left.location);
          end;
@@ -663,7 +663,15 @@ begin
 end.
 {
   $Log$
-  Revision 1.24  2002-04-04 19:06:12  peter
+  Revision 1.25  2002-04-15 19:12:09  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.24  2002/04/04 19:06:12  peter
     * removed unused units
     * use tlocation.size in cg.a_*loc*() routines
 

+ 60 - 13
compiler/i386/ra386.pas

@@ -27,7 +27,7 @@ unit Ra386;
 interface
 
 uses
-  aasm,cpubase,RAUtils;
+  aasm,cpubase,rautils,cclasses;
 
 { Parser helpers }
 function is_prefix(t:tasmop):boolean;
@@ -51,12 +51,48 @@ type
     procedure ConcatInstruction(p : taasmoutput);override;
   end;
 
+  tstr2opentry = class(Tnamedindexitem)
+    op: TAsmOp;
+  end;
+
+const
+  AsmPrefixes = 6;
+  AsmPrefix : array[0..AsmPrefixes-1] of TasmOP =(
+    A_LOCK,A_REP,A_REPE,A_REPNE,A_REPNZ,A_REPZ
+  );
+
+  AsmOverrides = 6;
+  AsmOverride : array[0..AsmOverrides-1] of TasmOP =(
+    A_SEGCS,A_SEGES,A_SEGDS,A_SEGFS,A_SEGGS,A_SEGSS
+  );
+  
+  CondAsmOps=3;
+  CondAsmOp:array[0..CondAsmOps-1] of TasmOp=(
+    A_CMOVcc, A_Jcc, A_SETcc
+  );
+  CondAsmOpStr:array[0..CondAsmOps-1] of string[4]=(
+    'CMOV','J','SET'
+  );
+
+  { Convert reg to opsize }
+  reg_2_opsize:array[firstreg..lastreg] of topsize = (S_NO,
+    S_L,S_L,S_L,S_L,S_L,S_L,S_L,S_L,
+    S_W,S_W,S_W,S_W,S_W,S_W,S_W,S_W,
+    S_B,S_B,S_B,S_B,S_B,S_B,S_B,S_B,
+    S_W,S_W,S_W,S_W,S_W,S_W,
+    S_FL,S_FL,S_FL,S_FL,S_FL,S_FL,S_FL,S_FL,S_FL,
+    S_L,S_L,S_L,S_L,S_L,S_L,
+    S_L,S_L,S_L,S_L,
+    S_L,S_L,S_L,S_L,S_L,
+    S_D,S_D,S_D,S_D,S_D,S_D,S_D,S_D,
+    S_D,S_D,S_D,S_D,S_D,S_D,S_D,S_D
+  );
 
 implementation
 
 uses
   globtype,globals,systems,verbose,
-  cpuinfo,cpuasm;
+  cpuinfo,cpuasm,ag386att;
 
 {$define ATTOP}
 {$define INTELOP}
@@ -74,6 +110,9 @@ uses
     {$undef ATTOP}
   {$endif}
 {$endif}
+
+
+
 {*****************************************************************************
                               Parser Helpers
 *****************************************************************************}
@@ -166,14 +205,14 @@ end;
 
 Procedure T386Operand.SetCorrectSize(opcode:tasmop);
 begin
-  if att_needsuffix[opcode]=attsufFPU then
+  if gas_needsuffix[opcode]=attsufFPU then
     begin
      case size of
       S_L : size:=S_FS;
       S_IQ : size:=S_FL;
      end;
     end
-  else if att_needsuffix[opcode]=attsufFPUint then
+  else if gas_needsuffix[opcode]=attsufFPUint then
     begin
       case size of
       S_W : size:=S_IS;
@@ -466,10 +505,10 @@ begin
        else if opcode=A_FDIVR then
          opcode:=A_FDIVRP;
 {$ifdef ATTOP}
-       message1(asmr_w_fadd_to_faddp,att_op2str[opcode]);
+       message1(asmr_w_fadd_to_faddp,gas_op2str[opcode]);
 {$else}
   {$ifdef INTELOP}
-       message1(asmr_w_fadd_to_faddp,int_op2str[opcode]);
+       message1(asmr_w_fadd_to_faddp,std_op2str[opcode]);
   {$else}
        message1(asmr_w_fadd_to_faddp,'fXX');
   {$endif INTELOP}
@@ -490,10 +529,10 @@ begin
       (opcode=A_FDIVR)) then
      begin
 {$ifdef ATTOP}
-       message1(asmr_w_adding_explicit_args_fXX,att_op2str[opcode]);
+       message1(asmr_w_adding_explicit_args_fXX,gas_op2str[opcode]);
 {$else}
   {$ifdef INTELOP}
-       message1(asmr_w_adding_explicit_args_fXX,int_op2str[opcode]);
+       message1(asmr_w_adding_explicit_args_fXX,std_op2str[opcode]);
   {$else}
        message1(asmr_w_adding_explicit_args_fXX,'fXX');
   {$endif INTELOP}
@@ -515,10 +554,10 @@ begin
       (opcode=A_FMULP)) then
      begin
 {$ifdef ATTOP}
-       message1(asmr_w_adding_explicit_first_arg_fXX,att_op2str[opcode]);
+       message1(asmr_w_adding_explicit_first_arg_fXX,gas_op2str[opcode]);
 {$else}
   {$ifdef INTELOP}
-       message1(asmr_w_adding_explicit_first_arg_fXX,int_op2str[opcode]);
+       message1(asmr_w_adding_explicit_first_arg_fXX,std_op2str[opcode]);
   {$else}
        message1(asmr_w_adding_explicit_first_arg_fXX,'fXX');
   {$endif INTELOP}
@@ -540,10 +579,10 @@ begin
       (opcode=A_FMUL)) then
      begin
 {$ifdef ATTOP}
-       message1(asmr_w_adding_explicit_second_arg_fXX,att_op2str[opcode]);
+       message1(asmr_w_adding_explicit_second_arg_fXX,gas_op2str[opcode]);
 {$else}
   {$ifdef INTELOP}
-       message1(asmr_w_adding_explicit_second_arg_fXX,int_op2str[opcode]);
+       message1(asmr_w_adding_explicit_second_arg_fXX,std_op2str[opcode]);
   {$else}
        message1(asmr_w_adding_explicit_second_arg_fXX,'fXX');
   {$endif INTELOP}
@@ -629,7 +668,15 @@ end;
 end.
 {
   $Log$
-  Revision 1.16  2002-04-04 19:06:13  peter
+  Revision 1.17  2002-04-15 19:12:09  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.16  2002/04/04 19:06:13  peter
     * removed unused units
     * use tlocation.size in cg.a_*loc*() routines
 

+ 15 - 7
compiler/i386/ra386att.pas

@@ -48,7 +48,7 @@ Implementation
        nbas,
        { parser }
        scanner,
-       ra386,rautils
+       ra386,ag386att,rautils
        ;
 
 type
@@ -114,7 +114,7 @@ Begin
   iasmops.delete_doubles:=true;
   for i:=firstop to lastop do
     begin
-      str2opentry:=tstr2opentry.createname(upper(att_op2str[i]));
+      str2opentry:=tstr2opentry.createname(upper(gas_op2str[i]));
       str2opentry.op:=i;
       iasmops.insert(str2opentry);
     end;
@@ -172,9 +172,9 @@ Begin
         if assigned(str2opentry) then
           begin
             actopcode:=str2opentry.op;
-            if att_needsuffix[actopcode]=attsufFPU then
+            if gas_needsuffix[actopcode]=attsufFPU then
              actopsize:=att_sizefpusuffix[sufidx]
-            else if att_needsuffix[actopcode]=attsufFPUint then
+            else if gas_needsuffix[actopcode]=attsufFPUint then
              actopsize:=att_sizefpuintsuffix[sufidx]
             else
              actopsize:=att_sizesuffix[sufidx];
@@ -195,9 +195,9 @@ Begin
                   if Cond=Upper(cond2str[cnd]) then
                    begin
                      actopcode:=CondASmOp[j];
-                     if att_needsuffix[actopcode]=attsufFPU then
+                     if gas_needsuffix[actopcode]=attsufFPU then
                       actopsize:=att_sizefpusuffix[sufidx]
-                     else if att_needsuffix[actopcode]=attsufFPUint then
+                     else if gas_needsuffix[actopcode]=attsufFPUint then
                       actopsize:=att_sizefpuintsuffix[sufidx]
                      else
                       actopsize:=att_sizesuffix[sufidx];
@@ -2129,7 +2129,15 @@ finalization
 end.
 {
   $Log$
-  Revision 1.20  2002-04-14 17:01:52  carl
+  Revision 1.21  2002-04-15 19:12:09  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.20  2002/04/14 17:01:52  carl
   + att_reg2str -> gas_reg2str
 
   Revision 1.19  2002/04/04 19:06:13  peter

+ 12 - 2
compiler/i386/ra386dir.pas

@@ -49,7 +49,9 @@ interface
        scanner,
        ra386,
        { codegen }
-       cgbase
+       cgbase,
+       { constants }
+       ag386att
        ;
 
     function assemble : tnode;
@@ -302,7 +304,15 @@ initialization
 end.
 {
   $Log$
-  Revision 1.13  2002-04-14 17:01:52  carl
+  Revision 1.14  2002-04-15 19:12:09  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.13  2002/04/14 17:01:52  carl
   + att_reg2str -> gas_reg2str
 
   Revision 1.12  2001/11/02 22:58:11  peter

+ 12 - 4
compiler/i386/ra386int.pas

@@ -48,7 +48,7 @@ Implementation
        nbas,
        { parser }
        scanner,
-       ra386,rautils,
+       rautils,ra386,
        { codegen }
        cgbase
        ;
@@ -130,14 +130,14 @@ Begin
   iasmops.delete_doubles:=true;
   for i:=firstop to lastop do
     begin
-      str2opentry:=tstr2opentry.createname(upper(int_op2str[i]));
+      str2opentry:=tstr2opentry.createname(upper(std_op2str[i]));
       str2opentry.op:=i;
       iasmops.insert(str2opentry);
     end;
   { registers }
   new(iasmregs);
   for j:=firstreg to lastreg do
-   iasmregs^[j] := upper(int_reg2str[j]);
+   iasmregs^[j] := upper(std_reg2str[j]);
 end;
 
 
@@ -1959,7 +1959,15 @@ finalization
 end.
 {
   $Log$
-  Revision 1.22  2002-04-04 19:06:13  peter
+  Revision 1.23  2002-04-15 19:12:09  carl
+  + target_info.size_of_pointer -> pointer_size
+  + some cleanup of unused types/variables
+  * move several constants from cpubase to their specific units
+    (where they are used)
+  + att_Reg2str -> gas_reg2str
+  + int_reg2str -> std_reg2str
+
+  Revision 1.22  2002/04/04 19:06:13  peter
     * removed unused units
     * use tlocation.size in cg.a_*loc*() routines