Pārlūkot izejas kodu

* tai_const refactored

git-svn-id: trunk@2323 -
florian 19 gadi atpakaļ
vecāks
revīzija
b06643a1eb

+ 83 - 62
compiler/aasmtai.pas

@@ -40,6 +40,8 @@ interface
        aasmbase;
 
     type
+       { keep the number of elements in this enumeration less or equal than 32 as long
+         as FPC knows only 4 byte and 32 byte sets (FK) }
        taitype = (
           ait_none,
           ait_align,
@@ -52,17 +54,7 @@ interface
           ait_symbol_end, { needed to calc the size of a symbol }
           ait_directive,
           ait_label,
-          { the const_xx must be below each other so it can be used as
-            array index }
-          ait_const_128bit,
-          ait_const_64bit,
-          ait_const_32bit,
-          ait_const_16bit,
-          ait_const_8bit,
-          ait_const_sleb128bit,
-          ait_const_uleb128bit,
-          ait_const_rva_symbol, { win32 only }
-          ait_const_indirect_symbol, { darwin only }
+          ait_const,
           ait_real_32bit,
           ait_real_64bit,
           ait_real_80bit,
@@ -88,16 +80,34 @@ interface
           ait_regalloc,
           ait_tempalloc,
           { used to mark assembler blocks and inlined functions }
-          ait_marker
+          ait_marker,
+          { new source file (dwarf) }
+          ait_file,
+          { new line in source file (dwarf) }
+          ait_line
           );
 
+        taiconst_type = (
+          aitconst_128bit,
+          aitconst_64bit,
+          aitconst_32bit,
+          aitconst_16bit,
+          aitconst_8bit,
+          aitconst_sleb128bit,
+          aitconst_uleb128bit,
+          { win32 only }
+          aitconst_rva_symbol,
+          { darwin only }
+          aitconst_indirect_symbol
+        );
+
     const
 {$ifdef cpu64bit}
-       ait_const_aint = ait_const_64bit;
-       ait_const_ptr  = ait_const_64bit;
+       aitconst_aint = aitconst_64bit;
+       aitconst_ptr  = aitconst_64bit;
 {$else cpu64bit}
-       ait_const_aint = ait_const_32bit;
-       ait_const_ptr  = ait_const_32bit;
+       aitconst_aint = aitconst_32bit;
+       aitconst_ptr  = aitconst_32bit;
 {$endif cpu64bit}
 
        taitypestr : array[taitype] of string[24] = (
@@ -112,15 +122,7 @@ interface
           'symbol_end',
           'symbol_directive',
           'label',
-          'const_128bit',
-          'const_64bit',
-          'const_32bit',
-          'const_16bit',
-          'const_8bit',
-          'const_sleb128bit',
-          'const_uleb128bit',
-          'const_rva_symbol',
-          'const_indirect_symbol',
+          'const',
           'real_32bit',
           'real_64bit',
           'real_80bit',
@@ -144,7 +146,9 @@ interface
           'cut',
           'regalloc',
           'tempalloc',
-          'marker'
+          'marker',
+          'file',
+          'line'
           );
 
     type
@@ -196,24 +200,22 @@ interface
       end;
       poper=^toper;
 
-{ ait_* types which don't result in executable code or which don't influence   }
-{ the way the program runs/behaves, but which may be encountered by the        }
-{ optimizer (= if it's sometimes added to the exprasm list). Update if you add }
-{ a new ait type!                                                              }
     const
+      { ait_* types which don't result in executable code or which don't influence
+        the way the program runs/behaves, but which may be encountered by the
+        optimizer (= if it's sometimes added to the exprasm list). Update if you add
+        a new ait type!                                                              }
       SkipInstr = [ait_comment, ait_symbol,ait_section
                    ,ait_stab, ait_function_name, ait_force_line
                    ,ait_regalloc, ait_tempalloc, ait_symbol_end, ait_directive];
 
-{ ait_* types which do not have line information (and hence which are of type
-  tai, otherwise, they are of type tailineinfo }
+      { ait_* types which do not have line information (and hence which are of type
+        tai, otherwise, they are of type tailineinfo }
       SkipLineInfo =[ait_label,
                      ait_regalloc,ait_tempalloc,
                      ait_stab,ait_function_name,
                      ait_cutobject,ait_marker,ait_align,ait_section,ait_comment,
-                     ait_const_8bit,ait_const_16bit,ait_const_32bit,ait_const_64bit,ait_const_128bit,
-                     ait_const_sleb128bit,ait_const_uleb128bit,
-                     ait_const_rva_symbol,ait_const_indirect_symbol,
+                     ait_const,
                      ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_real_128bit
                     ];
 
@@ -364,9 +366,10 @@ interface
           sym,
           endsym  : tasmsymbol;
           value   : int64;
+          consttype : taiconst_type;
           { we use for the 128bit int64/qword for now because I can't imagine a
             case where we need 128 bit now (FK) }
-          constructor Create(_typ:taitype;_value : int64);
+          constructor Create(_typ:taiconst_type;_value : int64);
           constructor Create_128bit(_value : int64);
           constructor Create_64bit(_value : int64);
           constructor Create_32bit(_value : longint);
@@ -377,7 +380,7 @@ interface
           constructor Create_aint(_value : aint);
           constructor Create_sym(_sym:tasmsymbol);
           constructor Create_sym_offset(_sym:tasmsymbol;ofs:aint);
-          constructor Create_rel_sym(_typ:taitype;_sym,_endsym:tasmsymbol);
+          constructor Create_rel_sym(_typ:taiconst_type;_sym,_endsym:tasmsymbol);
           constructor Create_rva_sym(_sym:tasmsymbol);
           constructor Create_indirect_sym(_sym:tasmsymbol);
           constructor Createname(const name:string;_symtyp:Tasmsymtype;ofs:aint);
@@ -1087,10 +1090,11 @@ implementation
                                TAI_CONST
  ****************************************************************************}
 
-    constructor tai_const.Create(_typ:taitype;_value : int64);
+    constructor tai_const.Create(_typ:taiconst_type;_value : int64);
       begin
          inherited Create;
-         typ:=_typ;
+         typ:=ait_const;
+         consttype:=_typ;
          value:=_value;
          sym:=nil;
          endsym:=nil;
@@ -1100,7 +1104,8 @@ implementation
     constructor tai_const.Create_128bit(_value : int64);
       begin
          inherited Create;
-         typ:=ait_const_128bit;
+         typ:=ait_const;
+         consttype:=aitconst_128bit;
          value:=_value;
          sym:=nil;
          endsym:=nil;
@@ -1110,7 +1115,8 @@ implementation
     constructor tai_const.Create_64bit(_value : int64);
       begin
          inherited Create;
-         typ:=ait_const_64bit;
+         typ:=ait_const;
+         consttype:=aitconst_64bit;
          value:=_value;
          sym:=nil;
          endsym:=nil;
@@ -1120,7 +1126,8 @@ implementation
     constructor tai_const.Create_32bit(_value : longint);
       begin
          inherited Create;
-         typ:=ait_const_32bit;
+         typ:=ait_const;
+         consttype:=aitconst_32bit;
          value:=_value;
          sym:=nil;
          endsym:=nil;
@@ -1130,7 +1137,8 @@ implementation
     constructor tai_const.Create_16bit(_value : word);
       begin
          inherited Create;
-         typ:=ait_const_16bit;
+         typ:=ait_const;
+         consttype:=aitconst_16bit;
          value:=_value;
          sym:=nil;
          endsym:=nil;
@@ -1140,7 +1148,8 @@ implementation
     constructor tai_const.Create_8bit(_value : byte);
       begin
          inherited Create;
-         typ:=ait_const_8bit;
+         typ:=ait_const;
+         consttype:=aitconst_8bit;
          value:=_value;
          sym:=nil;
          endsym:=nil;
@@ -1150,7 +1159,8 @@ implementation
     constructor tai_const.Create_sleb128bit(_value : int64);
       begin
          inherited Create;
-         typ:=ait_const_sleb128bit;
+         typ:=ait_const;
+         consttype:=aitconst_sleb128bit;
          value:=_value;
          sym:=nil;
          endsym:=nil;
@@ -1160,7 +1170,8 @@ implementation
     constructor tai_const.Create_uleb128bit(_value : qword);
       begin
          inherited Create;
-         typ:=ait_const_uleb128bit;
+         typ:=ait_const;
+         consttype:=aitconst_uleb128bit;
          value:=int64(_value);
          sym:=nil;
          endsym:=nil;
@@ -1170,7 +1181,8 @@ implementation
     constructor tai_const.Create_aint(_value : aint);
       begin
          inherited Create;
-         typ:=ait_const_aint;
+         typ:=ait_const;
+         consttype:=aitconst_aint;
          value:=_value;
          sym:=nil;
          endsym:=nil;
@@ -1180,7 +1192,8 @@ implementation
     constructor tai_const.Create_sym(_sym:tasmsymbol);
       begin
          inherited Create;
-         typ:=ait_const_ptr;
+         typ:=ait_const;
+         consttype:=aitconst_ptr;
          { sym is allowed to be nil, this is used to write nil pointers }
          sym:=_sym;
          endsym:=nil;
@@ -1194,7 +1207,8 @@ implementation
     constructor tai_const.Create_sym_offset(_sym:tasmsymbol;ofs:aint);
       begin
          inherited Create;
-         typ:=ait_const_ptr;
+         typ:=ait_const;
+         consttype:=aitconst_ptr;
          if not assigned(_sym) then
            internalerror(200404121);
          sym:=_sym;
@@ -1205,10 +1219,11 @@ implementation
       end;
 
 
-    constructor tai_const.Create_rel_sym(_typ:taitype;_sym,_endsym:tasmsymbol);
+    constructor tai_const.Create_rel_sym(_typ:taiconst_type;_sym,_endsym:tasmsymbol);
       begin
          inherited Create;
-         typ:=_typ;
+         typ:=ait_const;
+         consttype:=_typ;
          sym:=_sym;
          endsym:=_endsym;
          value:=0;
@@ -1221,7 +1236,8 @@ implementation
     constructor tai_const.Create_rva_sym(_sym:tasmsymbol);
       begin
          inherited Create;
-         typ:=ait_const_rva_symbol;
+         typ:=ait_const;
+         consttype:=aitconst_rva_symbol;
          sym:=_sym;
          endsym:=nil;
          value:=0;
@@ -1233,7 +1249,8 @@ implementation
     constructor tai_const.Create_indirect_sym(_sym:tasmsymbol);
       begin
          inherited Create;
-         typ:=ait_const_indirect_symbol;
+         typ:=ait_const;
+         consttype:=aitconst_indirect_symbol;
          sym:=_sym;
          endsym:=nil;
          value:=0;
@@ -1245,7 +1262,8 @@ implementation
     constructor tai_const.Createname(const name:string;_symtyp:Tasmsymtype;ofs:aint);
       begin
          inherited Create;
-         typ:=ait_const_ptr;
+         typ:=ait_const;
+         consttype:=aitconst_ptr;
          sym:=objectlibrary.newasmsymbol(name,AB_EXTERNAL,_symtyp);
          endsym:=nil;
          value:=ofs;
@@ -1257,7 +1275,8 @@ implementation
     constructor tai_const.Createname_rva(const name:string);
       begin
          inherited Create;
-         typ:=ait_const_rva_symbol;
+         typ:=ait_const;
+         consttype:=aitconst_rva_symbol;
          sym:=objectlibrary.newasmsymbol(name,AB_EXTERNAL,AT_FUNCTION);
          endsym:=nil;
          value:=0;
@@ -1269,6 +1288,7 @@ implementation
     constructor tai_const.ppuload(t:taitype;ppufile:tcompilerppufile);
       begin
         inherited ppuload(t,ppufile);
+        consttype:=taiconst_type(ppufile.getbyte);
         sym:=ppufile.getasmsymbol;
         endsym:=ppufile.getasmsymbol;
         value:=ppufile.getint64;
@@ -1278,6 +1298,7 @@ implementation
     procedure tai_const.ppuwrite(ppufile:tcompilerppufile);
       begin
         inherited ppuwrite(ppufile);
+        ppufile.putbyte(byte(consttype));
         ppufile.putasmsymbol(sym);
         ppufile.putasmsymbol(endsym);
         ppufile.putint64(value);
@@ -1303,17 +1324,17 @@ implementation
 
     function tai_const.size:longint;
       begin
-        case typ of
-          ait_const_8bit :
+        case consttype of
+          aitconst_8bit :
             result:=1;
-          ait_const_16bit :
+          aitconst_16bit :
             result:=2;
-          ait_const_32bit :
+          aitconst_32bit :
             result:=4;
-          ait_const_64bit :
+          aitconst_64bit :
             result:=8;
-          ait_const_indirect_symbol,
-          ait_const_rva_symbol :
+          aitconst_indirect_symbol,
+          aitconst_rva_symbol :
             result:=sizeof(aint);
         end;
       end;

+ 94 - 91
compiler/aggas.pas

@@ -185,7 +185,7 @@ implementation
 
 
     const
-      ait_const2str : array[ait_const_128bit..ait_const_indirect_symbol] of string[20]=(
+      ait_const2str : array[aitconst_128bit..aitconst_indirect_symbol] of string[20]=(
         #9'.fixme128'#9,#9'.quad'#9,#9'.long'#9,#9'.short'#9,#9'.byte'#9,
         #9'.sleb128'#9,#9'.uleb128'#9,
         #9'.rva'#9,#9'.indirect_symbol'#9
@@ -335,8 +335,7 @@ implementation
         needsObject :=
             (
               assigned(hp.next) and
-               (tai_symbol(hp.next).typ in [ait_const_rva_symbol,
-                ait_const_32bit,ait_const_16bit,ait_const_8bit,ait_datablock,
+               (tai_symbol(hp.next).typ in [ait_const,ait_datablock,
                 ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit])
             ) or
             (hp.sym.typ=AT_DATA);
@@ -549,103 +548,107 @@ implementation
                  end;
              end;
 
+           ait_const:
+             begin
+               case tai_const(hp).consttype of
 {$ifndef cpu64bit}
-           ait_const_128bit :
-              begin
-                internalerror(200404291);
-              end;
+                 aitconst_128bit :
+                    begin
+                      internalerror(200404291);
+                    end;
 
-           ait_const_64bit :
-              begin
-                if assigned(tai_const(hp).sym) then
-                  internalerror(200404292);
-                AsmWrite(ait_const2str[ait_const_32bit]);
-                if target_info.endian = endian_little then
-                  begin
-                    AsmWrite(tostr(longint(lo(tai_const(hp).value))));
-                    AsmWrite(',');
-                    AsmWrite(tostr(longint(hi(tai_const(hp).value))));
-                  end
-                else
-                  begin
-                    AsmWrite(tostr(longint(hi(tai_const(hp).value))));
-                    AsmWrite(',');
-                    AsmWrite(tostr(longint(lo(tai_const(hp).value))));
-                  end;
-                AsmLn;
-              end;
+                 aitconst_64bit :
+                    begin
+                      if assigned(tai_const(hp).sym) then
+                        internalerror(200404292);
+                      AsmWrite(ait_const2str[aitconst_32bit]);
+                      if target_info.endian = endian_little then
+                        begin
+                          AsmWrite(tostr(longint(lo(tai_const(hp).value))));
+                          AsmWrite(',');
+                          AsmWrite(tostr(longint(hi(tai_const(hp).value))));
+                        end
+                      else
+                        begin
+                          AsmWrite(tostr(longint(hi(tai_const(hp).value))));
+                          AsmWrite(',');
+                          AsmWrite(tostr(longint(lo(tai_const(hp).value))));
+                        end;
+                      AsmLn;
+                    end;
 {$endif cpu64bit}
-
-           ait_const_uleb128bit,
-           ait_const_sleb128bit,
+                 aitconst_uleb128bit,
+                 aitconst_sleb128bit,
 {$ifdef cpu64bit}
-           ait_const_128bit,
-           ait_const_64bit,
+                 aitconst_128bit,
+                 aitconst_64bit,
 {$endif cpu64bit}
-           ait_const_32bit,
-           ait_const_16bit,
-           ait_const_8bit,
-           ait_const_rva_symbol,
-           ait_const_indirect_symbol :
-             begin
-              if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) and
-                 (hp.typ in [ait_const_uleb128bit,ait_const_sleb128bit]) then
-                begin
-                  AsmWrite(ait_const2str[ait_const_8bit]);
-                  case hp.typ of
-                    ait_const_uleb128bit:
-                      WriteDecodedUleb128(aword(tai_const(hp).value));
-                    ait_const_sleb128bit:
-                      WriteDecodedSleb128(aint(tai_const(hp).value));
-                  end
-                end
-               else
-                 begin
-                   AsmWrite(ait_const2str[hp.typ]);
-                   consttyp:=hp.typ;
-                   l:=0;
-                   t := '';
-                   repeat
-                     if assigned(tai_const(hp).sym) then
+                 aitconst_32bit,
+                 aitconst_16bit,
+                 aitconst_8bit,
+                 aitconst_rva_symbol,
+                 aitconst_indirect_symbol :
+                   begin
+                     if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) and
+                        (tai_const(hp).consttype in [aitconst_uleb128bit,aitconst_sleb128bit]) then
                        begin
-                         if assigned(tai_const(hp).endsym) then
-                           begin
-                             if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
-                               begin
-                                 s := NextSetLabel;
-                                 t := #9'.set '+s+','+tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name;
-                               end
-                             else
-                               s:=tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name
-                            end
-                         else
-                           s:=tai_const(hp).sym.name;
-                         if tai_const(hp).value<>0 then
-                           s:=s+tostr_with_plus(tai_const(hp).value);
+                         AsmWrite(ait_const2str[aitconst_8bit]);
+                         case tai_const(hp).consttype of
+                           aitconst_uleb128bit:
+                             WriteDecodedUleb128(aword(tai_const(hp).value));
+                           aitconst_sleb128bit:
+                             WriteDecodedSleb128(aint(tai_const(hp).value));
+                         end
                        end
                      else
-                       s:=tostr(tai_const(hp).value);
-                     AsmWrite(s);
-                     inc(l,length(s));
-                     { Values with symbols are written on a single line to improve
-                       reading of the .s file (PFV) }
-                     if assigned(tai_const(hp).sym) or
-                        not(CurrSecType in [sec_data,sec_rodata]) or
-                        (l>line_length) or
-                        (hp.next=nil) or
-                        (tai(hp.next).typ<>consttyp) or
-                        assigned(tai_const(hp.next).sym) then
-                       break;
-                     hp:=tai(hp.next);
-                     AsmWrite(',');
-                   until false;
-                   if (t <> '') then
-                     begin
-                       AsmLn;
-                       AsmWrite(t);
-                     end;
+                       begin
+                         AsmWrite(ait_const2str[tai_const(hp).consttype]);
+                         consttyp:=hp.typ;
+                         l:=0;
+                         t := '';
+                         repeat
+                           if assigned(tai_const(hp).sym) then
+                             begin
+                               if assigned(tai_const(hp).endsym) then
+                                 begin
+                                   if (target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+                                     begin
+                                       s := NextSetLabel;
+                                       t := #9'.set '+s+','+tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name;
+                                     end
+                                   else
+                                     s:=tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name
+                                  end
+                               else
+                                 s:=tai_const(hp).sym.name;
+                               if tai_const(hp).value<>0 then
+                                 s:=s+tostr_with_plus(tai_const(hp).value);
+                             end
+                           else
+                             s:=tostr(tai_const(hp).value);
+                           AsmWrite(s);
+                           inc(l,length(s));
+                           { Values with symbols are written on a single line to improve
+                             reading of the .s file (PFV) }
+                           if assigned(tai_const(hp).sym) or
+                              not(CurrSecType in [sec_data,sec_rodata]) or
+                              (l>line_length) or
+                              (hp.next=nil) or
+                              (tai(hp.next).typ<>consttyp) or
+                              assigned(tai_const(hp.next).sym) then
+                             break;
+                           hp:=tai(hp.next);
+                           AsmWrite(',');
+                         until false;
+                         if (t <> '') then
+                           begin
+                             AsmLn;
+                             AsmWrite(t);
+                           end;
+                       end;
+                      AsmLn;
+                   end;
                  end;
-               AsmLn;
              end;
 
 {$ifdef cpuextended}

+ 23 - 30
compiler/assemble.pas

@@ -926,12 +926,7 @@ Implementation
                objectdata.alloc(4);
              ait_comp_64bit :
                objectdata.alloc(8);
-             ait_const_64bit,
-             ait_const_32bit,
-             ait_const_16bit,
-             ait_const_8bit,
-             ait_const_rva_symbol,
-             ait_const_indirect_symbol :
+             ait_const:
                objectdata.alloc(tai_const(hp).size);
              ait_section:
                begin
@@ -1015,12 +1010,7 @@ Implementation
                objectdata.alloc(4);
              ait_comp_64bit :
                objectdata.alloc(8);
-             ait_const_64bit,
-             ait_const_32bit,
-             ait_const_16bit,
-             ait_const_8bit,
-             ait_const_rva_symbol,
-             ait_const_indirect_symbol :
+             ait_const:
                begin
                  objectdata.alloc(tai_const(hp).size);
                  if assigned(Tai_const(hp).sym) then
@@ -1153,29 +1143,32 @@ Implementation
                end;
              ait_string :
                objectdata.writebytes(Tai_string(hp).str^,Tai_string(hp).len);
-             ait_const_64bit,
-             ait_const_32bit,
-             ait_const_16bit,
-             ait_const_8bit :
+             ait_const :
                begin
-                 if assigned(tai_const(hp).sym) then
-                   begin
-                     if assigned(tai_const(hp).endsym) then
+                 case tai_const(hp).consttype of
+                   aitconst_64bit,
+                   aitconst_32bit,
+                   aitconst_16bit,
+                   aitconst_8bit :
+                     if assigned(tai_const(hp).sym) then
                        begin
-                         if tai_const(hp).endsym.section<>tai_const(hp).sym.section then
-                           internalerror(200404124);
-                         v:=tai_const(hp).endsym.address-tai_const(hp).sym.address+Tai_const(hp).value;
-                         objectdata.writebytes(v,tai_const(hp).size);
+                         if assigned(tai_const(hp).endsym) then
+                           begin
+                             if tai_const(hp).endsym.section<>tai_const(hp).sym.section then
+                               internalerror(200404124);
+                             v:=tai_const(hp).endsym.address-tai_const(hp).sym.address+Tai_const(hp).value;
+                             objectdata.writebytes(v,tai_const(hp).size);
+                           end
+                         else
+                           objectdata.writereloc(Tai_const(hp).value,Tai_const(hp).size,
+                                                 Tai_const(hp).sym,RELOC_ABSOLUTE);
                        end
                      else
-                       objectdata.writereloc(Tai_const(hp).value,Tai_const(hp).size,
-                                             Tai_const(hp).sym,RELOC_ABSOLUTE);
-                   end
-                 else
-                   objectdata.writebytes(Tai_const(hp).value,tai_const(hp).size);
+                       objectdata.writebytes(Tai_const(hp).value,tai_const(hp).size);
+                   aitconst_rva_symbol :
+                     objectdata.writereloc(Tai_const(hp).value,sizeof(aint),Tai_const(hp).sym,RELOC_RVA);
+                 end;
                end;
-             ait_const_rva_symbol :
-               objectdata.writereloc(Tai_const(hp).value,sizeof(aint),Tai_const(hp).sym,RELOC_RVA);
              ait_label :
                begin
                  objectdata.writesymbol(Tai_label(hp).l);

+ 7 - 7
compiler/dwarf.pas

@@ -227,9 +227,9 @@ implementation
 
     procedure tdwarfitem.generate_code(list:taasmoutput);
       const
-        enc2ait_const : array[tdwarfoperenc] of taitype = (
-          ait_const_uleb128bit,ait_const_sleb128bit,ait_const_ptr,
-          ait_const_32bit,ait_const_16bit,ait_const_8bit
+        enc2ait_const : array[tdwarfoperenc] of taiconst_type = (
+          aitconst_uleb128bit,aitconst_sleb128bit,aitconst_ptr,
+          aitconst_32bit,aitconst_16bit,aitconst_8bit
         );
       var
         i : integer;
@@ -318,7 +318,7 @@ implementation
         list.concat(tai_label.create(cielabel));
         objectlibrary.getjumplabel(lenstartlabel);
         objectlibrary.getjumplabel(lenendlabel);
-        list.concat(tai_const.create_rel_sym(ait_const_32bit,lenstartlabel,lenendlabel));
+        list.concat(tai_const.create_rel_sym(aitconst_32bit,lenstartlabel,lenendlabel));
         list.concat(tai_label.create(lenstartlabel));
         list.concat(tai_const.create_32bit(longint($ffffffff)));
         list.concat(tai_const.create_8bit(1));
@@ -356,14 +356,14 @@ implementation
                      PTRSIZE initial location = oper[0]
                      PTRSIZE function size = oper[1]
                   }
-                  list.concat(tai_const.create_rel_sym(ait_const_32bit,lenstartlabel,lenendlabel));
+                  list.concat(tai_const.create_rel_sym(aitconst_32bit,lenstartlabel,lenendlabel));
                   list.concat(tai_label.create(lenstartlabel));
                   { force label offset to 32bit }
                   tc:=tai_const.create_sym(cielabel);
-                  tc.typ:=ait_const_32bit;
+                  tc.consttype:=aitconst_32bit;
                   list.concat(tc);
                   list.concat(tai_const.create_sym(hp.oper[0].beginsym));
-                  list.concat(tai_const.create_rel_sym(ait_const_ptr,hp.oper[0].beginsym,hp.oper[0].endsym));
+                  list.concat(tai_const.create_rel_sym(aitconst_ptr,hp.oper[0].beginsym,hp.oper[0].endsym));
                 end;
               DW_CFA_End_Frame :
                 begin

+ 42 - 37
compiler/i386/ag386nsm.pas

@@ -346,7 +346,7 @@ interface
       LastSecType : TAsmSectionType;
 
     const
-      ait_const2str : array[ait_const_128bit..ait_const_indirect_symbol] of string[20]=(
+      ait_const2str : array[aitconst_128bit..aitconst_indirect_symbol] of string[20]=(
         #9'FIXME128',#9'FIXME64',#9'DD'#9,#9'DW'#9,#9'DB'#9,
         #9'FIXMESLEB',#9'FIXEMEULEB',
         #9'RVA'#9,#9'FIXMEINDIRECT'#9
@@ -390,7 +390,7 @@ interface
       lines,
       i,j,l    : longint;
       InlineLevel : longint;
-      consttyp : taitype;
+      consttype : taiconst_type;
       found,
       do_line,
       quoted   : boolean;
@@ -511,41 +511,47 @@ interface
                AsmWriteLn('RESB'#9+tostr(tai_datablock(hp).size));
              end;
 
-           ait_const_uleb128bit,
-           ait_const_sleb128bit,
-           ait_const_128bit,
-           ait_const_64bit,
-           ait_const_32bit,
-           ait_const_16bit,
-           ait_const_8bit,
-           ait_const_rva_symbol,
-           ait_const_indirect_symbol :
+           ait_const:
              begin
-               AsmWrite(ait_const2str[hp.typ]);
-               consttyp:=hp.typ;
-               l:=0;
-               repeat
-                 if assigned(tai_const(hp).sym) then
+               consttype:=tai_const(hp).consttype;
+               case consttype of
+                 aitconst_uleb128bit,
+                 aitconst_sleb128bit,
+                 aitconst_128bit,
+                 aitconst_64bit,
+                 aitconst_32bit,
+                 aitconst_16bit,
+                 aitconst_8bit,
+                 aitconst_rva_symbol,
+                 aitconst_indirect_symbol :
                    begin
-                     if assigned(tai_const(hp).endsym) then
-                       s:=tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name
-                     else
-                       s:=tai_const(hp).sym.name;
-                     if tai_const(hp).value<>0 then
-                       s:=s+tostr_with_plus(tai_const(hp).value);
-                   end
-                 else
-                   s:=tostr(tai_const(hp).value);
-                 AsmWrite(s);
-                 inc(l,length(s));
-                 if (l>line_length) or
-                    (hp.next=nil) or
-                    (tai(hp.next).typ<>consttyp) then
-                   break;
-                 hp:=tai(hp.next);
-                 AsmWrite(',');
-               until false;
-               AsmLn;
+                     AsmWrite(ait_const2str[tai_const(hp).consttype]);
+                     l:=0;
+                     repeat
+                       if assigned(tai_const(hp).sym) then
+                         begin
+                           if assigned(tai_const(hp).endsym) then
+                             s:=tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name
+                           else
+                             s:=tai_const(hp).sym.name;
+                           if tai_const(hp).value<>0 then
+                             s:=s+tostr_with_plus(tai_const(hp).value);
+                         end
+                       else
+                         s:=tostr(tai_const(hp).value);
+                       AsmWrite(s);
+                       inc(l,length(s));
+                       if (l>line_length) or
+                          (hp.next=nil) or
+                          (tai(hp.next).typ<>ait_const) or
+                          (tai_const(hp.next).consttype<>consttype) then
+                         break;
+                       hp:=tai(hp.next);
+                       AsmWrite(',');
+                     until false;
+                     AsmLn;
+                   end;
+               end;
              end;
 
            ait_real_32bit :
@@ -652,8 +658,7 @@ interface
                 end;
                AsmWrite(tai_symbol(hp).sym.name);
                if assigned(hp.next) and not(tai(hp.next).typ in
-                  [ait_const_32bit,ait_const_16bit,ait_const_8bit,
-                   ait_const_rva_symbol,
+                  [ait_const,
                    ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_string]) then
                 AsmWriteLn(':')
              end;

+ 1 - 6
compiler/ncgbas.pas

@@ -236,12 +236,7 @@ interface
                 case hp2.typ of
                   ait_label :
                      ReLabel(tasmsymbol(tai_label(hp2).l));
-                  ait_const_64bit,
-                  ait_const_32bit,
-                  ait_const_16bit,
-                  ait_const_8bit,
-                  ait_const_rva_symbol,
-                  ait_const_indirect_symbol :
+                  ait_const :
                      begin
                        if assigned(tai_const(hp2).sym) then
                          ReLabel(tai_const(hp2).sym);

+ 12 - 7
compiler/ncgcon.pas

@@ -336,13 +336,16 @@ implementation
                                        }
                                        hp2:=tai(lastlabelhp.previous);
                                        if assigned(hp2) and
-                                          (hp2.typ=ait_const_aint) and
+                                          (hp2.typ=ait_const) and
+                                          (tai_const(hp2).consttype=aitconst_aint) and
                                           (tai_const(hp2).value=-1) and
                                           assigned(hp2.previous) and
-                                          (tai(hp2.previous).typ=ait_const_aint) and
+                                          (tai(hp2.previous).typ=ait_const) and
+                                          (tai_const(hp2.previous).consttype=aitconst_aint) and
                                           (tai_const(hp2.previous).value=len) and
                                           assigned(hp2.previous.previous) and
-                                          (tai(hp2.previous.previous).typ=ait_const_ptr) and
+                                          (tai(hp2.previous.previous).typ=ait_const) and
+                                          (tai_const(hp2.previous.previous).consttype=aitconst_ptr) and
                                           assigned(hp2.previous.previous.previous) and
                                           (tai(hp2.previous.previous.previous).typ=ait_label) then
                                          begin
@@ -473,7 +476,7 @@ implementation
          hp1         : tai;
          lastlabel   : tasmlabel;
          i           : longint;
-         neededtyp   : taitype;
+         neededtyp   : taiconst_type;
          indexadjust : longint;
       type
          setbytes=array[0..31] of byte;
@@ -494,7 +497,7 @@ implementation
            exit;
          end;
         location_reset(location,LOC_CREFERENCE,OS_NO);
-        neededtyp:=ait_const_8bit;
+        neededtyp:=aitconst_8bit;
         lastlabel:=nil;
         { const already used ? }
         if not assigned(lab_set) then
@@ -507,9 +510,11 @@ implementation
                     lastlabel:=tai_label(hp1).l
                   else
                     begin
-                      if (lastlabel<>nil) and (hp1.typ=neededtyp) then
+                      if (lastlabel<>nil) and
+                        (hp1.typ=ait_const) and
+                        (tai_const(hp1).consttype=neededtyp) then
                         begin
-                          if (hp1.typ=ait_const_8bit) then
+                          if (tai_const(hp1).consttype=aitconst_8bit) then
                            begin
                              { compare normal set }
                              i:=0;

+ 3 - 3
compiler/nobj.pas

@@ -1293,8 +1293,8 @@ implementation
 
          { determine the size with symtable.datasize, because }
          { size gives back 4 for classes                    }
-         asmlist[al_globals].concat(Tai_const.Create(ait_const_ptr,tobjectsymtable(_class.symtable).datasize));
-         asmlist[al_globals].concat(Tai_const.Create(ait_const_ptr,-int64(tobjectsymtable(_class.symtable).datasize)));
+         asmlist[al_globals].concat(Tai_const.Create(aitconst_ptr,tobjectsymtable(_class.symtable).datasize));
+         asmlist[al_globals].concat(Tai_const.Create(aitconst_ptr,-int64(tobjectsymtable(_class.symtable).datasize)));
 {$ifdef WITHDMT}
          if _class.classtype=ct_object then
            begin
@@ -1353,7 +1353,7 @@ implementation
           end;
          { write virtual methods }
          writevirtualmethods(asmlist[al_globals]);
-         asmlist[al_globals].concat(Tai_const.create(ait_const_ptr,0));
+         asmlist[al_globals].concat(Tai_const.create(aitconst_ptr,0));
          { write the size of the VMT }
          asmlist[al_globals].concat(Tai_symbol_end.Createname(_class.vmt_mangledname));
       end;

+ 107 - 101
compiler/powerpc/agppcmpw.pas

@@ -668,7 +668,7 @@ interface
       lastinfile   : tinputfile;
 
     const
-      ait_const2str:array[ait_const_32bit..ait_const_8bit] of string[8]=
+      ait_const2str:array[aitconst_32bit..aitconst_8bit] of string[8]=
         (#9'dc.l'#9,#9'dc.w'#9,#9'dc.b'#9);
 
 
@@ -683,7 +683,7 @@ interface
       lines,
       InlineLevel : longint;
       i,j,l    : longint;
-      consttyp : taitype;
+      consttype : taiconst_type;
       found,
       do_line,DoNotSplitLine,
       quoted   : boolean;
@@ -816,111 +816,117 @@ interface
                    end;
               end;
 
-           ait_const_128bit:
+            ait_const:
               begin
-                internalerror(200404291);
-              end;
-           ait_const_64bit:
-              begin
-                if assigned(tai_const(hp).sym) then
-                  internalerror(200404292);
-                AsmWrite(ait_const2str[ait_const_32bit]);
-                if target_info.endian = endian_little then
-                  begin
-                    AsmWrite(tostr(longint(lo(tai_const(hp).value))));
-                    AsmWrite(',');
-                    AsmWrite(tostr(longint(hi(tai_const(hp).value))));
-                  end
-                else
-                  begin
-                    AsmWrite(tostr(longint(hi(tai_const(hp).value))));
-                    AsmWrite(',');
-                    AsmWrite(tostr(longint(lo(tai_const(hp).value))));
-                  end;
-                AsmLn;
-              end;
-
-           ait_const_uleb128bit,
-           ait_const_sleb128bit,
-           ait_const_32bit,
-           ait_const_16bit,
-           ait_const_8bit,
-           ait_const_rva_symbol,
-           ait_const_indirect_symbol :
-             begin
-               AsmWrite(ait_const2str[hp.typ]);
-               consttyp:=hp.typ;
-               l:=0;
-               repeat
-                 if assigned(tai_const(hp).sym) then
-                   begin
-                     if assigned(tai_const(hp).endsym) then
-                       begin
-                         if (tai_const(hp).endsym.typ = AT_FUNCTION) and use_PR then
-                           AsmWrite('.');
-
-                         s:=tai_const(hp).endsym.name;
-                         ReplaceForbiddenChars(s);
-                         AsmWrite(s);
-                         inc(l,length(s));
+                consttype:=tai_const(hp).consttype;
+                case consttype of
+                   aitconst_128bit:
+                      begin
+                        internalerror(200404291);
+                      end;
+                   aitconst_64bit:
+                      begin
+                        if assigned(tai_const(hp).sym) then
+                          internalerror(200404292);
+                        AsmWrite(ait_const2str[aitconst_32bit]);
+                        if target_info.endian = endian_little then
+                          begin
+                            AsmWrite(tostr(longint(lo(tai_const(hp).value))));
+                            AsmWrite(',');
+                            AsmWrite(tostr(longint(hi(tai_const(hp).value))));
+                          end
+                        else
+                          begin
+                            AsmWrite(tostr(longint(hi(tai_const(hp).value))));
+                            AsmWrite(',');
+                            AsmWrite(tostr(longint(lo(tai_const(hp).value))));
+                          end;
+                        AsmLn;
+                      end;
 
-                         if tai_const(hp).endsym.typ = AT_FUNCTION then
+                   aitconst_uleb128bit,
+                   aitconst_sleb128bit,
+                   aitconst_32bit,
+                   aitconst_16bit,
+                   aitconst_8bit,
+                   aitconst_rva_symbol,
+                   aitconst_indirect_symbol :
+                     begin
+                       AsmWrite(ait_const2str[consttype]);
+                       l:=0;
+                       repeat
+                         if assigned(tai_const(hp).sym) then
                            begin
-                             if use_PR then
-                               AsmWrite('[PR]')
+                             if assigned(tai_const(hp).endsym) then
+                               begin
+                                 if (tai_const(hp).endsym.typ = AT_FUNCTION) and use_PR then
+                                   AsmWrite('.');
+
+                                 s:=tai_const(hp).endsym.name;
+                                 ReplaceForbiddenChars(s);
+                                 AsmWrite(s);
+                                 inc(l,length(s));
+
+                                 if tai_const(hp).endsym.typ = AT_FUNCTION then
+                                   begin
+                                     if use_PR then
+                                       AsmWrite('[PR]')
+                                     else
+                                       AsmWrite('[DS]');
+                                   end;
+
+                                 AsmWrite('-');
+                                 inc(l,5); {Approx 5 extra, no need to be exactly}
+                               end;
+
+                             if (tai_const(hp).sym.typ = AT_FUNCTION) and use_PR then
+                               AsmWrite('.');
+
+                             s:= tai_const(hp).sym.name;
+                             ReplaceForbiddenChars(s);
+                             AsmWrite(s);
+                             inc(l,length(s));
+
+                             if tai_const(hp).sym.typ = AT_FUNCTION then
+                               begin
+                                 if use_PR then
+                                   AsmWrite('[PR]')
+                                 else
+                                   AsmWrite('[DS]');
+                               end;
+                             inc(l,5); {Approx 5 extra, no need to be exactly}
+
+                             if tai_const(hp).value > 0 then
+                               s:= '+'+tostr(tai_const(hp).value)
+                             else if tai_const(hp).value < 0 then
+                               s:= '-'+tostr(tai_const(hp).value)
                              else
-                               AsmWrite('[DS]');
-                           end;
-
-                         AsmWrite('-');
-                         inc(l,5); {Approx 5 extra, no need to be exactly}
-                       end;
-
-                     if (tai_const(hp).sym.typ = AT_FUNCTION) and use_PR then
-                       AsmWrite('.');
-
-                     s:= tai_const(hp).sym.name;
-                     ReplaceForbiddenChars(s);
-                     AsmWrite(s);
-                     inc(l,length(s));
-
-                     if tai_const(hp).sym.typ = AT_FUNCTION then
-                       begin
-                         if use_PR then
-                           AsmWrite('[PR]')
+                               s:= '';
+                             if s<>'' then
+                               begin
+                                 AsmWrite(s);
+                                 inc(l,length(s));
+                               end;
+                           end
                          else
-                           AsmWrite('[DS]');
-                       end;
-                     inc(l,5); {Approx 5 extra, no need to be exactly}
-
-                     if tai_const(hp).value > 0 then
-                       s:= '+'+tostr(tai_const(hp).value)
-                     else if tai_const(hp).value < 0 then
-                       s:= '-'+tostr(tai_const(hp).value)
-                     else
-                       s:= '';
-                     if s<>'' then
-                       begin
-                         AsmWrite(s);
-                         inc(l,length(s));
-                       end;
-                   end
-                 else
-                   begin
-                     s:= tostr(tai_const(hp).value);
-                     AsmWrite(s);
-                     inc(l,length(s));
-                   end;
+                           begin
+                             s:= tostr(tai_const(hp).value);
+                             AsmWrite(s);
+                             inc(l,length(s));
+                           end;
 
-                 if (l>line_length) or
-                    (hp.next=nil) or
-                    (tai(hp.next).typ<>consttyp) then
-                   break;
-                 hp:=tai(hp.next);
-                 AsmWrite(',');
-               until false;
-               AsmLn;
-             end;
+                         if (l>line_length) or
+                            (hp.next=nil) or
+                            (tai(hp.next).typ<>ait_const) or
+                            (tai_const(hp.next).consttype<>consttype) then
+                           break;
+                         hp:=tai(hp.next);
+                         AsmWrite(',');
+                       until false;
+                       AsmLn;
+                     end;
+                end;
+              end;
 
             ait_real_64bit :
               begin

+ 1 - 1
compiler/ppu.pas

@@ -43,7 +43,7 @@ type
 {$endif Test_Double_checksum}
 
 const
-  CurrentPPUVersion=52;
+  CurrentPPUVersion=53;
 
 { buffer sizes }
   maxentrysize = 1024;

+ 1 - 6
compiler/psystem.pas

@@ -498,12 +498,7 @@ implementation
         aiclass[ait_symbol_end]:=tai_symbol_end;
         aiclass[ait_directive]:=tai_directive;
         aiclass[ait_label]:=tai_label;
-        aiclass[ait_const_64bit]:=tai_const;
-        aiclass[ait_const_32bit]:=tai_const;
-        aiclass[ait_const_16bit]:=tai_const;
-        aiclass[ait_const_8bit]:=tai_const;
-        aiclass[ait_const_indirect_symbol]:=tai_const;
-        aiclass[ait_const_rva_symbol]:=tai_const;
+        aiclass[ait_const]:=tai_const;
         aiclass[ait_real_32bit]:=tai_real_32bit;
         aiclass[ait_real_64bit]:=tai_real_64bit;
         aiclass[ait_real_80bit]:=tai_real_80bit;

+ 3 - 3
compiler/symdef.pas

@@ -4699,7 +4699,7 @@ implementation
         begin
            if not(assigned(proc) and assigned(proc.firstsym))  then
              begin
-                asmlist[al_rtti].concat(Tai_const.create(ait_const_ptr,1));
+                asmlist[al_rtti].concat(Tai_const.create(aitconst_ptr,1));
                 typvalue:=3;
              end
            else if proc.firstsym^.sym.typ=fieldvarsym then
@@ -4732,7 +4732,7 @@ implementation
                      end;
                      hp:=hp^.next;
                   end;
-                asmlist[al_rtti].concat(Tai_const.create(ait_const_ptr,address));
+                asmlist[al_rtti].concat(Tai_const.create(aitconst_ptr,address));
                 typvalue:=0;
              end
            else
@@ -4748,7 +4748,7 @@ implementation
                 else
                   begin
                      { virtual method, write vmt offset }
-                     asmlist[al_rtti].concat(Tai_const.create(ait_const_ptr,
+                     asmlist[al_rtti].concat(Tai_const.create(aitconst_ptr,
                        tprocdef(proc.procdef)._class.vmtmethodoffset(tprocdef(proc.procdef).extnumber)));
                      typvalue:=2;
                   end;

+ 1 - 1
compiler/utils/ppudump.pp

@@ -27,7 +27,7 @@ uses
   ppu;
 
 const
-  Version   = 'Version 2.0.0';
+  Version   = 'Version 2.0.2';
   Title     = 'PPU-Analyser';
   Copyright = 'Copyright (c) 1998-2005 by the Free Pascal Development Team';
 

+ 42 - 38
compiler/x86/agx86int.pas

@@ -349,7 +349,7 @@ implementation
       lastinfile   : tinputfile;
 
     const
-      ait_const2str : array[ait_const_128bit..ait_const_indirect_symbol] of string[20]=(
+      ait_const2str : array[aitconst_128bit..aitconst_indirect_symbol] of string[20]=(
         #9''#9,#9'DQ'#9,#9'DD'#9,#9'DW'#9,#9'DB'#9,
         #9'FIXMESLEB',#9'FIXEMEULEB',
         #9'DD RVA'#9,#9'FIXMEINDIRECT'#9
@@ -388,7 +388,7 @@ implementation
       lines,
       InlineLevel : longint;
       i,j,l    : longint;
-      consttyp : taitype;
+      consttype : taiconst_type;
       do_line,DoNotSplitLine,
       quoted   : boolean;
     begin
@@ -516,40 +516,46 @@ implementation
                  AsmWriteLn(#9'PUBLIC'#9+tai_datablock(hp).sym.name);
                AsmWriteLn(PadTabs(tai_datablock(hp).sym.name,#0)+'DB'#9+tostr(tai_datablock(hp).size)+' DUP(?)');
              end;
-           ait_const_uleb128bit,
-           ait_const_sleb128bit,
-           ait_const_128bit,
-           ait_const_64bit,
-           ait_const_32bit,
-           ait_const_16bit,
-           ait_const_8bit,
-           ait_const_rva_symbol,
-           ait_const_indirect_symbol :
+           ait_const:
              begin
-               AsmWrite(ait_const2str[hp.typ]);
-               consttyp:=hp.typ;
-               l:=0;
-               repeat
-                 if assigned(tai_const(hp).sym) then
+               consttype:=tai_const(hp).consttype;
+               case consttype of
+                 aitconst_uleb128bit,
+                 aitconst_sleb128bit,
+                 aitconst_128bit,
+                 aitconst_64bit,
+                 aitconst_32bit,
+                 aitconst_16bit,
+                 aitconst_8bit,
+                 aitconst_rva_symbol,
+                 aitconst_indirect_symbol :
                    begin
-                     if assigned(tai_const(hp).endsym) then
-                       s:=tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name
-                     else
-                       s:=tai_const(hp).sym.name;
-                     if tai_const(hp).value<>0 then
-                       s:=s+tostr_with_plus(tai_const(hp).value);
-                   end
-                 else
-                   s:=tostr(tai_const(hp).value);
-                 AsmWrite(s);
-                 if (l>line_length) or
-                    (hp.next=nil) or
-                    (tai(hp.next).typ<>consttyp) then
-                   break;
-                 hp:=tai(hp.next);
-                 AsmWrite(',');
-               until false;
-               AsmLn;
+                     AsmWrite(ait_const2str[consttype]);
+                     l:=0;
+                     repeat
+                       if assigned(tai_const(hp).sym) then
+                         begin
+                           if assigned(tai_const(hp).endsym) then
+                             s:=tai_const(hp).endsym.name+'-'+tai_const(hp).sym.name
+                           else
+                             s:=tai_const(hp).sym.name;
+                           if tai_const(hp).value<>0 then
+                             s:=s+tostr_with_plus(tai_const(hp).value);
+                         end
+                       else
+                         s:=tostr(tai_const(hp).value);
+                       AsmWrite(s);
+                       if (l>line_length) or
+                          (hp.next=nil) or
+                          (tai(hp.next).typ<>ait_const) or
+                          (tai_const(hp.next).consttype<>consttype) then
+                         break;
+                       hp:=tai(hp.next);
+                       AsmWrite(',');
+                     until false;
+                     AsmLn;
+                   end;
+               end;
              end;
 
            ait_real_32bit :
@@ -642,8 +648,7 @@ implementation
                 begin
                   AsmWrite(tai_label(hp).l.name);
                   if assigned(hp.next) and not(tai(hp.next).typ in
-                     [ait_const_32bit,ait_const_16bit,ait_const_8bit,
-                      ait_const_rva_symbol,
+                     [ait_const,
                       ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_string]) then
                    AsmWriteLn(':')
                   else
@@ -656,8 +661,7 @@ implementation
                  AsmWriteLn(#9'PUBLIC'#9+tai_symbol(hp).sym.name);
                AsmWrite(tai_symbol(hp).sym.name);
                if assigned(hp.next) and not(tai(hp.next).typ in
-                  [ait_const_32bit,ait_const_16bit,ait_const_8bit,
-                   ait_const_rva_symbol,
+                  [ait_const,
                    ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_string]) then
                 AsmWriteLn(':')
              end;