Browse Source

* dwarf branch merged

florian 21 years ago
parent
commit
588e2c38bf
100 changed files with 5886 additions and 3446 deletions
  1. 275 198
      compiler/aasmbase.pas
  2. 358 129
      compiler/aasmtai.pas
  3. 219 91
      compiler/aggas.pas
  4. 1 1
      compiler/alpha/cpuinfo.pas
  5. 33 11
      compiler/arm/aasmcpu.pas
  6. 8 9
      compiler/arm/agarmgas.pas
  7. 81 77
      compiler/arm/armreg.dat
  8. 33 34
      compiler/arm/cgcpu.pas
  9. 36 2
      compiler/arm/cpubase.pas
  10. 9 19
      compiler/arm/cpuinfo.pas
  11. 11 5
      compiler/arm/cpupara.pas
  12. 13 55
      compiler/arm/cpupi.pas
  13. 74 0
      compiler/arm/rarmdwa.inc
  14. 68 48
      compiler/arm/rgcpu.pas
  15. 189 185
      compiler/assemble.pas
  16. 17 11
      compiler/browcol.pas
  17. 38 25
      compiler/cclasses.pas
  18. 69 43
      compiler/cg64f32.pas
  19. 81 24
      compiler/cg64f64.pas
  20. 14 3
      compiler/cgbase.pas
  21. 243 147
      compiler/cgobj.pas
  22. 11 5
      compiler/cmsgs.pas
  23. 27 14
      compiler/cresstr.pas
  24. 17 4
      compiler/cstreams.pas
  25. 41 26
      compiler/cutils.pas
  26. 25 16
      compiler/defutil.pas
  27. 447 0
      compiler/dwarf.pas
  28. 8 2
      compiler/finput.pas
  29. 23 4
      compiler/fpcdefs.inc
  30. 9 3
      compiler/gendef.pas
  31. 39 28
      compiler/globals.pas
  32. 42 3
      compiler/globtype.pas
  33. 38 9
      compiler/htypechk.pas
  34. 96 80
      compiler/i386/ag386int.pas
  35. 107 98
      compiler/i386/ag386nsm.pas
  36. 244 49
      compiler/i386/cgcpu.pas
  37. 9 1
      compiler/i386/cpubase.inc
  38. 13 17
      compiler/i386/cpuinfo.pas
  39. 45 28
      compiler/i386/cpupara.pas
  40. 13 3
      compiler/i386/csopt386.pas
  41. 9 3
      compiler/i386/n386add.pas
  42. 8 63
      compiler/i386/n386cal.pas
  43. 15 4
      compiler/i386/n386mem.pas
  44. 14 3
      compiler/i386/n386obj.pas
  45. 39 19
      compiler/i386/n386set.pas
  46. 10 4
      compiler/i386/popt386.pas
  47. 13 12
      compiler/i386/r386ari.inc
  48. 1 0
      compiler/i386/r386att.inc
  49. 1 0
      compiler/i386/r386con.inc
  50. 73 0
      compiler/i386/r386dwrf.inc
  51. 1 0
      compiler/i386/r386int.inc
  52. 14 13
      compiler/i386/r386iri.inc
  53. 1 0
      compiler/i386/r386nasm.inc
  54. 1 1
      compiler/i386/r386nor.inc
  55. 14 13
      compiler/i386/r386nri.inc
  56. 1 0
      compiler/i386/r386num.inc
  57. 1 0
      compiler/i386/r386op.inc
  58. 1 0
      compiler/i386/r386ot.inc
  59. 3 2
      compiler/i386/r386rni.inc
  60. 14 13
      compiler/i386/r386sri.inc
  61. 1 0
      compiler/i386/r386stab.inc
  62. 1 0
      compiler/i386/r386std.inc
  63. 44 33
      compiler/i386/ra386int.pas
  64. 9 2
      compiler/ia64/cpubase.pas
  65. 72 4
      compiler/m68k/agcpugas.pas
  66. 13 3
      compiler/m68k/cpubase.pas
  67. 8 17
      compiler/m68k/cpuinfo.pas
  68. 45 42
      compiler/msg/errore.msg
  69. 14 14
      compiler/msgidx.inc
  70. 188 185
      compiler/msgtxt.inc
  71. 84 12
      compiler/nadd.pas
  72. 11 4
      compiler/nbas.pas
  73. 35 10
      compiler/ncal.pas
  74. 74 9
      compiler/ncgadd.pas
  75. 29 11
      compiler/ncgbas.pas
  76. 141 149
      compiler/ncgcal.pas
  77. 10 4
      compiler/ncgcnv.pas
  78. 66 34
      compiler/ncgcon.pas
  79. 20 10
      compiler/ncgflw.pas
  80. 69 46
      compiler/ncginl.pas
  81. 52 16
      compiler/ncgld.pas
  82. 38 67
      compiler/ncgmat.pas
  83. 29 10
      compiler/ncgmem.pas
  84. 107 102
      compiler/ncgset.pas
  85. 222 240
      compiler/ncgutil.pas
  86. 59 16
      compiler/ncnv.pas
  87. 18 3
      compiler/ncon.pas
  88. 11 4
      compiler/nflw.pas
  89. 102 30
      compiler/ninl.pas
  90. 10 3
      compiler/nld.pas
  91. 14 14
      compiler/nmat.pas
  92. 14 7
      compiler/nmem.pas
  93. 97 73
      compiler/nobj.pas
  94. 15 2
      compiler/node.pas
  95. 15 4
      compiler/nset.pas
  96. 14 7
      compiler/nutils.pas
  97. 63 100
      compiler/ogbase.pas
  98. 412 283
      compiler/ogcoff.pas
  99. 288 211
      compiler/ogelf.pas
  100. 14 8
      compiler/ogmap.pas

+ 275 - 198
compiler/aasmbase.pas

@@ -34,49 +34,65 @@ interface
 
 
     uses
     uses
        cutils,cclasses,
        cutils,cclasses,
-       globtype,globals,systems;
+       globtype,globals,systems,
+       cpuinfo;
 
 
-  { asm symbol functions }
     type
     type
+       TAsmSection = class;
+       TAsmObjectData = class;
+
        TAsmsymbind=(AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL);
        TAsmsymbind=(AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL);
 
 
        TAsmsymtype=(AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION);
        TAsmsymtype=(AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION);
 
 
        TAsmRelocationType = (RELOC_ABSOLUTE,RELOC_RELATIVE,RELOC_RVA);
        TAsmRelocationType = (RELOC_ABSOLUTE,RELOC_RELATIVE,RELOC_RVA);
 
 
-       TAsmSectionSizes = array[TSection] of longint;
+       TAsmSectionType=(sec_none,
+         sec_code,sec_data,sec_rodata,sec_bss,
+         sec_common, { used for executable creation }
+         sec_custom, { custom section, no prefix }
+         { stabs }
+         sec_stab,sec_stabstr,
+         { win32 }
+         sec_idata2,sec_idata4,sec_idata5,sec_idata6,sec_idata7,sec_edata,
+         { C++ exception handling unwinding (uses dwarf) }
+         sec_eh_frame,
+         { dwarf }
+         sec_debug_frame
+       );
+
+       TAsmSectionOption = (aso_alloconly,aso_executable);
+       TAsmSectionOptions = set of TAsmSectionOption;
 
 
        TAsmSymbol = class(TNamedIndexItem)
        TAsmSymbol = class(TNamedIndexItem)
        private
        private
          { this need to be incremented with every symbol loading into the
          { this need to be incremented with every symbol loading into the
            paasmoutput, thus in loadsym/loadref/const_symbol (PFV) }
            paasmoutput, thus in loadsym/loadref/const_symbol (PFV) }
-         refs    : longint;
+         refs       : longint;
        public
        public
          defbind,
          defbind,
-         currbind  : TAsmsymbind;
-         typ       : TAsmsymtype;
+         currbind   : TAsmsymbind;
+         typ        : TAsmsymtype;
          { the next fields are filled in the binary writer }
          { the next fields are filled in the binary writer }
-         section : TSection;
+         section    : TAsmSection;
          address,
          address,
-         size    : longint;
+         size       : aint;
          { Alternate symbol which can be used for 'renaming' needed for
          { Alternate symbol which can be used for 'renaming' needed for
            inlining }
            inlining }
-         altsymbol : tasmsymbol;
+         altsymbol  : tasmsymbol;
          { pointer to objectdata that is the owner of this symbol }
          { pointer to objectdata that is the owner of this symbol }
-         objectdata : pointer;
-         { pointer to the tai that is the owner of this symbol }
-{         taiowner : pointer;}
+         owner      : tasmobjectdata;
          { Is the symbol in the used list }
          { Is the symbol in the used list }
          inusedlist : boolean;
          inusedlist : boolean;
          { assembler pass label is set, used for detecting multiple labels }
          { assembler pass label is set, used for detecting multiple labels }
-         pass : byte;
-         ppuidx : longint;
+         pass       : byte;
+         ppuidx     : longint;
          constructor create(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype);
          constructor create(const s:string;_bind:TAsmsymbind;_typ:Tasmsymtype);
          procedure reset;
          procedure reset;
          function  is_used:boolean;
          function  is_used:boolean;
          procedure increfs;
          procedure increfs;
          procedure decrefs;
          procedure decrefs;
-         procedure setaddress(_pass:byte;sec:TSection;offset,len:longint);
+         procedure setaddress(_pass:byte;sec:TAsmSection;offset,len:aint);
        end;
        end;
 
 
        TAsmLabel = class(TAsmSymbol)
        TAsmLabel = class(TAsmSymbol)
@@ -94,77 +110,92 @@ interface
 
 
        TAsmRelocation = class(TLinkedListItem)
        TAsmRelocation = class(TLinkedListItem)
           address,
           address,
-          orgsize  : longint;  { original size of the symbol to relocate, required for COFF }
-          symbol   : tasmsymbol;
-          section  : TSection; { only used if symbol=nil }
+          orgsize  : aint;  { original size of the symbol to relocate, required for COFF }
+          symbol   : TAsmSymbol;
+          section  : TAsmSection; { only used if symbol=nil }
           typ      : TAsmRelocationType;
           typ      : TAsmRelocationType;
-          constructor CreateSymbol(Aaddress:longint;s:Tasmsymbol;Atyp:TAsmRelocationType);
-          constructor CreateSymbolSize(Aaddress:longint;s:Tasmsymbol;Aorgsize:longint;Atyp:TAsmRelocationType);
-          constructor CreateSection(Aaddress:longint;sec:TSection;Atyp:TAsmRelocationType);
+          constructor CreateSymbol(Aaddress:aint;s:Tasmsymbol;Atyp:TAsmRelocationType);
+          constructor CreateSymbolSize(Aaddress:aint;s:Tasmsymbol;Aorgsize:aint;Atyp:TAsmRelocationType);
+          constructor CreateSection(Aaddress:aint;sec:TAsmSection;Atyp:TAsmRelocationType);
        end;
        end;
 
 
-       TAsmSection = class(TLinkedListItem)
-         name      : string[32];
-         secsymidx : longint;   { index for the section in symtab }
-         addralign : longint;   { alignment of the section }
-         flags     : cardinal;  { section flags }
+       TAsmSection = class(TNamedIndexItem)
+         owner      : TAsmObjectData;
+         secoptions : TAsmSectionOptions;
+         sectype    : TAsmSectionType;
+         secsymidx  : longint;   { index for the section in symtab }
+         addralign  : longint;   { alignment of the section }
          { size of the data and in the file }
          { size of the data and in the file }
          dataalignbytes : longint;
          dataalignbytes : longint;
          data      : TDynamicArray;
          data      : TDynamicArray;
-         datasize  : longint;
-         datapos   : longint;
-         { size and position in memory, set by seTSectionsize }
+         datasize,
+         datapos   : aint;
+         { size and position in memory }
          memsize,
          memsize,
-         mempos    : longint;
+         mempos    : aint;
          { relocation }
          { relocation }
          relocations : TLinkedList;
          relocations : TLinkedList;
-         constructor create(const Aname:string;Aalign:longint;alloconly:boolean);
+         constructor create(const Aname:string;Atype:TAsmSectionType;Aalign:longint;Aoptions:TAsmSectionOptions);virtual;
          destructor  destroy;override;
          destructor  destroy;override;
-         function  write(var d;l:longint):longint;
-         function  writestr(const s:string):longint;
+         function  write(const d;l:aint):aint;
+         function  writestr(const s:string):aint;
          procedure writealign(l:longint);
          procedure writealign(l:longint);
-         function  aligneddatasize:longint;
+         function  aligneddatasize:aint;
+         procedure setdatapos(var dpos:aint);
          procedure alignsection;
          procedure alignsection;
-         procedure alloc(l:longint);
-         procedure addsymreloc(ofs:longint;p:tasmsymbol;relative:TAsmRelocationType);
-         procedure addsectionreloc(ofs:longint;sec:TSection;relative:TAsmRelocationType);
-       end;
-
-       TAsmObjectAlloc = class
-         currsec : TSection;
-         secsize : TAsmSectionSizes;
-         constructor create;
-         destructor  destroy;override;
-         procedure seTSection(sec:TSection);
-         function  sectionsize:longint;
-         procedure sectionalloc(l:longint);
-         procedure sectionalign(l:longint);
-         procedure staballoc(p:pchar);
-         procedure resetSections;
+         procedure alloc(l:aint);
+         procedure addsymreloc(ofs:aint;p:tasmsymbol;relative:TAsmRelocationType);
+         procedure addsectionreloc(ofs:aint;sec:TAsmSection;relative:TAsmRelocationType);
+         procedure fixuprelocs;virtual;
        end;
        end;
+       TAsmSectionClass = class of TAsmSection;
 
 
        TAsmObjectData = class(TLinkedListItem)
        TAsmObjectData = class(TLinkedListItem)
+       private
+         FName      : string[80];
+         FCurrSec   : TAsmSection;
+         FSects     : TDictionary;
+         FCAsmSection : TAsmSectionClass;
+         { Symbols that will be defined in this object file }
+         FSymbols   : TIndexArray;
+         { Special info sections that are written to during object generation }
+         FStabsRecSize : longint;
+         FStabsSec,
+         FStabStrSec : TAsmSection;
+         procedure section_reset(p:tnamedindexitem;arg:pointer);
+         procedure section_fixuprelocs(p:tnamedindexitem;arg:pointer);
+       protected
+         property StabsRecSize:longint read FStabsRecSize write FStabsRecSize;
+         property StabsSec:TAsmSection read FStabsSec write FStabsSec;
+         property StabStrSec:TAsmSection read FStabStrSec write FStabStrSec;
+         property CAsmSection:TAsmSectionClass read FCAsmSection write FCAsmSection;
        public
        public
-         name      : string[80];
-         currsec   : TSection;
-         sects     : array[TSection] of TAsmSection;
-         symbols   : tindexarray; { contains symbols that will be defined in object file }
-         constructor create(const n:string);
+         constructor create(const n:string);virtual;
          destructor  destroy;override;
          destructor  destroy;override;
-         procedure createsection(sec:TSection);virtual;
-         procedure defaulTSection(sec:TSection);
-         function  sectionsize(s:TSection):longint;
-         function  currsectionsize:longint;
-         procedure setsectionsizes(var s:TAsmSectionSizes);virtual;
-         procedure alloc(len:longint);
+         function  sectionname(atype:tasmsectiontype;const aname:string):string;virtual;
+         function  createsection(atype:tasmsectiontype;const aname:string;aalign:longint;aoptions:TAsmSectionOptions):tasmsection;virtual;
+         procedure setsection(asec:tasmsection);
+         procedure alloc(len:aint);
          procedure allocalign(len:longint);
          procedure allocalign(len:longint);
-         procedure writebytes(var data;len:longint);
-         procedure writereloc(data,len:longint;p:tasmsymbol;relative:TAsmRelocationType);virtual;abstract;
+         procedure allocstabs(p:pchar);
+         procedure allocsymbol(currpass:byte;p:tasmsymbol;len:aint);
+         procedure writebytes(var data;len:aint);
+         procedure writereloc(data,len:aint;p:tasmsymbol;relative:TAsmRelocationType);virtual;abstract;
          procedure writesymbol(p:tasmsymbol);virtual;abstract;
          procedure writesymbol(p:tasmsymbol);virtual;abstract;
-         procedure writestabs(section:TSection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);virtual;abstract;
-         procedure writesymstabs(section:TSection;offset:longint;p:pchar;ps:tasmsymbol;nidx,nother,line:longint;reloc:boolean);virtual;abstract;
-         procedure fixuprelocs;virtual;
+         procedure writestabs(offset:aint;p:pchar;nidx,nother,line:longint;reloc:boolean);virtual;abstract;
+         procedure writesymstabs(offset:aint;p:pchar;ps:tasmsymbol;nidx,nother,line:longint;reloc:boolean);virtual;abstract;
+         procedure beforealloc;virtual;
+         procedure beforewrite;virtual;
+         procedure afteralloc;virtual;
+         procedure afterwrite;virtual;
+         procedure resetsections;
+         procedure fixuprelocs;
+         property Name:string[80] read FName;
+         property CurrSec:TAsmSection read FCurrSec;
+         property Symbols:TindexArray read FSymbols;
+         property Sects:TDictionary read FSects;
        end;
        end;
+       TAsmObjectDataClass = class of TAsmObjectData;
 
 
 {$ifndef delphi}
 {$ifndef delphi}
        tasmsymbolidxarr = array[0..($7fffffff div sizeof(pointer))] of tasmsymbol;
        tasmsymbolidxarr = array[0..($7fffffff div sizeof(pointer))] of tasmsymbol;
@@ -253,7 +284,7 @@ implementation
     procedure tasmsymbol.reset;
     procedure tasmsymbol.reset;
       begin
       begin
         { reset section info }
         { reset section info }
-        section:=sec_none;
+        section:=nil;
         address:=0;
         address:=0;
         size:=0;
         size:=0;
         indexnr:=-1;
         indexnr:=-1;
@@ -284,7 +315,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tasmsymbol.setaddress(_pass:byte;sec:TSection;offset,len:longint);
+    procedure tasmsymbol.setaddress(_pass:byte;sec:TAsmSection;offset,len:aint);
       begin
       begin
         if (_pass=pass) then
         if (_pass=pass) then
          begin
          begin
@@ -318,20 +349,17 @@ implementation
     constructor tasmlabel.createdata(const modulename:string;nr:longint);
     constructor tasmlabel.createdata(const modulename:string;nr:longint);
       begin;
       begin;
         labelnr:=nr;
         labelnr:=nr;
-        if (cs_create_smart in aktmoduleswitches) or
-           target_asm.labelprefix_only_inside_procedure then
-          inherited create('_$'+modulename+'$_L'+tostr(labelnr),AB_GLOBAL,AT_DATA)
-        else
-          inherited create(target_asm.labelprefix+tostr(labelnr),AB_LOCAL,AT_DATA);
+        inherited create('_$'+modulename+'$_L'+tostr(labelnr),AB_GLOBAL,AT_DATA);
         is_set:=false;
         is_set:=false;
         is_addr := false;
         is_addr := false;
         { write it always }
         { write it always }
         increfs;
         increfs;
       end;
       end;
 
 
+
     constructor tasmlabel.createaddr(nr:longint);
     constructor tasmlabel.createaddr(nr:longint);
       begin;
       begin;
-        create(nr);
+        self.create(nr);
         is_addr := true;
         is_addr := true;
       end;
       end;
 
 
@@ -343,84 +371,31 @@ implementation
       end;
       end;
 
 
 
 
-{****************************************************************************
-                                TAsmObjectAlloc
-****************************************************************************}
-
-    constructor TAsmObjectAlloc.create;
-      begin
-      end;
-
-
-    destructor TAsmObjectAlloc.destroy;
-      begin
-      end;
-
-
-    procedure TAsmObjectAlloc.seTSection(sec:TSection);
-      begin
-        currsec:=sec;
-      end;
-
-
-    procedure TAsmObjectAlloc.reseTSections;
-      begin
-        FillChar(secsize,sizeof(secsize),0);
-      end;
-
-
-    procedure TAsmObjectAlloc.sectionalloc(l:longint);
-      begin
-        inc(secsize[currsec],l);
-      end;
-
-
-    procedure TAsmObjectAlloc.sectionalign(l:longint);
-      begin
-        if (secsize[currsec] mod l)<>0 then
-          inc(secsize[currsec],l-(secsize[currsec] mod l));
-      end;
-
-
-    procedure TAsmObjectAlloc.staballoc(p:pchar);
-      begin
-        inc(secsize[sec_stab]);
-        if assigned(p) and (p[0]<>#0) then
-          inc(secsize[sec_stabstr],strlen(p)+1);
-      end;
-
-
-    function TAsmObjectAlloc.sectionsize:longint;
-      begin
-        sectionsize:=secsize[currsec];
-      end;
-
-
 {****************************************************************************
 {****************************************************************************
                               TAsmRelocation
                               TAsmRelocation
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor TAsmRelocation.CreateSymbol(Aaddress:longint;s:Tasmsymbol;Atyp:TAsmRelocationType);
+    constructor TAsmRelocation.CreateSymbol(Aaddress:aint;s:Tasmsymbol;Atyp:TAsmRelocationType);
       begin
       begin
         Address:=Aaddress;
         Address:=Aaddress;
         Symbol:=s;
         Symbol:=s;
         OrgSize:=0;
         OrgSize:=0;
-        Section:=Sec_none;
+        Section:=nil;
         Typ:=Atyp;
         Typ:=Atyp;
       end;
       end;
 
 
 
 
-    constructor TAsmRelocation.CreateSymbolSize(Aaddress:longint;s:Tasmsymbol;Aorgsize:longint;Atyp:TAsmRelocationType);
+    constructor TAsmRelocation.CreateSymbolSize(Aaddress:aint;s:Tasmsymbol;Aorgsize:aint;Atyp:TAsmRelocationType);
       begin
       begin
         Address:=Aaddress;
         Address:=Aaddress;
         Symbol:=s;
         Symbol:=s;
         OrgSize:=Aorgsize;
         OrgSize:=Aorgsize;
-        Section:=Sec_none;
+        Section:=nil;
         Typ:=Atyp;
         Typ:=Atyp;
       end;
       end;
 
 
 
 
-    constructor TAsmRelocation.CreateSection(Aaddress:longint;sec:TSection;Atyp:TAsmRelocationType);
+    constructor TAsmRelocation.CreateSection(Aaddress:aint;sec:TAsmSection;Atyp:TAsmRelocationType);
       begin
       begin
         Address:=Aaddress;
         Address:=Aaddress;
         Symbol:=nil;
         Symbol:=nil;
@@ -434,20 +409,22 @@ implementation
                               TAsmSection
                               TAsmSection
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor TAsmSection.create(const Aname:string;Aalign:longint;alloconly:boolean);
+    constructor TAsmSection.create(const Aname:string;Atype:TAsmSectionType;Aalign:longint;Aoptions:TAsmSectionOptions);
       begin
       begin
-        inherited create;
+        inherited createname(Aname);
+        sectype:=Atype;
         name:=Aname;
         name:=Aname;
+        secoptions:=Aoptions;
         secsymidx:=0;
         secsymidx:=0;
         addralign:=Aalign;
         addralign:=Aalign;
         { data }
         { data }
         datasize:=0;
         datasize:=0;
         datapos:=0;
         datapos:=0;
-        if alloconly then
+        if (aso_alloconly in aoptions) then
          data:=nil
          data:=nil
         else
         else
          Data:=TDynamicArray.Create(8192);
          Data:=TDynamicArray.Create(8192);
-        { position }
+        { memory }
         mempos:=0;
         mempos:=0;
         memsize:=0;
         memsize:=0;
         { relocation }
         { relocation }
@@ -463,22 +440,20 @@ implementation
       end;
       end;
 
 
 
 
-    function TAsmSection.write(var d;l:longint):longint;
+    function TAsmSection.write(const d;l:aint):aint;
       begin
       begin
         write:=datasize;
         write:=datasize;
-        if not assigned(Data) then
-         Internalerror(3334441);
-        Data.write(d,l);
+        if assigned(Data) then
+          Data.write(d,l);
         inc(datasize,l);
         inc(datasize,l);
       end;
       end;
 
 
 
 
-    function TAsmSection.writestr(const s:string):longint;
+    function TAsmSection.writestr(const s:string):aint;
       begin
       begin
         writestr:=datasize;
         writestr:=datasize;
-        if not assigned(Data) then
-         Internalerror(3334441);
-        Data.write(s[1],length(s));
+        if assigned(Data) then
+          Data.write(s[1],length(s));
         inc(datasize,length(s));
         inc(datasize,length(s));
       end;
       end;
 
 
@@ -504,27 +479,38 @@ implementation
       end;
       end;
 
 
 
 
-    function TAsmSection.aligneddatasize:longint;
+    function TAsmSection.aligneddatasize:aint;
       begin
       begin
         aligneddatasize:=align(datasize,addralign);
         aligneddatasize:=align(datasize,addralign);
       end;
       end;
 
 
 
 
+    procedure TAsmSection.setdatapos(var dpos:aint);
+      var
+        alignedpos : aint;
+      begin
+        { get aligned datapos }
+        alignedpos:=align(dpos,addralign);
+        dataalignbytes:=alignedpos-dpos;
+        datapos:=alignedpos;
+        { update datapos }
+        dpos:=datapos+aligneddatasize;
+      end;
+
+
     procedure TAsmSection.alignsection;
     procedure TAsmSection.alignsection;
       begin
       begin
         writealign(addralign);
         writealign(addralign);
       end;
       end;
 
 
 
 
-    procedure TAsmSection.alloc(l:longint);
+    procedure TAsmSection.alloc(l:aint);
       begin
       begin
-        if assigned(Data) then
-         Internalerror(3334442);
         inc(datasize,l);
         inc(datasize,l);
       end;
       end;
 
 
 
 
-    procedure TAsmSection.addsymreloc(ofs:longint;p:tasmsymbol;relative:TAsmRelocationType);
+    procedure TAsmSection.addsymreloc(ofs:aint;p:tasmsymbol;relative:TAsmRelocationType);
       var
       var
         r : TAsmRelocation;
         r : TAsmRelocation;
       begin
       begin
@@ -532,13 +518,13 @@ implementation
         r.address:=ofs;
         r.address:=ofs;
         r.orgsize:=0;
         r.orgsize:=0;
         r.symbol:=p;
         r.symbol:=p;
-        r.section:=sec_none;
+        r.section:=nil;
         r.typ:=relative;
         r.typ:=relative;
         relocations.concat(r);
         relocations.concat(r);
       end;
       end;
 
 
 
 
-    procedure TAsmSection.addsectionreloc(ofs:longint;sec:TSection;relative:TAsmRelocationType);
+    procedure TAsmSection.addsectionreloc(ofs:aint;sec:TAsmSection;relative:TAsmRelocationType);
       var
       var
         r : TAsmRelocation;
         r : TAsmRelocation;
       begin
       begin
@@ -552,6 +538,11 @@ implementation
       end;
       end;
 
 
 
 
+    procedure TAsmSection.fixuprelocs;
+      begin
+      end;
+
+
 {****************************************************************************
 {****************************************************************************
                                 TAsmObjectData
                                 TAsmObjectData
 ****************************************************************************}
 ****************************************************************************}
@@ -559,93 +550,162 @@ implementation
     constructor TAsmObjectData.create(const n:string);
     constructor TAsmObjectData.create(const n:string);
       begin
       begin
         inherited create;
         inherited create;
-        name:=n;
+        FName:=n;
         { sections }
         { sections }
-        FillChar(Sects,sizeof(Sects),0);
+        FSects:=tdictionary.create;
+        FStabsRecSize:=1;
+        FStabsSec:=nil;
+        FStabStrSec:=nil;
         { symbols }
         { symbols }
-        symbols:=tindexarray.create(symbolsgrow);
-        symbols.noclear:=true;
+        FSymbols:=tindexarray.create(symbolsgrow);
+        FSymbols.noclear:=true;
+        { section class type for creating of new sections }
+        FCAsmSection:=TAsmSection;
       end;
       end;
 
 
 
 
     destructor TAsmObjectData.destroy;
     destructor TAsmObjectData.destroy;
+      begin
+        FSects.free;
+        FSymbols.free;
+      end;
+
+
+    function TAsmObjectData.sectionname(atype:tasmsectiontype;const aname:string):string;
+      const
+        secnames : array[tasmsectiontype] of string[12] = ('',
+          'code','data','rodata','bss',
+          'common',
+          'note',
+          'stab','stabstr',
+          'idata2','idata4','idata5','idata6','idata7','edata',
+          'eh_frame',
+          'debug_frame'
+        );
+      begin
+        if aname<>'' then
+          result:=secnames[atype]+'.'+aname
+        else
+          result:=secnames[atype];
+      end;
+
+
+    function TAsmObjectData.createsection(atype:tasmsectiontype;const aname:string;aalign:longint;aoptions:TAsmSectionOptions):TAsmSection;
       var
       var
-        sec : TSection;
+        secname : string;
       begin
       begin
-        { free memory }
-        for sec:=low(TSection) to high(TSection) do
-         if assigned(sects[sec]) then
-          sects[sec].free;
-        symbols.free;
+        secname:=sectionname(atype,aname);
+        result:=TasmSection(FSects.search(secname));
+        if not assigned(result) then
+          begin
+{$warning TODO make alloconly configurable}
+            if atype=sec_bss then
+              include(aoptions,aso_alloconly);
+            result:=CAsmSection.create(secname,atype,aalign,aoptions);
+            FSects.Insert(result);
+            result.owner:=self;
+          end;
+        FCurrSec:=result;
       end;
       end;
 
 
 
 
-    procedure TAsmObjectData.createsection(sec:TSection);
+    procedure TAsmObjectData.setsection(asec:tasmsection);
       begin
       begin
-        sects[sec]:=TAsmSection.create(target_asm.secnames[sec],1,(sec=sec_bss));
+        if asec.owner<>self then
+          internalerror(200403041);
+        FCurrSec:=asec;
       end;
       end;
 
 
 
 
-    function TAsmObjectData.sectionsize(s:TSection):longint;
+    procedure TAsmObjectData.writebytes(var data;len:aint);
       begin
       begin
-        if assigned(sects[s]) then
-         sectionsize:=sects[s].datasize
-        else
-         sectionsize:=0;
+        if not assigned(currsec) then
+          internalerror(200402251);
+        currsec.write(data,len);
       end;
       end;
 
 
 
 
-    function TAsmObjectData.currsectionsize:longint;
+    procedure TAsmObjectData.alloc(len:aint);
       begin
       begin
-        if assigned(sects[currsec]) then
-         currsectionsize:=sects[currsec].datasize
-        else
-         currsectionsize:=0;
+        if not assigned(currsec) then
+          internalerror(200402252);
+        currsec.alloc(len);
       end;
       end;
 
 
 
 
-    procedure TAsmObjectData.seTSectionsizes(var s:TAsmSectionSizes);
+    procedure TAsmObjectData.allocalign(len:longint);
+      var
+        modulo : aint;
       begin
       begin
+        if not assigned(currsec) then
+          internalerror(200402253);
+        modulo:=currsec.datasize mod len;
+        if modulo > 0 then
+          currsec.alloc(len-modulo);
       end;
       end;
 
 
 
 
-    procedure TAsmObjectData.defaulTSection(sec:TSection);
+    procedure TAsmObjectData.allocsymbol(currpass:byte;p:tasmsymbol;len:aint);
       begin
       begin
-        currsec:=sec;
+        p.setaddress(currpass,currsec,currsec.datasize,len);
       end;
       end;
 
 
 
 
-    procedure TAsmObjectData.writebytes(var data;len:longint);
+    procedure TAsmObjectData.allocstabs(p:pchar);
       begin
       begin
-        if not assigned(sects[currsec]) then
-         createsection(currsec);
-        sects[currsec].write(data,len);
+        if not(assigned(FStabsSec) and assigned(FStabStrSec)) then
+          internalerror(200402254);
+        FStabsSec.alloc(FStabsRecSize);
+        if assigned(p) and (p[0]<>#0) then
+          FStabStrSec.alloc(strlen(p)+1);
       end;
       end;
 
 
 
 
-    procedure TAsmObjectData.alloc(len:longint);
+    procedure TAsmObjectData.section_reset(p:tnamedindexitem;arg:pointer);
       begin
       begin
-        if not assigned(sects[currsec]) then
-         createsection(currsec);
-        sects[currsec].alloc(len);
+        with tasmsection(p) do
+          begin
+            datasize:=0;
+            datapos:=0;
+          end;
       end;
       end;
 
 
 
 
-    procedure TAsmObjectData.allocalign(len:longint);
-      var
-        modulo : longint;
+    procedure TAsmObjectData.section_fixuprelocs(p:tnamedindexitem;arg:pointer);
       begin
       begin
-        if not assigned(sects[currsec]) then
-         createsection(currsec);
-        modulo:=sects[currsec].datasize mod len;
-        if modulo > 0 then
-          sects[currsec].alloc(len-modulo);
+        tasmsection(p).fixuprelocs;
+      end;
+
+
+    procedure TAsmObjectData.beforealloc;
+      begin
+      end;
+
+
+    procedure TAsmObjectData.beforewrite;
+      begin
+      end;
+
+
+    procedure TAsmObjectData.afteralloc;
+      begin
+      end;
+
+
+    procedure TAsmObjectData.afterwrite;
+      begin
+      end;
+
+
+    procedure TAsmObjectData.resetsections;
+      begin
+        FSects.foreach(@section_reset,nil);
       end;
       end;
 
 
 
 
     procedure TAsmObjectData.fixuprelocs;
     procedure TAsmObjectData.fixuprelocs;
       begin
       begin
-        { no relocation support by default }
+        FSects.foreach(@section_fixuprelocs,nil);
       end;
       end;
 
 
 
 
@@ -693,9 +753,9 @@ implementation
          begin
          begin
            if not assigned(asmsymbolidx) then
            if not assigned(asmsymbolidx) then
              internalerror(200208072);
              internalerror(200208072);
-           if (longint(pointer(s))<1) or (longint(pointer(s))>asmsymbolppuidx) then
+           if (ptrint(pointer(s))<1) or (ptrint(pointer(s))>asmsymbolppuidx) then
              internalerror(200208073);
              internalerror(200208073);
-           s:=asmsymbolidx^[longint(pointer(s))-1];
+           s:=asmsymbolidx^[ptrint(pointer(s))-1];
          end;
          end;
       end;
       end;
 
 
@@ -708,7 +768,9 @@ implementation
         if assigned(hp) then
         if assigned(hp) then
          begin
          begin
            {$IFDEF EXTDEBUG}
            {$IFDEF EXTDEBUG}
-           if (_typ <> AT_NONE) and (hp.typ <> _typ) then
+           if (_typ <> AT_NONE) and
+              (hp.typ <> _typ) and
+              not(cs_compilesystem in aktmoduleswitches) then
              begin
              begin
                //Writeln('Error symbol '+hp.name+' type is ',Ord(_typ),', should be ',Ord(hp.typ));
                //Writeln('Error symbol '+hp.name+' type is ',Ord(_typ),', should be ',Ord(hp.typ));
                InternalError(2004031501);
                InternalError(2004031501);
@@ -822,7 +884,7 @@ implementation
            with hp do
            with hp do
             begin
             begin
               if is_used and
               if is_used and
-                 (section=Sec_none) and
+                 (section=nil) and
                  not(currbind in [AB_EXTERNAL,AB_COMMON]) then
                  not(currbind in [AB_EXTERNAL,AB_COMMON]) then
                Message1(asmw_e_undefined_label,name);
                Message1(asmw_e_undefined_label,name);
             end;
             end;
@@ -880,7 +942,22 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.17  2004-03-18 11:45:39  olle
+  Revision 1.18  2004-06-16 20:07:06  florian
+    * dwarf branch merged
+
+  Revision 1.17.2.4  2004/05/11 21:04:40  peter
+    * ignore EXTDEBUG check for different asmsymbol type for system unit
+
+  Revision 1.17.2.3  2004/04/26 21:05:09  peter
+    * size of classes is now stored as aint
+
+  Revision 1.17.2.2  2004/04/12 19:34:45  peter
+    * basic framework for dwarf CFI
+
+  Revision 1.17.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
+  Revision 1.17  2004/03/18 11:45:39  olle
     + added type similarity check in newasmsymbol
     + added type similarity check in newasmsymbol
 
 
   Revision 1.16  2004/03/02 00:36:32  olle
   Revision 1.16  2004/03/02 00:36:32  olle

+ 358 - 129
compiler/aasmtai.pas

@@ -53,14 +53,17 @@ interface
           ait_symbol,
           ait_symbol,
           ait_symbol_end, { needed to calc the size of a symbol }
           ait_symbol_end, { needed to calc the size of a symbol }
           ait_label,
           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_64bit,
           ait_const_32bit,
           ait_const_32bit,
           ait_const_16bit,
           ait_const_16bit,
           ait_const_8bit,
           ait_const_8bit,
-          ait_const_symbol,
-          { the following is only used by the win32 version of the compiler }
-          { and only the GNU AS Win32 is able to write it                   }
-          ait_const_rva,
+          ait_const_sleb128bit,
+          ait_const_uleb128bit,
+          ait_const_rva_symbol, { win32 only }
+          ait_const_indirect_symbol, { darwin only }
           ait_real_32bit,
           ait_real_32bit,
           ait_real_64bit,
           ait_real_64bit,
           ait_real_80bit,
           ait_real_80bit,
@@ -85,17 +88,24 @@ interface
           ait_labeled_instruction,
           ait_labeled_instruction,
 {$endif m68k}
 {$endif m68k}
           { used to split into tiny assembler files }
           { used to split into tiny assembler files }
-          ait_cut,
+          ait_cutobject,
           ait_regalloc,
           ait_regalloc,
           ait_tempalloc,
           ait_tempalloc,
           { used to mark assembler blocks and inlined functions }
           { used to mark assembler blocks and inlined functions }
           ait_marker,
           ait_marker,
-          { special symbols for darwin pic code }
-          ait_indirect_symbol,
+          { special symbol for darwin pic code }
           ait_non_lazy_symbol_pointer
           ait_non_lazy_symbol_pointer
           );
           );
 
 
     const
     const
+{$ifdef cpu64bit}
+       ait_const_aint = ait_const_64bit;
+       ait_const_ptr  = ait_const_64bit;
+{$else cpu64bit}
+       ait_const_aint = ait_const_32bit;
+       ait_const_ptr  = ait_const_32bit;
+{$endif cpu64bit}
+
        taitypestr : array[taitype] of string[24] = (
        taitypestr : array[taitype] of string[24] = (
           '<none>',
           '<none>',
           'align',
           'align',
@@ -108,12 +118,15 @@ interface
           'symbol',
           'symbol',
           'symbol_end',
           'symbol_end',
           'label',
           'label',
+          'const_128bit',
           'const_64bit',
           'const_64bit',
           'const_32bit',
           'const_32bit',
           'const_16bit',
           'const_16bit',
           'const_8bit',
           'const_8bit',
-          'const_symbol',
-          'const_rva',
+          'const_sleb128bit',
+          'const_uleb128bit',
+          'const_rva_symbol',
+          'const_indirect_symbol',
           'real_32bit',
           'real_32bit',
           'real_64bit',
           'real_64bit',
           'real_80bit',
           'real_80bit',
@@ -141,7 +154,6 @@ interface
           'regalloc',
           'regalloc',
           'tempalloc',
           'tempalloc',
           'marker',
           'marker',
-          'indirect_symbol',
           'non_lazy_symbol_pointer'
           'non_lazy_symbol_pointer'
           );
           );
 
 
@@ -177,7 +189,7 @@ interface
           top_none   : ();
           top_none   : ();
           top_reg    : (reg:tregister);
           top_reg    : (reg:tregister);
           top_ref    : (ref:preference);
           top_ref    : (ref:preference);
-          top_const  : (val:aword);
+          top_const  : (val:aint);
           top_bool   : (b:boolean);
           top_bool   : (b:boolean);
           { local varsym that will be inserted in pass_2 }
           { local varsym that will be inserted in pass_2 }
           top_local  : (localoper:plocaloper);
           top_local  : (localoper:plocaloper);
@@ -209,8 +221,10 @@ interface
 {$ifdef GDB}
 {$ifdef GDB}
                   ait_stabn,ait_stabs,ait_stab_function_name,
                   ait_stabn,ait_stabs,ait_stab_function_name,
 {$endif GDB}
 {$endif GDB}
-                  ait_cut,ait_marker,ait_align,ait_section,ait_comment,
-                  ait_const_8bit,ait_const_16bit,ait_const_32bit,ait_const_64bit,
+                  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_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_real_128bit,
                   ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_real_128bit,
                   ait_non_lazy_symbol_pointer
                   ait_non_lazy_symbol_pointer
                   ];
                   ];
@@ -332,8 +346,12 @@ interface
 
 
        { Generates a section / segment directive }
        { Generates a section / segment directive }
        tai_section = class(tai)
        tai_section = class(tai)
-          sec : TSection;
-          constructor Create(s : TSection);
+          sectype : TAsmSectionType;
+          secalign : byte;
+          name    : pstring;
+          sec     : TAsmSection; { used in binary writer }
+          constructor Create(Asectype:TAsmSectionType;Aname:string;Aalign:byte);
+          destructor Destroy;override;
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
        end;
        end;
@@ -354,30 +372,32 @@ interface
 
 
        { Generates an integer const }
        { Generates an integer const }
        tai_const = class(tai)
        tai_const = class(tai)
-          value : qword;
-          constructor Create_ptr(_value : TConstPtrUInt);
-          constructor Create_64bit(_value : qword);
-          constructor Create_32bit(_value : cardinal);
+          sym,
+          endsym  : tasmsymbol;
+          value   : int64;
+          { 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_128bit(_value : int64);
+          constructor Create_64bit(_value : int64);
+          constructor Create_32bit(_value : longint);
           constructor Create_16bit(_value : word);
           constructor Create_16bit(_value : word);
           constructor Create_8bit(_value : byte);
           constructor Create_8bit(_value : byte);
-          constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
-          procedure ppuwrite(ppufile:tcompilerppufile);override;
-       end;
-
-
-       tai_const_symbol = class(tailineinfo)
-          sym    : tasmsymbol;
-          offset : aint;
-          constructor Create(_sym:tasmsymbol);
-          constructor Create_offset(_sym:tasmsymbol;ofs:aint);
-          constructor Create_rva(_sym:tasmsymbol);
-          constructor Create_indirect(_sym:tasmsymbol);
+          constructor Create_sleb128bit(_value : int64);
+          constructor Create_uleb128bit(_value : qword);
+          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_rva_sym(_sym:tasmsymbol);
+          constructor Create_indirect_sym(_sym:tasmsymbol);
           constructor Createname(const name:string;_symtyp:Tasmsymtype;ofs:aint);
           constructor Createname(const name:string;_symtyp:Tasmsymtype;ofs:aint);
           constructor Createname_rva(const name:string);
           constructor Createname_rva(const name:string);
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure derefimpl;override;
           procedure derefimpl;override;
           function getcopy:tlinkedlistitem;override;
           function getcopy:tlinkedlistitem;override;
+          function size:longint;
        end;
        end;
 
 
        { Generates a single float (32 bit real) }
        { Generates a single float (32 bit real) }
@@ -433,7 +453,7 @@ interface
        end;
        end;
 
 
        { Insert a cut to split assembler into several smaller files }
        { Insert a cut to split assembler into several smaller files }
-       tai_cut = class(tai)
+       tai_cutobject = class(tai)
           place : tcutplace;
           place : tcutplace;
           constructor Create;
           constructor Create;
           constructor Create_begin;
           constructor Create_begin;
@@ -485,7 +505,7 @@ interface
 
 
        { Class template for assembler instructions
        { Class template for assembler instructions
        }
        }
-       taicpu_abstract = class(tailineinfo)
+       tai_cpu_abstract = class(tailineinfo)
        protected
        protected
           procedure ppuloadoper(ppufile:tcompilerppufile;var o:toper);virtual;abstract;
           procedure ppuloadoper(ppufile:tcompilerppufile;var o:toper);virtual;abstract;
           procedure ppuwriteoper(ppufile:tcompilerppufile;const o:toper);virtual;abstract;
           procedure ppuwriteoper(ppufile:tcompilerppufile;const o:toper);virtual;abstract;
@@ -507,7 +527,7 @@ interface
 {$endif x86}
 {$endif x86}
           { true if instruction is a jmp }
           { true if instruction is a jmp }
           is_jmp    : boolean; { is this instruction a jump? (needed for optimizer) }
           is_jmp    : boolean; { is this instruction a jump? (needed for optimizer) }
-          Constructor Create(op : tasmop);
+          Constructor Create(op : tasmop);virtual;
           Destructor Destroy;override;
           Destructor Destroy;override;
           function getcopy:TLinkedListItem;override;
           function getcopy:TLinkedListItem;override;
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
@@ -516,19 +536,18 @@ interface
           procedure derefimpl;override;
           procedure derefimpl;override;
           procedure SetCondition(const c:TAsmCond);
           procedure SetCondition(const c:TAsmCond);
           procedure allocate_oper(opers:longint);
           procedure allocate_oper(opers:longint);
-          procedure loadconst(opidx:longint;l:aword);
+          procedure loadconst(opidx:longint;l:aint);
           procedure loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
           procedure loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
           procedure loadlocal(opidx:longint;s:pointer;sofs:longint;indexreg:tregister;scale:byte;getoffset:boolean);
           procedure loadlocal(opidx:longint;s:pointer;sofs:longint;indexreg:tregister;scale:byte;getoffset:boolean);
           procedure loadref(opidx:longint;const r:treference);
           procedure loadref(opidx:longint;const r:treference);
           procedure loadreg(opidx:longint;r:tregister);
           procedure loadreg(opidx:longint;r:tregister);
           procedure loadoper(opidx:longint;o:toper);
           procedure loadoper(opidx:longint;o:toper);
           procedure clearop(opidx:longint);
           procedure clearop(opidx:longint);
-          function is_same_reg_move(regtype: Tregistertype):boolean;virtual;abstract;
           { register allocator }
           { register allocator }
-          function spilling_create_load(const ref:treference;r:tregister): tai;virtual;abstract;
-          function spilling_create_store(r:tregister; const ref:treference): tai;virtual;abstract;
-          function spilling_get_operation_type(opnr: longint): topertype;virtual;abstract;
+          function is_same_reg_move(regtype: Tregistertype):boolean;virtual;
+          function spilling_get_operation_type(opnr: longint): topertype;virtual;
        end;
        end;
+       tai_cpu_class = class of tai_cpu_abstract;
 
 
        { alignment for operator }
        { alignment for operator }
        tai_align_abstract = class(tai)
        tai_align_abstract = class(tai)
@@ -536,17 +555,19 @@ interface
           fillsize  : byte;   { real size to fill }
           fillsize  : byte;   { real size to fill }
           fillop    : byte;   { value to fill with - optional }
           fillop    : byte;   { value to fill with - optional }
           use_op    : boolean;
           use_op    : boolean;
-          constructor Create(b:byte);
-          constructor Create_op(b: byte; _op: byte);
+          constructor Create(b:byte);virtual;
+          constructor Create_op(b: byte; _op: byte);virtual;
+          constructor Create_zeros(b:byte);
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
           constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           function calculatefillbuf(var buf : tfillbuffer):pchar;virtual;
           function calculatefillbuf(var buf : tfillbuffer):pchar;virtual;
        end;
        end;
+       tai_align_class = class of tai_align_abstract;
 
 
        taasmoutput = class(tlinkedlist)
        taasmoutput = class(tlinkedlist)
           constructor create;
           constructor create;
-          function empty:boolean;
-          function getlasttaifilepos : pfileposinfo;
+          function  empty : boolean;
+          function  getlasttaifilepos : pfileposinfo;
           procedure InsertAfter(Item,Loc : TLinkedListItem);override;
           procedure InsertAfter(Item,Loc : TLinkedListItem);override;
        end;
        end;
 
 
@@ -572,10 +593,19 @@ interface
       debuglist,withdebuglist,consts,
       debuglist,withdebuglist,consts,
       importssection,exportssection,
       importssection,exportssection,
       resourcesection,rttilist,
       resourcesection,rttilist,
+      dwarflist,
       { data used by pic code }
       { data used by pic code }
       picdata,
       picdata,
       resourcestringlist         : taasmoutput;
       resourcestringlist         : taasmoutput;
 
 
+      cai_align : tai_align_class;
+      cai_cpu   : tai_cpu_class;
+
+    function  use_smartlink_section:boolean;
+    function  maybe_smartlink_symbol:boolean;
+    procedure maybe_new_object_file(list:taasmoutput);
+    procedure new_section(list:taasmoutput;Asectype:TAsmSectionType;Aname:string;Aalign:byte);
+
     function ppuloadai(ppufile:tcompilerppufile):tai;
     function ppuloadai(ppufile:tcompilerppufile):tai;
     procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
     procedure ppuwriteai(ppufile:tcompilerppufile;n:tai);
 
 
@@ -640,6 +670,36 @@ implementation
       end;
       end;
 
 
 
 
+    function use_smartlink_section:boolean;
+      begin
+        result:=(af_smartlink_sections in target_asm.flags) and
+                (tf_smartlink_sections in target_info.flags) and
+                not(cs_debuginfo in aktmoduleswitches);
+      end;
+
+
+    function maybe_smartlink_symbol:boolean;
+      begin
+        result:=(cs_create_smart in aktmoduleswitches) or
+                use_smartlink_section;
+      end;
+
+
+    procedure maybe_new_object_file(list:taasmoutput);
+      begin
+        if (cs_create_smart in aktmoduleswitches) and
+           (not use_smartlink_section) then
+          list.concat(tai_cutobject.create);
+      end;
+
+
+    procedure new_section(list:taasmoutput;Asectype:TAsmSectionType;Aname:string;Aalign:byte);
+      begin
+        list.concat(tai_section.create(Asectype,Aname,Aalign));
+        list.concat(cai_align.create(Aalign));
+      end;
+
+
 {****************************************************************************
 {****************************************************************************
                              TAI
                              TAI
  ****************************************************************************}
  ****************************************************************************}
@@ -718,25 +778,39 @@ implementation
                              TAI_SECTION
                              TAI_SECTION
  ****************************************************************************}
  ****************************************************************************}
 
 
-    constructor tai_section.Create(s : TSection);
+    constructor tai_section.Create(Asectype:TAsmSectionType;Aname:string;Aalign:byte);
       begin
       begin
-         inherited Create;
-         typ:=ait_section;
-         sec:=s;
+        inherited Create;
+        typ:=ait_section;
+        sectype:=asectype;
+        secalign:=Aalign;
+        name:=stringdup(Aname);
+        sec:=nil;
       end;
       end;
 
 
 
 
     constructor tai_section.ppuload(t:taitype;ppufile:tcompilerppufile);
     constructor tai_section.ppuload(t:taitype;ppufile:tcompilerppufile);
       begin
       begin
         inherited ppuload(t,ppufile);
         inherited ppuload(t,ppufile);
-        sec:=tsection(ppufile.getbyte);
+        sectype:=tasmsectiontype(ppufile.getbyte);
+        secalign:=ppufile.getbyte;
+        name:=stringdup(ppufile.getstring);
+        sec:=nil;
+      end;
+
+
+    destructor tai_section.Destroy;
+      begin
+        stringdispose(name);
       end;
       end;
 
 
 
 
     procedure tai_section.ppuwrite(ppufile:tcompilerppufile);
     procedure tai_section.ppuwrite(ppufile:tcompilerppufile);
       begin
       begin
         inherited ppuwrite(ppufile);
         inherited ppuwrite(ppufile);
-        ppufile.putbyte(byte(sec));
+        ppufile.putbyte(byte(sectype));
+        ppufile.putbyte(secalign);
+        ppufile.putstring(name^);
       end;
       end;
 
 
 
 
@@ -903,29 +977,43 @@ implementation
                                TAI_CONST
                                TAI_CONST
  ****************************************************************************}
  ****************************************************************************}
 
 
-    constructor tai_const.Create_ptr(_value : TConstPtrUInt);
+    constructor tai_const.Create(_typ:taitype;_value : int64);
       begin
       begin
-{$ifdef cpu64bit}
-        self.create_64bit(_value);
-{$else cpu64bit}
-        self.create_32bit(_value);
-{$endif cpu64bit}
+         inherited Create;
+         typ:=_typ;
+         value:=_value;
+         sym:=nil;
+         endsym:=nil;
       end;
       end;
 
 
 
 
-    constructor tai_const.Create_64bit(_value : qword);
+    constructor tai_const.Create_128bit(_value : int64);
+      begin
+         inherited Create;
+         typ:=ait_const_128bit;
+         value:=_value;
+         sym:=nil;
+         endsym:=nil;
+      end;
+
+
+    constructor tai_const.Create_64bit(_value : int64);
       begin
       begin
          inherited Create;
          inherited Create;
          typ:=ait_const_64bit;
          typ:=ait_const_64bit;
          value:=_value;
          value:=_value;
+         sym:=nil;
+         endsym:=nil;
       end;
       end;
 
 
 
 
-    constructor tai_const.Create_32bit(_value : cardinal);
+    constructor tai_const.Create_32bit(_value : longint);
       begin
       begin
          inherited Create;
          inherited Create;
          typ:=ait_const_32bit;
          typ:=ait_const_32bit;
          value:=_value;
          value:=_value;
+         sym:=nil;
+         endsym:=nil;
       end;
       end;
 
 
 
 
@@ -934,6 +1022,8 @@ implementation
          inherited Create;
          inherited Create;
          typ:=ait_const_16bit;
          typ:=ait_const_16bit;
          value:=_value;
          value:=_value;
+         sym:=nil;
+         endsym:=nil;
       end;
       end;
 
 
 
 
@@ -942,118 +1032,180 @@ implementation
          inherited Create;
          inherited Create;
          typ:=ait_const_8bit;
          typ:=ait_const_8bit;
          value:=_value;
          value:=_value;
+         sym:=nil;
+         endsym:=nil;
       end;
       end;
 
 
 
 
-    constructor tai_const.ppuload(t:taitype;ppufile:tcompilerppufile);
+    constructor tai_const.Create_sleb128bit(_value : int64);
       begin
       begin
-        inherited ppuload(t,ppufile);
-        value:=ppufile.getlongint;
+         inherited Create;
+         typ:=ait_const_sleb128bit;
+         value:=_value;
+         sym:=nil;
+         endsym:=nil;
       end;
       end;
 
 
 
 
-    procedure tai_const.ppuwrite(ppufile:tcompilerppufile);
+    constructor tai_const.Create_uleb128bit(_value : qword);
       begin
       begin
-        inherited ppuwrite(ppufile);
-        ppufile.putlongint(value);
+         inherited Create;
+         typ:=ait_const_uleb128bit;
+         value:=int64(_value);
+         sym:=nil;
+         endsym:=nil;
       end;
       end;
 
 
 
 
-{****************************************************************************
-                               TAI_CONST_SYMBOL
- ****************************************************************************}
+    constructor tai_const.Create_aint(_value : aint);
+      begin
+         inherited Create;
+         typ:=ait_const_aint;
+         value:=_value;
+         sym:=nil;
+         endsym:=nil;
+      end;
+
+
+    constructor tai_const.Create_sym(_sym:tasmsymbol);
+      begin
+         inherited Create;
+         typ:=ait_const_ptr;
+         { sym is allowed to be nil, this is used to write nil pointers }
+         sym:=_sym;
+         endsym:=nil;
+         value:=0;
+         { update sym info }
+         if assigned(sym) then
+           sym.increfs;
+      end;
+
 
 
-    constructor tai_const_symbol.Create(_sym:tasmsymbol);
+    constructor tai_const.Create_sym_offset(_sym:tasmsymbol;ofs:aint);
       begin
       begin
          inherited Create;
          inherited Create;
-         typ:=ait_const_symbol;
+         typ:=ait_const_ptr;
+         if not assigned(_sym) then
+           internalerror(200404121);
          sym:=_sym;
          sym:=_sym;
-         offset:=0;
+         endsym:=nil;
+         value:=ofs;
          { update sym info }
          { update sym info }
          sym.increfs;
          sym.increfs;
       end;
       end;
 
 
-    constructor tai_const_symbol.Create_offset(_sym:tasmsymbol;ofs:aint);
+
+    constructor tai_const.Create_rel_sym(_typ:taitype;_sym,_endsym:tasmsymbol);
       begin
       begin
          inherited Create;
          inherited Create;
-         typ:=ait_const_symbol;
+         typ:=_typ;
          sym:=_sym;
          sym:=_sym;
-         offset:=ofs;
+         endsym:=_endsym;
+         value:=0;
          { update sym info }
          { update sym info }
          sym.increfs;
          sym.increfs;
+         endsym.increfs;
       end;
       end;
 
 
 
 
-    constructor tai_const_symbol.Create_rva(_sym:tasmsymbol);
+    constructor tai_const.Create_rva_sym(_sym:tasmsymbol);
       begin
       begin
          inherited Create;
          inherited Create;
-         typ:=ait_const_rva;
+         typ:=ait_const_rva_symbol;
          sym:=_sym;
          sym:=_sym;
-         offset:=0;
+         endsym:=nil;
+         value:=0;
          { update sym info }
          { update sym info }
          sym.increfs;
          sym.increfs;
       end;
       end;
 
 
 
 
-    constructor tai_const_symbol.Create_indirect(_sym:tasmsymbol);
+    constructor tai_const.Create_indirect_sym(_sym:tasmsymbol);
       begin
       begin
          inherited Create;
          inherited Create;
-         typ:=ait_indirect_symbol;
+         typ:=ait_const_indirect_symbol;
          sym:=_sym;
          sym:=_sym;
-         offset:=0;
+         endsym:=nil;
+         value:=0;
          { update sym info }
          { update sym info }
          sym.increfs;
          sym.increfs;
       end;
       end;
 
 
 
 
-    constructor tai_const_symbol.Createname(const name:string;_symtyp:Tasmsymtype;ofs:aint);
+    constructor tai_const.Createname(const name:string;_symtyp:Tasmsymtype;ofs:aint);
       begin
       begin
          inherited Create;
          inherited Create;
-         typ:=ait_const_symbol;
+         typ:=ait_const_ptr;
          sym:=objectlibrary.newasmsymbol(name,AB_EXTERNAL,_symtyp);
          sym:=objectlibrary.newasmsymbol(name,AB_EXTERNAL,_symtyp);
-         offset:=ofs;
+         endsym:=nil;
+         value:=ofs;
          { update sym info }
          { update sym info }
          sym.increfs;
          sym.increfs;
       end;
       end;
 
 
 
 
-    constructor tai_const_symbol.Createname_rva(const name:string);
+    constructor tai_const.Createname_rva(const name:string);
       begin
       begin
          inherited Create;
          inherited Create;
-         typ:=ait_const_rva;
+         typ:=ait_const_rva_symbol;
          sym:=objectlibrary.newasmsymbol(name,AB_EXTERNAL,AT_FUNCTION);
          sym:=objectlibrary.newasmsymbol(name,AB_EXTERNAL,AT_FUNCTION);
-         offset:=0;
+         endsym:=nil;
+         value:=0;
          { update sym info }
          { update sym info }
          sym.increfs;
          sym.increfs;
       end;
       end;
 
 
-    constructor tai_const_symbol.ppuload(t:taitype;ppufile:tcompilerppufile);
+
+    constructor tai_const.ppuload(t:taitype;ppufile:tcompilerppufile);
       begin
       begin
         inherited ppuload(t,ppufile);
         inherited ppuload(t,ppufile);
         sym:=ppufile.getasmsymbol;
         sym:=ppufile.getasmsymbol;
-        offset:=ppufile.getlongint;
+        endsym:=ppufile.getasmsymbol;
+        value:=ppufile.getint64;
       end;
       end;
 
 
 
 
-    procedure tai_const_symbol.ppuwrite(ppufile:tcompilerppufile);
+    procedure tai_const.ppuwrite(ppufile:tcompilerppufile);
       begin
       begin
         inherited ppuwrite(ppufile);
         inherited ppuwrite(ppufile);
         ppufile.putasmsymbol(sym);
         ppufile.putasmsymbol(sym);
-        ppufile.putlongint(offset);
+        ppufile.putasmsymbol(endsym);
+        ppufile.putint64(value);
       end;
       end;
 
 
 
 
-    procedure tai_const_symbol.derefimpl;
+    procedure tai_const.derefimpl;
       begin
       begin
         objectlibrary.DerefAsmsymbol(sym);
         objectlibrary.DerefAsmsymbol(sym);
+        objectlibrary.DerefAsmsymbol(endsym);
       end;
       end;
 
 
 
 
-    function tai_const_symbol.getcopy:tlinkedlistitem;
+    function tai_const.getcopy:tlinkedlistitem;
       begin
       begin
         getcopy:=inherited getcopy;
         getcopy:=inherited getcopy;
         { we need to increase the reference number }
         { we need to increase the reference number }
         sym.increfs;
         sym.increfs;
+        if assigned(endsym) then
+          endsym.increfs;
+      end;
+
+
+    function tai_const.size:longint;
+      begin
+        case typ of
+          ait_const_8bit :
+            result:=1;
+          ait_const_16bit :
+            result:=2;
+          ait_const_32bit :
+            result:=4;
+          ait_const_64bit :
+            result:=8;
+          ait_const_indirect_symbol,
+          ait_const_rva_symbol :
+            result:=sizeof(aint);
+        end;
       end;
       end;
 
 
 
 
@@ -1423,41 +1575,41 @@ implementation
 
 
 
 
 {****************************************************************************
 {****************************************************************************
-                              TAI_CUT
+                              TAI_CUTOBJECT
  ****************************************************************************}
  ****************************************************************************}
 
 
-     constructor tai_cut.Create;
+     constructor tai_cutobject.Create;
        begin
        begin
           inherited Create;
           inherited Create;
-          typ:=ait_cut;
+          typ:=ait_cutobject;
           place:=cut_normal;
           place:=cut_normal;
        end;
        end;
 
 
 
 
-     constructor tai_cut.Create_begin;
+     constructor tai_cutobject.Create_begin;
        begin
        begin
           inherited Create;
           inherited Create;
-          typ:=ait_cut;
+          typ:=ait_cutobject;
           place:=cut_begin;
           place:=cut_begin;
        end;
        end;
 
 
 
 
-     constructor tai_cut.Create_end;
+     constructor tai_cutobject.Create_end;
        begin
        begin
           inherited Create;
           inherited Create;
-          typ:=ait_cut;
+          typ:=ait_cutobject;
           place:=cut_end;
           place:=cut_end;
        end;
        end;
 
 
 
 
-    constructor tai_cut.ppuload(t:taitype;ppufile:tcompilerppufile);
+    constructor tai_cutobject.ppuload(t:taitype;ppufile:tcompilerppufile);
       begin
       begin
         inherited ppuload(t,ppufile);
         inherited ppuload(t,ppufile);
         place:=TCutPlace(ppufile.getbyte);
         place:=TCutPlace(ppufile.getbyte);
       end;
       end;
 
 
 
 
-    procedure tai_cut.ppuwrite(ppufile:tcompilerppufile);
+    procedure tai_cutobject.ppuwrite(ppufile:tcompilerppufile);
       begin
       begin
         inherited ppuwrite(ppufile);
         inherited ppuwrite(ppufile);
         ppufile.putbyte(byte(place));
         ppufile.putbyte(byte(place));
@@ -1614,7 +1766,7 @@ implementation
                                TaiInstruction
                                TaiInstruction
 *****************************************************************************}
 *****************************************************************************}
 
 
-    constructor taicpu_abstract.Create(op : tasmop);
+    constructor tai_cpu_abstract.Create(op : tasmop);
 
 
       begin
       begin
          inherited create;
          inherited create;
@@ -1627,7 +1779,7 @@ implementation
       end;
       end;
 
 
 
 
-    destructor taicpu_abstract.Destroy;
+    destructor tai_cpu_abstract.Destroy;
       var
       var
         i : integer;
         i : integer;
       begin
       begin
@@ -1644,7 +1796,7 @@ implementation
     Loading of operands.
     Loading of operands.
   ---------------------------------------------------------------------}
   ---------------------------------------------------------------------}
 
 
-    procedure taicpu_abstract.allocate_oper(opers:longint);
+    procedure tai_cpu_abstract.allocate_oper(opers:longint);
       begin
       begin
         while (opers>opercnt) do
         while (opers>opercnt) do
           begin
           begin
@@ -1655,7 +1807,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure taicpu_abstract.loadconst(opidx:longint;l:aword);
+    procedure tai_cpu_abstract.loadconst(opidx:longint;l:aint);
       begin
       begin
         allocate_oper(opidx+1);
         allocate_oper(opidx+1);
         with oper[opidx]^ do
         with oper[opidx]^ do
@@ -1668,7 +1820,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure taicpu_abstract.loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
+    procedure tai_cpu_abstract.loadsymbol(opidx:longint;s:tasmsymbol;sofs:longint);
       var
       var
         r : treference;
         r : treference;
       begin
       begin
@@ -1678,7 +1830,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure taicpu_abstract.loadlocal(opidx:longint;s:pointer;sofs:longint;indexreg:tregister;scale:byte;getoffset:boolean);
+    procedure tai_cpu_abstract.loadlocal(opidx:longint;s:pointer;sofs:longint;indexreg:tregister;scale:byte;getoffset:boolean);
       begin
       begin
         if not assigned(s) then
         if not assigned(s) then
          internalerror(200204251);
          internalerror(200204251);
@@ -1703,7 +1855,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure taicpu_abstract.loadref(opidx:longint;const r:treference);
+    procedure tai_cpu_abstract.loadref(opidx:longint;const r:treference);
       begin
       begin
         allocate_oper(opidx+1);
         allocate_oper(opidx+1);
         with oper[opidx]^ do
         with oper[opidx]^ do
@@ -1734,7 +1886,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure taicpu_abstract.loadreg(opidx:longint;r:tregister);
+    procedure tai_cpu_abstract.loadreg(opidx:longint;r:tregister);
       begin
       begin
         allocate_oper(opidx+1);
         allocate_oper(opidx+1);
         with oper[opidx]^ do
         with oper[opidx]^ do
@@ -1757,7 +1909,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure taicpu_abstract.loadoper(opidx:longint;o:toper);
+    procedure tai_cpu_abstract.loadoper(opidx:longint;o:toper);
       begin
       begin
         allocate_oper(opidx+1);
         allocate_oper(opidx+1);
         clearop(opidx);
         clearop(opidx);
@@ -1795,7 +1947,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure taicpu_abstract.clearop(opidx:longint);
+    procedure tai_cpu_abstract.clearop(opidx:longint);
       begin
       begin
         with oper[opidx]^ do
         with oper[opidx]^ do
           begin
           begin
@@ -1820,18 +1972,18 @@ implementation
     Miscellaneous methods.
     Miscellaneous methods.
   ---------------------------------------------------------------------}
   ---------------------------------------------------------------------}
 
 
-    procedure taicpu_abstract.SetCondition(const c:TAsmCond);
+    procedure tai_cpu_abstract.SetCondition(const c:TAsmCond);
       begin
       begin
          condition:=c;
          condition:=c;
       end;
       end;
 
 
 
 
-    Function taicpu_abstract.getcopy:TLinkedListItem;
+    Function tai_cpu_abstract.getcopy:TLinkedListItem;
       var
       var
         i : longint;
         i : longint;
-        p : taicpu_abstract;
+        p : tai_cpu_abstract;
       begin
       begin
-        p:=taicpu_abstract(inherited getcopy);
+        p:=tai_cpu_abstract(inherited getcopy);
         { make a copy of the references }
         { make a copy of the references }
         p.opercnt:=0;
         p.opercnt:=0;
         p.allocate_oper(ops);
         p.allocate_oper(ops);
@@ -1862,7 +2014,22 @@ implementation
       end;
       end;
 
 
 
 
-    constructor taicpu_abstract.ppuload(t:taitype;ppufile:tcompilerppufile);
+    function tai_cpu_abstract.is_same_reg_move(regtype: Tregistertype):boolean;
+      begin
+        { When the generic RA is used this needs to be overriden, we don't use
+          virtual;abstract; to prevent a lot of warnings of unimplemented abstract methods
+          when tai_cpu is created (PFV) }
+        internalerror(200404091);
+      end;
+
+
+    function tai_cpu_abstract.spilling_get_operation_type(opnr: longint): topertype;
+      begin
+        internalerror(200404091);
+      end;
+
+
+    constructor tai_cpu_abstract.ppuload(t:taitype;ppufile:tcompilerppufile);
       var
       var
         i : integer;
         i : integer;
       begin
       begin
@@ -1880,7 +2047,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure taicpu_abstract.ppuwrite(ppufile:tcompilerppufile);
+    procedure tai_cpu_abstract.ppuwrite(ppufile:tcompilerppufile);
       var
       var
         i : integer;
         i : integer;
       begin
       begin
@@ -1897,7 +2064,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure taicpu_abstract.buildderefimpl;
+    procedure tai_cpu_abstract.buildderefimpl;
       var
       var
         i : integer;
         i : integer;
       begin
       begin
@@ -1906,7 +2073,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure taicpu_abstract.derefimpl;
+    procedure tai_cpu_abstract.derefimpl;
       var
       var
         i : integer;
         i : integer;
       begin
       begin
@@ -1947,8 +2114,24 @@ implementation
        end;
        end;
 
 
 
 
+     constructor tai_align_abstract.Create_zeros(b: byte);
+       begin
+          inherited Create;
+          typ:=ait_align;
+          if b in [1,2,4,8,16,32] then
+            aligntype := b
+          else
+            aligntype := 1;
+         use_op:=true;
+         fillsize:=0;
+         fillop:=0;
+       end;
+
+
      function tai_align_abstract.calculatefillbuf(var buf : tfillbuffer):pchar;
      function tai_align_abstract.calculatefillbuf(var buf : tfillbuffer):pchar;
        begin
        begin
+         if fillsize>sizeof(buf) then
+           internalerror(200404293);
          fillchar(buf,high(buf),fillop);
          fillchar(buf,high(buf),fillop);
          calculatefillbuf:=pchar(@buf);
          calculatefillbuf:=pchar(@buf);
        end;
        end;
@@ -1985,14 +2168,11 @@ implementation
       end;
       end;
 
 
 
 
-    function taasmoutput.empty:boolean;
+    function taasmoutput.empty : boolean;
       begin
       begin
-        result:=(count=0) or
-                (
-                 (count=1) and
-                 (tai(first).typ=ait_marker) and
-                 (tai_marker(first).kind=marker_blockstart)
-                );
+        { there is always a marker_blockstart available,
+          see taasmoutput.create }
+        result:=(count<=1);
       end;
       end;
 
 
 
 
@@ -2031,10 +2211,16 @@ implementation
         inherited InsertAfter(Item,Loc);
         inherited InsertAfter(Item,Loc);
       end;
       end;
 
 
+begin
+  cai_cpu:=tai_cpu_abstract;
+  cai_align:=tai_align_abstract;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.84  2004-05-23 14:31:05  peter
+  Revision 1.85  2004-06-16 20:07:06  florian
+    * dwarf branch merged
+
+  Revision 1.84  2004/05/23 14:31:05  peter
     * ignore marker block when checking for empty list
     * ignore marker block when checking for empty list
 
 
   Revision 1.83  2004/05/22 23:34:27  peter
   Revision 1.83  2004/05/22 23:34:27  peter
@@ -2043,6 +2229,49 @@ end.
   Revision 1.82  2004/04/12 18:59:32  florian
   Revision 1.82  2004/04/12 18:59:32  florian
     * small x86_64 fixes
     * small x86_64 fixes
 
 
+  Revision 1.81.2.14  2004/06/13 10:51:16  florian
+    * fixed several register allocator problems (sparc/arm)
+
+  Revision 1.81.2.13  2004/05/18 20:14:18  peter
+    * no section smartlink when using debuginfo
+
+  Revision 1.81.2.12  2004/05/10 21:28:34  peter
+    * section_smartlink enabled for gas under linux
+
+  Revision 1.81.2.11  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.81.2.10  2004/04/29 23:30:28  peter
+    * fix i386 compiler
+
+  Revision 1.81.2.9  2004/04/29 19:07:22  peter
+    * compile fixes
+
+  Revision 1.81.2.8  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.81.2.7  2004/04/20 16:35:58  peter
+    * generate dwarf for stackframe entry
+
+  Revision 1.81.2.6  2004/04/12 19:34:45  peter
+    * basic framework for dwarf CFI
+
+  Revision 1.81.2.5  2004/04/12 14:45:10  peter
+    * tai_const_symbol and tai_const merged
+
+  Revision 1.81.2.4  2004/04/10 19:45:07  florian
+    + .*leb128 support to assembler writer added
+
+  Revision 1.81.2.3  2004/04/10 12:36:40  peter
+    * fixed alignment issues
+
+  Revision 1.81.2.2  2004/04/09 14:34:52  peter
+    * fixed compilation for win32
+
+  Revision 1.81.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
   Revision 1.81  2004/03/16 22:12:10  florian
   Revision 1.81  2004/03/16 22:12:10  florian
     * some alignment issues resolved
     * some alignment issues resolved
     * compiler doesn't generate anymore instructions not supported by the linux fpe
     * compiler doesn't generate anymore instructions not supported by the linux fpe
@@ -2082,13 +2311,13 @@ end.
     * tai_const.create_ptr added
     * tai_const.create_ptr added
 
 
   Revision 1.71  2004/02/08 23:10:21  jonas
   Revision 1.71  2004/02/08 23:10:21  jonas
-    * taicpu.is_same_reg_move() now gets a regtype parameter so it only
+    * tai_cpu.is_same_reg_move() now gets a regtype parameter so it only
       removes moves of that particular register type. This is necessary so
       removes moves of that particular register type. This is necessary so
       we don't remove the live_start instruction of a register before it
       we don't remove the live_start instruction of a register before it
       has been processed
       has been processed
 
 
   Revision 1.70  2004/02/08 20:15:42  jonas
   Revision 1.70  2004/02/08 20:15:42  jonas
-    - removed taicpu.is_reg_move because it's not used anymore
+    - removed tai_cpu.is_reg_move because it's not used anymore
     + support tracking fpu register moves by rgobj for the ppc
     + support tracking fpu register moves by rgobj for the ppc
 
 
   Revision 1.69  2004/01/31 17:45:16  peter
   Revision 1.69  2004/01/31 17:45:16  peter
@@ -2111,7 +2340,7 @@ end.
       register set and shifter op
       register set and shifter op
 
 
   Revision 1.64  2004/01/12 16:37:59  peter
   Revision 1.64  2004/01/12 16:37:59  peter
-    * moved spilling code from taicpu to rg
+    * moved spilling code from tai_cpu to rg
 
 
   Revision 1.63  2003/12/28 16:20:09  jonas
   Revision 1.63  2003/12/28 16:20:09  jonas
     - removed unused methods from old generic spilling code
     - removed unused methods from old generic spilling code
@@ -2189,7 +2418,7 @@ end.
     * write derefdata in a separate ppu entry
     * write derefdata in a separate ppu entry
 
 
   Revision 1.45  2003/10/21 15:15:35  peter
   Revision 1.45  2003/10/21 15:15:35  peter
-    * taicpu_abstract.oper[] changed to pointers
+    * tai_cpu_abstract.oper[] changed to pointers
 
 
   Revision 1.44  2003/10/17 14:38:32  peter
   Revision 1.44  2003/10/17 14:38:32  peter
     * 64k registers supported
     * 64k registers supported

+ 219 - 91
compiler/aggas.pas

@@ -1,6 +1,6 @@
 {
 {
     $Id$
     $Id$
-    Copyright (c) 1998-2002 by the Free Pascal team
+    Copyright (c) 1998-2004 by the Free Pascal team
 
 
     This unit implements generic GNU assembler (v2.8 or later)
     This unit implements generic GNU assembler (v2.8 or later)
 
 
@@ -45,15 +45,18 @@ interface
          file.
          file.
       }
       }
       TGNUAssembler=class(texternalassembler)
       TGNUAssembler=class(texternalassembler)
-      public
-        procedure WriteTree(p:TAAsmoutput);override;
-        procedure WriteAsmList;override;
+      protected
+        function sectionname(atype:tasmsectiontype;const aname:string):string;virtual;
+        procedure WriteSection(atype:tasmsectiontype;const aname:string);
         procedure WriteExtraHeader;virtual;
         procedure WriteExtraHeader;virtual;
 {$ifdef GDB}
 {$ifdef GDB}
         procedure WriteFileLineInfo(var fileinfo : tfileposinfo);
         procedure WriteFileLineInfo(var fileinfo : tfileposinfo);
         procedure WriteFileEndInfo;
         procedure WriteFileEndInfo;
 {$endif}
 {$endif}
         procedure WriteInstruction(hp: tai);  virtual; abstract;
         procedure WriteInstruction(hp: tai);  virtual; abstract;
+      public
+        procedure WriteTree(p:TAAsmoutput);override;
+        procedure WriteAsmList;override;
       end;
       end;
 
 
     const
     const
@@ -65,7 +68,7 @@ implementation
 
 
     uses
     uses
       cutils,globtype,systems,
       cutils,globtype,systems,
-      fmodule,finput,verbose,cpubase,
+      fmodule,finput,verbose,
       itcpugas
       itcpugas
 {$ifdef GDB}
 {$ifdef GDB}
   {$ifdef delphi}
   {$ifdef delphi}
@@ -88,14 +91,16 @@ var
       funcname     : pchar;
       funcname     : pchar;
       stabslastfileinfo : tfileposinfo;
       stabslastfileinfo : tfileposinfo;
 {$endif}
 {$endif}
-      lasTSec      : TSection; { last section type written }
+      lasTSecType  : TAsmSectionType; { last section type written }
       lastfileinfo : tfileposinfo;
       lastfileinfo : tfileposinfo;
       infile,
       infile,
       lastinfile   : tinputfile;
       lastinfile   : tinputfile;
       symendcount  : longint;
       symendcount  : longint;
 
 
     type
     type
+{$ifdef cpuextended}
       t80bitarray = array[0..9] of byte;
       t80bitarray = array[0..9] of byte;
+{$endif cpuextended}
       t64bitarray = array[0..7] of byte;
       t64bitarray = array[0..7] of byte;
       t32bitarray = array[0..3] of byte;
       t32bitarray = array[0..3] of byte;
 
 
@@ -195,25 +200,11 @@ var
 
 
 
 
     const
     const
-      ait_const2str : array[ait_const_64bit..ait_const_8bit] of string[8]=
-       (#9'.quad'#9,#9'.long'#9,#9'.short'#9,#9'.byte'#9);
-
-
-    function ait_section2str(s:TSection):string;
-    begin
-       ait_section2str:=target_asm.secnames[s];
-{$ifdef GDB}
-       { this is needed for line info in data }
-       funcname:=nil;
-       case s of
-         sec_code : n_line:=n_textline;
-         sec_data : n_line:=n_dataline;
-         sec_bss  : n_line:=n_bssline;
-         else       n_line:=n_dataline;
-      end;
-{$endif GDB}
-      LasTSec:=s;
-    end;
+      ait_const2str : array[ait_const_128bit..ait_const_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
+      );
 
 
 {****************************************************************************}
 {****************************************************************************}
 {                          GNU Assembler writer                              }
 {                          GNU Assembler writer                              }
@@ -276,8 +267,7 @@ var
           if not ((cs_debuginfo in aktmoduleswitches) or
           if not ((cs_debuginfo in aktmoduleswitches) or
              (cs_gdb_lineinfo in aktglobalswitches)) then
              (cs_gdb_lineinfo in aktglobalswitches)) then
            exit;
            exit;
-          AsmLn;
-          AsmWriteLn(ait_section2str(sec_code));
+          WriteSection(sec_code,'');
           AsmWriteLn(#9'.stabs "",'+tostr(n_sourcefile)+',0,0,'+target_asm.labelprefix+'etext');
           AsmWriteLn(#9'.stabs "",'+tostr(n_sourcefile)+',0,0,'+target_asm.labelprefix+'etext');
           AsmWriteLn(target_asm.labelprefix+'etext:');
           AsmWriteLn(target_asm.labelprefix+'etext:');
         end;
         end;
@@ -285,6 +275,64 @@ var
 {$endif GDB}
 {$endif GDB}
 
 
 
 
+    function TGNUAssembler.sectionname(atype:tasmsectiontype;const aname:string):string;
+      const
+        secnames : array[tasmsectiontype] of string[12] = ('',
+{$warning TODO .rodata not yet working}
+          '.text','.data','.data','.bss',
+          'common',
+          '.note',
+          '.stab','.stabstr',
+          '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+          '.eh_frame',
+          '.debug_frame'
+        );
+      begin
+        if use_smartlink_section and
+           (atype<>sec_bss) and
+           (aname<>'') then
+          result:='.gnu.linkonce'+copy(secnames[atype],1,2)+'.'+aname
+        else
+          result:=secnames[atype];
+      end;
+
+
+    procedure TGNUAssembler.WriteSection(atype:tasmsectiontype;const aname:string);
+      var
+        s : string;
+      begin
+        AsmLn;
+        AsmWrite('.section ');
+        s:=sectionname(atype,aname);
+        AsmWrite(s);
+        if copy(s,1,4)='.gnu' then
+          begin
+            case atype of
+              sec_data :
+                AsmWrite(',""');
+              sec_code :
+                AsmWrite(',"x"');
+            end;
+          end;
+        AsmLn;
+{$ifdef GDB}
+        { this is needed for line info in data }
+        funcname:=nil;
+        case atype of
+          sec_code :
+            n_line:=n_textline;
+          sec_data :
+            n_line:=n_dataline;
+          sec_bss  :
+            n_line:=n_bssline;
+          else
+            n_line:=n_dataline;
+        end;
+{$endif GDB}
+        LasTSecType:=atype;
+      end;
+
+
     procedure TGNUAssembler.WriteTree(p:TAAsmoutput);
     procedure TGNUAssembler.WriteTree(p:TAAsmoutput);
     const
     const
       regallocstr : array[tregalloctype] of string[10]=(' allocated',' released','resized');
       regallocstr : array[tregalloctype] of string[10]=(' allocated',' released','resized');
@@ -295,7 +343,6 @@ var
       hp1      : tailineinfo;
       hp1      : tailineinfo;
       consttyp : taitype;
       consttyp : taitype;
       s        : string;
       s        : string;
-      found    : boolean;
       i,pos,l  : longint;
       i,pos,l  : longint;
       InlineLevel : longint;
       InlineLevel : longint;
       last_align : longint;
       last_align : longint;
@@ -386,8 +433,19 @@ var
            ait_regalloc :
            ait_regalloc :
              begin
              begin
                if (cs_asm_regalloc in aktglobalswitches) then
                if (cs_asm_regalloc in aktglobalswitches) then
-                 AsmWriteLn(#9+target_asm.comment+'Register '+gas_regname(Tai_regalloc(hp).reg)+
-                            regallocstr[tai_regalloc(hp).ratype]);
+                 begin
+                   AsmWrite(#9+target_asm.comment+'Register ');
+                   repeat
+                     AsmWrite(gas_regname(Tai_regalloc(hp).reg));
+                     if (hp.next=nil) or
+                        (tai(hp.next).typ<>ait_regalloc) or
+                        (tai_regalloc(hp.next).ratype<>tai_regalloc(hp).ratype) then
+                       break;
+                     hp:=tai(hp.next);
+                     AsmWrite(',');
+                   until false;
+                   AsmWriteLn(regallocstr[tai_regalloc(hp).ratype]);
+                 end;
              end;
              end;
 
 
            ait_tempalloc :
            ait_tempalloc :
@@ -407,29 +465,31 @@ var
 
 
            ait_align :
            ait_align :
              begin
              begin
-               if target_info.system <> system_powerpc_darwin then
+               if tai_align(hp).aligntype>1 then
                  begin
                  begin
-                   AsmWrite(#9'.balign '+tostr(tai_align(hp).aligntype));
-                   if tai_align(hp).use_op then
-                    AsmWrite(','+tostr(tai_align(hp).fillop))
-                 end
-               else
-                 begin
-                   { darwin as only supports .align }
-                   if not ispowerof2(tai_align(hp).aligntype,i) then
-                     internalerror(2003010305);
-                   AsmWrite(#9'.align '+tostr(i));
-                   last_align := i;
+                   if target_info.system <> system_powerpc_darwin then
+                     begin
+                       AsmWrite(#9'.balign '+tostr(tai_align(hp).aligntype));
+                       if tai_align(hp).use_op then
+                        AsmWrite(','+tostr(tai_align(hp).fillop))
+                     end
+                   else
+                     begin
+                       { darwin as only supports .align }
+                       if not ispowerof2(tai_align(hp).aligntype,i) then
+                         internalerror(2003010305);
+                       AsmWrite(#9'.align '+tostr(i));
+                       last_align := i;
+                     end;
+                   AsmLn;
                  end;
                  end;
-               AsmLn;
              end;
              end;
 
 
            ait_section :
            ait_section :
              begin
              begin
-               if tai_section(hp).sec<>sec_none then
+               if tai_section(hp).sectype<>sec_none then
                 begin
                 begin
-                  AsmLn;
-                  AsmWriteLn(ait_section2str(tai_section(hp).sec));
+                  WriteSection(tai_section(hp).sectype,tai_section(hp).name^);
 {$ifdef GDB}
 {$ifdef GDB}
                   lastfileinfo.line:=-1;
                   lastfileinfo.line:=-1;
 {$endif GDB}
 {$endif GDB}
@@ -457,51 +517,73 @@ var
                AsmWriteln('');
                AsmWriteln('');
              end;
              end;
 
 
+{$ifndef cpu64bit}
+           ait_const_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;
+{$endif cpu64bit}
+
+           ait_const_uleb128bit,
+           ait_const_sleb128bit,
+{$ifdef cpu64bit}
+           ait_const_128bit,
            ait_const_64bit,
            ait_const_64bit,
+{$endif cpu64bit}
            ait_const_32bit,
            ait_const_32bit,
            ait_const_16bit,
            ait_const_16bit,
-           ait_const_8bit :
+           ait_const_8bit,
+           ait_const_rva_symbol,
+           ait_const_indirect_symbol :
              begin
              begin
-               AsmWrite(ait_const2str[hp.typ]+tostru(tai_const(hp).value));
+               AsmWrite(ait_const2str[hp.typ]);
                consttyp:=hp.typ;
                consttyp:=hp.typ;
                l:=0;
                l:=0;
                repeat
                repeat
-                 found:=(not (tai(hp.next)=nil)) and (tai(hp.next).typ=consttyp);
-                 if found then
-                  begin
-                    hp:=tai(hp.next);
-                    s:=','+tostru(tai_const(hp).value);
-                    AsmWrite(s);
-                    inc(l,length(s));
-                  end;
-               until (not found) or (l>line_length);
-               AsmLn;
-             end;
-
-           ait_const_symbol :
-             begin
-               AsmWrite(#9'.long'#9);
-               AsmWrite(tai_const_symbol(hp).sym.name);
-               if tai_const_symbol(hp).offset>0 then
-                 AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
-               else if tai_const_symbol(hp).offset<0 then
-                 AsmWrite(tostr(tai_const_symbol(hp).offset));
-               AsmLn;
-             end;
-
-           ait_indirect_symbol :
-             begin
-               AsmWrite(#9'.indirect_symbol'#9);
-               AsmWrite(tai_const_symbol(hp).sym.name);
+                 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 (LasTSecType<>sec_data) or
+                    (l>line_length) or
+                    (hp.next=nil) or
+                    (tai(hp.next).typ<>consttyp) then
+                   break;
+                 hp:=tai(hp.next);
+                 AsmWrite(',');
+               until false;
                AsmLn;
                AsmLn;
              end;
              end;
 
 
-           ait_const_rva :
-             begin
-               AsmWrite(#9'.rva'#9);
-               AsmWriteLn(tai_const_symbol(hp).sym.name);
-             end;
-
 {$ifdef cpuextended}
 {$ifdef cpuextended}
            ait_real_80bit :
            ait_real_80bit :
              begin
              begin
@@ -674,7 +756,7 @@ var
                    AsmWrite(#9'.type'#9);
                    AsmWrite(#9'.type'#9);
                    AsmWrite(tai_symbol(hp).sym.name);
                    AsmWrite(tai_symbol(hp).sym.name);
                    if assigned(tai(hp.next)) and
                    if assigned(tai(hp.next)) and
-                      (tai(hp.next).typ in [ait_const_symbol,ait_const_rva,
+                      (tai(hp.next).typ in [ait_const_rva_symbol,
                          ait_const_32bit,ait_const_16bit,ait_const_8bit,ait_datablock,
                          ait_const_32bit,ait_const_16bit,ait_const_8bit,ait_datablock,
                          ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit]) then
                          ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit]) then
                      begin
                      begin
@@ -749,7 +831,7 @@ var
              funcname:=tai_stab_function_name(hp).str;
              funcname:=tai_stab_function_name(hp).str;
 {$endif GDB}
 {$endif GDB}
 
 
-           ait_cut :
+           ait_cutobject :
              begin
              begin
                if SmartAsm then
                if SmartAsm then
                 begin
                 begin
@@ -760,13 +842,13 @@ var
                    begin
                    begin
                      AsmClose;
                      AsmClose;
                      DoAssemble;
                      DoAssemble;
-                     AsmCreate(tai_cut(hp).place);
+                     AsmCreate(tai_cutobject(hp).place);
                    end;
                    end;
                 { avoid empty files }
                 { avoid empty files }
-                  while assigned(hp.next) and (tai(hp.next).typ in [ait_cut,ait_section,ait_comment]) do
+                  while assigned(hp.next) and (tai(hp.next).typ in [ait_cutobject,ait_section,ait_comment]) do
                    begin
                    begin
                      if tai(hp.next).typ=ait_section then
                      if tai(hp.next).typ=ait_section then
-                       lasTSec:=tai_section(hp.next).sec;
+                       lasTSectype:=tai_section(hp.next).sectype;
                      hp:=tai(hp.next);
                      hp:=tai(hp.next);
                    end;
                    end;
 {$ifdef GDB}
 {$ifdef GDB}
@@ -776,8 +858,8 @@ var
                   funcname:=nil;
                   funcname:=nil;
                   WriteFileLineInfo(aktfilepos);
                   WriteFileLineInfo(aktfilepos);
 {$endif GDB}
 {$endif GDB}
-                  if lasTSec<>sec_none then
-                    AsmWriteLn(ait_section2str(lasTSec));
+                  if lasTSectype<>sec_none then
+                    WriteSection(lasTSectype,'');
                   AsmStartSize:=AsmSize;
                   AsmStartSize:=AsmSize;
                 end;
                 end;
              end;
              end;
@@ -819,7 +901,7 @@ var
        Comment(V_Debug,'Start writing gas-styled assembler output for '+current_module.mainsource^);
        Comment(V_Debug,'Start writing gas-styled assembler output for '+current_module.mainsource^);
 {$endif}
 {$endif}
 
 
-      LasTSec:=sec_none;
+      LasTSectype:=sec_none;
 {$ifdef GDB}
 {$ifdef GDB}
       FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
       FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
 {$endif GDB}
 {$endif GDB}
@@ -862,9 +944,10 @@ var
       Writetree(importssection);
       Writetree(importssection);
       { exports are written by DLLTOOL
       { exports are written by DLLTOOL
         if we use it so don't insert it twice (PM) }
         if we use it so don't insert it twice (PM) }
-      if not UseDeffileForExport and assigned(exportssection) then
+      if not UseDeffileForExports and assigned(exportssection) then
         Writetree(exportssection);
         Writetree(exportssection);
       Writetree(resourcesection);
       Writetree(resourcesection);
+      Writetree(dwarflist);
       {$ifdef GDB}
       {$ifdef GDB}
       WriteFileEndInfo;
       WriteFileEndInfo;
       {$ENDIF}
       {$ENDIF}
@@ -879,7 +962,10 @@ var
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.53  2004-05-28 21:13:08  peter
+  Revision 1.54  2004-06-16 20:07:06  florian
+    * dwarf branch merged
+
+  Revision 1.53  2004/05/28 21:13:08  peter
     * fix wrong regalloc comments
     * fix wrong regalloc comments
 
 
   Revision 1.52  2004/05/22 23:34:27  peter
   Revision 1.52  2004/05/22 23:34:27  peter
@@ -894,6 +980,48 @@ end.
   Revision 1.49  2004/04/12 18:59:32  florian
   Revision 1.49  2004/04/12 18:59:32  florian
     * small x86_64 fixes
     * small x86_64 fixes
 
 
+  Revision 1.48.2.14  2004/05/31 15:24:26  peter
+    * merge ait_regalloc on one line
+
+  Revision 1.48.2.13  2004/05/18 20:14:18  peter
+    * no section smartlink when using debuginfo
+
+  Revision 1.48.2.12  2004/05/10 21:28:34  peter
+    * section_smartlink enabled for gas under linux
+
+  Revision 1.48.2.11  2004/05/03 14:59:57  peter
+    * no dlltool needed for win32 linking executables
+
+  Revision 1.48.2.10  2004/04/29 23:30:28  peter
+    * fix i386 compiler
+
+  Revision 1.48.2.9  2004/04/26 21:01:36  peter
+    * aint fixes
+
+  Revision 1.48.2.8  2004/04/20 16:35:58  peter
+    * generate dwarf for stackframe entry
+
+  Revision 1.48.2.7  2004/04/12 19:34:45  peter
+    * basic framework for dwarf CFI
+
+  Revision 1.48.2.6  2004/04/12 14:45:10  peter
+    * tai_const_symbol and tai_const merged
+
+  Revision 1.48.2.5  2004/04/10 22:08:52  florian
+    + more dwarf infrastructure
+
+  Revision 1.48.2.4  2004/04/10 19:45:07  florian
+    + .*leb128 support to assembler writer added
+
+  Revision 1.48.2.3  2004/04/10 12:36:41  peter
+    * fixed alignment issues
+
+  Revision 1.48.2.2  2004/04/09 14:34:53  peter
+    * fixed compilation for win32
+
+  Revision 1.48.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
   Revision 1.48  2004/03/17 22:27:41  florian
   Revision 1.48  2004/03/17 22:27:41  florian
     * fixed handling of doubles in a native arm compiler
     * fixed handling of doubles in a native arm compiler
     * fixed handling of typed double constants on arm
     * fixed handling of typed double constants on arm

+ 1 - 1
compiler/alpha/cpuinfo.pas

@@ -57,7 +57,7 @@ Const
    { Size of native extended type }
    { Size of native extended type }
    extended_size = 16;
    extended_size = 16;
    {# Size of a pointer                           }
    {# Size of a pointer                           }
-   pointer_size  = 8;
+   sizeof(aint)  = 8;
    {# Size of a multimedia register               }
    {# Size of a multimedia register               }
    mmreg_size = 8;
    mmreg_size = 8;
 
 

+ 33 - 11
compiler/arm/aasmcpu.pas

@@ -28,7 +28,7 @@ interface
 
 
 uses
 uses
   cclasses,aasmtai,
   cclasses,aasmtai,
-  aasmbase,globals,verbose,
+  aasmbase,globtype,globals,verbose,
   cpubase,cpuinfo,cgbase;
   cpubase,cpuinfo,cgbase;
 
 
     const
     const
@@ -38,7 +38,7 @@ uses
       O_MOV_DEST = 0;
       O_MOV_DEST = 0;
 
 
     type
     type
-      taicpu = class(taicpu_abstract)
+      taicpu = class(tai_cpu_abstract)
          oppostfix : TOpPostfix;
          oppostfix : TOpPostfix;
          roundingmode : troundingmode;
          roundingmode : troundingmode;
          procedure loadshifterop(opidx:longint;const so:tshifterop);
          procedure loadshifterop(opidx:longint;const so:tshifterop);
@@ -72,16 +72,15 @@ uses
 
 
          function is_same_reg_move(regtype: Tregistertype):boolean; override;
          function is_same_reg_move(regtype: Tregistertype):boolean; override;
 
 
-         { register spilling code }
-         function spilling_create_load(const ref:treference;r:tregister): tai;override;
-         function spilling_create_store(r:tregister; const ref:treference): tai;override;
-
          function spilling_get_operation_type(opnr: longint): topertype;override;
          function spilling_get_operation_type(opnr: longint): topertype;override;
       end;
       end;
       tai_align = class(tai_align_abstract)
       tai_align = class(tai_align_abstract)
         { nothing to add }
         { nothing to add }
       end;
       end;
 
 
+    function spilling_create_load(const ref:treference;r:tregister): tai;
+    function spilling_create_store(r:tregister; const ref:treference): tai;
+
     function setoppostfix(i : taicpu;pf : toppostfix) : taicpu;
     function setoppostfix(i : taicpu;pf : toppostfix) : taicpu;
     function setroundingmode(i : taicpu;rm : troundingmode) : taicpu;
     function setroundingmode(i : taicpu;rm : troundingmode) : taicpu;
     function setcondition(i : taicpu;c : tasmcond) : taicpu;
     function setcondition(i : taicpu;c : tasmcond) : taicpu;
@@ -319,15 +318,29 @@ implementation
       end;
       end;
 
 
 
 
-    function taicpu.spilling_create_load(const ref:treference;r:tregister): tai;
+    function spilling_create_load(const ref:treference;r:tregister): tai;
       begin
       begin
-        internalerror(200401261);
+        case getregtype(r) of
+          R_INTREGISTER :
+            result:=taicpu.op_reg_ref(A_LDR,r,ref);
+          R_FPUREGISTER :
+            result:=taicpu.op_reg_ref(A_LDF,r,ref);
+          else
+            internalerror(200401041);
+        end;
       end;
       end;
 
 
 
 
-    function taicpu.spilling_create_store(r:tregister; const ref:treference): tai;
+    function spilling_create_store(r:tregister; const ref:treference): tai;
       begin
       begin
-        internalerror(200401262);
+        case getregtype(r) of
+          R_INTREGISTER :
+            result:=taicpu.op_reg_ref(A_STR,r,ref);
+          R_FPUREGISTER :
+            result:=taicpu.op_reg_ref(A_STF,r,ref);
+          else
+            internalerror(200401041);
+        end;
       end;
       end;
 
 
 
 
@@ -473,7 +486,16 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.31  2004-03-29 19:19:35  florian
+  Revision 1.32  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.31.2.2  2004/06/13 10:51:17  florian
+    * fixed several register allocator problems (sparc/arm)
+
+  Revision 1.31.2.1  2004/06/12 17:01:01  florian
+    * fixed compilation of arm compiler
+
+  Revision 1.31  2004/03/29 19:19:35  florian
     + arm floating point register saving implemented
     + arm floating point register saving implemented
     * hopefully stabs generation for MacOSX fixed
     * hopefully stabs generation for MacOSX fixed
     + some defines for arm added
     + some defines for arm added

+ 8 - 9
compiler/arm/agarmgas.pas

@@ -63,16 +63,9 @@ unit agarmgas;
             asmbin : 'as';
             asmbin : 'as';
             asmcmd : '-o $OBJ $ASM';
             asmcmd : '-o $OBJ $ASM';
             supported_target : system_any;
             supported_target : system_any;
-            outputbinary: false;
-            allowdirect : true;
-            needar : true;
-            labelprefix_only_inside_procedure : false;
+            flags : [af_allowdirect,af_needar,af_smartlink_sections];
             labelprefix : '.L';
             labelprefix : '.L';
             comment : '# ';
             comment : '# ';
-            secnames : ('',
-              '.text','.data','.text',
-              '','','','','','',
-              '.stab','.stabstr','COMMON')
           );
           );
 
 
     function getreferencestring(var ref : treference) : string;
     function getreferencestring(var ref : treference) : string;
@@ -245,7 +238,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.19  2004-03-29 19:19:35  florian
+  Revision 1.20  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.19.2.1  2004/06/12 17:01:01  florian
+    * fixed compilation of arm compiler
+
+  Revision 1.19  2004/03/29 19:19:35  florian
     + arm floating point register saving implemented
     + arm floating point register saving implemented
     * hopefully stabs generation for MacOSX fixed
     * hopefully stabs generation for MacOSX fixed
     + some defines for arm added
     + some defines for arm added

+ 81 - 77
compiler/arm/armreg.dat

@@ -4,95 +4,99 @@
 ; ARM registers
 ; ARM registers
 ;
 ;
 ; layout
 ; layout
-; <name>,<type>,<value>,<stdname>,<stabidx>,<ot value>
+; <name>,<type>,<value>,<stdname>,<stab idx>,<dwarf idx>
 ;
 ;
-NO,$00,$00,INVALID,-1
+NO,$00,$00,INVALID,-1,-1
 ; Integer registers
 ; Integer registers
-R0,$01,$00,r0,0
-R1,$01,$01,r1,1
-R2,$01,$02,r2,2
-R3,$01,$03,r3,3
-R4,$01,$04,r4,4
-R5,$01,$05,r5,5
-R6,$01,$06,r6,6
-R7,$01,$07,r7,7
-R8,$01,$08,r8,8
-R9,$01,$09,r9,9
-R10,$01,$0a,r10,10
-R11,$01,$0b,r11,11
-R12,$01,$0c,r12,12
-R13,$01,$0d,r13,13
-R14,$01,$0e,r14,14
-R15,$01,$0f,r15,15
+R0,$01,$00,r0,0,0
+R1,$01,$01,r1,1,1
+R2,$01,$02,r2,2,2
+R3,$01,$03,r3,3,3
+R4,$01,$04,r4,4,4
+R5,$01,$05,r5,5,5
+R6,$01,$06,r6,6,6
+R7,$01,$07,r7,7,7
+R8,$01,$08,r8,8,8
+R9,$01,$09,r9,9,9
+R10,$01,$0a,r10,10,10
+R11,$01,$0b,r11,11,11
+R12,$01,$0c,r12,12,12
+R13,$01,$0d,r13,13,13
+R14,$01,$0e,r14,14,14
+R15,$01,$0f,r15,15,15
 
 
 ; Float registers
 ; Float registers
-F0,$02,$00,f0,32
-F1,$02,$01,f1,32
-F2,$02,$02,f2,32
-F3,$02,$03,f3,32
-F4,$02,$04,f4,32
-F5,$02,$05,f5,32
-F6,$02,$06,f6,32
-F7,$02,$07,f7,32
+F0,$02,$00,f0,32,16
+F1,$02,$01,f1,32,17
+F2,$02,$02,f2,32,18
+F3,$02,$03,f3,32,19
+F4,$02,$04,f4,32,20
+F5,$02,$05,f5,32,21
+F6,$02,$06,f6,32,22
+F7,$02,$07,f7,32,23
 
 
 ; MM registers
 ; MM registers
-S0,$03,$00,s0,0
-S1,$03,$00,s1,0
-D0,$03,$00,d0,0
-S2,$03,$00,s2,0
-S3,$03,$00,s3,0
-D1,$03,$00,d1,0
-S4,$03,$00,s4,0
-S5,$03,$00,s5,0
-D2,$03,$00,d2,0
-S6,$03,$00,s6,0
-S7,$03,$00,s7,0
-D3,$03,$00,d3,0
-S8,$03,$00,s8,0
-S9,$03,$00,s9,0
-D4,$03,$00,d4,0
-S10,$03,$00,s10,0
-S11,$03,$00,s11,0
-D5,$03,$00,d5,0
-S12,$03,$00,s12,0
-S13,$03,$00,s13,0
-D6,$03,$00,d6,0
-S14,$03,$00,s14,0
-S15,$03,$00,s15,0
-D7,$03,$00,d7,0
-S16,$03,$00,s16,0
-S17,$03,$00,s17,0
-D8,$03,$00,d8,0
-S18,$03,$00,s18,0
-S19,$03,$00,s19,0
-D9,$03,$00,d9,0
-S20,$03,$00,s20,0
-S21,$03,$00,s21,0
-D10,$03,$00,d10,0
-S22,$03,$00,s22,0
-S23,$03,$00,s23,0
-D11,$03,$00,d11,0
-S24,$03,$00,s24,0
-S25,$03,$00,s25,0
-D12,$03,$00,d12,0
-S26,$03,$00,s26,0
-S27,$03,$00,s27,0
-D13,$03,$00,d13,0
-S28,$03,$00,s28,0
-S29,$03,$00,s29,0
-D14,$03,$00,d14,0
-S30,$03,$00,s20,0
-S31,$03,$00,s21,0
-D15,$03,$00,d15,0
-
+S0,$03,$00,s0,0,0
+S1,$03,$00,s1,0,0
+D0,$03,$00,d0,0,0
+S2,$03,$00,s2,0,0
+S3,$03,$00,s3,0,0
+D1,$03,$00,d1,0,0
+S4,$03,$00,s4,0,0
+S5,$03,$00,s5,0,0
+D2,$03,$00,d2,0,0
+S6,$03,$00,s6,0,0
+S7,$03,$00,s7,0,0
+D3,$03,$00,d3,0,0
+S8,$03,$00,s8,0,0
+S9,$03,$00,s9,0,0
+D4,$03,$00,d4,0,0
+S10,$03,$00,s10,0,0
+S11,$03,$00,s11,0,0
+D5,$03,$00,d5,0,0
+S12,$03,$00,s12,0,0
+S13,$03,$00,s13,0,0
+D6,$03,$00,d6,0,0
+S14,$03,$00,s14,0,0
+S15,$03,$00,s15,0,0
+D7,$03,$00,d7,0,0
+S16,$03,$00,s16,0,0
+S17,$03,$00,s17,0,0
+D8,$03,$00,d8,0,0
+S18,$03,$00,s18,0,0
+S19,$03,$00,s19,0,0
+D9,$03,$00,d9,0,0
+S20,$03,$00,s20,0,0
+S21,$03,$00,s21,0,0
+D10,$03,$00,d10,0,0
+S22,$03,$00,s22,0,0
+S23,$03,$00,s23,0,0
+D11,$03,$00,d11,0,0
+S24,$03,$00,s24,0,0
+S25,$03,$00,s25,0,0
+D12,$03,$00,d12,0,0
+S26,$03,$00,s26,0,0
+S27,$03,$00,s27,0,0
+D13,$03,$00,d13,0,0
+S28,$03,$00,s28,0,0
+S29,$03,$00,s29,0,0
+D14,$03,$00,d14,0,0
+S30,$03,$00,s20,0,0
+S31,$03,$00,s21,0,0
+D15,$03,$00,d15,0,0
 
 
 ;
 ;
 ; $Log$
 ; $Log$
-; Revision 1.2  2003-09-09 12:53:39  florian
+; Revision 1.3  2004-06-16 20:07:10  florian
+;   * dwarf branch merged
+;
+; Revision 1.2.2.1  2004/06/12 17:01:01  florian
+;   * fixed compilation of arm compiler
+;
+; Revision 1.2  2003/09/09 12:53:39  florian
 ;   * some assembling problems fixed
 ;   * some assembling problems fixed
 ;   * improved loadaddr_ref_reg
 ;   * improved loadaddr_ref_reg
 ;
 ;
 ; Revision 1.1  2003/09/04 00:15:29  florian
 ; Revision 1.1  2003/09/04 00:15:29  florian
 ;   * first bunch of adaptions of arm compiler for new register type
 ;   * first bunch of adaptions of arm compiler for new register type
 ;
 ;
-;

+ 33 - 34
compiler/arm/cgcpu.pas

@@ -29,7 +29,7 @@ unit cgcpu;
   interface
   interface
 
 
     uses
     uses
-       symtype,
+       globtype,symtype,
        cgbase,cgobj,
        cgbase,cgobj,
        aasmbase,aasmcpu,aasmtai,
        aasmbase,aasmcpu,aasmtai,
        cpubase,cpuinfo,node,cg64f32,rgcpu;
        cpubase,cpuinfo,node,cg64f32,rgcpu;
@@ -42,23 +42,23 @@ unit cgcpu;
         procedure init_register_allocators;override;
         procedure init_register_allocators;override;
         procedure done_register_allocators;override;
         procedure done_register_allocators;override;
 
 
-        procedure a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);override;
+        procedure a_param_const(list : taasmoutput;size : tcgsize;a : aint;const locpara : tparalocation);override;
         procedure a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);override;
         procedure a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);override;
         procedure a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);override;
         procedure a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);override;
 
 
         procedure a_call_name(list : taasmoutput;const s : string);override;
         procedure a_call_name(list : taasmoutput;const s : string);override;
         procedure a_call_reg(list : taasmoutput;reg: tregister); override;
         procedure a_call_reg(list : taasmoutput;reg: tregister); override;
 
 
-        procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; reg: TRegister); override;
+        procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: aint; reg: TRegister); override;
         procedure a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister); override;
         procedure a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister); override;
 
 
         procedure a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
         procedure a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
-          size: tcgsize; a: aword; src, dst: tregister); override;
+          size: tcgsize; a: aint; src, dst: tregister); override;
         procedure a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
         procedure a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
           size: tcgsize; src1, src2, dst: tregister); override;
           size: tcgsize; src1, src2, dst: tregister); override;
 
 
         { move instructions }
         { move instructions }
-        procedure a_load_const_reg(list : taasmoutput; size: tcgsize; a : aword;reg : tregister);override;
+        procedure a_load_const_reg(list : taasmoutput; size: tcgsize; a : aint;reg : tregister);override;
         procedure a_load_reg_ref(list : taasmoutput; fromsize, tosize: tcgsize; reg : tregister;const ref : treference);override;
         procedure a_load_reg_ref(list : taasmoutput; fromsize, tosize: tcgsize; reg : tregister;const ref : treference);override;
         procedure a_load_ref_reg(list : taasmoutput; fromsize, tosize : tcgsize;const Ref : treference;reg : tregister);override;
         procedure a_load_ref_reg(list : taasmoutput; fromsize, tosize : tcgsize;const Ref : treference;reg : tregister);override;
         procedure a_load_reg_reg(list : taasmoutput; fromsize, tosize : tcgsize;reg1,reg2 : tregister);override;
         procedure a_load_reg_reg(list : taasmoutput; fromsize, tosize : tcgsize;reg1,reg2 : tregister);override;
@@ -69,7 +69,7 @@ unit cgcpu;
         procedure a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference); override;
         procedure a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference); override;
 
 
         {  comparison operations }
         {  comparison operations }
-        procedure a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
+        procedure a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aint;reg : tregister;
           l : tasmlabel);override;
           l : tasmlabel);override;
         procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); override;
         procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); override;
 
 
@@ -79,14 +79,13 @@ unit cgcpu;
 
 
         procedure g_flags2reg(list: taasmoutput; size: TCgSize; const f: TResFlags; reg: TRegister); override;
         procedure g_flags2reg(list: taasmoutput; size: TCgSize; const f: TResFlags; reg: TRegister); override;
 
 
-        procedure g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);override;
-        procedure g_stackframe_entry(list : taasmoutput;localsize : longint);override;
-        procedure g_return_from_proc(list : taasmoutput;parasize : aword); override;
-        procedure g_restore_frame_pointer(list : taasmoutput);override;
+        procedure g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aint);override;
+        procedure g_proc_entry(list : taasmoutput;localsize : longint;nostackframe:boolean);override;
+        procedure g_proc_exit(list : taasmoutput;parasize : longint;nostackframe:boolean); override;
 
 
         procedure a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);override;
         procedure a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);override;
 
 
-        procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword; delsource,loadref : boolean);override;
+        procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aint; delsource,loadref : boolean);override;
 
 
         procedure g_overflowcheck(list: taasmoutput; const l: tlocation; def: tdef); override;
         procedure g_overflowcheck(list: taasmoutput; const l: tlocation; def: tdef); override;
 
 
@@ -102,8 +101,8 @@ unit cgcpu;
 
 
       tcg64farm = class(tcg64f32)
       tcg64farm = class(tcg64f32)
         procedure a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);override;
         procedure a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);override;
-        procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;reg : tregister64);override;
-        procedure a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword;regsrc,regdst : tregister64);override;
+        procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : int64;reg : tregister64);override;
+        procedure a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : int64;regsrc,regdst : tregister64);override;
         procedure a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);override;
         procedure a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);override;
       end;
       end;
 
 
@@ -119,7 +118,7 @@ unit cgcpu;
 
 
 
 
     uses
     uses
-       globtype,globals,verbose,systems,cutils,
+       globals,verbose,systems,cutils,
        symconst,symdef,symsym,
        symconst,symdef,symsym,
        tgobj,
        tgobj,
        procinfo,cpupi,
        procinfo,cpupi,
@@ -170,7 +169,7 @@ unit cgcpu;
       end;
       end;
 
 
 
 
-    procedure tcgarm.a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);
+    procedure tcgarm.a_param_const(list : taasmoutput;size : tcgsize;a : aint;const locpara : tparalocation);
       var
       var
         ref: treference;
         ref: treference;
       begin
       begin
@@ -268,7 +267,7 @@ unit cgcpu;
       end;
       end;
 
 
 
 
-     procedure tcgarm.a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; reg: TRegister);
+     procedure tcgarm.a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: aint; reg: TRegister);
        begin
        begin
           a_op_const_reg_reg(list,op,size,a,reg,reg);
           a_op_const_reg_reg(list,op,size,a,reg,reg);
        end;
        end;
@@ -294,7 +293,7 @@ unit cgcpu;
 
 
 
 
      procedure tcgarm.a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
      procedure tcgarm.a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
-       size: tcgsize; a: aword; src, dst: tregister);
+       size: tcgsize; a: aint; src, dst: tregister);
        var
        var
          shift : byte;
          shift : byte;
          tmpreg : tregister;
          tmpreg : tregister;
@@ -468,7 +467,7 @@ unit cgcpu;
        end;
        end;
 
 
 
 
-     procedure tcgarm.a_load_const_reg(list : taasmoutput; size: tcgsize; a : aword;reg : tregister);
+     procedure tcgarm.a_load_const_reg(list : taasmoutput; size: tcgsize; a : aint;reg : tregister);
        var
        var
           imm_shift : byte;
           imm_shift : byte;
           l : tasmlabel;
           l : tasmlabel;
@@ -547,7 +546,7 @@ unit cgcpu;
             tmpref.symboldata:=current_procinfo.aktlocaldata.last;
             tmpref.symboldata:=current_procinfo.aktlocaldata.last;
 
 
             if assigned(ref.symbol) then
             if assigned(ref.symbol) then
-              current_procinfo.aktlocaldata.concat(tai_const_symbol.Create_offset(ref.symbol,ref.offset))
+              current_procinfo.aktlocaldata.concat(tai_const.create_sym_offset(ref.symbol,ref.offset))
             else
             else
               current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(ref.offset));
               current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(ref.offset));
 
 
@@ -777,7 +776,7 @@ unit cgcpu;
 
 
 
 
     {  comparison operations }
     {  comparison operations }
-    procedure tcgarm.a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
+    procedure tcgarm.a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aint;reg : tregister;
       l : tasmlabel);
       l : tasmlabel);
       var
       var
         tmpreg : tregister;
         tmpreg : tregister;
@@ -838,12 +837,12 @@ unit cgcpu;
       end;
       end;
 
 
 
 
-    procedure tcgarm.g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);
+    procedure tcgarm.g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aint);
       begin
       begin
       end;
       end;
 
 
 
 
-    procedure tcgarm.g_stackframe_entry(list : taasmoutput;localsize : longint);
+    procedure tcgarm.g_proc_entry(list : taasmoutput;localsize : longint;nostackframe:boolean);
       var
       var
          ref : treference;
          ref : treference;
          shift : byte;
          shift : byte;
@@ -900,7 +899,7 @@ unit cgcpu;
       end;
       end;
 
 
 
 
-    procedure tcgarm.g_return_from_proc(list : taasmoutput;parasize : aword);
+    procedure tcgarm.g_proc_exit(list : taasmoutput;parasize : longint;nostackframe:boolean);
       var
       var
          ref : treference;
          ref : treference;
          firstfloatreg,lastfloatreg,
          firstfloatreg,lastfloatreg,
@@ -937,12 +936,6 @@ unit cgcpu;
       end;
       end;
 
 
 
 
-    procedure tcgarm.g_restore_frame_pointer(list : taasmoutput);
-      begin
-         { the frame pointer on the ARM is restored while the ret is executed }
-      end;
-
-
     procedure tcgarm.a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);
     procedure tcgarm.a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);
       var
       var
         b : byte;
         b : byte;
@@ -1022,7 +1015,7 @@ unit cgcpu;
         tmpref.symboldata:=current_procinfo.aktlocaldata.last;
         tmpref.symboldata:=current_procinfo.aktlocaldata.last;
 
 
         if assigned(ref.symbol) then
         if assigned(ref.symbol) then
-          current_procinfo.aktlocaldata.concat(tai_const_symbol.Create_offset(ref.symbol,ref.offset))
+          current_procinfo.aktlocaldata.concat(tai_const.create_sym_offset(ref.symbol,ref.offset))
         else
         else
           current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(ref.offset));
           current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(ref.offset));
 
 
@@ -1055,7 +1048,7 @@ unit cgcpu;
       end;
       end;
 
 
 
 
-    procedure tcgarm.g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword; delsource,loadref : boolean);
+    procedure tcgarm.g_concatcopy(list : taasmoutput;const source,dest : treference;len : aint; delsource,loadref : boolean);
       var
       var
         srcref,dstref:treference;
         srcref,dstref:treference;
         srcreg,destreg,countreg,r:tregister;
         srcreg,destreg,countreg,r:tregister;
@@ -1234,13 +1227,13 @@ unit cgcpu;
       end;
       end;
 
 
 
 
-    procedure tcg64farm.a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;reg : tregister64);
+    procedure tcg64farm.a_op64_const_reg(list : taasmoutput;op:TOpCG;value : int64;reg : tregister64);
       begin
       begin
         a_op64_const_reg_reg(list,op,value,reg,reg);
         a_op64_const_reg_reg(list,op,value,reg,reg);
       end;
       end;
 
 
 
 
-    procedure tcg64farm.a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword;regsrc,regdst : tregister64);
+    procedure tcg64farm.a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : int64;regsrc,regdst : tregister64);
       var
       var
         tmpreg : tregister;
         tmpreg : tregister;
         b : byte;
         b : byte;
@@ -1331,7 +1324,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.51  2004-03-31 19:13:04  florian
+  Revision 1.52  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.51.2.1  2004/06/12 17:01:01  florian
+    * fixed compilation of arm compiler
+
+  Revision 1.51  2004/03/31 19:13:04  florian
     * concatcopy with len=0 exits now immediatly
     * concatcopy with len=0 exits now immediatly
 
 
   Revision 1.50  2004/03/29 19:19:35  florian
   Revision 1.50  2004/03/29 19:19:35  florian

+ 36 - 2
compiler/arm/cpubase.pas

@@ -121,6 +121,9 @@ unit cpubase;
         {$i rarmsta.inc}
         {$i rarmsta.inc}
       );
       );
 
 
+      regdwarf_table : array[tregisterindex] of shortint = (
+        {$i rarmdwa.inc}
+      );
       { registers which may be destroyed by calls }
       { registers which may be destroyed by calls }
       VOLATILE_INTREGISTERS = [RS_R0..RS_R3,RS_R12..RS_R15];
       VOLATILE_INTREGISTERS = [RS_R0..RS_R3,RS_R12..RS_R15];
       VOLATILE_FPUREGISTERS = [RS_F0..RS_F3];
       VOLATILE_FPUREGISTERS = [RS_F0..RS_F3];
@@ -291,7 +294,7 @@ unit cpubase;
                 { lo(valueqword)/hi(valueqword) instead (JM)              }
                 { lo(valueqword)/hi(valueqword) instead (JM)              }
                 { 2 : (valuelow, valuehigh:AWord);                        }
                 { 2 : (valuelow, valuehigh:AWord);                        }
                 { overlay a complete 64 Bit value }
                 { overlay a complete 64 Bit value }
-                3 : (valueqword : qword);
+                3 : (value64 : qword);
               );
               );
             LOC_CREFERENCE,
             LOC_CREFERENCE,
             LOC_REFERENCE : (reference : treference);
             LOC_REFERENCE : (reference : treference);
@@ -435,6 +438,8 @@ unit cpubase;
 
 
       NR_MM_RESULT_REG  = NR_NO;
       NR_MM_RESULT_REG  = NR_NO;
 
 
+      NR_RETURN_ADDRESS_REG = NR_FUNCTION_RETURN_REG;
+
       { Offset where the parent framepointer is pushed }
       { Offset where the parent framepointer is pushed }
       PARENT_FRAMEPOINTER_OFFSET = 0;
       PARENT_FRAMEPOINTER_OFFSET = 0;
 
 
@@ -465,6 +470,8 @@ unit cpubase;
                                   Helpers
                                   Helpers
 *****************************************************************************}
 *****************************************************************************}
 
 
+    { Returns the tcgsize corresponding with the size of reg.}
+    function reg_cgsize(const reg: tregister) : tcgsize;
     function cgsize2subreg(s:Tcgsize):Tsubregister;
     function cgsize2subreg(s:Tcgsize):Tsubregister;
     function is_calljmp(o:tasmop):boolean;
     function is_calljmp(o:tasmop):boolean;
     procedure inverse_flags(var f: TResFlags);
     procedure inverse_flags(var f: TResFlags);
@@ -502,6 +509,21 @@ unit cpubase;
       end;
       end;
 
 
 
 
+    function reg_cgsize(const reg: tregister): tcgsize;
+      const subreg2cgsize:array[Tsubregister] of Tcgsize =
+            (OS_NO,OS_8,OS_8,OS_16,OS_32,OS_64,OS_NO,OS_NO);
+      begin
+        case getregtype(reg) of
+          R_INTREGISTER :
+            reg_cgsize:=OS_32;
+          R_FPUREGISTER :
+            reg_cgsize:=OS_F80;
+          else
+            internalerror(200303181);
+          end;
+        end;
+
+
     function is_calljmp(o:tasmop):boolean;
     function is_calljmp(o:tasmop):boolean;
       begin
       begin
         { This isn't 100% perfect because the arm allows jumps also by writing to PC=R15.
         { This isn't 100% perfect because the arm allows jumps also by writing to PC=R15.
@@ -570,7 +592,19 @@ unit cpubase;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.29  2004-03-23 21:03:50  florian
+  Revision 1.30  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.29.2.3  2004/06/13 10:51:17  florian
+    * fixed several register allocator problems (sparc/arm)
+
+  Revision 1.29.2.2  2004/06/12 17:01:01  florian
+    * fixed compilation of arm compiler
+
+  Revision 1.29.2.1  2004/05/01 11:12:23  florian
+    * spilling of registers with size<>4 fixed
+
+  Revision 1.29  2004/03/23 21:03:50  florian
     * arm assembler instructions can have 4 operands
     * arm assembler instructions can have 4 operands
     * qword comparisations fixed
     * qword comparisations fixed
 
 

+ 9 - 19
compiler/arm/cpuinfo.pas

@@ -21,21 +21,6 @@ Interface
     globtype;
     globtype;
 
 
 Type
 Type
-   { Architecture word - Native unsigned type }
-   AWord  = Longword;
-   AInt = longint;
-   PAWord = ^AWord;
-   PAInt = ^AInt;
-
-   { this must be an ordinal type with the same size as a pointer }
-   { to allow some dirty type casts for example when using        }
-   { tconstsym.value                                              }
-   { Note: must be unsigned!! Otherwise, ugly code like           }
-   { pointer(-1) will result in a pointer with the value          }
-   { $fffffffffffffff on a 32bit machine if the compiler uses     }
-   { int64 constants internally (JM)                              }
-   TConstPtrUInt = Longword;
-
    bestreal = double;
    bestreal = double;
    ts32real = single;
    ts32real = single;
    ts64real = double;
    ts64real = double;
@@ -66,8 +51,6 @@ Type
 Const
 Const
    {# Size of native extended floating point type }
    {# Size of native extended floating point type }
    extended_size = 8;
    extended_size = 8;
-   {# Size of a pointer                           }
-   pointer_size  = 4;
    {# Size of a multimedia register               }
    {# Size of a multimedia register               }
    mmreg_size = 16;
    mmreg_size = 16;
    { target cpu string (used by compiler options) }
    { target cpu string (used by compiler options) }
@@ -114,9 +97,16 @@ Implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2004-04-28 15:19:03  florian
+  Revision 1.8  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.7  2004/04/28 15:19:03  florian
     + syscall directive support for MorphOS added
     + syscall directive support for MorphOS added
 
 
+  Revision 1.6.2.1  2004/05/01 16:02:10  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
   Revision 1.6  2004/03/06 20:35:19  florian
   Revision 1.6  2004/03/06 20:35:19  florian
     * fixed arm compilation
     * fixed arm compilation
     * cleaned up code generation for exported linux procedures
     * cleaned up code generation for exported linux procedures
@@ -141,4 +131,4 @@ end.
 
 
   Revision 1.1  2003/07/21 16:35:30  florian
   Revision 1.1  2003/07/21 16:35:30  florian
     * very basic stuff for the arm
     * very basic stuff for the arm
-}
+}

+ 11 - 5
compiler/arm/cpupara.pas

@@ -40,12 +40,12 @@ unit cpupara;
           function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
           function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
           function getintparaloc(calloption : tproccalloption; nr : longint) : tparalocation;override;
           function getintparaloc(calloption : tproccalloption; nr : longint) : tparalocation;override;
           procedure alloctempparaloc(list: taasmoutput;calloption : tproccalloption;paraitem : tparaitem;var locpara:tparalocation);override;
           procedure alloctempparaloc(list: taasmoutput;calloption : tproccalloption;paraitem : tparaitem;var locpara:tparalocation);override;
-          function  create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;override;
+          function create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;override;
           function create_varargs_paraloc_info(p : tabstractprocdef; varargspara:tvarargspara):longint;override;
           function create_varargs_paraloc_info(p : tabstractprocdef; varargspara:tvarargspara):longint;override;
          private
          private
-           procedure init_values(var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword);
-           function create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee; firstpara: tparaitem;
-               var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword):longint;
+          procedure init_values(var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword);
+          function create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee; firstpara: tparaitem;
+            var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword):longint;
        end;
        end;
 
 
   implementation
   implementation
@@ -438,7 +438,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.17  2004-03-20 21:11:01  florian
+  Revision 1.18  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.17.2.1  2004/06/13 20:38:38  florian
+    * fixed floating point register spilling on sparc
+
+  Revision 1.17  2004/03/20 21:11:01  florian
     + float parameters can be on the stack now as well
     + float parameters can be on the stack now as well
 
 
   Revision 1.16  2004/03/20 20:55:36  florian
   Revision 1.16  2004/03/20 20:55:36  florian

+ 13 - 55
compiler/arm/cpupi.pas

@@ -29,13 +29,12 @@ unit cpupi;
   interface
   interface
 
 
     uses
     uses
-       cutils,
+       globtype,cutils,
        procinfo,cpuinfo,psub;
        procinfo,cpuinfo,psub;
 
 
     type
     type
        tarmprocinfo = class(tcgprocinfo)
        tarmprocinfo = class(tcgprocinfo)
           floatregstart : aword;
           floatregstart : aword;
-          constructor create(aparent:tprocinfo);override;
           // procedure handle_body_start;override;
           // procedure handle_body_start;override;
           // procedure after_pass1;override;
           // procedure after_pass1;override;
           procedure set_first_temp_offset;override;
           procedure set_first_temp_offset;override;
@@ -47,7 +46,7 @@ unit cpupi;
   implementation
   implementation
 
 
     uses
     uses
-       globtype,globals,systems,
+       globals,systems,
        cpubase,
        cpubase,
        aasmtai,
        aasmtai,
        tgobj,
        tgobj,
@@ -55,57 +54,6 @@ unit cpupi;
        cgbase,
        cgbase,
        cgobj;
        cgobj;
 
 
-    constructor tarmprocinfo.create(aparent:tprocinfo);
-
-      begin
-         inherited create(aparent);
-         maxpushedparasize:=0;
-      end;
-
-(*
-    procedure tarmprocinfo.handle_body_start;
-      var
-         ofs : aword;
-      begin
-        if not(po_assembler in procdef.procoptions) then
-          begin
-            {!!!!!!!!
-            case target_info.abi of
-              abi_powerpc_aix:
-                ofs:=align(maxpushedparasize+LinkageAreaSizeAIX,16);
-              abi_powerpc_sysv:
-                ofs:=align(maxpushedparasize+LinkageAreaSizeSYSV,16);
-            end;
-            }
-            inc(procdef.parast.address_fixup,ofs);
-            procdef.localst.address_fixup:=procdef.parast.address_fixup+procdef.parast.datasize;
-          end;
-        inherited handle_body_start;
-      end;
-
-    procedure tarmprocinfo.after_pass1;
-      begin
-         if not(po_assembler in procdef.procoptions) then
-           begin
-             if cs_asm_source in aktglobalswitches then
-               aktproccode.insert(Tai_comment.Create(strpnew('Parameter copies start at: r1+'+tostr(procdef.parast.address_fixup))));
-
-             if cs_asm_source in aktglobalswitches then
-               aktproccode.insert(Tai_comment.Create(strpnew('Locals start at: r1+'+tostr(procdef.localst.address_fixup))));
-
-             firsttemp_offset:=align(procdef.localst.address_fixup+procdef.localst.datasize,16);
-             if cs_asm_source in aktglobalswitches then
-               aktproccode.insert(Tai_comment.Create(strpnew('Temp. space start: r1+'+tostr(firsttemp_offset))));
-
-             //!!!! tg.setfirsttemp(firsttemp_offset);
-             tg.firsttemp:=firsttemp_offset;
-             tg.lasttemp:=firsttemp_offset;
-             inherited after_pass1;
-           end;
-      end;
-*)
-
-
     procedure tarmprocinfo.set_first_temp_offset;
     procedure tarmprocinfo.set_first_temp_offset;
       begin
       begin
         { We allocate enough space to save all registers because we can't determine
         { We allocate enough space to save all registers because we can't determine
@@ -119,6 +67,7 @@ unit cpupi;
         tg.setfirsttemp(-12-28);
         tg.setfirsttemp(-12-28);
       end;
       end;
 
 
+
     procedure tarmprocinfo.allocate_push_parasize(size:longint);
     procedure tarmprocinfo.allocate_push_parasize(size:longint);
       begin
       begin
         if size>maxpushedparasize then
         if size>maxpushedparasize then
@@ -157,7 +106,16 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2004-03-29 19:19:35  florian
+  Revision 1.8  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.7.2.2  2004/06/12 17:01:01  florian
+    * fixed compilation of arm compiler
+
+  Revision 1.7.2.1  2004/04/23 22:12:37  florian
+    * fixed some potential stack corruption reasons
+
+  Revision 1.7  2004/03/29 19:19:35  florian
     + arm floating point register saving implemented
     + arm floating point register saving implemented
     * hopefully stabs generation for MacOSX fixed
     * hopefully stabs generation for MacOSX fixed
     + some defines for arm added
     + some defines for arm added

+ 74 - 0
compiler/arm/rarmdwa.inc

@@ -0,0 +1,74 @@
+{ don't edit, this file is generated from armreg.dat }
+-1,
+0,
+1,
+2,
+3,
+4,
+5,
+6,
+7,
+8,
+9,
+10,
+11,
+12,
+13,
+14,
+15,
+16,
+17,
+18,
+19,
+20,
+21,
+22,
+23,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0,
+0

+ 68 - 48
compiler/arm/rgcpu.pas

@@ -29,7 +29,7 @@ unit rgcpu;
   interface
   interface
 
 
      uses
      uses
-       aasmbase,aasmtai,
+       aasmbase,aasmtai,aasmcpu,
        cgbase,
        cgbase,
        cpubase,
        cpubase,
        rgobj;
        rgobj;
@@ -37,11 +37,11 @@ unit rgcpu;
      type
      type
        trgcpu = class(trgobj)
        trgcpu = class(trgobj)
          procedure add_cpu_interferences(p : tai);override;
          procedure add_cpu_interferences(p : tai);override;
-         procedure do_spill_read(list : taasmoutput;instr : taicpu_abstract;pos: tai; regidx: word;
+         procedure do_spill_read(list : taasmoutput;instr : taicpu;pos: tai; regidx: word;
           const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);override;
           const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);override;
-         procedure do_spill_written(list : taasmoutput;instr : taicpu_abstract;pos: tai; regidx: word;
+         procedure do_spill_written(list : taasmoutput;instr : taicpu;pos: tai; regidx: word;
           const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);override;
           const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);override;
-         procedure do_spill_readwritten(list : taasmoutput;instr : taicpu_abstract;pos: tai; regidx: word;
+         procedure do_spill_readwritten(list : taasmoutput;instr : taicpu;pos: tai; regidx: word;
           const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);override;
           const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);override;
        end;
        end;
 
 
@@ -50,8 +50,7 @@ unit rgcpu;
     uses
     uses
       verbose, cutils,
       verbose, cutils,
       cgutils,cgobj,
       cgutils,cgobj,
-      procinfo,
-      aasmcpu;
+      procinfo;
 
 
 
 
     procedure trgcpu.add_cpu_interferences(p : tai);
     procedure trgcpu.add_cpu_interferences(p : tai);
@@ -64,7 +63,7 @@ unit rgcpu;
       end;
       end;
 
 
 
 
-    procedure trgcpu.do_spill_read(list : taasmoutput;instr : taicpu_abstract;pos: tai; regidx: word;
+    procedure trgcpu.do_spill_read(list : taasmoutput;instr : taicpu;pos: tai; regidx: word;
      const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);
      const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);
       var
       var
         helpins: tai;
         helpins: tai;
@@ -86,7 +85,10 @@ unit rgcpu;
             current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(ref.offset));
             current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(ref.offset));
 
 
             { load consts entry }
             { load consts entry }
-            getregisterinline(helplist,nil,defaultsub,tmpreg);
+            if getregtype(regs[regidx].tempreg)=R_INTREGISTER then
+              getregisterinline(helplist,pos,defaultsub,tmpreg)
+            else
+              tmpreg:=cg.getintregister(helplist,OS_ADDR);
             tmpref.symbol:=l;
             tmpref.symbol:=l;
             tmpref.base:=NR_R15;
             tmpref.base:=NR_R15;
             helplist.concat(taicpu.op_reg_ref(A_LDR,tmpreg,tmpref));
             helplist.concat(taicpu.op_reg_ref(A_LDR,tmpreg,tmpref));
@@ -96,34 +98,28 @@ unit rgcpu;
             ref.index:=tmpreg;
             ref.index:=tmpreg;
             ref.offset:=0;
             ref.offset:=0;
 
 
-            helpins:=taicpu.op_reg_ref(A_LDR,regs[regidx].tempreg,ref);
+            helpins:=spilling_create_load(ref,regs[regidx].tempreg);
             helplist.concat(helpins);
             helplist.concat(helpins);
             if pos=nil then
             if pos=nil then
               list.insertlistafter(list.first,helplist)
               list.insertlistafter(list.first,helplist)
             else
             else
               list.insertlistafter(pos.next,helplist);
               list.insertlistafter(pos.next,helplist);
 
 
-            ungetregisterinline(helplist,tai(helplist.last),regs[regidx].tempreg);
+            ungetregisterinline(list,helpins,regs[regidx].tempreg);
+
+            if getregtype(regs[regidx].tempreg)=R_INTREGISTER then
+              ungetregisterinline(list,helpins,tmpreg);
 
 
-            ungetregisterinline(list,instr,regs[regidx].tempreg);
             forward_allocation(tai(helpins.next),instr);
             forward_allocation(tai(helpins.next),instr);
 
 
             helplist.free;
             helplist.free;
           end
           end
         else
         else
-          begin
-            helpins:=taicpu.op_reg_ref(A_LDR,regs[regidx].tempreg,ref);
-            if pos=nil then
-              list.insertafter(helpins,list.first)
-            else
-              list.insertafter(helpins,pos.next);
-            ungetregisterinline(list,instr,regs[regidx].tempreg);
-            forward_allocation(tai(helpins.next),instr);
-          end;
+          inherited do_spill_read(list,instr,pos,regidx,spilltemplist,regs);
       end;
       end;
 
 
 
 
-    procedure trgcpu.do_spill_written(list : taasmoutput;instr : taicpu_abstract;pos: tai; regidx: word;
+    procedure trgcpu.do_spill_written(list : taasmoutput;instr : taicpu;pos: tai; regidx: word;
       const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);
       const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);
       var
       var
         helpins: tai;
         helpins: tai;
@@ -145,7 +141,10 @@ unit rgcpu;
             current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(ref.offset));
             current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(ref.offset));
 
 
             { load consts entry }
             { load consts entry }
-            getregisterinline(helplist,nil,defaultsub,tmpreg);
+            if getregtype(regs[regidx].tempreg)=R_INTREGISTER then
+              getregisterinline(helplist,pos,defaultsub,tmpreg)
+            else
+              tmpreg:=cg.getintregister(helplist,OS_ADDR);
             tmpref.symbol:=l;
             tmpref.symbol:=l;
             tmpref.base:=NR_R15;
             tmpref.base:=NR_R15;
             helplist.concat(taicpu.op_reg_ref(A_LDR,tmpreg,tmpref));
             helplist.concat(taicpu.op_reg_ref(A_LDR,tmpreg,tmpref));
@@ -155,36 +154,33 @@ unit rgcpu;
             ref.index:=tmpreg;
             ref.index:=tmpreg;
             ref.offset:=0;
             ref.offset:=0;
 
 
-            helplist.concat(taicpu.op_reg_ref(A_STR,regs[regidx].tempreg,ref));
+            helplist.concat(spilling_create_store(regs[regidx].tempreg,ref));
             ungetregisterinline(helplist,tai(helplist.last),regs[regidx].tempreg);
             ungetregisterinline(helplist,tai(helplist.last),regs[regidx].tempreg);
-            ungetregisterinline(helplist,tai(helplist.last),tmpreg);
+            if getregtype(regs[regidx].tempreg)=R_INTREGISTER then
+              ungetregisterinline(helplist,tai(helplist.last),tmpreg);
 
 
             list.insertlistafter(instr,helplist);
             list.insertlistafter(instr,helplist);
 
 
             helplist.free;
             helplist.free;
           end
           end
         else
         else
-          begin
-            helpins:=taicpu.op_reg_ref(A_STR,regs[regidx].tempreg,ref);
-            list.insertafter(helpins,instr);
-            ungetregisterinline(list,helpins,regs[regidx].tempreg);
-          end;
+          inherited do_spill_written(list,instr,pos,regidx,spilltemplist,regs);
       end;
       end;
 
 
 
 
-    procedure trgcpu.do_spill_readwritten(list : taasmoutput;instr : taicpu_abstract;pos: tai; regidx: word;
+    procedure trgcpu.do_spill_readwritten(list : taasmoutput;instr : taicpu;pos: tai; regidx: word;
       const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);
       const spilltemplist:Tspill_temp_list;const regs : tspillregsinfo);
       var
       var
         helpins1, helpins2: tai;
         helpins1, helpins2: tai;
         tmpref,ref : treference;
         tmpref,ref : treference;
+        helplist : taasmoutput;
+        l : tasmlabel;
         tmpreg : tregister;
         tmpreg : tregister;
-
       begin
       begin
         ref:=spilltemplist[regs[regidx].orgreg];
         ref:=spilltemplist[regs[regidx].orgreg];
-        internalerror(200403141);
-        {
         if abs(ref.offset)>4095 then
         if abs(ref.offset)>4095 then
           begin
           begin
+            helplist:=taasmoutput.create;
             reference_reset(tmpref);
             reference_reset(tmpref);
             { create consts entry }
             { create consts entry }
             objectlibrary.getlabel(l);
             objectlibrary.getlabel(l);
@@ -194,35 +190,59 @@ unit rgcpu;
             current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(ref.offset));
             current_procinfo.aktlocaldata.concat(tai_const.Create_32bit(ref.offset));
 
 
             { load consts entry }
             { load consts entry }
-            getregisterinline(list,pos,defaultsub,tmpreg);
+            if getregtype(regs[regidx].tempreg)=R_INTREGISTER then
+              getregisterinline(helplist,pos,defaultsub,tmpreg)
+            else
+              tmpreg:=cg.getintregister(helplist,OS_ADDR);
             tmpref.symbol:=l;
             tmpref.symbol:=l;
             tmpref.base:=NR_R15;
             tmpref.base:=NR_R15;
-            list.concat(taicpu.op_reg_ref(A_LDR,tmpreg,tmpref));
+            helplist.concat(taicpu.op_reg_ref(A_LDR,tmpreg,tmpref));
 
 
             if ref.index<>NR_NO then
             if ref.index<>NR_NO then
               internalerror(200401263);
               internalerror(200401263);
             ref.index:=tmpreg;
             ref.index:=tmpreg;
             ref.offset:=0;
             ref.offset:=0;
-          end;
-        }
-        helpins1:=taicpu.op_reg_ref(A_LDR,regs[regidx].tempreg,ref);
-        if pos=nil then
-          list.insertafter(helpins1,list.first)
+
+            helpins1:=spilling_create_load(ref,regs[regidx].tempreg);
+            helplist.concat(helpins1);
+            if pos=nil then
+              list.insertlistafter(list.first,helplist)
+            else
+              list.insertlistafter(pos.next,helplist);
+
+            helpins2:=spilling_create_store(regs[regidx].tempreg,ref);
+            list.insertafter(helpins2,instr);
+            ungetregisterinline(list,helpins2,regs[regidx].tempreg);
+
+            if getregtype(regs[regidx].tempreg)=R_INTREGISTER then
+              ungetregisterinline(list,helpins2,tmpreg);
+
+            forward_allocation(tai(helpins1.next),instr);
+          end
         else
         else
-          list.insertafter(helpins1,pos.next);
-        ref:=spilltemplist[regs[regidx].orgreg];
-        ref.symboldata:=nil;
-        helpins2:=taicpu.op_reg_ref(A_STR,regs[regidx].tempreg,ref);
-        list.insertafter(helpins2,instr);
-        ungetregisterinline(list,helpins2,regs[regidx].tempreg);
-        forward_allocation(tai(helpins1.next),instr);
+          inherited do_spill_readwritten(list,instr,pos,regidx,spilltemplist,regs);
       end;
       end;
 
 
 end.
 end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2004-03-14 16:15:40  florian
+  Revision 1.11  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.10.2.4  2004/06/13 20:38:38  florian
+    * fixed floating point register spilling on sparc
+
+  Revision 1.10.2.3  2004/06/13 16:02:39  florian
+    * fixed floating point register spilling problems with offsets > 4095
+
+  Revision 1.10.2.2  2004/06/13 10:51:17  florian
+    * fixed several register allocator problems (sparc/arm)
+
+  Revision 1.10.2.1  2004/06/12 17:01:01  florian
+    * fixed compilation of arm compiler
+
+  Revision 1.10  2004/03/14 16:15:40  florian
     * spilling problem fixed
     * spilling problem fixed
     * handling of floating point memory references fixed
     * handling of floating point memory references fixed
 
 

+ 189 - 185
compiler/assemble.pas

@@ -1,6 +1,6 @@
 {
 {
     $Id$
     $Id$
-    Copyright (c) 1998-2002 by Peter Vreman
+    Copyright (c) 1998-2004 by Peter Vreman
 
 
     This unit handles the assemblerfile write and assembler calls of FPC
     This unit handles the assemblerfile write and assembler calls of FPC
 
 
@@ -134,8 +134,6 @@ interface
         destructor  destroy;override;
         destructor  destroy;override;
         procedure MakeObject;override;
         procedure MakeObject;override;
       protected
       protected
-        { object alloc and output }
-        objectalloc  : TAsmObjectAlloc;
         objectdata   : TAsmObjectData;
         objectdata   : TAsmObjectData;
         objectoutput : tobjectoutput;
         objectoutput : tobjectoutput;
       private
       private
@@ -156,7 +154,7 @@ interface
         procedure emitlineinfostabs(nidx,line : longint);
         procedure emitlineinfostabs(nidx,line : longint);
         procedure emitstabs(s:string);
         procedure emitstabs(s:string);
         procedure WriteFileLineInfo(var fileinfo : tfileposinfo);
         procedure WriteFileLineInfo(var fileinfo : tfileposinfo);
-        procedure StartFileLineInfo(sec:tsection);
+        procedure StartFileLineInfo;
         procedure EndFileLineInfo;
         procedure EndFileLineInfo;
 {$endif}
 {$endif}
         function  MaybeNextList(var hp:Tai):boolean;
         function  MaybeNextList(var hp:Tai):boolean;
@@ -188,6 +186,7 @@ Implementation
   {$endif}
   {$endif}
 {$endif}
 {$endif}
       cutils,script,fmodule,verbose,
       cutils,script,fmodule,verbose,
+      cpuinfo,
 {$ifdef memdebug}
 {$ifdef memdebug}
       cclasses,
       cclasses,
 {$endif memdebug}
 {$endif memdebug}
@@ -617,7 +616,6 @@ Implementation
         inherited create(smart);
         inherited create(smart);
         objectoutput:=nil;
         objectoutput:=nil;
         objectdata:=nil;
         objectdata:=nil;
-        objectalloc:=TAsmObjectAlloc.create;
         SmartAsm:=smart;
         SmartAsm:=smart;
         currpass:=0;
         currpass:=0;
       end;
       end;
@@ -634,7 +632,6 @@ Implementation
 {$endif}
 {$endif}
         objectdata.free;
         objectdata.free;
         objectoutput.free;
         objectoutput.free;
-        objectalloc.free;
 {$ifdef MEMDEBUG}
 {$ifdef MEMDEBUG}
         d.free;
         d.free;
 {$endif}
 {$endif}
@@ -649,14 +646,12 @@ Implementation
         code : integer;
         code : integer;
         hp : pchar;
         hp : pchar;
         reloc : boolean;
         reloc : boolean;
-        sec : TSection;
         ps : tasmsymbol;
         ps : tasmsymbol;
         s : string;
         s : string;
       begin
       begin
         ofs:=0;
         ofs:=0;
         reloc:=true;
         reloc:=true;
         ps:=nil;
         ps:=nil;
-        sec:=sec_none;
         if p[0]='"' then
         if p[0]='"' then
          begin
          begin
            i:=1;
            i:=1;
@@ -677,7 +672,7 @@ Implementation
       { When in pass 1 then only alloc and leave }
       { When in pass 1 then only alloc and leave }
         if currpass=1 then
         if currpass=1 then
          begin
          begin
-           objectalloc.staballoc(hp);
+           objectdata.allocstabs(hp);
            if assigned(hp) then
            if assigned(hp) then
             p[i]:='"';
             p[i]:='"';
            exit;
            exit;
@@ -755,7 +750,6 @@ Implementation
                   internalerror(33006)
                   internalerror(33006)
                 else
                 else
                   begin
                   begin
-                    sec:=ps.section;
                     ofs:=ofs+ps.address;
                     ofs:=ofs+ps.address;
                     reloc:=true;
                     reloc:=true;
                     objectlibrary.UsedAsmSymbolListInsert(ps);
                     objectlibrary.UsedAsmSymbolListInsert(ps);
@@ -777,7 +771,7 @@ Implementation
                       internalerror(33007)
                       internalerror(33007)
                     else
                     else
                       begin
                       begin
-                        if ps.section<>sec then
+                        if ps.section<>objectdata.currsec then
                           internalerror(33008);
                           internalerror(33008);
                         ofs:=ofs-ps.address;
                         ofs:=ofs-ps.address;
                         reloc:=false;
                         reloc:=false;
@@ -787,47 +781,35 @@ Implementation
               end;
               end;
           end;
           end;
         { external bss need speical handling (PM) }
         { external bss need speical handling (PM) }
-        if assigned(ps) and (ps.section=sec_none) then
+        if assigned(ps) and (ps.section=nil) then
           begin
           begin
             if currpass=2 then
             if currpass=2 then
               begin
               begin
                 objectdata.writesymbol(ps);
                 objectdata.writesymbol(ps);
                 objectoutput.exportsymbol(ps);
                 objectoutput.exportsymbol(ps);
               end;
               end;
-            objectdata.writeSymStabs(sec,ofs,hp,ps,nidx,nother,line,reloc)
+            objectdata.writeSymStabs(ofs,hp,ps,nidx,nother,line,reloc)
           end
           end
         else
         else
-          objectdata.writeStabs(sec,ofs,hp,nidx,nother,line,reloc);
+          objectdata.writeStabs(ofs,hp,nidx,nother,line,reloc);
         if assigned(hp) then
         if assigned(hp) then
          p[ii]:='"';
          p[ii]:='"';
       end;
       end;
 
 
 
 
     procedure TInternalAssembler.emitlineinfostabs(nidx,line : longint);
     procedure TInternalAssembler.emitlineinfostabs(nidx,line : longint);
-      var
-         sec : TSection;
       begin
       begin
         if currpass=1 then
         if currpass=1 then
           begin
           begin
-            objectalloc.staballoc(nil);
+            objectdata.allocstabs(nil);
             exit;
             exit;
           end;
           end;
 
 
         if (nidx=n_textline) and assigned(funcname) and
         if (nidx=n_textline) and assigned(funcname) and
            (target_info.use_function_relative_addresses) then
            (target_info.use_function_relative_addresses) then
-          objectdata.writeStabs(sec_code,objectdata.sectionsize(sec_code)-funcname.address,
-              nil,nidx,0,line,false)
+          objectdata.writeStabs(objectdata.currsec.datasize-funcname.address,nil,nidx,0,line,false)
         else
         else
-          begin
-            if nidx=n_textline then
-              sec:=sec_code
-            else if nidx=n_dataline then
-              sec:=sec_data
-            else
-              sec:=sec_bss;
-            objectdata.writeStabs(sec,objectdata.sectionsize(sec),
-              nil,nidx,0,line,true);
-          end;
+          objectdata.writeStabs(objectdata.currsec.datasize,nil,nidx,0,line,true);
       end;
       end;
 
 
 
 
@@ -863,7 +845,7 @@ Implementation
               hp:=objectlibrary.newasmsymbol('Ltext'+ToStr(IncludeCount),AB_LOCAL,AT_FUNCTION);
               hp:=objectlibrary.newasmsymbol('Ltext'+ToStr(IncludeCount),AB_LOCAL,AT_FUNCTION);
               if currpass=1 then
               if currpass=1 then
                 begin
                 begin
-                  hp.setaddress(currpass,objectalloc.currsec,objectalloc.sectionsize,0);
+                  objectdata.allocsymbol(currpass,hp,0);
                   objectlibrary.UsedAsmSymbolListInsert(hp);
                   objectlibrary.UsedAsmSymbolListInsert(hp);
                 end
                 end
               else
               else
@@ -887,18 +869,12 @@ Implementation
       end;
       end;
 
 
 
 
-    procedure TInternalAssembler.StartFileLineInfo(sec:tsection);
+    procedure TInternalAssembler.StartFileLineInfo;
       var
       var
         fileinfo : tfileposinfo;
         fileinfo : tfileposinfo;
       begin
       begin
         FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
         FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
-        case sec of
-         sec_code : n_line:=n_textline;
-         sec_data : n_line:=n_dataline;
-          sec_bss : n_line:=n_bssline;
-        else
-         n_line:=n_bssline;
-        end;
+        n_line:=n_bssline;
         funcname:=nil;
         funcname:=nil;
         linecount:=1;
         linecount:=1;
         includecount:=0;
         includecount:=0;
@@ -911,23 +887,20 @@ Implementation
     procedure TInternalAssembler.EndFileLineInfo;
     procedure TInternalAssembler.EndFileLineInfo;
       var
       var
         hp : tasmsymbol;
         hp : tasmsymbol;
-        store_sec : TSection;
       begin
       begin
           if not ((cs_debuginfo in aktmoduleswitches) or
           if not ((cs_debuginfo in aktmoduleswitches) or
              (cs_gdb_lineinfo in aktglobalswitches)) then
              (cs_gdb_lineinfo in aktglobalswitches)) then
            exit;
            exit;
-        store_sec:=objectalloc.currsec;
-        objectalloc.seTSection(sec_code);
+        objectdata.createsection(sec_code,'',0,[]);
         hp:=objectlibrary.newasmsymbol('Letext',AB_LOCAL,AT_FUNCTION);
         hp:=objectlibrary.newasmsymbol('Letext',AB_LOCAL,AT_FUNCTION);
         if currpass=1 then
         if currpass=1 then
           begin
           begin
-            hp.setaddress(currpass,objectalloc.currsec,objectalloc.sectionsize,0);
+            objectdata.allocsymbol(currpass,hp,0);
             objectlibrary.UsedAsmSymbolListInsert(hp);
             objectlibrary.UsedAsmSymbolListInsert(hp);
           end
           end
         else
         else
           objectdata.writesymbol(hp);
           objectdata.writesymbol(hp);
         EmitStabs('"",'+tostr(n_sourcefile)+',0,0,Letext');
         EmitStabs('"",'+tostr(n_sourcefile)+',0,0,Letext');
-        objectalloc.seTSection(store_sec);
       end;
       end;
 {$endif GDB}
 {$endif GDB}
 
 
@@ -965,68 +938,62 @@ Implementation
                  { always use the maximum fillsize in this pass to avoid possible
                  { always use the maximum fillsize in this pass to avoid possible
                    short jumps to become out of range }
                    short jumps to become out of range }
                  Tai_align(hp).fillsize:=Tai_align(hp).aligntype;
                  Tai_align(hp).fillsize:=Tai_align(hp).aligntype;
-                 objectalloc.sectionalloc(Tai_align(hp).fillsize);
+                 objectdata.alloc(Tai_align(hp).fillsize);
                end;
                end;
              ait_datablock :
              ait_datablock :
                begin
                begin
+                 l:=used_align(size_2_align(Tai_datablock(hp).size),0,objectdata.currsec.addralign);
                  if not SmartAsm then
                  if not SmartAsm then
                   begin
                   begin
                     if not Tai_datablock(hp).is_global then
                     if not Tai_datablock(hp).is_global then
                      begin
                      begin
-                        l:=Tai_datablock(hp).size;
-                        if l>2 then
-                          objectalloc.sectionalign(4)
-                        else if l>1 then
-                          objectalloc.sectionalign(2);
-                        objectalloc.sectionalloc(Tai_datablock(hp).size);
+                        objectdata.allocalign(l);
+                        objectdata.alloc(Tai_datablock(hp).size);
                      end;
                      end;
                   end
                   end
                  else
                  else
                   begin
                   begin
-                    l:=Tai_datablock(hp).size;
-                    if l>2 then
-                      objectalloc.sectionalign(4)
-                    else if l>1 then
-                      objectalloc.sectionalign(2);
-                    objectalloc.sectionalloc(Tai_datablock(hp).size);
+                    objectdata.allocalign(l);
+                    objectdata.alloc(Tai_datablock(hp).size);
                   end;
                   end;
                end;
                end;
-             ait_const_32bit :
-               objectalloc.sectionalloc(4);
-             ait_const_16bit :
-               objectalloc.sectionalloc(2);
-             ait_const_8bit :
-               objectalloc.sectionalloc(1);
              ait_real_80bit :
              ait_real_80bit :
-               objectalloc.sectionalloc(10);
+               objectdata.alloc(10);
              ait_real_64bit :
              ait_real_64bit :
-               objectalloc.sectionalloc(8);
+               objectdata.alloc(8);
              ait_real_32bit :
              ait_real_32bit :
-               objectalloc.sectionalloc(4);
+               objectdata.alloc(4);
              ait_comp_64bit :
              ait_comp_64bit :
-               objectalloc.sectionalloc(8);
-             ait_const_rva,
-             ait_const_symbol :
-               objectalloc.sectionalloc(4);
+               objectdata.alloc(8);
+             ait_const_64bit,
+             ait_const_32bit,
+             ait_const_16bit,
+             ait_const_8bit,
+             ait_const_rva_symbol,
+             ait_const_indirect_symbol :
+               objectdata.alloc(tai_const(hp).size);
              ait_section:
              ait_section:
-               objectalloc.seTSection(Tai_section(hp).sec);
+               begin
+                 objectdata.CreateSection(Tai_section(hp).sectype,Tai_section(hp).name^,Tai_section(hp).secalign,[]);
+                 Tai_section(hp).sec:=objectdata.CurrSec;
+               end;
              ait_symbol :
              ait_symbol :
-               Tai_symbol(hp).sym.setaddress(currpass,objectalloc.currsec,objectalloc.sectionsize,0);
+               objectdata.allocsymbol(currpass,Tai_symbol(hp).sym,0);
              ait_label :
              ait_label :
-               Tai_label(hp).l.setaddress(currpass,objectalloc.currsec,objectalloc.sectionsize,0);
+               objectdata.allocsymbol(currpass,Tai_label(hp).l,0);
              ait_string :
              ait_string :
-               objectalloc.sectionalloc(Tai_string(hp).len);
+               objectdata.alloc(Tai_string(hp).len);
              ait_instruction :
              ait_instruction :
                begin
                begin
 {$ifdef i386}
 {$ifdef i386}
 {$ifndef NOAG386BIN}
 {$ifndef NOAG386BIN}
                  { reset instructions which could change in pass 2 }
                  { reset instructions which could change in pass 2 }
                  Taicpu(hp).resetpass2;
                  Taicpu(hp).resetpass2;
-                 objectalloc.sectionalloc(Taicpu(hp).Pass1(objectalloc.sectionsize));
+                 objectdata.alloc(Taicpu(hp).Pass1(objectdata.currsec.datasize));
 {$endif NOAG386BIN}
 {$endif NOAG386BIN}
 {$endif i386}
 {$endif i386}
                end;
                end;
-             ait_cut :
+             ait_cutobject :
                if SmartAsm then
                if SmartAsm then
                 break;
                 break;
            end;
            end;
@@ -1055,7 +1022,7 @@ Implementation
               ((cs_debuginfo in aktmoduleswitches) or
               ((cs_debuginfo in aktmoduleswitches) or
                (cs_gdb_lineinfo in aktglobalswitches)) then
                (cs_gdb_lineinfo in aktglobalswitches)) then
             begin
             begin
-              if (objectalloc.currsec<>sec_none) and
+              if (objectdata.currsec<>nil) and
                  not(hp.typ in SkipLineInfo) then
                  not(hp.typ in SkipLineInfo) then
                WriteFileLineInfo(tailineinfo(hp).fileinfo);
                WriteFileLineInfo(tailineinfo(hp).fileinfo);
             end;
             end;
@@ -1064,77 +1031,74 @@ Implementation
              ait_align :
              ait_align :
                begin
                begin
                  { here we must determine the fillsize which is used in pass2 }
                  { here we must determine the fillsize which is used in pass2 }
-                 Tai_align(hp).fillsize:=align(objectalloc.sectionsize,Tai_align(hp).aligntype)-
-                   objectalloc.sectionsize;
-                 objectalloc.sectionalloc(Tai_align(hp).fillsize);
+                 Tai_align(hp).fillsize:=align(objectdata.currsec.datasize,Tai_align(hp).aligntype)-
+                   objectdata.currsec.datasize;
+                 objectdata.alloc(Tai_align(hp).fillsize);
                end;
                end;
              ait_datablock :
              ait_datablock :
                begin
                begin
-                 if objectalloc.currsec<>sec_bss then
-                  Message(asmw_e_alloc_data_only_in_bss);
+                 if objectdata.currsec.sectype<>sec_bss then
+                   Message(asmw_e_alloc_data_only_in_bss);
+                 l:=used_align(size_2_align(Tai_datablock(hp).size),0,objectdata.currsec.addralign);
                  if not SmartAsm then
                  if not SmartAsm then
                   begin
                   begin
                     if Tai_datablock(hp).is_global then
                     if Tai_datablock(hp).is_global then
                      begin
                      begin
-                       Tai_datablock(hp).sym.setaddress(currpass,sec_none,Tai_datablock(hp).size,Tai_datablock(hp).size);
+                       objectdata.allocsymbol(currpass,Tai_datablock(hp).sym,Tai_datablock(hp).size);
                        { force to be common/external, must be after setaddress as that would
                        { force to be common/external, must be after setaddress as that would
-                         set it to AS_GLOBAL }
+                         set it to AB_GLOBAL }
                        Tai_datablock(hp).sym.currbind:=AB_COMMON;
                        Tai_datablock(hp).sym.currbind:=AB_COMMON;
                      end
                      end
                     else
                     else
                      begin
                      begin
-                       l:=Tai_datablock(hp).size;
-                       if l>2 then
-                         objectalloc.sectionalign(4)
-                       else if l>1 then
-                         objectalloc.sectionalign(2);
-                       Tai_datablock(hp).sym.setaddress(currpass,objectalloc.currsec,objectalloc.sectionsize,
-                         Tai_datablock(hp).size);
-                       objectalloc.sectionalloc(Tai_datablock(hp).size);
+                       objectdata.allocalign(l);
+                       objectdata.allocsymbol(currpass,Tai_datablock(hp).sym,Tai_datablock(hp).size);
+                       objectdata.alloc(Tai_datablock(hp).size);
                      end;
                      end;
                    end
                    end
                   else
                   else
                    begin
                    begin
-                     l:=Tai_datablock(hp).size;
-                     if l>2 then
-                       objectalloc.sectionalign(4)
-                     else if l>1 then
-                       objectalloc.sectionalign(2);
-                     Tai_datablock(hp).sym.setaddress(currpass,objectalloc.currsec,objectalloc.sectionsize,Tai_datablock(hp).size);
-                     objectalloc.sectionalloc(Tai_datablock(hp).size);
+                     objectdata.allocalign(l);
+                     objectdata.allocsymbol(currpass,Tai_datablock(hp).sym,Tai_datablock(hp).size);
+                     objectdata.alloc(Tai_datablock(hp).size);
                    end;
                    end;
                  objectlibrary.UsedAsmSymbolListInsert(Tai_datablock(hp).sym);
                  objectlibrary.UsedAsmSymbolListInsert(Tai_datablock(hp).sym);
                end;
                end;
-             ait_const_32bit :
-               objectalloc.sectionalloc(4);
-             ait_const_16bit :
-               objectalloc.sectionalloc(2);
-             ait_const_8bit :
-               objectalloc.sectionalloc(1);
              ait_real_80bit :
              ait_real_80bit :
-               objectalloc.sectionalloc(10);
+               objectdata.alloc(10);
              ait_real_64bit :
              ait_real_64bit :
-               objectalloc.sectionalloc(8);
+               objectdata.alloc(8);
              ait_real_32bit :
              ait_real_32bit :
-               objectalloc.sectionalloc(4);
+               objectdata.alloc(4);
              ait_comp_64bit :
              ait_comp_64bit :
-               objectalloc.sectionalloc(8);
-             ait_const_rva,
-             ait_const_symbol :
+               objectdata.alloc(8);
+             ait_const_64bit,
+             ait_const_32bit,
+             ait_const_16bit,
+             ait_const_8bit,
+             ait_const_rva_symbol,
+             ait_const_indirect_symbol :
                begin
                begin
-                 objectalloc.sectionalloc(4);
-                 objectlibrary.UsedAsmSymbolListInsert(Tai_const_symbol(hp).sym);
+                 objectdata.alloc(tai_const(hp).size);
+                 if assigned(Tai_const(hp).sym) then
+                   objectlibrary.UsedAsmSymbolListInsert(Tai_const(hp).sym);
+                 if assigned(Tai_const(hp).endsym) then
+                   objectlibrary.UsedAsmSymbolListInsert(Tai_const(hp).endsym);
                end;
                end;
              ait_section:
              ait_section:
                begin
                begin
-                 objectalloc.seTSection(Tai_section(hp).sec);
+                 { use cached value }
+                 objectdata.setsection(Tai_section(hp).sec);
 {$ifdef GDB}
 {$ifdef GDB}
-                 case Tai_section(hp).sec of
-                  sec_code : n_line:=n_textline;
-                  sec_data : n_line:=n_dataline;
-                   sec_bss : n_line:=n_bssline;
-                 else
-                  n_line:=n_dataline;
+                 case Tai_section(hp).sectype of
+                   sec_code :
+                     n_line:=n_textline;
+                   sec_data :
+                     n_line:=n_dataline;
+                   sec_bss :
+                     n_line:=n_bssline;
+                   else
+                     n_line:=n_dataline;
                  end;
                  end;
                  stabslastfileinfo.line:=-1;
                  stabslastfileinfo.line:=-1;
 {$endif GDB}
 {$endif GDB}
@@ -1165,29 +1129,29 @@ Implementation
 {$endif}
 {$endif}
              ait_symbol :
              ait_symbol :
                begin
                begin
-                 Tai_symbol(hp).sym.setaddress(currpass,objectalloc.currsec,objectalloc.sectionsize,0);
+                 objectdata.allocsymbol(currpass,Tai_symbol(hp).sym,0);
                  objectlibrary.UsedAsmSymbolListInsert(Tai_symbol(hp).sym);
                  objectlibrary.UsedAsmSymbolListInsert(Tai_symbol(hp).sym);
                end;
                end;
              ait_symbol_end :
              ait_symbol_end :
                begin
                begin
                  if target_info.system in [system_i386_linux,system_i386_beos] then
                  if target_info.system in [system_i386_linux,system_i386_beos] then
                   begin
                   begin
-                    Tai_symbol_end(hp).sym.size:=objectalloc.sectionsize-Tai_symbol_end(hp).sym.address;
+                    Tai_symbol_end(hp).sym.size:=objectdata.currsec.datasize-Tai_symbol_end(hp).sym.address;
                     objectlibrary.UsedAsmSymbolListInsert(Tai_symbol_end(hp).sym);
                     objectlibrary.UsedAsmSymbolListInsert(Tai_symbol_end(hp).sym);
                   end;
                   end;
                 end;
                 end;
              ait_label :
              ait_label :
                begin
                begin
-                 Tai_label(hp).l.setaddress(currpass,objectalloc.currsec,objectalloc.sectionsize,0);
+                 objectdata.allocsymbol(currpass,Tai_label(hp).l,0);
                  objectlibrary.UsedAsmSymbolListInsert(Tai_label(hp).l);
                  objectlibrary.UsedAsmSymbolListInsert(Tai_label(hp).l);
                end;
                end;
              ait_string :
              ait_string :
-               objectalloc.sectionalloc(Tai_string(hp).len);
+               objectdata.alloc(Tai_string(hp).len);
              ait_instruction :
              ait_instruction :
                begin
                begin
 {$ifdef i386}
 {$ifdef i386}
 {$ifndef NOAG386BIN}
 {$ifndef NOAG386BIN}
-                 objectalloc.sectionalloc(Taicpu(hp).Pass1(objectalloc.sectionsize));
+                 objectdata.alloc(Taicpu(hp).Pass1(objectdata.currsec.datasize));
                  { fixup the references }
                  { fixup the references }
                  for i:=1 to Taicpu(hp).ops do
                  for i:=1 to Taicpu(hp).ops do
                   begin
                   begin
@@ -1209,7 +1173,7 @@ Implementation
                end;
                end;
              ait_direct :
              ait_direct :
                Message(asmw_f_direct_not_supported);
                Message(asmw_f_direct_not_supported);
-             ait_cut :
+             ait_cutobject :
                if SmartAsm then
                if SmartAsm then
                 break;
                 break;
              ait_marker :
              ait_marker :
@@ -1229,6 +1193,7 @@ Implementation
         fillbuffer : tfillbuffer;
         fillbuffer : tfillbuffer;
         InlineLevel,
         InlineLevel,
         l  : longint;
         l  : longint;
+        v  : int64;
 {$ifdef x86}
 {$ifdef x86}
         co : comp;
         co : comp;
 {$endif x86}
 {$endif x86}
@@ -1243,7 +1208,7 @@ Implementation
               ((cs_debuginfo in aktmoduleswitches) or
               ((cs_debuginfo in aktmoduleswitches) or
                (cs_gdb_lineinfo in aktglobalswitches)) then
                (cs_gdb_lineinfo in aktglobalswitches)) then
             begin
             begin
-              if (objectdata.currsec<>sec_none) and
+              if (objectdata.currsec<>nil) and
                  not(hp.typ in SkipLineInfo) then
                  not(hp.typ in SkipLineInfo) then
                WriteFileLineInfo(tailineinfo(hp).fileinfo);
                WriteFileLineInfo(tailineinfo(hp).fileinfo);
             end;
             end;
@@ -1251,16 +1216,17 @@ Implementation
            case hp.typ of
            case hp.typ of
              ait_align :
              ait_align :
                begin
                begin
-                 if objectdata.currsec=sec_bss then
+                 if objectdata.currsec.sectype=sec_bss then
                    objectdata.alloc(Tai_align(hp).fillsize)
                    objectdata.alloc(Tai_align(hp).fillsize)
                  else
                  else
                    objectdata.writebytes(Tai_align(hp).calculatefillbuf(fillbuffer)^,Tai_align(hp).fillsize);
                    objectdata.writebytes(Tai_align(hp).calculatefillbuf(fillbuffer)^,Tai_align(hp).fillsize);
                end;
                end;
              ait_section :
              ait_section :
                begin
                begin
-                 objectdata.defaulTSection(Tai_section(hp).sec);
+                 { use cached value }
+                 objectdata.setsection(Tai_section(hp).sec);
 {$ifdef GDB}
 {$ifdef GDB}
-                 case Tai_section(hp).sec of
+                 case Tai_section(hp).sectype of
                   sec_code : n_line:=n_textline;
                   sec_code : n_line:=n_textline;
                   sec_data : n_line:=n_dataline;
                   sec_data : n_line:=n_dataline;
                    sec_bss : n_line:=n_bssline;
                    sec_bss : n_line:=n_bssline;
@@ -1289,12 +1255,6 @@ Implementation
                      objectdata.alloc(Tai_datablock(hp).size);
                      objectdata.alloc(Tai_datablock(hp).size);
                    end;
                    end;
                end;
                end;
-             ait_const_32bit :
-               objectdata.writebytes(Tai_const(hp).value,4);
-             ait_const_16bit :
-               objectdata.writebytes(Tai_const(hp).value,2);
-             ait_const_8bit :
-               objectdata.writebytes(Tai_const(hp).value,1);
              ait_real_80bit :
              ait_real_80bit :
                objectdata.writebytes(Tai_real_80bit(hp).value,10);
                objectdata.writebytes(Tai_real_80bit(hp).value,10);
              ait_real_64bit :
              ait_real_64bit :
@@ -1314,12 +1274,28 @@ Implementation
                end;
                end;
              ait_string :
              ait_string :
                objectdata.writebytes(Tai_string(hp).str^,Tai_string(hp).len);
                objectdata.writebytes(Tai_string(hp).str^,Tai_string(hp).len);
-             ait_const_rva :
-               objectdata.writereloc(Tai_const_symbol(hp).offset,4,
-                 Tai_const_symbol(hp).sym,RELOC_RVA);
-             ait_const_symbol :
-               objectdata.writereloc(Tai_const_symbol(hp).offset,4,
-                 Tai_const_symbol(hp).sym,RELOC_ABSOLUTE);
+             ait_const_64bit,
+             ait_const_32bit,
+             ait_const_16bit,
+             ait_const_8bit :
+               begin
+                 if assigned(tai_const(hp).sym) then
+                   begin
+                     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.writebytes(Tai_const(hp).value,tai_const(hp).size);
+               end;
+             ait_const_rva_symbol :
+               objectdata.writereloc(Tai_const(hp).value,sizeof(aint),Tai_const(hp).sym,RELOC_RVA);
              ait_label :
              ait_label :
                begin
                begin
                  objectdata.writesymbol(Tai_label(hp).l);
                  objectdata.writesymbol(Tai_label(hp).l);
@@ -1346,7 +1322,7 @@ Implementation
              ait_force_line :
              ait_force_line :
                stabslastfileinfo.line:=0;
                stabslastfileinfo.line:=0;
 {$endif}
 {$endif}
-             ait_cut :
+             ait_cutobject :
                if SmartAsm then
                if SmartAsm then
                 break;
                 break;
              ait_marker :
              ait_marker :
@@ -1367,17 +1343,14 @@ Implementation
       label
       label
         doexit;
         doexit;
       begin
       begin
-        objectalloc.reseTSections;
-        objectalloc.seTSection(sec_code);
-
         objectdata:=objectoutput.newobjectdata(Objfile);
         objectdata:=objectoutput.newobjectdata(Objfile);
-        objectdata.defaulTSection(sec_code);
         { reset the asmsymbol list }
         { reset the asmsymbol list }
         objectlibrary.CreateUsedAsmsymbolList;
         objectlibrary.CreateUsedAsmsymbolList;
 
 
       { Pass 0 }
       { Pass 0 }
         currpass:=0;
         currpass:=0;
-        objectalloc.seTSection(sec_code);
+        objectdata.createsection(sec_code,'',0,[]);
+        objectdata.beforealloc;
         { start with list 1 }
         { start with list 1 }
         currlistidx:=1;
         currlistidx:=1;
         currlist:=list[currlistidx];
         currlist:=list[currlistidx];
@@ -1387,16 +1360,18 @@ Implementation
            hp:=TreePass0(hp);
            hp:=TreePass0(hp);
            MaybeNextList(hp);
            MaybeNextList(hp);
          end;
          end;
+        objectdata.afteralloc;
         { leave if errors have occured }
         { leave if errors have occured }
         if errorcount>0 then
         if errorcount>0 then
          goto doexit;
          goto doexit;
 
 
       { Pass 1 }
       { Pass 1 }
         currpass:=1;
         currpass:=1;
-        objectalloc.reseTSections;
-        objectalloc.seTSection(sec_code);
+        objectdata.resetsections;
+        objectdata.beforealloc;
+        objectdata.createsection(sec_code,'',0,[]);
 {$ifdef GDB}
 {$ifdef GDB}
-        StartFileLineInfo(sec_code);
+        StartFileLineInfo;
 {$endif GDB}
 {$endif GDB}
         { start with list 1 }
         { start with list 1 }
         currlistidx:=1;
         currlistidx:=1;
@@ -1410,19 +1385,21 @@ Implementation
 {$ifdef GDB}
 {$ifdef GDB}
         EndFileLineInfo;
         EndFileLineInfo;
 {$endif GDB}
 {$endif GDB}
+        objectdata.afteralloc;
         { check for undefined labels and reset }
         { check for undefined labels and reset }
         objectlibrary.UsedAsmSymbolListCheckUndefined;
         objectlibrary.UsedAsmSymbolListCheckUndefined;
 
 
-        { set section sizes }
-        objectdata.seTSectionsizes(objectalloc.secsize);
         { leave if errors have occured }
         { leave if errors have occured }
         if errorcount>0 then
         if errorcount>0 then
          goto doexit;
          goto doexit;
 
 
       { Pass 2 }
       { Pass 2 }
         currpass:=2;
         currpass:=2;
+        objectdata.resetsections;
+        objectdata.beforewrite;
+        objectdata.createsection(sec_code,'',0,[]);
 {$ifdef GDB}
 {$ifdef GDB}
-        StartFileLineInfo(sec_code);
+        StartFileLineInfo;
 {$endif GDB}
 {$endif GDB}
         { start with list 1 }
         { start with list 1 }
         currlistidx:=1;
         currlistidx:=1;
@@ -1436,6 +1413,7 @@ Implementation
 {$ifdef GDB}
 {$ifdef GDB}
         EndFileLineInfo;
         EndFileLineInfo;
 {$endif GDB}
 {$endif GDB}
+        objectdata.afterwrite;
 
 
         { don't write the .o file if errors have occured }
         { don't write the .o file if errors have occured }
         if errorcount=0 then
         if errorcount=0 then
@@ -1458,16 +1436,12 @@ Implementation
     procedure TInternalAssembler.writetreesmart;
     procedure TInternalAssembler.writetreesmart;
       var
       var
         hp : Tai;
         hp : Tai;
-        starTSec : TSection;
+        startsectype : TAsmSectionType;
         place: tcutplace;
         place: tcutplace;
       begin
       begin
-        objectalloc.reseTSections;
-        objectalloc.seTSection(sec_code);
-
         NextSmartName(cut_normal);
         NextSmartName(cut_normal);
         objectdata:=objectoutput.newobjectdata(Objfile);
         objectdata:=objectoutput.newobjectdata(Objfile);
-        objectdata.defaulTSection(sec_code);
-        starTSec:=sec_code;
+        startsectype:=sec_code;
 
 
         { start with list 1 }
         { start with list 1 }
         currlistidx:=1;
         currlistidx:=1;
@@ -1480,29 +1454,31 @@ Implementation
 
 
          { Pass 0 }
          { Pass 0 }
            currpass:=0;
            currpass:=0;
-           objectalloc.reseTSections;
-           objectalloc.seTSection(starTSec);
+           objectdata.resetsections;
+           objectdata.beforealloc;
+           objectdata.createsection(startsectype,'',0,[]);
            TreePass0(hp);
            TreePass0(hp);
+           objectdata.afteralloc;
            { leave if errors have occured }
            { leave if errors have occured }
            if errorcount>0 then
            if errorcount>0 then
             exit;
             exit;
 
 
          { Pass 1 }
          { Pass 1 }
            currpass:=1;
            currpass:=1;
-           objectalloc.reseTSections;
-           objectalloc.seTSection(starTSec);
+           objectdata.resetsections;
+           objectdata.beforealloc;
+           objectdata.createsection(startsectype,'',0,[]);
 {$ifdef GDB}
 {$ifdef GDB}
-           StartFileLineInfo(startsec);
+           StartFileLineInfo;
 {$endif GDB}
 {$endif GDB}
            TreePass1(hp);
            TreePass1(hp);
 {$ifdef GDB}
 {$ifdef GDB}
            EndFileLineInfo;
            EndFileLineInfo;
 {$endif GDB}
 {$endif GDB}
+           objectdata.afteralloc;
            { check for undefined labels }
            { check for undefined labels }
            objectlibrary.UsedAsmSymbolListCheckUndefined;
            objectlibrary.UsedAsmSymbolListCheckUndefined;
 
 
-           { set section sizes }
-           objectdata.seTSectionsizes(objectalloc.secsize);
            { leave if errors have occured }
            { leave if errors have occured }
            if errorcount>0 then
            if errorcount>0 then
             exit;
             exit;
@@ -1510,14 +1486,20 @@ Implementation
          { Pass 2 }
          { Pass 2 }
            currpass:=2;
            currpass:=2;
            objectoutput.startobjectfile(Objfile);
            objectoutput.startobjectfile(Objfile);
-           objectdata.defaulTSection(starTSec);
+           objectdata.resetsections;
+           objectdata.beforewrite;
+           objectdata.createsection(startsectype,'',0,[]);
 {$ifdef GDB}
 {$ifdef GDB}
-           StartFileLineInfo(startsec);
+           StartFileLineInfo;
 {$endif GDB}
 {$endif GDB}
            hp:=TreePass2(hp);
            hp:=TreePass2(hp);
+           { save section type for next loop, must be done before EndFileLineInfo
+             because that changes the section to sec_code }
+           startsectype:=objectdata.currsec.sectype;
 {$ifdef GDB}
 {$ifdef GDB}
            EndFileLineInfo;
            EndFileLineInfo;
 {$endif GDB}
 {$endif GDB}
+           objectdata.afterwrite;
            { leave if errors have occured }
            { leave if errors have occured }
            if errorcount>0 then
            if errorcount>0 then
             exit;
             exit;
@@ -1536,28 +1518,27 @@ Implementation
            if not MaybeNextList(hp) then
            if not MaybeNextList(hp) then
             break;
             break;
 
 
-           { save section for next loop }
-           { this leads to a problem if starTSec is sec_none !! PM }
-           starTSec:=objectalloc.currsec;
-
            { we will start a new objectfile so reset everything }
            { we will start a new objectfile so reset everything }
            { The place can still change in the next while loop, so don't init }
            { The place can still change in the next while loop, so don't init }
            { the writer yet (JM)                                              }
            { the writer yet (JM)                                              }
-           if (hp.typ=ait_cut) then
-            place := Tai_cut(hp).place
+           if (hp.typ=ait_cutobject) then
+            place := Tai_cutobject(hp).place
            else
            else
             place := cut_normal;
             place := cut_normal;
 
 
            { avoid empty files }
            { avoid empty files }
            while assigned(hp) and
            while assigned(hp) and
-                 (Tai(hp).typ in [ait_marker,ait_comment,ait_section,ait_cut]) do
+                 (Tai(hp).typ in [ait_marker,ait_comment,ait_section,ait_cutobject]) do
             begin
             begin
               if Tai(hp).typ=ait_section then
               if Tai(hp).typ=ait_section then
-               starTSec:=Tai_section(hp).sec
-              else if (Tai(hp).typ=ait_cut) then
-               place := Tai_cut(hp).place;
+               startsectype:=Tai_section(hp).sectype
+              else if (Tai(hp).typ=ait_cutobject) then
+               place:=Tai_cutobject(hp).place;
               hp:=Tai(hp.next);
               hp:=Tai(hp.next);
             end;
             end;
+           { there is a problem if startsectype is sec_none !! PM }
+           if startsectype=sec_none then
+             startsectype:=sec_code;
 
 
            if not MaybeNextList(hp) then
            if not MaybeNextList(hp) then
              break;
              break;
@@ -1565,11 +1546,6 @@ Implementation
            { start next objectfile }
            { start next objectfile }
            NextSmartName(place);
            NextSmartName(place);
            objectdata:=objectoutput.newobjectdata(Objfile);
            objectdata:=objectoutput.newobjectdata(Objfile);
-
-           { there is a problem if starTSec is sec_none !! PM }
-           if starTSec=sec_none then
-             starTSec:=sec_code;
-
          end;
          end;
       end;
       end;
 
 
@@ -1595,10 +1571,13 @@ Implementation
         addlist(bsssegment);
         addlist(bsssegment);
         if assigned(importssection) then
         if assigned(importssection) then
           addlist(importssection);
           addlist(importssection);
-        if assigned(exportssection) and not UseDeffileForExport then
+        if assigned(exportssection) and not UseDeffileForExports then
           addlist(exportssection);
           addlist(exportssection);
         if assigned(resourcesection) then
         if assigned(resourcesection) then
           addlist(resourcesection);
           addlist(resourcesection);
+{$warning TODO internal writer support for dwarf}
+        {if assigned(dwarflist) then
+          addlist(dwarflist);}
 
 
         if SmartAsm then
         if SmartAsm then
           writetreesmart
           writetreesmart
@@ -1666,10 +1645,35 @@ Implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.67  2004-05-21 22:43:36  peter
+  Revision 1.68  2004-06-16 20:07:06  florian
+    * dwarf branch merged
+
+  Revision 1.67  2004/05/21 22:43:36  peter
     * set correct n_line type when starting new .o file by passing
     * set correct n_line type when starting new .o file by passing
       the current section type
       the current section type
 
 
+  Revision 1.66.2.7  2004/05/03 14:59:57  peter
+    * no dlltool needed for win32 linking executables
+
+  Revision 1.66.2.6  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.66.2.5  2004/04/29 23:30:28  peter
+    * fix i386 compiler
+
+  Revision 1.66.2.4  2004/04/12 19:34:45  peter
+    * basic framework for dwarf CFI
+
+  Revision 1.66.2.3  2004/04/12 14:45:10  peter
+    * tai_const_symbol and tai_const merged
+
+  Revision 1.66.2.2  2004/04/10 12:36:41  peter
+    * fixed alignment issues
+
+  Revision 1.66.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
   Revision 1.66  2004/03/22 09:28:34  michael
   Revision 1.66  2004/03/22 09:28:34  michael
   + Patch from peter for stack overflow
   + Patch from peter for stack overflow
 
 

+ 17 - 11
compiler/browcol.pas

@@ -92,8 +92,8 @@ type
       Items      : PSymbolCollection;
       Items      : PSymbolCollection;
       DType      : PString;
       DType      : PString;
       VType      : PString;
       VType      : PString;
-      TypeID     : longint;
-      RelatedTypeID : longint;
+      TypeID     : Ptrint;
+      RelatedTypeID : Ptrint;
       DebuggerCount : longint;
       DebuggerCount : longint;
       Ancestor   : PSymbol;
       Ancestor   : PSymbol;
       Flags      : longint;
       Flags      : longint;
@@ -587,8 +587,8 @@ begin
   if S1<S2 then R:=-1 else
   if S1<S2 then R:=-1 else
   if S1>S2 then R:=1 else
   if S1>S2 then R:=1 else
   { make sure that we distinguish between different objects with the same name }
   { make sure that we distinguish between different objects with the same name }
-  if longint(K1^.Symbol)<longint(K2^.Symbol) then R:=-1 else
-  if longint(K1^.Symbol)>longint(K2^.Symbol) then R:= 1 else
+  if Ptrint(K1^.Symbol)<Ptrint(K2^.Symbol) then R:=-1 else
+  if Ptrint(K1^.Symbol)>Ptrint(K2^.Symbol) then R:= 1 else
   R:=0;
   R:=0;
   Compare:=R;
   Compare:=R;
 end;
 end;
@@ -1441,7 +1441,7 @@ end;
                     assigned(tpointerdef(vartype.def).pointertype.def) then
                     assigned(tpointerdef(vartype.def).pointertype.def) then
                  begin
                  begin
                    Symbol^.Flags:=(Symbol^.Flags or sfPointer);
                    Symbol^.Flags:=(Symbol^.Flags or sfPointer);
-                   Symbol^.RelatedTypeID:=longint(tpointerdef(vartype.def).pointertype.def);
+                   Symbol^.RelatedTypeID:=Ptrint(tpointerdef(vartype.def).pointertype.def);
                  end;
                  end;
                if  Table.symtabletype in [recordsymtable,objectsymtable] then
                if  Table.symtabletype in [recordsymtable,objectsymtable] then
                  MemInfo.Addr:=fieldoffset
                  MemInfo.Addr:=fieldoffset
@@ -1508,7 +1508,7 @@ end;
             with ttypesym(sym) do
             with ttypesym(sym) do
               if assigned(restype.def) then
               if assigned(restype.def) then
                begin
                begin
-                Symbol^.TypeID:=longint(restype.def);
+                Symbol^.TypeID:=Ptrint(restype.def);
                 case restype.def.deftype of
                 case restype.def.deftype of
                   arraydef :
                   arraydef :
                     SetDType(Symbol,GetArrayDefStr(tarraydef(restype.def)));
                     SetDType(Symbol,GetArrayDefStr(tarraydef(restype.def)));
@@ -1523,7 +1523,7 @@ end;
                     begin
                     begin
                       ObjDef:=childof;
                       ObjDef:=childof;
                       if ObjDef<>nil then
                       if ObjDef<>nil then
-                        Symbol^.RelatedTypeID:=longint(ObjDef);{TypeNames^.Add(S);}
+                        Symbol^.RelatedTypeID:=Ptrint(ObjDef);{TypeNames^.Add(S);}
                       Symbol^.Flags:=(Symbol^.Flags or sfObject);
                       Symbol^.Flags:=(Symbol^.Flags or sfObject);
                       if tobjectdef(restype.def).objecttype=odt_class then
                       if tobjectdef(restype.def).objecttype=odt_class then
                         Symbol^.Flags:=(Symbol^.Flags or sfClass);
                         Symbol^.Flags:=(Symbol^.Flags or sfClass);
@@ -1537,7 +1537,7 @@ end;
                   pointerdef :
                   pointerdef :
                     begin
                     begin
                       Symbol^.Flags:=(Symbol^.Flags or sfPointer);
                       Symbol^.Flags:=(Symbol^.Flags or sfPointer);
-                      Symbol^.RelatedTypeID:=longint(tpointerdef(restype.def).pointertype.def);{TypeNames^.Add(S);}
+                      Symbol^.RelatedTypeID:=Ptrint(tpointerdef(restype.def).pointertype.def);{TypeNames^.Add(S);}
                       SetDType(Symbol,GetPointerDefStr(tpointerdef(restype.def)));
                       SetDType(Symbol,GetPointerDefStr(tpointerdef(restype.def)));
                     end;
                     end;
 
 
@@ -1943,8 +1943,8 @@ var K1: PPointerXRef absolute Key1;
     K2: PPointerXRef absolute Key2;
     K2: PPointerXRef absolute Key2;
     R: integer;
     R: integer;
 begin
 begin
-  if longint(K1^.PtrValue)<longint(K2^.PtrValue) then R:=-1 else
-  if longint(K1^.PtrValue)>longint(K2^.PtrValue) then R:= 1 else
+  if Ptrint(K1^.PtrValue)<Ptrint(K2^.PtrValue) then R:=-1 else
+  if Ptrint(K1^.PtrValue)>Ptrint(K2^.PtrValue) then R:= 1 else
   R:=0;
   R:=0;
   Compare:=R;
   Compare:=R;
 end;
 end;
@@ -2118,7 +2118,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.37  2004-03-23 22:34:49  peter
+  Revision 1.38  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.37.2.1  2004/05/03 21:08:56  peter
+    * use ptrint
+
+  Revision 1.37  2004/03/23 22:34:49  peter
     * constants ordinals now always have a type assigned
     * constants ordinals now always have a type assigned
     * integer constants have the smallest type, unsigned prefered over
     * integer constants have the smallest type, unsigned prefered over
       signed
       signed

+ 38 - 25
compiler/cclasses.pas

@@ -269,6 +269,7 @@ type
          function  search(const s:string):TNamedIndexItem;
          function  search(const s:string):TNamedIndexItem;
          function  speedsearch(const s:string;SpeedValue:cardinal):TNamedIndexItem;
          function  speedsearch(const s:string;SpeedValue:cardinal):TNamedIndexItem;
          property  Items[const s:string]:TNamedIndexItem read Search;default;
          property  Items[const s:string]:TNamedIndexItem read Search;default;
+         property  Count:longint read FCount;
        end;
        end;
 
 
        tsingleList=class
        tsingleList=class
@@ -1379,27 +1380,27 @@ end;
             if root<>nil then
             if root<>nil then
               begin
               begin
                 dec(FCount);
                 dec(FCount);
-            if root.FLeft<>nil then
-             begin
-               { Now the Node pointing to root must point to the left
-                 subtree of root. The right subtree of root must be
-                 connected to the right bottom of the left subtree.}
-               if lr=left then
-                oldroot.FLeft:=root.FLeft
-               else
-                oldroot.FRight:=root.FLeft;
-               if root.FRight<>nil then
-                insert_right_bottom(root.FLeft,root.FRight);
-             end
-            else
-             begin
-               { There is no left subtree. So we can just replace the Node to
-                 delete with the right subtree.}
-               if lr=left then
-                oldroot.FLeft:=root.FRight
-               else
-                oldroot.FRight:=root.FRight;
-             end;
+                if root.FLeft<>nil then
+                 begin
+                   { Now the Node pointing to root must point to the left
+                     subtree of root. The right subtree of root must be
+                     connected to the right bottom of the left subtree.}
+                   if lr=left then
+                    oldroot.FLeft:=root.FLeft
+                   else
+                    oldroot.FRight:=root.FLeft;
+                   if root.FRight<>nil then
+                    insert_right_bottom(root.FLeft,root.FRight);
+                 end
+                else
+                 begin
+                   { There is no left subtree. So we can just replace the Node to
+                     delete with the right subtree.}
+                   if lr=left then
+                    oldroot.FLeft:=root.FRight
+                   else
+                    oldroot.FRight:=root.FRight;
+                 end;
               end;
               end;
             delete_from_tree:=root;
             delete_from_tree:=root;
           end;
           end;
@@ -1602,9 +1603,9 @@ end;
       begin
       begin
         inc(FCount);
         inc(FCount);
         if assigned(FHashArray) then
         if assigned(FHashArray) then
-         insert:=insertNode(obj,FHashArray^[obj.SpeedValue mod hasharraysize])
+          insert:=insertNode(obj,FHashArray^[obj.SpeedValue mod hasharraysize])
         else
         else
-         insert:=insertNode(obj,FRoot);
+          insert:=insertNode(obj,FRoot);
       end;
       end;
 
 
 
 
@@ -2300,7 +2301,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.33  2004-05-24 17:30:09  peter
+  Revision 1.34  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.33  2004/05/24 17:30:09  peter
     * allow setting of name in dictionary always. Otherwise it is never
     * allow setting of name in dictionary always. Otherwise it is never
       possible to create an item with a name and rename before insert
       possible to create an item with a name and rename before insert
       this is used in the symtable to hide the current symbol
       this is used in the symtable to hide the current symbol
@@ -2311,6 +2315,15 @@ end.
   Revision 1.31  2004/04/28 18:02:54  peter
   Revision 1.31  2004/04/28 18:02:54  peter
     * add TList to cclasses, remove classes dependency from t_win32
     * add TList to cclasses, remove classes dependency from t_win32
 
 
+  Revision 1.30.2.3  2004/05/02 14:27:21  peter
+    * use sizeof(pointer) instead of 4
+
+  Revision 1.30.2.2  2004/04/09 14:34:53  peter
+    * fixed compilation for win32
+
+  Revision 1.30.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
   Revision 1.30  2004/01/15 15:16:17  daniel
   Revision 1.30  2004/01/15 15:16:17  daniel
     * Some minor stuff
     * Some minor stuff
     * Managed to eliminate speed effects of string compression
     * Managed to eliminate speed effects of string compression
@@ -2409,4 +2422,4 @@ end.
     * fixed pascal calling method with reversing also the high tree in
     * fixed pascal calling method with reversing also the high tree in
       the parast, detected by tcalcst3 test
       the parast, detected by tcalcst3 test
 
 
-}
+}

+ 69 - 43
compiler/cg64f32.pas

@@ -48,14 +48,14 @@ unit cg64f32;
       tcg64f32 = class(tcg64)
       tcg64f32 = class(tcg64)
         procedure a_reg_alloc(list : taasmoutput;r : tregister64);override;
         procedure a_reg_alloc(list : taasmoutput;r : tregister64);override;
         procedure a_reg_dealloc(list : taasmoutput;r : tregister64);override;
         procedure a_reg_dealloc(list : taasmoutput;r : tregister64);override;
-        procedure a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);override;
+        procedure a_load64_const_ref(list : taasmoutput;value : int64;const ref : treference);override;
         procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);override;
         procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);override;
         procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);override;
         procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);override;
         procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);override;
         procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);override;
-        procedure a_load64_const_reg(list : taasmoutput;value: qword;reg : tregister64);override;
+        procedure a_load64_const_reg(list : taasmoutput;value: int64;reg : tregister64);override;
         procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);override;
         procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);override;
         procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);override;
         procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);override;
-        procedure a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);override;
+        procedure a_load64_const_loc(list : taasmoutput;value : int64;const l : tlocation);override;
         procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);override;
         procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);override;
 
 
         procedure a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);override;
         procedure a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);override;
@@ -67,13 +67,13 @@ unit cg64f32;
 
 
         procedure a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);override;
         procedure a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);override;
         procedure a_op64_reg_ref(list : taasmoutput;op:TOpCG;reg : tregister64; const ref: treference);override;
         procedure a_op64_reg_ref(list : taasmoutput;op:TOpCG;reg : tregister64; const ref: treference);override;
-        procedure a_op64_const_loc(list : taasmoutput;op:TOpCG;value : qword;const l: tlocation);override;
+        procedure a_op64_const_loc(list : taasmoutput;op:TOpCG;value : int64;const l: tlocation);override;
         procedure a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);override;
         procedure a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);override;
         procedure a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg : tregister64);override;
         procedure a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg : tregister64);override;
-        procedure a_op64_const_ref(list : taasmoutput;op:TOpCG;value : qword;const ref : treference);override;
+        procedure a_op64_const_ref(list : taasmoutput;op:TOpCG;value : int64;const ref : treference);override;
 
 
         procedure a_param64_reg(list : taasmoutput;reg : tregister64;const locpara : tparalocation);override;
         procedure a_param64_reg(list : taasmoutput;reg : tregister64;const locpara : tparalocation);override;
-        procedure a_param64_const(list : taasmoutput;value : qword;const locpara : tparalocation);override;
+        procedure a_param64_const(list : taasmoutput;value : int64;const locpara : tparalocation);override;
         procedure a_param64_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);override;
         procedure a_param64_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);override;
         procedure a_param64_loc(list : taasmoutput;const l : tlocation;const locpara : tparalocation);override;
         procedure a_param64_loc(list : taasmoutput;const l : tlocation;const locpara : tparalocation);override;
 
 
@@ -82,7 +82,7 @@ unit cg64f32;
            must continue in op64_const_reg, otherwise, everything is processed
            must continue in op64_const_reg, otherwise, everything is processed
            entirely in this routine, by emitting the appropriate 32-bit opcodes.
            entirely in this routine, by emitting the appropriate 32-bit opcodes.
         }
         }
-        function optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : qword; var reg: tregister64): boolean;override;
+        function optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : int64; var reg: tregister64): boolean;override;
 
 
         procedure g_rangecheck64(list: taasmoutput; const l:tlocation;fromdef,todef: tdef); override;
         procedure g_rangecheck64(list: taasmoutput; const l:tlocation;fromdef,todef: tdef); override;
       end;
       end;
@@ -93,7 +93,7 @@ unit cg64f32;
   implementation
   implementation
 
 
     uses
     uses
-       globals,systems,
+       globtype,globals,systems,
        verbose,
        verbose,
        symbase,symconst,symdef,defutil,tgobj,paramgr;
        symbase,symconst,symdef,defutil,tgobj,paramgr;
 
 
@@ -108,6 +108,12 @@ unit cg64f32;
       end;
       end;
 
 
 
 
+    procedure swap64(var q : int64);
+      begin
+         q:=(int64(lo(q)) shl 32) or hi(q);
+      end;
+
+
 {****************************************************************************
 {****************************************************************************
                                    TCG64F32
                                    TCG64F32
 ****************************************************************************}
 ****************************************************************************}
@@ -144,16 +150,16 @@ unit cg64f32;
       end;
       end;
 
 
 
 
-    procedure tcg64f32.a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);
+    procedure tcg64f32.a_load64_const_ref(list : taasmoutput;value : int64;const ref : treference);
       var
       var
         tmpref: treference;
         tmpref: treference;
       begin
       begin
         if target_info.endian = endian_big then
         if target_info.endian = endian_big then
-          swap_qword(value);
-        cg.a_load_const_ref(list,OS_32,lo(value),ref);
+          swap64(value);
+        cg.a_load_const_ref(list,OS_32,aint(lo(value)),ref);
         tmpref := ref;
         tmpref := ref;
         inc(tmpref.offset,4);
         inc(tmpref.offset,4);
-        cg.a_load_const_ref(list,OS_32,hi(value),tmpref);
+        cg.a_load_const_ref(list,OS_32,aint(hi(value)),tmpref);
       end;
       end;
 
 
 
 
@@ -205,11 +211,11 @@ unit cg64f32;
       end;
       end;
 
 
 
 
-    procedure tcg64f32.a_load64_const_reg(list : taasmoutput;value : qword;reg : tregister64);
+    procedure tcg64f32.a_load64_const_reg(list : taasmoutput;value : int64;reg : tregister64);
 
 
       begin
       begin
-        cg.a_load_const_reg(list,OS_32,lo(value),reg.reglo);
-        cg.a_load_const_reg(list,OS_32,hi(value),reg.reghi);
+        cg.a_load_const_reg(list,OS_32,aint(lo(value)),reg.reglo);
+        cg.a_load_const_reg(list,OS_32,aint(hi(value)),reg.reghi);
       end;
       end;
 
 
 
 
@@ -222,7 +228,7 @@ unit cg64f32;
           LOC_REGISTER,LOC_CREGISTER:
           LOC_REGISTER,LOC_CREGISTER:
             a_load64_reg_reg(list,l.register64,reg);
             a_load64_reg_reg(list,l.register64,reg);
           LOC_CONSTANT :
           LOC_CONSTANT :
-            a_load64_const_reg(list,l.valueqword,reg);
+            a_load64_const_reg(list,l.value64,reg);
           else
           else
             internalerror(200112292);
             internalerror(200112292);
         end;
         end;
@@ -235,14 +241,14 @@ unit cg64f32;
           LOC_REGISTER,LOC_CREGISTER:
           LOC_REGISTER,LOC_CREGISTER:
             a_load64_reg_ref(list,l.reg64,ref);
             a_load64_reg_ref(list,l.reg64,ref);
           LOC_CONSTANT :
           LOC_CONSTANT :
-            a_load64_const_ref(list,l.valueqword,ref);
+            a_load64_const_ref(list,l.value64,ref);
           else
           else
             internalerror(200203288);
             internalerror(200203288);
         end;
         end;
       end;
       end;
 
 
 
 
-    procedure tcg64f32.a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);
+    procedure tcg64f32.a_load64_const_loc(list : taasmoutput;value : int64;const l : tlocation);
 
 
       begin
       begin
         case l.loc of
         case l.loc of
@@ -338,12 +344,13 @@ unit cg64f32;
           LOC_REGISTER :
           LOC_REGISTER :
             cg.a_load_reg_reg(list,OS_32,OS_32,l.registerlow,reg);
             cg.a_load_reg_reg(list,OS_32,OS_32,l.registerlow,reg);
           LOC_CONSTANT :
           LOC_CONSTANT :
-            cg.a_load_const_reg(list,OS_32,lo(l.valueqword),reg);
+            cg.a_load_const_reg(list,OS_32,aint(lo(l.value64)),reg);
           else
           else
             internalerror(200203244);
             internalerror(200203244);
         end;
         end;
       end;
       end;
 
 
+
     procedure tcg64f32.a_load64high_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);
     procedure tcg64f32.a_load64high_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);
       begin
       begin
         case l.loc of
         case l.loc of
@@ -353,14 +360,14 @@ unit cg64f32;
           LOC_REGISTER :
           LOC_REGISTER :
             cg.a_load_reg_reg(list,OS_32,OS_32,l.registerhigh,reg);
             cg.a_load_reg_reg(list,OS_32,OS_32,l.registerhigh,reg);
           LOC_CONSTANT :
           LOC_CONSTANT :
-            cg.a_load_const_reg(list,OS_32,hi(l.valueqword),reg);
+            cg.a_load_const_reg(list,OS_32,hi(l.value64),reg);
           else
           else
             internalerror(200203244);
             internalerror(200203244);
         end;
         end;
       end;
       end;
 
 
 
 
-    procedure tcg64f32.a_op64_const_loc(list : taasmoutput;op:TOpCG;value : qword;const l: tlocation);
+    procedure tcg64f32.a_op64_const_loc(list : taasmoutput;op:TOpCG;value : int64;const l: tlocation);
       begin
       begin
         case l.loc of
         case l.loc of
           LOC_REFERENCE, LOC_CREFERENCE:
           LOC_REFERENCE, LOC_CREFERENCE:
@@ -395,7 +402,7 @@ unit cg64f32;
           LOC_REGISTER,LOC_CREGISTER:
           LOC_REGISTER,LOC_CREGISTER:
             a_op64_reg_reg(list,op,l.register64,reg);
             a_op64_reg_reg(list,op,l.register64,reg);
           LOC_CONSTANT :
           LOC_CONSTANT :
-            a_op64_const_reg(list,op,l.valueqword,reg);
+            a_op64_const_reg(list,op,l.value64,reg);
           else
           else
             internalerror(200203242);
             internalerror(200203242);
         end;
         end;
@@ -406,8 +413,8 @@ unit cg64f32;
       var
       var
         tempreg: tregister64;
         tempreg: tregister64;
       begin
       begin
-        tempreg.reghi:=cg.getintregister(list,OS_INT);
-        tempreg.reglo:=cg.getintregister(list,OS_INT);
+        tempreg.reghi:=cg.getintregister(list,OS_32);
+        tempreg.reglo:=cg.getintregister(list,OS_32);
         a_load64_ref_reg(list,ref,tempreg);
         a_load64_ref_reg(list,ref,tempreg);
         a_op64_reg_reg(list,op,tempreg,reg);
         a_op64_reg_reg(list,op,tempreg,reg);
         cg.ungetregister(list,tempreg.reglo);
         cg.ungetregister(list,tempreg.reglo);
@@ -419,8 +426,8 @@ unit cg64f32;
       var
       var
         tempreg: tregister64;
         tempreg: tregister64;
       begin
       begin
-        tempreg.reghi:=cg.getintregister(list,OS_INT);
-        tempreg.reglo:=cg.getintregister(list,OS_INT);
+        tempreg.reghi:=cg.getintregister(list,OS_32);
+        tempreg.reglo:=cg.getintregister(list,OS_32);
         a_load64_ref_reg(list,ref,tempreg);
         a_load64_ref_reg(list,ref,tempreg);
         a_op64_reg_reg(list,op,reg,tempreg);
         a_op64_reg_reg(list,op,reg,tempreg);
         a_load64_reg_ref(list,tempreg,ref);
         a_load64_reg_ref(list,tempreg,ref);
@@ -429,12 +436,12 @@ unit cg64f32;
       end;
       end;
 
 
 
 
-    procedure tcg64f32.a_op64_const_ref(list : taasmoutput;op:TOpCG;value : qword;const ref : treference);
+    procedure tcg64f32.a_op64_const_ref(list : taasmoutput;op:TOpCG;value : int64;const ref : treference);
       var
       var
         tempreg: tregister64;
         tempreg: tregister64;
       begin
       begin
-        tempreg.reghi:=cg.getintregister(list,OS_INT);
-        tempreg.reglo:=cg.getintregister(list,OS_INT);
+        tempreg.reghi:=cg.getintregister(list,OS_32);
+        tempreg.reglo:=cg.getintregister(list,OS_32);
         a_load64_ref_reg(list,ref,tempreg);
         a_load64_ref_reg(list,ref,tempreg);
         a_op64_const_reg(list,op,value,tempreg);
         a_op64_const_reg(list,op,value,tempreg);
         a_load64_reg_ref(list,tempreg,ref);
         a_load64_reg_ref(list,tempreg,ref);
@@ -453,13 +460,13 @@ unit cg64f32;
       end;
       end;
 
 
 
 
-    procedure tcg64f32.a_param64_const(list : taasmoutput;value : qword;const locpara : tparalocation);
+    procedure tcg64f32.a_param64_const(list : taasmoutput;value : int64;const locpara : tparalocation);
       var
       var
         tmplochi,tmploclo: tparalocation;
         tmplochi,tmploclo: tparalocation;
       begin
       begin
         paramanager.splitparaloc64(locpara,tmploclo,tmplochi);
         paramanager.splitparaloc64(locpara,tmploclo,tmplochi);
-        cg.a_param_const(list,OS_32,hi(value),tmplochi);
-        cg.a_param_const(list,OS_32,lo(value),tmploclo);
+        cg.a_param_const(list,OS_32,aint(hi(value)),tmplochi);
+        cg.a_param_const(list,OS_32,aint(lo(value)),tmploclo);
       end;
       end;
 
 
 
 
@@ -487,7 +494,7 @@ unit cg64f32;
           LOC_CREGISTER :
           LOC_CREGISTER :
             a_param64_reg(list,l.register64,locpara);
             a_param64_reg(list,l.register64,locpara);
           LOC_CONSTANT :
           LOC_CONSTANT :
-            a_param64_const(list,l.valueqword,locpara);
+            a_param64_const(list,l.value64,locpara);
           LOC_CREFERENCE,
           LOC_CREFERENCE,
           LOC_REFERENCE :
           LOC_REFERENCE :
             a_param64_ref(list,l.reference,locpara);
             a_param64_ref(list,l.reference,locpara);
@@ -528,7 +535,7 @@ unit cg64f32;
                end
                end
              else
              else
                begin
                begin
-                 hreg:=cg.getintregister(list,OS_INT);
+                 hreg:=cg.getintregister(list,OS_32);
                  got_scratch := true;
                  got_scratch := true;
                  a_load64high_ref_reg(list,l.reference,hreg);
                  a_load64high_ref_reg(list,l.reference,hreg);
                end;
                end;
@@ -541,7 +548,7 @@ unit cg64f32;
              if from_signed and to_signed then
              if from_signed and to_signed then
                begin
                begin
                  objectlibrary.getlabel(neglabel);
                  objectlibrary.getlabel(neglabel);
-                 cg.a_cmp_const_reg_label(list,OS_32,OC_EQ,aword(-1),hreg,neglabel);
+                 cg.a_cmp_const_reg_label(list,OS_32,OC_EQ,-1,hreg,neglabel);
                end;
                end;
              { !!! freeing of register should happen directly after compare! (JM) }
              { !!! freeing of register should happen directly after compare! (JM) }
              if got_scratch then
              if got_scratch then
@@ -552,7 +559,7 @@ unit cg64f32;
              { if the high dword = 0, the low dword can be considered a }
              { if the high dword = 0, the low dword can be considered a }
              { simple cardinal                                          }
              { simple cardinal                                          }
              cg.a_label(list,poslabel);
              cg.a_label(list,poslabel);
-             hdef:=torddef.create(u32bit,0,cardinal($ffffffff));
+             hdef:=torddef.create(u32bit,0,$ffffffff);
 
 
              location_copy(temploc,l);
              location_copy(temploc,l);
              temploc.size:=OS_32;
              temploc.size:=OS_32;
@@ -578,7 +585,7 @@ unit cg64f32;
                    end
                    end
                  else
                  else
                    begin
                    begin
-                     hreg:=cg.getintregister(list,OS_INT);
+                     hreg:=cg.getintregister(list,OS_32);
                      got_scratch := true;
                      got_scratch := true;
                      a_load64low_ref_reg(list,l.reference,hreg);
                      a_load64low_ref_reg(list,l.reference,hreg);
                    end;
                    end;
@@ -631,14 +638,14 @@ unit cg64f32;
                  end
                  end
                else
                else
                  begin
                  begin
-                   hreg:=cg.getintregister(list,OS_INT);
+                   hreg:=cg.getintregister(list,OS_32);
                    got_scratch := true;
                    got_scratch := true;
 
 
                    opsize := def_cgsize(fromdef);
                    opsize := def_cgsize(fromdef);
                    if opsize in [OS_64,OS_S64] then
                    if opsize in [OS_64,OS_S64] then
                      a_load64high_ref_reg(list,l.reference,hreg)
                      a_load64high_ref_reg(list,l.reference,hreg)
                    else
                    else
-                     cg.a_load_ref_reg(list,opsize,OS_INT,l.reference,hreg);
+                     cg.a_load_ref_reg(list,opsize,OS_32,l.reference,hreg);
                  end;
                  end;
                objectlibrary.getlabel(poslabel);
                objectlibrary.getlabel(poslabel);
                cg.a_cmp_const_reg_label(list,opsize,OC_GTE,0,hreg,poslabel);
                cg.a_cmp_const_reg_label(list,opsize,OC_GTE,0,hreg,poslabel);
@@ -651,7 +658,7 @@ unit cg64f32;
              end;
              end;
       end;
       end;
 
 
-    function tcg64f32.optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : qword; var reg: tregister64): boolean;
+    function tcg64f32.optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : int64; var reg: tregister64): boolean;
       var
       var
         lowvalue, highvalue : cardinal;
         lowvalue, highvalue : cardinal;
         hreg: tregister;
         hreg: tregister;
@@ -746,7 +753,26 @@ unit cg64f32;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.57  2004-01-22 02:22:47  florian
+  Revision 1.58  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.57.2.5  2004/06/13 10:51:16  florian
+    * fixed several register allocator problems (sparc/arm)
+
+  Revision 1.57.2.4  2004/06/12 17:01:01  florian
+    * fixed compilation of arm compiler
+
+  Revision 1.57.2.3  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.57.2.2  2004/04/29 19:07:22  peter
+    * compile fixes
+
+  Revision 1.57.2.1  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.57  2004/01/22 02:22:47  florian
     * op_const_reg_reg with OP_SAR fixed
     * op_const_reg_reg with OP_SAR fixed
 
 
   Revision 1.56  2003/12/24 00:10:02  florian
   Revision 1.56  2003/12/24 00:10:02  florian
@@ -882,8 +908,8 @@ end.
   Revision 1.25  2002/08/14 18:41:47  jonas
   Revision 1.25  2002/08/14 18:41:47  jonas
     - remove valuelow/valuehigh fields from tlocation, because they depend
     - remove valuelow/valuehigh fields from tlocation, because they depend
       on the endianess of the host operating system -> difficult to get
       on the endianess of the host operating system -> difficult to get
-      right. Use lo/hi(location.valueqword) instead (remember to use
-      valueqword and not value!!)
+      right. Use lo/hi(location.valueint64) instead (remember to use
+      valueint64 and not value!!)
 
 
   Revision 1.24  2002/08/11 14:32:26  peter
   Revision 1.24  2002/08/11 14:32:26  peter
     * renamed current_library to objectlibrary
     * renamed current_library to objectlibrary

+ 81 - 24
compiler/cg64f64.pas

@@ -37,6 +37,7 @@ unit cg64f64;
        cgbase,cgobj,
        cgbase,cgobj,
        symtype;
        symtype;
 
 
+{$ifndef cpu64bit}
     type
     type
       {# Defines all the methods required on 32-bit processors
       {# Defines all the methods required on 32-bit processors
          to handle 64-bit integers.
          to handle 64-bit integers.
@@ -44,14 +45,14 @@ unit cg64f64;
       tcg64f64 = class(tcg64)
       tcg64f64 = class(tcg64)
         procedure a_reg_alloc(list : taasmoutput;r : tregister64);override;
         procedure a_reg_alloc(list : taasmoutput;r : tregister64);override;
         procedure a_reg_dealloc(list : taasmoutput;r : tregister64);override;
         procedure a_reg_dealloc(list : taasmoutput;r : tregister64);override;
-        procedure a_load64_const_ref(list : taasmoutput;value : AWord;const ref : treference);override;
+        procedure a_load64_const_ref(list : taasmoutput;value : int64;const ref : treference);override;
         procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);override;
         procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);override;
         procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);override;
         procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);override;
         procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);override;
         procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);override;
-        procedure a_load64_const_reg(list : taasmoutput;value: qword;reg : tregister64);override;
+        procedure a_load64_const_reg(list : taasmoutput;value: int64;reg : tregister64);override;
         procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);override;
         procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);override;
         procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);override;
         procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);override;
-        procedure a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);override;
+        procedure a_load64_const_loc(list : taasmoutput;value : int64;const l : tlocation);override;
         procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);override;
         procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);override;
 
 
         procedure a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);override;
         procedure a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);override;
@@ -63,92 +64,116 @@ unit cg64f64;
 
 
         procedure a_op64_reg_ref(list : taasmoutput;op:TOpCG;regsrc : tregister64;const ref : treference);override;
         procedure a_op64_reg_ref(list : taasmoutput;op:TOpCG;regsrc : tregister64;const ref : treference);override;
         procedure a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);override;
         procedure a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);override;
-        procedure a_op64_const_loc(list : taasmoutput;op:TOpCG;value:qword;const l: tlocation);override;
+        procedure a_op64_const_loc(list : taasmoutput;op:TOpCG;value:int64;const l: tlocation);override;
         procedure a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);override;
         procedure a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);override;
         procedure a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg : tregister64);override;
         procedure a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg : tregister64);override;
-        procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;regdst : tregister64);override;
-        procedure a_op64_const_ref(list : taasmoutput;op:TOpCG;value : qword;const ref : treference);override;
+        procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : int64;regdst : tregister64);override;
+        procedure a_op64_const_ref(list : taasmoutput;op:TOpCG;value : int64;const ref : treference);override;
 
 
         procedure a_param64_reg(list : taasmoutput;reg : tregister64;const locpara : tparalocation);override;
         procedure a_param64_reg(list : taasmoutput;reg : tregister64;const locpara : tparalocation);override;
-        procedure a_param64_const(list : taasmoutput;value : qword;const locpara : tparalocation);override;
+        procedure a_param64_const(list : taasmoutput;value : int64;const locpara : tparalocation);override;
         procedure a_param64_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);override;
         procedure a_param64_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);override;
         procedure a_param64_loc(list : taasmoutput;const l : tlocation;const locpara : tparalocation);override;
         procedure a_param64_loc(list : taasmoutput;const l : tlocation;const locpara : tparalocation);override;
 
 
-        function optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : qword; var reg: tregister64): boolean;override;
+        function optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : int64; var reg: tregister64): boolean;override;
 
 
         { override to catch 64bit rangechecks }
         { override to catch 64bit rangechecks }
         procedure g_rangecheck64(list: taasmoutput; const l:tlocation;fromdef,todef: tdef); override;
         procedure g_rangecheck64(list: taasmoutput; const l:tlocation;fromdef,todef: tdef); override;
       end;
       end;
+{$endif cpu64bit}
 
 
   implementation
   implementation
 
 
-    procedure tcg64f64.a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);
+    uses
+      verbose;
+
+{$ifndef cpu64bit}
+    procedure tcg64f64.a_load64_const_ref(list : taasmoutput;value : int64;const ref : treference);
       begin
       begin
          cg.a_load_const_ref(list,OS_64,value,ref);
          cg.a_load_const_ref(list,OS_64,value,ref);
       end;
       end;
 
 
+
     procedure tcg64f64.a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);
     procedure tcg64f64.a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);
       begin
       begin
          cg.a_load_reg_ref(list,OS_64,OS_64,reg,ref);
          cg.a_load_reg_ref(list,OS_64,OS_64,reg,ref);
       end;
       end;
 
 
+
     procedure tcg64f64.a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);
     procedure tcg64f64.a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);
       begin
       begin
          cg.a_load_ref_reg(list,OS_64,OS_64,ref,reg);
          cg.a_load_ref_reg(list,OS_64,OS_64,ref,reg);
       end;
       end;
 
 
+
     procedure tcg64f64.a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);
     procedure tcg64f64.a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);
       begin
       begin
          cg.a_load_reg_reg(list,OS_64,OS_64,regsrc,regdst);
          cg.a_load_reg_reg(list,OS_64,OS_64,regsrc,regdst);
       end;
       end;
 
 
-    procedure tcg64f64.a_load64_const_reg(list : taasmoutput;value : qword;reg : tregister64);
+
+    procedure tcg64f64.a_load64_const_reg(list : taasmoutput;value : int64;reg : tregister64);
       begin
       begin
          cg.a_load_const_reg(list,OS_64,value,reg);
          cg.a_load_const_reg(list,OS_64,value,reg);
       end;
       end;
 
 
+
     procedure tcg64f64.a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);
     procedure tcg64f64.a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);
       begin
       begin
          cg.a_load_loc_reg(list,l.size,l,reg);
          cg.a_load_loc_reg(list,l.size,l,reg);
       end;
       end;
 
 
+
     procedure tcg64f64.a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);
     procedure tcg64f64.a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);
       begin
       begin
          cg.a_load_loc_ref(list,l.size,l,ref);
          cg.a_load_loc_ref(list,l.size,l,ref);
       end;
       end;
 
 
-    procedure tcg64f64.a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);
+
+    procedure tcg64f64.a_load64_const_loc(list : taasmoutput;value : int64;const l : tlocation);
       begin
       begin
          cg.a_load_const_loc(list,value,l);
          cg.a_load_const_loc(list,value,l);
       end;
       end;
 
 
+
     procedure tcg64f64.a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);
     procedure tcg64f64.a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);
       begin
       begin
          cg.a_load_reg_loc(list,OS_64,reg,l);
          cg.a_load_reg_loc(list,OS_64,reg,l);
       end;
       end;
 
 
+
     procedure tcg64f64.a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);
     procedure tcg64f64.a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);
       begin
       begin
+        internalerror(200404211);
       end;
       end;
 
 
+
     procedure tcg64f64.a_load64low_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);
     procedure tcg64f64.a_load64low_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);
       begin
       begin
+        internalerror(200404212);
       end;
       end;
 
 
+
     procedure tcg64f64.a_load64high_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);
     procedure tcg64f64.a_load64high_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);
       begin
       begin
+        internalerror(200404213);
       end;
       end;
 
 
+
     procedure tcg64f64.a_load64low_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);
     procedure tcg64f64.a_load64low_ref_reg(list : taasmoutput;const ref : treference;reg : tregister);
       begin
       begin
+        internalerror(200404214);
       end;
       end;
 
 
+
     procedure tcg64f64.a_load64high_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);
     procedure tcg64f64.a_load64high_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);
       begin
       begin
+        internalerror(200404215);
       end;
       end;
 
 
     procedure tcg64f64.a_load64low_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);
     procedure tcg64f64.a_load64low_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister);
       begin
       begin
+        internalerror(200404216);
       end;
       end;
 
 
 
 
@@ -157,73 +182,105 @@ unit cg64f64;
          cg.a_op_ref_reg(list,op,OS_64,ref,reg);
          cg.a_op_ref_reg(list,op,OS_64,ref,reg);
       end;
       end;
 
 
+
     procedure tcg64f64.a_op64_reg_ref(list : taasmoutput;op:TOpCG;regsrc : tregister64;const ref : treference);
     procedure tcg64f64.a_op64_reg_ref(list : taasmoutput;op:TOpCG;regsrc : tregister64;const ref : treference);
       begin
       begin
+        cg.a_op_reg_ref(list,op,OS_64,regsrc,ref);
       end;
       end;
 
 
-    procedure tcg64f64.a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;regdst : tregister64);
+
+    procedure tcg64f64.a_op64_const_reg(list : taasmoutput;op:TOpCG;value : int64;regdst : tregister64);
       begin
       begin
+        cg.a_op_const_reg(list,op,OS_64,value,regdst);
       end;
       end;
 
 
-    procedure tcg64f64.a_op64_const_ref(list : taasmoutput;op:TOpCG;value : qword;const ref : treference);
+
+    procedure tcg64f64.a_op64_const_ref(list : taasmoutput;op:TOpCG;value : int64;const ref : treference);
       begin
       begin
+        cg.a_op_const_ref(list,op,OS_64,value,ref);
       end;
       end;
 
 
-    procedure tcg64f64.a_op64_const_loc(list : taasmoutput;op:TOpCG;value : qword;const l: tlocation);
+
+    procedure tcg64f64.a_op64_const_loc(list : taasmoutput;op:TOpCG;value : int64;const l: tlocation);
       begin
       begin
+        cg.a_op_const_loc(list,op,value,l);
       end;
       end;
 
 
+
     procedure tcg64f64.a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);
     procedure tcg64f64.a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);
       begin
       begin
+        cg.a_op_reg_loc(list,op,reg,l);
       end;
       end;
 
 
+
     procedure tcg64f64.a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg : tregister64);
     procedure tcg64f64.a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg : tregister64);
       begin
       begin
+        internalerror(200404217);
       end;
       end;
 
 
+
     procedure tcg64f64.a_param64_reg(list : taasmoutput;reg : tregister64;const locpara : tparalocation);
     procedure tcg64f64.a_param64_reg(list : taasmoutput;reg : tregister64;const locpara : tparalocation);
       begin
       begin
+        cg.a_param_reg(list,OS_64,reg,locpara);
       end;
       end;
 
 
-    procedure tcg64f64.a_param64_const(list : taasmoutput;value : qword;const locpara : tparalocation);
+
+    procedure tcg64f64.a_param64_const(list : taasmoutput;value : int64;const locpara : tparalocation);
       begin
       begin
+        cg.a_param_const(list,OS_64,value,locpara);
       end;
       end;
 
 
+
     procedure tcg64f64.a_param64_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);
     procedure tcg64f64.a_param64_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);
       begin
       begin
+        cg.a_param_ref(list,OS_64,r,locpara);
       end;
       end;
 
 
+
     procedure tcg64f64.a_param64_loc(list : taasmoutput;const l : tlocation;const locpara : tparalocation);
     procedure tcg64f64.a_param64_loc(list : taasmoutput;const l : tlocation;const locpara : tparalocation);
       begin
       begin
+        cg.a_param_loc(list,l,locpara);
       end;
       end;
 
 
+
     procedure tcg64f64.g_rangecheck64(list: taasmoutput; const l:tlocation;fromdef,todef: tdef);
     procedure tcg64f64.g_rangecheck64(list: taasmoutput; const l:tlocation;fromdef,todef: tdef);
       begin
       begin
+        cg.g_rangecheck(list,l,fromdef,todef);
       end;
       end;
 
 
-    function tcg64f64.optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : qword; var reg: tregister64): boolean;
-     begin
-       { this should be the same routine as optimize_const_reg!!!!!!!! }
-     end;
 
 
+    function tcg64f64.optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : int64; var reg: tregister64): boolean;
+      begin
+        result:=cg.optimize_op_const_reg(list,op,a,reg);
+      end;
 
 
-    procedure tcg64f64.a_reg_alloc(list : taasmoutput;r : tregister64);
 
 
+    procedure tcg64f64.a_reg_alloc(list : taasmoutput;r : tregister64);
       begin
       begin
-         list.concat(tai_regalloc.alloc(r));
+        list.concat(tai_regalloc.alloc(r));
       end;
       end;
 
 
-    procedure tcg64f64.a_reg_dealloc(list : taasmoutput;r : tregister64);
 
 
+    procedure tcg64f64.a_reg_dealloc(list : taasmoutput;r : tregister64);
       begin
       begin
-         list.concat(tai_regalloc.dealloc(r));
+        list.concat(tai_regalloc.dealloc(r));
       end;
       end;
+{$endif cpu64bit}
 
 
 
 
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2004-01-13 18:08:58  florian
+  Revision 1.12  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.11.2.2  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.11.2.1  2004/04/21 18:54:29  florian
+    + implemented most methods as redirections to cg
+
+  Revision 1.11  2004/01/13 18:08:58  florian
     * x86-64 compilation fixed
     * x86-64 compilation fixed
 
 
   Revision 1.10  2003/12/24 00:10:02  florian
   Revision 1.10  2003/12/24 00:10:02  florian

+ 14 - 3
compiler/cgbase.pas

@@ -28,6 +28,7 @@ unit cgbase;
 interface
 interface
 
 
     uses
     uses
+      globtype,
       cpuinfo,
       cpuinfo,
       symconst;
       symconst;
 
 
@@ -283,7 +284,7 @@ interface
     {# From a constant numeric value, return the abstract code generator
     {# From a constant numeric value, return the abstract code generator
        size.
        size.
     }
     }
-    function int_cgsize(const a: aword): tcgsize;{$ifdef USEINLINE}inline;{$endif}
+    function int_cgsize(const a: aint): tcgsize;{$ifdef USEINLINE}inline;{$endif}
 
 
     { return the inverse condition of opcmp }
     { return the inverse condition of opcmp }
     function inverse_opcmp(opcmp: topcmp): topcmp;{$ifdef USEINLINE}inline;{$endif}
     function inverse_opcmp(opcmp: topcmp): topcmp;{$ifdef USEINLINE}inline;{$endif}
@@ -510,7 +511,7 @@ implementation
       end;
       end;
 
 
 
 
-    function int_cgsize(const a: aword): tcgsize;{$ifdef USEINLINE}inline;{$endif}
+    function int_cgsize(const a: aint): tcgsize;{$ifdef USEINLINE}inline;{$endif}
       const
       const
         size2cgsize : array[0..8] of tcgsize = (
         size2cgsize : array[0..8] of tcgsize = (
           OS_NO,OS_8,OS_16,OS_32,OS_32,OS_64,OS_64,OS_64,OS_64
           OS_NO,OS_8,OS_16,OS_32,OS_32,OS_64,OS_64,OS_64,OS_64
@@ -587,7 +588,17 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.88  2004-02-27 10:21:05  florian
+  Revision 1.89  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.88.2.2  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.88.2.1  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.88  2004/02/27 10:21:05  florian
     * top_symbol killed
     * top_symbol killed
     + refaddr to treference added
     + refaddr to treference added
     + refsymbol to treference added
     + refsymbol to treference added

+ 243 - 147
compiler/cgobj.pas

@@ -1,6 +1,5 @@
 {
 {
     $Id$
     $Id$
-
     Copyright (c) 1998-2002 by Florian Klaempfl
     Copyright (c) 1998-2002 by Florian Klaempfl
     Member of the Free Pascal development team
     Member of the Free Pascal development team
 
 
@@ -41,7 +40,7 @@ unit cgobj;
 {$ifdef delphi}
 {$ifdef delphi}
        dmisc,
        dmisc,
 {$endif}
 {$endif}
-       cclasses,
+       cclasses,globtype,
        cpubase,cpuinfo,cgbase,
        cpubase,cpuinfo,cgbase,
        aasmbase,aasmtai,aasmcpu,
        aasmbase,aasmtai,aasmcpu,
        symconst,symbase,symtype,symdef,symtable,rgobj
        symconst,symbase,symtype,symdef,symtable,rgobj
@@ -106,9 +105,6 @@ unit cgobj;
 
 
           function makeregsize(list:Taasmoutput;reg:Tregister;size:Tcgsize):Tregister;
           function makeregsize(list:Taasmoutput;reg:Tregister;size:Tcgsize):Tregister;
 
 
-          {# Returns the tcgsize corresponding with the size of reg.}
-          class function reg_cgsize(const reg: tregister) : tcgsize; virtual;
-
           {# Emit a label to the instruction stream. }
           {# Emit a label to the instruction stream. }
           procedure a_label(list : taasmoutput;l : tasmlabel);virtual;
           procedure a_label(list : taasmoutput;l : tasmlabel);virtual;
 
 
@@ -138,7 +134,7 @@ unit cgobj;
              @param(a value of constant to send)
              @param(a value of constant to send)
              @param(locpara where the parameter will be stored)
              @param(locpara where the parameter will be stored)
           }
           }
-          procedure a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);virtual;
+          procedure a_param_const(list : taasmoutput;size : tcgsize;a : aint;const locpara : tparalocation);virtual;
           {# Pass the value of a parameter, which is located in memory, to a routine.
           {# Pass the value of a parameter, which is located in memory, to a routine.
 
 
              A generic version is provided. This routine should
              A generic version is provided. This routine should
@@ -174,7 +170,7 @@ unit cgobj;
           procedure a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);virtual;
           procedure a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);virtual;
 
 
           { Copies a whole memory block to the stack, the locpara must be a memory location }
           { Copies a whole memory block to the stack, the locpara must be a memory location }
-          procedure a_param_copy_ref(list : taasmoutput;size : qword;const r : treference;const locpara : tparalocation);
+          procedure a_param_copy_ref(list : taasmoutput;size : aint;const r : treference;const locpara : tparalocation);
           { Remarks:
           { Remarks:
             * If a method specifies a size you have only to take care
             * If a method specifies a size you have only to take care
               of that number of bits, i.e. load_const_reg with OP_8 must
               of that number of bits, i.e. load_const_reg with OP_8 must
@@ -208,9 +204,9 @@ unit cgobj;
           procedure a_call_reg(list : taasmoutput;reg : tregister);virtual;abstract;
           procedure a_call_reg(list : taasmoutput;reg : tregister);virtual;abstract;
 
 
           { move instructions }
           { move instructions }
-          procedure a_load_const_reg(list : taasmoutput;size : tcgsize;a : aword;register : tregister);virtual; abstract;
-          procedure a_load_const_ref(list : taasmoutput;size : tcgsize;a : aword;const ref : treference);virtual;
-          procedure a_load_const_loc(list : taasmoutput;a : aword;const loc : tlocation);
+          procedure a_load_const_reg(list : taasmoutput;size : tcgsize;a : aint;register : tregister);virtual; abstract;
+          procedure a_load_const_ref(list : taasmoutput;size : tcgsize;a : aint;const ref : treference);virtual;
+          procedure a_load_const_loc(list : taasmoutput;a : aint;const loc : tlocation);
           procedure a_load_reg_ref(list : taasmoutput;fromsize,tosize : tcgsize;register : tregister;const ref : treference);virtual; abstract;
           procedure a_load_reg_ref(list : taasmoutput;fromsize,tosize : tcgsize;register : tregister;const ref : treference);virtual; abstract;
           procedure a_load_reg_reg(list : taasmoutput;fromsize,tosize : tcgsize;reg1,reg2 : tregister);virtual; abstract;
           procedure a_load_reg_reg(list : taasmoutput;fromsize,tosize : tcgsize;reg1,reg2 : tregister);virtual; abstract;
           procedure a_load_reg_loc(list : taasmoutput;fromsize : tcgsize;reg : tregister;const loc: tlocation);
           procedure a_load_reg_loc(list : taasmoutput;fromsize : tcgsize;reg : tregister;const loc: tlocation);
@@ -248,9 +244,9 @@ unit cgobj;
           { the op_reg_reg, op_reg_ref or op_reg_loc methods and keep in mind   }
           { the op_reg_reg, op_reg_ref or op_reg_loc methods and keep in mind   }
           { that in this case the *second* operand is used as both source and   }
           { that in this case the *second* operand is used as both source and   }
           { destination (JM)                                                    }
           { destination (JM)                                                    }
-          procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; reg: TRegister); virtual; abstract;
-          procedure a_op_const_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; const ref: TReference); virtual;
-          procedure a_op_const_loc(list : taasmoutput; Op: TOpCG; a: AWord; const loc: tlocation);
+          procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: Aint; reg: TRegister); virtual; abstract;
+          procedure a_op_const_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; a: Aint; const ref: TReference); virtual;
+          procedure a_op_const_loc(list : taasmoutput; Op: TOpCG; a: Aint; const loc: tlocation);
           procedure a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; reg1, reg2: TRegister); virtual; abstract;
           procedure a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; reg1, reg2: TRegister); virtual; abstract;
           procedure a_op_reg_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; reg: TRegister; const ref: TReference); virtual;
           procedure a_op_reg_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; reg: TRegister; const ref: TReference); virtual;
           procedure a_op_ref_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; const ref: TReference; reg: TRegister); virtual;
           procedure a_op_ref_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; const ref: TReference; reg: TRegister); virtual;
@@ -260,20 +256,19 @@ unit cgobj;
           { trinary operations for processors that support them, 'emulated' }
           { trinary operations for processors that support them, 'emulated' }
           { on others. None with "ref" arguments since I don't think there  }
           { on others. None with "ref" arguments since I don't think there  }
           { are any processors that support it (JM)                         }
           { are any processors that support it (JM)                         }
-          procedure a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
-            size: tcgsize; a: aword; src, dst: tregister); virtual;
-          procedure a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
-            size: tcgsize; src1, src2, dst: tregister); virtual;
+          procedure a_op_const_reg_reg(list: taasmoutput; op: TOpCg; size: tcgsize; a: aint; src, dst: tregister); virtual;
+          procedure a_op_reg_reg_reg(list: taasmoutput; op: TOpCg; size: tcgsize; src1, src2, dst: tregister); virtual;
 
 
           {  comparison operations }
           {  comparison operations }
-          procedure a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
+          procedure a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aint;reg : tregister;
             l : tasmlabel);virtual; abstract;
             l : tasmlabel);virtual; abstract;
-          procedure a_cmp_const_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;const ref : treference;
+          procedure a_cmp_const_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aint;const ref : treference;
             l : tasmlabel); virtual;
             l : tasmlabel); virtual;
-          procedure a_cmp_const_loc_label(list: taasmoutput; size: tcgsize;cmp_op: topcmp; a: aword; const loc: tlocation;
+          procedure a_cmp_const_loc_label(list: taasmoutput; size: tcgsize;cmp_op: topcmp; a: aint; const loc: tlocation;
             l : tasmlabel);
             l : tasmlabel);
           procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); virtual; abstract;
           procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); virtual; abstract;
           procedure a_cmp_ref_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const ref: treference; reg : tregister; l : tasmlabel); virtual;
           procedure a_cmp_ref_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const ref: treference; reg : tregister; l : tasmlabel); virtual;
+          procedure a_cmp_reg_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg : tregister; const ref: treference; l : tasmlabel); virtual;
           procedure a_cmp_loc_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const loc: tlocation; reg : tregister; l : tasmlabel);
           procedure a_cmp_loc_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const loc: tlocation; reg : tregister; l : tasmlabel);
           procedure a_cmp_ref_loc_label(list: taasmoutput; size: tcgsize;cmp_op: topcmp; const ref: treference; const loc: tlocation;
           procedure a_cmp_ref_loc_label(list: taasmoutput; size: tcgsize;cmp_op: topcmp; const ref: treference; const loc: tlocation;
             l : tasmlabel);
             l : tasmlabel);
@@ -300,7 +295,7 @@ unit cgobj;
              @param(reg The register to emit the opcode with, returns the register with
              @param(reg The register to emit the opcode with, returns the register with
                    which the opcode will be emitted)
                    which the opcode will be emitted)
           }
           }
-          function optimize_op_const_reg(list: taasmoutput; var op: topcg; var a : aword; var reg: tregister): boolean;virtual;
+          function optimize_op_const_reg(list: taasmoutput; var op: topcg; var a : aint; var reg: tregister): boolean;virtual;
 
 
          {#
          {#
              This routine is used in exception management nodes. It should
              This routine is used in exception management nodes. It should
@@ -321,7 +316,7 @@ unit cgobj;
              The size of the value to save is OS_S32. The default version
              The size of the value to save is OS_S32. The default version
              saves the exception reason to a temp. memory area.
              saves the exception reason to a temp. memory area.
           }
           }
-         procedure g_exception_reason_save_const(list : taasmoutput; const href : treference; a: aword);virtual;
+         procedure g_exception_reason_save_const(list : taasmoutput; const href : treference; a: aint);virtual;
          {#
          {#
              This routine is used in exception management nodes. It should
              This routine is used in exception management nodes. It should
              load the exception reason to the FUNCTION_RETURN_REG. The saved value
              load the exception reason to the FUNCTION_RETURN_REG. The saved value
@@ -348,7 +343,7 @@ unit cgobj;
              @param(loadref Is the source reference a pointer to the actual source (TRUE), is it the actual source address (FALSE))
              @param(loadref Is the source reference a pointer to the actual source (TRUE), is it the actual source address (FALSE))
 
 
           }
           }
-          procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword;delsource,loadref : boolean);virtual; abstract;
+          procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aint;delsource,loadref : boolean);virtual; abstract;
           {# This should emit the opcode to a shortrstring from the source
           {# This should emit the opcode to a shortrstring from the source
              to destination, if loadref is true, it assumes that it first must load
              to destination, if loadref is true, it assumes that it first must load
              the source address from the memory location where
              the source address from the memory location where
@@ -379,19 +374,8 @@ unit cgobj;
           {# Generates overflow checking code for a node }
           {# Generates overflow checking code for a node }
           procedure g_overflowcheck(list: taasmoutput; const l:tlocation; def:tdef); virtual; abstract;
           procedure g_overflowcheck(list: taasmoutput; const l:tlocation; def:tdef); virtual; abstract;
 
 
-          procedure g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);virtual;
+          procedure g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aint);virtual;
           procedure g_releasevaluepara_openarray(list : taasmoutput;const ref:treference);virtual;
           procedure g_releasevaluepara_openarray(list : taasmoutput;const ref:treference);virtual;
-          {# Emits instructions which should be emitted when entering
-             a routine declared as @var(interrupt). The default
-             behavior does nothing, should be overriden as required.
-          }
-          procedure g_interrupt_stackframe_entry(list : taasmoutput);virtual;
-
-          {# Emits instructions which should be emitted when exiting
-             a routine declared as @var(interrupt). The default
-             behavior does nothing, should be overriden as required.
-          }
-          procedure g_interrupt_stackframe_exit(list : taasmoutput;accused,acchiused:boolean);virtual;
 
 
           {# Emits instructions when compilation is done in profile
           {# Emits instructions when compilation is done in profile
              mode (this is set as a command line option). The default
              mode (this is set as a command line option). The default
@@ -409,18 +393,13 @@ unit cgobj;
 
 
              @param(localsize Number of bytes to allocate as locals)
              @param(localsize Number of bytes to allocate as locals)
           }
           }
-          procedure g_stackframe_entry(list : taasmoutput;localsize : longint);virtual; abstract;
-          {# Emits instructiona for restoring the frame pointer
-             at routine exit. For some processors, this routine
-             may do nothing at all.
-          }
-          procedure g_restore_frame_pointer(list : taasmoutput);virtual; abstract;
+          procedure g_proc_entry(list : taasmoutput;localsize : longint;nostackframe:boolean);virtual; abstract;
           {# Emits instructions for returning from a subroutine.
           {# Emits instructions for returning from a subroutine.
-             Should also restore the stack.
+             Should also restore the framepointer and stack.
 
 
              @param(parasize  Number of bytes of parameters to deallocate from stack)
              @param(parasize  Number of bytes of parameters to deallocate from stack)
           }
           }
-          procedure g_return_from_proc(list : taasmoutput;parasize : aword);virtual; abstract;
+          procedure g_proc_exit(list : taasmoutput;parasize:longint;nostackframe:boolean);virtual;abstract;
           {# This routine is called when generating the code for the entry point
           {# This routine is called when generating the code for the entry point
              of a routine. It should save all registers which are not used in this
              of a routine. It should save all registers which are not used in this
              routine, and which should be declared as saved in the std_saved_registers
              routine, and which should be declared as saved in the std_saved_registers
@@ -444,6 +423,7 @@ unit cgobj;
           procedure g_restore_all_registers(list : taasmoutput;const funcretparaloc:tparalocation);virtual;abstract;
           procedure g_restore_all_registers(list : taasmoutput;const funcretparaloc:tparalocation);virtual;abstract;
        end;
        end;
 
 
+{$ifndef cpu64bit}
     {# @abstract(Abstract code generator for 64 Bit operations)
     {# @abstract(Abstract code generator for 64 Bit operations)
        This class implements an abstract code generator class
        This class implements an abstract code generator class
        for 64 Bit operations.
        for 64 Bit operations.
@@ -453,14 +433,14 @@ unit cgobj;
         procedure a_reg_alloc(list : taasmoutput;r : tregister64);virtual;abstract;
         procedure a_reg_alloc(list : taasmoutput;r : tregister64);virtual;abstract;
         { Deallocates 64 Bit register r by inserting a pa_regdealloc record}
         { Deallocates 64 Bit register r by inserting a pa_regdealloc record}
         procedure a_reg_dealloc(list : taasmoutput;r : tregister64);virtual;abstract;
         procedure a_reg_dealloc(list : taasmoutput;r : tregister64);virtual;abstract;
-        procedure a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);virtual;abstract;
+        procedure a_load64_const_ref(list : taasmoutput;value : int64;const ref : treference);virtual;abstract;
         procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);virtual;abstract;
         procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);virtual;abstract;
         procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);virtual;abstract;
         procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);virtual;abstract;
         procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);virtual;abstract;
         procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);virtual;abstract;
-        procedure a_load64_const_reg(list : taasmoutput;value : qword;reg : tregister64);virtual;abstract;
+        procedure a_load64_const_reg(list : taasmoutput;value : int64;reg : tregister64);virtual;abstract;
         procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);virtual;abstract;
         procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);virtual;abstract;
         procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);virtual;abstract;
         procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);virtual;abstract;
-        procedure a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);virtual;abstract;
+        procedure a_load64_const_loc(list : taasmoutput;value : int64;const l : tlocation);virtual;abstract;
         procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);virtual;abstract;
         procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);virtual;abstract;
 
 
         procedure a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);virtual;abstract;
         procedure a_load64high_reg_ref(list : taasmoutput;reg : tregister;const ref : treference);virtual;abstract;
@@ -473,16 +453,16 @@ unit cgobj;
         procedure a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);virtual;abstract;
         procedure a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);virtual;abstract;
         procedure a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);virtual;abstract;
         procedure a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);virtual;abstract;
         procedure a_op64_reg_ref(list : taasmoutput;op:TOpCG;regsrc : tregister64;const ref : treference);virtual;abstract;
         procedure a_op64_reg_ref(list : taasmoutput;op:TOpCG;regsrc : tregister64;const ref : treference);virtual;abstract;
-        procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;regdst : tregister64);virtual;abstract;
-        procedure a_op64_const_ref(list : taasmoutput;op:TOpCG;value : qword;const ref : treference);virtual;abstract;
-        procedure a_op64_const_loc(list : taasmoutput;op:TOpCG;value : qword;const l: tlocation);virtual;abstract;
+        procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : int64;regdst : tregister64);virtual;abstract;
+        procedure a_op64_const_ref(list : taasmoutput;op:TOpCG;value : int64;const ref : treference);virtual;abstract;
+        procedure a_op64_const_loc(list : taasmoutput;op:TOpCG;value : int64;const l: tlocation);virtual;abstract;
         procedure a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);virtual;abstract;
         procedure a_op64_reg_loc(list : taasmoutput;op:TOpCG;reg : tregister64;const l : tlocation);virtual;abstract;
         procedure a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg64 : tregister64);virtual;abstract;
         procedure a_op64_loc_reg(list : taasmoutput;op:TOpCG;const l : tlocation;reg64 : tregister64);virtual;abstract;
-        procedure a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword;regsrc,regdst : tregister64);virtual;
+        procedure a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : int64;regsrc,regdst : tregister64);virtual;
         procedure a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);virtual;
         procedure a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);virtual;
 
 
         procedure a_param64_reg(list : taasmoutput;reg64 : tregister64;const loc : tparalocation);virtual;abstract;
         procedure a_param64_reg(list : taasmoutput;reg64 : tregister64;const loc : tparalocation);virtual;abstract;
-        procedure a_param64_const(list : taasmoutput;value : qword;const loc : tparalocation);virtual;abstract;
+        procedure a_param64_const(list : taasmoutput;value : int64;const loc : tparalocation);virtual;abstract;
         procedure a_param64_ref(list : taasmoutput;const r : treference;const loc : tparalocation);virtual;abstract;
         procedure a_param64_ref(list : taasmoutput;const r : treference;const loc : tparalocation);virtual;abstract;
         procedure a_param64_loc(list : taasmoutput;const l : tlocation;const loc : tparalocation);virtual;abstract;
         procedure a_param64_loc(list : taasmoutput;const l : tlocation;const loc : tparalocation);virtual;abstract;
 
 
@@ -498,12 +478,13 @@ unit cgobj;
              @param(reg The register to emit the opcode with, returns the register with
              @param(reg The register to emit the opcode with, returns the register with
                    which the opcode will be emitted)
                    which the opcode will be emitted)
         }
         }
-        function optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : qword; var reg: tregister64): boolean;virtual;abstract;
+        function optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : int64; var reg: tregister64): boolean;virtual;abstract;
 
 
 
 
         { override to catch 64bit rangechecks }
         { override to catch 64bit rangechecks }
         procedure g_rangecheck64(list: taasmoutput; const l:tlocation; fromdef,todef: tdef);virtual;abstract;
         procedure g_rangecheck64(list: taasmoutput; const l:tlocation; fromdef,todef: tdef);virtual;abstract;
     end;
     end;
+{$endif cpu64bit}
 
 
     procedure reference_release(list: taasmoutput; const ref : treference);
     procedure reference_release(list: taasmoutput; const ref : treference);
 
 
@@ -519,14 +500,16 @@ unit cgobj;
     var
     var
        {# Main code generator class }
        {# Main code generator class }
        cg : tcg;
        cg : tcg;
+{$ifndef cpu64bit}
        {# Code generator class for all operations working with 64-Bit operands }
        {# Code generator class for all operations working with 64-Bit operands }
        cg64 : tcg64;
        cg64 : tcg64;
+{$endif cpu64bit}
 
 
 
 
 implementation
 implementation
 
 
     uses
     uses
-       globals,globtype,options,systems,
+       globals,options,systems,
        verbose,defutil,paramgr,
        verbose,defutil,paramgr,
        tgobj,cutils,
        tgobj,cutils,
        cgutils;
        cgutils;
@@ -672,7 +655,7 @@ implementation
       end;
       end;
 
 
 
 
-    function  tcg.uses_registers(rt:Tregistertype):boolean;
+    function tcg.uses_registers(rt:Tregistertype):boolean;
       begin
       begin
         if assigned(rg[rt]) then
         if assigned(rg[rt]) then
           result:=rg[rt].uses_registers
           result:=rg[rt].uses_registers
@@ -710,11 +693,17 @@ implementation
       var
       var
         rt : tregistertype;
         rt : tregistertype;
       begin
       begin
-        for rt:=low(tregistertype) to high(tregistertype) do
+        for rt:=R_FPUREGISTER to R_SPECIALREGISTER do
           begin
           begin
             if assigned(rg[rt]) then
             if assigned(rg[rt]) then
               rg[rt].do_register_allocation(list,headertai);
               rg[rt].do_register_allocation(list,headertai);
           end;
           end;
+         { running the other register allocator passes could require addition int/addr. registers
+           when spilling so run int/addr register allocation at the end }
+         if assigned(rg[R_INTREGISTER]) then
+           rg[R_INTREGISTER].do_register_allocation(list,headertai);
+         if assigned(rg[R_ADDRESSREGISTER]) then
+           rg[R_ADDRESSREGISTER].do_register_allocation(list,headertai);
       end;
       end;
 
 
 
 
@@ -760,7 +749,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tcg.a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);
+    procedure tcg.a_param_const(list : taasmoutput;size : tcgsize;a : aint;const locpara : tparalocation);
       var
       var
          ref : treference;
          ref : treference;
       begin
       begin
@@ -792,7 +781,9 @@ implementation
                  reference_reset(ref);
                  reference_reset(ref);
                  ref.base:=locpara.reference.index;
                  ref.base:=locpara.reference.index;
                  ref.offset:=locpara.reference.offset;
                  ref.offset:=locpara.reference.offset;
-                 a_load_ref_ref(list,size,locpara.size,r,ref);
+                 { use concatcopy, because it can also be a float which fails when
+                   load_ref_ref is used }
+                 g_concatcopy(list,r,ref,tcgsize2size[size],false,false);
               end
               end
             else
             else
               internalerror(2002071004);
               internalerror(2002071004);
@@ -828,7 +819,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tcg.a_param_copy_ref(list : taasmoutput;size : qword;const r : treference;const locpara : tparalocation);
+    procedure tcg.a_param_copy_ref(list : taasmoutput;size : aint;const r : treference;const locpara : tparalocation);
       var
       var
         ref : treference;
         ref : treference;
       begin
       begin
@@ -960,7 +951,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tcg.a_load_const_ref(list : taasmoutput;size : tcgsize;a : aword;const ref : treference);
+    procedure tcg.a_load_const_ref(list : taasmoutput;size : tcgsize;a : aint;const ref : treference);
       var
       var
         tmpreg: tregister;
         tmpreg: tregister;
       begin
       begin
@@ -971,7 +962,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tcg.a_load_const_loc(list : taasmoutput;a : aword;const loc: tlocation);
+    procedure tcg.a_load_const_loc(list : taasmoutput;a : aint;const loc: tlocation);
       begin
       begin
         case loc.loc of
         case loc.loc of
           LOC_REFERENCE,LOC_CREFERENCE:
           LOC_REFERENCE,LOC_CREFERENCE:
@@ -1027,7 +1018,7 @@ implementation
       end;
       end;
 
 
 
 
-    function tcg.optimize_op_const_reg(list: taasmoutput; var op: topcg; var a : aword; var reg:tregister): boolean;
+    function tcg.optimize_op_const_reg(list: taasmoutput; var op: topcg; var a : aint; var reg:tregister): boolean;
       var
       var
         powerval : longint;
         powerval : longint;
       begin
       begin
@@ -1148,7 +1139,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tcg.a_op_const_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; const ref: TReference);
+    procedure tcg.a_op_const_ref(list : taasmoutput; Op: TOpCG; size: TCGSize; a: aint; const ref: TReference);
 
 
       var
       var
         tmpreg: tregister;
         tmpreg: tregister;
@@ -1162,7 +1153,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tcg.a_op_const_loc(list : taasmoutput; Op: TOpCG; a: AWord; const loc: tlocation);
+    procedure tcg.a_op_const_loc(list : taasmoutput; Op: TOpCG; a: aint; const loc: tlocation);
 
 
       begin
       begin
         case loc.loc of
         case loc.loc of
@@ -1250,7 +1241,7 @@ implementation
       end;
       end;
 
 
     procedure Tcg.a_op_const_reg_reg(list:Taasmoutput;op:Topcg;size:Tcgsize;
     procedure Tcg.a_op_const_reg_reg(list:Taasmoutput;op:Topcg;size:Tcgsize;
-                                     a:aword;src,dst:Tregister);
+                                     a:aint;src,dst:Tregister);
 
 
     begin
     begin
       a_load_reg_reg(list,size,size,src,dst);
       a_load_reg_reg(list,size,size,src,dst);
@@ -1279,7 +1270,7 @@ implementation
 
 
 
 
 
 
-    procedure tcg.a_cmp_const_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;const ref : treference;
+    procedure tcg.a_cmp_const_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aint;const ref : treference;
      l : tasmlabel);
      l : tasmlabel);
 
 
       var
       var
@@ -1292,7 +1283,7 @@ implementation
         ungetregister(list,tmpreg);
         ungetregister(list,tmpreg);
       end;
       end;
 
 
-    procedure tcg.a_cmp_const_loc_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;const loc : tlocation;
+    procedure tcg.a_cmp_const_loc_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aint;const loc : tlocation;
       l : tasmlabel);
       l : tasmlabel);
 
 
       begin
       begin
@@ -1306,11 +1297,10 @@ implementation
         end;
         end;
       end;
       end;
 
 
-    procedure tcg.a_cmp_ref_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const ref: treference; reg : tregister; l : tasmlabel);
 
 
+    procedure tcg.a_cmp_ref_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const ref: treference; reg : tregister; l : tasmlabel);
       var
       var
         tmpreg: tregister;
         tmpreg: tregister;
-
       begin
       begin
         tmpreg:=getintregister(list,size);
         tmpreg:=getintregister(list,size);
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_load_ref_reg(list,size,size,ref,tmpreg);
@@ -1318,6 +1308,18 @@ implementation
         ungetregister(list,tmpreg);
         ungetregister(list,tmpreg);
       end;
       end;
 
 
+
+    procedure tcg.a_cmp_reg_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; reg : tregister; const ref: treference; l : tasmlabel);
+      var
+        tmpreg: tregister;
+      begin
+        tmpreg:=getintregister(list,size);
+        a_load_ref_reg(list,size,size,ref,tmpreg);
+        a_cmp_reg_reg_label(list,size,cmp_op,reg,tmpreg,l);
+        ungetregister(list,tmpreg);
+      end;
+
+
     procedure tcg.a_cmp_loc_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const loc: tlocation; reg : tregister; l : tasmlabel);
     procedure tcg.a_cmp_loc_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const loc: tlocation; reg : tregister; l : tasmlabel);
       begin
       begin
         case loc.loc of
         case loc.loc of
@@ -1489,12 +1491,6 @@ implementation
       end;
       end;
 
 
 
 
-    class function tcg.reg_cgsize(const reg: tregister) : tcgsize;
-      begin
-        reg_cgsize := OS_INT;
-      end;
-
-
     procedure tcg.g_copyshortstring(list : taasmoutput;const source,dest : treference;len:byte;delsource,loadref : boolean);
     procedure tcg.g_copyshortstring(list : taasmoutput;const source,dest : treference;len:byte;delsource,loadref : boolean);
       var
       var
         paraloc1,paraloc2,paraloc3 : tparalocation;
         paraloc1,paraloc2,paraloc3 : tparalocation;
@@ -1762,11 +1758,9 @@ implementation
     { type used is checked against todefs ranges. fromdef (p.resulttype.def) }
     { type used is checked against todefs ranges. fromdef (p.resulttype.def) }
     { is the original type used at that location. When both defs are equal   }
     { is the original type used at that location. When both defs are equal   }
     { the check is also insert (needed for succ,pref,inc,dec)                }
     { the check is also insert (needed for succ,pref,inc,dec)                }
+{$ifndef ver1_0}
       const
       const
-{$ifdef ver1_0}
-        awordsignedmax=high(longint);
-{$else}
-        awordsignedmax=high(aword) div 2;
+        aintmax=high(aint);
 {$endif}
 {$endif}
       var
       var
         neglabel : tasmlabel;
         neglabel : tasmlabel;
@@ -1774,43 +1768,71 @@ implementation
         lto,hto,
         lto,hto,
         lfrom,hfrom : TConstExprInt;
         lfrom,hfrom : TConstExprInt;
         from_signed: boolean;
         from_signed: boolean;
+{$ifdef ver1_0}
+        aintmax : aint;
+{$endif ver1_0}
       begin
       begin
+{$ifdef ver1_0}
+  {$ifdef cpu64bit}
+        { this is required to prevent incorrect code }
+        aintmax:=$7fffffff;
+        aintmax:=int64(aintmax shl 16) or int64($ffff);
+        aintmax:=int64(aintmax shl 16) or int64($ffff);
+  {$else cpu64bit}
+        aintmax:=high(aint);
+  {$endif cpu64bit}
+{$endif}
         { range checking on and range checkable value? }
         { range checking on and range checkable value? }
         if not(cs_check_range in aktlocalswitches) or
         if not(cs_check_range in aktlocalswitches) or
            not(fromdef.deftype in [orddef,enumdef,arraydef]) then
            not(fromdef.deftype in [orddef,enumdef,arraydef]) then
           exit;
           exit;
+{$ifndef cpu64bit}
+        { handle 64bit rangechecks separate for 32bit processors }
         if is_64bit(fromdef) or is_64bit(todef) then
         if is_64bit(fromdef) or is_64bit(todef) then
           begin
           begin
              cg64.g_rangecheck64(list,l,fromdef,todef);
              cg64.g_rangecheck64(list,l,fromdef,todef);
              exit;
              exit;
           end;
           end;
+{$endif cpu64bit}
         { only check when assigning to scalar, subranges are different, }
         { only check when assigning to scalar, subranges are different, }
         { when todef=fromdef then the check is always generated         }
         { when todef=fromdef then the check is always generated         }
         getrange(fromdef,lfrom,hfrom);
         getrange(fromdef,lfrom,hfrom);
         getrange(todef,lto,hto);
         getrange(todef,lto,hto);
+        from_signed := is_signed(fromdef);
         { no range check if from and to are equal and are both longint/dword }
         { no range check if from and to are equal and are both longint/dword }
         { (if we have a 32bit processor) or int64/qword, since such          }
         { (if we have a 32bit processor) or int64/qword, since such          }
         { operations can at most cause overflows (JM)                        }
         { operations can at most cause overflows (JM)                        }
         { Note that these checks are mostly processor independent, they only }
         { Note that these checks are mostly processor independent, they only }
         { have to be changed once we introduce 64bit subrange types          }
         { have to be changed once we introduce 64bit subrange types          }
-{$warning range check still s32bit}
+{$ifdef cpu64bit}
+        if (fromdef = todef) and
+           (fromdef.deftype=orddef) and
+           (((((torddef(fromdef).typ = s64bit) and
+               (lfrom = low(int64)) and
+               (hfrom = high(int64))) or
+              ((torddef(fromdef).typ = u64bit) and
+               (lfrom = low(qword)) and
+               (hfrom = high(qword)))))) then
+          exit;
+{$else cpu64bit}
         if (fromdef = todef) and
         if (fromdef = todef) and
            (fromdef.deftype=orddef) and
            (fromdef.deftype=orddef) and
-           (((sizeof(aword) = 4) and
-             (((torddef(fromdef).typ = s32bit) and
+           (((((torddef(fromdef).typ = s32bit) and
                (lfrom = low(longint)) and
                (lfrom = low(longint)) and
                (hfrom = high(longint))) or
                (hfrom = high(longint))) or
               ((torddef(fromdef).typ = u32bit) and
               ((torddef(fromdef).typ = u32bit) and
                (lfrom = low(cardinal)) and
                (lfrom = low(cardinal)) and
                (hfrom = high(cardinal)))))) then
                (hfrom = high(cardinal)))))) then
           exit;
           exit;
-        if todef<>fromdef then
-         begin
-           { if the from-range falls completely in the to-range, no check }
-           { is necessary                                                 }
-           if (lto<=lfrom) and (hto>=hfrom) then
-            exit;
-         end;
+{$endif cpu64bit}
+
+        { if the from-range falls completely in the to-range, no check }
+        { is necessary. Don't do this conversion for the largest unsigned type }
+        if (todef<>fromdef) and
+           (from_signed or (hfrom>=0)) and
+           (lto<=lfrom) and (hto>=hfrom) then
+          exit;
+
         { generate the rangecheck code for the def where we are going to }
         { generate the rangecheck code for the def where we are going to }
         { store the result                                               }
         { store the result                                               }
 
 
@@ -1822,45 +1844,46 @@ implementation
         { the parts < 0 and > maxlongint out                                 }
         { the parts < 0 and > maxlongint out                                 }
 
 
         { is_signed now also works for arrays (it checks the rangetype) (JM) }
         { is_signed now also works for arrays (it checks the rangetype) (JM) }
-        from_signed := is_signed(fromdef);
         if from_signed xor is_signed(todef) then
         if from_signed xor is_signed(todef) then
-          if from_signed then
-            { from is signed, to is unsigned }
-            begin
-              { if high(from) < 0 -> always range error }
-              if (hfrom < 0) or
-                 { if low(to) > maxlongint also range error }
-                 (lto > awordsignedmax) then
-                begin
-                  a_call_name(list,'FPC_RANGEERROR');
-                  exit
-                end;
-              { from is signed and to is unsigned -> when looking at from }
-              { as an unsigned value, it must be < maxlongint (otherwise  }
-              { it's negative, which is invalid since "to" is unsigned)   }
-              if hto > awordsignedmax then
-                hto := awordsignedmax;
-            end
-          else
-            { from is unsigned, to is signed }
-            begin
-              if (lfrom > awordsignedmax) or
-                 (hto < 0) then
-                begin
-                  a_call_name(list,'FPC_RANGEERROR');
-                  exit
-                end;
-              { from is unsigned and to is signed -> when looking at to }
-              { as an unsigned value, it must be >= 0 (since negative   }
-              { values are the same as values > maxlongint)             }
-              if lto < 0 then
-                lto := 0;
-            end;
+          begin
+             if from_signed then
+               { from is signed, to is unsigned }
+               begin
+                 { if high(from) < 0 -> always range error }
+                 if (hfrom < 0) or
+                    { if low(to) > maxlongint also range error }
+                    (lto > aintmax) then
+                   begin
+                     a_call_name(list,'FPC_RANGEERROR');
+                     exit
+                   end;
+                 { from is signed and to is unsigned -> when looking at to }
+                 { as an signed value, it must be < maxaint (otherwise     }
+                 { it will become negative, which is invalid since "to" is unsigned) }
+                 if hto < 0 then
+                   hto := aintmax;
+               end
+             else
+               { from is unsigned, to is signed }
+               begin
+                 if (lfrom > aintmax) or
+                    (hto < 0) then
+                   begin
+                     a_call_name(list,'FPC_RANGEERROR');
+                     exit
+                   end;
+                 { from is unsigned and to is signed -> when looking at to }
+                 { as an unsigned value, it must be >= 0 (since negative   }
+                 { values are the same as values > maxlongint)             }
+                 if lto < 0 then
+                   lto := 0;
+               end;
+          end;
         hreg:=getintregister(list,OS_INT);
         hreg:=getintregister(list,OS_INT);
         a_load_loc_reg(list,OS_INT,l,hreg);
         a_load_loc_reg(list,OS_INT,l,hreg);
-        a_op_const_reg(list,OP_SUB,OS_INT,aword(lto),hreg);
+        a_op_const_reg(list,OP_SUB,OS_INT,aint(lto),hreg);
         objectlibrary.getlabel(neglabel);
         objectlibrary.getlabel(neglabel);
-        a_cmp_const_reg_label(list,OS_INT,OC_BE,aword(hto-lto),hreg,neglabel);
+        a_cmp_const_reg_label(list,OS_INT,OC_BE,aint(hto-lto),hreg,neglabel);
         { !!! should happen right after the compare (JM) }
         { !!! should happen right after the compare (JM) }
         ungetregister(list,hreg);
         ungetregister(list,hreg);
         a_call_name(list,'FPC_RANGEERROR');
         a_call_name(list,'FPC_RANGEERROR');
@@ -1916,7 +1939,6 @@ implementation
            a_param_reg(list,OS_ADDR,reg,paraloc1);
            a_param_reg(list,OS_ADDR,reg,paraloc1);
            paramanager.freeparaloc(list,paraloc1);
            paramanager.freeparaloc(list,paraloc1);
            paramanager.freeparaloc(list,paraloc2);
            paramanager.freeparaloc(list,paraloc2);
-           { No register saving needed, saveregisters is used }
            allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
            allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
            a_call_name(list,'FPC_CHECK_OBJECT_EXT');
            a_call_name(list,'FPC_CHECK_OBJECT_EXT');
            deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
            deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
@@ -1927,7 +1949,6 @@ implementation
             paramanager.allocparaloc(list,paraloc1);
             paramanager.allocparaloc(list,paraloc1);
             a_param_reg(list,OS_ADDR,reg,paraloc1);
             a_param_reg(list,OS_ADDR,reg,paraloc1);
             paramanager.freeparaloc(list,paraloc1);
             paramanager.freeparaloc(list,paraloc1);
-            { No register saving needed, saveregisters is used }
             allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
             allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
             a_call_name(list,'FPC_CHECK_OBJECT');
             a_call_name(list,'FPC_CHECK_OBJECT');
             deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
             deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
@@ -1939,7 +1960,7 @@ implementation
                             Entry/Exit Code Functions
                             Entry/Exit Code Functions
 *****************************************************************************}
 *****************************************************************************}
 
 
-    procedure tcg.g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);
+    procedure tcg.g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aint);
       var
       var
         sizereg,sourcereg,destreg : tregister;
         sizereg,sourcereg,destreg : tregister;
         paraloc1,paraloc2,paraloc3 : tparalocation;
         paraloc1,paraloc2,paraloc3 : tparalocation;
@@ -1955,7 +1976,7 @@ implementation
         { calculate necessary memory }
         { calculate necessary memory }
         a_load_ref_reg(list,OS_INT,OS_INT,lenref,sizereg);
         a_load_ref_reg(list,OS_INT,OS_INT,lenref,sizereg);
         a_op_const_reg(list,OP_ADD,OS_INT,1,sizereg);
         a_op_const_reg(list,OP_ADD,OS_INT,1,sizereg);
-        a_op_const_reg(list,OP_MUL,OS_INT,elesize,sizereg);
+        a_op_const_reg(list,OP_IMUL,OS_INT,elesize,sizereg);
         { load source }
         { load source }
         a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,sourcereg);
         a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,sourcereg);
 
 
@@ -2013,16 +2034,6 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tcg.g_interrupt_stackframe_entry(list : taasmoutput);
-      begin
-      end;
-
-
-    procedure tcg.g_interrupt_stackframe_exit(list : taasmoutput;accused,acchiused:boolean);
-      begin
-      end;
-
-
     procedure tcg.g_profilecode(list : taasmoutput);
     procedure tcg.g_profilecode(list : taasmoutput);
       begin
       begin
       end;
       end;
@@ -2030,19 +2041,19 @@ implementation
 
 
     procedure tcg.g_exception_reason_save(list : taasmoutput; const href : treference);
     procedure tcg.g_exception_reason_save(list : taasmoutput; const href : treference);
       begin
       begin
-        a_load_reg_ref(list, OS_S32, OS_32, NR_FUNCTION_RETURN_REG, href);
+        a_load_reg_ref(list, OS_INT, OS_INT, NR_FUNCTION_RESULT_REG, href);
       end;
       end;
 
 
 
 
-    procedure tcg.g_exception_reason_save_const(list : taasmoutput; const href : treference; a: aword);
+    procedure tcg.g_exception_reason_save_const(list : taasmoutput; const href : treference; a: aint);
       begin
       begin
-        a_load_const_ref(list, OS_S32, a, href);
+        a_load_const_ref(list, OS_INT, a, href);
       end;
       end;
 
 
 
 
     procedure tcg.g_exception_reason_load(list : taasmoutput; const href : treference);
     procedure tcg.g_exception_reason_load(list : taasmoutput; const href : treference);
       begin
       begin
-        a_load_ref_reg(list, OS_S32, OS_S32, href, NR_FUNCTION_RETURN_REG);
+        a_load_ref_reg(list, OS_INT, OS_INT, href, NR_FUNCTION_RESULT_REG);
       end;
       end;
 
 
 
 
@@ -2050,7 +2061,8 @@ implementation
                                     TCG64
                                     TCG64
 *****************************************************************************}
 *****************************************************************************}
 
 
-    procedure tcg64.a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword; regsrc,regdst : tregister64);
+{$ifndef cpu64bit}
+    procedure tcg64.a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : int64; regsrc,regdst : tregister64);
       begin
       begin
         a_load64_reg_reg(list,regsrc,regdst);
         a_load64_reg_reg(list,regsrc,regdst);
         a_op64_const_reg(list,op,value,regdst);
         a_op64_const_reg(list,op,value,regdst);
@@ -2058,10 +2070,30 @@ implementation
 
 
 
 
     procedure tcg64.a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);
     procedure tcg64.a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);
-      begin
-        a_load64_reg_reg(list,regsrc2,regdst);
-        a_op64_reg_reg(list,op,regsrc1,regdst);
+      var
+        tmpreg64 : tregister64;
+      begin
+        { when src1=dst then we need to first create a temp to prevent
+          overwriting src1 with src2 }
+        if (regsrc1.reghi=regdst.reghi) or
+           (regsrc1.reglo=regdst.reghi) or
+           (regsrc1.reghi=regdst.reglo) or
+           (regsrc1.reglo=regdst.reglo) then
+          begin
+            tmpreg64.reglo:=cg.getintregister(list,OS_32);
+            tmpreg64.reghi:=cg.getintregister(list,OS_32);
+            a_load64_reg_reg(list,regsrc2,tmpreg64);
+            a_op64_reg_reg(list,op,regsrc1,tmpreg64);
+            a_load64_reg_reg(list,tmpreg64,regdst);
+          end
+        else
+          begin
+            a_load64_reg_reg(list,regsrc2,regdst);
+            a_op64_reg_reg(list,op,regsrc1,regdst);
+          end;
       end;
       end;
+{$endif cpu64bit}
+
 
 
 {****************************************************************************
 {****************************************************************************
                                   TReference
                                   TReference
@@ -2136,11 +2168,16 @@ initialization
     ;
     ;
 finalization
 finalization
   cg.free;
   cg.free;
+{$ifndef cpu64bit}
   cg64.free;
   cg64.free;
+{$endif cpu64bit}
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.164  2004-05-22 23:34:27  peter
+  Revision 1.165  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.164  2004/05/22 23:34:27  peter
   tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
   tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
 
 
   Revision 1.163  2004/04/29 19:56:36  daniel
   Revision 1.163  2004/04/29 19:56:36  daniel
@@ -2149,6 +2186,65 @@ end.
   Revision 1.162  2004/04/18 07:52:43  florian
   Revision 1.162  2004/04/18 07:52:43  florian
     * fixed web bug 3048: comparision of dyn. arrays
     * fixed web bug 3048: comparision of dyn. arrays
 
 
+  Revision 1.161.2.17  2004/06/13 10:51:16  florian
+    * fixed several register allocator problems (sparc/arm)
+
+  Revision 1.161.2.16  2004/06/02 16:07:00  peter
+    * fixed op64_reg_reg_reg to not override src when src=dst
+
+  Revision 1.161.2.15  2004/05/30 17:54:13  florian
+    + implemented cmp64bit
+    * started to fix spilling
+    * fixed int64 sub partially
+
+  Revision 1.161.2.14  2004/05/30 12:07:54  florian
+    * fixed loading/saving of exception reason for CPUs where RETURN and RESULT registers of functions are differently named
+
+  Revision 1.161.2.13  2004/05/27 23:36:18  peter
+    * nostackframe procdirective added
+
+  Revision 1.161.2.12  2004/05/10 21:28:34  peter
+    * section_smartlink enabled for gas under linux
+
+  Revision 1.161.2.11  2004/05/03 19:06:34  peter
+    * fixed range checking
+
+  Revision 1.161.2.10  2004/05/02 20:20:59  florian
+    * started to fix callee side result value handling
+
+  Revision 1.161.2.9  2004/05/02 12:45:32  peter
+    * enabled cpuhasfixedstack for x86-64 again
+    * fixed size of temp allocation for parameters
+
+  Revision 1.161.2.8  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.161.2.7  2004/05/01 11:12:23  florian
+    * spilling of registers with size<>4 fixed
+
+  Revision 1.161.2.6  2004/04/28 21:46:22  peter
+    * fix 1.0.x bootstrap of maxaint
+
+  Revision 1.161.2.5  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.161.2.4  2004/04/26 16:09:16  peter
+    * fixed infinite loop with 64bit rangecheck
+
+  Revision 1.161.2.3  2004/04/26 15:54:33  peter
+    * small x86-64 fixes
+
+  Revision 1.161.2.2  2004/04/24 20:13:24  florian
+    * fixed x86-64 exception handling
+
+  Revision 1.161.2.1  2004/04/18 16:55:37  peter
+    * procedure entry and exit code restructured, some x86 specific
+      things are removed from the generic ncgutil code and moved to
+      the target depend cg.g_proc_entry and cg.g_proc_exit that now
+      contain all the code during startup including stackframe allocation
+      only the saving of registers is excluded from this code
+
   Revision 1.161  2004/03/06 20:35:19  florian
   Revision 1.161  2004/03/06 20:35:19  florian
     * fixed arm compilation
     * fixed arm compilation
     * cleaned up code generation for exported linux procedures
     * cleaned up code generation for exported linux procedures
@@ -2678,4 +2774,4 @@ end.
       unit so this would conflicts if D6 programms are compiled
       unit so this would conflicts if D6 programms are compiled
     + Willamette/SSE2 instructions to assembler added
     + Willamette/SSE2 instructions to assembler added
 
 
-}
+}

+ 11 - 5
compiler/cmsgs.pas

@@ -113,8 +113,8 @@ begin
   for i:=1 to n do
   for i:=1 to n do
    begin
    begin
      msgidxmax[i]:=idxmax[i-1];
      msgidxmax[i]:=idxmax[i-1];
-     getmem(msgidx[i],msgidxmax[i]*4);
-     fillchar(msgidx[i]^,msgidxmax[i]*4,0);
+     getmem(msgidx[i],msgidxmax[i]*sizeof(pointer));
+     fillchar(msgidx[i]^,msgidxmax[i]*sizeof(pointer),0);
    end;
    end;
 end;
 end;
 
 
@@ -124,7 +124,7 @@ var
   i : longint;
   i : longint;
 begin
 begin
   for i:=1 to msgparts do
   for i:=1 to msgparts do
-   freemem(msgidx[i],msgidxmax[i]*4);
+   freemem(msgidx[i],msgidxmax[i]*sizeof(pointer));
   if msgallocsize>0 then
   if msgallocsize>0 then
    begin
    begin
      freemem(msgtxt,msgsize);
      freemem(msgtxt,msgsize);
@@ -333,7 +333,7 @@ var
 begin
 begin
   { clear }
   { clear }
   for i:=1 to msgparts do
   for i:=1 to msgparts do
-   fillchar(msgidx[i]^,msgidxmax[i]*4,0);
+   fillchar(msgidx[i]^,msgidxmax[i]*sizeof(pointer),0);
 end;
 end;
 
 
 
 
@@ -418,7 +418,13 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2004-02-20 19:49:21  daniel
+  Revision 1.11  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.10.2.1  2004/05/02 14:09:54  peter
+    * fix case 64bit issues
+
+  Revision 1.10  2004/02/20 19:49:21  daniel
     * Message system uses open arrays internally
     * Message system uses open arrays internally
     * Bugfix for string handling in array constructor node
     * Bugfix for string handling in array constructor node
     * Micro code reductions in pdecl.pas
     * Micro code reductions in pdecl.pas

+ 27 - 14
compiler/cresstr.pas

@@ -60,11 +60,11 @@ var
 implementation
 implementation
 
 
 uses
 uses
-   cutils,globals,
+   cutils,globtype,globals,
    symdef,
    symdef,
    verbose,fmodule,
    verbose,fmodule,
    aasmbase,aasmtai,
    aasmbase,aasmtai,
-   aasmcpu,cpuinfo;
+   aasmcpu;
 
 
 
 
 { ---------------------------------------------------------------------
 { ---------------------------------------------------------------------
@@ -149,15 +149,15 @@ procedure TResourceStrings.CreateResourceStringList;
     With P Do
     With P Do
      begin
      begin
        if (Value=nil) or (len=0) then
        if (Value=nil) or (len=0) then
-         resourcestringlist.concat(tai_const.create_ptr(0))
+         resourcestringlist.concat(tai_const.create_sym(nil))
        else
        else
          begin
          begin
             objectlibrary.getdatalabel(l1);
             objectlibrary.getdatalabel(l1);
-            resourcestringlist.concat(tai_const_symbol.create(l1));
-            consts.concat(tai_align.Create(const_align(pointer_size)));
+            resourcestringlist.concat(tai_const.create_sym(l1));
+            consts.concat(tai_align.Create(const_align(sizeof(aint))));
             consts.concat(tai_const.create_32bit(len));
             consts.concat(tai_const.create_32bit(len));
             consts.concat(tai_const.create_32bit(len));
             consts.concat(tai_const.create_32bit(len));
-            consts.concat(tai_const.create_32bit(cardinal(-1)));
+            consts.concat(tai_const.create_32bit(-1));
             consts.concat(tai_label.create(l1));
             consts.concat(tai_label.create(l1));
             getmem(s,len+1);
             getmem(s,len+1);
             move(Value^,s^,len);
             move(Value^,s^,len);
@@ -166,16 +166,16 @@ procedure TResourceStrings.CreateResourceStringList;
             consts.concat(tai_const.create_8bit(0));
             consts.concat(tai_const.create_8bit(0));
          end;
          end;
        { append Current value (nil) and hash...}
        { append Current value (nil) and hash...}
-       resourcestringlist.concat(tai_const.create_ptr(0));
-       resourcestringlist.concat(tai_const.create_32bit(hash));
+       resourcestringlist.concat(tai_const.create_sym(nil));
+       resourcestringlist.concat(tai_const.create_32bit(longint(hash)));
        { Append the name as a ansistring. }
        { Append the name as a ansistring. }
        objectlibrary.getdatalabel(l1);
        objectlibrary.getdatalabel(l1);
        L:=Length(Name);
        L:=Length(Name);
-       resourcestringlist.concat(tai_const_symbol.create(l1));
-       consts.concat(tai_align.Create(const_align(pointer_size)));
+       resourcestringlist.concat(tai_const.create_sym(l1));
+       consts.concat(tai_align.Create(const_align(sizeof(aint))));
        consts.concat(tai_const.create_32bit(l));
        consts.concat(tai_const.create_32bit(l));
        consts.concat(tai_const.create_32bit(l));
        consts.concat(tai_const.create_32bit(l));
-       consts.concat(tai_const.create_32bit(cardinal(-1)));
+       consts.concat(tai_const.create_32bit(-1));
        consts.concat(tai_label.create(l1));
        consts.concat(tai_label.create(l1));
        getmem(s,l+1);
        getmem(s,l+1);
        move(Name[1],s^,l);
        move(Name[1],s^,l);
@@ -192,7 +192,7 @@ begin
     resourcestringlist:=taasmoutput.create;
     resourcestringlist:=taasmoutput.create;
   resourcestringlist.insert(tai_const.create_32bit(resstrcount));
   resourcestringlist.insert(tai_const.create_32bit(resstrcount));
   resourcestringlist.insert(tai_symbol.createname_global(make_mangledname('RESOURCESTRINGLIST',current_module.localsymtable,''),AT_DATA,0));
   resourcestringlist.insert(tai_symbol.createname_global(make_mangledname('RESOURCESTRINGLIST',current_module.localsymtable,''),AT_DATA,0));
-  resourcestringlist.insert(tai_align.Create(const_align(pointer_size)));
+  resourcestringlist.insert(tai_align.Create(const_align(sizeof(aint))));
   R:=TResourceStringItem(List.First);
   R:=TResourceStringItem(List.First);
   While assigned(R) do
   While assigned(R) do
    begin
    begin
@@ -295,11 +295,24 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.23  2004-05-23 15:23:30  peter
+  Revision 1.24  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.23  2004/05/23 15:23:30  peter
     * fixed qword(longint) that removed sign from the number
     * fixed qword(longint) that removed sign from the number
     * removed code in the compiler that relied on wrong qword(longint)
     * removed code in the compiler that relied on wrong qword(longint)
       code generation
       code generation
 
 
+  Revision 1.22.2.3  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.22.2.2  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.22.2.1  2004/04/12 14:45:11  peter
+    * tai_const_symbol and tai_const merged
+
   Revision 1.22  2004/03/02 00:36:33  olle
   Revision 1.22  2004/03/02 00:36:33  olle
     * big transformation of Tai_[const_]Symbol.Create[data]name*
     * big transformation of Tai_[const_]Symbol.Create[data]name*
 
 
@@ -349,4 +362,4 @@ end.
   + generic constructor calls
   + generic constructor calls
   + start of tassembler / tmodulebase class cleanup
   + start of tassembler / tmodulebase class cleanup
 
 
-}
+}

+ 17 - 4
compiler/cstreams.pas

@@ -26,6 +26,10 @@ unit cstreams;
 
 
 interface
 interface
 
 
+   uses
+     cutils;
+
+
 {****************************************************************************
 {****************************************************************************
                                   TCStream
                                   TCStream
 ****************************************************************************}
 ****************************************************************************}
@@ -307,7 +311,7 @@ implementation
     if TheSize>0 then
     if TheSize>0 then
      begin
      begin
        ReadBuffer (Pointer(Result)^,TheSize);
        ReadBuffer (Pointer(Result)^,TheSize);
-       P:=PByte(Longint(Result)+TheSize);
+       P:=PByte(PtrInt(Result)+TheSize);
        p^:=0;
        p^:=0;
      end;
      end;
    end;
    end;
@@ -451,7 +455,7 @@ begin
     begin
     begin
     Result:=FSize-FPosition;
     Result:=FSize-FPosition;
     If Result>Count then Result:=Count;
     If Result>Count then Result:=Count;
-    Move (Pointer(Longint(FMemory)+FPosition)^,Buffer,Result);
+    Move (Pointer(PtrInt(FMemory)+FPosition)^,Buffer,Result);
     FPosition:=Fposition+Result;
     FPosition:=Fposition+Result;
     end;
     end;
 end;
 end;
@@ -602,7 +606,7 @@ begin
       SetCapacity (NewPos);
       SetCapacity (NewPos);
     FSize:=Newpos;
     FSize:=Newpos;
     end;
     end;
-  System.Move (Buffer,Pointer(Longint(FMemory)+FPosition)^,Count);
+  System.Move (Buffer,Pointer(Ptrint(FMemory)+FPosition)^,Count);
   FPosition:=NewPos;
   FPosition:=NewPos;
   Result:=Count;
   Result:=Count;
 end;
 end;
@@ -610,7 +614,16 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2002-07-01 16:23:52  peter
+  Revision 1.7  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.6.2.2  2004/04/29 19:07:22  peter
+    * compile fixes
+
+  Revision 1.6.2.1  2004/04/28 21:46:56  peter
+    * compile fixes for x86-64
+
+  Revision 1.6  2002/07/01 16:23:52  peter
     * cg64 patch
     * cg64 patch
     * basics for currency
     * basics for currency
     * asnode updates for class and interface (not finished)
     * asnode updates for class and interface (not finished)

+ 41 - 26
compiler/cutils.pas

@@ -32,6 +32,9 @@ interface
 
 
 
 
     type
     type
+{$ifdef ver1_0}
+       ptrint = longint;
+{$endif ver1_0}
        pstring = ^string;
        pstring = ^string;
        get_var_value_proc=function(const s:string):string of object;
        get_var_value_proc=function(const s:string):string of object;
        Tcharset=set of char;
        Tcharset=set of char;
@@ -65,11 +68,11 @@ interface
     function GetToken(var s:string;endchar:char):string;
     function GetToken(var s:string;endchar:char):string;
     procedure uppervar(var s : string);
     procedure uppervar(var s : string);
     function hexstr(val : cardinal;cnt : cardinal) : string;
     function hexstr(val : cardinal;cnt : cardinal) : string;
-    function tostru(i:cardinal) : string;{$ifdef USEINLINE}inline;{$endif}
-    function tostr(i : longint) : string;{$ifdef USEINLINE}inline;{$endif}
     function realtostr(e:extended):string;{$ifdef USEINLINE}inline;{$endif}
     function realtostr(e:extended):string;{$ifdef USEINLINE}inline;{$endif}
-    function int64tostr(i : int64) : string;{$ifdef USEINLINE}inline;{$endif}
-    function tostr_with_plus(i : longint) : string;{$ifdef USEINLINE}inline;{$endif}
+    function tostr(i : qword) : string;{$ifdef USEINLINE}inline;{$endif}overload;
+    function tostr(i : int64) : string;{$ifdef USEINLINE}inline;{$endif}overload;
+    function tostr(i : longint) : string;{$ifdef USEINLINE}inline;{$endif}overload;
+    function tostr_with_plus(i : int64) : string;{$ifdef USEINLINE}inline;{$endif}
     function DStr(l:longint):string;
     function DStr(l:longint):string;
     procedure valint(S : string;var V : longint;var code : integer);
     procedure valint(S : string;var V : longint;var code : integer);
     {# Returns true if the string s is a number }
     {# Returns true if the string s is a number }
@@ -405,24 +408,6 @@ uses
       end;
       end;
 
 
 
 
-    function tostru(i:cardinal):string;{$ifdef USEINLINE}inline;{$endif}
-    {
-      return string of value i, but for cardinals
-    }
-      begin
-        str(i,result);
-      end;
-
-
-   function tostr(i : longint) : string;{$ifdef USEINLINE}inline;{$endif}
-   {
-     return string of value i
-   }
-     begin
-       str(i,result);
-     end;
-
-
     function DStr(l:longint):string;
     function DStr(l:longint):string;
       var
       var
         TmpStr : string[32];
         TmpStr : string[32];
@@ -553,7 +538,25 @@ uses
      end;
      end;
 
 
 
 
-   function int64tostr(i : int64) : string;{$ifdef USEINLINE}inline;{$endif}
+   function tostr(i : qword) : string;{$ifdef USEINLINE}inline;{$endif}overload;
+   {
+     return string of value i
+   }
+     begin
+        str(i,result);
+     end;
+
+
+   function tostr(i : int64) : string;{$ifdef USEINLINE}inline;{$endif}overload;
+   {
+     return string of value i
+   }
+     begin
+        str(i,result);
+     end;
+
+
+   function tostr(i : longint) : string;{$ifdef USEINLINE}inline;{$endif}overload;
    {
    {
      return string of value i
      return string of value i
    }
    }
@@ -562,7 +565,7 @@ uses
      end;
      end;
 
 
 
 
-   function tostr_with_plus(i : longint) : string;{$ifdef USEINLINE}inline;{$endif}
+   function tostr_with_plus(i : int64) : string;{$ifdef USEINLINE}inline;{$endif}
    {
    {
      return string of value i, but always include a + when i>=0
      return string of value i, but always include a + when i>=0
    }
    }
@@ -1188,9 +1191,21 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.39  2004-05-22 23:33:18  peter
+  Revision 1.40  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.39  2004/05/22 23:33:18  peter
   fix range check error when array size > maxlongint
   fix range check error when array size > maxlongint
 
 
+  Revision 1.38.2.3  2004/04/29 19:07:22  peter
+    * compile fixes
+
+  Revision 1.38.2.2  2004/04/26 21:01:36  peter
+    * aint fixes
+
+  Revision 1.38.2.1  2004/04/20 16:35:58  peter
+    * generate dwarf for stackframe entry
+
   Revision 1.38  2004/03/29 19:19:35  florian
   Revision 1.38  2004/03/29 19:19:35  florian
     + arm floating point register saving implemented
     + arm floating point register saving implemented
     * hopefully stabs generation for MacOSX fixed
     * hopefully stabs generation for MacOSX fixed
@@ -1287,4 +1302,4 @@ end.
   Revision 1.14  2002/04/12 17:16:35  carl
   Revision 1.14  2002/04/12 17:16:35  carl
   + more documentation of basic unit
   + more documentation of basic unit
 
 
-}
+}

+ 25 - 16
compiler/defutil.pas

@@ -28,9 +28,9 @@ interface
 
 
     uses
     uses
        cclasses,
        cclasses,
-       globals,
+       globtype,globals,
        symconst,symbase,symtype,symdef,
        symconst,symbase,symtype,symdef,
-       cgbase,cpuinfo,cpubase;
+       cgbase,cpubase;
 
 
     type
     type
        tmmxtype = (mmxno,mmxu8bit,mmxs8bit,mmxu16bit,mmxs16bit,
        tmmxtype = (mmxno,mmxu8bit,mmxs8bit,mmxu16bit,mmxs16bit,
@@ -57,9 +57,6 @@ interface
     {# Returns true, if definition defines an integer type }
     {# Returns true, if definition defines an integer type }
     function is_integer(def : tdef) : boolean;
     function is_integer(def : tdef) : boolean;
 
 
-    { true if p is a 32bit int i.e. dword or longint }
-    function is_32bitint(def : tdef) : boolean;
-
     {# Returns true if definition is a boolean }
     {# Returns true if definition is a boolean }
     function is_boolean(def : tdef) : boolean;
     function is_boolean(def : tdef) : boolean;
 
 
@@ -173,6 +170,9 @@ interface
     {# Returns true, if def is an extended type }
     {# Returns true, if def is an extended type }
     function is_extended(def : tdef) : boolean;
     function is_extended(def : tdef) : boolean;
 
 
+    {# Returns true, if def is a 32 bit integer type }
+    function is_32bitint(def : tdef) : boolean;
+
     {# Returns true, if def is a 64 bit integer type }
     {# Returns true, if def is a 64 bit integer type }
     function is_64bitint(def : tdef) : boolean;
     function is_64bitint(def : tdef) : boolean;
 
 
@@ -203,7 +203,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-       globtype,tokens,systems,verbose;
+       tokens,systems,verbose;
 
 
     { returns true, if def uses FPU }
     { returns true, if def uses FPU }
     function is_fpu(def : tdef) : boolean;
     function is_fpu(def : tdef) : boolean;
@@ -342,14 +342,6 @@ implementation
       end;
       end;
 
 
 
 
-    { true if p is a 32bit int i.e. dword or longint }
-    function is_32bitint(def : tdef) : boolean;
-      begin
-        is_32bitint:=(def.deftype=orddef) and
-                    (torddef(def).typ in [u32bit,s32bit]);
-      end;
-
-
     { true if p is a boolean }
     { true if p is a boolean }
     function is_boolean(def : tdef) : boolean;
     function is_boolean(def : tdef) : boolean;
       begin
       begin
@@ -609,6 +601,13 @@ implementation
       end;
       end;
 
 
 
 
+    { true, if def is a 32 bit int type }
+    function is_32bitint(def : tdef) : boolean;
+      begin
+         result:=(def.deftype=orddef) and (torddef(def).typ in [u32bit,s32bit])
+      end;
+
+
     { true, if def is a 64 bit int type }
     { true, if def is a 64 bit int type }
     function is_64bitint(def : tdef) : boolean;
     function is_64bitint(def : tdef) : boolean;
       begin
       begin
@@ -905,7 +904,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.15  2004-05-28 21:13:23  peter
+  Revision 1.16  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.15  2004/05/28 21:13:23  peter
     * prefer signed constants over unsigned
     * prefer signed constants over unsigned
 
 
   Revision 1.14  2004/05/01 22:05:01  florian
   Revision 1.14  2004/05/01 22:05:01  florian
@@ -914,6 +916,13 @@ end.
   Revision 1.13  2004/04/29 19:56:36  daniel
   Revision 1.13  2004/04/29 19:56:36  daniel
     * Prepare compiler infrastructure for multiple ansistring types
     * Prepare compiler infrastructure for multiple ansistring types
 
 
+  Revision 1.12.2.2  2004/05/03 16:27:38  peter
+    * fixed shl for x86-64
+
+  Revision 1.12.2.1  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
   Revision 1.12  2004/03/29 14:44:10  peter
   Revision 1.12  2004/03/29 14:44:10  peter
     * fixes to previous constant integer commit
     * fixes to previous constant integer commit
 
 
@@ -1106,7 +1115,7 @@ end.
     * moved more routines from cga/n386util
     * moved more routines from cga/n386util
 
 
   Revision 1.68  2002/04/15 19:08:22  carl
   Revision 1.68  2002/04/15 19:08:22  carl
-  + target_info.size_of_pointer -> pointer_size
+  + target_info.size_of_pointer -> sizeof(aint)
   + some cleanup of unused types/variables
   + some cleanup of unused types/variables
 
 
   Revision 1.67  2002/04/07 13:40:29  carl
   Revision 1.67  2002/04/07 13:40:29  carl

+ 447 - 0
compiler/dwarf.pas

@@ -0,0 +1,447 @@
+{
+    $Id$
+    Copyright (c) 2003-2004 by Peter Vreman and Florian Klaempfl
+
+    This units contains special support for DWARF debug info
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit dwarf;
+
+{$i fpcdefs.inc}
+
+interface
+
+    uses
+      cclasses,
+      globtype,
+      cgbase,cpubase,
+      aasmbase,aasmtai;
+
+    const
+      maxdwarfops = 2;
+
+    type
+      tdwarfoperenc=(doe_uleb,doe_sleb,doe_ptr,doe_32bit,doe_16bit,doe_8bit);
+      tdwarfopertype=(dop_reg,dop_const,dop_sym,dop_reloffset);
+
+      tdwarfoper=record
+        enc : tdwarfoperenc;
+        case typ:tdwarfopertype of
+          dop_reg : (register:tregister);
+          dop_const : (value:int64);
+          dop_sym : (sym:tasmsymbol);
+          dop_reloffset : (beginsym,endsym:tasmsymbol);
+      end;
+
+      tdwarfitem=class(TLinkedListItem)
+        op   : byte;
+        ops  : byte;
+        oper : array[0..maxdwarfops-1] of tdwarfoper;
+        constructor create(aop:longint);
+        constructor create_reg(aop:longint;enc1:tdwarfoperenc;reg:tregister);
+        constructor create_const(aop:longint;enc1:tdwarfoperenc;val:int64);
+        constructor create_reloffset(aop:longint;enc1:tdwarfoperenc;beginlab,endlab:tasmsymbol);
+        constructor create_reg_const(aop:longint;enc1:tdwarfoperenc;reg:tregister;enc2:tdwarfoperenc;val:longint);
+        procedure generate_code(list:taasmoutput);
+      end;
+
+      tdwarf=class
+      private
+        FDwarfList : TLinkedList;
+      public
+        constructor create;
+        destructor destroy;override;
+        property DwarfList:TlinkedList read FDwarfList;
+      end;
+
+      tdwarfcfi=class(tdwarf)
+      private
+        FFrameStartLabel,
+        FFrameEndLabel,
+        FLastloclabel : tasmlabel;
+        procedure cfa_advance_loc(list:taasmoutput);
+      protected
+        code_alignment_factor,
+        data_alignment_factor : shortint;
+      public
+        constructor create;
+        procedure generate_code(list:taasmoutput);
+        { operations }
+        procedure start_frame(list:taasmoutput);
+        procedure end_frame(list:taasmoutput);
+        procedure cfa_offset(list:taasmoutput;reg:tregister;ofs:longint);
+        procedure cfa_restore(list:taasmoutput;reg:tregister);
+        procedure cfa_def_cfa_register(list:taasmoutput;reg:tregister);
+        procedure cfa_def_cfa_offset(list:taasmoutput;ofs:longint);
+      end;
+
+
+    var
+      dwarfcfi : tdwarfcfi;
+
+    function dwarf_reg(r:tregister):longint;
+
+
+implementation
+
+    uses
+      verbose,
+      cpuinfo;
+
+    const
+      { Call frame information }
+      DW_CFA_set_loc          = $01;
+      DW_CFA_advance_loc1     = $02;
+      DW_CFA_advance_loc2     = $03;
+      DW_CFA_advance_loc4     = $04;
+      DW_CFA_offset_extended  = $05;
+      DW_CFA_restore_extended = $06;
+      DW_CFA_def_cfa          = $0c;
+      DW_CFA_def_cfa_register = $0d;
+      DW_CFA_def_cfa_offset   = $0e;
+      { Own additions }
+      DW_CFA_start_frame = $f0;
+      DW_CFA_end_frame   = $f1;
+
+
+{****************************************************************************
+                                  Helpers
+****************************************************************************}
+
+    function dwarf_reg(r:tregister):longint;
+      begin
+        result:=regdwarf_table[findreg_by_number(r)];
+      end;
+
+
+{****************************************************************************
+                                  TDWARF
+****************************************************************************}
+
+    constructor tdwarf.create;
+      begin
+        FDwarfList:=TLinkedList.Create;
+      end;
+
+
+    destructor tdwarf.destroy;
+      begin
+        FDwarfList.Free;
+      end;
+
+
+{****************************************************************************
+                                TDWARFITEM
+****************************************************************************}
+
+    constructor tdwarfitem.create(aop:longint);
+      begin
+        inherited create;
+        op:=aop;
+        ops:=0;
+      end;
+
+
+    constructor tdwarfitem.create_reg(aop:longint;enc1:tdwarfoperenc;reg:tregister);
+      begin
+        inherited create;
+        op:=aop;
+        ops:=1;
+        oper[0].typ:=dop_reg;
+        oper[0].enc:=enc1;
+        oper[0].register:=reg;
+      end;
+
+
+    constructor tdwarfitem.create_const(aop:longint;enc1:tdwarfoperenc;val:int64);
+      begin
+        inherited create;
+        op:=aop;
+        ops:=1;
+        oper[0].typ:=dop_const;
+        oper[0].enc:=enc1;
+        oper[0].value:=val;
+      end;
+
+
+    constructor tdwarfitem.create_reloffset(aop:longint;enc1:tdwarfoperenc;beginlab,endlab:tasmsymbol);
+      begin
+        inherited create;
+        op:=aop;
+        ops:=1;
+        { relative offsets are passed }
+        oper[0].typ:=dop_reloffset;
+        oper[0].enc:=enc1;
+        oper[0].beginsym:=beginlab;
+        oper[0].endsym:=endlab;
+      end;
+
+
+    constructor tdwarfitem.create_reg_const(aop:longint;enc1:tdwarfoperenc;reg:tregister;enc2:tdwarfoperenc;val:longint);
+      begin
+        inherited create;
+        op:=aop;
+        ops:=2;
+        oper[0].typ:=dop_reg;
+        oper[0].enc:=enc1;
+        oper[0].register:=reg;
+        oper[1].typ:=dop_const;
+        oper[1].enc:=enc2;
+        oper[1].value:=val;
+      end;
+
+
+    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
+        );
+      var
+        i : integer;
+        v : int64;
+      begin
+        list.concat(tai_const.create_8bit(op));
+        for i:=0 to ops-1 do
+          begin
+            case oper[i].typ of
+              dop_const :
+                list.concat(tai_const.create(enc2ait_const[oper[i].enc],oper[i].value));
+              dop_sym :
+                begin
+                  if oper[i].enc<>doe_ptr then
+                    internalerror(200404127);
+                  list.concat(tai_const.create_sym(oper[i].sym));
+                end;
+              dop_reloffset :
+                list.concat(tai_const.create_rel_sym(enc2ait_const[oper[i].enc],oper[i].beginsym,oper[i].endsym));
+              dop_reg :
+                list.concat(tai_const.create(enc2ait_const[oper[i].enc],regdwarf_table[findreg_by_number(oper[i].register)]));
+              else
+                internalerror(200404128);
+            end;
+          end;
+      end;
+
+
+{****************************************************************************
+                                 TDWARFCFI
+****************************************************************************}
+
+    constructor tdwarfcfi.create;
+      begin
+        inherited create;
+        FFrameStartLabel:=nil;
+        FFrameEndLabel:=nil;
+        FLastLocLabel:=nil;
+        code_alignment_factor:=1;
+        data_alignment_factor:=-1;
+      end;
+
+
+    procedure tdwarfcfi.generate_code(list:taasmoutput);
+      var
+        hp : tdwarfitem;
+        cielabel,
+        lenstartlabel,
+        lenendlabel    : tasmlabel;
+        tc             : tai_const;
+      begin
+        new_section(list,sec_debug_frame,'',0);
+        { CIE
+           DWORD   length
+           DWORD   CIE_Id = 0xffffffff
+           BYTE    version = 1
+           STRING  augmentation = "" = BYTE 0
+           ULEB128 code alignment factor = 1
+           ULEB128 data alignment factor = -1
+           BYTE    return address register
+           <...>   start sequence
+        }
+        objectlibrary.getlabel(cielabel);
+        list.concat(tai_label.create(cielabel));
+        objectlibrary.getlabel(lenstartlabel);
+        objectlibrary.getlabel(lenendlabel);
+        list.concat(tai_const.create_rel_sym(ait_const_32bit,lenstartlabel,lenendlabel));
+        list.concat(tai_label.create(lenstartlabel));
+        list.concat(tai_const.create_32bit(longint($ffffffff)));
+        list.concat(tai_const.create_8bit(1));
+        list.concat(tai_const.create_8bit(0)); { empty string }
+        list.concat(tai_const.create_uleb128bit(code_alignment_factor));
+        list.concat(tai_const.create_sleb128bit(data_alignment_factor));
+        list.concat(tai_const.create_8bit(dwarf_reg(NR_RETURN_ADDRESS_REG)));
+        { Generate standard code
+            def_cfa(stackpointer,sizeof(aint))
+            cfa_offset_extended(returnaddres,-sizeof(aint))
+        }
+{$warning TODO This needs to be target dependent}
+        list.concat(tai_const.create_8bit(DW_CFA_def_cfa));
+        list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_STACK_POINTER_REG)));
+        list.concat(tai_const.create_uleb128bit(sizeof(aint)));
+        list.concat(tai_const.create_8bit(DW_CFA_offset_extended));
+        list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_RETURN_ADDRESS_REG)));
+        list.concat(tai_const.create_uleb128bit((-sizeof(aint)) div data_alignment_factor));
+        list.concat(cai_align.create_zeros(4));
+        list.concat(tai_label.create(lenendlabel));
+        lenstartlabel:=nil;
+        lenendlabel:=nil;
+
+        hp:=TDwarfItem(Dwarflist.first);
+        while assigned(hp) do
+          begin
+            case hp.op of
+              DW_CFA_Start_Frame :
+                begin
+                  if assigned(lenstartlabel) then
+                    internalerror(200404125);
+                  if (hp.ops<>1) or
+                     (hp.oper[0].typ<>dop_reloffset) then
+                    internalerror(200404126);
+                  objectlibrary.getlabel(lenstartlabel);
+                  objectlibrary.getlabel(lenendlabel);
+                  { FDE
+                     DWORD length
+                     DWORD CIE-pointer = cielabel
+                     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_label.create(lenstartlabel));
+                  { force label offset to 32bit }
+                  tc:=tai_const.create_sym(cielabel);
+                  tc.typ:=ait_const_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));
+                end;
+              DW_CFA_End_Frame :
+                begin
+                  list.concat(cai_align.create_zeros(4));
+                  list.concat(tai_label.create(lenendlabel));
+                  lenstartlabel:=nil;
+                  lenendlabel:=nil;
+                end;
+              else
+                hp.generate_code(list);
+            end;
+            hp:=TDwarfItem(hp.next);
+          end;
+        { Check for open frames }
+        if assigned(lenstartlabel) then
+          internalerror(2004041210);
+        { Dwarflist is processed, remove items }
+        DwarfList.Clear;
+      end;
+
+
+    procedure tdwarfcfi.start_frame(list:taasmoutput);
+      begin
+        if assigned(FFrameStartLabel) then
+          internalerror(200404129);
+        objectlibrary.getlabel(FFrameStartLabel);
+        objectlibrary.getlabel(FFrameEndLabel);
+        FLastloclabel:=FFrameStartLabel;
+        list.concat(tai_label.create(FFrameStartLabel));
+        dwarflist.concat(tdwarfitem.create_reloffset(DW_CFA_start_frame,doe_32bit,FFrameStartLabel,FFrameEndLabel));
+      end;
+
+
+    procedure tdwarfcfi.end_frame(list:taasmoutput);
+      begin
+        if not assigned(FFrameStartLabel) then
+          internalerror(2004041213);
+        dwarflist.concat(tdwarfitem.create(DW_CFA_end_frame));
+        list.concat(tai_label.create(FFrameEndLabel));
+        FFrameStartLabel:=nil;
+        FFrameEndLabel:=nil;
+        FLastLocLabel:=nil;
+      end;
+
+
+    procedure tdwarfcfi.cfa_advance_loc(list:taasmoutput);
+      var
+        currloclabel : tasmlabel;
+      begin
+        if FLastloclabel=nil then
+          internalerror(200404082);
+        objectlibrary.getlabel(currloclabel);
+        list.concat(tai_label.create(currloclabel));
+        dwarflist.concat(tdwarfitem.create_reloffset(DW_CFA_advance_loc4,doe_32bit,FLastloclabel,currloclabel));
+        FLastloclabel:=currloclabel;
+      end;
+
+
+    procedure tdwarfcfi.cfa_offset(list:taasmoutput;reg:tregister;ofs:longint);
+      begin
+        cfa_advance_loc(list);
+{$warning TODO check if ref is a temp}
+        { offset must be positive }
+        dwarflist.concat(tdwarfitem.create_reg_const(DW_CFA_offset_extended,doe_uleb,reg,doe_uleb,ofs div data_alignment_factor));
+      end;
+
+
+    procedure tdwarfcfi.cfa_restore(list:taasmoutput;reg:tregister);
+      begin
+        cfa_advance_loc(list);
+        dwarflist.concat(tdwarfitem.create_reg(DW_CFA_restore_extended,doe_uleb,reg));
+      end;
+
+
+    procedure tdwarfcfi.cfa_def_cfa_register(list:taasmoutput;reg:tregister);
+      begin
+        cfa_advance_loc(list);
+        dwarflist.concat(tdwarfitem.create_reg(DW_CFA_def_cfa_register,doe_uleb,reg));
+      end;
+
+
+    procedure tdwarfcfi.cfa_def_cfa_offset(list:taasmoutput;ofs:longint);
+      begin
+        cfa_advance_loc(list);
+        dwarflist.concat(tdwarfitem.create_const(DW_CFA_def_cfa_offset,doe_uleb,ofs));
+      end;
+
+
+begin
+{$warning TODO Maybe initialize per module}
+  dwarfcfi:=tdwarfcfi.create;
+end.
+{
+  $Log$
+  Revision 1.2  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.1.2.6  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.1.2.5  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.1.2.4  2004/04/20 16:35:58  peter
+    * generate dwarf for stackframe entry
+
+  Revision 1.1.2.3  2004/04/12 19:34:45  peter
+    * basic framework for dwarf CFI
+
+  Revision 1.1.2.2  2004/04/12 14:45:11  peter
+    * tai_const_symbol and tai_const merged
+
+  Revision 1.1.2.1  2004/04/08 21:04:24  peter
+    * prototype
+
+}

+ 8 - 2
compiler/finput.pas

@@ -417,7 +417,7 @@ uses
               break;
               break;
              inc(i);
              inc(i);
              getlinestr[i]:=c;
              getlinestr[i]:=c;
-             inc(longint(p));
+             inc(p);
            until (i=255);
            until (i=255);
            getlinestr[0]:=chr(i);
            getlinestr[0]:=chr(i);
          end;
          end;
@@ -712,7 +712,13 @@ uses
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.23  2003-12-27 22:27:24  peter
+  Revision 1.24  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.23.2.1  2004/04/28 21:46:56  peter
+    * compile fixes for x86-64
+
+  Revision 1.23  2003/12/27 22:27:24  peter
     * check with fileexists() before opening a file
     * check with fileexists() before opening a file
 
 
   Revision 1.22  2003/04/28 16:18:16  peter
   Revision 1.22  2003/04/28 16:18:16  peter

+ 23 - 4
compiler/fpcdefs.inc

@@ -18,8 +18,10 @@
       { We don't use exceptions, so turn off the implicit
       { We don't use exceptions, so turn off the implicit
         exceptions in the constructors }
         exceptions in the constructors }
       {$IMPLICITEXCEPTIONS OFF}
       {$IMPLICITEXCEPTIONS OFF}
-      { Inline small functions }
-      {$define USEINLINE}
+      { Inline small functions, but not when EXTDEBUG is used }
+      {$ifndef EXTDEBUG}
+        {$define USEINLINE}
+      {$endif EXTDEBUG}
     {$else}
     {$else}
       { Optimizer is broken when compiling with optimizations using 1.0.x }
       { Optimizer is broken when compiling with optimizations using 1.0.x }
       {$ifndef USEOPT}
       {$ifndef USEOPT}
@@ -64,6 +66,7 @@
   {$define cpuextended}
   {$define cpuextended}
   {$define cpufloat128}
   {$define cpufloat128}
   {$define noopt}
   {$define noopt}
+  {$define cputargethasfixedstack}
 {$endif x86_64}
 {$endif x86_64}
 
 
 {$ifdef alpha}
 {$ifdef alpha}
@@ -99,9 +102,25 @@
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.36  2004-05-30 21:20:40  jonas
+  Revision 1.37  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.36  2004/05/30 21:20:40  jonas
     * enable regvars by default for PPC
     * enable regvars by default for PPC
 
 
+  Revision 1.35.2.4  2004/05/02 12:45:32  peter
+    * enabled cpuhasfixedstack for x86-64 again
+    * fixed size of temp allocation for parameters
+
+  Revision 1.35.2.3  2004/05/02 01:02:24  peter
+    * remove fixed stack for x86-64
+
+  Revision 1.35.2.2  2004/04/29 23:30:28  peter
+    * fix i386 compiler
+
+  Revision 1.35.2.1  2004/04/23 22:12:37  florian
+    * fixed some potential stack corruption reasons
+
   Revision 1.35  2004/03/16 22:12:10  florian
   Revision 1.35  2004/03/16 22:12:10  florian
     * some alignment issues resolved
     * some alignment issues resolved
     * compiler doesn't generate anymore instructions not supported by the linux fpe
     * compiler doesn't generate anymore instructions not supported by the linux fpe
@@ -226,4 +245,4 @@
 
 
   Revision 1.3  2002/07/04 18:56:50  florian
   Revision 1.3  2002/07/04 18:56:50  florian
     + log added
     + log added
-}
+}

+ 9 - 3
compiler/gendef.pas

@@ -91,13 +91,13 @@ begin
   is_empty:=false;
   is_empty:=false;
 end;
 end;
 
 
+
 function tdeffile.empty : boolean;
 function tdeffile.empty : boolean;
 begin
 begin
-  empty:=is_empty and (description='');
+  empty:=is_empty or DescriptionSetExplicity;
 end;
 end;
 
 
 
 
-
 procedure tdeffile.writefile;
 procedure tdeffile.writefile;
 var
 var
   t : text;
   t : text;
@@ -160,7 +160,13 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2003-03-23 23:20:38  hajny
+  Revision 1.13  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.12.2.1  2004/05/03 14:59:57  peter
+    * no dlltool needed for win32 linking executables
+
+  Revision 1.12  2003/03/23 23:20:38  hajny
     + emx target added
     + emx target added
 
 
   Revision 1.11  2002/07/26 21:15:38  florian
   Revision 1.11  2002/07/26 21:15:38  florian

+ 39 - 28
compiler/globals.pas

@@ -89,9 +89,6 @@ interface
 
 
 
 
     type
     type
-{$ifdef ver1_0}
-       PtrInt = DWord;
-{$endif ver1_0}
        TFPUException = (exInvalidOp, exDenormalized, exZeroDivide,
        TFPUException = (exInvalidOp, exDenormalized, exZeroDivide,
                         exOverflow, exUnderflow, exPrecision);
                         exOverflow, exUnderflow, exPrecision);
        TFPUExceptionMask = set of TFPUException;
        TFPUExceptionMask = set of TFPUException;
@@ -113,11 +110,6 @@ interface
 
 
        tcodepagestring = string[20];
        tcodepagestring = string[20];
 
 
-       { the ordinal type used when evaluating constant integer expressions }
-       TConstExprInt = int64;
-       { ... the same unsigned }
-       TConstExprUInt = {$ifdef fpc}qword{$else}int64{$endif};
-
     var
     var
        { specified inputfile }
        { specified inputfile }
        inputdir       : dirstr;
        inputdir       : dirstr;
@@ -157,11 +149,19 @@ interface
        objectsearchpath,
        objectsearchpath,
        includesearchpath  : TSearchPathList;
        includesearchpath  : TSearchPathList;
 
 
-       { deffile }
+       { linking }
        usewindowapi  : boolean;
        usewindowapi  : boolean;
        description   : string;
        description   : string;
+       DescriptionSetExplicity : boolean;
        dllversion    : string;
        dllversion    : string;
-       dllmajor,dllminor,dllrevision : word;  { revision only for netware }
+       dllmajor,
+       dllminor,
+       dllrevision   : word;  { revision only for netware }
+       UseDeffileForExports    : boolean;
+       UseDeffileForExportsSetExplicitly : boolean;
+       RelocSection : boolean;
+       RelocSectionSetExplicitly : boolean;
+       LinkTypeSetExplicitly : boolean;
 
 
        akttokenpos,                  { position of the last token }
        akttokenpos,                  { position of the last token }
        aktfilepos : tfileposinfo;    { current position }
        aktfilepos : tfileposinfo;    { current position }
@@ -244,14 +244,8 @@ interface
        apptype : tapptype;
        apptype : tapptype;
 
 
     const
     const
-       RelocSection : boolean = true;
-       RelocSectionSetExplicitly : boolean = false;
-       LinkTypeSetExplicitly : boolean = false;
-
        DLLsource : boolean = false;
        DLLsource : boolean = false;
        DLLImageBase : pstring = nil;
        DLLImageBase : pstring = nil;
-       UseDeffileForExport : boolean = true;
-       ForceDeffileForExport : boolean = false;
 
 
        { used to set all registers used for each global function
        { used to set all registers used for each global function
          this should dramatically decrease the number of
          this should dramatically decrease the number of
@@ -325,7 +319,6 @@ interface
 
 
     function  string2guid(const s: string; var GUID: TGUID): boolean;
     function  string2guid(const s: string; var GUID: TGUID): boolean;
     function  guid2string(const GUID: TGUID): string;
     function  guid2string(const GUID: TGUID): string;
-    procedure swap_qword(var q : qword);
 
 
     function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
     function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
 
 
@@ -1377,7 +1370,7 @@ implementation
         begin
         begin
           CtlWord:=Get8087CW;
           CtlWord:=Get8087CW;
           Set8087CW( (CtlWord and $FFC0) or Byte(Longint(Mask)) );
           Set8087CW( (CtlWord and $FFC0) or Byte(Longint(Mask)) );
-          Result:=TFPUExceptionMask(CtlWord and $3F);
+          Result:=TFPUExceptionMask(Longint(CtlWord and $3F));
         end;
         end;
 {$else CPUI386}
 {$else CPUI386}
 {$ifdef CPUPOWERPC}
 {$ifdef CPUPOWERPC}
@@ -1666,11 +1659,6 @@ implementation
       end;
       end;
 
 
 
 
-    procedure swap_qword(var q : qword);
-      begin
-         q:=(qword(lo(q)) shl 32) or hi(q);
-      end;
-
     function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
     function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
       var
       var
         tok  : string;
         tok  : string;
@@ -1777,9 +1765,6 @@ implementation
        initdefines.free;
        initdefines.free;
        if assigned(DLLImageBase) then
        if assigned(DLLImageBase) then
          StringDispose(DLLImageBase);
          StringDispose(DLLImageBase);
-       RelocSection:=true;
-       RelocSectionSetExplicitly:=false;
-       UseDeffileForExport:=true;
        librarysearchpath.Free;
        librarysearchpath.Free;
        unitsearchpath.Free;
        unitsearchpath.Free;
        objectsearchpath.Free;
        objectsearchpath.Free;
@@ -1799,6 +1784,7 @@ implementation
         inlining_procedure:=false;
         inlining_procedure:=false;
         resolving_forward:=false;
         resolving_forward:=false;
         make_ref:=false;
         make_ref:=false;
+        LinkTypeSetExplicitly:=false;
 
 
       { Output }
       { Output }
         OutputFile:='';
         OutputFile:='';
@@ -1820,10 +1806,19 @@ implementation
       { Def file }
       { Def file }
         usewindowapi:=false;
         usewindowapi:=false;
         description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
         description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
+        DescriptionSetExplicity:=false;
         dllversion:='';
         dllversion:='';
+        dllmajor:=1;
+        dllminor:=0;
+        dllrevision:=0;
         nwscreenname := '';
         nwscreenname := '';
         nwthreadname := '';
         nwthreadname := '';
         nwcopyright  := '';
         nwcopyright  := '';
+        UseDeffileForExports:=false;
+        UseDeffileForExportsSetExplicitly:=false;
+        RelocSection:=false;
+        RelocSectionSetExplicitly:=false;
+        LinkTypeSetExplicitly:=false;
 
 
       { Init values }
       { Init values }
         initmodeswitches:=fpcmodeswitches;
         initmodeswitches:=fpcmodeswitches;
@@ -1903,7 +1898,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.129  2004-05-11 18:20:52  olle
+  Revision 1.130  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.129  2004/05/11 18:20:52  olle
     * changed $mode mac to $mode macpas
     * changed $mode mac to $mode macpas
     * changed macmodeswitches to be more faithful to the mac dialect
     * changed macmodeswitches to be more faithful to the mac dialect
 
 
@@ -1913,6 +1911,19 @@ end.
   Revision 1.127  2004/04/28 15:19:03  florian
   Revision 1.127  2004/04/28 15:19:03  florian
     + syscall directive support for MorphOS added
     + syscall directive support for MorphOS added
 
 
+  Revision 1.126.2.4  2004/05/09 15:47:21  peter
+    * fix typecast from word->set
+
+  Revision 1.126.2.3  2004/05/03 14:59:57  peter
+    * no dlltool needed for win32 linking executables
+
+  Revision 1.126.2.2  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.126.2.1  2004/04/27 18:18:25  peter
+    * aword -> aint
+
   Revision 1.126  2004/03/14 20:08:37  peter
   Revision 1.126  2004/03/14 20:08:37  peter
     * packrecords fixed for settings from $PACKRECORDS
     * packrecords fixed for settings from $PACKRECORDS
     * default packrecords now uses value 0 and uses info from aligment
     * default packrecords now uses value 0 and uses info from aligment
@@ -2231,4 +2242,4 @@ end.
    * implicit result variable generation for assembler routines
    * implicit result variable generation for assembler routines
    * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
    * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
 
 
-}
+}

+ 42 - 3
compiler/globtype.pas

@@ -29,12 +29,38 @@ interface
        maxidlen = 64;
        maxidlen = 64;
 
 
     type
     type
+{$ifndef fpc}
+       qword = int64;
+{$endif fpc}
+
 {$ifdef ver1_0}
 {$ifdef ver1_0}
        { Bootstrapping }
        { Bootstrapping }
        PtrInt = DWord;
        PtrInt = DWord;
        SizeInt = Longint;
        SizeInt = Longint;
 {$endif ver1_0}
 {$endif ver1_0}
 
 
+       { Natural integer register type and size for the target machine }
+{$ifdef cpu64bit}
+       AWord = qword;
+       AInt = Int64;
+{$else cpu64bit}
+       AWord = longword;
+       AInt = longint;
+{$endif cpu64bit}
+       PAWord = ^AWord;
+       PAInt = ^AInt;
+
+       { the ordinal type used when evaluating constant integer expressions }
+       TConstExprInt = int64;
+       { ... the same unsigned }
+       TConstExprUInt = qword;
+       { This must be an ordinal type with the same size as a pointer
+         Note: Must be unsigned! Otherwise, ugly code like
+         pointer(-1) will result in a pointer with the value
+         $fffffffffffffff on a 32bit machine if the compiler uses
+         int64 constants internally (JM) }
+       TConstPtrUInt = AWord;
+
        { Switches which can be changed locally }
        { Switches which can be changed locally }
        tlocalswitch = (cs_localnone,
        tlocalswitch = (cs_localnone,
          { codegen }
          { codegen }
@@ -79,7 +105,7 @@ interface
          cs_browser_log,
          cs_browser_log,
          { debugger }
          { debugger }
          cs_gdb_dbx,cs_gdb_gsym,cs_gdb_heaptrc,cs_gdb_lineinfo,
          cs_gdb_dbx,cs_gdb_gsym,cs_gdb_heaptrc,cs_gdb_lineinfo,
-         cs_checkpointer,cs_gdb_valgrind,
+         cs_checkpointer,cs_gdb_valgrind,cs_gdb_dwarf,
          { assembling }
          { assembling }
          cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source,
          cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source,
          cs_asm_regalloc,cs_asm_tempalloc,cs_asm_nodes,
          cs_asm_regalloc,cs_asm_tempalloc,cs_asm_nodes,
@@ -267,7 +293,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.56  2004-05-23 15:06:20  peter
+  Revision 1.57  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.56  2004/05/23 15:06:20  peter
     * implicit_finally flag must be set in pass1
     * implicit_finally flag must be set in pass1
     * add check whether the implicit frame is generated when expected
     * add check whether the implicit frame is generated when expected
 
 
@@ -283,6 +312,16 @@ end.
   Revision 1.52  2004/04/28 15:19:03  florian
   Revision 1.52  2004/04/28 15:19:03  florian
     + syscall directive support for MorphOS added
     + syscall directive support for MorphOS added
 
 
+  Revision 1.51.2.3  2004/05/02 00:45:51  peter
+    * define sizeint for 1.0.x
+
+  Revision 1.51.2.2  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.51.2.1  2004/04/10 22:08:52  florian
+    + more dwarf infrastructure
+
   Revision 1.51  2004/04/04 18:46:09  olle
   Revision 1.51  2004/04/04 18:46:09  olle
     + added $APPTYPE TOOL for MPW tools on MacOS
     + added $APPTYPE TOOL for MPW tools on MacOS
 
 
@@ -439,4 +478,4 @@ end.
    * implicit result variable generation for assembler routines
    * implicit result variable generation for assembler routines
    * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
    * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
 
 
-}
+}

+ 38 - 9
compiler/htypechk.pas

@@ -451,7 +451,7 @@ implementation
         { Multiple candidates left? }
         { Multiple candidates left? }
         if cand_cnt>1 then
         if cand_cnt>1 then
           begin
           begin
-            CGMessage(cg_e_cant_choose_overload_function);
+            CGMessage(type_e_cant_choose_overload_function);
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
             candidates.dump_info(V_Hint);
             candidates.dump_info(V_Hint);
 {$else EXTDEBUG}
 {$else EXTDEBUG}
@@ -597,7 +597,7 @@ implementation
         { Multiple candidates left? }
         { Multiple candidates left? }
         if cand_cnt>1 then
         if cand_cnt>1 then
           begin
           begin
-            CGMessage(cg_e_cant_choose_overload_function);
+            CGMessage(type_e_cant_choose_overload_function);
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
             candidates.dump_info(V_Hint);
             candidates.dump_info(V_Hint);
 {$else EXTDEBUG}
 {$else EXTDEBUG}
@@ -696,11 +696,6 @@ implementation
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
             end;
             end;
          end;
          end;
-
-         { error CGMessage, if more than 8 floating point }
-         { registers are needed                         }
-         { if p.registersfpu>maxfpuregs then
-          CGMessage(cg_e_too_complex_expr); now pushed if needed PM }
       end;
       end;
 
 
 
 
@@ -1909,7 +1904,37 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.92  2004-05-25 21:27:35  florian
+  Revision 1.93  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.92  2004/05/25 21:27:35  florian
+    * fixed another formal const problem caused by yesterday's changes
+
+  Revision 1.91  2004/05/24 21:24:40  florian
+    * properties are allowed as formal const parameters as well
+
+  Revision 1.90  2004/05/24 21:04:31  florian
+    * fixed more formal const problems
+
+  Revision 1.89  2004/05/24 20:39:41  florian
+    * stricter handling of formal const parameters and IE fixed
+
+  Revision 1.88  2004/05/23 18:28:40  peter
+    * methodpointer is loaded into a temp when it was a calln
+
+  Revision 1.87  2004/05/23 15:03:40  peter
+    * some typeconvs don't allow assignment or passing to var para
+
+  Revision 1.86  2004/05/16 13:29:46  peter
+    * forbid more overloaded operators with orddef/enumdef
+
+  Revision 1.85  2004/04/18 07:52:43  florian
+    * fixed web bug 3048: comparision of dyn. arrays
+
+  Revision 1.84.2.2  2004/05/30 10:45:49  peter
+    * merged fixes from main branch
+
+  Revision 1.92  2004/05/25 21:27:35  florian
     * fixed another formal const problem caused by yesterday's changes
     * fixed another formal const problem caused by yesterday's changes
 
 
   Revision 1.91  2004/05/24 21:24:40  florian
   Revision 1.91  2004/05/24 21:24:40  florian
@@ -1933,6 +1958,10 @@ end.
   Revision 1.85  2004/04/18 07:52:43  florian
   Revision 1.85  2004/04/18 07:52:43  florian
     * fixed web bug 3048: comparision of dyn. arrays
     * fixed web bug 3048: comparision of dyn. arrays
 
 
+  Revision 1.84.2.1  2004/04/28 19:55:51  peter
+    * new warning for ordinal-pointer when size is different
+    * fixed some cg_e_ messages to the correct section type_e_ or parser_e_
+
   Revision 1.84  2004/03/18 16:29:07  peter
   Revision 1.84  2004/03/18 16:29:07  peter
     * missing result initialization in node2opstr
     * missing result initialization in node2opstr
 
 
@@ -2115,4 +2144,4 @@ end.
     * no longer allow assignments to pointer expressions (unless there's a
     * no longer allow assignments to pointer expressions (unless there's a
       deref), reported by John Lee
       deref), reported by John Lee
 
 
-}
+}

+ 96 - 80
compiler/i386/ag386int.pas

@@ -62,6 +62,12 @@ implementation
     const
     const
       line_length = 70;
       line_length = 70;
 
 
+      secnames : array[TAsmSectionType] of string[4] = ('',
+        'CODE','DATA','DATA','BSS',
+        '','','','','','',
+        '','','','','',''
+      );
+
     function single2str(d : single) : string;
     function single2str(d : single) : string;
       var
       var
          hs : string;
          hs : string;
@@ -305,14 +311,17 @@ implementation
 
 
 
 
     var
     var
-      LasTSec : TSection;
+      LasTSectype : TAsmSectionType;
       lastfileinfo : tfileposinfo;
       lastfileinfo : tfileposinfo;
       infile,
       infile,
       lastinfile   : tinputfile;
       lastinfile   : tinputfile;
 
 
     const
     const
-      ait_const2str:array[ait_const_32bit..ait_const_8bit] of string[8]=
-        (#9'DD'#9,#9'DW'#9,#9'DB'#9);
+      ait_const2str : array[ait_const_128bit..ait_const_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
+      );
 
 
     Function PadTabs(const p:string;addch:char):string;
     Function PadTabs(const p:string;addch:char):string;
     var
     var
@@ -439,57 +448,65 @@ implementation
              end;
              end;
 
 
        ait_section : begin
        ait_section : begin
-                       if LasTSec<>sec_none then
-                        AsmWriteLn('_'+target_asm.secnames[LasTSec]+#9#9'ENDS');
-                       if tai_section(hp).sec<>sec_none then
+                       if LasTSecType<>sec_none then
+                        AsmWriteLn('_'+secnames[LasTSecType]+#9#9'ENDS');
+                       if tai_section(hp).sectype<>sec_none then
                         begin
                         begin
                           AsmLn;
                           AsmLn;
-                          AsmWriteLn('_'+target_asm.secnames[tai_section(hp).sec]+#9#9+
+                          AsmWriteLn('_'+secnames[tai_section(hp).sectype]+#9#9+
                                      'SEGMENT'#9'PARA PUBLIC USE32 '''+
                                      'SEGMENT'#9'PARA PUBLIC USE32 '''+
-                                     target_asm.secnames[tai_section(hp).sec]+'''');
+                                     secnames[tai_section(hp).sectype]+'''');
                         end;
                         end;
-                       LasTSec:=tai_section(hp).sec;
+                       LasTSecType:=tai_section(hp).sectype;
                      end;
                      end;
          ait_align : begin
          ait_align : begin
                      { CAUSES PROBLEMS WITH THE SEGMENT DEFINITION   }
                      { CAUSES PROBLEMS WITH THE SEGMENT DEFINITION   }
                      { SEGMENT DEFINITION SHOULD MATCH TYPE OF ALIGN }
                      { SEGMENT DEFINITION SHOULD MATCH TYPE OF ALIGN }
                      { HERE UNDER TASM!                              }
                      { HERE UNDER TASM!                              }
-                       AsmWriteLn(#9'ALIGN '+tostr(tai_align(hp).aligntype));
+                       if tai_align(hp).aligntype>1 then
+                         AsmWriteLn(#9'ALIGN '+tostr(tai_align(hp).aligntype));
                      end;
                      end;
      ait_datablock : begin
      ait_datablock : begin
                        if tai_datablock(hp).is_global then
                        if tai_datablock(hp).is_global then
                          AsmWriteLn(#9'PUBLIC'#9+tai_datablock(hp).sym.name);
                          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(?)');
                        AsmWriteLn(PadTabs(tai_datablock(hp).sym.name,#0)+'DB'#9+tostr(tai_datablock(hp).size)+' DUP(?)');
                      end;
                      end;
-   ait_const_32bit,
-    ait_const_8bit,
-   ait_const_16bit : begin
-                       AsmWrite(ait_const2str[hp.typ]+tostru(tai_const(hp).value));
-                       consttyp:=hp.typ;
-                       l:=0;
-                       repeat
-                         found:=(not (tai(hp.next)=nil)) and (tai(hp.next).typ=consttyp);
-                         if found then
-                          begin
-                            hp:=tai(hp.next);
-                            s:=','+tostru(tai_const(hp).value);
-                            AsmWrite(s);
-                            inc(l,length(s));
-                          end;
-                       until (not found) or (l>line_length);
-                       AsmLn;
-                     end;
-  ait_const_symbol : begin
-                       AsmWriteLn(#9#9'DD'#9'offset '+tai_const_symbol(hp).sym.name);
-                       if tai_const_symbol(hp).offset>0 then
-                         AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
-                       else if tai_const_symbol(hp).offset<0 then
-                         AsmWrite(tostr(tai_const_symbol(hp).offset));
-                       AsmLn;
-                     end;
-     ait_const_rva : begin
-                       AsmWriteLn(#9#9'RVA'#9+tai_const_symbol(hp).sym.name);
-                     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 :
+             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
+                       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;
+             end;
+
         ait_real_32bit : AsmWriteLn(#9#9'DD'#9+single2str(tai_real_32bit(hp).value));
         ait_real_32bit : AsmWriteLn(#9#9'DD'#9+single2str(tai_real_32bit(hp).value));
         ait_real_64bit : AsmWriteLn(#9#9'DQ'#9+double2str(tai_real_64bit(hp).value));
         ait_real_64bit : AsmWriteLn(#9#9'DQ'#9+double2str(tai_real_64bit(hp).value));
       ait_real_80bit : AsmWriteLn(#9#9'DT'#9+extended2str(tai_real_80bit(hp).value));
       ait_real_80bit : AsmWriteLn(#9#9'DT'#9+extended2str(tai_real_80bit(hp).value));
@@ -575,7 +592,7 @@ implementation
                           AsmWrite(tai_label(hp).l.name);
                           AsmWrite(tai_label(hp).l.name);
                           if assigned(hp.next) and not(tai(hp.next).typ in
                           if assigned(hp.next) and not(tai(hp.next).typ in
                              [ait_const_32bit,ait_const_16bit,ait_const_8bit,
                              [ait_const_32bit,ait_const_16bit,ait_const_8bit,
-                              ait_const_symbol,ait_const_rva,
+                              ait_const_rva_symbol,
                               ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_string]) then
                               ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_string]) then
                            AsmWriteLn(':')
                            AsmWriteLn(':')
                           else
                           else
@@ -592,7 +609,7 @@ implementation
                        AsmWrite(tai_symbol(hp).sym.name);
                        AsmWrite(tai_symbol(hp).sym.name);
                        if assigned(hp.next) and not(tai(hp.next).typ in
                        if assigned(hp.next) and not(tai(hp.next).typ in
                           [ait_const_32bit,ait_const_16bit,ait_const_8bit,
                           [ait_const_32bit,ait_const_16bit,ait_const_8bit,
-                           ait_const_symbol,ait_const_rva,
+                           ait_const_rva_symbol,
                            ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_string]) then
                            ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_string]) then
                         AsmWriteLn(':')
                         AsmWriteLn(':')
                      end;
                      end;
@@ -683,27 +700,25 @@ implementation
         ait_force_line,
         ait_force_line,
 ait_stab_function_name : ;
 ait_stab_function_name : ;
 {$endif GDB}
 {$endif GDB}
-           ait_cut : begin
+           ait_cutobject : begin
                      { only reset buffer if nothing has changed }
                      { only reset buffer if nothing has changed }
                        if AsmSize=AsmStartSize then
                        if AsmSize=AsmStartSize then
                         AsmClear
                         AsmClear
                        else
                        else
                         begin
                         begin
-                          if LasTSec<>sec_none then
-                           AsmWriteLn('_'+target_asm.secnames[LasTSec]+#9#9'ENDS');
+                          if LasTSecType<>sec_none then
+                           AsmWriteLn('_'+secnames[LasTSecType]+#9#9'ENDS');
                           AsmLn;
                           AsmLn;
                           AsmWriteLn(#9'END');
                           AsmWriteLn(#9'END');
                           AsmClose;
                           AsmClose;
                           DoAssemble;
                           DoAssemble;
-                          AsmCreate(tai_cut(hp).place);
+                          AsmCreate(tai_cutobject(hp).place);
                         end;
                         end;
                      { avoid empty files }
                      { avoid empty files }
-                       while assigned(hp.next) and (tai(hp.next).typ in [ait_cut,ait_section,ait_comment]) do
+                       while assigned(hp.next) and (tai(hp.next).typ in [ait_cutobject,ait_section,ait_comment]) do
                         begin
                         begin
                           if tai(hp.next).typ=ait_section then
                           if tai(hp.next).typ=ait_section then
-                           begin
-                             lasTSec:=tai_section(hp.next).sec;
-                           end;
+                            lasTSecType:=tai_section(hp.next).sectype;
                           hp:=tai(hp.next);
                           hp:=tai(hp.next);
                         end;
                         end;
                        AsmWriteLn(#9'.386p');
                        AsmWriteLn(#9'.386p');
@@ -712,10 +727,10 @@ ait_stab_function_name : ;
                        { I was told that this isn't necesarry because }
                        { I was told that this isn't necesarry because }
                        { the labels generated by FPC are unique (FK)  }
                        { the labels generated by FPC are unique (FK)  }
                        { AsmWriteLn(#9'LOCALS '+target_asm.labelprefix); }
                        { AsmWriteLn(#9'LOCALS '+target_asm.labelprefix); }
-                       if lasTSec<>sec_none then
-                          AsmWriteLn('_'+target_asm.secnames[lasTSec]+#9#9+
+                       if lasTSectype<>sec_none then
+                          AsmWriteLn('_'+secnames[lasTSectype]+#9#9+
                                      'SEGMENT'#9'PARA PUBLIC USE32 '''+
                                      'SEGMENT'#9'PARA PUBLIC USE32 '''+
-                                     target_asm.secnames[lasTSec]+'''');
+                                     secnames[lasTSectype]+'''');
                        AsmStartSize:=AsmSize;
                        AsmStartSize:=AsmSize;
                      end;
                      end;
            ait_marker :
            ait_marker :
@@ -782,7 +797,7 @@ ait_stab_function_name : ;
       if assigned(current_module.mainsource) then
       if assigned(current_module.mainsource) then
        comment(v_info,'Start writing intel-styled assembler output for '+current_module.mainsource^);
        comment(v_info,'Start writing intel-styled assembler output for '+current_module.mainsource^);
 {$endif}
 {$endif}
-      LasTSec:=sec_none;
+      LasTSecType:=sec_none;
       AsmWriteLn(#9'.386p');
       AsmWriteLn(#9'.386p');
       { masm 6.11 does not seem to like LOCALS PM }
       { masm 6.11 does not seem to like LOCALS PM }
       if (aktoutputformat = as_i386_tasm) then
       if (aktoutputformat = as_i386_tasm) then
@@ -827,16 +842,9 @@ ait_stab_function_name : ;
             asmbin : 'tasm';
             asmbin : 'tasm';
             asmcmd : '/m2 /ml $ASM $OBJ';
             asmcmd : '/m2 /ml $ASM $OBJ';
             supported_target : system_any; { what should I write here ?? }
             supported_target : system_any; { what should I write here ?? }
-            outputbinary: false;
-            allowdirect : true;
-            needar : true;
-            labelprefix_only_inside_procedure : true;
+            flags : [af_allowdirect,af_needar,af_labelprefix_only_inside_procedure];
             labelprefix : '@@';
             labelprefix : '@@';
             comment : '; ';
             comment : '; ';
-            secnames : ('',
-              'CODE','DATA','BSS',
-              '','','','','','',
-              '','','')
           );
           );
 
 
        as_i386_masm_info : tasminfo =
        as_i386_masm_info : tasminfo =
@@ -846,16 +854,9 @@ ait_stab_function_name : ;
             asmbin : 'masm';
             asmbin : 'masm';
             asmcmd : '/c /Cp $ASM /Fo$OBJ';
             asmcmd : '/c /Cp $ASM /Fo$OBJ';
             supported_target : system_any; { what should I write here ?? }
             supported_target : system_any; { what should I write here ?? }
-            outputbinary: false;
-            allowdirect : true;
-            needar : true;
-            labelprefix_only_inside_procedure : false;
+            flags : [af_allowdirect,af_needar];
             labelprefix : '@@';
             labelprefix : '@@';
             comment : '; ';
             comment : '; ';
-            secnames : ('',
-              'CODE','DATA','BSS',
-              '','','','','','',
-              '','','')
           );
           );
 
 
        as_i386_wasm_info : tasminfo =
        as_i386_wasm_info : tasminfo =
@@ -865,16 +866,9 @@ ait_stab_function_name : ;
             asmbin : 'wasm';
             asmbin : 'wasm';
             asmcmd : '$ASM -6s -fp6 -ms -zq -Fo=$OBJ';
             asmcmd : '$ASM -6s -fp6 -ms -zq -Fo=$OBJ';
             supported_target : system_any; { what should I write here ?? }
             supported_target : system_any; { what should I write here ?? }
-            outputbinary: false;
-            allowdirect : true;
-            needar : true;
-            labelprefix_only_inside_procedure : false;
+            flags : [af_allowdirect,af_needar];
             labelprefix : '@@';
             labelprefix : '@@';
             comment : '; ';
             comment : '; ';
-            secnames : ('',
-              'CODE','DATA','BSS',
-              '','','','','','',
-              '','','')
           );
           );
 
 
 initialization
 initialization
@@ -884,9 +878,31 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.48  2004-05-22 23:34:28  peter
+  Revision 1.49  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.48  2004/05/22 23:34:28  peter
   tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
   tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
 
 
+  Revision 1.47.2.6  2004/05/01 16:02:10  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.47.2.5  2004/04/29 19:07:22  peter
+    * compile fixes
+
+  Revision 1.47.2.4  2004/04/12 19:34:46  peter
+    * basic framework for dwarf CFI
+
+  Revision 1.47.2.3  2004/04/12 14:45:11  peter
+    * tai_const_symbol and tai_const merged
+
+  Revision 1.47.2.2  2004/04/10 12:36:41  peter
+    * fixed alignment issues
+
+  Revision 1.47.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
   Revision 1.47  2004/03/17 12:03:00  olle
   Revision 1.47  2004/03/17 12:03:00  olle
     * bugfix for multiline string constants
     * bugfix for multiline string constants
 
 
@@ -1039,7 +1055,7 @@ end.
       the parast, detected by tcalcst3 test
       the parast, detected by tcalcst3 test
 
 
   Revision 1.17  2002/04/15 19:12:09  carl
   Revision 1.17  2002/04/15 19:12:09  carl
-  + target_info.size_of_pointer -> pointer_size
+  + target_info.size_of_pointer -> sizeof(aint)
   + some cleanup of unused types/variables
   + some cleanup of unused types/variables
   * move several constants from cpubase to their specific units
   * move several constants from cpubase to their specific units
     (where they are used)
     (where they are used)
@@ -1061,4 +1077,4 @@ end.
       with string operations
       with string operations
     * adapted some routines to use the new cg methods
     * adapted some routines to use the new cg methods
 
 
-}
+}

+ 107 - 98
compiler/i386/ag386nsm.pas

@@ -37,6 +37,7 @@ interface
         procedure WriteReference(var ref : treference);
         procedure WriteReference(var ref : treference);
         procedure WriteOper(const o:toper;s : topsize; opcode: tasmop;ops:longint;dest : boolean);
         procedure WriteOper(const o:toper;s : topsize; opcode: tasmop;ops:longint;dest : boolean);
         procedure WriteOper_jmp(const o:toper; op : tasmop);
         procedure WriteOper_jmp(const o:toper; op : tasmop);
+        procedure WriteSection(atype:tasmsectiontype;const aname:string);
       public
       public
         procedure WriteTree(p:taasmoutput);override;
         procedure WriteTree(p:taasmoutput);override;
         procedure WriteAsmList;override;
         procedure WriteAsmList;override;
@@ -346,11 +347,38 @@ interface
 
 
 
 
     var
     var
-      LasTSec : TSection;
+      LastSecType : TAsmSectionType;
 
 
     const
     const
-      ait_const2str:array[ait_const_32bit..ait_const_8bit] of string[8]=
-        (#9'DD'#9,#9'DW'#9,#9'DB'#9);
+      ait_const2str : array[ait_const_128bit..ait_const_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
+      );
+
+    procedure T386NasmAssembler.WriteSection(atype:tasmsectiontype;const aname:string);
+      const
+        secnames : array[tasmsectiontype] of string[12] = ('',
+          '.text','.data','.rodata','.bss',
+          'common',
+          '.note',
+          '.stab','.stabstr',
+          '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
+          '.eh_frame',
+          '.debug_frame'
+        );
+      begin
+        AsmLn;
+        AsmWrite('SECTION ');
+        AsmWrite(secnames[atype]);
+        if (atype<>sec_bss) and (aname<>'') then
+          begin
+            AsmWrite('.');
+            AsmWrite(aname);
+          end;
+        AsmLn;
+        LasTSecType:=atype;
+      end;
 
 
     procedure T386NasmAssembler.WriteTree(p:taasmoutput);
     procedure T386NasmAssembler.WriteTree(p:taasmoutput);
     const
     const
@@ -460,19 +488,17 @@ interface
 
 
            ait_section :
            ait_section :
              begin
              begin
-               if tai_section(hp).sec<>sec_none then
-                begin
-                  AsmLn;
-                  AsmWriteLn('SECTION '+target_asm.secnames[tai_section(hp).sec]);
-                end;
-               LasTSec:=tai_section(hp).sec;
+               if tai_section(hp).sectype<>sec_none then
+                 WriteSection(tai_section(hp).sectype,tai_section(hp).name^);
+               LasTSecType:=tai_section(hp).sectype;
              end;
              end;
 
 
            ait_align :
            ait_align :
              begin
              begin
                { nasm gives warnings when it finds align in bss as it
                { nasm gives warnings when it finds align in bss as it
                  wants to store data }
                  wants to store data }
-               if lastsec<>sec_bss then
+               if (lastsectype<>sec_bss) and
+                  (tai_align(hp).aligntype>1) then
                  AsmWriteLn(#9'ALIGN '+tostr(tai_align(hp).aligntype));
                  AsmWriteLn(#9'ALIGN '+tostr(tai_align(hp).aligntype));
              end;
              end;
 
 
@@ -487,43 +513,43 @@ interface
                AsmWriteLn('RESB'#9+tostr(tai_datablock(hp).size));
                AsmWriteLn('RESB'#9+tostr(tai_datablock(hp).size));
              end;
              end;
 
 
+           ait_const_uleb128bit,
+           ait_const_sleb128bit,
+           ait_const_128bit,
+           ait_const_64bit,
            ait_const_32bit,
            ait_const_32bit,
            ait_const_16bit,
            ait_const_16bit,
-           ait_const_8bit :
+           ait_const_8bit,
+           ait_const_rva_symbol,
+           ait_const_indirect_symbol :
              begin
              begin
-               AsmWrite(ait_const2str[hp.typ]+tostru(tai_const(hp).value));
+               AsmWrite(ait_const2str[hp.typ]);
                consttyp:=hp.typ;
                consttyp:=hp.typ;
                l:=0;
                l:=0;
                repeat
                repeat
-                 found:=(not (tai(hp.next)=nil)) and (tai(hp.next).typ=consttyp);
-                 if found then
-                  begin
-                    hp:=tai(hp.next);
-                    s:=','+tostru(tai_const(hp).value);
-                    AsmWrite(s);
-                    inc(l,length(s));
-                  end;
-               until (not found) or (l>line_length);
-               AsmLn;
-             end;
-
-           ait_const_symbol :
-             begin
-               AsmWrite(#9#9'DD'#9);
-               AsmWrite(tai_const_symbol(hp).sym.name);
-               if tai_const_symbol(hp).offset>0 then
-                 AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
-               else if tai_const_symbol(hp).offset<0 then
-                 AsmWrite(tostr(tai_const_symbol(hp).offset));
+                 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<>consttyp) then
+                   break;
+                 hp:=tai(hp.next);
+                 AsmWrite(',');
+               until false;
                AsmLn;
                AsmLn;
              end;
              end;
 
 
-           ait_const_rva :
-             begin
-               AsmWrite(#9#9'RVA'#9);
-               AsmWriteLn(tai_const_symbol(hp).sym.name);
-             end;
-
            ait_real_32bit :
            ait_real_32bit :
              AsmWriteLn(#9#9'DD'#9+single2str(tai_real_32bit(hp).value));
              AsmWriteLn(#9#9'DD'#9+single2str(tai_real_32bit(hp).value));
 
 
@@ -635,7 +661,7 @@ interface
                AsmWrite(tai_symbol(hp).sym.name);
                AsmWrite(tai_symbol(hp).sym.name);
                if assigned(hp.next) and not(tai(hp.next).typ in
                if assigned(hp.next) and not(tai(hp.next).typ in
                   [ait_const_32bit,ait_const_16bit,ait_const_8bit,
                   [ait_const_32bit,ait_const_16bit,ait_const_8bit,
-                   ait_const_symbol,ait_const_rva,
+                   ait_const_rva_symbol,
                    ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_string]) then
                    ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_string]) then
                 AsmWriteLn(':')
                 AsmWriteLn(':')
              end;
              end;
@@ -701,7 +727,7 @@ interface
            ait_stab_function_name : ;
            ait_stab_function_name : ;
 {$endif GDB}
 {$endif GDB}
 
 
-           ait_cut :
+           ait_cutobject :
              begin
              begin
              { only reset buffer if nothing has changed }
              { only reset buffer if nothing has changed }
                if AsmSize=AsmStartSize then
                if AsmSize=AsmStartSize then
@@ -710,17 +736,17 @@ interface
                 begin
                 begin
                   AsmClose;
                   AsmClose;
                   DoAssemble;
                   DoAssemble;
-                  AsmCreate(tai_cut(hp).place);
+                  AsmCreate(tai_cutobject(hp).place);
                 end;
                 end;
              { avoid empty files }
              { avoid empty files }
-               while assigned(hp.next) and (tai(hp.next).typ in [ait_cut,ait_section,ait_comment]) do
+               while assigned(hp.next) and (tai(hp.next).typ in [ait_cutobject,ait_section,ait_comment]) do
                 begin
                 begin
                   if tai(hp.next).typ=ait_section then
                   if tai(hp.next).typ=ait_section then
-                    lasTSec:=tai_section(hp.next).sec;
+                    lasTSectype:=tai_section(hp.next).sectype;
                   hp:=tai(hp.next);
                   hp:=tai(hp.next);
                 end;
                 end;
-               if lasTSec<>sec_none then
-                 AsmWriteLn('SECTION '+target_asm.secnames[lasTSec]);
+               if lasTSectype<>sec_none then
+                 WriteSection(tai_section(hp).sectype,tai_section(hp).name^);
                AsmStartSize:=AsmSize;
                AsmStartSize:=AsmSize;
              end;
              end;
 
 
@@ -760,7 +786,7 @@ interface
       if assigned(current_module.mainsource) then
       if assigned(current_module.mainsource) then
        comment(v_info,'Start writing nasm-styled assembler output for '+current_module.mainsource^);
        comment(v_info,'Start writing nasm-styled assembler output for '+current_module.mainsource^);
 {$endif}
 {$endif}
-      LasTSec:=sec_none;
+      LasTSecType:=sec_none;
       AsmWriteLn('BITS 32');
       AsmWriteLn('BITS 32');
       AsmLn;
       AsmLn;
 
 
@@ -782,7 +808,7 @@ interface
       Writetree(importssection);
       Writetree(importssection);
       { exports are written by DLLTOOL
       { exports are written by DLLTOOL
         if we use it so don't insert it twice (PM) }
         if we use it so don't insert it twice (PM) }
-      if not UseDeffileForExport and assigned(exportssection) then
+      if not UseDeffileForExports and assigned(exportssection) then
         Writetree(exportssection);
         Writetree(exportssection);
       Writetree(resourcesection);
       Writetree(resourcesection);
 
 
@@ -806,16 +832,9 @@ interface
             asmbin : 'nasm';
             asmbin : 'nasm';
             asmcmd : '-f coff -o $OBJ $ASM';
             asmcmd : '-f coff -o $OBJ $ASM';
             supported_target : system_i386_go32v2;
             supported_target : system_i386_go32v2;
-            outputbinary: false;
-            allowdirect : true;
-            needar : true;
-            labelprefix_only_inside_procedure: false;
+            flags : [af_allowdirect,af_needar];
             labelprefix : '..@';
             labelprefix : '..@';
             comment : '; ';
             comment : '; ';
-            secnames : ('',
-              '.text','.data','.bss',
-              '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
-              '.stab','.stabstr','')
           );
           );
 
 
        as_i386_nasmwin32_info : tasminfo =
        as_i386_nasmwin32_info : tasminfo =
@@ -825,16 +844,9 @@ interface
             asmbin : 'nasm';
             asmbin : 'nasm';
             asmcmd : '-f win32 -o $OBJ $ASM';
             asmcmd : '-f win32 -o $OBJ $ASM';
             supported_target : system_i386_win32;
             supported_target : system_i386_win32;
-            outputbinary: false;
-            allowdirect : true;
-            needar : true;
-            labelprefix_only_inside_procedure: false;
+            flags : [af_allowdirect,af_needar];
             labelprefix : '..@';
             labelprefix : '..@';
             comment : '; ';
             comment : '; ';
-            secnames : ('',
-              '.text','.data','.bss',
-              '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
-              '.stab','.stabstr','')
           );
           );
 
 
        as_i386_nasmobj_info : tasminfo =
        as_i386_nasmobj_info : tasminfo =
@@ -844,16 +856,9 @@ interface
             asmbin : 'nasm';
             asmbin : 'nasm';
             asmcmd : '-f obj -o $OBJ $ASM';
             asmcmd : '-f obj -o $OBJ $ASM';
             supported_target : system_any; { what should I write here ?? }
             supported_target : system_any; { what should I write here ?? }
-            outputbinary: false;
-            allowdirect : true;
-            needar : true;
-            labelprefix_only_inside_procedure: false;
+            flags : [af_allowdirect,af_needar];
             labelprefix : '..@';
             labelprefix : '..@';
             comment : '; ';
             comment : '; ';
-            secnames : ('',
-              '.text','.data','.bss',
-              '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
-              '.stab','.stabstr','')
           );
           );
 
 
        as_i386_nasmwdosx_info : tasminfo =
        as_i386_nasmwdosx_info : tasminfo =
@@ -863,16 +868,9 @@ interface
             asmbin : 'nasm';
             asmbin : 'nasm';
             asmcmd : '-f win32 -o $OBJ $ASM';
             asmcmd : '-f win32 -o $OBJ $ASM';
             supported_target : system_i386_wdosx;
             supported_target : system_i386_wdosx;
-            outputbinary: false;
-            allowdirect : true;
-            needar : true;
-            labelprefix_only_inside_procedure: false;
+            flags : [af_allowdirect,af_needar];
             labelprefix : '..@';
             labelprefix : '..@';
             comment : '; ';
             comment : '; ';
-            secnames : ('',
-              '.text','.data','.bss',
-              '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
-              '.stab','.stabstr','')
           );
           );
 
 
 
 
@@ -883,16 +881,9 @@ interface
             asmbin : 'nasm';
             asmbin : 'nasm';
             asmcmd : '-f elf -o $OBJ $ASM';
             asmcmd : '-f elf -o $OBJ $ASM';
             supported_target : system_i386_linux;
             supported_target : system_i386_linux;
-            outputbinary: false;
-            allowdirect : true;
-            needar : true;
-            labelprefix_only_inside_procedure: false;
+            flags : [af_allowdirect,af_needar];
             labelprefix : '..@';
             labelprefix : '..@';
             comment : '; ';
             comment : '; ';
-            secnames : ('',
-              '.text','.data','.bss',
-              '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
-              '.stab','.stabstr','')
           );
           );
 
 
        as_i386_nasmbeos_info : tasminfo =
        as_i386_nasmbeos_info : tasminfo =
@@ -902,16 +893,9 @@ interface
             asmbin : 'nasm';
             asmbin : 'nasm';
             asmcmd : '-f elf -o $OBJ $ASM';
             asmcmd : '-f elf -o $OBJ $ASM';
             supported_target : system_i386_beos;
             supported_target : system_i386_beos;
-            outputbinary: false;
-            allowdirect : true;
-            needar : true;
-            labelprefix_only_inside_procedure: false;
+            flags : [af_allowdirect,af_needar];
             labelprefix : '..@';
             labelprefix : '..@';
             comment : '; ';
             comment : '; ';
-            secnames : ('',
-              '.text','.data','.bss',
-              '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
-              '.stab','.stabstr','')
           );
           );
 
 
 
 
@@ -925,9 +909,34 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.45  2004-05-22 23:34:28  peter
+  Revision 1.46  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.45  2004/05/22 23:34:28  peter
   tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
   tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
 
 
+  Revision 1.44.2.7  2004/05/03 14:59:58  peter
+    * no dlltool needed for win32 linking executables
+
+  Revision 1.44.2.6  2004/05/01 16:02:10  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.44.2.5  2004/04/29 19:07:22  peter
+    * compile fixes
+
+  Revision 1.44.2.4  2004/04/12 19:34:46  peter
+    * basic framework for dwarf CFI
+
+  Revision 1.44.2.3  2004/04/12 14:45:11  peter
+    * tai_const_symbol and tai_const merged
+
+  Revision 1.44.2.2  2004/04/10 12:36:41  peter
+    * fixed alignment issues
+
+  Revision 1.44.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
   Revision 1.44  2004/02/27 10:21:05  florian
   Revision 1.44  2004/02/27 10:21:05  florian
     * top_symbol killed
     * top_symbol killed
     + refaddr to treference added
     + refaddr to treference added
@@ -1072,7 +1081,7 @@ end.
       the parast, detected by tcalcst3 test
       the parast, detected by tcalcst3 test
 
 
   Revision 1.16  2002/04/15 19:12:09  carl
   Revision 1.16  2002/04/15 19:12:09  carl
-  + target_info.size_of_pointer -> pointer_size
+  + target_info.size_of_pointer -> sizeof(aint)
   + some cleanup of unused types/variables
   + some cleanup of unused types/variables
   * move several constants from cpubase to their specific units
   * move several constants from cpubase to their specific units
     (where they are used)
     (where they are used)
@@ -1096,4 +1105,4 @@ end.
       with string operations
       with string operations
     * adapted some routines to use the new cg methods
     * adapted some routines to use the new cg methods
 
 
-}
+}

+ 244 - 49
compiler/i386/cgcpu.pas

@@ -29,6 +29,7 @@ unit cgcpu;
   interface
   interface
 
 
     uses
     uses
+       globtype,
        cgbase,cgobj,cg64f32,cgx86,
        cgbase,cgobj,cg64f32,cgx86,
        aasmbase,aasmtai,aasmcpu,
        aasmbase,aasmtai,aasmcpu,
        cpubase,cpuinfo,
        cpubase,cpuinfo,
@@ -41,17 +42,27 @@ unit cgcpu;
     type
     type
       tcg386 = class(tcgx86)
       tcg386 = class(tcgx86)
         procedure init_register_allocators;override;
         procedure init_register_allocators;override;
-        class function reg_cgsize(const reg: tregister): tcgsize; override;
+        { passing parameter using push instead of mov }
+        procedure a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;const locpara : tparalocation);override;
+        procedure a_param_const(list : taasmoutput;size : tcgsize;a : aint;const locpara : tparalocation);override;
+        procedure a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);override;
+        procedure a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);override;
+
         procedure g_save_all_registers(list : taasmoutput);override;
         procedure g_save_all_registers(list : taasmoutput);override;
         procedure g_restore_all_registers(list : taasmoutput;const funcretparaloc:tparalocation);override;
         procedure g_restore_all_registers(list : taasmoutput;const funcretparaloc:tparalocation);override;
-        procedure g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);override;
+        procedure g_proc_exit(list : taasmoutput;parasize:longint;nostackframe:boolean);override;
+        procedure g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aint);override;
+
+        procedure g_exception_reason_save(list : taasmoutput; const href : treference);override;
+        procedure g_exception_reason_save_const(list : taasmoutput; const href : treference; a: aint);override;
+        procedure g_exception_reason_load(list : taasmoutput; const href : treference);override;
      end;
      end;
 
 
       tcg64f386 = class(tcg64f32)
       tcg64f386 = class(tcg64f32)
         procedure a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);override;
         procedure a_op64_ref_reg(list : taasmoutput;op:TOpCG;const ref : treference;reg : tregister64);override;
         procedure a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);override;
         procedure a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);override;
-        procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;reg : tregister64);override;
-        procedure a_op64_const_ref(list : taasmoutput;op:TOpCG;value : qword;const ref : treference);override;
+        procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : int64;reg : tregister64);override;
+        procedure a_op64_const_ref(list : taasmoutput;op:TOpCG;value : int64;const ref : treference);override;
       private
       private
         procedure get_64bit_ops(op:TOpCG;var op1,op2:TAsmOp);
         procedure get_64bit_ops(op:TOpCG;var op1,op2:TAsmOp);
       end;
       end;
@@ -59,7 +70,7 @@ unit cgcpu;
   implementation
   implementation
 
 
     uses
     uses
-       globtype,globals,verbose,systems,cutils,
+       globals,verbose,systems,cutils,
        symdef,symsym,defutil,paramgr,procinfo,
        symdef,symsym,defutil,paramgr,procinfo,
        rgcpu,rgx86,tgobj,
        rgcpu,rgx86,tgobj,
        cgutils;
        cgutils;
@@ -77,47 +88,109 @@ unit cgcpu;
       end;
       end;
 
 
 
 
-    class function tcg386.reg_cgsize(const reg: tregister): tcgsize;
-
-    const subreg2cgsize:array[Tsubregister] of Tcgsize =
-          (OS_NO,OS_8,OS_8,OS_16,OS_32,OS_64,OS_NO,OS_NO);
-
-    begin
-      case getregtype(reg) of
-        R_INTREGISTER :
-          reg_cgsize:=subreg2cgsize[getsubreg(reg)];
-        R_FPUREGISTER :
-          reg_cgsize:=OS_F80;
-        R_MMXREGISTER,
-        R_MMREGISTER :
-          reg_cgsize:=OS_M64;
-        R_SPECIALREGISTER :
-          case reg of
-            NR_CS,NR_DS,NR_ES,NR_SS,NR_FS,NR_GS:
-              reg_cgsize:=OS_16
-            else
-              reg_cgsize:=OS_32
-          end
-        else
-            internalerror(200303181);
-        end;
+    procedure tcg386.a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;const locpara : tparalocation);
+      var
+        pushsize : tcgsize;
+      begin
+        check_register_size(size,r);
+        with locpara do
+          if (loc=LOC_REFERENCE) and
+             (reference.index=NR_STACK_POINTER_REG) then
+            begin
+              pushsize:=int_cgsize(alignment);
+              list.concat(taicpu.op_reg(A_PUSH,tcgsize2opsize[pushsize],makeregsize(list,r,pushsize)));
+            end
+          else
+            inherited a_param_reg(list,size,r,locpara);
+      end;
+
+
+    procedure tcg386.a_param_const(list : taasmoutput;size : tcgsize;a : aint;const locpara : tparalocation);
+      var
+        pushsize : tcgsize;
+      begin
+        with locpara do
+          if (loc=LOC_REFERENCE) and
+             (reference.index=NR_STACK_POINTER_REG) then
+            begin
+              pushsize:=int_cgsize(alignment);
+              list.concat(taicpu.op_const(A_PUSH,tcgsize2opsize[pushsize],a));
+            end
+          else
+            inherited a_param_const(list,size,a,locpara);
+      end;
+
+
+    procedure tcg386.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);
+      var
+        pushsize : tcgsize;
+        tmpreg : tregister;
+      begin
+        with locpara do
+          if (loc=LOC_REFERENCE) and
+             (reference.index=NR_STACK_POINTER_REG) then
+            begin
+              pushsize:=int_cgsize(alignment);
+              if tcgsize2size[size]<alignment then
+                begin
+                  tmpreg:=getintregister(list,pushsize);
+                  a_load_ref_reg(list,size,pushsize,r,tmpreg);
+                  list.concat(taicpu.op_reg(A_PUSH,TCgsize2opsize[pushsize],tmpreg));
+                  ungetregister(list,tmpreg);
+                end
+              else
+                list.concat(taicpu.op_ref(A_PUSH,TCgsize2opsize[pushsize],r));
+            end
+          else
+            inherited a_param_ref(list,size,r,locpara);
       end;
       end;
 
 
-{      const
-        opsize_2_cgsize: array[topsize] of tcgsize = (OS_NO,
-          OS_8,OS_16,OS_32,OS_NO,OS_NO,OS_NO,
-          OS_32,OS_64,OS_64,
-          OS_F32,OS_F64,OS_F80,OS_F32,OS_F64,OS_M64,OS_NO,
-          OS_NO,OS_NO,OS_NO
-        );
+
+    procedure tcg386.a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);
+      var
+        tmpreg : tregister;
+        opsize : topsize;
       begin
       begin
-        result := opsize_2_cgsize[reg2opsize(reg)];
-      end;}
+        with r do
+          begin
+            if (segment<>NR_NO) then
+              cgmessage(cg_e_cant_use_far_pointer_there);
+            with locpara do
+              if (locpara.loc=LOC_REFERENCE) and
+                 (locpara.reference.index=NR_STACK_POINTER_REG) then
+                begin
+                  opsize:=tcgsize2opsize[OS_ADDR];
+                  if (base=NR_NO) and (index=NR_NO) then
+                    begin
+                      if assigned(symbol) then
+                        list.concat(Taicpu.Op_sym_ofs(A_PUSH,opsize,symbol,offset))
+                      else
+                        list.concat(Taicpu.Op_const(A_PUSH,opsize,offset));
+                    end
+                  else if (base=NR_NO) and (index<>NR_NO) and
+                          (offset=0) and (scalefactor=0) and (symbol=nil) then
+                    list.concat(Taicpu.Op_reg(A_PUSH,opsize,index))
+                  else if (base<>NR_NO) and (index=NR_NO) and
+                          (offset=0) and (symbol=nil) then
+                    list.concat(Taicpu.Op_reg(A_PUSH,opsize,base))
+                  else
+                    begin
+                      tmpreg:=getaddressregister(list);
+                      a_loadaddr_ref_reg(list,r,tmpreg);
+                      ungetregister(list,tmpreg);
+                      list.concat(taicpu.op_reg(A_PUSH,opsize,tmpreg));
+                    end;
+                end
+              else
+                inherited a_paramaddr_ref(list,r,locpara);
+        end;
+      end;
+
 
 
     procedure tcg386.g_save_all_registers(list : taasmoutput);
     procedure tcg386.g_save_all_registers(list : taasmoutput);
       begin
       begin
         list.concat(Taicpu.Op_none(A_PUSHA,S_L));
         list.concat(Taicpu.Op_none(A_PUSHA,S_L));
-        tg.GetTemp(list,POINTER_SIZE,tt_noreuse,current_procinfo.save_regs_ref);
+        tg.GetTemp(list,sizeof(aint),tt_noreuse,current_procinfo.save_regs_ref);
         a_load_reg_ref(list,OS_ADDR,OS_ADDR,NR_STACK_POINTER_REG,current_procinfo.save_regs_ref);
         a_load_reg_ref(list,OS_ADDR,OS_ADDR,NR_STACK_POINTER_REG,current_procinfo.save_regs_ref);
       end;
       end;
 
 
@@ -148,7 +221,81 @@ unit cgcpu;
         list.concat(taicpu.op_none(A_NOP,S_L));
         list.concat(taicpu.op_none(A_NOP,S_L));
       end;
       end;
 
 
-    procedure tcg386.g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aword);
+
+    procedure tcg386.g_proc_exit(list : taasmoutput;parasize:longint;nostackframe:boolean);
+      var
+        stacksize : longint;
+      begin
+        { Release PIC register }
+        if cs_create_pic in aktmoduleswitches then
+          list.concat(tai_regalloc.dealloc(NR_PIC_OFFSET_REG));
+
+        { MMX needs to call EMMS }
+        if assigned(rg[R_MMXREGISTER]) and
+           (rg[R_MMXREGISTER].uses_registers) then
+          list.concat(Taicpu.op_none(A_EMMS,S_NO));
+
+        { remove stackframe }
+        if not nostackframe then
+          begin
+            if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
+              begin
+                stacksize:=current_procinfo.calc_stackframe_size;
+                if (stacksize<>0) then
+                  cg.a_op_const_reg(list,OP_ADD,OS_ADDR,stacksize,current_procinfo.framepointer);
+              end
+            else
+              list.concat(Taicpu.op_none(A_LEAVE,S_NO));
+            list.concat(tai_regalloc.dealloc(NR_FRAME_POINTER_REG));
+          end;
+
+        { return from proc }
+        if (po_interrupt in current_procinfo.procdef.procoptions) then
+          begin
+            if current_procinfo.procdef.funcret_paraloc[calleeside].loc=LOC_REGISTER then
+              list.concat(Taicpu.Op_const_reg(A_ADD,S_L,4,NR_ESP))
+            else
+              list.concat(Taicpu.Op_reg(A_POP,S_L,NR_EAX));
+            list.concat(Taicpu.Op_reg(A_POP,S_L,NR_EBX));
+            list.concat(Taicpu.Op_reg(A_POP,S_L,NR_ECX));
+            if current_procinfo.procdef.funcret_paraloc[calleeside].lochigh=LOC_REGISTER then
+              list.concat(Taicpu.Op_const_reg(A_ADD,S_L,4,NR_ESP))
+            else
+              list.concat(Taicpu.Op_reg(A_POP,S_L,NR_EDX));
+            list.concat(Taicpu.Op_reg(A_POP,S_L,NR_ESI));
+            list.concat(Taicpu.Op_reg(A_POP,S_L,NR_EDI));
+            { .... also the segment registers }
+            list.concat(Taicpu.Op_reg(A_POP,S_W,NR_DS));
+            list.concat(Taicpu.Op_reg(A_POP,S_W,NR_ES));
+            list.concat(Taicpu.Op_reg(A_POP,S_W,NR_FS));
+            list.concat(Taicpu.Op_reg(A_POP,S_W,NR_GS));
+            { this restores the flags }
+            list.concat(Taicpu.Op_none(A_IRET,S_NO));
+          end
+        { Routines with the poclearstack flag set use only a ret }
+        else if current_procinfo.procdef.proccalloption in clearstack_pocalls then
+         begin
+           { complex return values are removed from stack in C code PM }
+           if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,
+                                       current_procinfo.procdef.proccalloption) then
+             list.concat(Taicpu.Op_const(A_RET,S_NO,sizeof(aint)))
+           else
+             list.concat(Taicpu.Op_none(A_RET,S_NO));
+         end
+        { ... also routines with parasize=0 }
+        else if (parasize=0) then
+         list.concat(Taicpu.Op_none(A_RET,S_NO))
+        else
+         begin
+           { parameters are limited to 65535 bytes because ret allows only imm16 }
+           if (parasize>65535) then
+             CGMessage(cg_e_parasize_too_big);
+           list.concat(Taicpu.Op_const(A_RET,S_NO,parasize));
+         end;
+      end;
+
+
+    procedure tcg386.g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:aint);
       var
       var
         power,len  : longint;
         power,len  : longint;
         opsize : topsize;
         opsize : topsize;
@@ -202,7 +349,7 @@ unit cgcpu;
 {$endif __NOWINPECOFF__}
 {$endif __NOWINPECOFF__}
           list.concat(Taicpu.op_reg_reg(A_SUB,S_L,NR_EDI,NR_ESP));
           list.concat(Taicpu.op_reg_reg(A_SUB,S_L,NR_EDI,NR_ESP));
         { align stack on 4 bytes }
         { align stack on 4 bytes }
-        list.concat(Taicpu.op_const_reg(A_AND,S_L,$fffffff4,NR_ESP));
+        list.concat(Taicpu.op_const_reg(A_AND,S_L,aint($fffffff4),NR_ESP));
         { load destination }
         { load destination }
         a_load_reg_reg(list,OS_INT,OS_INT,NR_ESP,NR_EDI);
         a_load_reg_reg(list,OS_INT,OS_INT,NR_ESP,NR_EDI);
 
 
@@ -253,6 +400,22 @@ unit cgcpu;
       end;
       end;
 
 
 
 
+    procedure tcg386.g_exception_reason_save(list : taasmoutput; const href : treference);
+      begin
+        list.concat(Taicpu.op_reg(A_PUSH,tcgsize2opsize[OS_INT],NR_FUNCTION_RESULT_REG));
+      end;
+
+
+    procedure tcg386.g_exception_reason_save_const(list : taasmoutput;const href : treference; a: aint);
+      begin
+        list.concat(Taicpu.op_const(A_PUSH,tcgsize2opsize[OS_INT],a));
+      end;
+
+
+    procedure tcg386.g_exception_reason_load(list : taasmoutput; const href : treference);
+      begin
+        list.concat(Taicpu.op_reg(A_POP,tcgsize2opsize[OS_INT],NR_FUNCTION_RESULT_REG));
+      end;
 
 
 
 
 { ************* 64bit operations ************ }
 { ************* 64bit operations ************ }
@@ -315,7 +478,7 @@ unit cgcpu;
                 a_load64_reg_reg(list,regsrc,regdst);
                 a_load64_reg_reg(list,regsrc,regdst);
               list.concat(taicpu.op_reg(A_NOT,S_L,regdst.reghi));
               list.concat(taicpu.op_reg(A_NOT,S_L,regdst.reghi));
               list.concat(taicpu.op_reg(A_NEG,S_L,regdst.reglo));
               list.concat(taicpu.op_reg(A_NEG,S_L,regdst.reglo));
-              list.concat(taicpu.op_const_reg(A_SBB,S_L,aword(-1),regdst.reghi));
+              list.concat(taicpu.op_const_reg(A_SBB,S_L,-1,regdst.reghi));
               exit;
               exit;
             end;
             end;
           OP_NOT :
           OP_NOT :
@@ -333,22 +496,22 @@ unit cgcpu;
       end;
       end;
 
 
 
 
-    procedure tcg64f386.a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;reg : tregister64);
+    procedure tcg64f386.a_op64_const_reg(list : taasmoutput;op:TOpCG;value : int64;reg : tregister64);
       var
       var
         op1,op2 : TAsmOp;
         op1,op2 : TAsmOp;
       begin
       begin
         case op of
         case op of
           OP_AND,OP_OR,OP_XOR:
           OP_AND,OP_OR,OP_XOR:
             begin
             begin
-              cg.a_op_const_reg(list,op,OS_32,lo(value),reg.reglo);
-              cg.a_op_const_reg(list,op,OS_32,hi(value),reg.reghi);
+              cg.a_op_const_reg(list,op,OS_32,aint(lo(value)),reg.reglo);
+              cg.a_op_const_reg(list,op,OS_32,aint(hi(value)),reg.reghi);
             end;
             end;
           OP_ADD, OP_SUB:
           OP_ADD, OP_SUB:
             begin
             begin
               // can't use a_op_const_ref because this may use dec/inc
               // can't use a_op_const_ref because this may use dec/inc
               get_64bit_ops(op,op1,op2);
               get_64bit_ops(op,op1,op2);
-              list.concat(taicpu.op_const_reg(op1,S_L,lo(value),reg.reglo));
-              list.concat(taicpu.op_const_reg(op2,S_L,hi(value),reg.reghi));
+              list.concat(taicpu.op_const_reg(op1,S_L,aint(lo(value)),reg.reglo));
+              list.concat(taicpu.op_const_reg(op2,S_L,aint(hi(value)),reg.reghi));
             end;
             end;
           else
           else
             internalerror(200204021);
             internalerror(200204021);
@@ -356,7 +519,7 @@ unit cgcpu;
       end;
       end;
 
 
 
 
-    procedure tcg64f386.a_op64_const_ref(list : taasmoutput;op:TOpCG;value : qword;const ref : treference);
+    procedure tcg64f386.a_op64_const_ref(list : taasmoutput;op:TOpCG;value : int64;const ref : treference);
       var
       var
         op1,op2 : TAsmOp;
         op1,op2 : TAsmOp;
         tempref : treference;
         tempref : treference;
@@ -389,9 +552,41 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.48  2004-04-09 14:36:05  peter
+  Revision 1.49  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.48  2004/04/09 14:36:05  peter
     * A_MOVSL renamed to A_MOVSD
     * A_MOVSL renamed to A_MOVSD
 
 
+  Revision 1.47.2.9  2004/05/30 10:45:50  peter
+    * merged fixes from main branch
+
+  Revision 1.47.2.8  2004/05/02 21:34:01  florian
+    * i386 compilation fixed
+
+  Revision 1.47.2.7  2004/05/02 12:45:32  peter
+    * enabled cpuhasfixedstack for x86-64 again
+    * fixed size of temp allocation for parameters
+
+  Revision 1.47.2.6  2004/05/01 16:02:10  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.47.2.5  2004/04/29 23:30:28  peter
+    * fix i386 compiler
+
+  Revision 1.47.2.4  2004/04/29 19:07:22  peter
+    * compile fixes
+
+  Revision 1.47.2.3  2004/04/24 20:13:24  florian
+    * fixed x86-64 exception handling
+
+  Revision 1.47.2.2  2004/04/24 18:30:11  florian
+    * extended parameters shouldn't be poped by the callee on x86-64 either
+
+  Revision 1.47.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
   Revision 1.47  2004/02/27 10:21:05  florian
   Revision 1.47  2004/02/27 10:21:05  florian
     * top_symbol killed
     * top_symbol killed
     + refaddr to treference added
     + refaddr to treference added

+ 9 - 1
compiler/i386/cpubase.inc

@@ -111,6 +111,8 @@
       {# Frame pointer register }
       {# Frame pointer register }
       RS_FRAME_POINTER_REG = RS_EBP;
       RS_FRAME_POINTER_REG = RS_EBP;
       NR_FRAME_POINTER_REG = NR_EBP;
       NR_FRAME_POINTER_REG = NR_EBP;
+      { Return address for DWARF }
+      NR_RETURN_ADDRESS_REG = NR_EIP;
       {# Register for addressing absolute data in a position independant way,
       {# Register for addressing absolute data in a position independant way,
          such as in PIC code. The exact meaning is ABI specific. For
          such as in PIC code. The exact meaning is ABI specific. For
          further information look at GCC source : PIC_OFFSET_TABLE_REGNUM
          further information look at GCC source : PIC_OFFSET_TABLE_REGNUM
@@ -167,7 +169,13 @@
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2004-02-05 18:28:37  peter
+  Revision 1.13  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.12.2.1  2004/04/20 16:35:58  peter
+    * generate dwarf for stackframe entry
+
+  Revision 1.12  2004/02/05 18:28:37  peter
     * x86_64 fixes for opsize
     * x86_64 fixes for opsize
 
 
   Revision 1.11  2004/01/14 23:39:05  florian
   Revision 1.11  2004/01/14 23:39:05  florian

+ 13 - 17
compiler/i386/cpuinfo.pas

@@ -1,6 +1,6 @@
 {
 {
     $Id$
     $Id$
-    Copyright (c) 1998-2002 by Florian Klaempfl
+    Copyright (c) 1998-2004 by Florian Klaempfl
 
 
     Basic Processor information
     Basic Processor information
 
 
@@ -30,18 +30,6 @@ Interface
     globtype;
     globtype;
 
 
 Type
 Type
-   { Natural integer register type and size for the target machine }
-   AWord = longword;
-   AInt = longint;
-   PAWord = ^AWord;
-
-   { This must be an ordinal type with the same size as a pointer
-     Note: Must be unsigned! Otherwise, ugly code like
-     pointer(-1) will result in a pointer with the value
-     $fffffffffffffff on a 32bit machine if the compiler uses
-     int64 constants internally (JM)                              }
-   TConstPtrUInt = longword;
-
    bestreal = extended;
    bestreal = extended;
    ts32real = single;
    ts32real = single;
    ts64real = double;
    ts64real = double;
@@ -73,8 +61,6 @@ Type
 Const
 Const
    {# Size of native extended floating point type }
    {# Size of native extended floating point type }
    extended_size = 10;
    extended_size = 10;
-   {# Size of a pointer                           }
-   pointer_size  = 4;
    {# Size of a multimedia register               }
    {# Size of a multimedia register               }
    mmreg_size = 8;
    mmreg_size = 8;
 
 
@@ -124,9 +110,19 @@ Implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.24  2004-04-28 15:19:03  florian
+  Revision 1.25  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.24  2004/04/28 15:19:03  florian
     + syscall directive support for MorphOS added
     + syscall directive support for MorphOS added
 
 
+  Revision 1.23.2.2  2004/05/01 16:02:10  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.23.2.1  2004/04/26 21:00:37  peter
+    * AInt fixed, PAInt added
+
   Revision 1.23  2004/02/27 10:21:05  florian
   Revision 1.23  2004/02/27 10:21:05  florian
     * top_symbol killed
     * top_symbol killed
     + refaddr to treference added
     + refaddr to treference added
@@ -227,4 +223,4 @@ end.
       with string operations
       with string operations
     * adapted some routines to use the new cg methods
     * adapted some routines to use the new cg methods
 
 
-}
+}

+ 45 - 28
compiler/i386/cpupara.pas

@@ -207,14 +207,14 @@ unit cpupara;
                begin
                begin
                  result.loc:=LOC_REFERENCE;
                  result.loc:=LOC_REFERENCE;
                  result.reference.index:=NR_STACK_POINTER_REG;
                  result.reference.index:=NR_STACK_POINTER_REG;
-                 result.reference.offset:=POINTER_SIZE*nr;
+                 result.reference.offset:=sizeof(aint)*nr;
                end;
                end;
            end
            end
          else
          else
            begin
            begin
              result.loc:=LOC_REFERENCE;
              result.loc:=LOC_REFERENCE;
              result.reference.index:=NR_STACK_POINTER_REG;
              result.reference.index:=NR_STACK_POINTER_REG;
-             result.reference.offset:=POINTER_SIZE*nr;
+             result.reference.offset:=sizeof(aint)*nr;
            end;
            end;
       end;
       end;
 
 
@@ -225,34 +225,37 @@ unit cpupara;
       begin
       begin
         { Function return }
         { Function return }
         fillchar(paraloc,sizeof(tparalocation),0);
         fillchar(paraloc,sizeof(tparalocation),0);
-        paraloc.size:=def_cgsize(p.rettype.def);
-        paraloc.lochigh:=LOC_INVALID;
-        { Return in FPU register? }
-        if p.rettype.def.deftype=floatdef then
-          begin
-            paraloc.loc:=LOC_FPUREGISTER;
-            paraloc.register:=NR_FPU_RESULT_REG;
-          end
+        if (p.proctypeoption=potype_constructor) then
+          paraloc.size:=OS_ADDR
         else
         else
-         { Return in register? }
-         if not ret_in_param(p.rettype.def,p.proccalloption) then
+          paraloc.size:=def_cgsize(p.rettype.def);
+        paraloc.lochigh:=LOC_INVALID;
+        if paraloc.size<>OS_NO then
           begin
           begin
-            paraloc.loc:=LOC_REGISTER;
-{$ifndef cpu64bit}
-            if paraloc.size in [OS_64,OS_S64] then
-             begin
-               paraloc.register64.reglo:=NR_FUNCTION_RETURN64_LOW_REG;
-               paraloc.register64.reghi:=NR_FUNCTION_RETURN64_HIGH_REG;
-             end
+            { Return in FPU register? }
+            if p.rettype.def.deftype=floatdef then
+              begin
+                paraloc.loc:=LOC_FPUREGISTER;
+                paraloc.register:=NR_FPU_RESULT_REG;
+              end
             else
             else
-{$endif cpu64bit}
-             begin
-               paraloc.register:=NR_FUNCTION_RETURN_REG;
-             end;
-          end
-        else
-          begin
-            paraloc.loc:=LOC_REFERENCE;
+             { Return in register? }
+             if not ret_in_param(p.rettype.def,p.proccalloption) then
+              begin
+                paraloc.loc:=LOC_REGISTER;
+                if paraloc.size in [OS_64,OS_S64] then
+                  begin
+                    paraloc.lochigh:=LOC_REGISTER;
+                    paraloc.register64.reglo:=NR_FUNCTION_RETURN64_LOW_REG;
+                    paraloc.register64.reghi:=NR_FUNCTION_RETURN64_HIGH_REG;
+                  end
+                else
+                  paraloc.register:=newreg(R_INTREGISTER,RS_FUNCTION_RETURN_REG,cgsize2subreg(paraloc.size));
+              end
+            else
+              begin
+                paraloc.loc:=LOC_REFERENCE;
+              end;
           end;
           end;
         p.funcret_paraloc[side]:=paraloc;
         p.funcret_paraloc[side]:=paraloc;
       end;
       end;
@@ -494,7 +497,21 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.50  2004-02-09 22:14:17  peter
+  Revision 1.51  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.50.2.3  2004/05/02 21:37:35  florian
+    * setting of func. ret. for i386 fixed
+
+  Revision 1.50.2.2  2004/05/02 12:45:32  peter
+    * enabled cpuhasfixedstack for x86-64 again
+    * fixed size of temp allocation for parameters
+
+  Revision 1.50.2.1  2004/05/01 16:02:10  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.50  2004/02/09 22:14:17  peter
     * more x86_64 parameter fixes
     * more x86_64 parameter fixes
     * tparalocation.lochigh is now used to indicate if registerhigh
     * tparalocation.lochigh is now used to indicate if registerhigh
       is used and what the type is
       is used and what the type is

+ 13 - 3
compiler/i386/csopt386.pas

@@ -1386,7 +1386,7 @@ begin
 end;
 end;
 
 
 
 
-function FindRegWithConst(p: tai; size: topsize; l: aword; var Res: TRegister): Boolean;
+function FindRegWithConst(p: tai; size: topsize; l: aint; var Res: TRegister): Boolean;
 {Finds a register which contains the constant l}
 {Finds a register which contains the constant l}
 var
 var
   Counter: tsuperregister;
   Counter: tsuperregister;
@@ -2115,7 +2115,17 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.61  2004-02-27 10:21:05  florian
+  Revision 1.62  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.61.2.2  2004/05/01 16:02:10  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.61.2.1  2004/04/29 23:30:28  peter
+    * fix i386 compiler
+
+  Revision 1.61  2004/02/27 10:21:05  florian
     * top_symbol killed
     * top_symbol killed
     + refaddr to treference added
     + refaddr to treference added
     + refsymbol to treference added
     + refsymbol to treference added
@@ -2261,7 +2271,7 @@ end.
     * fixed default stacksize of linux and go32v2, 8kb was a bit small :-)
     * fixed default stacksize of linux and go32v2, 8kb was a bit small :-)
 
 
   Revision 1.29  2002/04/15 19:12:09  carl
   Revision 1.29  2002/04/15 19:12:09  carl
-  + target_info.size_of_pointer -> pointer_size
+  + target_info.size_of_pointer -> sizeof(aint)
   + some cleanup of unused types/variables
   + some cleanup of unused types/variables
   * move several constants from cpubase to their specific units
   * move several constants from cpubase to their specific units
     (where they are used)
     (where they are used)

+ 9 - 3
compiler/i386/n386add.pas

@@ -425,9 +425,9 @@ interface
                end;
                end;
              LOC_CONSTANT :
              LOC_CONSTANT :
                begin
                begin
-                 exprasmlist.concat(taicpu.op_const_reg(A_CMP,S_L,aword(hi(right.location.valueqword)),left.location.registerhigh));
+                 exprasmlist.concat(taicpu.op_const_reg(A_CMP,S_L,aint(hi(right.location.value64)),left.location.registerhigh));
                  firstjmp64bitcmp;
                  firstjmp64bitcmp;
-                 exprasmlist.concat(taicpu.op_const_reg(A_CMP,S_L,aword(lo(right.location.valueqword)),left.location.registerlow));
+                 exprasmlist.concat(taicpu.op_const_reg(A_CMP,S_L,aint(lo(right.location.value64)),left.location.registerlow));
                  secondjmp64bitcmp;
                  secondjmp64bitcmp;
                end;
                end;
              else
              else
@@ -687,9 +687,15 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.96  2004-05-19 23:30:18  peter
+  Revision 1.97  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.96  2004/05/19 23:30:18  peter
     * extra typecast to prevent range check
     * extra typecast to prevent range check
 
 
+  Revision 1.95.2.1  2004/04/29 19:07:22  peter
+    * compile fixes
+
   Revision 1.95  2004/02/04 19:22:27  peter
   Revision 1.95  2004/02/04 19:22:27  peter
   *** empty log message ***
   *** empty log message ***
 
 

+ 8 - 63
compiler/i386/n386cal.pas

@@ -34,7 +34,6 @@ interface
     type
     type
        ti386callnode = class(tcgcallnode)
        ti386callnode = class(tcgcallnode)
        protected
        protected
-          function  align_parasize:longint;override;
           procedure pop_parasize(pop_size:longint);override;
           procedure pop_parasize(pop_size:longint);override;
           procedure extra_interrupt_code;override;
           procedure extra_interrupt_code;override;
        end;
        end;
@@ -67,62 +66,6 @@ implementation
       end;
       end;
 
 
 
 
-    function ti386callnode.align_parasize:longint;
-      var
-         pop_size : longint;
-{$ifdef OPTALIGN}
-         pop_esp : boolean;
-         push_size : longint;
-{$endif OPTALIGN}
-         i : integer;
-      begin
-        pop_size:=0;
-        { This parasize aligned on 4 ? }
-        i:=pushedparasize and 3;
-        if i>0 then
-         inc(pop_size,4-i);
-        { insert the opcode and update pushedparasize }
-        { never push 4 or more !! }
-        pop_size:=pop_size mod 4;
-        if pop_size>0 then
-         begin
-           inc(pushedparasize,pop_size);
-           exprasmlist.concat(taicpu.op_const_reg(A_SUB,S_L,pop_size,NR_ESP));
-{$ifdef GDB}
-           if (cs_debuginfo in aktmoduleswitches) and
-              (exprasmList.first=exprasmList.last) then
-             exprasmList.concat(Tai_force_line.Create);
-{$endif GDB}
-         end;
-{$ifdef OPTALIGN}
-         if pop_allowed and (cs_align in aktglobalswitches) then
-           begin
-              pop_esp:=true;
-              push_size:=pushedparasize;
-              { !!!! here we have to take care of return type, self
-                and nested procedures
-              }
-              inc(push_size,12);
-              emit_reg_reg(A_MOV,S_L,rsp,R_EDI);
-              if (push_size mod 8)=0 then
-                emit_const_reg(A_AND,S_L,$fffffff8,rsp)
-              else
-                begin
-                   emit_const_reg(A_SUB,S_L,push_size,rsp);
-                   emit_const_reg(A_AND,S_L,$fffffff8,rsp);
-                   emit_const_reg(A_SUB,S_L,push_size,rsp);
-                end;
-              r.enum:=R_INTREGISTER;
-              r.number:=R_EDI;
-              emit_reg(A_PUSH,S_L,r);
-           end
-         else
-           pop_esp:=false;
-{$endif OPTALIGN}
-        align_parasize:=pop_size;
-      end;
-
-
     procedure ti386callnode.pop_parasize(pop_size:longint);
     procedure ti386callnode.pop_parasize(pop_size:longint);
       var
       var
         hreg : tregister;
         hreg : tregister;
@@ -151,11 +94,6 @@ implementation
         else
         else
           if pop_size<>0 then
           if pop_size<>0 then
             exprasmlist.concat(taicpu.op_const_reg(A_ADD,S_L,pop_size,NR_ESP));
             exprasmlist.concat(taicpu.op_const_reg(A_ADD,S_L,pop_size,NR_ESP));
-
-{$ifdef OPTALIGN}
-        if pop_esp then
-          emit_reg(A_POP,S_L,NR_ESP);
-{$endif OPTALIGN}
       end;
       end;
 
 
 
 
@@ -164,7 +102,14 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.99  2003-11-07 15:58:32  florian
+  Revision 1.100  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.99.2.1  2004/05/02 12:45:32  peter
+    * enabled cpuhasfixedstack for x86-64 again
+    * fixed size of temp allocation for parameters
+
+  Revision 1.99  2003/11/07 15:58:32  florian
     * Florian's culmutative nr. 1; contains:
     * Florian's culmutative nr. 1; contains:
       - invalid calling conventions for a certain cpu are rejected
       - invalid calling conventions for a certain cpu are rejected
       - arm softfloat calling conventions
       - arm softfloat calling conventions

+ 15 - 4
compiler/i386/n386mem.pas

@@ -27,6 +27,7 @@ unit n386mem;
 interface
 interface
 
 
     uses
     uses
+      globtype,
       cgbase,cpuinfo,cpubase,
       cgbase,cpuinfo,cpubase,
       node,nmem,ncgmem;
       node,nmem,ncgmem;
 
 
@@ -40,7 +41,7 @@ interface
        end;
        end;
 
 
        ti386vecnode = class(tcgvecnode)
        ti386vecnode = class(tcgvecnode)
-          procedure update_reference_reg_mul(reg:tregister;l:aword);override;
+          procedure update_reference_reg_mul(reg:tregister;l:aint);override;
           procedure pass_2;override;
           procedure pass_2;override;
        end;
        end;
 
 
@@ -87,7 +88,7 @@ implementation
                              TI386VECNODE
                              TI386VECNODE
 *****************************************************************************}
 *****************************************************************************}
 
 
-     procedure ti386vecnode.update_reference_reg_mul(reg:tregister;l:aword);
+     procedure ti386vecnode.update_reference_reg_mul(reg:tregister;l:aint);
        var
        var
          l2 : integer;
          l2 : integer;
          hreg : tregister;
          hreg : tregister;
@@ -144,7 +145,17 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.60  2004-02-27 10:21:05  florian
+  Revision 1.61  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.60.2.2  2004/05/01 16:02:10  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.60.2.1  2004/04/29 19:07:22  peter
+    * compile fixes
+
+  Revision 1.60  2004/02/27 10:21:05  florian
     * top_symbol killed
     * top_symbol killed
     + refaddr to treference added
     + refaddr to treference added
     + refsymbol to treference added
     + refsymbol to treference added
@@ -320,7 +331,7 @@ end.
     * moved arrayconstructnode secondpass to ncgld
     * moved arrayconstructnode secondpass to ncgld
 
 
   Revision 1.25  2002/04/15 19:12:09  carl
   Revision 1.25  2002/04/15 19:12:09  carl
-  + target_info.size_of_pointer -> pointer_size
+  + target_info.size_of_pointer -> sizeof(aint)
   + some cleanup of unused types/variables
   + some cleanup of unused types/variables
   * move several constants from cpubase to their specific units
   * move several constants from cpubase to their specific units
     (where they are used)
     (where they are used)

+ 14 - 3
compiler/i386/n386obj.pas

@@ -92,9 +92,9 @@ function getselfoffsetfromsp(procdef: tprocdef): longint;
 begin
 begin
   { framepointer is pushed for nested procs }
   { framepointer is pushed for nested procs }
   if procdef.parast.symtablelevel>normal_function_level then
   if procdef.parast.symtablelevel>normal_function_level then
-    getselfoffsetfromsp:=2*POINTER_SIZE
+    getselfoffsetfromsp:=2*sizeof(aint)
   else
   else
-    getselfoffsetfromsp:=POINTER_SIZE;
+    getselfoffsetfromsp:=sizeof(aint);
 end;
 end;
 
 
 
 
@@ -164,6 +164,7 @@ begin
   make_global:=false;
   make_global:=false;
   if (not current_module.is_unit) or
   if (not current_module.is_unit) or
      (cs_create_smart in aktmoduleswitches) or
      (cs_create_smart in aktmoduleswitches) or
+     (af_smartlink_sections in target_asm.flags) or
      (procdef.owner.defowner.owner.symtabletype=globalsymtable) then
      (procdef.owner.defowner.owner.symtabletype=globalsymtable) then
     make_global:=true;
     make_global:=true;
 
 
@@ -238,7 +239,17 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.32  2004-03-02 00:36:33  olle
+  Revision 1.33  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.32.2.2  2004/05/01 16:02:10  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.32.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
+  Revision 1.32  2004/03/02 00:36:33  olle
     * big transformation of Tai_[const_]Symbol.Create[data]name*
     * big transformation of Tai_[const_]Symbol.Create[data]name*
 
 
   Revision 1.31  2004/02/27 13:42:52  olle
   Revision 1.31  2004/02/27 13:42:52  olle

+ 39 - 19
compiler/i386/n386set.pas

@@ -27,13 +27,14 @@ unit n386set;
 interface
 interface
 
 
     uses
     uses
+      globtype,
       node,nset,pass_1,ncgset;
       node,nset,pass_1,ncgset;
 
 
     type
     type
       ti386casenode = class(tcgcasenode)
       ti386casenode = class(tcgcasenode)
-         procedure optimizevalues(var max_linear_list:longint;var max_dist:cardinal);override;
+         procedure optimizevalues(var max_linear_list:aint;var max_dist:aword);override;
          function  has_jumptable : boolean;override;
          function  has_jumptable : boolean;override;
-         procedure genjumptable(hp : pcaserecord;min_,max_ : longint);override;
+         procedure genjumptable(hp : pcaserecord;min_,max_ : aint);override;
          procedure genlinearlist(hp : pcaserecord);override;
          procedure genlinearlist(hp : pcaserecord);override;
       end;
       end;
 
 
@@ -41,7 +42,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      globtype,systems,
+      systems,
       verbose,globals,
       verbose,globals,
       symconst,symdef,defutil,
       symconst,symdef,defutil,
       aasmbase,aasmtai,aasmcpu,
       aasmbase,aasmtai,aasmcpu,
@@ -56,7 +57,7 @@ implementation
                             TI386CASENODE
                             TI386CASENODE
 *****************************************************************************}
 *****************************************************************************}
 
 
-    procedure ti386casenode.optimizevalues(var max_linear_list:longint;var max_dist:cardinal);
+    procedure ti386casenode.optimizevalues(var max_linear_list:aint;var max_dist:aword);
       begin
       begin
         { a jump table crashes the pipeline! }
         { a jump table crashes the pipeline! }
         if aktoptprocessor=Class386 then
         if aktoptprocessor=Class386 then
@@ -76,7 +77,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure ti386casenode.genjumptable(hp : pcaserecord;min_,max_ : longint);
+    procedure ti386casenode.genjumptable(hp : pcaserecord;min_,max_ : aint);
       var
       var
         table : tasmlabel;
         table : tasmlabel;
         last : TConstExprInt;
         last : TConstExprInt;
@@ -86,31 +87,32 @@ implementation
 
 
         procedure genitem(t : pcaserecord);
         procedure genitem(t : pcaserecord);
           var
           var
-            i : longint;
+            i : aint;
           begin
           begin
             if assigned(t^.less) then
             if assigned(t^.less) then
               genitem(t^.less);
               genitem(t^.less);
             { fill possible hole }
             { fill possible hole }
             for i:=last+1 to t^._low-1 do
             for i:=last+1 to t^._low-1 do
-              jumpSegment.concat(Tai_const_symbol.Create(elselabel));
+              jumpSegment.concat(Tai_const.Create_sym(elselabel));
             for i:=t^._low to t^._high do
             for i:=t^._low to t^._high do
-              jumpSegment.concat(Tai_const_symbol.Create(t^.statement));
+              jumpSegment.concat(Tai_const.Create_sym(t^.statement));
             last:=t^._high;
             last:=t^._high;
             if assigned(t^.greater) then
             if assigned(t^.greater) then
               genitem(t^.greater);
               genitem(t^.greater);
           end;
           end;
 
 
       begin
       begin
-        if (cs_create_smart in aktmoduleswitches) then
+        if (cs_create_smart in aktmoduleswitches) or
+           (af_smartlink_sections in target_asm.flags) then
           jumpsegment:=current_procinfo.aktlocaldata
           jumpsegment:=current_procinfo.aktlocaldata
         else
         else
           jumpsegment:=datasegment;
           jumpsegment:=datasegment;
         if not(jumptable_no_range) then
         if not(jumptable_no_range) then
           begin
           begin
              { case expr less than min_ => goto elselabel }
              { case expr less than min_ => goto elselabel }
-             cg.a_cmp_const_reg_label(exprasmlist,opsize,jmp_lt,aword(min_),hregister,elselabel);
+             cg.a_cmp_const_reg_label(exprasmlist,opsize,jmp_lt,aint(min_),hregister,elselabel);
              { case expr greater than max_ => goto elselabel }
              { case expr greater than max_ => goto elselabel }
-             cg.a_cmp_const_reg_label(exprasmlist,opsize,jmp_gt,aword(max_),hregister,elselabel);
+             cg.a_cmp_const_reg_label(exprasmlist,opsize,jmp_gt,aint(max_),hregister,elselabel);
           end;
           end;
         objectlibrary.getlabel(table);
         objectlibrary.getlabel(table);
         { make it a 32bit register }
         { make it a 32bit register }
@@ -118,7 +120,7 @@ implementation
         cg.a_load_reg_reg(exprasmlist,opsize,OS_INT,hregister,indexreg);
         cg.a_load_reg_reg(exprasmlist,opsize,OS_INT,hregister,indexreg);
         { create reference }
         { create reference }
         reference_reset_symbol(href,table,0);
         reference_reset_symbol(href,table,0);
-        href.offset:=(-longint(min_))*4;
+        href.offset:=(-aint(min_))*4;
         href.index:=indexreg;
         href.index:=indexreg;
         href.scalefactor:=4;
         href.scalefactor:=4;
         emit_ref(A_JMP,S_NO,href);
         emit_ref(A_JMP,S_NO,href);
@@ -145,7 +147,7 @@ implementation
              { need we to test the first value }
              { need we to test the first value }
              if first and (t^._low>get_min_value(left.resulttype.def)) then
              if first and (t^._low>get_min_value(left.resulttype.def)) then
                begin
                begin
-                 cg.a_cmp_const_reg_label(exprasmlist,opsize,jmp_lt,aword(t^._low),hregister,elselabel);
+                 cg.a_cmp_const_reg_label(exprasmlist,opsize,jmp_lt,aint(t^._low),hregister,elselabel);
                end;
                end;
              if t^._low=t^._high then
              if t^._low=t^._high then
                begin
                begin
@@ -153,7 +155,7 @@ implementation
                     cg.a_cmp_const_reg_label(exprasmlist, opsize, OC_EQ,0,hregister,t^.statement)
                     cg.a_cmp_const_reg_label(exprasmlist, opsize, OC_EQ,0,hregister,t^.statement)
                   else
                   else
                     begin
                     begin
-                      cg.a_op_const_reg(exprasmlist, OP_SUB, opsize, aword(t^._low-last), hregister);
+                      cg.a_op_const_reg(exprasmlist, OP_SUB, opsize, aint(t^._low-last), hregister);
                       cg.a_jmp_flags(exprasmlist,F_E,t^.statement);
                       cg.a_jmp_flags(exprasmlist,F_E,t^.statement);
                     end;
                     end;
                   last:=t^._low;
                   last:=t^._low;
@@ -168,7 +170,7 @@ implementation
                     begin
                     begin
                        { have we to ajust the first value ? }
                        { have we to ajust the first value ? }
                        if (t^._low>get_min_value(left.resulttype.def)) then
                        if (t^._low>get_min_value(left.resulttype.def)) then
-                         cg.a_op_const_reg(exprasmlist, OP_SUB, opsize, longint(t^._low), hregister);
+                         cg.a_op_const_reg(exprasmlist, OP_SUB, opsize, aint(t^._low), hregister);
                     end
                     end
                   else
                   else
                     begin
                     begin
@@ -176,7 +178,7 @@ implementation
                       { present label then the lower limit can be checked    }
                       { present label then the lower limit can be checked    }
                       { immediately. else check the range in between:       }
                       { immediately. else check the range in between:       }
 
 
-                      cg.a_op_const_reg(exprasmlist, OP_SUB, opsize, longint(t^._low-last), hregister);
+                      cg.a_op_const_reg(exprasmlist, OP_SUB, opsize, aint(t^._low-last), hregister);
                       { no jump necessary here if the new range starts at }
                       { no jump necessary here if the new range starts at }
                       { at the value following the previous one           }
                       { at the value following the previous one           }
                       if ((t^._low-last) <> 1) or
                       if ((t^._low-last) <> 1) or
@@ -185,7 +187,7 @@ implementation
                     end;
                     end;
                   {we need to use A_SUB, because A_DEC does not set the correct flags, therefor
                   {we need to use A_SUB, because A_DEC does not set the correct flags, therefor
                    using a_op_const_reg(OP_SUB) is not possible }
                    using a_op_const_reg(OP_SUB) is not possible }
-                  emit_const_reg(A_SUB,TCGSize2OpSize[opsize],longint(t^._high-t^._low),hregister);
+                  emit_const_reg(A_SUB,TCGSize2OpSize[opsize],aint(t^._high-t^._low),hregister);
                   cg.a_jmp_flags(exprasmlist,cond_le,t^.statement);
                   cg.a_jmp_flags(exprasmlist,cond_le,t^.statement);
                   last:=t^._high;
                   last:=t^._high;
                   lastrange:=true;
                   lastrange:=true;
@@ -224,9 +226,27 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.74  2004-05-22 23:34:28  peter
+  Revision 1.75  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.74  2004/05/22 23:34:28  peter
   tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
   tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
 
 
+  Revision 1.73.2.5  2004/05/02 20:54:41  peter
+    * compile fix
+
+  Revision 1.73.2.4  2004/05/02 14:09:54  peter
+    * fix case 64bit issues
+
+  Revision 1.73.2.3  2004/04/29 23:30:28  peter
+    * fix i386 compiler
+
+  Revision 1.73.2.2  2004/04/12 14:45:11  peter
+    * tai_const_symbol and tai_const merged
+
+  Revision 1.73.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
   Revision 1.73  2004/02/27 10:21:05  florian
   Revision 1.73  2004/02/27 10:21:05  florian
     * top_symbol killed
     * top_symbol killed
     + refaddr to treference added
     + refaddr to treference added
@@ -506,4 +526,4 @@ end.
     - list field removed of the tnode class because it's not used currently
     - list field removed of the tnode class because it's not used currently
       and can cause hard-to-find bugs
       and can cause hard-to-find bugs
 
 
-}
+}

+ 10 - 4
compiler/i386/popt386.pas

@@ -343,7 +343,7 @@ begin
                         taicpu(hp1).opcode := A_AND;
                         taicpu(hp1).opcode := A_AND;
                         l := (1 shl (taicpu(hp1).oper[0]^.val)) - 1;
                         l := (1 shl (taicpu(hp1).oper[0]^.val)) - 1;
                         case taicpu(p).opsize Of
                         case taicpu(p).opsize Of
-                          S_L: taicpu(hp1).LoadConst(0,l Xor aword($ffffffff));
+                          S_L: taicpu(hp1).LoadConst(0,l Xor aint($ffffffff));
                           S_B: taicpu(hp1).LoadConst(0,l Xor $ff);
                           S_B: taicpu(hp1).LoadConst(0,l Xor $ff);
                           S_W: taicpu(hp1).LoadConst(0,l Xor $ffff);
                           S_W: taicpu(hp1).LoadConst(0,l Xor $ffff);
                         end;
                         end;
@@ -558,7 +558,7 @@ var
               (taicpu(hp1).oper[1]^.typ = top_reg) and
               (taicpu(hp1).oper[1]^.typ = top_reg) and
               (taicpu(hp1).oper[1]^.reg = taicpu(p).oper[1]^.reg) then
               (taicpu(hp1).oper[1]^.reg = taicpu(p).oper[1]^.reg) then
              begin
              begin
-               taicpu(p).LoadConst(0,AWord(int64(taicpu(p).oper[0]^.val)-int64(taicpu(hp1).oper[0]^.val)));
+               taicpu(p).LoadConst(0,taicpu(p).oper[0]^.val-taicpu(hp1).oper[0]^.val);
                asml.remove(hp1);
                asml.remove(hp1);
                hp1.free;
                hp1.free;
                if (taicpu(p).oper[0]^.val = 0) then
                if (taicpu(p).oper[0]^.val = 0) then
@@ -877,7 +877,7 @@ begin
                                 else
                                 else
                                   begin
                                   begin
                                     taicpu(p).opcode := A_ADD;
                                     taicpu(p).opcode := A_ADD;
-                                    taicpu(p).loadconst(0,aword(l));
+                                    taicpu(p).loadconst(0,l);
                                   end;
                                   end;
                               end;
                               end;
                     end;
                     end;
@@ -2002,7 +2002,13 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.59  2004-03-14 18:42:32  jonas
+  Revision 1.60  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.59.2.1  2004/04/29 23:30:28  peter
+    * fix i386 compiler
+
+  Revision 1.59  2004/03/14 18:42:32  jonas
     * fixed refaddr bug that caused go32v2 cycle failure
     * fixed refaddr bug that caused go32v2 cycle failure
 
 
   Revision 1.58  2004/02/28 16:59:02  jonas
   Revision 1.58  2004/02/28 16:59:02  jonas

+ 13 - 12
compiler/i386/r386ari.inc

@@ -8,22 +8,22 @@
 15,
 15,
 6,
 6,
 5,
 5,
-37,
 38,
 38,
 39,
 39,
 40,
 40,
-25,
+41,
+26,
 7,
 7,
 10,
 10,
 19,
 19,
 9,
 9,
-31,
 32,
 32,
 33,
 33,
 34,
 34,
 35,
 35,
 36,
 36,
-26,
+37,
+27,
 11,
 11,
 4,
 4,
 22,
 22,
@@ -31,12 +31,11 @@
 8,
 8,
 20,
 20,
 12,
 12,
-27,
+28,
 18,
 18,
 24,
 24,
-29,
 30,
 30,
-55,
+31,
 56,
 56,
 57,
 57,
 58,
 58,
@@ -44,11 +43,11 @@
 60,
 60,
 61,
 61,
 62,
 62,
+63,
 17,
 17,
 23,
 23,
-28,
-54,
-46,
+29,
+55,
 47,
 47,
 48,
 48,
 49,
 49,
@@ -56,12 +55,12 @@
 51,
 51,
 52,
 52,
 53,
 53,
-41,
+54,
 42,
 42,
 43,
 43,
 44,
 44,
 45,
 45,
-63,
+46,
 64,
 64,
 65,
 65,
 66,
 66,
@@ -69,4 +68,6 @@
 68,
 68,
 69,
 69,
 70,
 70,
+71,
+25,
 0
 0

+ 1 - 0
compiler/i386/r386att.inc

@@ -24,6 +24,7 @@
 '%ebp',
 '%ebp',
 '%sp',
 '%sp',
 '%esp',
 '%esp',
+'EIP',
 '%cs',
 '%cs',
 '%ds',
 '%ds',
 '%es',
 '%es',

+ 1 - 0
compiler/i386/r386con.inc

@@ -24,6 +24,7 @@ NR_BP = tregister($01030006);
 NR_EBP = tregister($01040006);
 NR_EBP = tregister($01040006);
 NR_SP = tregister($01030007);
 NR_SP = tregister($01030007);
 NR_ESP = tregister($01040007);
 NR_ESP = tregister($01040007);
+NR_EIP = tregister($05000000);
 NR_CS = tregister($05000001);
 NR_CS = tregister($05000001);
 NR_DS = tregister($05000002);
 NR_DS = tregister($05000002);
 NR_ES = tregister($05000003);
 NR_ES = tregister($05000003);

+ 73 - 0
compiler/i386/r386dwrf.inc

@@ -0,0 +1,73 @@
+{ don't edit, this file is generated from x86reg.dat }
+-1,
+0,
+0,
+0,
+0,
+1,
+1,
+1,
+1,
+2,
+2,
+2,
+2,
+3,
+3,
+3,
+3,
+6,
+6,
+7,
+7,
+5,
+5,
+4,
+4,
+8,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+-1,
+11,
+12,
+13,
+14,
+15,
+16,
+17,
+18,
+11,
+29,
+30,
+31,
+32,
+33,
+34,
+35,
+36,
+21,
+22,
+23,
+24,
+25,
+26,
+27,
+28

+ 1 - 0
compiler/i386/r386int.inc

@@ -24,6 +24,7 @@
 'ebp',
 'ebp',
 'sp',
 'sp',
 'esp',
 'esp',
+'EIP',
 'cs',
 'cs',
 'ds',
 'ds',
 'es',
 'es',

+ 14 - 13
compiler/i386/r386iri.inc

@@ -1,4 +1,5 @@
 { don't edit, this file is generated from x86reg.dat }
 { don't edit, this file is generated from x86reg.dat }
+25,
 0,
 0,
 2,
 2,
 1,
 1,
@@ -9,22 +10,22 @@
 15,
 15,
 6,
 6,
 5,
 5,
-37,
 38,
 38,
 39,
 39,
 40,
 40,
-25,
+41,
+26,
 7,
 7,
 10,
 10,
 19,
 19,
 9,
 9,
-31,
 32,
 32,
 33,
 33,
 34,
 34,
 35,
 35,
 36,
 36,
-26,
+37,
+27,
 11,
 11,
 4,
 4,
 22,
 22,
@@ -32,12 +33,11 @@
 8,
 8,
 20,
 20,
 12,
 12,
-27,
+28,
 18,
 18,
 24,
 24,
-29,
 30,
 30,
-55,
+31,
 56,
 56,
 57,
 57,
 58,
 58,
@@ -45,11 +45,11 @@
 60,
 60,
 61,
 61,
 62,
 62,
+63,
 17,
 17,
 23,
 23,
-28,
-54,
-46,
+29,
+55,
 47,
 47,
 48,
 48,
 49,
 49,
@@ -57,16 +57,17 @@
 51,
 51,
 52,
 52,
 53,
 53,
-41,
+54,
 42,
 42,
 43,
 43,
 44,
 44,
 45,
 45,
-63,
+46,
 64,
 64,
 65,
 65,
 66,
 66,
 67,
 67,
 68,
 68,
 69,
 69,
-70
+70,
+71

+ 1 - 0
compiler/i386/r386nasm.inc

@@ -24,6 +24,7 @@
 'ebp',
 'ebp',
 'sp',
 'sp',
 'esp',
 'esp',
+'EIP',
 'cs',
 'cs',
 'ds',
 'ds',
 'es',
 'es',

+ 1 - 1
compiler/i386/r386nor.inc

@@ -1,2 +1,2 @@
 { don't edit, this file is generated from x86reg.dat }
 { don't edit, this file is generated from x86reg.dat }
-71
+72

+ 14 - 13
compiler/i386/r386nri.inc

@@ -1,4 +1,5 @@
 { don't edit, this file is generated from x86reg.dat }
 { don't edit, this file is generated from x86reg.dat }
+25,
 0,
 0,
 2,
 2,
 1,
 1,
@@ -9,22 +10,22 @@
 15,
 15,
 6,
 6,
 5,
 5,
-37,
 38,
 38,
 39,
 39,
 40,
 40,
-25,
+41,
+26,
 7,
 7,
 10,
 10,
 19,
 19,
 9,
 9,
-31,
 32,
 32,
 33,
 33,
 34,
 34,
 35,
 35,
 36,
 36,
-26,
+37,
+27,
 11,
 11,
 4,
 4,
 22,
 22,
@@ -32,12 +33,11 @@
 8,
 8,
 20,
 20,
 12,
 12,
-27,
+28,
 18,
 18,
 24,
 24,
-29,
 30,
 30,
-55,
+31,
 56,
 56,
 57,
 57,
 58,
 58,
@@ -45,11 +45,11 @@
 60,
 60,
 61,
 61,
 62,
 62,
+63,
 17,
 17,
 23,
 23,
-28,
-54,
-46,
+29,
+55,
 47,
 47,
 48,
 48,
 49,
 49,
@@ -57,16 +57,17 @@
 51,
 51,
 52,
 52,
 53,
 53,
-41,
+54,
 42,
 42,
 43,
 43,
 44,
 44,
 45,
 45,
-63,
+46,
 64,
 64,
 65,
 65,
 66,
 66,
 67,
 67,
 68,
 68,
 69,
 69,
-70
+70,
+71

+ 1 - 0
compiler/i386/r386num.inc

@@ -24,6 +24,7 @@ tregister($01030006),
 tregister($01040006),
 tregister($01040006),
 tregister($01030007),
 tregister($01030007),
 tregister($01040007),
 tregister($01040007),
+tregister($05000000),
 tregister($05000001),
 tregister($05000001),
 tregister($05000002),
 tregister($05000002),
 tregister($05000003),
 tregister($05000003),

+ 1 - 0
compiler/i386/r386op.inc

@@ -24,6 +24,7 @@
 5,
 5,
 4,
 4,
 4,
 4,
+0,
 1,
 1,
 3,
 3,
 0,
 0,

+ 1 - 0
compiler/i386/r386ot.inc

@@ -24,6 +24,7 @@ OT_REG16,
 OT_REG32,
 OT_REG32,
 OT_REG16,
 OT_REG16,
 OT_REG32,
 OT_REG32,
+OT_NONE,
 OT_REG_CS,
 OT_REG_CS,
 OT_REG_DESS,
 OT_REG_DESS,
 OT_REG_DESS,
 OT_REG_DESS,

+ 3 - 2
compiler/i386/r386rni.inc

@@ -24,7 +24,6 @@
 20,
 20,
 22,
 22,
 24,
 24,
-46,
 47,
 47,
 48,
 48,
 49,
 49,
@@ -49,6 +48,7 @@
 68,
 68,
 69,
 69,
 70,
 70,
+71,
 25,
 25,
 26,
 26,
 27,
 27,
@@ -69,4 +69,5 @@
 42,
 42,
 43,
 43,
 44,
 44,
-45
+45,
+46

+ 14 - 13
compiler/i386/r386sri.inc

@@ -1,4 +1,5 @@
 { don't edit, this file is generated from x86reg.dat }
 { don't edit, this file is generated from x86reg.dat }
+25,
 0,
 0,
 2,
 2,
 1,
 1,
@@ -9,22 +10,22 @@
 15,
 15,
 6,
 6,
 5,
 5,
-37,
 38,
 38,
 39,
 39,
 40,
 40,
-25,
+41,
+26,
 7,
 7,
 10,
 10,
 19,
 19,
 9,
 9,
-31,
 32,
 32,
 33,
 33,
 34,
 34,
 35,
 35,
 36,
 36,
-26,
+37,
+27,
 11,
 11,
 4,
 4,
 22,
 22,
@@ -32,12 +33,11 @@
 8,
 8,
 20,
 20,
 12,
 12,
-27,
+28,
 18,
 18,
 24,
 24,
-29,
 30,
 30,
-55,
+31,
 56,
 56,
 57,
 57,
 58,
 58,
@@ -45,11 +45,11 @@
 60,
 60,
 61,
 61,
 62,
 62,
+63,
 17,
 17,
 23,
 23,
-28,
-54,
-46,
+29,
+55,
 47,
 47,
 48,
 48,
 49,
 49,
@@ -57,16 +57,17 @@
 51,
 51,
 52,
 52,
 53,
 53,
-41,
+54,
 42,
 42,
 43,
 43,
 44,
 44,
 45,
 45,
-63,
+46,
 64,
 64,
 65,
 65,
 66,
 66,
 67,
 67,
 68,
 68,
 69,
 69,
-70
+70,
+71

+ 1 - 0
compiler/i386/r386stab.inc

@@ -45,6 +45,7 @@
 -1,
 -1,
 -1,
 -1,
 -1,
 -1,
+-1,
 12,
 12,
 13,
 13,
 14,
 14,

+ 1 - 0
compiler/i386/r386std.inc

@@ -24,6 +24,7 @@
 'ebp',
 'ebp',
 'sp',
 'sp',
 'esp',
 'esp',
+'EIP',
 'cs',
 'cs',
 'ds',
 'ds',
 'es',
 'es',

+ 44 - 33
compiler/i386/ra386int.pas

@@ -29,6 +29,7 @@ Unit Ra386int;
     uses
     uses
       cclasses,
       cclasses,
       cpubase,
       cpubase,
+      globtype,
       rasm,
       rasm,
       rax86;
       rax86;
 
 
@@ -60,15 +61,15 @@ Unit Ra386int;
          procedure GetToken;
          procedure GetToken;
          function consume(t : tasmtoken):boolean;
          function consume(t : tasmtoken):boolean;
          procedure RecoverConsume(allowcomma:boolean);
          procedure RecoverConsume(allowcomma:boolean);
-         procedure BuildRecordOffsetSize(const expr: string;var offset:longint;var size:longint);
-         procedure BuildConstSymbolExpression(needofs,isref:boolean;var value:longint;var asmsym:string);
-         function BuildConstExpression:longint;
-         function BuildRefConstExpression:longint;
+         procedure BuildRecordOffsetSize(const expr: string;var offset:aint;var size:aint);
+         procedure BuildConstSymbolExpression(needofs,isref:boolean;var value:aint;var asmsym:string);
+         function BuildConstExpression:aint;
+         function BuildRefConstExpression:aint;
          procedure BuildReference(oper : tx86operand);
          procedure BuildReference(oper : tx86operand);
          procedure BuildOperand(oper: tx86operand);
          procedure BuildOperand(oper: tx86operand);
          procedure BuildConstantOperand(oper: tx86operand);
          procedure BuildConstantOperand(oper: tx86operand);
          procedure BuildOpCode(instr : tx86instruction);
          procedure BuildOpCode(instr : tx86instruction);
-         procedure BuildConstant(maxvalue: longint);
+         procedure BuildConstant(constsize: longint);
        end;
        end;
 
 
 
 
@@ -78,7 +79,7 @@ Unit Ra386int;
        { common }
        { common }
        cutils,
        cutils,
        { global }
        { global }
-       globtype,globals,verbose,
+       globals,verbose,
        systems,
        systems,
        { aasm }
        { aasm }
        cpuinfo,aasmbase,aasmtai,aasmcpu,
        cpuinfo,aasmbase,aasmtai,aasmcpu,
@@ -686,7 +687,7 @@ Unit Ra386int;
     { This routine builds up a record offset after a AS_DOT
     { This routine builds up a record offset after a AS_DOT
       token is encountered.
       token is encountered.
       On entry actasmtoken should be equal to AS_DOT                     }
       On entry actasmtoken should be equal to AS_DOT                     }
-    Procedure ti386intreader.BuildRecordOffsetSize(const expr: string;var offset:longint;var size:longint);
+    Procedure ti386intreader.BuildRecordOffsetSize(const expr: string;var offset:aint;var size:aint);
       var
       var
         s : string;
         s : string;
       Begin
       Begin
@@ -709,10 +710,11 @@ Unit Ra386int;
       end;
       end;
 
 
 
 
-    Procedure ti386intreader.BuildConstSymbolExpression(needofs,isref:boolean;var value:longint;var asmsym:string);
+    Procedure ti386intreader.BuildConstSymbolExpression(needofs,isref:boolean;var value:aint;var asmsym:string);
       var
       var
         tempstr,expr,hs : string;
         tempstr,expr,hs : string;
-        parenlevel,l,k : longint;
+        parenlevel : longint;
+        l,k : aint;
         hasparen,
         hasparen,
         errorflag : boolean;
         errorflag : boolean;
         prevtok : tasmtoken;
         prevtok : tasmtoken;
@@ -997,9 +999,9 @@ Unit Ra386int;
       end;
       end;
 
 
 
 
-    Function ti386intreader.BuildConstExpression:longint;
+    Function ti386intreader.BuildConstExpression:aint;
       var
       var
-        l : longint;
+        l : aint;
         hs : string;
         hs : string;
       begin
       begin
         BuildConstSymbolExpression(false,false,l,hs);
         BuildConstSymbolExpression(false,false,l,hs);
@@ -1009,9 +1011,9 @@ Unit Ra386int;
       end;
       end;
 
 
 
 
-    Function ti386intreader.BuildRefConstExpression:longint;
+    Function ti386intreader.BuildRefConstExpression:aint;
       var
       var
-        l : longint;
+        l : aint;
         hs : string;
         hs : string;
       begin
       begin
         BuildConstSymbolExpression(false,true,l,hs);
         BuildConstSymbolExpression(false,true,l,hs);
@@ -1023,7 +1025,7 @@ Unit Ra386int;
 
 
     procedure ti386intreader.BuildReference(oper : tx86operand);
     procedure ti386intreader.BuildReference(oper : tx86operand);
       var
       var
-        k,l,scale : longint;
+        k,l,scale : aint;
         tempstr,hs : string;
         tempstr,hs : string;
         typesize : longint;
         typesize : longint;
         code : integer;
         code : integer;
@@ -1361,7 +1363,7 @@ Unit Ra386int;
 
 
     Procedure ti386intreader.BuildConstantOperand(oper: tx86operand);
     Procedure ti386intreader.BuildConstantOperand(oper: tx86operand);
       var
       var
-        l : longint;
+        l : aint;
         tempstr : string;
         tempstr : string;
       begin
       begin
         if not (oper.opr.typ in [OPR_NONE,OPR_CONSTANT]) then
         if not (oper.opr.typ in [OPR_NONE,OPR_CONSTANT]) then
@@ -1406,10 +1408,10 @@ Unit Ra386int;
         expr    : string;
         expr    : string;
         tempreg : tregister;
         tempreg : tregister;
         typesize,
         typesize,
-        l       : longint;
+        l       : aint;
         hl      : tasmlabel;
         hl      : tasmlabel;
         toffset,
         toffset,
-        tsize   : longint;
+        tsize   : aint;
       Begin
       Begin
         expr:='';
         expr:='';
         repeat
         repeat
@@ -1594,7 +1596,7 @@ Unit Ra386int;
                      Message(asmr_e_invalid_operand_type);
                      Message(asmr_e_invalid_operand_type);
                    oper.opr.typ:=OPR_REGISTER;
                    oper.opr.typ:=OPR_REGISTER;
                    oper.opr.reg:=tempreg;
                    oper.opr.reg:=tempreg;
-                   oper.SetSize(tcgsize2size[cg.reg_cgsize(oper.opr.reg)],true);
+                   oper.SetSize(tcgsize2size[reg_cgsize(oper.opr.reg)],true);
                  end;
                  end;
               end;
               end;
 
 
@@ -1779,23 +1781,19 @@ Unit Ra386int;
       end;
       end;
 
 
 
 
-    Procedure ti386intreader.BuildConstant(maxvalue: longint);
+    Procedure ti386intreader.BuildConstant(constsize: longint);
       var
       var
        strlength: byte;
        strlength: byte;
        asmsym,
        asmsym,
        expr: string;
        expr: string;
-       value : longint;
+       value : aint;
       Begin
       Begin
         strlength:=0; { assume it is a DB }
         strlength:=0; { assume it is a DB }
         Repeat
         Repeat
           Case actasmtoken of
           Case actasmtoken of
             AS_STRING:
             AS_STRING:
               Begin
               Begin
-                if maxvalue = $ffff then
-                  strlength:=2
-                else
-                  if maxvalue = longint($ffffffff) then
-                    strlength:=4;
+                strlength:=constsize;
                 { DD and DW cases }
                 { DD and DW cases }
                 if strlength <> 0 then
                 if strlength <> 0 then
                  Begin
                  Begin
@@ -1824,12 +1822,12 @@ Unit Ra386int;
                 BuildConstSymbolExpression(false,false,value,asmsym);
                 BuildConstSymbolExpression(false,false,value,asmsym);
                 if asmsym<>'' then
                 if asmsym<>'' then
                  begin
                  begin
-                   if maxvalue<>longint($ffffffff) then
+                   if constsize<>sizeof(aint) then
                      Message1(asmr_w_const32bit_for_address,asmsym);
                      Message1(asmr_w_const32bit_for_address,asmsym);
                    ConcatConstSymbol(curlist,asmsym,value)
                    ConcatConstSymbol(curlist,asmsym,value)
                  end
                  end
                 else
                 else
-                 ConcatConstant(curlist,value,maxvalue);
+                 ConcatConstant(curlist,value,constsize);
               end;
               end;
             AS_COMMA:
             AS_COMMA:
               Consume(AS_COMMA);
               Consume(AS_COMMA);
@@ -1891,7 +1889,7 @@ Unit Ra386int;
             Begin
             Begin
               inexpression:=true;
               inexpression:=true;
               Consume(AS_DW);
               Consume(AS_DW);
-              BuildConstant($ffff);
+              BuildConstant(2);
               inexpression:=false;
               inexpression:=false;
             end;
             end;
 
 
@@ -1899,7 +1897,7 @@ Unit Ra386int;
             Begin
             Begin
               inexpression:=true;
               inexpression:=true;
               Consume(AS_DB);
               Consume(AS_DB);
-              BuildConstant($ff);
+              BuildConstant(1);
               inexpression:=false;
               inexpression:=false;
             end;
             end;
 
 
@@ -1907,7 +1905,7 @@ Unit Ra386int;
             Begin
             Begin
               inexpression:=true;
               inexpression:=true;
               Consume(AS_DD);
               Consume(AS_DD);
-              BuildConstant(longint($ffffffff));
+              BuildConstant(4);
               inexpression:=false;
               inexpression:=false;
             end;
             end;
 
 
@@ -1970,10 +1968,23 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.72  2004-05-20 21:54:33  florian
+  Revision 1.73  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.72  2004/05/20 21:54:33  florian
     + <pointer> - <pointer> result is divided by the pointer element size now
     + <pointer> - <pointer> result is divided by the pointer element size now
       this is delphi compatible as well as resulting in the expected result for p1+(p2-p1)
       this is delphi compatible as well as resulting in the expected result for p1+(p2-p1)
 
 
+  Revision 1.71.2.3  2004/05/02 00:31:33  peter
+    * fixedi i386 compile
+
+  Revision 1.71.2.2  2004/05/01 23:36:47  peter
+    * assembler reader 64bit fixes
+
+  Revision 1.71.2.1  2004/05/01 16:02:10  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
   Revision 1.71  2004/03/02 17:32:12  florian
   Revision 1.71  2004/03/02 17:32:12  florian
     * make cycle fixed
     * make cycle fixed
     + pic support for darwin
     + pic support for darwin
@@ -2187,7 +2198,7 @@ end.
     * fixed default stacksize of linux and go32v2, 8kb was a bit small :-)
     * fixed default stacksize of linux and go32v2, 8kb was a bit small :-)
 
 
   Revision 1.23  2002/04/15 19:12:09  carl
   Revision 1.23  2002/04/15 19:12:09  carl
-  + target_info.size_of_pointer -> pointer_size
+  + target_info.size_of_pointer -> sizeof(aint)
   + some cleanup of unused types/variables
   + some cleanup of unused types/variables
   * move several constants from cpubase to their specific units
   * move several constants from cpubase to their specific units
     (where they are used)
     (where they are used)
@@ -2213,4 +2224,4 @@ end.
    * implicit result variable generation for assembler routines
    * implicit result variable generation for assembler routines
    * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
    * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
 
 
-}
+}

+ 9 - 2
compiler/ia64/cpubase.pas

@@ -112,7 +112,7 @@ Const
   HiGPReg = R_31;
   HiGPReg = R_31;
 
 
   { sizes }
   { sizes }
-  pointer_size  = 8;
+  sizeof(aint)  = 8;
   extended_size = 16;
   extended_size = 16;
 
 
   general_registers = [R_0..R_31];
   general_registers = [R_0..R_31];
@@ -283,7 +283,14 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2002-11-17 18:26:16  mazen
+  Revision 1.7  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.6.2.1  2004/05/01 16:02:10  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.6  2002/11/17 18:26:16  mazen
   * fixed a compilation bug accmulator-->accumulator, in definition of return_result_reg
   * fixed a compilation bug accmulator-->accumulator, in definition of return_result_reg
 
 
   Revision 1.5  2002/11/17 17:49:09  mazen
   Revision 1.5  2002/11/17 17:49:09  mazen

+ 72 - 4
compiler/m68k/agcpugas.pas

@@ -40,9 +40,71 @@ interface
       end;
       end;
 
 
     const
     const
-      gas_opsize2str : array[topsize] of string[2] =
-      ('','.b','.w','.l','.s','.d','.x',''
-      );
+      gas_op2str:op2strtable=
+    {  warning: CPU32 opcodes are not fully compatible with the MC68020. }
+       { 68000 only opcodes }
+       ('abcd',
+         'add','adda','addi','addq','addx','and','andi',
+         'asl','asr','bcc','bcs','beq','bge','bgt','bhi',
+         'ble','bls','blt','bmi','bne','bpl','bvc','bvs',
+         'bchg','bclr','bra','bset','bsr','btst','chk',
+         'clr','cmp','cmpa','cmpi','cmpm','dbcc','dbcs','dbeq','dbge',
+         'dbgt','dbhi','dble','dbls','dblt','dbmi','dbne','dbra',
+         'dbpl','dbt','dbvc','dbvs','dbf','divs','divu',
+         'eor','eori','exg','illegal','ext','jmp','jsr',
+         'lea','link','lsl','lsr','move','movea','movei','moveq',
+         'movem','movep','muls','mulu','nbcd','neg','negx',
+         'nop','not','or','ori','pea','rol','ror','roxl',
+         'roxr','rtr','rts','sbcd','scc','scs','seq','sge',
+         'sgt','shi','sle','sls','slt','smi','sne',
+         'spl','st','svc','svs','sf','sub','suba','subi','subq',
+         'subx','swap','tas','trap','trapv','tst','unlk',
+         'rte','reset','stop',
+         { mc68010 instructions }
+         'bkpt','movec','moves','rtd',
+         { mc68020 instructions }
+         'bfchg','bfclr','bfexts','bfextu','bfffo',
+         'bfins','bfset','bftst','callm','cas','cas2',
+         'chk2','cmp2','divsl','divul','extb','pack','rtm',
+         'trapcc','tracs','trapeq','trapf','trapge','trapgt',
+         'traphi','traple','trapls','traplt','trapmi','trapne',
+         'trappl','trapt','trapvc','trapvs','unpk',
+         { fpu processor instructions - directly supported only. }
+         { ieee aware and misc. condition codes not supported   }
+         'fabs','fadd',
+         'fbeq','fbne','fbngt','fbgt','fbge','fbnge',
+         'fblt','fbnlt','fble','fbgl','fbngl','fbgle','fbngle',
+         'fdbeq','fdbne','fdbgt','fdbngt','fdbge','fdbnge',
+         'fdblt','fdbnlt','fdble','fdbgl','fdbngl','fdbgle','fdbngle',
+         'fseq','fsne','fsgt','fsngt','fsge','fsnge',
+         'fslt','fsnlt','fsle','fsgl','fsngl','fsgle','fsngle',
+         'fcmp','fdiv','fmove','fmovem',
+         'fmul','fneg','fnop','fsqrt','fsub','fsgldiv',
+         'fsflmul','ftst',
+         'ftrapeq','ftrapne','ftrapgt','ftrapngt','ftrapge','ftrapnge',
+         'ftraplt','ftrapnlt','ftraple','ftrapgl','ftrapngl','ftrapgle','ftrapngle',
+         { protected instructions }
+         'cprestore','cpsave',
+         { fpu unit protected instructions                    }
+         { and 68030/68851 common mmu instructions            }
+         { (this may include 68040 mmu instructions)          }
+         'frestore','fsave','pflush','pflusha','pload','pmove','ptest',
+         { useful for assembly language output }
+         'label','none','db','s','b','fb');
+
+
+     gas_opsize2str : array[topsize] of string[2] =
+     ('','.b','.w','.l','.s','.d','.x',''
+     );
+
+     gas_reg2str : reg2strtable =
+      ('', '%d0','%d1','%d2','%d3','%d4','%d5','%d6','%d7',
+       '%a0','%a1','%a2','%a3','%a4','%a5','%a6','%sp',
+       '-(%sp)','(%sp)+',
+       '%ccr','%fp0','%fp1','%fp2','%fp3','%fp4','%fp5',
+       '%fp6','%fp7','%fpcr','%sr','%ssp','%dfc',
+       '%sfc','%vbr','%fpsr');
+
 
 
   implementation
   implementation
 
 
@@ -300,7 +362,10 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2004-05-01 23:29:01  florian
+  Revision 1.12  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.11  2004/05/01 23:29:01  florian
     * continued to fix m68k compiler compilation
     * continued to fix m68k compiler compilation
 
 
   Revision 1.10  2004/04/27 15:46:01  florian
   Revision 1.10  2004/04/27 15:46:01  florian
@@ -312,6 +377,9 @@ end.
   Revision 1.8  2004/04/25 21:26:16  florian
   Revision 1.8  2004/04/25 21:26:16  florian
     * some m68k stuff fixed
     * some m68k stuff fixed
 
 
+  Revision 1.7.2.1  2004/06/13 20:38:38  florian
+    * fixed floating point register spilling on sparc
+
   Revision 1.7  2003/02/19 22:00:16  daniel
   Revision 1.7  2003/02/19 22:00:16  daniel
     * Code generator converted to new register notation
     * Code generator converted to new register notation
     - Horribily outdated todo.txt removed
     - Horribily outdated todo.txt removed

+ 13 - 3
compiler/m68k/cpubase.pas

@@ -28,6 +28,10 @@ unit cpubase;
 
 
   interface
   interface
 
 
+  uses
+    globtype,
+    strings,cutils,cclasses,aasmbase,cpuinfo,cgbase;
+
     uses
     uses
       strings,cutils,cclasses,aasmbase,cpuinfo,cgbase;
       strings,cutils,cclasses,aasmbase,cpuinfo,cgbase;
 
 
@@ -244,12 +248,12 @@ unit cpubase;
             LOC_FLAGS : (resflags : tresflags);
             LOC_FLAGS : (resflags : tresflags);
             LOC_CONSTANT : (
             LOC_CONSTANT : (
               case longint of
               case longint of
-                1 : (value : AWord);
+                1 : (value : aint);
                 { can't do this, this layout depends on the host cpu. Use }
                 { can't do this, this layout depends on the host cpu. Use }
                 { lo(valueqword)/hi(valueqword) instead (JM)              }
                 { lo(valueqword)/hi(valueqword) instead (JM)              }
                 { 2 : (valuelow, valuehigh:AWord);                        }
                 { 2 : (valuelow, valuehigh:AWord);                        }
                 { overlay a complete 64 Bit value }
                 { overlay a complete 64 Bit value }
-                3 : (valueqword : qword);
+                3 : (value64 : qword);
               );
               );
             LOC_CREFERENCE,
             LOC_CREFERENCE,
             LOC_REFERENCE : (reference : treference);
             LOC_REFERENCE : (reference : treference);
@@ -514,7 +518,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.28  2004-05-06 22:01:54  florian
+  Revision 1.29  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.28  2004/05/06 22:01:54  florian
     * register numbers for address registers fixed
     * register numbers for address registers fixed
 
 
   Revision 1.27  2004/05/06 20:30:51  florian
   Revision 1.27  2004/05/06 20:30:51  florian
@@ -526,6 +533,9 @@ end.
   Revision 1.25  2004/04/18 21:13:59  florian
   Revision 1.25  2004/04/18 21:13:59  florian
     * more adaptions for m68k
     * more adaptions for m68k
 
 
+  Revision 1.24.2.1  2004/06/13 20:38:38  florian
+    * fixed floating point register spilling on sparc
+
   Revision 1.24  2004/01/30 12:17:18  florian
   Revision 1.24  2004/01/30 12:17:18  florian
     * fixed some m68k compilation problems
     * fixed some m68k compilation problems
 
 

+ 8 - 17
compiler/m68k/cpuinfo.pas

@@ -21,20 +21,6 @@ Interface
     globtype;
     globtype;
 
 
 Type
 Type
-   { Architecture word - Native unsigned type }
-   aword  = longword;
-   PAWord = ^AWord;
-   AInt = longint;
-
-   { this must be an ordinal type with the same size as a pointer }
-   { to allow some dirty type casts for example when using        }
-   { tconstsym.value                                              }
-   { Note: must be unsigned!! Otherwise, ugly code like           }
-   { pointer(-1) will result in a pointer with the value          }
-   { $fffffffffffffff on a 32bit machine if the compiler uses     }
-   { int64 constants internally (JM)                              }
-   TConstPtrUInt = longword;
-
    bestreal = real;
    bestreal = real;
    ts32real = single;
    ts32real = single;
    ts64real = double;
    ts64real = double;
@@ -62,8 +48,6 @@ Type
 Const
 Const
    {# Size of native extended floating point type }
    {# Size of native extended floating point type }
    extended_size = 8;
    extended_size = 8;
-   {# Size of a pointer                           }
-   pointer_size  = 4;
    {# Size of a multimedia register               }
    {# Size of a multimedia register               }
    mmreg_size = 16;
    mmreg_size = 16;
    { size of the buffer used for setjump/longjmp
    { size of the buffer used for setjump/longjmp
@@ -105,7 +89,10 @@ Implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.11  2004-05-01 23:29:01  florian
+  Revision 1.12  2004-06-16 20:07:10  florian
+    * dwarf branch merged
+
+  Revision 1.11  2004/05/01 23:29:01  florian
     * continued to fix m68k compiler compilation
     * continued to fix m68k compiler compilation
 
 
   Revision 1.10  2004/04/28 15:19:03  florian
   Revision 1.10  2004/04/28 15:19:03  florian
@@ -114,6 +101,10 @@ end.
   Revision 1.9  2004/04/18 21:13:59  florian
   Revision 1.9  2004/04/18 21:13:59  florian
     * more adaptions for m68k
     * more adaptions for m68k
 
 
+  Revision 1.8.2.1  2004/05/01 16:02:10  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
   Revision 1.8  2004/01/30 12:17:18  florian
   Revision 1.8  2004/01/30 12:17:18  florian
     * fixed some m68k compilation problems
     * fixed some m68k compilation problems
 
 

+ 45 - 42
compiler/msg/errore.msg

@@ -933,7 +933,7 @@ parser_e_goto_outside_proc=03201_E_Goto statements aren't allowed between differ
 %   procedure p1;
 %   procedure p1;
 %   label
 %   label
 %     l1;
 %     l1;
-%    
+%
 %     procedure p2;
 %     procedure p2;
 %     begin
 %     begin
 %       goto l1; // This goto ISN'T allowed
 %       goto l1; // This goto ISN'T allowed
@@ -946,6 +946,25 @@ parser_e_goto_outside_proc=03201_E_Goto statements aren't allowed between differ
 % ...
 % ...
 %
 %
 % \end{verbatim}
 % \end{verbatim}
+parser_e_too_complex_expr=03202_E_Expression too complicated - FPU stack overflow
+% Your expression is too long for the compiler. You should try dividing the
+% construct over multiple assignments.
+parser_e_illegal_expression=03203_E_Illegal expression
+% This can occur under many circumstances. Mostly when trying to evaluate
+% constant expressions.
+parser_e_invalid_integer=03204_E_Invalid integer expression
+% You made an expression which isn't an integer, and the compiler expects the
+% result to be an integer.
+parser_e_invalid_qualifier=03205_E_Illegal qualifier
+% One of the following is happening :
+% \begin{itemize}
+% \item You're trying to access a field of a variable that is not a record.
+% \item You're indexing a variable that is not an array.
+% \item You're dereferencing a variable that is not a pointer.
+% \end{itemize}
+parser_e_upper_lower_than_lower=03206_E_High range limit < low range limit
+% You are declaring a subrange, and the lower limit is higher than the high
+% limit of the range.
 % \end{description}
 % \end{description}
 #
 #
 # Type Checking
 # Type Checking
@@ -1157,6 +1176,24 @@ type_e_constant_expr_expected=04052_E_Constant Expression expected
 % The compiler expects an constant expression, but gets a variable expression.
 % The compiler expects an constant expression, but gets a variable expression.
 type_e_operator_not_supported_for_types=04053_E_Operation "$1" not supported types "$2" and "$3"
 type_e_operator_not_supported_for_types=04053_E_Operation "$1" not supported types "$2" and "$3"
 % The operation is not allowed for the supplied types
 % The operation is not allowed for the supplied types
+type_e_illegal_type_conversion=04054_E_Illegal type conversion: "$1" to "$2"
+% When doing a type-cast, you must take care that the sizes of the variable and
+% the destination type are the same.
+type_h_pointer_to_longint_conv_not_portable=04055_H_Conversion between ordinals and pointers is not portable
+% If you typecast a pointer to a longint (or vice-versa), this code will not compile
+% on a machine using 64-bit for pointer storage.
+type_w_pointer_to_longint_conv_not_portable=04056_W_Conversion between ordinals and pointers is not portable
+% If you typecast a pointer to a ordinal type of a different size (or vice-versa), this can
+% cause problems. This is a warning to help finding the 32bit specific code where cardinal/longint is used
+% to typecast pointers to ordinals. A solution is to use the ptrint/ptruint types instead.
+type_e_cant_choose_overload_function=04057_E_Can't determine which overloaded function to call
+% You're calling overloaded functions with a parameter that doesn't correspond
+% to any of the declared function parameter lists. e.g. when you have declared
+% a function with parameters \var{word} and \var{longint}, and then you call
+% it with a parameter which is of type \var{integer}.
+type_e_illegal_count_var=04058_E_Illegal counter variable
+% The type of a \var{for} loop variable must be an ordinal type.
+% Loop variables cannot be reals or strings.
 % \end{description}
 % \end{description}
 #
 #
 # Symtable
 # Symtable
@@ -1305,46 +1342,9 @@ sym_e_cant_create_unique_type=05056_E_Can't create unique type from this type
 % This section lists all messages that can be displayed if the code
 % This section lists all messages that can be displayed if the code
 % generator encounters an error condition.
 % generator encounters an error condition.
 % \begin{description}
 % \begin{description}
-cg_e_break_not_allowed=06000_E_BREAK not allowed
-% You're trying to use \var{break} outside a loop construction.
-cg_e_continue_not_allowed=06001_E_CONTINUE not allowed
-% You're trying to use \var{continue} outside a loop construction.
-cg_e_too_complex_expr=06002_E_Expression too complicated - FPU stack overflow
-% Your expression is too long for the compiler. You should try dividing the
-% construct over multiple assignments.
-cg_e_illegal_expression=06003_E_Illegal expression
-% This can occur under many circumstances. Mostly when trying to evaluate
-% constant expressions.
-cg_e_invalid_integer=06004_E_Invalid integer expression
-% You made an expression which isn't an integer, and the compiler expects the
-% result to be an integer.
-cg_e_invalid_qualifier=06005_E_Illegal qualifier
-% One of the following is happening :
-% \begin{itemize}
-% \item You're trying to access a field of a variable that is not a record.
-% \item You're indexing a variable that is not an array.
-% \item You're dereferencing a variable that is not a pointer.
-% \end{itemize}
-cg_e_upper_lower_than_lower=06006_E_High range limit < low range limit
-% You are declaring a subrange, and the lower limit is higher than the high
-% limit of the range.
-cg_e_illegal_count_var=06007_E_Illegal counter variable
-% The type of a \var{for} loop variable must be an ordinal type.
-% Loop variables cannot be reals or strings.
-cg_e_cant_choose_overload_function=06008_E_Can't determine which overloaded function to call
-% You're calling overloaded functions with a parameter that doesn't correspond
-% to any of the declared function parameter lists. e.g. when you have declared
-% a function with parameters \var{word} and \var{longint}, and then you call
-% it with a parameter which is of type \var{integer}.
 cg_e_parasize_too_big=06009_E_Parameter list size exceeds 65535 bytes
 cg_e_parasize_too_big=06009_E_Parameter list size exceeds 65535 bytes
 % The I386 processor limits the parameter list to 65535 bytes (the \var{RET}
 % The I386 processor limits the parameter list to 65535 bytes (the \var{RET}
 % instruction causes this)
 % instruction causes this)
-cg_e_illegal_type_conversion=06010_E_Illegal type conversion: "$1" to "$2"
-% When doing a type-cast, you must take care that the sizes of the variable and
-% the destination type are the same.
-cg_h_pointer_to_longint_conv_not_portable=06011_H_Conversion between ordinals and pointers are not portable
-% If you typecast a pointer to a longint (or vice-versa), this code will not compile
-% on a machine using 64-bit for pointer storage.
 cg_e_file_must_call_by_reference=06012_E_File types must be var parameters
 cg_e_file_must_call_by_reference=06012_E_File types must be var parameters
 % You cannot specify files as value parameters, i.e. they must always be
 % You cannot specify files as value parameters, i.e. they must always be
 % declared \var{var} parameters.
 % declared \var{var} parameters.
@@ -1358,10 +1358,6 @@ cg_e_cant_use_far_pointer_there=06013_E_The use of a far pointer isn't allowed t
 % ...
 % ...
 % p:=@mem[a000:000];
 % p:=@mem[a000:000];
 % \end{verbatim}
 % \end{verbatim}
-cg_e_var_must_be_reference=06014_E_illegal call by reference parameters
-% You are trying to pass a constant or an expression to a procedure that
-% requires a \var{var} parameter. Only variables can be passed as a \var{var}
-% parameter.
 cg_e_dont_call_exported_direct=06015_E_EXPORT declared functions can't be called
 cg_e_dont_call_exported_direct=06015_E_EXPORT declared functions can't be called
 % No longer in use.
 % No longer in use.
 cg_w_member_cd_call_from_method=06016_W_Possible illegal call of constructor or destructor
 cg_w_member_cd_call_from_method=06016_W_Possible illegal call of constructor or destructor
@@ -1446,6 +1442,10 @@ cg_w_localsize_too_big=06042_W_Local variable size exceed limit for certain cpu'
 cg_e_localsize_too_big=06043_E_Local variables size exceeds supported limit
 cg_e_localsize_too_big=06043_E_Local variables size exceeds supported limit
 % This indicates that you are declaring more than 32K of lcoal variables, which
 % This indicates that you are declaring more than 32K of lcoal variables, which
 % is not supported by this processor.
 % is not supported by this processor.
+cg_e_break_not_allowed=06044_E_BREAK not allowed
+% You're trying to use \var{break} outside a loop construction.
+cg_e_continue_not_allowed=06045_E_CONTINUE not allowed
+% You're trying to use \var{continue} outside a loop construction.
 # EndOfTeX
 # EndOfTeX
 
 
 #
 #
@@ -2141,6 +2141,8 @@ option_help_pages=11025_[
 *g2gh_use heap trace unit (for memory leak debugging)
 *g2gh_use heap trace unit (for memory leak debugging)
 *g2gl_use line info unit to show more info for backtraces
 *g2gl_use line info unit to show more info for backtraces
 *g2gc_generate checks for pointers
 *g2gc_generate checks for pointers
+*g2gv_generates programs tracable with valygrind
+*g2gw_generate dwarf debugging info
 **1i_information
 **1i_information
 **2iD_return compiler date
 **2iD_return compiler date
 **2iV_return compiler version
 **2iV_return compiler version
@@ -2201,6 +2203,7 @@ option_help_pages=11025_[
 *L2Xc_link with the c library
 *L2Xc_link with the c library
 **2Xs_strip all symbols from executable
 **2Xs_strip all symbols from executable
 **2XD_try to link dynamic          (defines FPC_LINK_DYNAMIC)
 **2XD_try to link dynamic          (defines FPC_LINK_DYNAMIC)
+**2XP<x>_prepend the binutils names with the prefix <x>
 **2XS_try to link static (default) (defines FPC_LINK_STATIC)
 **2XS_try to link static (default) (defines FPC_LINK_STATIC)
 **2XX_try to link smart            (defines FPC_LINK_SMART)
 **2XX_try to link smart            (defines FPC_LINK_SMART)
 **0*_Processor specific options:
 **0*_Processor specific options:

+ 14 - 14
compiler/msgidx.inc

@@ -260,6 +260,11 @@ const
   parser_e_illegal_explicit_paraloc=03199;
   parser_e_illegal_explicit_paraloc=03199;
   parser_e_32bitint_or_pointer_variable_expected=03200;
   parser_e_32bitint_or_pointer_variable_expected=03200;
   parser_e_goto_outside_proc=03201;
   parser_e_goto_outside_proc=03201;
+  parser_e_too_complex_expr=03202;
+  parser_e_illegal_expression=03203;
+  parser_e_invalid_integer=03204;
+  parser_e_invalid_qualifier=03205;
+  parser_e_upper_lower_than_lower=03206;
   type_e_mismatch=04000;
   type_e_mismatch=04000;
   type_e_incompatible_types=04001;
   type_e_incompatible_types=04001;
   type_e_not_equal_types=04002;
   type_e_not_equal_types=04002;
@@ -313,6 +318,11 @@ const
   type_e_operator_not_allowed=04051;
   type_e_operator_not_allowed=04051;
   type_e_constant_expr_expected=04052;
   type_e_constant_expr_expected=04052;
   type_e_operator_not_supported_for_types=04053;
   type_e_operator_not_supported_for_types=04053;
+  type_e_illegal_type_conversion=04054;
+  type_h_pointer_to_longint_conv_not_portable=04055;
+  type_w_pointer_to_longint_conv_not_portable=04056;
+  type_e_cant_choose_overload_function=04057;
+  type_e_illegal_count_var=04058;
   sym_e_id_not_found=05000;
   sym_e_id_not_found=05000;
   sym_f_internal_error_in_symtablestack=05001;
   sym_f_internal_error_in_symtablestack=05001;
   sym_e_duplicate_id=05002;
   sym_e_duplicate_id=05002;
@@ -356,21 +366,9 @@ const
   sym_w_non_portable_symbol=05044;
   sym_w_non_portable_symbol=05044;
   sym_w_non_implemented_symbol=05055;
   sym_w_non_implemented_symbol=05055;
   sym_e_cant_create_unique_type=05056;
   sym_e_cant_create_unique_type=05056;
-  cg_e_break_not_allowed=06000;
-  cg_e_continue_not_allowed=06001;
-  cg_e_too_complex_expr=06002;
-  cg_e_illegal_expression=06003;
-  cg_e_invalid_integer=06004;
-  cg_e_invalid_qualifier=06005;
-  cg_e_upper_lower_than_lower=06006;
-  cg_e_illegal_count_var=06007;
-  cg_e_cant_choose_overload_function=06008;
   cg_e_parasize_too_big=06009;
   cg_e_parasize_too_big=06009;
-  cg_e_illegal_type_conversion=06010;
-  cg_h_pointer_to_longint_conv_not_portable=06011;
   cg_e_file_must_call_by_reference=06012;
   cg_e_file_must_call_by_reference=06012;
   cg_e_cant_use_far_pointer_there=06013;
   cg_e_cant_use_far_pointer_there=06013;
-  cg_e_var_must_be_reference=06014;
   cg_e_dont_call_exported_direct=06015;
   cg_e_dont_call_exported_direct=06015;
   cg_w_member_cd_call_from_method=06016;
   cg_w_member_cd_call_from_method=06016;
   cg_n_inefficient_code=06017;
   cg_n_inefficient_code=06017;
@@ -389,6 +387,8 @@ const
   cg_w_parasize_too_big=06041;
   cg_w_parasize_too_big=06041;
   cg_w_localsize_too_big=06042;
   cg_w_localsize_too_big=06042;
   cg_e_localsize_too_big=06043;
   cg_e_localsize_too_big=06043;
+  cg_e_break_not_allowed=06044;
+  cg_e_continue_not_allowed=06045;
   asmr_d_start_reading=07000;
   asmr_d_start_reading=07000;
   asmr_d_finish_reading=07001;
   asmr_d_finish_reading=07001;
   asmr_e_none_label_contain_at=07002;
   asmr_e_none_label_contain_at=07002;
@@ -639,9 +639,9 @@ const
   option_info=11024;
   option_info=11024;
   option_help_pages=11025;
   option_help_pages=11025;
 
 
-  MsgTxtSize = 36547;
+  MsgTxtSize = 36707;
 
 
   MsgIdxMax : array[1..20] of longint=(
   MsgIdxMax : array[1..20] of longint=(
-    17,63,202,54,57,44,99,20,35,60,
+    17,63,207,59,57,46,99,20,35,60,
     40,1,1,1,1,1,1,1,1,1
     40,1,1,1,1,1,1,1,1,1
   );
   );

+ 188 - 185
compiler/msgtxt.inc

@@ -293,298 +293,298 @@ const msgtxt : array[0..000152,1..240] of char=(
   '03200_E_32 Bit Integer or Pointer Variable expected'#000+
   '03200_E_32 Bit Integer or Pointer Variable expected'#000+
   '03201_E_Goto statements aren'#039't allowed between different procedure'+
   '03201_E_Goto statements aren'#039't allowed between different procedure'+
   's'#000+
   's'#000+
+  '03202_E_Expression too complicated - FPU stack overflow'#000+
+  '03203_E_Illegal expression'#000+
+  '03','204_E_Invalid integer expression'#000+
+  '03205_E_Illegal qualifier'#000+
+  '03206_E_High range limit < low range limit'#000+
   '04000_E_Type mismatch'#000+
   '04000_E_Type mismatch'#000+
   '04001_E_Incompatible types: got "$1" expected "$2"'#000+
   '04001_E_Incompatible types: got "$1" expected "$2"'#000+
-  '04002_E_Type',' mismatch between "$1" and "$2"'#000+
-  '04003_E_Type identifier expected'#000+
+  '04002_E_Type mismatch between "$1" and "$2"'#000+
+  '04003_E_Type identifi','er expected'#000+
   '04004_E_Variable identifier expected'#000+
   '04004_E_Variable identifier expected'#000+
   '04005_E_Integer expression expected, but got "$1"'#000+
   '04005_E_Integer expression expected, but got "$1"'#000+
   '04006_E_Boolean expression expected, but got "$1"'#000+
   '04006_E_Boolean expression expected, but got "$1"'#000+
   '04007_E_Ordinal expression expected'#000+
   '04007_E_Ordinal expression expected'#000+
-  '04','008_E_pointer type expected, but got "$1"'#000+
-  '04009_E_class type expected, but got "$1"'#000+
+  '04008_E_pointer type expected, but got "$1"'#000+
+  '04009_E_cla','ss type expected, but got "$1"'#000+
   '04011_E_Can'#039't evaluate constant expression'#000+
   '04011_E_Can'#039't evaluate constant expression'#000+
   '04012_E_Set elements are not compatible'#000+
   '04012_E_Set elements are not compatible'#000+
   '04013_E_Operation not implemented for sets'#000+
   '04013_E_Operation not implemented for sets'#000+
-  '04014_W_Automatic type convers','ion from floating type to COMP which i'+
-  's an integer type'#000+
+  '04014_W_Automatic type conversion from floating type to COMP which is '+
+  'an integer ty','pe'#000+
   '04015_H_use DIV instead to get an integer result'#000+
   '04015_H_use DIV instead to get an integer result'#000+
   '04016_E_string types doesn'#039't match, because of $V+ mode'#000+
   '04016_E_string types doesn'#039't match, because of $V+ mode'#000+
   '04017_E_succ or pred on enums with assignments not possible'#000+
   '04017_E_succ or pred on enums with assignments not possible'#000+
-  '04018_E_Can'#039't read ','or write variables of this type'#000+
-  '04019_E_Can'#039't use readln or writeln on typed file'#000+
+  '04018_E_Can'#039't read or write variables of this type'#000+
+  '04019_E_Can'#039't use rea','dln or writeln on typed file'#000+
   '04020_E_Can'#039't use read or write on untyped file.'#000+
   '04020_E_Can'#039't use read or write on untyped file.'#000+
   '04021_E_Type conflict between set elements'#000+
   '04021_E_Type conflict between set elements'#000+
   '04022_W_lo/hi(dword/qword) returns the upper/lower word/dword'#000+
   '04022_W_lo/hi(dword/qword) returns the upper/lower word/dword'#000+
-  '0402','3_E_Integer or real expression expected'#000+
-  '04024_E_Wrong type "$1" in array constructor'#000+
+  '04023_E_Integer or real expression expected'#000+
+  '04024_E_Wrong',' type "$1" in array constructor'#000+
   '04025_E_Incompatible type for arg no. $1: Got "$2", expected "$3"'#000+
   '04025_E_Incompatible type for arg no. $1: Got "$2", expected "$3"'#000+
   '04026_E_Method (variable) and Procedure (variable) are not compatible'#000+
   '04026_E_Method (variable) and Procedure (variable) are not compatible'#000+
-  '04027_E_Illegal con','stant passed to internal math function'#000+
-  '04028_E_Can'#039't get the address of constants'#000+
+  '04027_E_Illegal constant passed to internal math function'#000+
+  '04028_E_Can'#039't ','get the address of constants'#000+
   '04029_E_Argument can'#039't be assigned to'#000+
   '04029_E_Argument can'#039't be assigned to'#000+
   '04030_E_Can'#039't assign local procedure/function to procedure variabl'+
   '04030_E_Can'#039't assign local procedure/function to procedure variabl'+
   'e'#000+
   'e'#000+
   '04031_E_Can'#039't assign values to an address'#000+
   '04031_E_Can'#039't assign values to an address'#000+
-  '04032_E_Ca','n'#039't assign values to const variable'#000+
-  '04033_E_Array type required'#000+
+  '04032_E_Can'#039't assign values to const variable'#000+
+  '04033_E_Array typ','e required'#000+
   '04034_E_interface type expected, but got "$1"'#000+
   '04034_E_interface type expected, but got "$1"'#000+
   '04035_W_Mixing signed expressions and longwords gives a 64bit result'#000+
   '04035_W_Mixing signed expressions and longwords gives a 64bit result'#000+
-  '04036_W_Mixing signed expressions and cardinals here may caus','e a ran'+
-  'ge check error'#000+
-  '04037_E_Typecast has different size ($1 -> $2) in assignment'#000+
+  '04036_W_Mixing signed expressions and cardinals here may cause a range'+
+  ' check error'#000+
+  '04037_E_Typecast has different ','size ($1 -> $2) in assignment'#000+
   '04038_E_enums with assignments can'#039't be used as array index'#000+
   '04038_E_enums with assignments can'#039't be used as array index'#000+
   '04039_E_Class or Object types "$1" and "$2" are not related'#000+
   '04039_E_Class or Object types "$1" and "$2" are not related'#000+
-  '04040_W_Class types "$1" and "$2" are',' not related'#000+
-  '04041_E_Class or interface type expected, but got "$1"'#000+
+  '04040_W_Class types "$1" and "$2" are not related'#000+
+  '04041_E_Class or interface type expected',', but got "$1"'#000+
   '04042_E_Type "$1" is not completely defined'#000+
   '04042_E_Type "$1" is not completely defined'#000+
   '04043_W_String literal has more characters than short string length'#000+
   '04043_W_String literal has more characters than short string length'#000+
   '04044_W_Comparison is always false due to range of values'#000+
   '04044_W_Comparison is always false due to range of values'#000+
-  '04','045_W_Comparison is always true due to range of values'#000+
+  '04045_W_Comparison is always true due to range of value','s'#000+
   '04046_W_Constructing a class "$1" with abstract methods'#000+
   '04046_W_Constructing a class "$1" with abstract methods'#000+
   '04047_H_The left operand of the IN operator should be byte sized'#000+
   '04047_H_The left operand of the IN operator should be byte sized'#000+
-  '04048_W_Type size mismatch, possible loss of data / range check ','erro'+
+  '04048_W_Type size mismatch, possible loss of data / range check error'#000+
+  '04049_H_Type size mismatch, possible loss of da','ta / range check erro'+
   'r'#000+
   'r'#000+
-  '04049_H_Type size mismatch, possible loss of data / range check error'#000+
   '04050_E_The address of an abstract method can'#039't be taken'#000+
   '04050_E_The address of an abstract method can'#039't be taken'#000+
   '04051_E_The operator is not applicable for the operand type'#000+
   '04051_E_The operator is not applicable for the operand type'#000+
   '04052_E_Constant Expression expected'#000+
   '04052_E_Constant Expression expected'#000+
-  '04053_E_Op','eration "$1" not supported types "$2" and "$3"'#000+
+  '04053_E_Operation "$1" not supported types "$2" and "$3"'#000+
+  '04054_','E_Illegal type conversion: "$1" to "$2"'#000+
+  '04055_H_Conversion between ordinals and pointers is not portable'#000+
+  '04056_W_Conversion between ordinals and pointers is not portable'#000+
+  '04057_E_Can'#039't determine which overloaded function to call'#000+
+  '04058_E_Ille','gal counter variable'#000+
   '05000_E_Identifier not found "$1"'#000+
   '05000_E_Identifier not found "$1"'#000+
   '05001_F_Internal Error in SymTableStack()'#000+
   '05001_F_Internal Error in SymTableStack()'#000+
   '05002_E_Duplicate identifier "$1"'#000+
   '05002_E_Duplicate identifier "$1"'#000+
   '05003_H_Identifier already defined in $1 at line $2'#000+
   '05003_H_Identifier already defined in $1 at line $2'#000+
-  '05004_E_Unknown identifier "$1"',#000+
-  '05005_E_Forward declaration not solved "$1"'#000+
+  '05004_E_Unknown identifier "$1"'#000+
+  '05005_E_Forward declarati','on not solved "$1"'#000+
   '05007_E_Error in type definition'#000+
   '05007_E_Error in type definition'#000+
   '05009_E_Forward type not resolved "$1"'#000+
   '05009_E_Forward type not resolved "$1"'#000+
   '05010_E_Only static variables can be used in static methods or outside'+
   '05010_E_Only static variables can be used in static methods or outside'+
   ' methods'#000+
   ' methods'#000+
   '05012_F_record or class type expected'#000+
   '05012_F_record or class type expected'#000+
-  '05013_','E_Instances of classes or objects with an abstract method are '+
+  '05013_E_Instances of classes or ','objects with an abstract method are '+
   'not allowed'#000+
   'not allowed'#000+
   '05014_W_Label not defined "$1"'#000+
   '05014_W_Label not defined "$1"'#000+
   '05015_E_Label used but not defined "$1"'#000+
   '05015_E_Label used but not defined "$1"'#000+
   '05016_E_Illegal label declaration'#000+
   '05016_E_Illegal label declaration'#000+
   '05017_E_GOTO and LABEL are not supported (use switch -Sg)'#000+
   '05017_E_GOTO and LABEL are not supported (use switch -Sg)'#000+
-  '050','18_E_Label not found'#000+
-  '05019_E_identifier isn'#039't a label'#000+
+  '05018_E_Label not found'#000+
+  '05019','_E_identifier isn'#039't a label'#000+
   '05020_E_label already defined'#000+
   '05020_E_label already defined'#000+
   '05021_E_illegal type declaration of set elements'#000+
   '05021_E_illegal type declaration of set elements'#000+
   '05022_E_Forward class definition not resolved "$1"'#000+
   '05022_E_Forward class definition not resolved "$1"'#000+
   '05023_H_Unit "$1" not used in $2'#000+
   '05023_H_Unit "$1" not used in $2'#000+
-  '05024_H_Parameter "$1" ','not used'#000+
-  '05025_N_Local variable "$1" not used'#000+
+  '05024_H_Parameter "$1" not used'#000+
+  '05025_N_Local var','iable "$1" not used'#000+
   '05026_H_Value parameter "$1" is assigned but never used'#000+
   '05026_H_Value parameter "$1" is assigned but never used'#000+
   '05027_N_Local variable "$1" is assigned but never used'#000+
   '05027_N_Local variable "$1" is assigned but never used'#000+
   '05028_H_Local $1 "$2" is not used'#000+
   '05028_H_Local $1 "$2" is not used'#000+
   '05029_N_Private field "$1.$2" is never used'#000+
   '05029_N_Private field "$1.$2" is never used'#000+
-  '05030','_N_Private field "$1.$2" is assigned but never used'#000+
+  '05030_N_Private field "$1.$2" i','s assigned but never used'#000+
   '05031_N_Private method "$1.$2" never used'#000+
   '05031_N_Private method "$1.$2" never used'#000+
   '05032_E_Set type expected'#000+
   '05032_E_Set type expected'#000+
   '05033_W_Function result does not seem to be set'#000+
   '05033_W_Function result does not seem to be set'#000+
   '05034_W_Type "$1" is not aligned correctly in current record for C'#000+
   '05034_W_Type "$1" is not aligned correctly in current record for C'#000+
-  '05035','_E_Unknown record field identifier "$1"'#000+
+  '05035_E_Unknown record field id','entifier "$1"'#000+
   '05036_W_Local variable "$1" does not seem to be initialized'#000+
   '05036_W_Local variable "$1" does not seem to be initialized'#000+
   '05037_W_Variable "$1" does not seem to be initialized'#000+
   '05037_W_Variable "$1" does not seem to be initialized'#000+
   '05038_E_identifier idents no member "$1"'#000+
   '05038_E_identifier idents no member "$1"'#000+
   '05039_H_Found declaration: $1'#000+
   '05039_H_Found declaration: $1'#000+
-  '05040_E_Data el','ement too large'#000+
-  '05042_E_No matching implementation for interface method "$1" found'#000+
+  '05040_E_Data element too large'#000+
+  '05042_E_No',' matching implementation for interface method "$1" found'#000+
   '05043_W_Symbol "$1" is deprecated'#000+
   '05043_W_Symbol "$1" is deprecated'#000+
   '05044_W_Symbol "$1" is not portable'#000+
   '05044_W_Symbol "$1" is not portable'#000+
   '05055_W_Symbol "$1" is not implemented'#000+
   '05055_W_Symbol "$1" is not implemented'#000+
-  '05056_E_Can'#039't create unique type from this type'#000,
-  '06000_E_BREAK not allowed'#000+
-  '06001_E_CONTINUE not allowed'#000+
-  '06002_E_Expression too complicated - FPU stack overflow'#000+
-  '06003_E_Illegal expression'#000+
-  '06004_E_Invalid integer expression'#000+
-  '06005_E_Illegal qualifier'#000+
-  '06006_E_High range limit < low range limi','t'#000+
-  '06007_E_Illegal counter variable'#000+
-  '06008_E_Can'#039't determine which overloaded function to call'#000+
-  '06009_E_Parameter list size exceeds 65535 bytes'#000+
-  '06010_E_Illegal type conversion: "$1" to "$2"'#000+
-  '06011_H_Conversion between ordinals and pointers are ','not portable'#000+
+  '05056_E_Can'#039't create unique type from this type'#000+
+  '06009_E_Parameter list siz','e exceeds 65535 bytes'#000+
   '06012_E_File types must be var parameters'#000+
   '06012_E_File types must be var parameters'#000+
   '06013_E_The use of a far pointer isn'#039't allowed there'#000+
   '06013_E_The use of a far pointer isn'#039't allowed there'#000+
-  '06014_E_illegal call by reference parameters'#000+
   '06015_E_EXPORT declared functions can'#039't be called'#000+
   '06015_E_EXPORT declared functions can'#039't be called'#000+
-  '06016_W_Possible illegal call of cons','tructor or destructor'#000+
-  '06017_N_Inefficient code'#000+
+  '06016_W_Possible illegal call of constructor or destructor'#000+
+  '06017_N_Ineffi','cient code'#000+
   '06018_W_unreachable code'#000+
   '06018_W_unreachable code'#000+
   '06020_E_Abstract methods can'#039't be called directly'#000+
   '06020_E_Abstract methods can'#039't be called directly'#000+
   '06027_DL_Register $1 weight $2 $3'#000+
   '06027_DL_Register $1 weight $2 $3'#000+
   '06029_DL_Stack frame is omitted'#000+
   '06029_DL_Stack frame is omitted'#000+
   '06031_E_Object or class methods can'#039't be inline.'#000+
   '06031_E_Object or class methods can'#039't be inline.'#000+
-  '060','32_E_Procvar calls cannot be inline.'#000+
+  '06032_E_Procvar calls cannot be inline.',#000+
   '06033_E_No code for inline procedure stored'#000+
   '06033_E_No code for inline procedure stored'#000+
   '06035_E_Element zero of an ansi/wide- or longstring can'#039't be acces'+
   '06035_E_Element zero of an ansi/wide- or longstring can'#039't be acces'+
   'sed, use (set)length instead'#000+
   'sed, use (set)length instead'#000+
-  '06037_E_Constructors or destructors can not be called inside a '#039,'w'+
-  'ith'#039' clause'#000+
-  '06038_E_Cannot call message handler methods directly'#000+
+  '06037_E_Constructors or destructors can not be called inside a '#039'wi'+
+  'th'#039' clause'#000+
+  '06038_E_Cannot call mes','sage handler methods directly'#000+
   '06039_E_Jump in or outside of an exception block'#000+
   '06039_E_Jump in or outside of an exception block'#000+
   '06040_E_Control flow statements aren'#039't allowed in a finally block'#000+
   '06040_E_Control flow statements aren'#039't allowed in a finally block'#000+
   '06041_W_Parameters size exceeds limit for certain cpu'#039's'#000+
   '06041_W_Parameters size exceeds limit for certain cpu'#039's'#000+
-  '060','42_W_Local variable size exceed limit for certain cpu'#039's'#000+
+  '06042_W_Local variable size exceed limi','t for certain cpu'#039's'#000+
   '06043_E_Local variables size exceeds supported limit'#000+
   '06043_E_Local variables size exceeds supported limit'#000+
+  '06044_E_BREAK not allowed'#000+
+  '06045_E_CONTINUE not allowed'#000+
   '07000_DL_Starting $1 styled assembler parsing'#000+
   '07000_DL_Starting $1 styled assembler parsing'#000+
   '07001_DL_Finished $1 styled assembler parsing'#000+
   '07001_DL_Finished $1 styled assembler parsing'#000+
-  '07002_E_Non-label pattern contains @'#000+
-  '07','004_E_Error building record offset'#000+
+  '07002_E_Non-label pa','ttern contains @'#000+
+  '07004_E_Error building record offset'#000+
   '07005_E_OFFSET used without identifier'#000+
   '07005_E_OFFSET used without identifier'#000+
   '07006_E_TYPE used without identifier'#000+
   '07006_E_TYPE used without identifier'#000+
   '07007_E_Cannot use local variable or parameters here'#000+
   '07007_E_Cannot use local variable or parameters here'#000+
   '07008_E_need to use OFFSET here'#000+
   '07008_E_need to use OFFSET here'#000+
-  '07009_E_need to use $ here'#000+
-  '07010_E_Cannot us','e multiple relocatable symbols'#000+
+  '07009_E_need to use $ her','e'#000+
+  '07010_E_Cannot use multiple relocatable symbols'#000+
   '07011_E_Relocatable symbol can only be added'#000+
   '07011_E_Relocatable symbol can only be added'#000+
   '07012_E_Invalid constant expression'#000+
   '07012_E_Invalid constant expression'#000+
   '07013_E_Relocatable symbol is not allowed'#000+
   '07013_E_Relocatable symbol is not allowed'#000+
   '07014_E_Invalid reference syntax'#000+
   '07014_E_Invalid reference syntax'#000+
-  '07015_E_You can not reach $1 from that code'#000+
-  '07016_E_L','ocal symbols/labels aren'#039't allowed as references'#000+
+  '07015_E_You can not reach $1 from ','that code'#000+
+  '07016_E_Local symbols/labels aren'#039't allowed as references'#000+
   '07017_E_Invalid base and index register usage'#000+
   '07017_E_Invalid base and index register usage'#000+
   '07018_W_Possible error in object field handling'#000+
   '07018_W_Possible error in object field handling'#000+
   '07019_E_Wrong scale factor specified'#000+
   '07019_E_Wrong scale factor specified'#000+
   '07020_E_Multiple index register usage'#000+
   '07020_E_Multiple index register usage'#000+
-  '07021_E_Invalid operan','d type'#000+
+  '070','21_E_Invalid operand type'#000+
   '07022_E_Invalid string as opcode operand: $1'#000+
   '07022_E_Invalid string as opcode operand: $1'#000+
   '07023_W_@CODE and @DATA not supported'#000+
   '07023_W_@CODE and @DATA not supported'#000+
   '07024_E_Null label references are not allowed'#000+
   '07024_E_Null label references are not allowed'#000+
   '07025_E_Divide by zero in asm evaluator'#000+
   '07025_E_Divide by zero in asm evaluator'#000+
   '07026_E_Illegal expression'#000+
   '07026_E_Illegal expression'#000+
-  '07027_E_escape sequence ignored: $1'#000+
-  '0','7028_E_Invalid symbol reference'#000+
+  '07027_E_escape seq','uence ignored: $1'#000+
+  '07028_E_Invalid symbol reference'#000+
   '07029_W_Fwait can cause emulation problems with emu387'#000+
   '07029_W_Fwait can cause emulation problems with emu387'#000+
   '07030_W_$1 without operand translated into $1P'#000+
   '07030_W_$1 without operand translated into $1P'#000+
   '07031_W_ENTER instruction is not supported by Linux kernel'#000+
   '07031_W_ENTER instruction is not supported by Linux kernel'#000+
-  '07032_W_Calling an overload function in assembl','er'#000+
+  '07032_W_Calling an overload ','function in assembler'#000+
   '07033_E_Unsupported symbol type for operand'#000+
   '07033_E_Unsupported symbol type for operand'#000+
   '07034_E_Constant value out of bounds'#000+
   '07034_E_Constant value out of bounds'#000+
   '07035_E_Error converting decimal $1'#000+
   '07035_E_Error converting decimal $1'#000+
   '07036_E_Error converting octal $1'#000+
   '07036_E_Error converting octal $1'#000+
   '07037_E_Error converting binary $1'#000+
   '07037_E_Error converting binary $1'#000+
-  '07038_E_Error converting hexadecimal $1'#000+
-  '07039_H_$1 ','translated to $2'#000+
+  '07038_E_Error converting hexadec','imal $1'#000+
+  '07039_H_$1 translated to $2'#000+
   '07040_W_$1 is associated to an overloaded function'#000+
   '07040_W_$1 is associated to an overloaded function'#000+
   '07041_E_Cannot use SELF outside a method'#000+
   '07041_E_Cannot use SELF outside a method'#000+
   '07042_E_Cannot use OLDEBP outside a nested procedure'#000+
   '07042_E_Cannot use OLDEBP outside a nested procedure'#000+
   '07043_W_Procedures can'#039't return any value in asm code'#000+
   '07043_W_Procedures can'#039't return any value in asm code'#000+
-  '07044_E_SEG not supporte','d'#000+
+  '07044','_E_SEG not supported'#000+
   '07045_E_Size suffix and destination or source size do not match'#000+
   '07045_E_Size suffix and destination or source size do not match'#000+
   '07046_W_Size suffix and destination or source size do not match'#000+
   '07046_W_Size suffix and destination or source size do not match'#000+
   '07047_E_Assembler syntax error'#000+
   '07047_E_Assembler syntax error'#000+
   '07048_E_Invalid combination of opcode and operands'#000+
   '07048_E_Invalid combination of opcode and operands'#000+
-  '07049_E_Assembler syntax err','or in operand'#000+
+  '07049_E_A','ssembler syntax error in operand'#000+
   '07050_E_Assembler syntax error in constant'#000+
   '07050_E_Assembler syntax error in constant'#000+
   '07051_E_Invalid String expression'#000+
   '07051_E_Invalid String expression'#000+
   '07052_W_constant with symbol $1 for address which is not on a pointer'#000+
   '07052_W_constant with symbol $1 for address which is not on a pointer'#000+
   '07053_E_Unrecognized opcode $1'#000+
   '07053_E_Unrecognized opcode $1'#000+
-  '07054_E_Invalid or missing opcode'#000+
-  '07055_E_Invali','d combination of prefix and opcode: $1'#000+
+  '07054_E_Invalid or missing op','code'#000+
+  '07055_E_Invalid combination of prefix and opcode: $1'#000+
   '07056_E_Invalid combination of override and opcode: $1'#000+
   '07056_E_Invalid combination of override and opcode: $1'#000+
   '07057_E_Too many operands on line'#000+
   '07057_E_Too many operands on line'#000+
   '07058_W_NEAR ignored'#000+
   '07058_W_NEAR ignored'#000+
   '07059_W_FAR ignored'#000+
   '07059_W_FAR ignored'#000+
   '07060_E_Duplicate local symbol $1'#000+
   '07060_E_Duplicate local symbol $1'#000+
-  '07061_E_Undefined local symbol $1'#000+
-  '070','62_E_Unknown label identifier $1'#000+
+  '07061_E_Undefined ','local symbol $1'#000+
+  '07062_E_Unknown label identifier $1'#000+
   '07063_E_Invalid register name'#000+
   '07063_E_Invalid register name'#000+
   '07064_E_Invalid floating point register name'#000+
   '07064_E_Invalid floating point register name'#000+
   '07066_W_Modulo not supported'#000+
   '07066_W_Modulo not supported'#000+
   '07067_E_Invalid floating point constant $1'#000+
   '07067_E_Invalid floating point constant $1'#000+
-  '07068_E_Invalid floating point expression'#000+
-  '07069_E_Wrong symb','ol type'#000+
+  '07068_E_Invalid floating point expression',#000+
+  '07069_E_Wrong symbol type'#000+
   '07070_E_Cannot index a local var or parameter with a register'#000+
   '07070_E_Cannot index a local var or parameter with a register'#000+
   '07071_E_Invalid segment override expression'#000+
   '07071_E_Invalid segment override expression'#000+
   '07072_W_Identifier $1 supposed external'#000+
   '07072_W_Identifier $1 supposed external'#000+
   '07073_E_Strings not allowed as constants'#000+
   '07073_E_Strings not allowed as constants'#000+
-  '07074_No type of variable specified'#000+
-  '07075_E_a','ssembler code not returned to text section'#000+
+  '07074_No type of variable ','specified'#000+
+  '07075_E_assembler code not returned to text section'#000+
   '07076_E_Not a directive or local symbol $1'#000+
   '07076_E_Not a directive or local symbol $1'#000+
   '07077_E_Using a defined name as a local label'#000+
   '07077_E_Using a defined name as a local label'#000+
   '07078_E_Dollar token is used without an identifier'#000+
   '07078_E_Dollar token is used without an identifier'#000+
-  '07079_W_32bit constant created for address'#000+
-  '07080_N_.align',' is target specific, use .balign or .p2align'#000+
+  '07079_W_32bit constant created for add','ress'#000+
+  '07080_N_.align is target specific, use .balign or .p2align'#000+
   '07081_E_Can'#039't access fields directly for parameters'#000+
   '07081_E_Can'#039't access fields directly for parameters'#000+
   '07082_E_Can'#039't access fields of objects/classes directly'#000+
   '07082_E_Can'#039't access fields of objects/classes directly'#000+
-  '07083_E_No size specified and unable to determine the size of the oper'+
-  'ands'#000+
-  '07084_E_Cann','ot use RESULT in this function'#000+
+  '07083_E_No size specified and unable to determine the size of the op','e'+
+  'rands'#000+
+  '07084_E_Cannot use RESULT in this function'#000+
   '07086_W_"$1" without operand translated into "$1 %st,%st(1)"'#000+
   '07086_W_"$1" without operand translated into "$1 %st,%st(1)"'#000+
   '07087_W_"$1 %st(n)" translated into "$1 %st,%st(n)"'#000+
   '07087_W_"$1 %st(n)" translated into "$1 %st,%st(n)"'#000+
   '07088_W_"$1 %st(n)" translated into "$1 %st(n),%st"'#000+
   '07088_W_"$1 %st(n)" translated into "$1 %st(n),%st"'#000+
-  '07089_E_Char < not allowed here'#000+
-  '07090_E_Char',' > not allowed here'#000+
+  '07089_E_Char < not allowe','d here'#000+
+  '07090_E_Char > not allowed here'#000+
   '07093_W_ALIGN not supported'#000+
   '07093_W_ALIGN not supported'#000+
   '07094_E_Inc and Dec cannot be together'#000+
   '07094_E_Inc and Dec cannot be together'#000+
   '07095_E_Invalid reglist for movem'#000+
   '07095_E_Invalid reglist for movem'#000+
   '07096_E_Reglist invalid for opcode'#000+
   '07096_E_Reglist invalid for opcode'#000+
   '07097_E_Higher cpu mode required ($1)'#000+
   '07097_E_Higher cpu mode required ($1)'#000+
-  '07098_W_No size specified and unable to determ','ine the size of the op'+
+  '07098_W_No size specified a','nd unable to determine the size of the op'+
   'erands, using DWORD as default'#000+
   'erands, using DWORD as default'#000+
   '08000_F_Too many assembler files'#000+
   '08000_F_Too many assembler files'#000+
   '08001_F_Selected assembler output not supported'#000+
   '08001_F_Selected assembler output not supported'#000+
   '08002_F_Comp not supported'#000+
   '08002_F_Comp not supported'#000+
   '08003_F_Direct not support for binary writers'#000+
   '08003_F_Direct not support for binary writers'#000+
-  '08004_E_Allocating of data is onl','y allowed in bss section'#000+
+  '08004_E_Alloca','ting of data is only allowed in bss section'#000+
   '08005_F_No binary writer selected'#000+
   '08005_F_No binary writer selected'#000+
   '08006_E_Asm: Opcode $1 not in table'#000+
   '08006_E_Asm: Opcode $1 not in table'#000+
   '08007_E_Asm: $1 invalid combination of opcode and operands'#000+
   '08007_E_Asm: $1 invalid combination of opcode and operands'#000+
   '08008_E_Asm: 16 Bit references not supported'#000+
   '08008_E_Asm: 16 Bit references not supported'#000+
-  '08009_E_Asm: Invalid effective address'#000+
-  '08','010_E_Asm: Immediate or reference expected'#000+
+  '08009_E_Asm: Invalid e','ffective address'#000+
+  '08010_E_Asm: Immediate or reference expected'#000+
   '08011_E_Asm: $1 value exceeds bounds $2'#000+
   '08011_E_Asm: $1 value exceeds bounds $2'#000+
   '08012_E_Asm: Short jump is out of range $1'#000+
   '08012_E_Asm: Short jump is out of range $1'#000+
   '08013_E_Asm: Undefined label $1'#000+
   '08013_E_Asm: Undefined label $1'#000+
   '08014_E_Asm: Comp type not supported for this target'#000+
   '08014_E_Asm: Comp type not supported for this target'#000+
-  '08015_E_Asm: Extended type no','t supported for this target'#000+
+  '08015_E_As','m: Extended type not supported for this target'#000+
   '08016_E_Asm: Duplicate label $1'#000+
   '08016_E_Asm: Duplicate label $1'#000+
   '08017_E_Asm: Redefined label $1'#000+
   '08017_E_Asm: Redefined label $1'#000+
   '08018_E_Asm: First defined here'#000+
   '08018_E_Asm: First defined here'#000+
   '08019_E_Asm: Invalid register $1'#000+
   '08019_E_Asm: Invalid register $1'#000+
   '09000_W_Source operating system redefined'#000+
   '09000_W_Source operating system redefined'#000+
-  '09001_I_Assembling (pipe) $1'#000+
-  '09002_E_Can'#039,'t create assember file: $1'#000+
+  '09001_I_Assembling (pi','pe) $1'#000+
+  '09002_E_Can'#039't create assember file: $1'#000+
   '09003_E_Can'#039't create object file: $1'#000+
   '09003_E_Can'#039't create object file: $1'#000+
   '09004_E_Can'#039't create archive file: $1'#000+
   '09004_E_Can'#039't create archive file: $1'#000+
   '09005_E_Assembler $1 not found, switching to external assembling'#000+
   '09005_E_Assembler $1 not found, switching to external assembling'#000+
   '09006_T_Using assembler: $1'#000+
   '09006_T_Using assembler: $1'#000+
-  '09007_E_Error while assembling exitcode $1'#000+
-  '09','008_E_Can'#039't call the assembler, error $1 switching to external'+
-  ' assembling'#000+
+  '09007_E_Error while assemb','ling exitcode $1'#000+
+  '09008_E_Can'#039't call the assembler, error $1 switching to external a'+
+  'ssembling'#000+
   '09009_I_Assembling $1'#000+
   '09009_I_Assembling $1'#000+
   '09010_I_Assembling with smartlinking $1'#000+
   '09010_I_Assembling with smartlinking $1'#000+
   '09011_W_Object $1 not found, Linking may fail !'#000+
   '09011_W_Object $1 not found, Linking may fail !'#000+
-  '09012_W_Library $1 not found, Linking may fail !'#000+
-  '09013_E','_Error while linking'#000+
+  '09012_W_Library $1 not found, Linking',' may fail !'#000+
+  '09013_E_Error while linking'#000+
   '09014_E_Can'#039't call the linker, switching to external linking'#000+
   '09014_E_Can'#039't call the linker, switching to external linking'#000+
   '09015_I_Linking $1'#000+
   '09015_I_Linking $1'#000+
   '09016_E_Util $1 not found, switching to external linking'#000+
   '09016_E_Util $1 not found, switching to external linking'#000+
   '09017_T_Using util $1'#000+
   '09017_T_Using util $1'#000+
-  '09018_E_Creation of Executables not supported'#000+
-  '09019_E_Creati','on of Dynamic/Shared Libraries not supported'#000+
+  '09018_E_Creation of Executables not suppo','rted'#000+
+  '09019_E_Creation of Dynamic/Shared Libraries not supported'#000+
   '09020_I_Closing script $1'#000+
   '09020_I_Closing script $1'#000+
   '09021_E_resource compiler not found, switching to external mode'#000+
   '09021_E_resource compiler not found, switching to external mode'#000+
   '09022_I_Compiling resource $1'#000+
   '09022_I_Compiling resource $1'#000+
-  '09023_T_unit $1 can'#039't be statically linked, switching to smart lin'+
-  'king'#000+
-  '0902','4_T_unit $1 can'#039't be smart linked, switching to static linki'+
-  'ng'#000+
+  '09023_T_unit $1 can'#039't be statically linked, switching to',' smart l'+
+  'inking'#000+
+  '09024_T_unit $1 can'#039't be smart linked, switching to static linking'+
+  #000+
   '09025_T_unit $1 can'#039't be shared linked, switching to static linkin'+
   '09025_T_unit $1 can'#039't be shared linked, switching to static linkin'+
   'g'#000+
   'g'#000+
   '09026_E_unit $1 can'#039't be smart or static linked'#000+
   '09026_E_unit $1 can'#039't be smart or static linked'#000+
-  '09027_E_unit $1 can'#039't be shared or static linked'#000+
-  '09028_F_Can'#039,'t post process executable $1'#000+
+  '09027_E_unit $1 can'#039't be shared or static ','linked'#000+
+  '09028_F_Can'#039't post process executable $1'#000+
   '09029_F_Can'#039't open executable $1'#000+
   '09029_F_Can'#039't open executable $1'#000+
   '09030_X_Size of Code: $1 bytes'#000+
   '09030_X_Size of Code: $1 bytes'#000+
   '09031_X_Size of initialized data: $1 bytes'#000+
   '09031_X_Size of initialized data: $1 bytes'#000+
   '09032_X_Size of uninitialized data: $1 bytes'#000+
   '09032_X_Size of uninitialized data: $1 bytes'#000+
   '09033_X_Stack space reserved: $1 bytes'#000+
   '09033_X_Stack space reserved: $1 bytes'#000+
-  '09034_X_Stack space ','commited: $1 bytes'#000+
+  '0','9034_X_Stack space commited: $1 bytes'#000+
   '10000_T_Unitsearch: $1'#000+
   '10000_T_Unitsearch: $1'#000+
   '10001_T_PPU Loading $1'#000+
   '10001_T_PPU Loading $1'#000+
   '10002_U_PPU Name: $1'#000+
   '10002_U_PPU Name: $1'#000+
@@ -592,105 +592,105 @@ const msgtxt : array[0..000152,1..240] of char=(
   '10004_U_PPU Crc: $1'#000+
   '10004_U_PPU Crc: $1'#000+
   '10005_U_PPU Time: $1'#000+
   '10005_U_PPU Time: $1'#000+
   '10006_U_PPU File too short'#000+
   '10006_U_PPU File too short'#000+
-  '10007_U_PPU Invalid Header (no PPU at the begin)'#000+
-  '10008_U_PPU Inv','alid Version $1'#000+
+  '10007_U_PPU Invalid Header (no PPU at the beg','in)'#000+
+  '10008_U_PPU Invalid Version $1'#000+
   '10009_U_PPU is compiled for another processor'#000+
   '10009_U_PPU is compiled for another processor'#000+
   '10010_U_PPU is compiled for an other target'#000+
   '10010_U_PPU is compiled for an other target'#000+
   '10011_U_PPU Source: $1'#000+
   '10011_U_PPU Source: $1'#000+
   '10012_U_Writing $1'#000+
   '10012_U_Writing $1'#000+
   '10013_F_Can'#039't Write PPU-File'#000+
   '10013_F_Can'#039't Write PPU-File'#000+
   '10014_F_Error reading PPU-File'#000+
   '10014_F_Error reading PPU-File'#000+
-  '10015_F_unexpected end of PPU-Fi','le'#000+
+  '10015_F_unexp','ected end of PPU-File'#000+
   '10016_F_Invalid PPU-File entry: $1'#000+
   '10016_F_Invalid PPU-File entry: $1'#000+
   '10017_F_PPU Dbx count problem'#000+
   '10017_F_PPU Dbx count problem'#000+
   '10018_E_Illegal unit name: $1'#000+
   '10018_E_Illegal unit name: $1'#000+
   '10019_F_Too much units'#000+
   '10019_F_Too much units'#000+
   '10020_F_Circular unit reference between $1 and $2'#000+
   '10020_F_Circular unit reference between $1 and $2'#000+
-  '10021_F_Can'#039't compile unit $1, no sources available'#000+
-  '10022_F_Can'#039't fin','d unit $1'#000+
+  '10021_F_Can'#039't compile unit $1, no sources availabl','e'#000+
+  '10022_F_Can'#039't find unit $1'#000+
   '10023_W_Unit $1 was not found but $2 exists'#000+
   '10023_W_Unit $1 was not found but $2 exists'#000+
   '10024_F_Unit $1 searched but $2 found'#000+
   '10024_F_Unit $1 searched but $2 found'#000+
   '10025_W_Compiling the system unit requires the -Us switch'#000+
   '10025_W_Compiling the system unit requires the -Us switch'#000+
   '10026_F_There were $1 errors compiling module, stopping'#000+
   '10026_F_There were $1 errors compiling module, stopping'#000+
-  '10027_U_Load from $1 ($2) unit $3'#000,
+  '10027_U_Load fr','om $1 ($2) unit $3'#000+
   '10028_U_Recompiling $1, checksum changed for $2'#000+
   '10028_U_Recompiling $1, checksum changed for $2'#000+
   '10029_U_Recompiling $1, source found only'#000+
   '10029_U_Recompiling $1, source found only'#000+
   '10030_U_Recompiling unit, static lib is older than ppufile'#000+
   '10030_U_Recompiling unit, static lib is older than ppufile'#000+
   '10031_U_Recompiling unit, shared lib is older than ppufile'#000+
   '10031_U_Recompiling unit, shared lib is older than ppufile'#000+
-  '10032_U_Recompiling unit, obj an','d asm are older than ppufile'#000+
+  '10032_U_Recom','piling unit, obj and asm are older than ppufile'#000+
   '10033_U_Recompiling unit, obj is older than asm'#000+
   '10033_U_Recompiling unit, obj is older than asm'#000+
   '10034_U_Parsing interface of $1'#000+
   '10034_U_Parsing interface of $1'#000+
   '10035_U_Parsing implementation of $1'#000+
   '10035_U_Parsing implementation of $1'#000+
   '10036_U_Second load for unit $1'#000+
   '10036_U_Second load for unit $1'#000+
   '10037_U_PPU Check file $1 time $2'#000+
   '10037_U_PPU Check file $1 time $2'#000+
-  '10038_H_Conditional $1 was n','ot set at startup in last compilation of'+
+  '10038_H_C','onditional $1 was not set at startup in last compilation of'+
   ' $2'#000+
   ' $2'#000+
   '10039_H_Conditional $1 was set at startup in last compilation of $2'#000+
   '10039_H_Conditional $1 was set at startup in last compilation of $2'#000+
   '10040_W_Can'#039't recompile unit $1, but found modifed include files'#000+
   '10040_W_Can'#039't recompile unit $1, but found modifed include files'#000+
-  '10041_H_File $1 is newer than Release PPU file $2'#000+
-  '10042_U_Using',' a unit which was not compiled with correct FPU mode'#000+
+  '10041_H_File $1 is newer than Release PPU fi','le $2'#000+
+  '10042_U_Using a unit which was not compiled with correct FPU mode'#000+
   '10043_U_Loading interface units from $1'#000+
   '10043_U_Loading interface units from $1'#000+
   '10044_U_Loading implementation units from $1'#000+
   '10044_U_Loading implementation units from $1'#000+
   '10045_U_Interface CRC changed for unit $1'#000+
   '10045_U_Interface CRC changed for unit $1'#000+
-  '10046_U_Implementation CRC changed for unit $1'#000+
-  '10047_U_Finis','hed compiling unit $1'#000+
+  '10046_U_Implementation CRC changed for un','it $1'#000+
+  '10047_U_Finished compiling unit $1'#000+
   '10048_U_Add dependency of $1 to $2'#000+
   '10048_U_Add dependency of $1 to $2'#000+
   '10049_U_No reload, is caller: $1'#000+
   '10049_U_No reload, is caller: $1'#000+
   '10050_U_No reload, already in second compile: $1'#000+
   '10050_U_No reload, already in second compile: $1'#000+
   '10051_U_Flag for reload: $1'#000+
   '10051_U_Flag for reload: $1'#000+
   '10052_U_Forced reloading'#000+
   '10052_U_Forced reloading'#000+
-  '10053_U_Previous state of $1: $2'#000+
-  '10054_U_Already',' compiling $1, setting second compile'#000+
+  '10053_U_Previous state of $1:',' $2'#000+
+  '10054_U_Already compiling $1, setting second compile'#000+
   '10055_U_Loading unit $1'#000+
   '10055_U_Loading unit $1'#000+
   '10056_U_Finished loading unit $1'#000+
   '10056_U_Finished loading unit $1'#000+
   '10057_U_Registering new unit $1'#000+
   '10057_U_Registering new unit $1'#000+
   '10058_U_Re-resolving unit $1'#000+
   '10058_U_Re-resolving unit $1'#000+
   '10059_U_Skipping re-resolving unit $1, still loading used units'#000+
   '10059_U_Skipping re-resolving unit $1, still loading used units'#000+
-  '11000_$1 [options] <','inputfile> [options]'#000+
+  '1','1000_$1 [options] <inputfile> [options]'#000+
   '11001_W_Only one source file supported'#000+
   '11001_W_Only one source file supported'#000+
   '11002_W_DEF file can be created only for OS/2'#000+
   '11002_W_DEF file can be created only for OS/2'#000+
   '11003_E_nested response files are not supported'#000+
   '11003_E_nested response files are not supported'#000+
   '11004_F_No source file name in command line'#000+
   '11004_F_No source file name in command line'#000+
-  '11005_N_No option inside $1 config file'#000+
-  '11','006_E_Illegal parameter: $1'#000+
+  '11005_N_No option insid','e $1 config file'#000+
+  '11006_E_Illegal parameter: $1'#000+
   '11007_H_-? writes help pages'#000+
   '11007_H_-? writes help pages'#000+
   '11008_F_Too many config files nested'#000+
   '11008_F_Too many config files nested'#000+
   '11009_F_Unable to open file $1'#000+
   '11009_F_Unable to open file $1'#000+
   '11010_D_Reading further options from $1'#000+
   '11010_D_Reading further options from $1'#000+
   '11011_W_Target is already set to: $1'#000+
   '11011_W_Target is already set to: $1'#000+
-  '11012_W_Shared libs not supported on D','OS platform, reverting to stat'+
+  '11012_W_Shared libs',' not supported on DOS platform, reverting to stat'+
   'ic'#000+
   'ic'#000+
   '11013_F_too many IF(N)DEFs'#000+
   '11013_F_too many IF(N)DEFs'#000+
   '11014_F_too many ENDIFs'#000+
   '11014_F_too many ENDIFs'#000+
   '11015_F_open conditional at the end of the file'#000+
   '11015_F_open conditional at the end of the file'#000+
   '11016_W_Debug information generation is not supported by this executab'+
   '11016_W_Debug information generation is not supported by this executab'+
   'le'#000+
   'le'#000+
-  '11017_H_Try recompiling with -dGDB'#000,
+  '11017_H_Try reco','mpiling with -dGDB'#000+
   '11018_E_You are using the obsolete switch $1'#000+
   '11018_E_You are using the obsolete switch $1'#000+
   '11019_E_You are using the obsolete switch $1, please use $2'#000+
   '11019_E_You are using the obsolete switch $1, please use $2'#000+
   '11020_N_Switching assembler to default source writing assembler'#000+
   '11020_N_Switching assembler to default source writing assembler'#000+
-  '11021_W_Assembler output selected "$1" is not compatible with "$2"'#000+
-  '1102','2_W_"$1" assembler use forced'#000+
+  '11021_W_Assembler output selected "$1" is not compat','ible with "$2"'#000+
+  '11022_W_"$1" assembler use forced'#000+
   '11026_T_Reading options from file $1'#000+
   '11026_T_Reading options from file $1'#000+
   '11027_T_Reading options from environment $1'#000+
   '11027_T_Reading options from environment $1'#000+
   '11028_D_Handling option "$1"'#000+
   '11028_D_Handling option "$1"'#000+
   '11029__*** press enter ***'#000+
   '11029__*** press enter ***'#000+
   '11030_H_Start of reading config file $1'#000+
   '11030_H_Start of reading config file $1'#000+
-  '11031_H_End of reading config fil','e $1'#000+
+  '11031_H_End of',' reading config file $1'#000+
   '11032_D_interpreting option "$1"'#000+
   '11032_D_interpreting option "$1"'#000+
   '11036_D_interpreting firstpass option "$1"'#000+
   '11036_D_interpreting firstpass option "$1"'#000+
   '11033_D_interpreting file option "$1"'#000+
   '11033_D_interpreting file option "$1"'#000+
   '11034_D_Reading config file "$1"'#000+
   '11034_D_Reading config file "$1"'#000+
   '11035_D_found source file name "$1"'#000+
   '11035_D_found source file name "$1"'#000+
   '11037_D_Defining symbol $1'#000+
   '11037_D_Defining symbol $1'#000+
-  '11038_D_Undefining symbol',' $1'#000+
+  '11038_','D_Undefining symbol $1'#000+
   '11039_E_Unknown code page'#000+
   '11039_E_Unknown code page'#000+
   '11023_Free Pascal Compiler version $FPCVER [$FPCDATE] for $FPCTARGET'#010+
   '11023_Free Pascal Compiler version $FPCVER [$FPCDATE] for $FPCTARGET'#010+
   'Copyright (c) 1993-2004 by Florian Klaempfl'#000+
   'Copyright (c) 1993-2004 by Florian Klaempfl'#000+
   '11024_Free Pascal Compiler version $FPCVER'#010+
   '11024_Free Pascal Compiler version $FPCVER'#010+
   #010+
   #010+
   'Compiler Date  : $FPCDATE'#010+
   'Compiler Date  : $FPCDATE'#010+
-  'Compiler Target: $FPCTARGET',#010+
+  'Compiler',' Target: $FPCTARGET'#010+
   #010+
   #010+
   'Supported targets:'#010+
   'Supported targets:'#010+
   '  $OSTARGETS'#010+
   '  $OSTARGETS'#010+
@@ -700,188 +700,191 @@ const msgtxt : array[0..000152,1..240] of char=(
   #010+
   #010+
   'Report bugs,suggestions etc to:'#010+
   'Report bugs,suggestions etc to:'#010+
   '                 [email protected]'#000+
   '                 [email protected]'#000+
-  '11025_**0*_put + after a boolean switch',' option to enable it, - to di'+
+  '11025_**0*_put + aft','er a boolean switch option to enable it, - to di'+
   'sable it'#010+
   'sable it'#010+
   '**1a_the compiler doesn'#039't delete the generated assembler file'#010+
   '**1a_the compiler doesn'#039't delete the generated assembler file'#010+
   '**2al_list sourcecode lines in assembler file'#010+
   '**2al_list sourcecode lines in assembler file'#010+
   '**2ar_list register allocation/release info in assembler file'#010+
   '**2ar_list register allocation/release info in assembler file'#010+
-  '**2at_list temp allocation/relea','se info in assembler file'#010+
+  '**2at_list te','mp allocation/release info in assembler file'#010+
   '**1b_generate browser info'#010+
   '**1b_generate browser info'#010+
   '**2bl_generate local symbol info'#010+
   '**2bl_generate local symbol info'#010+
   '**1B_build all modules'#010+
   '**1B_build all modules'#010+
   '**1C<x>_code generation options:'#010+
   '**1C<x>_code generation options:'#010+
   '**2CD_create also dynamic library (not supported)'#010+
   '**2CD_create also dynamic library (not supported)'#010+
-  '**2Ce_Compilation with emulated floating point o','pcodes'#010+
+  '**2Ce_Compilation with emulat','ed floating point opcodes'#010+
   '**2Cf_Select fpu instruction set to use'#010+
   '**2Cf_Select fpu instruction set to use'#010+
   '**2Cg_Generate PIC code'#010+
   '**2Cg_Generate PIC code'#010+
   '**2Ch<n>_<n> bytes heap (between 1023 and 67107840)'#010+
   '**2Ch<n>_<n> bytes heap (between 1023 and 67107840)'#010+
   '**2Ci_IO-checking'#010+
   '**2Ci_IO-checking'#010+
   '**2Cn_omit linking stage'#010+
   '**2Cn_omit linking stage'#010+
   '**2Co_check overflow of integer operations'#010+
   '**2Co_check overflow of integer operations'#010+
-  '**2Cr_range checking'#010+
-  '**2CR_veri','fy object method call validity'#010+
+  '**2Cr_range ','checking'#010+
+  '**2CR_verify object method call validity'#010+
   '**2Cs<n>_set stack size to <n>'#010+
   '**2Cs<n>_set stack size to <n>'#010+
   '**2Ct_stack checking'#010+
   '**2Ct_stack checking'#010+
   '**2CX_create also smartlinked library'#010+
   '**2CX_create also smartlinked library'#010+
   '**1d<x>_defines the symbol <x>'#010+
   '**1d<x>_defines the symbol <x>'#010+
   '*O1D_generate a DEF file'#010+
   '*O1D_generate a DEF file'#010+
   '*O2Dd<x>_set description to <x>'#010+
   '*O2Dd<x>_set description to <x>'#010+
-  '*O2Dw_PM application'#010+
-  '**1e<x>_se','t path to executable'#010+
+  '*O2Dw_PM app','lication'#010+
+  '**1e<x>_set path to executable'#010+
   '**1E_same as -Cn'#010+
   '**1E_same as -Cn'#010+
   '**1F<x>_set file names and paths:'#010+
   '**1F<x>_set file names and paths:'#010+
   '**2FD<x>_sets the directory where to search for compiler utilities'#010+
   '**2FD<x>_sets the directory where to search for compiler utilities'#010+
   '**2Fe<x>_redirect error output to <x>'#010+
   '**2Fe<x>_redirect error output to <x>'#010+
   '**2FE<x>_set exe/unit output path to <x>'#010+
   '**2FE<x>_set exe/unit output path to <x>'#010+
-  '**2Fi<x>_adds <x> to i','nclude path'#010+
+  '**2','Fi<x>_adds <x> to include path'#010+
   '**2Fl<x>_adds <x> to library path'#010+
   '**2Fl<x>_adds <x> to library path'#010+
   '*L2FL<x>_uses <x> as dynamic linker'#010+
   '*L2FL<x>_uses <x> as dynamic linker'#010+
   '**2Fo<x>_adds <x> to object path'#010+
   '**2Fo<x>_adds <x> to object path'#010+
   '**2Fr<x>_load error message file <x>'#010+
   '**2Fr<x>_load error message file <x>'#010+
   '**2Fu<x>_adds <x> to unit path'#010+
   '**2Fu<x>_adds <x> to unit path'#010+
-  '**2FU<x>_set unit output path to <x>, overrides -FE'#010+
-  '*g1g_','generate debugger information:'#010+
+  '**2FU<x>_set unit output path to <x>, ','overrides -FE'#010+
+  '*g1g_generate debugger information:'#010+
   '*g2gg_use gsym'#010+
   '*g2gg_use gsym'#010+
   '*g2gd_use dbx'#010+
   '*g2gd_use dbx'#010+
   '*g2gh_use heap trace unit (for memory leak debugging)'#010+
   '*g2gh_use heap trace unit (for memory leak debugging)'#010+
   '*g2gl_use line info unit to show more info for backtraces'#010+
   '*g2gl_use line info unit to show more info for backtraces'#010+
   '*g2gc_generate checks for pointers'#010+
   '*g2gc_generate checks for pointers'#010+
+  '*g2gv_generate','s programs tracable with valygrind'#010+
+  '*g2gw_generate dwarf debugging info'#010+
   '**1i_information'#010+
   '**1i_information'#010+
-  '**2iD_return com','piler date'#010+
+  '**2iD_return compiler date'#010+
   '**2iV_return compiler version'#010+
   '**2iV_return compiler version'#010+
   '**2iSO_return compiler OS'#010+
   '**2iSO_return compiler OS'#010+
   '**2iSP_return compiler processor'#010+
   '**2iSP_return compiler processor'#010+
   '**2iTO_return target OS'#010+
   '**2iTO_return target OS'#010+
-  '**2iTP_return target processor'#010+
+  '**2iTP_retur','n target processor'#010+
   '**1I<x>_adds <x> to include path'#010+
   '**1I<x>_adds <x> to include path'#010+
   '**1k<x>_Pass <x> to the linker'#010+
   '**1k<x>_Pass <x> to the linker'#010+
   '**1l_write logo'#010+
   '**1l_write logo'#010+
-  '**1M<','x>_set language mode to <x>'#010+
+  '**1M<x>_set language mode to <x>'#010+
   '**2Mfpc_free pascal dialect (default)'#010+
   '**2Mfpc_free pascal dialect (default)'#010+
   '**2Mobjfpc_switch some Delphi 2 extensions on'#010+
   '**2Mobjfpc_switch some Delphi 2 extensions on'#010+
-  '**2Mdelphi_tries to be Delphi compatible'#010+
+  '**2Mdelphi_tries to be D','elphi compatible'#010+
   '**2Mtp_tries to be TP/BP 7.0 compatible'#010+
   '**2Mtp_tries to be TP/BP 7.0 compatible'#010+
   '**2Mgpc_tries to be gpc compatible'#010+
   '**2Mgpc_tries to be gpc compatible'#010+
-  '**2Mmacpas_t','ries to be compatible to the macintosh pascal dialects'#010+
+  '**2Mmacpas_tries to be compatible to the macintosh pascal dialects'#010+
   '**1n_don'#039't read the default config file'#010+
   '**1n_don'#039't read the default config file'#010+
-  '**1o<x>_change the name of the executable produced to <x>'#010+
+  '**1o<x>_change the name of the executable',' produced to <x>'#010+
   '**1pg_generate profile code for gprof (defines FPC_PROFILE)'#010+
   '**1pg_generate profile code for gprof (defines FPC_PROFILE)'#010+
-  '*L1P_use pipes instead of c','reating temporary assembler files'#010+
+  '*L1P_use pipes instead of creating temporary assembler files'#010+
   '**1S<x>_syntax options:'#010+
   '**1S<x>_syntax options:'#010+
   '**2S2_same as -Mobjfpc'#010+
   '**2S2_same as -Mobjfpc'#010+
   '**2Sc_supports operators like C (*=,+=,/= and -=)'#010+
   '**2Sc_supports operators like C (*=,+=,/= and -=)'#010+
-  '**2Sa_include assertion code.'#010+
+  '**2Sa','_include assertion code.'#010+
   '**2Sd_same as -Mdelphi'#010+
   '**2Sd_same as -Mdelphi'#010+
-  '**2Se<x>_compiler stops after the <x> errors (default is',' 1)'#010+
+  '**2Se<x>_compiler stops after the <x> errors (default is 1)'#010+
   '**2Sg_allow LABEL and GOTO'#010+
   '**2Sg_allow LABEL and GOTO'#010+
   '**2Sh_Use ansistrings'#010+
   '**2Sh_Use ansistrings'#010+
   '**2Si_support C++ styled INLINE'#010+
   '**2Si_support C++ styled INLINE'#010+
   '**2Sm_support macros like C (global)'#010+
   '**2Sm_support macros like C (global)'#010+
-  '**2So_same as -Mtp'#010+
+  '**2So_same as ','-Mtp'#010+
   '**2Sp_same as -Mgpc'#010+
   '**2Sp_same as -Mgpc'#010+
   '**2Ss_constructor name must be init (destructor must be done)'#010+
   '**2Ss_constructor name must be init (destructor must be done)'#010+
-  '**2St_allow stati','c keyword in objects'#010+
+  '**2St_allow static keyword in objects'#010+
   '**1s_don'#039't call assembler and linker'#010+
   '**1s_don'#039't call assembler and linker'#010+
   '**2sh_Generate script to link on host'#010+
   '**2sh_Generate script to link on host'#010+
-  '**2st_Generate script to link on target'#010+
+  '**2st_Generate script to link on target'#010,
   '**2sr_Skip register allocation phase (optimizations will be disabled)'#010+
   '**2sr_Skip register allocation phase (optimizations will be disabled)'#010+
   '**1u<x>_undefines the symbol <x>'#010+
   '**1u<x>_undefines the symbol <x>'#010+
-  '*','*1U_unit options:'#010+
+  '**1U_unit options:'#010+
   '**2Un_don'#039't check the unit name'#010+
   '**2Un_don'#039't check the unit name'#010+
   '**2Ur_generate release unit files'#010+
   '**2Ur_generate release unit files'#010+
   '**2Us_compile a system unit'#010+
   '**2Us_compile a system unit'#010+
-  '**1v<x>_Be verbose. <x> is a combination of the following letters:'#010+
+  '**1v<x>_Be verbose. <x> ','is a combination of the following letters:'#010+
   '**2*_e : Show errors (default)       d : Show debug info'#010+
   '**2*_e : Show errors (default)       d : Show debug info'#010+
-  '**2*','_w : Show warnings               u : Show unit info'#010+
+  '**2*_w : Show warnings               u : Show unit info'#010+
   '**2*_n : Show notes                  t : Show tried/used files'#010+
   '**2*_n : Show notes                  t : Show tried/used files'#010+
-  '**2*_h : Show hints                  m : Show defined macros'#010+
-  '**2*_i : Show general info           p : Show compiled procedure','s'#010+
+  '**2*_h : Show hints  ','                m : Show defined macros'#010+
+  '**2*_i : Show general info           p : Show compiled procedures'#010+
   '**2*_l : Show linenumbers            c : Show conditionals'#010+
   '**2*_l : Show linenumbers            c : Show conditionals'#010+
   '**2*_a : Show everything             0 : Show nothing (except errors)'#010+
   '**2*_a : Show everything             0 : Show nothing (except errors)'#010+
-  '**2*_b : Show all procedure          r : Rhide/GCC compatibility mode'#010+
-  '**2*_    declarations if an error    x ',': Executable info (Win32 only'+
-  ')'#010+
+  '**2*_','b : Show all procedure          r : Rhide/GCC compatibility mod'+
+  'e'#010+
+  '**2*_    declarations if an error    x : Executable info (Win32 only)'#010+
   '**2*_    occurs'#010+
   '**2*_    occurs'#010+
   '**1V_write fpcdebug.txt file with lots of debugging info'#010+
   '**1V_write fpcdebug.txt file with lots of debugging info'#010+
   '**1X_executable options:'#010+
   '**1X_executable options:'#010+
-  '*L2Xc_link with the c library'#010+
+  '*L2Xc_l','ink with the c library'#010+
   '**2Xs_strip all symbols from executable'#010+
   '**2Xs_strip all symbols from executable'#010+
-  '**2XD_try to link dynamic          (defin','es FPC_LINK_DYNAMIC)'#010+
-  '**2XS_try to link static (default) (defines FPC_LINK_STATIC)'#010+
+  '**2XD_try to link dynamic          (defines FPC_LINK_DYNAMIC)'#010+
+  '**2XP<x>_prepend the binutils names with the prefix <x>'#010+
+  '**2XS_try to link static (default) (defines FPC_LINK_STATIC',')'#010+
   '**2XX_try to link smart            (defines FPC_LINK_SMART)'#010+
   '**2XX_try to link smart            (defines FPC_LINK_SMART)'#010+
   '**0*_Processor specific options:'#010+
   '**0*_Processor specific options:'#010+
   '3*1A<x>_output format:'#010+
   '3*1A<x>_output format:'#010+
   '3*2Aas_assemble using GNU AS'#010+
   '3*2Aas_assemble using GNU AS'#010+
-  '3*2Anasmcoff_','coff (Go32v2) file using Nasm'#010+
+  '3*2Anasmcoff_coff (Go32v2) file using Nasm'#010+
   '3*2Anasmelf_elf32 (Linux) file using Nasm'#010+
   '3*2Anasmelf_elf32 (Linux) file using Nasm'#010+
-  '3*2Awasm_obj file using Wasm (Watcom)'#010+
+  '3*2Awasm','_obj file using Wasm (Watcom)'#010+
   '3*2Anasmobj_obj file using Nasm'#010+
   '3*2Anasmobj_obj file using Nasm'#010+
   '3*2Amasm_obj file using Masm (Microsoft)'#010+
   '3*2Amasm_obj file using Masm (Microsoft)'#010+
   '3*2Atasm_obj file using Tasm (Borland)'#010+
   '3*2Atasm_obj file using Tasm (Borland)'#010+
-  '3*2Acoff_coff (Go3','2v2) using internal writer'#010+
+  '3*2Acoff_coff (Go32v2) using internal writer'#010+
   '3*2Apecoff_pecoff (Win32) using internal writer'#010+
   '3*2Apecoff_pecoff (Win32) using internal writer'#010+
-  '3*1R<x>_assembler reading style:'#010+
+  '3*1R<','x>_assembler reading style:'#010+
   '3*2Ratt_read AT&T style assembler'#010+
   '3*2Ratt_read AT&T style assembler'#010+
   '3*2Rintel_read Intel style assembler'#010+
   '3*2Rintel_read Intel style assembler'#010+
   '3*2Rdirect_copy assembler text directly to assembler file'#010+
   '3*2Rdirect_copy assembler text directly to assembler file'#010+
-  '3*1','O<x>_optimizations:'#010+
+  '3*1O<x>_optimizations:'#010+
   '3*2Og_generate smaller code'#010+
   '3*2Og_generate smaller code'#010+
-  '3*2OG_generate faster code (default)'#010+
+  '3*2OG_generate faster code (defa','ult)'#010+
   '3*2Or_keep certain variables in registers'#010+
   '3*2Or_keep certain variables in registers'#010+
   '3*2Ou_enable uncertain optimizations (see docs)'#010+
   '3*2Ou_enable uncertain optimizations (see docs)'#010+
   '3*2O1_level 1 optimizations (quick optimizations)'#010+
   '3*2O1_level 1 optimizations (quick optimizations)'#010+
-  '3*2O2_level 2 o','ptimizations (-O1 + slower optimizations)'#010+
-  '3*2O3_level 3 optimizations (-O2 repeatedly, max 5 times)'#010+
+  '3*2O2_level 2 optimizations (-O1 + slower optimizations)'#010+
+  '3*2O3_level 3 optimizations (-O2 repea','tedly, max 5 times)'#010+
   '3*2Op<x>_target processor:'#010+
   '3*2Op<x>_target processor:'#010+
   '3*3Op1_set target processor to 386/486'#010+
   '3*3Op1_set target processor to 386/486'#010+
   '3*3Op2_set target processor to Pentium/PentiumMMX (tm)'#010+
   '3*3Op2_set target processor to Pentium/PentiumMMX (tm)'#010+
-  '3*3Op3_set target p','rocessor to PPro/PII/c6x86/K6 (tm)'#010+
+  '3*3Op3_set target processor to PPro/PII/c6x86/K6 (tm)'#010+
   '3*1T<x>_Target operating system:'#010+
   '3*1T<x>_Target operating system:'#010+
-  '3*2Temx_OS/2 via EMX (including EMX/RSX extender)'#010+
+  '3*2Temx_OS/2',' via EMX (including EMX/RSX extender)'#010+
   '3*2Tgo32v2_Version 2 of DJ Delorie DOS extender'#010+
   '3*2Tgo32v2_Version 2 of DJ Delorie DOS extender'#010+
   '3*2Tlinux_Linux'#010+
   '3*2Tlinux_Linux'#010+
   '3*2Tnetware_Novell Netware Module (clib)'#010+
   '3*2Tnetware_Novell Netware Module (clib)'#010+
-  '3*2Tos2_OS/2 / eC','omStation'#010+
+  '3*2Tos2_OS/2 / eComStation'#010+
   '3*2Tsunos_SunOS/Solaris'#010+
   '3*2Tsunos_SunOS/Solaris'#010+
   '3*2Twatcom_Watcom compatible DOS extender'#010+
   '3*2Twatcom_Watcom compatible DOS extender'#010+
-  '3*2Twdosx_WDOSX DOS extender'#010+
+  '3*2T','wdosx_WDOSX DOS extender'#010+
   '3*2Twin32_Windows 32 Bit'#010+
   '3*2Twin32_Windows 32 Bit'#010+
   '3*1W<x>_Win32-like target options'#010+
   '3*1W<x>_Win32-like target options'#010+
   '3*2WB<x>_Set Image base to Hexadecimal <x> value'#010+
   '3*2WB<x>_Set Image base to Hexadecimal <x> value'#010+
-  '3*2WC_Specify console type ','application'#010+
+  '3*2WC_Specify console type application'#010+
   '3*2WD_Use DEFFILE to export functions of DLL or EXE'#010+
   '3*2WD_Use DEFFILE to export functions of DLL or EXE'#010+
-  '3*2WF_Specify full-screen type application (OS/2 only)'#010+
+  '3*2WF_Specify fu','ll-screen type application (OS/2 only)'#010+
   '3*2WG_Specify graphic type application'#010+
   '3*2WG_Specify graphic type application'#010+
   '3*2WN_Do not generate relocation code (necessary for debugging)'#010+
   '3*2WN_Do not generate relocation code (necessary for debugging)'#010+
-  '3*2WR_Generate rel','ocation code'#010+
+  '3*2WR_Generate relocation code'#010+
   '6*1A<x>_output format'#010+
   '6*1A<x>_output format'#010+
   '6*2Aas_Unix o-file using GNU AS'#010+
   '6*2Aas_Unix o-file using GNU AS'#010+
-  '6*2Agas_GNU Motorola assembler'#010+
+  '6*2Agas_GNU M','otorola assembler'#010+
   '6*2Amit_MIT Syntax (old GAS)'#010+
   '6*2Amit_MIT Syntax (old GAS)'#010+
   '6*2Amot_Standard Motorola assembler'#010+
   '6*2Amot_Standard Motorola assembler'#010+
   '6*1O_optimizations:'#010+
   '6*1O_optimizations:'#010+
   '6*2Oa_turn on the optimizer'#010+
   '6*2Oa_turn on the optimizer'#010+
   '6*2Og_generate smaller code'#010+
   '6*2Og_generate smaller code'#010+
-  '6','*2OG_generate faster code (default)'#010+
+  '6*2OG_generate faster code (default)'#010+
   '6*2Ox_optimize maximum (still BUGGY!!!)'#010+
   '6*2Ox_optimize maximum (still BUGGY!!!)'#010+
-  '6*2O0_set target processor to a MC68000'#010+
+  '6*2O','0_set target processor to a MC68000'#010+
   '6*2O2_set target processor to a MC68020+ (default)'#010+
   '6*2O2_set target processor to a MC68020+ (default)'#010+
   '6*1R<x>_assembler reading style:'#010+
   '6*1R<x>_assembler reading style:'#010+
   '6*2RMOT_read motorola style assembler'#010+
   '6*2RMOT_read motorola style assembler'#010+
-  '6*','1T<x>_Target operating system:'#010+
+  '6*1T<x>_Target operating system:'#010+
   '6*2Tamiga_Commodore Amiga'#010+
   '6*2Tamiga_Commodore Amiga'#010+
-  '6*2Tatari_Atari ST/STe/TT'#010+
+  '6*2Tatari_Atari ST/STe/','TT'#010+
   '6*2Tlinux_Linux-68k'#010+
   '6*2Tlinux_Linux-68k'#010+
   '6*2Tmacos_Macintosh m68k (not supported)'#010+
   '6*2Tmacos_Macintosh m68k (not supported)'#010+
   '6*2Tpalmos_PalmOS'#010+
   '6*2Tpalmos_PalmOS'#010+
   'P*1T<x>_Target operating system:'#010+
   'P*1T<x>_Target operating system:'#010+
   'P*2Tdarwin_Darwin and MacOS X on PowerPC'#010+
   'P*2Tdarwin_Darwin and MacOS X on PowerPC'#010+
-  'P*2T','linux_Linux on PowerPC'#010+
+  'P*2Tlinux_Linux on PowerPC'#010+
   'P*2Tmacos_MacOS (classic) on PowerPC'#010+
   'P*2Tmacos_MacOS (classic) on PowerPC'#010+
-  'P*2Tmorphos_MorphOS'#010+
+  'P*2Tmorphos_MorphOS'#010,
   'P*2WC_Specify console type application (MacOS only)'#010+
   'P*2WC_Specify console type application (MacOS only)'#010+
   'P*2WG_Specify graphic type application (MacOS only)'#010+
   'P*2WG_Specify graphic type application (MacOS only)'#010+
-  'P*2WT_Specify tool type application (MPW tool, MacOS onl','y)'#010+
+  'P*2WT_Specify tool type application (MPW tool, MacOS only)'#010+
   '**1*_'#010+
   '**1*_'#010+
   '**1?_shows this help'#010+
   '**1?_shows this help'#010+
   '**1h_shows this help without waiting'#000
   '**1h_shows this help without waiting'#000

+ 84 - 12
compiler/nadd.pas

@@ -765,6 +765,15 @@ implementation
                   if (torddef(rd).typ<>scurrency) then
                   if (torddef(rd).typ<>scurrency) then
                    inserttypeconv(right,s64currencytype);
                    inserttypeconv(right,s64currencytype);
                end
                end
+             { and,or,xor work on bit patterns and don't care
+               about the sign }
+             else if nodetype in [andn,orn,xorn] then
+               begin
+                 if rd.size>ld.size then
+                   inserttypeconv_explicit(left,right.resulttype)
+                 else
+                   inserttypeconv_explicit(right,left.resulttype);
+               end
              { is there a signed 64 bit type ? }
              { is there a signed 64 bit type ? }
              else if ((torddef(rd).typ=s64bit) or (torddef(ld).typ=s64bit)) then
              else if ((torddef(rd).typ=s64bit) or (torddef(ld).typ=s64bit)) then
                begin
                begin
@@ -786,12 +795,23 @@ implementation
              { is there a cardinal? }
              { is there a cardinal? }
              else if ((torddef(rd).typ=u32bit) or (torddef(ld).typ=u32bit)) then
              else if ((torddef(rd).typ=u32bit) or (torddef(ld).typ=u32bit)) then
                begin
                begin
-                 { and,or,xor work on bit patterns and don't care
-                   about the sign }
-                 if nodetype in [andn,orn,xorn] then
+                 { convert positive constants to u32bit }
+                 if (torddef(ld).typ<>u32bit) and
+                    is_constintnode(left) and
+                    (tordconstnode(left).value >= 0) then
+                   inserttypeconv(left,u32inttype);
+                 if (torddef(rd).typ<>u32bit) and
+                    is_constintnode(right) and
+                    (tordconstnode(right).value >= 0) then
+                   inserttypeconv(right,u32inttype);
+                 { when one of the operand is signed perform
+                   the operation in 64bit, can't use rd/ld here because there
+                   could be already typeconvs inserted }
+                 if is_signed(left.resulttype.def) or is_signed(right.resulttype.def) then
                    begin
                    begin
-                     inserttypeconv_explicit(left,u32inttype);
-                     inserttypeconv_explicit(right,u32inttype);
+                     CGMessage(type_w_mixed_signed_unsigned);
+                     inserttypeconv(left,s64inttype);
+                     inserttypeconv(right,s64inttype);
                    end
                    end
                  else
                  else
                    begin
                    begin
@@ -1679,12 +1699,20 @@ implementation
                  end
                  end
                 else
                 else
                  begin
                  begin
-                   expectloc:=LOC_FLAGS;
-                   if (left.expectloc in [LOC_JUMP,LOC_FLAGS]) and
-                      (left.expectloc in [LOC_JUMP,LOC_FLAGS]) then
-                     calcregisters(self,2,0,0)
+                   if nodetype in [ltn,lten,gtn,gten,equaln,unequaln] then
+                     begin
+                       expectloc:=LOC_FLAGS;
+                       if (left.expectloc in [LOC_JUMP,LOC_FLAGS]) and
+                          (left.expectloc in [LOC_JUMP,LOC_FLAGS]) then
+                         calcregisters(self,2,0,0)
+                       else
+                         calcregisters(self,1,0,0);
+                     end
                    else
                    else
-                     calcregisters(self,1,0,0);
+                     begin
+                       expectloc:=LOC_REGISTER;
+                       calcregisters(self,0,0,0);
+                     end;
                  end;
                  end;
               end
               end
              else
              else
@@ -1706,7 +1734,11 @@ implementation
                   if nodetype in [addn,subn,muln,andn,orn,xorn] then
                   if nodetype in [addn,subn,muln,andn,orn,xorn] then
                     expectloc:=LOC_REGISTER
                     expectloc:=LOC_REGISTER
                   else
                   else
+{$ifdef sparc}
+                    expectloc:=LOC_FLAGS;
+{$else sparc}
                     expectloc:=LOC_JUMP;
                     expectloc:=LOC_JUMP;
+{$endif sparc}
                   calcregisters(self,2,0,0)
                   calcregisters(self,2,0,0)
                end
                end
 {$endif cpu64bit}
 {$endif cpu64bit}
@@ -1978,7 +2010,44 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.123  2004-05-28 21:13:44  peter
+  Revision 1.124  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.123  2004/05/28 21:13:44  peter
+    * fix cardinal+constint
+
+  Revision 1.122  2004/05/23 14:14:18  florian
+    + added set of widechar support (limited to 256 chars, is delphi compatible)
+
+  Revision 1.121  2004/05/23 14:08:39  peter
+    * only convert widechar to widestring when both operands are
+      constant
+    * support widechar-widechar operations in orddef part
+
+  Revision 1.120  2004/05/21 13:08:14  florian
+    * fixed <ordinal>+<pointer>
+
+  Revision 1.119  2004/05/20 21:54:33  florian
+    + <pointer> - <pointer> result is divided by the pointer element size now
+      this is delphi compatible as well as resulting in the expected result for p1+(p2-p1)
+
+  Revision 1.118  2004/05/19 23:29:26  peter
+    * don't change sign for unsigned shl/shr operations
+    * cleanup for u32bit
+
+  Revision 1.117  2004/04/29 19:56:37  daniel
+    * Prepare compiler infrastructure for multiple ansistring types
+
+  Revision 1.116  2004/04/18 07:52:43  florian
+    * fixed web bug 3048: comparision of dyn. arrays
+
+  Revision 1.115.2.3  2004/05/31 16:39:42  peter
+    * add ungetiftemp in a few locations
+
+  Revision 1.115.2.2  2004/05/30 10:45:50  peter
+    * merged fixes from main branch
+
+  Revision 1.123  2004/05/28 21:13:44  peter
     * fix cardinal+constint
     * fix cardinal+constint
 
 
   Revision 1.122  2004/05/23 14:14:18  florian
   Revision 1.122  2004/05/23 14:14:18  florian
@@ -2006,6 +2075,9 @@ end.
   Revision 1.116  2004/04/18 07:52:43  florian
   Revision 1.116  2004/04/18 07:52:43  florian
     * fixed web bug 3048: comparision of dyn. arrays
     * fixed web bug 3048: comparision of dyn. arrays
 
 
+  Revision 1.115.2.1  2004/05/02 21:26:28  peter
+    * for xor,or,and only typecast to the biggest size
+
   Revision 1.115  2004/03/29 14:44:10  peter
   Revision 1.115  2004/03/29 14:44:10  peter
     * fixes to previous constant integer commit
     * fixes to previous constant integer commit
 
 
@@ -2332,4 +2404,4 @@ end.
       with string operations
       with string operations
     * adapted some routines to use the new cg methods
     * adapted some routines to use the new cg methods
 
 
-}
+}

+ 11 - 4
compiler/nbas.pas

@@ -310,7 +310,7 @@ implementation
                 (assigned(tcallnode(left).funcretnode) or
                 (assigned(tcallnode(left).funcretnode) or
                  (tcallnode(left).procdefinition.proctypeoption=potype_constructor))) and
                  (tcallnode(left).procdefinition.proctypeoption=potype_constructor))) and
             not(is_void(left.resulttype.def)) then
             not(is_void(left.resulttype.def)) then
-           CGMessage(cg_e_illegal_expression);
+           CGMessage(parser_e_illegal_expression);
          if codegenerror then
          if codegenerror then
            exit;
            exit;
 
 
@@ -397,7 +397,7 @@ implementation
                       not((tcallnode(hp.left).procdefinition.proctypeoption=potype_constructor) and
                       not((tcallnode(hp.left).procdefinition.proctypeoption=potype_constructor) and
                           assigned(tprocdef(tcallnode(hp.left).procdefinition)._class) and
                           assigned(tprocdef(tcallnode(hp.left).procdefinition)._class) and
                           is_object(tprocdef(tcallnode(hp.left).procdefinition)._class)) then
                           is_object(tprocdef(tcallnode(hp.left).procdefinition)._class)) then
-                     CGMessagePos(hp.left.fileinfo,cg_e_illegal_expression);
+                     CGMessagePos(hp.left.fileinfo,parser_e_illegal_expression);
                    { the resulttype of the block is the last type that is
                    { the resulttype of the block is the last type that is
                      returned. Normally this is a voidtype. But when the
                      returned. Normally this is a voidtype. But when the
                      compiler inserts a block of multiple statements then the
                      compiler inserts a block of multiple statements then the
@@ -1017,13 +1017,20 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.83  2004-05-23 18:28:41  peter
+  Revision 1.84  2004-06-16 20:07:07  florian
+    * dwarf branch merged
+
+  Revision 1.83  2004/05/23 18:28:41  peter
     * methodpointer is loaded into a temp when it was a calln
     * methodpointer is loaded into a temp when it was a calln
 
 
   Revision 1.82  2004/05/23 15:06:20  peter
   Revision 1.82  2004/05/23 15:06:20  peter
     * implicit_finally flag must be set in pass1
     * implicit_finally flag must be set in pass1
     * add check whether the implicit frame is generated when expected
     * add check whether the implicit frame is generated when expected
 
 
+  Revision 1.81.2.1  2004/04/28 19:55:51  peter
+    * new warning for ordinal-pointer when size is different
+    * fixed some cg_e_ messages to the correct section type_e_ or parser_e_
+
   Revision 1.81  2004/03/10 20:41:17  peter
   Revision 1.81  2004/03/10 20:41:17  peter
     * maybe_in_reg moved to tempinfo
     * maybe_in_reg moved to tempinfo
     * fixed expectloc for maybe_in_reg
     * fixed expectloc for maybe_in_reg
@@ -1332,4 +1339,4 @@ end.
     - list field removed of the tnode class because it's not used currently
     - list field removed of the tnode class because it's not used currently
       and can cause hard-to-find bugs
       and can cause hard-to-find bugs
 
 
-}
+}

+ 35 - 10
compiler/ncal.pas

@@ -63,6 +63,8 @@ interface
           procedure setfuncretnode(const returnnode: tnode);
           procedure setfuncretnode(const returnnode: tnode);
           procedure convert_carg_array_of_const;
           procedure convert_carg_array_of_const;
           procedure order_parameters;
           procedure order_parameters;
+       protected
+          pushedparasize : longint;
        public
        public
           { the symbol containing the definition of the procedure }
           { the symbol containing the definition of the procedure }
           { to call                                               }
           { to call                                               }
@@ -415,6 +417,9 @@ type
                  end;
                  end;
                  set_varstate(left,vs_used,true);
                  set_varstate(left,vs_used,true);
                  resulttype:=left.resulttype;
                  resulttype:=left.resulttype;
+                 { also update paraitem type to get the correct parameter location
+                   for the new types }
+                 paraitem.paratype:=left.resulttype;
                end
                end
              else
              else
               if (paraitem.is_hidden) then
               if (paraitem.is_hidden) then
@@ -1530,7 +1535,7 @@ type
                       { Multiple candidates left? }
                       { Multiple candidates left? }
                       if cand_cnt>1 then
                       if cand_cnt>1 then
                        begin
                        begin
-                         CGMessage(cg_e_cant_choose_overload_function);
+                         CGMessage(type_e_cant_choose_overload_function);
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
                          candidates.dump_info(V_Hint);
                          candidates.dump_info(V_Hint);
 {$else EXTDEBUG}
 {$else EXTDEBUG}
@@ -1852,12 +1857,14 @@ type
              procdefinition.has_paraloc_info:=true;
              procdefinition.has_paraloc_info:=true;
            end;
            end;
 
 
-         current_procinfo.maxpushedparasize:=max(current_procinfo.maxpushedparasize,procdefinition.requiredargarea);
-
-         { calculate the parameter info for varargs }
+         { calculate the parameter size needed for this call include varargs if they are available }
          if assigned(varargsparas) then
          if assigned(varargsparas) then
-           current_procinfo.maxpushedparasize:=max(current_procinfo.maxpushedparasize,
-             paramanager.create_varargs_paraloc_info(procdefinition,varargsparas));
+           pushedparasize:=paramanager.create_varargs_paraloc_info(procdefinition,varargsparas)
+         else
+           pushedparasize:=procdefinition.requiredargarea;
+
+         { record maximum parameter size used in this proc }
+         current_procinfo.allocate_push_parasize(pushedparasize);
 
 
          { work trough all parameters to get the register requirements }
          { work trough all parameters to get the register requirements }
          if assigned(left) then
          if assigned(left) then
@@ -1940,14 +1947,14 @@ type
                move them to memory after ... }
                move them to memory after ... }
              if (resulttype.def.deftype=recorddef) then
              if (resulttype.def.deftype=recorddef) then
               begin
               begin
-                expectloc:=LOC_CREFERENCE;
+                expectloc:=LOC_REFERENCE;
               end
               end
              else
              else
              { ansi/widestrings must be registered, so we can dispose them }
              { ansi/widestrings must be registered, so we can dispose them }
               if is_ansistring(resulttype.def) or
               if is_ansistring(resulttype.def) or
                  is_widestring(resulttype.def) then
                  is_widestring(resulttype.def) then
                begin
                begin
-                 expectloc:=LOC_CREFERENCE;
+                 expectloc:=LOC_REFERENCE;
                  registersint:=1;
                  registersint:=1;
                end
                end
              else
              else
@@ -2140,7 +2147,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.237  2004-05-25 18:51:49  peter
+  Revision 1.238  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.237  2004/05/25 18:51:49  peter
     * fix tcallnode.getcopy. the parameters need to be copied after
     * fix tcallnode.getcopy. the parameters need to be copied after
       methodpointerinit is copied
       methodpointerinit is copied
 
 
@@ -2160,6 +2170,21 @@ end.
   Revision 1.232  2004/05/01 22:05:01  florian
   Revision 1.232  2004/05/01 22:05:01  florian
     + added lib support for Amiga/MorphOS syscalls
     + added lib support for Amiga/MorphOS syscalls
 
 
+  Revision 1.231.2.4  2004/05/31 16:39:42  peter
+    * add ungetiftemp in a few locations
+
+  Revision 1.231.2.3  2004/05/03 20:54:00  peter
+    * update paraitem after varargs typeconvs have been inserted so
+      the parameter location uses the new type
+
+  Revision 1.231.2.2  2004/05/02 12:45:32  peter
+    * enabled cpuhasfixedstack for x86-64 again
+    * fixed size of temp allocation for parameters
+
+  Revision 1.231.2.1  2004/04/28 19:55:51  peter
+    * new warning for ordinal-pointer when size is different
+    * fixed some cg_e_ messages to the correct section type_e_ or parser_e_
+
   Revision 1.231  2004/03/14 20:07:13  peter
   Revision 1.231  2004/03/14 20:07:13  peter
     * removed unused paravisible
     * removed unused paravisible
 
 
@@ -2785,4 +2810,4 @@ end.
   Revision 1.78  2002/07/04 20:43:00  florian
   Revision 1.78  2002/07/04 20:43:00  florian
     * first x86-64 patches
     * first x86-64 patches
 
 
-}
+}

+ 74 - 9
compiler/ncgadd.pas

@@ -292,7 +292,7 @@ interface
                    internalerror(43244);
                    internalerror(43244);
                   if (right.location.loc = LOC_CONSTANT) then
                   if (right.location.loc = LOC_CONSTANT) then
                     cg.a_op_const_reg_reg(exprasmlist,OP_OR,location.size,
                     cg.a_op_const_reg_reg(exprasmlist,OP_OR,location.size,
-                      aword(1 shl aword(right.location.value)),
+                      aint(1 shl right.location.value),
                       left.location.register,location.register)
                       left.location.register,location.register)
                   else
                   else
                     begin
                     begin
@@ -305,7 +305,7 @@ interface
                             left.location.register,location.register)
                             left.location.register,location.register)
                       else
                       else
                         cg.a_op_const_reg_reg(exprasmlist,OP_OR,location.size,
                         cg.a_op_const_reg_reg(exprasmlist,OP_OR,location.size,
-                            aword(left.location.value),tmpreg,location.register);
+                            left.location.value,tmpreg,location.register);
                       cg.ungetregister(exprasmlist,tmpreg);
                       cg.ungetregister(exprasmlist,tmpreg);
                     end;
                     end;
                   opdone := true;
                   opdone := true;
@@ -338,7 +338,7 @@ interface
                     begin
                     begin
                       tmpreg := cg.getintregister(exprasmlist,location.size);
                       tmpreg := cg.getintregister(exprasmlist,location.size);
                       cg.a_load_const_reg(exprasmlist,location.size,
                       cg.a_load_const_reg(exprasmlist,location.size,
-                        aword(left.location.value),tmpreg);
+                        left.location.value,tmpreg);
                       cg.a_op_reg_reg(exprasmlist,OP_NOT,location.size,right.location.register,right.location.register);
                       cg.a_op_reg_reg(exprasmlist,OP_NOT,location.size,right.location.register,right.location.register);
                       cg.a_op_reg_reg(exprasmlist,OP_AND,location.size,right.location.register,tmpreg);
                       cg.a_op_reg_reg(exprasmlist,OP_AND,location.size,right.location.register,tmpreg);
                       cg.a_load_reg_reg(exprasmlist,OS_INT,location.size,tmpreg,location.register);
                       cg.a_load_reg_reg(exprasmlist,OS_INT,location.size,tmpreg,location.register);
@@ -363,7 +363,7 @@ interface
               swapleftright;
               swapleftright;
             if (right.location.loc = LOC_CONSTANT) then
             if (right.location.loc = LOC_CONSTANT) then
               cg.a_op_const_reg_reg(exprasmlist,cgop,location.size,
               cg.a_op_const_reg_reg(exprasmlist,cgop,location.size,
-                aword(right.location.value),left.location.register,
+                right.location.value,left.location.register,
                 location.register)
                 location.register)
             else
             else
               cg.a_op_reg_reg_reg(exprasmlist,cgop,location.size,
               cg.a_op_reg_reg_reg(exprasmlist,cgop,location.size,
@@ -447,7 +447,7 @@ interface
                  location.register)
                  location.register)
             else
             else
               cg.a_op_const_reg_reg(exprasmlist,cgop,location.size,
               cg.a_op_const_reg_reg(exprasmlist,cgop,location.size,
-                 aword(right.location.value),left.location.register,
+                 right.location.value,left.location.register,
                  location.register);
                  location.register);
          end;
          end;
 
 
@@ -507,11 +507,55 @@ interface
             internalerror(2002072705);
             internalerror(2002072705);
         end;
         end;
 
 
+{$ifdef cpu64bit}
         case nodetype of
         case nodetype of
           xorn,orn,andn,addn:
           xorn,orn,andn,addn:
             begin
             begin
               if (right.location.loc = LOC_CONSTANT) then
               if (right.location.loc = LOC_CONSTANT) then
-                cg64.a_op64_const_reg_reg(exprasmlist,op,right.location.valueqword,
+                cg.a_op_const_reg_reg(exprasmlist,op,location.size,right.location.value,
+                  left.location.register64,location.register)
+              else
+                cg.a_op_reg_reg_reg(exprasmlist,op,location.size,right.location.register,
+                  left.location.register64,location.register);
+            end;
+          subn:
+            begin
+              if (nf_swaped in flags) then
+                swapleftright;
+
+              if left.location.loc <> LOC_CONSTANT then
+                begin
+                  if (location.registerlow = NR_NO) then
+                    begin
+                     location.registerlow := cg.getintregister(exprasmlist,OS_INT);
+                     location.registerhigh := cg.getintregister(exprasmlist,OS_INT);
+                  end;
+                  if right.location.loc <> LOC_CONSTANT then
+                    // reg64 - reg64
+                    cg.a_op_reg_reg_reg(exprasmlist,OP_SUB,location.size,
+                      right.location.register,left.location.register,location.register)
+                  else
+                    // reg64 - const64
+                    cg.a_op_const_reg_reg(exprasmlist,OP_SUB,location.size,
+                      right.location.value,left.location.register,location.register);
+                end
+              else
+                begin
+                  // const64 - reg64
+                  location_force_reg(exprasmlist,left.location,left.location.size,true);
+                  cg.a_op_reg_reg_reg(exprasmlist,OP_SUB,location.size,
+                    right.location.register,left.location.register,location.register);
+                end;
+            end;
+          else
+            internalerror(2002072803);
+        end;
+{$else cpu64bit}
+        case nodetype of
+          xorn,orn,andn,addn:
+            begin
+              if (right.location.loc = LOC_CONSTANT) then
+                cg64.a_op64_const_reg_reg(exprasmlist,op,right.location.value64,
                   left.location.register64,location.register64)
                   left.location.register64,location.register64)
               else
               else
                 cg64.a_op64_reg_reg_reg(exprasmlist,op,right.location.register64,
                 cg64.a_op64_reg_reg_reg(exprasmlist,op,right.location.register64,
@@ -532,7 +576,7 @@ interface
                   else
                   else
                     // reg64 - const64
                     // reg64 - const64
                     cg64.a_op64_const_reg_reg(exprasmlist,OP_SUB,
                     cg64.a_op64_const_reg_reg(exprasmlist,OP_SUB,
-                      right.location.valueqword,left.location.register64,
+                      right.location.value64,left.location.register64,
                       location.register64)
                       location.register64)
                 end
                 end
               else
               else
@@ -547,6 +591,7 @@ interface
           else
           else
             internalerror(2002072803);
             internalerror(2002072803);
         end;
         end;
+{$endif cpu64bit}
 
 
         { emit overflow check if enabled }
         { emit overflow check if enabled }
         if checkoverflow then
         if checkoverflow then
@@ -653,7 +698,7 @@ interface
                location.register)
                location.register)
           else
           else
             cg.a_op_const_reg_reg(exprasmlist,cgop,location.size,
             cg.a_op_const_reg_reg(exprasmlist,cgop,location.size,
-               aword(right.location.value),left.location.register,
+               right.location.value,left.location.register,
                location.register);
                location.register);
         end
         end
       else  { subtract is a special case since its not commutative }
       else  { subtract is a special case since its not commutative }
@@ -762,7 +807,27 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.29  2004-02-26 16:11:29  peter
+  Revision 1.30  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.29.2.5  2004/06/13 10:51:16  florian
+    * fixed several register allocator problems (sparc/arm)
+
+  Revision 1.29.2.4  2004/06/12 17:01:01  florian
+    * fixed compilation of arm compiler
+
+  Revision 1.29.2.3  2004/06/02 20:59:05  peter
+    * fix negative consts
+
+  Revision 1.29.2.2  2004/05/30 17:54:14  florian
+    + implemented cmp64bit
+    * started to fix spilling
+    * fixed int64 sub partially
+
+  Revision 1.29.2.1  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.29  2004/02/26 16:11:29  peter
     * use op_ordinal for dynarr compares
     * use op_ordinal for dynarr compares
 
 
   Revision 1.28  2004/02/04 19:22:27  peter
   Revision 1.28  2004/02/04 19:22:27  peter

+ 29 - 11
compiler/ncgbas.pas

@@ -161,22 +161,20 @@ interface
                         if indexreg=NR_NO then
                         if indexreg=NR_NO then
                           begin
                           begin
                             op.typ:=top_const;
                             op.typ:=top_const;
-                            op.val:=aword(sym.localloc.reference.offset+sofs);
+                            op.val:=sym.localloc.reference.offset+sofs;
                           end
                           end
                         else
                         else
                           begin
                           begin
                             op.typ:=top_ref;
                             op.typ:=top_ref;
                             new(op.ref);
                             new(op.ref);
-                            reference_reset_base(op.ref^,indexreg,
-                                sym.localloc.reference.offset+sofs);
+                            reference_reset_base(op.ref^,indexreg,sym.localloc.reference.offset+sofs);
                           end;
                           end;
                       end
                       end
                     else
                     else
                       begin
                       begin
                         op.typ:=top_ref;
                         op.typ:=top_ref;
                         new(op.ref);
                         new(op.ref);
-                        reference_reset_base(op.ref^,sym.localloc.reference.index,
-                            sym.localloc.reference.offset+sofs);
+                        reference_reset_base(op.ref^,sym.localloc.reference.index,sym.localloc.reference.offset+sofs);
                         op.ref^.index:=indexreg;
                         op.ref^.index:=indexreg;
 {$ifdef x86}
 {$ifdef x86}
                         op.ref^.scalefactor:=scale;
                         op.ref^.scalefactor:=scale;
@@ -233,10 +231,18 @@ interface
                 case hp2.typ of
                 case hp2.typ of
                   ait_label :
                   ait_label :
                      ReLabel(tasmsymbol(tai_label(hp2).l));
                      ReLabel(tasmsymbol(tai_label(hp2).l));
-                  ait_indirect_symbol,
-                  ait_const_rva,
-                  ait_const_symbol :
-                     ReLabel(tai_const_symbol(hp2).sym);
+                  ait_const_64bit,
+                  ait_const_32bit,
+                  ait_const_16bit,
+                  ait_const_8bit,
+                  ait_const_rva_symbol,
+                  ait_const_indirect_symbol :
+                     begin
+                       if assigned(tai_const(hp2).sym) then
+                         ReLabel(tai_const(hp2).sym);
+                       if assigned(tai_const(hp2).endsym) then
+                         ReLabel(tai_const(hp2).endsym);
+                     end;
                   ait_instruction :
                   ait_instruction :
                      begin
                      begin
                        { remove cached insentry, because the new code can
                        { remove cached insentry, because the new code can
@@ -477,13 +483,25 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.62  2004-05-23 18:28:41  peter
+  Revision 1.63  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.62  2004/05/23 18:28:41  peter
     * methodpointer is loaded into a temp when it was a calln
     * methodpointer is loaded into a temp when it was a calln
 
 
   Revision 1.61  2004/05/23 15:06:20  peter
   Revision 1.61  2004/05/23 15:06:20  peter
     * implicit_finally flag must be set in pass1
     * implicit_finally flag must be set in pass1
     * add check whether the implicit frame is generated when expected
     * add check whether the implicit frame is generated when expected
 
 
+  Revision 1.60.2.3  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.60.2.2  2004/04/12 19:34:45  peter
+    * basic framework for dwarf CFI
+
+  Revision 1.60.2.1  2004/04/12 14:45:11  peter
+    * tai_const_symbol and tai_const merged
+
   Revision 1.60  2004/03/15 08:44:51  michael
   Revision 1.60  2004/03/15 08:44:51  michael
   + Fix from peter: fixes crash when inlining assembler code referencing local vars
   + Fix from peter: fixes crash when inlining assembler code referencing local vars
 
 
@@ -737,4 +755,4 @@ end.
     - list field removed of the tnode class because it's not used currently
     - list field removed of the tnode class because it's not used currently
       and can cause hard-to-find bugs
       and can cause hard-to-find bugs
 
 
-}
+}

+ 141 - 149
compiler/ncgcal.pas

@@ -48,9 +48,6 @@ interface
           procedure normal_pass_2;
           procedure normal_pass_2;
           procedure inlined_pass_2;
           procedure inlined_pass_2;
        protected
        protected
-          { save the size of pushed parameter, needed po_clearstack
-            and alignment }
-          pushedparasize : longint;
           framepointer_paraloc : tparalocation;
           framepointer_paraloc : tparalocation;
           refcountedtemp : treference;
           refcountedtemp : treference;
           procedure handle_return_value;
           procedure handle_return_value;
@@ -63,7 +60,6 @@ interface
              most stack based machines, where the frame pointer is
              most stack based machines, where the frame pointer is
              the first invisible parameter.
              the first invisible parameter.
           }
           }
-          function  align_parasize:longint;virtual;
           procedure pop_parasize(pop_size:longint);virtual;
           procedure pop_parasize(pop_size:longint);virtual;
           procedure extra_interrupt_code;virtual;
           procedure extra_interrupt_code;virtual;
           procedure extra_call_code;virtual;
           procedure extra_call_code;virtual;
@@ -88,7 +84,7 @@ implementation
       gdb,
       gdb,
 {$endif GDB}
 {$endif GDB}
       cgbase,pass_2,
       cgbase,pass_2,
-      cpuinfo,aasmbase,aasmtai,
+      aasmbase,aasmtai,
       nbas,nmem,nld,ncnv,nutils,
       nbas,nmem,nld,ncnv,nutils,
 {$ifdef x86}
 {$ifdef x86}
       cga,cgx86,
       cga,cgx86,
@@ -127,15 +123,16 @@ implementation
           internalerror(200304235);
           internalerror(200304235);
         location_release(exprasmlist,left.location);
         location_release(exprasmlist,left.location);
         cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
         cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
-        inc(tcgcallnode(aktcallnode).pushedparasize,POINTER_SIZE);
       end;
       end;
 
 
 
 
     procedure tcgcallparanode.push_value_para;
     procedure tcgcallparanode.push_value_para;
+{$ifdef i386}
       var
       var
+        cgsize : tcgsize;
         href   : treference;
         href   : treference;
         size   : longint;
         size   : longint;
-        cgsize : tcgsize;
+{$endif i386}
       begin
       begin
         { we've nothing to push when the size of the parameter is 0 }
         { we've nothing to push when the size of the parameter is 0 }
         if left.resulttype.def.size=0 then
         if left.resulttype.def.size=0 then
@@ -157,7 +154,6 @@ implementation
              LOC_CFPUREGISTER:
              LOC_CFPUREGISTER:
                begin
                begin
                  size:=align(TCGSize2Size[left.location.size],tempparaloc.alignment);
                  size:=align(TCGSize2Size[left.location.size],tempparaloc.alignment);
-                 inc(tcgcallnode(aktcallnode).pushedparasize,size);
                  if tempparaloc.reference.index=NR_STACK_POINTER_REG then
                  if tempparaloc.reference.index=NR_STACK_POINTER_REG then
                    begin
                    begin
                      cg.g_stackpointer_alloc(exprasmlist,size);
                      cg.g_stackpointer_alloc(exprasmlist,size);
@@ -171,7 +167,6 @@ implementation
              LOC_CMMREGISTER:
              LOC_CMMREGISTER:
                begin
                begin
                  size:=align(tfloatdef(left.resulttype.def).size,tempparaloc.alignment);
                  size:=align(tfloatdef(left.resulttype.def).size,tempparaloc.alignment);
-                 inc(tcgcallnode(aktcallnode).pushedparasize,size);
                  if tempparaloc.reference.index=NR_STACK_POINTER_REG then
                  if tempparaloc.reference.index=NR_STACK_POINTER_REG then
                    begin
                    begin
                      cg.g_stackpointer_alloc(exprasmlist,size);
                      cg.g_stackpointer_alloc(exprasmlist,size);
@@ -194,14 +189,12 @@ implementation
                         if (size>=4) or (tempparaloc.alignment>=4) then
                         if (size>=4) or (tempparaloc.alignment>=4) then
                          begin
                          begin
                            cgsize:=OS_32;
                            cgsize:=OS_32;
-                           inc(tcgcallnode(aktcallnode).pushedparasize,4);
                            dec(href.offset,4);
                            dec(href.offset,4);
                            dec(size,4);
                            dec(size,4);
                          end
                          end
                         else
                         else
                          begin
                          begin
                            cgsize:=OS_16;
                            cgsize:=OS_16;
-                           inc(tcgcallnode(aktcallnode).pushedparasize,2);
                            dec(href.offset,2);
                            dec(href.offset,2);
                            dec(size,2);
                            dec(size,2);
                          end;
                          end;
@@ -212,7 +205,6 @@ implementation
                    begin
                    begin
                      reference_reset_base(href,tempparaloc.reference.index,tempparaloc.reference.offset);
                      reference_reset_base(href,tempparaloc.reference.index,tempparaloc.reference.offset);
                      cg.g_concatcopy(exprasmlist,left.location.reference,href,size,false,false);
                      cg.g_concatcopy(exprasmlist,left.location.reference,href,size,false,false);
-                     inc(tcgcallnode(aktcallnode).pushedparasize,size);
                    end;
                    end;
                end;
                end;
              else
              else
@@ -299,7 +291,6 @@ implementation
                 internalerror(200204241);
                 internalerror(200204241);
               { push on stack }
               { push on stack }
               size:=align(left.resulttype.def.size,tempparaloc.alignment);
               size:=align(left.resulttype.def.size,tempparaloc.alignment);
-              inc(tcgcallnode(aktcallnode).pushedparasize,size);
               if tempparaloc.reference.index=NR_STACK_POINTER_REG then
               if tempparaloc.reference.index=NR_STACK_POINTER_REG then
                 begin
                 begin
                   cg.g_stackpointer_alloc(exprasmlist,size);
                   cg.g_stackpointer_alloc(exprasmlist,size);
@@ -321,17 +312,16 @@ implementation
                 LOC_REFERENCE,
                 LOC_REFERENCE,
                 LOC_CREFERENCE :
                 LOC_CREFERENCE :
                   begin
                   begin
-                    cgsize:=def_cgsize(left.resulttype.def);
-                    if cgsize in [OS_64,OS_S64] then
+{$ifndef cpu64bit}
+                    if left.location.size in [OS_64,OS_S64] then
                      begin
                      begin
-                       inc(tcgcallnode(aktcallnode).pushedparasize,8);
                        cg64.a_param64_loc(exprasmlist,left.location,tempparaloc);
                        cg64.a_param64_loc(exprasmlist,left.location,tempparaloc);
                        location_release(exprasmlist,left.location);
                        location_release(exprasmlist,left.location);
                      end
                      end
                     else
                     else
+{$endif cpu64bit}
                      begin
                      begin
                        location_release(exprasmlist,left.location);
                        location_release(exprasmlist,left.location);
-                       inc(tcgcallnode(aktcallnode).pushedparasize,align(tcgsize2size[tempparaloc.size],tempparaloc.alignment));
                        cg.a_param_loc(exprasmlist,left.location,tempparaloc);
                        cg.a_param_loc(exprasmlist,left.location,tempparaloc);
                      end;
                      end;
                   end;
                   end;
@@ -340,7 +330,6 @@ implementation
                 LOC_CMMXREGISTER:
                 LOC_CMMXREGISTER:
                   begin
                   begin
                      location_release(exprasmlist,left.location);
                      location_release(exprasmlist,left.location);
-                     inc(tcgcallnode(aktcallnode).pushedparasize,8);
                      cg.a_parammm_reg(exprasmlist,left.location.register);
                      cg.a_parammm_reg(exprasmlist,left.location.register);
                   end;
                   end;
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
@@ -413,7 +402,6 @@ implementation
                   if (hp.nodetype=addrn) and
                   if (hp.nodetype=addrn) and
                      (not(nf_procvarload in hp.flags)) then
                      (not(nf_procvarload in hp.flags)) then
                     begin
                     begin
-                      inc(tcgcallnode(aktcallnode).pushedparasize,POINTER_SIZE);
                       location_release(exprasmlist,left.location);
                       location_release(exprasmlist,left.location);
                       cg.a_param_loc(exprasmlist,left.location,tempparaloc);
                       cg.a_param_loc(exprasmlist,left.location,tempparaloc);
                     end
                     end
@@ -480,12 +468,6 @@ implementation
       end;
       end;
 
 
 
 
-    function tcgcallnode.align_parasize:longint;
-      begin
-        result:=0;
-      end;
-
-
     procedure tcgcallnode.pop_parasize(pop_size:longint);
     procedure tcgcallnode.pop_parasize(pop_size:longint);
       begin
       begin
       end;
       end;
@@ -496,23 +478,25 @@ implementation
         cgsize : tcgsize;
         cgsize : tcgsize;
         hregister : tregister;
         hregister : tregister;
         tempnode: tnode;
         tempnode: tnode;
+        resultloc : tparalocation;
       begin
       begin
-        { structured results are easy to handle.... }
-        { needed also when result_no_used !! }
+        resultloc:=procdefinition.funcret_paraloc[callerside];
+        cgsize:=resultloc.size;
+        { structured results are easy to handle....
+          needed also when result_no_used !! }
         if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
         if paramanager.ret_in_param(resulttype.def,procdefinition.proccalloption) then
-         begin
-           { Location should be setup by the funcret para }
-           if location.loc<>LOC_REFERENCE then
-            internalerror(200304241);
-         end
-        else
+          begin
+            { Location should be setup by the funcret para }
+            if location.loc<>LOC_REFERENCE then
+             internalerror(200304241);
+          end
         { ansi/widestrings must be registered, so we can dispose them }
         { ansi/widestrings must be registered, so we can dispose them }
-         if resulttype.def.needs_inittable then
+        else if resulttype.def.needs_inittable then
           begin
           begin
             { the FUNCTION_RESULT_REG is already allocated }
             { the FUNCTION_RESULT_REG is already allocated }
             if not assigned(funcretnode) then
             if not assigned(funcretnode) then
               begin
               begin
-                location_reset(location,LOC_CREFERENCE,OS_ADDR);
+                location_reset(location,LOC_REFERENCE,OS_ADDR);
                 location.reference:=refcountedtemp;
                 location.reference:=refcountedtemp;
                 { a_load_reg_ref may allocate registers! }
                 { a_load_reg_ref may allocate registers! }
                 cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,location.reference);
                 cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,location.reference);
@@ -520,9 +504,9 @@ implementation
               end
               end
             else
             else
               begin
               begin
-                cg.ungetregister(exprasmlist,NR_FUNCTION_RESULT_REG);
+                cg.ungetregister(exprasmlist,resultloc.register);
                 hregister := cg.getaddressregister(exprasmlist);
                 hregister := cg.getaddressregister(exprasmlist);
-                cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,hregister);
+                cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,resultloc.register,hregister);
                 { in case of a regular funcretnode with ret_in_param, the }
                 { in case of a regular funcretnode with ret_in_param, the }
                 { original funcretnode isn't touched -> make sure it's    }
                 { original funcretnode isn't touched -> make sure it's    }
                 { the same here (not sure if it's necessary)              }
                 { the same here (not sure if it's necessary)              }
@@ -530,98 +514,88 @@ implementation
                 tempnode.pass_2;
                 tempnode.pass_2;
                 location := tempnode.location;
                 location := tempnode.location;
                 tempnode.free;
                 tempnode.free;
-                cg.g_decrrefcount(exprasmlist,resulttype.def,location.reference, false);
+                cg.g_decrrefcount(exprasmlist,resulttype.def,location.reference,false);
                 cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference);
                 cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference);
                 cg.ungetregister(exprasmlist,hregister);
                 cg.ungetregister(exprasmlist,hregister);
              end;
              end;
           end
           end
-        else
         { we have only to handle the result if it is used }
         { we have only to handle the result if it is used }
-         if (cnf_return_value_used in callnodeflags) then
+        else if (cnf_return_value_used in callnodeflags) then
           begin
           begin
-            if (resulttype.def.deftype=floatdef) then
-              begin
-                location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-{$ifdef cpufpemu}
-                if cs_fp_emulation in aktmoduleswitches then
-                  location.register:=NR_FUNCTION_RESULT_REG
-                else
-{$endif cpufpemu}
-                  begin
-                    location.register:=NR_FPU_RESULT_REG;
-{$ifdef sparc}
-                    { Double are returned in F0:F1 }
-                    if location.size=OS_F64 then
-                      setsubreg(location.register,R_SUBFD);
-{$endif sparc}
-                  end;
+            location.loc:=resultloc.loc;
+            case resultloc.loc of
+               LOC_FPUREGISTER:
+                 begin
+                   location_reset(location,LOC_FPUREGISTER,cgsize);
+                   location.register:=procdefinition.funcret_paraloc[callerside].register;
 {$ifdef x86}
 {$ifdef x86}
-                tcgx86(cg).inc_fpu_stack;
+                   tcgx86(cg).inc_fpu_stack;
 {$else x86}
 {$else x86}
-                cg.ungetregister(exprasmlist,location.register);
-                hregister := cg.getfpuregister(exprasmlist,location.size);
-                cg.a_loadfpu_reg_reg(exprasmlist,location.size,location.register,hregister);
-                location.register := hregister;
+                   cg.ungetregister(exprasmlist,location.register);
+                   hregister:=cg.getfpuregister(exprasmlist,location.size);
+                   cg.a_loadfpu_reg_reg(exprasmlist,location.size,location.register,hregister);
+                   location.register:=hregister;
 {$endif x86}
 {$endif x86}
-              end
-            else
-              begin
-                cgsize:=def_cgsize(resulttype.def);
-                if cgsize<>OS_NO then
+                 end;
+
+               LOC_REGISTER:
                  begin
                  begin
-                   location_reset(location,LOC_REGISTER,cgsize);
-{$ifndef cpu64bit}
-                   if cgsize in [OS_64,OS_S64] then
+                   if cgsize<>OS_NO then
                     begin
                     begin
-                      { Move the function result to free registers, preferably the
-                        FUNCTION_RESULT_REG/FUNCTION_RESULTHIGH_REG, so no move is necessary.}
-                      { the FUNCTION_RESULT_LOW_REG/FUNCTION_RESULT_HIGH_REG
-                        are already allocated }
-                      cg.ungetregister(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG);
-                      location.registerlow:=cg.getintregister(exprasmlist,OS_INT);
-                      cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,NR_FUNCTION_RESULT64_LOW_REG,location.registerlow);
-                      cg.ungetregister(exprasmlist,NR_FUNCTION_RESULT64_HIGH_REG);
-                      location.registerhigh:=cg.getintregister(exprasmlist,OS_INT);
-                      cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,NR_FUNCTION_RESULT64_HIGH_REG,location.registerhigh);
+                      location_reset(location,LOC_REGISTER,cgsize);
+{$ifndef cpu64bit}
+                      if cgsize in [OS_64,OS_S64] then
+                       begin
+                         { Move the function result to free registers, preferably the
+                           FUNCTION_RESULT_REG/FUNCTION_RESULTHIGH_REG, so no move is necessary.}
+                         { the FUNCTION_RESULT_LOW_REG/FUNCTION_RESULT_HIGH_REG
+                           are already allocated }
+                         cg.ungetregister(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG);
+                         location.registerlow:=cg.getintregister(exprasmlist,OS_32);
+                         cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,NR_FUNCTION_RESULT64_LOW_REG,location.registerlow);
+                         cg.ungetregister(exprasmlist,NR_FUNCTION_RESULT64_HIGH_REG);
+                         location.registerhigh:=cg.getintregister(exprasmlist,OS_32);
+                         cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,NR_FUNCTION_RESULT64_HIGH_REG,location.registerhigh);
+                       end
+                      else
+{$endif cpu64bit}
+                       begin
+                         { Move the function result to a free register, preferably the
+                           FUNCTION_RESULT_REG, so no move is necessary.}
+                         { the FUNCTION_RESULT_REG is already allocated }
+                         cg.ungetregister(exprasmlist,resultloc.register);
+                         { change register size after the unget because the
+                           getregister was done for the full register
+
+                           def_cgsize(resulttype.def) is used here because
+                           it could be a constructor call }
+                         location.register:=cg.getintregister(exprasmlist,def_cgsize(resulttype.def));
+                         cg.a_load_reg_reg(exprasmlist,cgsize,def_cgsize(resulttype.def),resultloc.register,location.register);
+                       end;
                     end
                     end
                    else
                    else
-{$endif cpu64bit}
                     begin
                     begin
-                      {Move the function result to a free register, preferably the
-                       FUNCTION_RESULT_REG, so no move is necessary.}
-                      { the FUNCTION_RESULT_REG is already allocated }
-                      cg.ungetregister(exprasmlist,NR_FUNCTION_RESULT_REG);
-                      { change register size after the unget because the
-                      getregister was done for the full register }
-                      location.register:=cg.getintregister(exprasmlist,cgsize);
-                      cg.a_load_reg_reg(exprasmlist,cgsize,cgsize,cg.makeregsize(exprasmlist,NR_FUNCTION_RESULT_REG,cgsize),location.register);
+                      if resulttype.def.size>0 then
+                        internalerror(200305131);
                     end;
                     end;
-                 end
-                else
+                 end;
+
+               LOC_MMREGISTER:
                  begin
                  begin
-                   if resulttype.def.size>0 then
-                     internalerror(200305131);
+                   location_reset(location,LOC_MMREGISTER,cgsize);
+                   cg.ungetregister(exprasmlist,resultloc.register);
+                   location.register:=cg.getmmregister(exprasmlist,cgsize);
+                   cg.a_loadmm_reg_reg(exprasmlist,cgsize,cgsize,resultloc.register,location.register,mms_movescalar);
                  end;
                  end;
-              end;
+
+               else
+                 internalerror(200405023);
+             end;
           end
           end
         else
         else
           begin
           begin
-            cgsize:=def_cgsize(resulttype.def);
-
-            { an object constructor is a function with pointer result }
-            if (procdefinition.proctypeoption=potype_constructor) then
-              cgsize:=OS_ADDR;
-
             if cgsize<>OS_NO then
             if cgsize<>OS_NO then
-{$ifndef cpu64bit}
-              if cgsize in [OS_64,OS_S64] then
-                begin
-                  cg.ungetregister(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG);
-                  cg.ungetregister(exprasmlist,NR_FUNCTION_RESULT64_HIGH_REG);
-                end
-              else
-{$endif cpu64bit}
-                cg.ungetregister(exprasmlist,NR_FUNCTION_RESULT_REG);
+              paramanager.freeparaloc(exprasmlist,resultloc);
             location_reset(location,LOC_VOID,OS_NO);
             location_reset(location,LOC_VOID,OS_NO);
           end;
           end;
       end;
       end;
@@ -666,10 +640,6 @@ implementation
          regs_to_push_fpu,
          regs_to_push_fpu,
          regs_to_alloc,
          regs_to_alloc,
          regs_to_free : Tcpuregisterset;
          regs_to_free : Tcpuregisterset;
-         oldpushedparasize : longint;
-{$ifdef cputargethasfixedstack}
-         href2,
-{$endif cputargethasfixedstack}
          href : treference;
          href : treference;
          pop_size : longint;
          pop_size : longint;
          pvreg,
          pvreg,
@@ -739,22 +709,17 @@ implementation
                            LOC_REFERENCE:
                            LOC_REFERENCE:
                              begin
                              begin
                                reference_reset_base(href,ppn.tempparaloc.reference.index,ppn.tempparaloc.reference.offset);
                                reference_reset_base(href,ppn.tempparaloc.reference.index,ppn.tempparaloc.reference.offset);
-                               reference_reset_base(href2,ppn.paraitem.paraloc[callerside].reference.index,ppn.paraitem.paraloc[callerside].reference.offset);
-                               cg.g_concatcopy(exprasmlist,href,href2,ppn.paraitem.paratype.def.size,false,false);
+                               if ppn.paraitem.paraloc[callerside].size=OS_NO then
+                                 cg.a_param_copy_ref(exprasmlist,ppn.paraitem.paratype.def.size,href,ppn.paraitem.paraloc[callerside])
+                               else
+                                 cg.a_param_ref(exprasmlist,ppn.paraitem.paraloc[callerside].size,href,ppn.paraitem.paraloc[callerside]);
                              end;
                              end;
                            LOC_REGISTER:
                            LOC_REGISTER:
+{$ifndef cpu64bit}
                              if ppn.tempparaloc.size in [OS_64,OS_S64] then
                              if ppn.tempparaloc.size in [OS_64,OS_S64] then
-                               begin
-                                 reference_reset_base(href,ppn.paraitem.paraloc[callerside].reference.index,ppn.paraitem.paraloc[callerside].reference.offset);
-                                 cg.a_load_reg_ref(exprasmlist,OS_32,OS_32,ppn.tempparaloc.registerlow,
-                                    href);
-                                 { we don't use a c64.load here because later (when fixed ;)) one dword could be on the stack and the
-                                   other in a cpu register }
-                                 reference_reset_base(href,ppn.paraitem.paraloc[callerside].reference.index,ppn.paraitem.paraloc[callerside].reference.offset+4);
-                                 cg.a_load_reg_ref(exprasmlist,OS_32,OS_32,ppn.tempparaloc.registerhigh,
-                                    href);
-                               end
+                               cg64.a_param64_reg(exprasmlist,ppn.tempparaloc.register64,ppn.paraitem.paraloc[callerside])
                              else
                              else
+{$endif cpu64bit}
                                cg.a_param_reg(exprasmlist,ppn.paraitem.paraloc[callerside].size,ppn.tempparaloc.register,ppn.paraitem.paraloc[callerside]);
                                cg.a_param_reg(exprasmlist,ppn.paraitem.paraloc[callerside].size,ppn.tempparaloc.register,ppn.paraitem.paraloc[callerside]);
                            LOC_FPUREGISTER:
                            LOC_FPUREGISTER:
                              cg.a_paramfpu_reg(exprasmlist,ppn.paraitem.paraloc[callerside].size,ppn.tempparaloc.register,ppn.paraitem.paraloc[callerside]);
                              cg.a_paramfpu_reg(exprasmlist,ppn.paraitem.paraloc[callerside].size,ppn.tempparaloc.register,ppn.paraitem.paraloc[callerside]);
@@ -822,15 +787,11 @@ implementation
                 end;
                 end;
               LOC_MMREGISTER,LOC_CMMREGISTER:
               LOC_MMREGISTER,LOC_CMMREGISTER:
                 begin
                 begin
-                  internalerror(2003102911);
+                  include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].register));
                 end;
                 end;
             end;
             end;
           end;
           end;
 
 
-         { Initialize for pushing the parameters }
-         oldpushedparasize:=pushedparasize;
-         pushedparasize:=0;
-
          { Process parameters, register parameters will be loaded
          { Process parameters, register parameters will be loaded
            in imaginary registers. The actual load to the correct
            in imaginary registers. The actual load to the correct
            register is done just before the call }
            register is done just before the call }
@@ -840,9 +801,6 @@ implementation
            tcallparanode(left).secondcallparan;
            tcallparanode(left).secondcallparan;
          aktcallnode:=oldaktcallnode;
          aktcallnode:=oldaktcallnode;
 
 
-         { Align stack if required }
-         pop_size:=align_parasize;
-
          { procedure variable or normal function call ? }
          { procedure variable or normal function call ? }
          if (right=nil) then
          if (right=nil) then
            begin
            begin
@@ -973,24 +931,15 @@ implementation
          { Need to remove the parameters from the stack? }
          { Need to remove the parameters from the stack? }
          if (procdefinition.proccalloption in clearstack_pocalls) then
          if (procdefinition.proccalloption in clearstack_pocalls) then
           begin
           begin
-            { the old pop_size was already included in pushedparasize }
             pop_size:=pushedparasize;
             pop_size:=pushedparasize;
             { for Cdecl functions we don't need to pop the funcret when it
             { for Cdecl functions we don't need to pop the funcret when it
               was pushed by para }
               was pushed by para }
             if paramanager.ret_in_param(procdefinition.rettype.def,procdefinition.proccalloption) then
             if paramanager.ret_in_param(procdefinition.rettype.def,procdefinition.proccalloption) then
-              dec(pop_size,POINTER_SIZE);
+              dec(pop_size,sizeof(aint));
+            { Remove parameters/alignment from the stack }
+            pop_parasize(pop_size);
           end;
           end;
 
 
-         { Remove parameters/alignment from the stack }
-         if pop_size>0 then
-           pop_parasize(pop_size);
-
-         { Reserve space for storing parameters that will be pushed }
-         current_procinfo.allocate_push_parasize(pushedparasize);
-
-         { Restore }
-         pushedparasize:=oldpushedparasize;
-
          { Release registers, but not the registers that contain the
          { Release registers, but not the registers that contain the
            function result }
            function result }
          regs_to_free:=regs_to_alloc;
          regs_to_free:=regs_to_alloc;
@@ -1071,7 +1020,6 @@ implementation
          oldprocinfo : tprocinfo;
          oldprocinfo : tprocinfo;
          oldinlining_procedure : boolean;
          oldinlining_procedure : boolean;
          inlineentrycode,inlineexitcode : TAAsmoutput;
          inlineentrycode,inlineexitcode : TAAsmoutput;
-         usesacc,usesacchi,usesfpu : boolean;
 {$ifdef GDB}
 {$ifdef GDB}
          startlabel,endlabel : tasmlabel;
          startlabel,endlabel : tasmlabel;
          pp : pchar;
          pp : pchar;
@@ -1173,7 +1121,7 @@ implementation
 
 
          cg.a_label(exprasmlist,current_procinfo.aktexitlabel);
          cg.a_label(exprasmlist,current_procinfo.aktexitlabel);
          gen_finalize_code(inlineexitcode,true);
          gen_finalize_code(inlineexitcode,true);
-         gen_load_return_value(inlineexitcode,usesacc,usesacchi,usesfpu);
+         gen_load_return_value(inlineexitcode);
          if po_assembler in current_procinfo.procdef.procoptions then
          if po_assembler in current_procinfo.procdef.procoptions then
            inlineexitcode.concat(Tai_marker.Create(asmblockend));
            inlineexitcode.concat(Tai_marker.Create(asmblockend));
          exprasmlist.concatlist(inlineexitcode);
          exprasmlist.concatlist(inlineexitcode);
@@ -1278,7 +1226,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.167  2004-05-23 18:28:41  peter
+  Revision 1.168  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.167  2004/05/23 18:28:41  peter
     * methodpointer is loaded into a temp when it was a calln
     * methodpointer is loaded into a temp when it was a calln
 
 
   Revision 1.166  2004/05/22 23:34:27  peter
   Revision 1.166  2004/05/22 23:34:27  peter
@@ -1287,6 +1238,48 @@ end.
   Revision 1.165  2004/04/28 15:19:03  florian
   Revision 1.165  2004/04/28 15:19:03  florian
     + syscall directive support for MorphOS added
     + syscall directive support for MorphOS added
 
 
+  Revision 1.164.2.13  2004/06/12 17:01:01  florian
+    * fixed compilation of arm compiler
+
+  Revision 1.164.2.12  2004/05/31 16:39:42  peter
+    * add ungetiftemp in a few locations
+
+  Revision 1.164.2.11  2004/05/30 17:07:07  peter
+    * fix shl shr for sparc
+
+  Revision 1.164.2.10  2004/05/02 21:17:39  florian
+    * fixed boolean test of constructors
+
+  Revision 1.164.2.9  2004/05/02 21:07:29  florian
+    * fixed constructor results
+
+  Revision 1.164.2.8  2004/05/02 20:56:54  florian
+    * more fixes to handle_return_value update
+
+  Revision 1.164.2.7  2004/05/02 20:20:59  florian
+    * started to fix callee side result value handling
+
+  Revision 1.164.2.6  2004/05/02 19:08:01  florian
+    * rewrote tcgcallnode.handle_return_value
+
+  Revision 1.164.2.5  2004/05/02 14:09:35  peter
+    * use size of paraloc when copying reference, only when size is OS_NO
+      use the size of the type
+
+  Revision 1.164.2.4  2004/05/02 12:45:32  peter
+    * enabled cpuhasfixedstack for x86-64 again
+    * fixed size of temp allocation for parameters
+
+  Revision 1.164.2.3  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.164.2.2  2004/05/01 11:12:23  florian
+    * spilling of registers with size<>4 fixed
+
+  Revision 1.164.2.1  2004/04/27 18:18:25  peter
+    * aword -> aint
+
   Revision 1.164  2004/03/14 20:10:56  peter
   Revision 1.164  2004/03/14 20:10:56  peter
     * disable some debuginfo info when valgrind support is used
     * disable some debuginfo info when valgrind support is used
 
 
@@ -1971,5 +1964,4 @@ end.
 
 
   Revision 1.2  2002/07/13 19:38:43  florian
   Revision 1.2  2002/07/13 19:38:43  florian
     * some more generic calling stuff fixed
     * some more generic calling stuff fixed
-
-}
+}

+ 10 - 4
compiler/ncgcnv.pas

@@ -452,9 +452,9 @@ interface
            begin
            begin
               if hd.implementedinterfaces.searchintf(resulttype.def)<>-1 then
               if hd.implementedinterfaces.searchintf(resulttype.def)<>-1 then
                 begin
                 begin
-                   cg.a_op_const_reg(exprasmlist,OP_ADD,OS_ADDR,aword(
+                   cg.a_op_const_reg(exprasmlist,OP_ADD,OS_ADDR,
                      hd.implementedinterfaces.ioffsets(
                      hd.implementedinterfaces.ioffsets(
-                       hd.implementedinterfaces.searchintf(resulttype.def))^),location.register);
+                       hd.implementedinterfaces.searchintf(resulttype.def))^,location.register);
                    break;
                    break;
                 end;
                 end;
               hd:=hd.childof;
               hd:=hd.childof;
@@ -539,9 +539,15 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.57  2004-04-29 19:56:37  daniel
+  Revision 1.58  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.57  2004/04/29 19:56:37  daniel
     * Prepare compiler infrastructure for multiple ansistring types
     * Prepare compiler infrastructure for multiple ansistring types
 
 
+  Revision 1.56.2.1  2004/04/27 18:18:25  peter
+    * aword -> aint
+
   Revision 1.56  2004/03/02 00:36:33  olle
   Revision 1.56  2004/03/02 00:36:33  olle
     * big transformation of Tai_[const_]Symbol.Create[data]name*
     * big transformation of Tai_[const_]Symbol.Create[data]name*
 
 
@@ -758,4 +764,4 @@ end.
     * fixed returnvalue handling
     * fixed returnvalue handling
     * fixed default stacksize of linux and go32v2, 8kb was a bit small :-)
     * fixed default stacksize of linux and go32v2, 8kb was a bit small :-)
 
 
-}
+}

+ 66 - 34
compiler/ncgcon.pas

@@ -67,10 +67,11 @@ implementation
       verbose,globals,
       verbose,globals,
       symconst,symdef,aasmbase,aasmtai,aasmcpu,defutil,
       symconst,symdef,aasmbase,aasmtai,aasmcpu,defutil,
       cpuinfo,cpubase,
       cpuinfo,cpubase,
-      cgbase,cgobj
+      cgbase,cgobj,
 {$ifdef delphi}
 {$ifdef delphi}
       ,dmisc
       ,dmisc
 {$endif}
 {$endif}
+      ncgutil
       ;
       ;
 
 
 
 
@@ -141,9 +142,8 @@ implementation
                begin
                begin
                   objectlibrary.getdatalabel(lastlabel);
                   objectlibrary.getdatalabel(lastlabel);
                   lab_real:=lastlabel;
                   lab_real:=lastlabel;
-                  if (cs_create_smart in aktmoduleswitches) then
-                   Consts.concat(Tai_cut.Create);
-                  consts.concat(tai_align.create(const_align(resulttype.def.size)));
+                  maybe_new_object_file(consts);
+                  new_section(consts,sec_rodata,lastlabel.name,const_align(resulttype.def.size));
                   Consts.concat(Tai_label.Create(lastlabel));
                   Consts.concat(Tai_label.Create(lastlabel));
                   case realait of
                   case realait of
                     ait_real_32bit :
                     ait_real_32bit :
@@ -190,7 +190,11 @@ implementation
     procedure tcgordconstnode.pass_2;
     procedure tcgordconstnode.pass_2;
       begin
       begin
          location_reset(location,LOC_CONSTANT,def_cgsize(resulttype.def));
          location_reset(location,LOC_CONSTANT,def_cgsize(resulttype.def));
-         location.valueqword:=TConstExprUInt(value);
+{$ifdef cpu64bit}
+         location.value:=value;
+{$else cpu64bit}
+         location.value64:=int64(value);
+{$endif cpu64bit}
       end;
       end;
 
 
 
 
@@ -202,7 +206,7 @@ implementation
       begin
       begin
          { an integer const. behaves as a memory reference }
          { an integer const. behaves as a memory reference }
          location_reset(location,LOC_CONSTANT,OS_ADDR);
          location_reset(location,LOC_CONSTANT,OS_ADDR);
-         location.value:=AWord(value);
+         location.value:=aint(value);
       end;
       end;
 
 
 
 
@@ -339,23 +343,23 @@ implementation
                                        { before the string the following sequence must be found:
                                        { before the string the following sequence must be found:
                                          <label>
                                          <label>
                                            constsymbol <datalabel>
                                            constsymbol <datalabel>
-                                           const32 <len>
-                                           const32 <len>
-                                           const32 -1
+                                           constint <len>
+                                           constint <len>
+                                           constint -1
                                          we must then return <label> to reuse
                                          we must then return <label> to reuse
                                        }
                                        }
                                        hp2:=tai(lastlabelhp.previous);
                                        hp2:=tai(lastlabelhp.previous);
                                        if assigned(hp2) and
                                        if assigned(hp2) and
-                                          (hp2.typ=ait_const_32bit) and
-                                          (tai_const(hp2).value=aword(-1)) and
+                                          (hp2.typ=ait_const_aint) and
+                                          (tai_const(hp2).value=-1) and
                                           assigned(hp2.previous) and
                                           assigned(hp2.previous) and
-                                          (tai(hp2.previous).typ=ait_const_32bit) and
+                                          (tai(hp2.previous).typ=ait_const_aint) and
                                           (tai_const(hp2.previous).value=len) and
                                           (tai_const(hp2.previous).value=len) and
                                           assigned(hp2.previous.previous) and
                                           assigned(hp2.previous.previous) and
-                                          (tai(hp2.previous.previous).typ=ait_const_32bit) and
+                                          (tai(hp2.previous.previous).typ=ait_const_aint) and
                                           (tai_const(hp2.previous.previous).value=len) and
                                           (tai_const(hp2.previous.previous).value=len) and
                                           assigned(hp2.previous.previous.previous) and
                                           assigned(hp2.previous.previous.previous) and
-                                          (tai(hp2.previous.previous.previous).typ=ait_const_symbol) and
+                                          (tai(hp2.previous.previous.previous).typ=ait_const_ptr) and
                                           assigned(hp2.previous.previous.previous.previous) and
                                           assigned(hp2.previous.previous.previous.previous) and
                                           (tai(hp2.previous.previous.previous.previous).typ=ait_label) then
                                           (tai(hp2.previous.previous.previous.previous).typ=ait_label) then
                                          begin
                                          begin
@@ -438,9 +442,8 @@ implementation
                 begin
                 begin
                    objectlibrary.getdatalabel(lastlabel);
                    objectlibrary.getdatalabel(lastlabel);
                    lab_str:=lastlabel;
                    lab_str:=lastlabel;
-                   if (cs_create_smart in aktmoduleswitches) then
-                    Consts.concat(Tai_cut.Create);
-                   consts.concat(tai_align.create(const_align(4)));
+                   maybe_new_object_file(consts);
+                   new_section(consts,sec_rodata,lastlabel.name,const_align(sizeof(aint)));
                    Consts.concat(Tai_label.Create(lastlabel));
                    Consts.concat(Tai_label.Create(lastlabel));
                    { generate an ansi string ? }
                    { generate an ansi string ? }
                    case st_type of
                    case st_type of
@@ -475,16 +478,16 @@ implementation
                         begin
                         begin
                            { an empty ansi string is nil! }
                            { an empty ansi string is nil! }
                            if len=0 then
                            if len=0 then
-                             Consts.concat(Tai_const.Create_ptr(0))
+                             Consts.concat(Tai_const.Create_sym(nil))
                            else
                            else
                              begin
                              begin
                                 objectlibrary.getdatalabel(l1);
                                 objectlibrary.getdatalabel(l1);
                                 objectlibrary.getdatalabel(l2);
                                 objectlibrary.getdatalabel(l2);
                                 Consts.concat(Tai_label.Create(l2));
                                 Consts.concat(Tai_label.Create(l2));
-                                Consts.concat(Tai_const_symbol.Create(l1));
-                                Consts.concat(Tai_const.Create_32bit(len));
-                                Consts.concat(Tai_const.Create_32bit(len));
-                                Consts.concat(Tai_const.Create_32bit(Cardinal(-1)));
+                                Consts.concat(Tai_const.Create_sym(l1));
+                                Consts.concat(Tai_const.Create_aint(len));
+                                Consts.concat(Tai_const.Create_aint(len));
+                                Consts.concat(Tai_const.Create_aint(-1));
                                 Consts.concat(Tai_label.Create(l1));
                                 Consts.concat(Tai_label.Create(l1));
                                 getmem(pc,len+2);
                                 getmem(pc,len+2);
                                 move(value_str^,pc^,len);
                                 move(value_str^,pc^,len);
@@ -527,20 +530,20 @@ implementation
                         begin
                         begin
                            { an empty wide string is nil! }
                            { an empty wide string is nil! }
                            if len=0 then
                            if len=0 then
-                             Consts.concat(Tai_const.Create_ptr(0))
+                             Consts.concat(Tai_const.Create_sym(nil))
                            else
                            else
                              begin
                              begin
                                 objectlibrary.getdatalabel(l1);
                                 objectlibrary.getdatalabel(l1);
                                 objectlibrary.getdatalabel(l2);
                                 objectlibrary.getdatalabel(l2);
                                 Consts.concat(Tai_label.Create(l2));
                                 Consts.concat(Tai_label.Create(l2));
-                                Consts.concat(Tai_const_symbol.Create(l1));
+                                Consts.concat(Tai_const.Create_sym(l1));
 
 
                                 { we use always UTF-16 coding for constants }
                                 { we use always UTF-16 coding for constants }
                                 { at least for now                          }
                                 { at least for now                          }
                                 { Consts.concat(Tai_const.Create_8bit(2)); }
                                 { Consts.concat(Tai_const.Create_8bit(2)); }
-                                Consts.concat(Tai_const.Create_32bit(len));
-                                Consts.concat(Tai_const.Create_32bit(len));
-                                Consts.concat(Tai_const.Create_32bit(Cardinal(-1)));
+                                Consts.concat(Tai_const.Create_aint(len));
+                                Consts.concat(Tai_const.Create_aint(len));
+                                Consts.concat(Tai_const.Create_aint(-1));
                                 Consts.concat(Tai_label.Create(l1));
                                 Consts.concat(Tai_label.Create(l1));
                                 for i:=0 to len-1 do
                                 for i:=0 to len-1 do
                                   Consts.concat(Tai_const.Create_16bit(pcompilerwidestring(value_str)^.data[i]));
                                   Consts.concat(Tai_const.Create_16bit(pcompilerwidestring(value_str)^.data[i]));
@@ -599,7 +602,7 @@ implementation
         if tsetdef(resulttype.def).settype=smallset then
         if tsetdef(resulttype.def).settype=smallset then
          begin
          begin
            location_reset(location,LOC_CONSTANT,OS_32);
            location_reset(location,LOC_CONSTANT,OS_32);
-           location.value:=PAWord(value_set)^;
+           location.value:=PAInt(value_set)^;
            exit;
            exit;
          end;
          end;
         location_reset(location,LOC_CREFERENCE,OS_NO);
         location_reset(location,LOC_CREFERENCE,OS_NO);
@@ -643,7 +646,7 @@ implementation
                           else
                           else
                            begin
                            begin
                              { compare small set }
                              { compare small set }
-                             if paword(value_set)^=tai_const(hp1).value then
+                             if paint(value_set)^=tai_const(hp1).value then
                               begin
                               begin
                                 { found! }
                                 { found! }
                                 lab_set:=lastlabel;
                                 lab_set:=lastlabel;
@@ -660,9 +663,8 @@ implementation
                begin
                begin
                  objectlibrary.getdatalabel(lastlabel);
                  objectlibrary.getdatalabel(lastlabel);
                  lab_set:=lastlabel;
                  lab_set:=lastlabel;
-                 if (cs_create_smart in aktmoduleswitches) then
-                  Consts.concat(Tai_cut.Create);
-                 consts.concat(tai_align.create(const_align(4)));
+                 maybe_new_object_file(consts);
+                 new_section(consts,sec_rodata,lastlabel.name,const_align(sizeof(aint)));
                  Consts.concat(Tai_label.Create(lastlabel));
                  Consts.concat(Tai_label.Create(lastlabel));
                  { already handled at the start of this method?? (JM)
                  { already handled at the start of this method?? (JM)
                  if tsetdef(resulttype.def).settype=smallset then
                  if tsetdef(resulttype.def).settype=smallset then
@@ -727,9 +729,40 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.40  2004-04-29 19:56:37  daniel
+  Revision 1.41  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.40  2004/04/29 19:56:37  daniel
     * Prepare compiler infrastructure for multiple ansistring types
     * Prepare compiler infrastructure for multiple ansistring types
 
 
+  Revision 1.39.2.9  2004/06/13 10:51:16  florian
+    * fixed several register allocator problems (sparc/arm)
+
+  Revision 1.39.2.8  2004/06/12 17:01:01  florian
+    * fixed compilation of arm compiler
+
+  Revision 1.39.2.7  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.39.2.6  2004/04/29 19:07:22  peter
+    * compile fixes
+
+  Revision 1.39.2.5  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.39.2.4  2004/04/12 19:34:45  peter
+    * basic framework for dwarf CFI
+
+  Revision 1.39.2.3  2004/04/12 14:45:11  peter
+    * tai_const_symbol and tai_const merged
+
+  Revision 1.39.2.2  2004/04/10 12:36:41  peter
+    * fixed alignment issues
+
+  Revision 1.39.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
   Revision 1.39  2004/03/18 17:29:40  peter
   Revision 1.39  2004/03/18 17:29:40  peter
     * fix overflow
     * fix overflow
 
 
@@ -896,4 +929,3 @@ end.
 
 
 
 
 
 
-

+ 20 - 10
compiler/ncgflw.pas

@@ -79,8 +79,6 @@ interface
           procedure pass_2;override;
           procedure pass_2;override;
        end;
        end;
 
 
-
-
 implementation
 implementation
 
 
     uses
     uses
@@ -411,7 +409,7 @@ implementation
              if lnf_testatbegin in loopflags then
              if lnf_testatbegin in loopflags then
                begin
                begin
                  cg.a_cmp_const_loc_label(exprasmlist,opsize,hcond,
                  cg.a_cmp_const_loc_label(exprasmlist,opsize,hcond,
-                   aword(tordconstnode(right).value),
+                   tordconstnode(right).value,
                    t2.location,aktbreaklabel);
                    t2.location,aktbreaklabel);
                end;
                end;
            end;
            end;
@@ -981,7 +979,7 @@ implementation
               }
               }
               paraloc1:=paramanager.getintparaloc(pocall_default,1);
               paraloc1:=paramanager.getintparaloc(pocall_default,1);
               paramanager.allocparaloc(exprasmlist,paraloc1);
               paramanager.allocparaloc(exprasmlist,paraloc1);
-              cg.a_param_const(exprasmlist,OS_ADDR,aword(-1),paraloc1);
+              cg.a_param_const(exprasmlist,OS_ADDR,-1,paraloc1);
               paramanager.freeparaloc(exprasmlist,paraloc1);
               paramanager.freeparaloc(exprasmlist,paraloc1);
               cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
               cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
               cg.a_call_name(exprasmlist,'FPC_CATCHES');
               cg.a_call_name(exprasmlist,'FPC_CATCHES');
@@ -1161,7 +1159,7 @@ implementation
          if assigned(exceptsymtable) then
          if assigned(exceptsymtable) then
            begin
            begin
              tvarsym(exceptsymtable.symindex.first).localloc.loc:=LOC_REFERENCE;
              tvarsym(exceptsymtable.symindex.first).localloc.loc:=LOC_REFERENCE;
-             tg.GetLocal(exprasmlist,POINTER_SIZE,voidpointertype.def,
+             tg.GetLocal(exprasmlist,sizeof(aint),voidpointertype.def,
                 tvarsym(exceptsymtable.symindex.first).localloc.reference);
                 tvarsym(exceptsymtable.symindex.first).localloc.reference);
              reference_reset_base(href2,tvarsym(exceptsymtable.symindex.first).localloc.reference.index,
              reference_reset_base(href2,tvarsym(exceptsymtable.symindex.first).localloc.reference.index,
                 tvarsym(exceptsymtable.symindex.first).localloc.reference.offset);
                 tvarsym(exceptsymtable.symindex.first).localloc.reference.offset);
@@ -1169,13 +1167,12 @@ implementation
            end
            end
          else
          else
            begin
            begin
-             tg.GetTemp(exprasmlist,POINTER_SIZE,tt_normal,exceptref);
+             tg.GetTemp(exprasmlist,sizeof(aint),tt_normal,exceptref);
              cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,exceptref);
              cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,exceptref);
            end;
            end;
 
 
-
-         { in the case that another exception is risen }
-         { we've to destroy the old one                }
+         { in the case that another exception is risen
+           we've to destroy the old one                }
          objectlibrary.getlabel(doobjectdestroyandreraise);
          objectlibrary.getlabel(doobjectdestroyandreraise);
 
 
          { call setjmp, and jump to finally label on non-zero result }
          { call setjmp, and jump to finally label on non-zero result }
@@ -1443,7 +1440,20 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.95  2004-03-29 14:43:47  peter
+  Revision 1.96  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.95.2.3  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.95.2.2  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.95.2.1  2004/04/24 20:13:24  florian
+    * fixed x86-64 exception handling
+
+  Revision 1.95  2004/03/29 14:43:47  peter
     * cleaner temp get/unget for exceptions
     * cleaner temp get/unget for exceptions
 
 
   Revision 1.94  2004/03/02 00:36:33  olle
   Revision 1.94  2004/03/02 00:36:33  olle

+ 69 - 46
compiler/ncginl.pas

@@ -243,7 +243,10 @@ implementation
          hrefvmt   : treference;
          hrefvmt   : treference;
          hregister : tregister;
          hregister : tregister;
       begin
       begin
-        location_reset(location,LOC_REGISTER,OS_ADDR);
+        if inlinenumber=in_sizeof_x then
+          location_reset(location,LOC_REGISTER,OS_INT)
+        else
+          location_reset(location,LOC_REGISTER,OS_ADDR);
         { for both cases load vmt }
         { for both cases load vmt }
         if left.nodetype=typen then
         if left.nodetype=typen then
           begin
           begin
@@ -327,15 +330,15 @@ implementation
          end
          end
         else
         else
          begin
          begin
-           { length in ansi strings is at offset -8 }
+           { length in ansi strings is at offset sizeof(aint)*2 }
            location_force_reg(exprasmlist,left.location,OS_ADDR,false);
            location_force_reg(exprasmlist,left.location,OS_ADDR,false);
            objectlibrary.getlabel(lengthlab);
            objectlibrary.getlabel(lengthlab);
            cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,left.location.register,lengthlab);
            cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,left.location.register,lengthlab);
-           reference_reset_base(href,left.location.register,-8);
-           hregister:=cg.makeregsize(exprasmlist,left.location.register,OS_32);
-           cg.a_load_ref_reg(exprasmlist,OS_32,OS_32,href,hregister);
+           reference_reset_base(href,left.location.register,-sizeof(aint)*2);
+           hregister:=cg.makeregsize(exprasmlist,left.location.register,OS_INT);
+           cg.a_load_ref_reg(exprasmlist,OS_INT,OS_INT,href,hregister);
            cg.a_label(exprasmlist,lengthlab);
            cg.a_label(exprasmlist,lengthlab);
-           location_reset(location,LOC_REGISTER,OS_32);
+           location_reset(location,LOC_REGISTER,OS_INT);
            location.register:=hregister;
            location.register:=hregister;
          end;
          end;
       end;
       end;
@@ -361,10 +364,11 @@ implementation
         location_copy(location,left.location);
         location_copy(location,left.location);
         location_force_reg(exprasmlist,location,cgsize,false);
         location_force_reg(exprasmlist,location,cgsize,false);
 
 
+{$ifndef cpu64bit}
         if cgsize in [OS_64,OS_S64] then
         if cgsize in [OS_64,OS_S64] then
-          cg64.a_op64_const_reg(exprasmlist,cgop,1,
-                      location.register64)
+          cg64.a_op64_const_reg(exprasmlist,cgop,1,location.register64)
         else
         else
+{$endif cpu64bit}
           cg.a_op_const_reg(exprasmlist,cgop,location.size,1,location.register);
           cg.a_op_const_reg(exprasmlist,cgop,location.size,1,location.register);
 
 
         cg.g_rangecheck(exprasmlist,location,resulttype.def,resulttype.def);
         cg.g_rangecheck(exprasmlist,location,resulttype.def,resulttype.def);
@@ -429,12 +433,13 @@ implementation
           { write the add instruction }
           { write the add instruction }
           if addconstant then
           if addconstant then
             begin
             begin
+{$ifndef cpu64bit}
               if cgsize in [OS_64,OS_S64] then
               if cgsize in [OS_64,OS_S64] then
-               cg64.a_op64_const_loc(exprasmlist,addsubop[inlinenumber],
-                  addvalue,tcallparanode(left).left.location)
+                cg64.a_op64_const_loc(exprasmlist,addsubop[inlinenumber],addvalue,tcallparanode(left).left.location)
               else
               else
-               cg.a_op_const_loc(exprasmlist,addsubop[inlinenumber],
-                  aword(addvalue),tcallparanode(left).left.location);
+{$endif cpu64bit}
+                cg.a_op_const_loc(exprasmlist,addsubop[inlinenumber],
+                  addvalue,tcallparanode(left).left.location);
             end
             end
            else
            else
              begin
              begin
@@ -475,19 +480,21 @@ implementation
 
 
       procedure tcginlinenode.second_IncludeExclude;
       procedure tcginlinenode.second_IncludeExclude;
         var
         var
-          L : longint;
+          bitsperop,l : longint;
+          opsize : tcgsize;
           cgop : topcg;
           cgop : topcg;
           addrreg2,addrreg,
           addrreg2,addrreg,
           hregister,hregister2: tregister;
           hregister,hregister2: tregister;
           use_small : boolean;
           use_small : boolean;
-          cgsize : tcgsize;
           href : treference;
           href : treference;
         begin
         begin
+          opsize:=OS_32;
+          bitsperop:=(8*tcgsize2size[opsize]);
           secondpass(tcallparanode(left).left);
           secondpass(tcallparanode(left).left);
           if tcallparanode(tcallparanode(left).right).left.nodetype=ordconstn then
           if tcallparanode(tcallparanode(left).right).left.nodetype=ordconstn then
             begin
             begin
               { calculate bit position }
               { calculate bit position }
-              l:=1 shl (tordconstnode(tcallparanode(tcallparanode(left).right).left).value mod 32);
+              l:=1 shl (tordconstnode(tcallparanode(tcallparanode(left).right).left).value mod bitsperop);
 
 
               { determine operator }
               { determine operator }
               if inlinenumber=in_include_x_y then
               if inlinenumber=in_include_x_y then
@@ -497,18 +504,19 @@ implementation
                   cgop:=OP_AND;
                   cgop:=OP_AND;
                   l:=not(l);
                   l:=not(l);
                 end;
                 end;
-              if (tcallparanode(left).left.location.loc=LOC_REFERENCE) then
-                begin
-                  inc(tcallparanode(left).left.location.reference.offset,
-                    (tordconstnode(tcallparanode(tcallparanode(left).right).left).value div 32)*4);
-                  cg.a_op_const_ref(exprasmlist,cgop,OS_INT,aword(l),tcallparanode(left).left.location.reference);
-                  location_release(exprasmlist,tcallparanode(left).left.location);
-                end
-              else
-                { LOC_CREGISTER }
-                begin
-                  cg.a_op_const_reg(exprasmlist,cgop,tcallparanode(left).left.location.size,aword(l),tcallparanode(left).left.location.register);
-                end;
+              case tcallparanode(left).left.location.loc of
+                LOC_REFERENCE :
+                  begin
+                    inc(tcallparanode(left).left.location.reference.offset,
+                      (tordconstnode(tcallparanode(tcallparanode(left).right).left).value div bitsperop)*tcgsize2size[opsize]);
+                    cg.a_op_const_ref(exprasmlist,cgop,opsize,l,tcallparanode(left).left.location.reference);
+                    location_release(exprasmlist,tcallparanode(left).left.location);
+                  end;
+                LOC_CREGISTER :
+                  cg.a_op_const_reg(exprasmlist,cgop,tcallparanode(left).left.location.size,l,tcallparanode(left).left.location.register);
+                else
+                  internalerror(200405021);
+              end;
             end
             end
           else
           else
             begin
             begin
@@ -526,17 +534,17 @@ implementation
               secondpass(tcallparanode(tcallparanode(left).right).left);
               secondpass(tcallparanode(tcallparanode(left).right).left);
 
 
               { bitnumber - which must be loaded into register }
               { bitnumber - which must be loaded into register }
-              hregister:=cg.getintregister(exprasmlist,OS_32);
-              hregister2:=cg.getintregister(exprasmlist,OS_32);
+              hregister:=cg.getintregister(exprasmlist,opsize);
+              hregister2:=cg.getintregister(exprasmlist,opsize);
 
 
-              cg.a_load_loc_reg(exprasmlist,OS_32,
+              cg.a_load_loc_reg(exprasmlist,opsize,
                   tcallparanode(tcallparanode(left).right).left.location,hregister);
                   tcallparanode(tcallparanode(left).right).left.location,hregister);
 
 
               if use_small then
               if use_small then
                 begin
                 begin
                   { hregister contains the bitnumber to add }
                   { hregister contains the bitnumber to add }
-                  cg.a_load_const_reg(exprasmlist, OS_32, 1, hregister2);
-                  cg.a_op_reg_reg(exprasmlist, OP_SHL, OS_32, hregister, hregister2);
+                  cg.a_load_const_reg(exprasmlist, opsize, 1, hregister2);
+                  cg.a_op_reg_reg(exprasmlist, OP_SHL, opsize, hregister, hregister2);
 
 
                   { possiblities :
                   { possiblities :
                        bitnumber : LOC_REFERENCE, LOC_REGISTER, LOC_CREGISTER
                        bitnumber : LOC_REFERENCE, LOC_REGISTER, LOC_CREGISTER
@@ -547,13 +555,13 @@ implementation
                     begin
                     begin
                       if inlinenumber=in_include_x_y then
                       if inlinenumber=in_include_x_y then
                         begin
                         begin
-                          cg.a_op_reg_ref(exprasmlist, OP_OR, OS_32, hregister2,
+                          cg.a_op_reg_ref(exprasmlist, OP_OR, opsize, hregister2,
                           tcallparanode(left).left.location.reference);
                           tcallparanode(left).left.location.reference);
                         end
                         end
                       else
                       else
                         begin
                         begin
-                          cg.a_op_reg_reg(exprasmlist, OP_NOT, OS_32, hregister2,hregister2);
-                          cg.a_op_reg_ref(exprasmlist, OP_AND, OS_32, hregister2,
+                          cg.a_op_reg_reg(exprasmlist, OP_NOT, opsize, hregister2,hregister2);
+                          cg.a_op_reg_ref(exprasmlist, OP_AND, opsize, hregister2,
                               tcallparanode(left).left.location.reference);
                               tcallparanode(left).left.location.reference);
                         end;
                         end;
                     end
                     end
@@ -569,30 +577,30 @@ implementation
                   { hregister contains the bitnumber (div 32 to get the correct offset) }
                   { hregister contains the bitnumber (div 32 to get the correct offset) }
                   { hregister contains the bitnumber to add }
                   { hregister contains the bitnumber to add }
 
 
-                  cg.a_op_const_reg_reg(exprasmlist, OP_SHR, OS_32, 5, hregister,hregister2);
-                  cg.a_op_const_reg(exprasmlist, OP_SHL, OS_32, 2, hregister2);
+                  cg.a_op_const_reg_reg(exprasmlist, OP_SHR, opsize, 5, hregister,hregister2);
+                  cg.a_op_const_reg(exprasmlist, OP_SHL, opsize, 2, hregister2);
                   addrreg:=cg.getaddressregister(exprasmlist);
                   addrreg:=cg.getaddressregister(exprasmlist);
                   { we need an extra address register to be able to do an ADD operation }
                   { we need an extra address register to be able to do an ADD operation }
                   addrreg2:=cg.getaddressregister(exprasmlist);
                   addrreg2:=cg.getaddressregister(exprasmlist);
-                  cg.a_load_reg_reg(exprasmlist,OS_32,OS_ADDR,hregister2,addrreg2);
+                  cg.a_load_reg_reg(exprasmlist,opsize,OS_ADDR,hregister2,addrreg2);
                   { calculate the correct address of the operand }
                   { calculate the correct address of the operand }
                   cg.a_loadaddr_ref_reg(exprasmlist, tcallparanode(left).left.location.reference,addrreg);
                   cg.a_loadaddr_ref_reg(exprasmlist, tcallparanode(left).left.location.reference,addrreg);
-                  cg.a_op_reg_reg(exprasmlist, OP_ADD, OS_32, addrreg2, addrreg);
+                  cg.a_op_reg_reg(exprasmlist, OP_ADD, OS_ADDR, addrreg2, addrreg);
                   cg.ungetregister(exprasmlist,addrreg2);
                   cg.ungetregister(exprasmlist,addrreg2);
 
 
                   { hregister contains the bitnumber to add }
                   { hregister contains the bitnumber to add }
-                  cg.a_load_const_reg(exprasmlist, OS_32, 1, hregister2);
-                  cg.a_op_const_reg(exprasmlist, OP_AND, OS_32, 31, hregister);
-                  cg.a_op_reg_reg(exprasmlist, OP_SHL, OS_32, hregister, hregister2);
+                  cg.a_load_const_reg(exprasmlist, opsize, 1, hregister2);
+                  cg.a_op_const_reg(exprasmlist, OP_AND, opsize, 31, hregister);
+                  cg.a_op_reg_reg(exprasmlist, OP_SHL, opsize, hregister, hregister2);
 
 
                   reference_reset_base(href,addrreg,0);
                   reference_reset_base(href,addrreg,0);
 
 
                   if inlinenumber=in_include_x_y then
                   if inlinenumber=in_include_x_y then
-                    cg.a_op_reg_ref(exprasmlist, OP_OR, OS_32, hregister2, href)
+                    cg.a_op_reg_ref(exprasmlist, OP_OR, opsize, hregister2, href)
                   else
                   else
                     begin
                     begin
-                      cg.a_op_reg_reg(exprasmlist, OP_NOT, OS_32, hregister2, hregister2);
-                      cg.a_op_reg_ref(exprasmlist, OP_AND, OS_32, hregister2, href);
+                      cg.a_op_reg_reg(exprasmlist, OP_NOT, opsize, hregister2, hregister2);
+                      cg.a_op_reg_ref(exprasmlist, OP_AND, opsize, hregister2, href);
                     end;
                     end;
                   cg.ungetregister(exprasmlist,addrreg);
                   cg.ungetregister(exprasmlist,addrreg);
                 end;
                 end;
@@ -678,12 +686,27 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.58  2004-05-30 21:18:22  jonas
+  Revision 1.59  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.58  2004/05/30 21:18:22  jonas
     * some optimizations and associated fixes for better regvar code
     * some optimizations and associated fixes for better regvar code
 
 
   Revision 1.57  2004/05/22 23:34:28  peter
   Revision 1.57  2004/05/22 23:34:28  peter
   tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
   tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
 
 
+  Revision 1.56.2.4  2004/05/02 16:49:12  peter
+    * 64 bit fixes
+
+  Revision 1.56.2.3  2004/05/01 16:35:51  florian
+    * fixed length(<ansi/widestring>) for 64 Bit CPUs
+
+  Revision 1.56.2.2  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.56.2.1  2004/04/26 21:02:34  peter
+    * 64bit fixes
+
   Revision 1.56  2004/03/02 00:36:33  olle
   Revision 1.56  2004/03/02 00:36:33  olle
     * big transformation of Tai_[const_]Symbol.Create[data]name*
     * big transformation of Tai_[const_]Symbol.Create[data]name*
 
 

+ 52 - 16
compiler/ncgld.pas

@@ -56,7 +56,7 @@ implementation
       aasmbase,aasmtai,aasmcpu,
       aasmbase,aasmtai,aasmcpu,
       cgbase,pass_2,
       cgbase,pass_2,
       procinfo,
       procinfo,
-      cpubase,cpuinfo,
+      cpubase,
       tgobj,ncgutil,
       tgobj,ncgutil,
       cgutils,cgobj,
       cgutils,cgobj,
       ncgbas;
       ncgbas;
@@ -110,7 +110,7 @@ implementation
                    begin
                    begin
                       location_reset(location,LOC_CREFERENCE,OS_ADDR);
                       location_reset(location,LOC_CREFERENCE,OS_ADDR);
                       location.reference.symbol:=objectlibrary.newasmsymbol(make_mangledname('RESOURCESTRINGLIST',tconstsym(symtableentry).owner,''),AB_EXTERNAL,AT_DATA);
                       location.reference.symbol:=objectlibrary.newasmsymbol(make_mangledname('RESOURCESTRINGLIST',tconstsym(symtableentry).owner,''),AB_EXTERNAL,AT_DATA);
-                      location.reference.offset:=tconstsym(symtableentry).resstrindex*16+8;
+                      location.reference.offset:=tconstsym(symtableentry).resstrindex*(4+sizeof(aint)*3)+4+sizeof(aint);
                    end
                    end
                  else
                  else
                    internalerror(22798);
                    internalerror(22798);
@@ -188,7 +188,7 @@ implementation
                          layout of a threadvar is (4 bytes pointer):
                          layout of a threadvar is (4 bytes pointer):
                            0 - Threadvar index
                            0 - Threadvar index
                            4 - Threadvar value in single threading }
                            4 - Threadvar value in single threading }
-                       reference_reset_symbol(href,objectlibrary.newasmsymbol(tvarsym(symtableentry).mangledname,AB_EXTERNAL,AT_DATA),POINTER_SIZE);
+                       reference_reset_symbol(href,objectlibrary.newasmsymbol(tvarsym(symtableentry).mangledname,AB_EXTERNAL,AT_DATA),sizeof(aint));
                        cg.a_loadaddr_ref_reg(exprasmlist,href,hregister);
                        cg.a_loadaddr_ref_reg(exprasmlist,href,hregister);
                        cg.a_label(exprasmlist,endrelocatelab);
                        cg.a_label(exprasmlist,endrelocatelab);
                        location.reference.base:=hregister;
                        location.reference.base:=hregister;
@@ -296,13 +296,13 @@ implementation
                         to OS_64 - how to solve?? Carl
                         to OS_64 - how to solve?? Carl
                         Solved. Florian
                         Solved. Florian
                       }
                       }
-                      if (sizeof(aword) = 4) then
+                      if (sizeof(aint) = 4) then
                          location_reset(location,LOC_CREFERENCE,OS_64)
                          location_reset(location,LOC_CREFERENCE,OS_64)
-                      else if (sizeof(aword) = 8) then
+                      else if (sizeof(aint) = 8) then
                          location_reset(location,LOC_CREFERENCE,OS_128)
                          location_reset(location,LOC_CREFERENCE,OS_128)
                       else
                       else
                          internalerror(20020520);
                          internalerror(20020520);
-                      tg.GetTemp(exprasmlist,2*POINTER_SIZE,tt_normal,location.reference);
+                      tg.GetTemp(exprasmlist,2*sizeof(aint),tt_normal,location.reference);
                       secondpass(left);
                       secondpass(left);
 
 
                       { load class instance address }
                       { load class instance address }
@@ -332,7 +332,7 @@ implementation
 
 
                       { store the class instance address }
                       { store the class instance address }
                       href:=location.reference;
                       href:=location.reference;
-                      inc(href.offset,POINTER_SIZE);
+                      inc(href.offset,sizeof(aint));
                       cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,href);
                       cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,href);
 
 
                       { virtual method ? }
                       { virtual method ? }
@@ -552,10 +552,11 @@ implementation
             case right.location.loc of
             case right.location.loc of
               LOC_CONSTANT :
               LOC_CONSTANT :
                 begin
                 begin
+{$ifndef cpu64bit}
                   if right.location.size in [OS_64,OS_S64] then
                   if right.location.size in [OS_64,OS_S64] then
-                   cg64.a_load64_const_loc(exprasmlist,
-                       right.location.valueqword,left.location)
+                   cg64.a_load64_const_loc(exprasmlist,right.location.value64,left.location)
                   else
                   else
+{$endif cpu64bit}
                    cg.a_load_const_loc(exprasmlist,right.location.value,left.location);
                    cg.a_load_const_loc(exprasmlist,right.location.value,left.location);
                 end;
                 end;
               LOC_REFERENCE,
               LOC_REFERENCE,
@@ -565,6 +566,7 @@ implementation
                     LOC_CREGISTER :
                     LOC_CREGISTER :
                       begin
                       begin
                         cgsize:=def_cgsize(left.resulttype.def);
                         cgsize:=def_cgsize(left.resulttype.def);
+{$ifndef cpu64bit}
                         if cgsize in [OS_64,OS_S64] then
                         if cgsize in [OS_64,OS_S64] then
                           begin
                           begin
                             cg64.a_load64_ref_reg(exprasmlist,
                             cg64.a_load64_ref_reg(exprasmlist,
@@ -572,6 +574,7 @@ implementation
                             location_release(exprasmlist,right.location);
                             location_release(exprasmlist,right.location);
                           end
                           end
                         else
                         else
+{$endif cpu64bit}
                           begin
                           begin
                             location_release(exprasmlist,right.location);
                             location_release(exprasmlist,right.location);
                             cg.a_load_ref_reg(exprasmlist,cgsize,cgsize,
                             cg.a_load_ref_reg(exprasmlist,cgsize,cgsize,
@@ -626,10 +629,12 @@ implementation
               LOC_CREGISTER :
               LOC_CREGISTER :
                 begin
                 begin
                   cgsize:=def_cgsize(left.resulttype.def);
                   cgsize:=def_cgsize(left.resulttype.def);
+{$ifndef cpu64bit}
                   if cgsize in [OS_64,OS_S64] then
                   if cgsize in [OS_64,OS_S64] then
                     cg64.a_load64_reg_loc(exprasmlist,
                     cg64.a_load64_reg_loc(exprasmlist,
                       right.location.register64,left.location)
                       right.location.register64,left.location)
                   else
                   else
+{$endif cpu64bit}
                     cg.a_load_reg_loc(exprasmlist,right.location.size,right.location.register,left.location);
                     cg.a_load_reg_loc(exprasmlist,right.location.size,right.location.register,left.location);
                 end;
                 end;
               LOC_FPUREGISTER,LOC_CFPUREGISTER :
               LOC_FPUREGISTER,LOC_CFPUREGISTER :
@@ -692,6 +697,7 @@ implementation
 
 
         if releaseright then
         if releaseright then
           location_release(exprasmlist,right.location);
           location_release(exprasmlist,right.location);
+        location_freetemp(exprasmlist,right.location);
         location_release(exprasmlist,left.location);
         location_release(exprasmlist,left.location);
 
 
         truelabel:=otlabel;
         truelabel:=otlabel;
@@ -740,9 +746,9 @@ implementation
       begin
       begin
         dovariant:=(nf_forcevaria in flags) or tarraydef(resulttype.def).isvariant;
         dovariant:=(nf_forcevaria in flags) or tarraydef(resulttype.def).isvariant;
         if dovariant then
         if dovariant then
-         elesize:=8
+          elesize:=sizeof(aint)+sizeof(aint)
         else
         else
-         elesize:=tarraydef(resulttype.def).elesize;
+          elesize:=tarraydef(resulttype.def).elesize;
         location_reset(location,LOC_CREFERENCE,OS_NO);
         location_reset(location,LOC_CREFERENCE,OS_NO);
         fillchar(paraloc,sizeof(paraloc),0);
         fillchar(paraloc,sizeof(paraloc),0);
         { Allocate always a temp, also if no elements are required, to
         { Allocate always a temp, also if no elements are required, to
@@ -866,7 +872,7 @@ implementation
                  if vtype=$ff then
                  if vtype=$ff then
                    internalerror(14357);
                    internalerror(14357);
                  { write changing field update href to the next element }
                  { write changing field update href to the next element }
-                 inc(href.offset,4);
+                 inc(href.offset,sizeof(aint));
                  if vaddr then
                  if vaddr then
                   begin
                   begin
                     location_force_mem(exprasmlist,hp.left.location);
                     location_force_mem(exprasmlist,hp.left.location);
@@ -884,10 +890,10 @@ implementation
                     cg.a_load_loc_ref(exprasmlist,OS_ADDR,hp.left.location,href);
                     cg.a_load_loc_ref(exprasmlist,OS_ADDR,hp.left.location,href);
                   end;
                   end;
                  { update href to the vtype field and write it }
                  { update href to the vtype field and write it }
-                 dec(href.offset,4);
+                 dec(href.offset,sizeof(aint));
                  cg.a_load_const_ref(exprasmlist, OS_INT,vtype,href);
                  cg.a_load_const_ref(exprasmlist, OS_INT,vtype,href);
                  { goto next array element }
                  { goto next array element }
-                 inc(href.offset,8);
+                 inc(href.offset,sizeof(aint)*2);
                end
                end
               else
               else
               { normal array constructor of the same type }
               { normal array constructor of the same type }
@@ -915,12 +921,14 @@ implementation
                      end;
                      end;
                    else
                    else
                      begin
                      begin
+{$ifndef cpu64bit}
                        if hp.left.location.size in [OS_64,OS_S64] then
                        if hp.left.location.size in [OS_64,OS_S64] then
                          begin
                          begin
                            cg64.a_load64_loc_ref(exprasmlist,hp.left.location,href);
                            cg64.a_load64_loc_ref(exprasmlist,hp.left.location,href);
                            location_release(exprasmlist,hp.left.location);
                            location_release(exprasmlist,hp.left.location);
                          end
                          end
                        else
                        else
+{$endif cpu64bit}
                          begin
                          begin
                            location_release(exprasmlist,hp.left.location);
                            location_release(exprasmlist,hp.left.location);
                            cg.a_load_loc_ref(exprasmlist,hp.left.location.size,hp.left.location,href);
                            cg.a_load_loc_ref(exprasmlist,hp.left.location.size,hp.left.location,href);
@@ -942,12 +950,40 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.116  2004-05-22 23:34:28  peter
+  Revision 1.117  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.116  2004/05/22 23:34:28  peter
   tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
   tai_regalloc.allocation changed to ratype to notify rgobj of register size changes
 
 
   Revision 1.115  2004/04/29 19:56:37  daniel
   Revision 1.115  2004/04/29 19:56:37  daniel
     * Prepare compiler infrastructure for multiple ansistring types
     * Prepare compiler infrastructure for multiple ansistring types
 
 
+  Revision 1.114.2.8  2004/06/13 10:51:16  florian
+    * fixed several register allocator problems (sparc/arm)
+
+  Revision 1.114.2.7  2004/06/12 17:01:01  florian
+    * fixed compilation of arm compiler
+
+  Revision 1.114.2.6  2004/05/31 16:39:42  peter
+    * add ungetiftemp in a few locations
+
+  Revision 1.114.2.5  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.114.2.4  2004/04/29 20:51:25  florian
+    * tvarrec generation fixed
+
+  Revision 1.114.2.3  2004/04/29 19:07:22  peter
+    * compile fixes
+
+  Revision 1.114.2.2  2004/04/28 19:23:00  florian
+    * resource string offset calculation for 64 bit fixed
+
+  Revision 1.114.2.1  2004/04/27 18:18:25  peter
+    * aword -> aint
+
   Revision 1.114  2004/03/02 17:32:12  florian
   Revision 1.114  2004/03/02 17:32:12  florian
     * make cycle fixed
     * make cycle fixed
     + pic support for darwin
     + pic support for darwin
@@ -1413,4 +1449,4 @@ end.
   * bugfix of hdisponen (base must be set, not index)
   * bugfix of hdisponen (base must be set, not index)
   * more portability fixes
   * more portability fixes
 
 
-}
+}

+ 38 - 67
compiler/ncgmat.pas

@@ -82,6 +82,7 @@ interface
            been done and emitted, so this should really a do a modulo.
            been done and emitted, so this should really a do a modulo.
          }
          }
          procedure emit_mod_reg_reg(signed: boolean;denum,num : tregister);virtual;abstract;
          procedure emit_mod_reg_reg(signed: boolean;denum,num : tregister);virtual;abstract;
+{$ifndef cpu64bit}
          { This routine must do an actual 64-bit division, be it
          { This routine must do an actual 64-bit division, be it
            signed or unsigned. The result must set into the the
            signed or unsigned. The result must set into the the
            @var(num) register.
            @var(num) register.
@@ -96,6 +97,7 @@ interface
            64-bit systems, otherwise a helper is called in 1st pass.
            64-bit systems, otherwise a helper is called in 1st pass.
          }
          }
          procedure emit64_div_reg_reg(signed: boolean;denum,num : tregister64);virtual;
          procedure emit64_div_reg_reg(signed: boolean;denum,num : tregister64);virtual;
+{$endif cpu64bit}
       end;
       end;
 
 
       tcgshlshrnode = class(tshlshrnode)
       tcgshlshrnode = class(tshlshrnode)
@@ -126,10 +128,9 @@ implementation
     uses
     uses
       globtype,systems,
       globtype,systems,
       cutils,verbose,globals,
       cutils,verbose,globals,
-      symconst,symdef,aasmbase,aasmtai,aasmcpu,defutil,
-      pass_1,pass_2,
+      symconst,aasmbase,aasmtai,aasmcpu,defutil,
+      pass_2,
       ncon,
       ncon,
-      cpuinfo,
       tgobj,ncgutil,cgobj,paramgr
       tgobj,ncgutil,cgobj,paramgr
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
       ,cg64f32
       ,cg64f32
@@ -142,8 +143,8 @@ implementation
 
 
     procedure tcgunaryminusnode.emit_float_sign_change(r: tregister; _size : tcgsize);
     procedure tcgunaryminusnode.emit_float_sign_change(r: tregister; _size : tcgsize);
       var
       var
-        href : treference;
-        hreg : tregister;
+        href,
+        href2 : treference;
       begin
       begin
         { get a temporary memory reference to store the floating
         { get a temporary memory reference to store the floating
           point value
           point value
@@ -151,38 +152,22 @@ implementation
         tg.gettemp(exprasmlist,tcgsize2size[_size],tt_normal,href);
         tg.gettemp(exprasmlist,tcgsize2size[_size],tt_normal,href);
         { store the floating point value in the temporary memory area }
         { store the floating point value in the temporary memory area }
         cg.a_loadfpu_reg_ref(exprasmlist,_size,r,href);
         cg.a_loadfpu_reg_ref(exprasmlist,_size,r,href);
-        { only single and double ieee are supported }
-        if _size = OS_F64 then
-          begin
-            { on little-endian machine the most significant
-              32-bit value is stored at the highest address
-            }
-            if target_info.endian = endian_little then
-              inc(href.offset,4);
-          end
-        else
-        if _size <> OS_F32 then
-           internalerror(20020814);
-        hreg := cg.getintregister(exprasmlist,OS_32);
-        { load value }
-        cg.a_load_ref_reg(exprasmlist,OS_32,OS_32,href,hreg);
-        { bitwise complement copied value }
-        cg.a_op_reg_reg(exprasmlist,OP_NOT,OS_32,hreg,hreg);
-        { sign-bit is bit 31/63 of single/double }
-        cg.a_op_const_reg(exprasmlist,OP_AND,OS_32,aword($80000000),hreg);
-        { or with value in reference memory }
-        cg.a_op_reg_ref(exprasmlist,OP_OR,OS_32,hreg,href);
-        cg.ungetregister(exprasmlist,hreg);
-        { store the floating point value in the temporary memory area }
-        if _size = OS_F64 then
-          begin
-            { on little-endian machine the most significant
-              32-bit value is stored at the highest address
-            }
+        { only single and double ieee are supported, for little endian
+          the signed bit is in the second dword }
+        href2:=href;
+        case _size of
+          OS_F64 :
             if target_info.endian = endian_little then
             if target_info.endian = endian_little then
-              dec(href.offset,4);
-          end;
+              inc(href2.offset,4);
+          OS_F32 :
+            ;
+          else
+            internalerror(200406021);
+        end;
+        { flip sign-bit (bit 31/63) of single/double }
+        cg.a_op_const_ref(exprasmlist,OP_XOR,OS_32,aint($80000000),href2);
         cg.a_loadfpu_ref_reg(exprasmlist,_size,href,r);
         cg.a_loadfpu_ref_reg(exprasmlist,_size,href,r);
+        tg.ungetiftemp(exprasmlist,href);
       end;
       end;
 
 
 
 
@@ -263,6 +248,7 @@ implementation
                              TCGMODDIVNODE
                              TCGMODDIVNODE
 *****************************************************************************}
 *****************************************************************************}
 
 
+{$ifndef cpu64bit}
     procedure tcgmoddivnode.emit64_div_reg_reg(signed: boolean; denum,num:tregister64);
     procedure tcgmoddivnode.emit64_div_reg_reg(signed: boolean; denum,num:tregister64);
       begin
       begin
         { handled in pass_1 already, unless pass_1 is
         { handled in pass_1 already, unless pass_1 is
@@ -271,6 +257,7 @@ implementation
         { should be handled in pass_1 (JM) }
         { should be handled in pass_1 (JM) }
         internalerror(200109052);
         internalerror(200109052);
       end;
       end;
+{$endif cpu64bit}
 
 
 
 
     procedure tcgmoddivnode.pass_2;
     procedure tcgmoddivnode.pass_2;
@@ -370,40 +357,9 @@ implementation
 
 
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
     procedure tcgshlshrnode.second_64bit;
     procedure tcgshlshrnode.second_64bit;
-      var
-         freescratch : boolean;
-         op : topcg;
       begin
       begin
-{$ifdef cpu64bit}
-         freescratch:=false;
-         secondpass(left);
-         secondpass(right);
-         { determine operator }
-         case nodetype of
-           shln: op:=OP_SHL;
-           shrn: op:=OP_SHR;
-         end;
-         freescratch:=false;
-         location_reset(location,LOC_REGISTER,OS_64);
-
-         { load left operator in a register }
-         location_force_reg(exprasmlist,left.location,OS_64,false);
-         location_copy(location,left.location);
-
-         if (right.nodetype=ordconstn) then
-           begin
-              cg64.a_op64_const_reg(exprasmlist,op,tordconstnode(right).value,
-                joinreg64(location.registerlow,location.registerhigh));
-           end
-         else
-           begin
-             { this should be handled in pass_1 }
-             internalerror(2002081501);
-           end;
-{$else cpu64bit}
          { already hanled in 1st pass }
          { already hanled in 1st pass }
          internalerror(2002081501);
          internalerror(2002081501);
-{$endif cpu64bit}
       end;
       end;
 {$endif cpu64bit}
 {$endif cpu64bit}
 
 
@@ -524,7 +480,22 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.25  2004-01-23 15:12:49  florian
+  Revision 1.26  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.25.2.4  2004/06/02 19:04:51  peter
+    * fixed minusunary for float
+
+  Revision 1.25.2.3  2004/05/31 16:39:42  peter
+    * add ungetiftemp in a few locations
+
+  Revision 1.25.2.2  2004/05/30 17:07:07  peter
+    * fix shl shr for sparc
+
+  Revision 1.25.2.1  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.25  2004/01/23 15:12:49  florian
     * fixed generic shl/shr operations
     * fixed generic shl/shr operations
     + added register allocation hook calls for arm specific operand types:
     + added register allocation hook calls for arm specific operand types:
       register set and shifter op
       register set and shifter op

+ 29 - 10
compiler/ncgmem.pas

@@ -30,7 +30,7 @@ unit ncgmem;
 interface
 interface
 
 
     uses
     uses
-      cgbase,cpuinfo,cpubase,
+      globtype,cgbase,cpuinfo,cpubase,
       node,nmem;
       node,nmem;
 
 
     type
     type
@@ -69,7 +69,7 @@ interface
            This routine should update location.reference correctly,
            This routine should update location.reference correctly,
            so it points to the correct address.
            so it points to the correct address.
          }
          }
-         procedure update_reference_reg_mul(reg:tregister;l:aword);virtual;
+         procedure update_reference_reg_mul(reg:tregister;l:aint);virtual;
          procedure second_wideansistring;virtual;
          procedure second_wideansistring;virtual;
          procedure second_dynamicarray;virtual;
          procedure second_dynamicarray;virtual;
        public
        public
@@ -88,7 +88,7 @@ implementation
 {$ifdef GDB}
 {$ifdef GDB}
       gdb,
       gdb,
 {$endif GDB}
 {$endif GDB}
-      globtype,systems,
+      systems,
       cutils,verbose,globals,
       cutils,verbose,globals,
       symconst,symdef,symsym,defutil,paramgr,
       symconst,symdef,symsym,defutil,paramgr,
       aasmbase,aasmtai,
       aasmbase,aasmtai,
@@ -296,8 +296,9 @@ implementation
             paramanager.allocparaloc(exprasmlist,paraloc1);
             paramanager.allocparaloc(exprasmlist,paraloc1);
             cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,paraloc1);
             cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,paraloc1);
             paramanager.freeparaloc(exprasmlist,paraloc1);
             paramanager.freeparaloc(exprasmlist,paraloc1);
-            { FPC_CHECKPOINTER uses saveregisters }
+            cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
             cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER');
             cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER');
+            cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
           end;
           end;
       end;
       end;
 
 
@@ -350,8 +351,9 @@ implementation
                 paramanager.allocparaloc(exprasmlist,paraloc1);
                 paramanager.allocparaloc(exprasmlist,paraloc1);
                 cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,paraloc1);
                 cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,paraloc1);
                 paramanager.freeparaloc(exprasmlist,paraloc1);
                 paramanager.freeparaloc(exprasmlist,paraloc1);
-                { FPC_CHECKPOINTER uses saveregisters }
+                cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
                 cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER');
                 cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER');
+                cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
               end;
               end;
            end
            end
          else if is_interfacecom(left.resulttype.def) then
          else if is_interfacecom(left.resulttype.def) then
@@ -367,8 +369,9 @@ implementation
                 paramanager.allocparaloc(exprasmlist,paraloc1);
                 paramanager.allocparaloc(exprasmlist,paraloc1);
                 cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,paraloc1);
                 cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,paraloc1);
                 paramanager.freeparaloc(exprasmlist,paraloc1);
                 paramanager.freeparaloc(exprasmlist,paraloc1);
-                { FPC_CHECKPOINTER uses saveregisters }
+                cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
                 cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER');
                 cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER');
+                cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
               end;
               end;
            end
            end
          else
          else
@@ -471,7 +474,7 @@ implementation
        end;
        end;
 
 
 
 
-     procedure tcgvecnode.update_reference_reg_mul(reg:tregister;l:aword);
+     procedure tcgvecnode.update_reference_reg_mul(reg:tregister;l:aint);
        var
        var
          hreg: tregister;
          hreg: tregister;
        begin
        begin
@@ -535,7 +538,7 @@ implementation
                { generate compares }
                { generate compares }
                freereg:=false;
                freereg:=false;
                if (right.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
                if (right.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
-                 hreg:=right.location.register
+                 hreg:=cg.makeregsize(exprasmlist,right.location.register,OS_INT)
                else
                else
                  begin
                  begin
                    hreg:=cg.getintregister(exprasmlist,OS_INT);
                    hreg:=cg.getintregister(exprasmlist,OS_INT);
@@ -891,7 +894,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.91  2004-04-29 19:56:37  daniel
+  Revision 1.92  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.91  2004/04/29 19:56:37  daniel
     * Prepare compiler infrastructure for multiple ansistring types
     * Prepare compiler infrastructure for multiple ansistring types
 
 
   Revision 1.90  2004/04/21 17:39:40  jonas
   Revision 1.90  2004/04/21 17:39:40  jonas
@@ -899,6 +905,19 @@ end.
       at the same time confused the register allocator and therefore also
       at the same time confused the register allocator and therefore also
       the optimizer. May be fixed in the future using dwarf support
       the optimizer. May be fixed in the future using dwarf support
 
 
+  Revision 1.89.2.4  2004/05/10 21:28:34  peter
+    * section_smartlink enabled for gas under linux
+
+  Revision 1.89.2.3  2004/05/02 13:04:28  peter
+    * ofs fixed
+
+  Revision 1.89.2.2  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.89.2.1  2004/04/27 18:18:25  peter
+    * aword -> aint
+
   Revision 1.89  2004/03/02 00:36:33  olle
   Revision 1.89  2004/03/02 00:36:33  olle
     * big transformation of Tai_[const_]Symbol.Create[data]name*
     * big transformation of Tai_[const_]Symbol.Create[data]name*
 
 
@@ -1264,7 +1283,7 @@ end.
   * fix generic size problems which depend now on EXTEND_SIZE constant
   * fix generic size problems which depend now on EXTEND_SIZE constant
 
 
   Revision 1.7  2002/04/15 18:58:47  carl
   Revision 1.7  2002/04/15 18:58:47  carl
-  + target_info.size_of_pointer -> pointer_Size
+  + target_info.size_of_pointer -> sizeof(aint)
 
 
   Revision 1.6  2002/04/04 19:05:57  peter
   Revision 1.6  2002/04/04 19:05:57  peter
     * removed unused units
     * removed unused units

+ 107 - 102
compiler/ncgset.pas

@@ -27,7 +27,8 @@ unit ncgset;
 interface
 interface
 
 
     uses
     uses
-       node,nset,cpubase,cgbase,cgobj,aasmbase,aasmtai,globals;
+       globtype,globals,
+       node,nset,cpubase,cgbase,cgobj,aasmbase,aasmtai;
 
 
     type
     type
        tcgsetelementnode = class(tsetelementnode)
        tcgsetelementnode = class(tsetelementnode)
@@ -72,9 +73,9 @@ interface
           { has the implementation jumptable support }
           { has the implementation jumptable support }
           min_label : tconstexprint;
           min_label : tconstexprint;
 
 
-          procedure optimizevalues(var max_linear_list:longint;var max_dist:cardinal);virtual;
+          procedure optimizevalues(var max_linear_list:aint;var max_dist:aword);virtual;
           function  has_jumptable : boolean;virtual;
           function  has_jumptable : boolean;virtual;
-          procedure genjumptable(hp : pcaserecord;min_,max_ : longint); virtual;
+          procedure genjumptable(hp : pcaserecord;min_,max_ : aint); virtual;
           procedure genlinearlist(hp : pcaserecord); virtual;
           procedure genlinearlist(hp : pcaserecord); virtual;
           procedure genlinearcmplist(hp : pcaserecord); virtual;
           procedure genlinearcmplist(hp : pcaserecord); virtual;
           procedure gentreejmp(p : pcaserecord);
           procedure gentreejmp(p : pcaserecord);
@@ -84,7 +85,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      globtype,systems,
+      systems,
       verbose,
       verbose,
       symconst,symdef,defutil,
       symconst,symdef,defutil,
       paramgr,
       paramgr,
@@ -143,14 +144,23 @@ implementation
       { be caught when range checking is on! (JM)                        }
       { be caught when range checking is on! (JM)                        }
       { cg.a_op_const_reg(list,OP_AND,31,bitnumber);                     }
       { cg.a_op_const_reg(list,OP_AND,31,bitnumber);                     }
 
 
-      if (bitsize <> OS_32) then
-        internalerror(2004053010);
-      newres := cg.makeregsize(list,res,OS_32);
-      { rotate value register "bitnumber" bits to the right }
-      cg.a_op_reg_reg_reg(list,OP_SHR,OS_32,bitnumber,value,newres);
-      { extract the bit we want }
-      cg.a_op_const_reg(list,OP_AND,OS_32,1,newres);
-      cg.a_load_reg_reg(list,OS_32,ressize,newres,res);
+      if bitsize<>ressize then
+        begin
+          { FIX ME! We're not allowed to modify the value register here! }
+
+          { shift value register "bitnumber" bits to the right }
+          cg.a_op_reg_reg(list,OP_SHR,bitsize,bitnumber,value);
+          { extract the bit we want }
+          cg.a_op_const_reg(list,OP_AND,bitsize,1,value);
+          cg.a_load_reg_reg(list,bitsize,ressize,value,res);
+        end
+      else
+        begin
+          { rotate value register "bitnumber" bits to the right }
+          cg.a_op_reg_reg_reg(list,OP_SHR,bitsize,bitnumber,value,res);
+          { extract the bit we want }
+          cg.a_op_const_reg(list,OP_AND,bitsize,1,res);
+        end;
     end;
     end;
 
 
 
 
@@ -161,16 +171,15 @@ implementation
            start,stop : byte;    {Start/stop when range; Stop=element when an element.}
            start,stop : byte;    {Start/stop when range; Stop=element when an element.}
          end;
          end;
        var
        var
-         l,l2,l3       : tasmlabel;
-         adjustment : longint;
+         l,l3       : tasmlabel;
+         adjustment : aint;
          href : treference;
          href : treference;
-         hr,hr2,hr3,
+         hr,hr2,
          pleftreg   : tregister;
          pleftreg   : tregister;
          setparts   : array[1..8] of Tsetpart;
          setparts   : array[1..8] of Tsetpart;
          opsize     : tcgsize;
          opsize     : tcgsize;
          genjumps,
          genjumps,
-         use_small,
-         ranges     : boolean;
+         use_small  : boolean;
          i,numparts : byte;
          i,numparts : byte;
 
 
          function analizeset(const Aset:Tconstset;is_small:boolean):boolean;
          function analizeset(const Aset:Tconstset;is_small:boolean):boolean;
@@ -179,7 +188,6 @@ implementation
              i:byte;
              i:byte;
            begin
            begin
              analizeset:=false;
              analizeset:=false;
-             ranges:=false;
              numparts:=0;
              numparts:=0;
              compares:=0;
              compares:=0;
              { Lots of comparisions take a lot of time, so do not allow
              { Lots of comparisions take a lot of time, so do not allow
@@ -214,7 +222,6 @@ implementation
                      setparts[numparts].range:=true;
                      setparts[numparts].range:=true;
                      setparts[numparts].start:=setparts[numparts].stop;
                      setparts[numparts].start:=setparts[numparts].stop;
                      setparts[numparts].stop:=i;
                      setparts[numparts].stop:=i;
-                     ranges := true;
                      { there's only one compare per range anymore. Only a }
                      { there's only one compare per range anymore. Only a }
                      { sub is added, but that's much faster than a        }
                      { sub is added, but that's much faster than a        }
                      { cmp/jcc combo so neglect its effect                }
                      { cmp/jcc combo so neglect its effect                }
@@ -245,6 +252,8 @@ implementation
          genjumps:=(right.nodetype=setconstn) and
          genjumps:=(right.nodetype=setconstn) and
                    analizeset(Tsetconstnode(right).value_set^,use_small);
                    analizeset(Tsetconstnode(right).value_set^,use_small);
 
 
+         opsize:=OS_32;
+
          { calculate both operators }
          { calculate both operators }
          { the complex one first }
          { the complex one first }
          firstcomplex(self);
          firstcomplex(self);
@@ -272,9 +281,8 @@ implementation
             { clear the register value, indicating result is FALSE }
             { clear the register value, indicating result is FALSE }
             cg.a_load_const_reg(exprasmlist,location.size,0,location.register);
             cg.a_load_const_reg(exprasmlist,location.size,0,location.register);
             { If register is used, use only lower 8 bits }
             { If register is used, use only lower 8 bits }
-            location_force_reg(exprasmlist,left.location,OS_INT,false);
+            location_force_reg(exprasmlist,left.location,opsize,false);
             pleftreg := left.location.register;
             pleftreg := left.location.register;
-            opsize := OS_INT;
 
 
             { how much have we already substracted from the x in the }
             { how much have we already substracted from the x in the }
             { "x in [y..z]" expression                               }
             { "x in [y..z]" expression                               }
@@ -283,7 +291,7 @@ implementation
 
 
             for i:=1 to numparts do
             for i:=1 to numparts do
              if setparts[i].range then
              if setparts[i].range then
-              { use fact that a <= x <= b <=> cardinal(x-a) <= cardinal(b-a) }
+              { use fact that a <= x <= b <=> aword(x-a) <= aword(b-a) }
               begin
               begin
                 { is the range different from all legal values? }
                 { is the range different from all legal values? }
                 if (setparts[i].stop-setparts[i].start <> 255) then
                 if (setparts[i].stop-setparts[i].start <> 255) then
@@ -298,10 +306,9 @@ implementation
                          (hr<>pleftreg) then
                          (hr<>pleftreg) then
                         begin
                         begin
                           cg.a_op_const_reg(exprasmlist,OP_SUB,opsize,setparts[i].start,pleftreg);
                           cg.a_op_const_reg(exprasmlist,OP_SUB,opsize,setparts[i].start,pleftreg);
-                          hr:=cg.getintregister(exprasmlist,OS_INT);
-                          cg.a_load_reg_reg(exprasmlist,opsize,OS_INT,pleftreg,hr);
+                          hr:=cg.getintregister(exprasmlist,opsize);
+                          cg.a_load_reg_reg(exprasmlist,opsize,opsize,pleftreg,hr);
                           pleftreg:=hr;
                           pleftreg:=hr;
-                          opsize := OS_INT;
                         end
                         end
                       else
                       else
                         begin
                         begin
@@ -368,18 +375,18 @@ implementation
                {****************************  SMALL SET **********************}
                {****************************  SMALL SET **********************}
                if left.nodetype=ordconstn then
                if left.nodetype=ordconstn then
                 begin
                 begin
-                  location_force_reg(exprasmlist,right.location,OS_32,false);
+                  location_force_reg(exprasmlist,right.location,opsize,true);
                   { first SHR the register }
                   { first SHR the register }
-                  cg.a_op_const_reg(exprasmlist,OP_SHR,OS_32,tordconstnode(left).value and 31,right.location.register);
+                  cg.a_op_const_reg(exprasmlist,OP_SHR,opsize,tordconstnode(left).value and 31,right.location.register);
                   { then extract the lowest bit }
                   { then extract the lowest bit }
-                  cg.a_op_const_reg(exprasmlist,OP_AND,OS_32,1,right.location.register);
+                  cg.a_op_const_reg(exprasmlist,OP_AND,opsize,1,right.location.register);
                   location.register:=cg.getintregister(exprasmlist,location.size);
                   location.register:=cg.getintregister(exprasmlist,location.size);
-                  cg.a_load_reg_reg(exprasmlist,OS_32,location.size,right.location.register,location.register);
+                  cg.a_load_reg_reg(exprasmlist,opsize,location.size,right.location.register,location.register);
                 end
                 end
                else
                else
                 begin
                 begin
-                  location_force_reg(exprasmlist,left.location,OS_32,false);
-                  location_force_reg(exprasmlist,right.location,OS_32,true);
+                  location_force_reg(exprasmlist,left.location,opsize,false);
+                  location_force_reg(exprasmlist,right.location,opsize,true);
                   { allocate a register for the result }
                   { allocate a register for the result }
                   location.register:=cg.getintregister(exprasmlist,location.size);
                   location.register:=cg.getintregister(exprasmlist,location.size);
                   { emit bit test operation }
                   { emit bit test operation }
@@ -401,21 +408,21 @@ implementation
                   { assumption (other cases will be caught by range checking) (JM)  }
                   { assumption (other cases will be caught by range checking) (JM)  }
 
 
                   { load left in register }
                   { load left in register }
-                  location_force_reg(exprasmlist,left.location,OS_32,true);
+                  location_force_reg(exprasmlist,left.location,opsize,true);
                   if left.location.loc = LOC_CREGISTER then
                   if left.location.loc = LOC_CREGISTER then
-                    hr := cg.getintregister(exprasmlist,OS_32)
+                    hr := cg.getintregister(exprasmlist,opsize)
                   else
                   else
                     hr := left.location.register;
                     hr := left.location.register;
                   { load right in register }
                   { load right in register }
-                  hr2:=cg.getintregister(exprasmlist,OS_32);
-                  cg.a_load_const_reg(exprasmlist,OS_32,right.location.value,hr2);
+                  hr2:=cg.getintregister(exprasmlist,opsize);
+                  cg.a_load_const_reg(exprasmlist,opsize,right.location.value,hr2);
 
 
                   { emit bit test operation }
                   { emit bit test operation }
-                  emit_bit_test_reg_reg(exprasmlist,OS_32,left.location.register,hr2,OS_32,hr2);
+                  emit_bit_test_reg_reg(exprasmlist,left.location.size,left.location.register,hr2,opsize,hr2);
 
 
                   { if left > 31 then hr := 0 else hr := $ffffffff }
                   { if left > 31 then hr := 0 else hr := $ffffffff }
-                  cg.a_op_const_reg_reg(exprasmlist,OP_SUB,OS_32,32,left.location.register,hr);
-                  cg.a_op_const_reg(exprasmlist,OP_SAR,OS_32,31,hr);
+                  cg.a_op_const_reg_reg(exprasmlist,OP_SUB,opsize,32,left.location.register,hr);
+                  cg.a_op_const_reg(exprasmlist,OP_SAR,opsize,31,hr);
 
 
                   { free registers }
                   { free registers }
                   cg.ungetregister(exprasmlist,hr2);
                   cg.ungetregister(exprasmlist,hr2);
@@ -425,10 +432,10 @@ implementation
                     cg.ungetregister(exprasmlist,left.location.register);
                     cg.ungetregister(exprasmlist,left.location.register);
 
 
                   { if left > 31, then result := 0 else result := result of bit test }
                   { if left > 31, then result := 0 else result := result of bit test }
-                  cg.a_op_reg_reg(exprasmlist,OP_AND,OS_32,hr,hr2);
+                  cg.a_op_reg_reg(exprasmlist,OP_AND,opsize,hr,hr2);
                   { allocate a register for the result }
                   { allocate a register for the result }
                   location.register := cg.getintregister(exprasmlist,location.size);
                   location.register := cg.getintregister(exprasmlist,location.size);
-                  cg.a_load_reg_reg(exprasmlist,OS_32,location.size,hr2,location.register);
+                  cg.a_load_reg_reg(exprasmlist,opsize,location.size,hr2,location.register);
                 end { of right.location.loc=LOC_CONSTANT }
                 end { of right.location.loc=LOC_CONSTANT }
                { do search in a normal set which could have >32 elementsm
                { do search in a normal set which could have >32 elementsm
                  but also used if the left side contains higher values > 32 }
                  but also used if the left side contains higher values > 32 }
@@ -455,8 +462,8 @@ implementation
 
 
                   location_freetemp(exprasmlist,left.location);
                   location_freetemp(exprasmlist,left.location);
                   hr := cg.getaddressregister(exprasmlist);
                   hr := cg.getaddressregister(exprasmlist);
-                  cg.a_op_const_reg_reg(exprasmlist,OP_SHR,OS_ADDR,5,pleftreg,hr);
-                  cg.a_op_const_reg(exprasmlist,OP_SHL,OS_ADDR,2,hr);
+                  cg.a_op_const_reg_reg(exprasmlist,OP_SHR,OS_INT,5,pleftreg,hr);
+                  cg.a_op_const_reg(exprasmlist,OP_SHL,OS_INT,2,hr);
 
 
                   href := right.location.reference;
                   href := right.location.reference;
                   if (href.base = NR_NO) then
                   if (href.base = NR_NO) then
@@ -473,15 +480,15 @@ implementation
                     end;
                     end;
                   reference_release(exprasmlist,href);
                   reference_release(exprasmlist,href);
                   { allocate a register for the result }
                   { allocate a register for the result }
-                  location.register := cg.getintregister(exprasmlist,OS_INT);
-                  cg.a_load_ref_reg(exprasmlist,OS_32,OS_INT,href,location.register);
+                  location.register := cg.getintregister(exprasmlist,opsize);
+                  cg.a_load_ref_reg(exprasmlist,opsize,opsize,href,location.register);
 
 
                   cg.ungetregister(exprasmlist,pleftreg);
                   cg.ungetregister(exprasmlist,pleftreg);
-                  hr := cg.getintregister(exprasmlist,OS_INT);
-                  cg.a_op_const_reg_reg(exprasmlist,OP_AND,OS_INT,31,pleftreg,hr);
-                  cg.a_op_reg_reg(exprasmlist,OP_SHR,OS_INT,hr,location.register);
+                  hr := cg.getintregister(exprasmlist,opsize);
+                  cg.a_op_const_reg_reg(exprasmlist,OP_AND,opsize,31,pleftreg,hr);
+                  cg.a_op_reg_reg(exprasmlist,OP_SHR,opsize,hr,location.register);
                   cg.ungetregister(exprasmlist,hr);
                   cg.ungetregister(exprasmlist,hr);
-                  cg.a_op_const_reg(exprasmlist,OP_AND,OS_INT,1,location.register);
+                  cg.a_op_const_reg(exprasmlist,OP_AND,opsize,1,location.register);
                 end;
                 end;
              end;
              end;
           end;
           end;
@@ -492,7 +499,7 @@ implementation
                             TCGCASENODE
                             TCGCASENODE
 *****************************************************************************}
 *****************************************************************************}
 
 
-    procedure tcgcasenode.optimizevalues(var max_linear_list:longint;var max_dist:cardinal);
+    procedure tcgcasenode.optimizevalues(var max_linear_list:aint;var max_dist:aword);
       begin
       begin
         { no changes by default }
         { no changes by default }
       end;
       end;
@@ -505,7 +512,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tcgcasenode.genjumptable(hp : pcaserecord;min_,max_ : longint);
+    procedure tcgcasenode.genjumptable(hp : pcaserecord;min_,max_ : aint);
       begin
       begin
         internalerror(200209161);
         internalerror(200209161);
       end;
       end;
@@ -520,7 +527,7 @@ implementation
 
 
       procedure genitem(t : pcaserecord);
       procedure genitem(t : pcaserecord);
 
 
-          procedure gensub(value:longint);
+          procedure gensub(value:aint);
           begin
           begin
             { here, since the sub and cmp are separate we need
             { here, since the sub and cmp are separate we need
               to move the result before subtract to a help
               to move the result before subtract to a help
@@ -536,7 +543,7 @@ implementation
            { need we to test the first value }
            { need we to test the first value }
            if first and (t^._low>get_min_value(left.resulttype.def)) then
            if first and (t^._low>get_min_value(left.resulttype.def)) then
              begin
              begin
-                cg.a_cmp_const_reg_label(exprasmlist,opsize,jmp_lt,aword(t^._low),hregister,elselabel);
+                cg.a_cmp_const_reg_label(exprasmlist,opsize,jmp_lt,t^._low,hregister,elselabel);
              end;
              end;
            if t^._low=t^._high then
            if t^._low=t^._high then
              begin
              begin
@@ -544,8 +551,8 @@ implementation
                   cg.a_cmp_const_reg_label(exprasmlist, opsize, OC_EQ,0,hregister,t^.statement)
                   cg.a_cmp_const_reg_label(exprasmlist, opsize, OC_EQ,0,hregister,t^.statement)
                 else
                 else
                   begin
                   begin
-                      gensub(longint(t^._low-last));
-                      cg.a_cmp_const_reg_label(exprasmlist, opsize, OC_EQ,aword(t^._low-last),scratch_reg,t^.statement);
+                      gensub(aint(t^._low-last));
+                      cg.a_cmp_const_reg_label(exprasmlist, opsize, OC_EQ,aint(t^._low-last),scratch_reg,t^.statement);
                   end;
                   end;
                 last:=t^._low;
                 last:=t^._low;
              end
              end
@@ -558,18 +565,18 @@ implementation
                   begin
                   begin
                      { have we to ajust the first value ? }
                      { have we to ajust the first value ? }
                      if (t^._low>get_min_value(left.resulttype.def)) then
                      if (t^._low>get_min_value(left.resulttype.def)) then
-                       gensub(longint(t^._low));
+                       gensub(aint(t^._low));
                   end
                   end
                 else
                 else
                   begin
                   begin
                     { if there is no unused label between the last and the }
                     { if there is no unused label between the last and the }
                     { present label then the lower limit can be checked    }
                     { present label then the lower limit can be checked    }
                     { immediately. else check the range in between:       }
                     { immediately. else check the range in between:       }
-                    gensub(longint(t^._low-last));
-                    cg.a_cmp_const_reg_label(exprasmlist, opsize,jmp_lt,aword(t^._low-last),scratch_reg,elselabel);
+                    gensub(aint(t^._low-last));
+                    cg.a_cmp_const_reg_label(exprasmlist, opsize,jmp_lt,aint(t^._low-last),scratch_reg,elselabel);
                   end;
                   end;
-                gensub(longint(t^._high-t^._low));
-                cg.a_cmp_const_reg_label(exprasmlist, opsize,jmp_le,aword(t^._high-t^._low),scratch_reg,t^.statement);
+                gensub(aint(t^._high-t^._low));
+                cg.a_cmp_const_reg_label(exprasmlist, opsize,jmp_le,aint(t^._high-t^._low),scratch_reg,t^.statement);
                 last:=t^._high;
                 last:=t^._high;
              end;
              end;
            first:=false;
            first:=false;
@@ -601,8 +608,10 @@ implementation
 
 
       procedure genitem(t : pcaserecord);
       procedure genitem(t : pcaserecord);
 
 
+{$ifndef cpu64bit}
         var
         var
            l1 : tasmlabel;
            l1 : tasmlabel;
+{$endif cpu64bit}
 
 
         begin
         begin
            if assigned(t^.less) then
            if assigned(t^.less) then
@@ -613,19 +622,14 @@ implementation
                 if opsize in [OS_S64,OS_64] then
                 if opsize in [OS_S64,OS_64] then
                   begin
                   begin
                      objectlibrary.getlabel(l1);
                      objectlibrary.getlabel(l1);
-{$ifdef Delphi}
-                     cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_NE, hi((t^._low)),hregister2,l1);
-                     cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_EQ, lo((t^._low)),hregister, t^.statement);
-{$else}
-                     cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_NE, aword(hi(int64(t^._low))),hregister2,l1);
-                     cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_EQ, aword(lo(int64(t^._low))),hregister, t^.statement);
-{$endif}
+                     cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_NE, aint(hi(int64(t^._low))),hregister2,l1);
+                     cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_EQ, aint(lo(int64(t^._low))),hregister, t^.statement);
                      cg.a_label(exprasmlist,l1);
                      cg.a_label(exprasmlist,l1);
                   end
                   end
                 else
                 else
 {$endif cpu64bit}
 {$endif cpu64bit}
                   begin
                   begin
-                     cg.a_cmp_const_reg_label(exprasmlist, opsize, OC_EQ, aword(t^._low),hregister, t^.statement);
+                     cg.a_cmp_const_reg_label(exprasmlist, opsize, OC_EQ, aint(t^._low),hregister, t^.statement);
                   end;
                   end;
                 { Reset last here, because we've only checked for one value and need to compare
                 { Reset last here, because we've only checked for one value and need to compare
                   for the next range both the lower and upper bound }
                   for the next range both the lower and upper bound }
@@ -642,27 +646,18 @@ implementation
                      if opsize in [OS_64,OS_S64] then
                      if opsize in [OS_64,OS_S64] then
                        begin
                        begin
                           objectlibrary.getlabel(l1);
                           objectlibrary.getlabel(l1);
-{$ifdef Delphi}
-                          cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_lt, aword(hi((t^._low))),
-                               hregister2, elselabel);
-                          cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_gt, aword(hi((t^._low))),
-                               hregister2, l1);
-                          { the comparisation of the low dword must be always unsigned! }
-                          cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_B, aword(lo((t^._low))), hregister, elselabel);
-{$else}
-                          cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_lt, aword(hi(int64(t^._low))),
+                          cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_lt, aint(hi(int64(t^._low))),
                                hregister2, elselabel);
                                hregister2, elselabel);
-                          cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_gt, aword(hi(int64(t^._low))),
+                          cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_gt, aint(hi(int64(t^._low))),
                                hregister2, l1);
                                hregister2, l1);
                           { the comparisation of the low dword must be always unsigned! }
                           { the comparisation of the low dword must be always unsigned! }
-                          cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_B, aword(lo(int64(t^._low))), hregister, elselabel);
-{$endif}
+                          cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_B, aint(lo(int64(t^._low))), hregister, elselabel);
                           cg.a_label(exprasmlist,l1);
                           cg.a_label(exprasmlist,l1);
                        end
                        end
                      else
                      else
 {$endif cpu64bit}
 {$endif cpu64bit}
                        begin
                        begin
-                        cg.a_cmp_const_reg_label(exprasmlist, opsize, jmp_lt, aword(t^._low), hregister,
+                        cg.a_cmp_const_reg_label(exprasmlist, opsize, jmp_lt, aint(t^._low), hregister,
                            elselabel);
                            elselabel);
                        end;
                        end;
                   end;
                   end;
@@ -670,25 +665,17 @@ implementation
                 if opsize in [OS_S64,OS_64] then
                 if opsize in [OS_S64,OS_64] then
                   begin
                   begin
                      objectlibrary.getlabel(l1);
                      objectlibrary.getlabel(l1);
-{$ifdef Delphi}
-                     cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_lt, aword(hi(t^._high)), hregister2,
+                     cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_lt, aint(hi(int64(t^._high))), hregister2,
                            t^.statement);
                            t^.statement);
-                     cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_gt, aword(hi(t^._high)), hregister2,
+                     cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_gt, aint(hi(int64(t^._high))), hregister2,
                            l1);
                            l1);
-                    cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_BE, aword(lo(t^._high)), hregister, t^.statement);
-{$else}
-                     cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_lt, aword(hi(int64(t^._high))), hregister2,
-                           t^.statement);
-                     cg.a_cmp_const_reg_label(exprasmlist, OS_32, jmp_gt, aword(hi(int64(t^._high))), hregister2,
-                           l1);
-                    cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_BE, aword(lo(int64(t^._high))), hregister, t^.statement);
-{$endif}
+                    cg.a_cmp_const_reg_label(exprasmlist, OS_32, OC_BE, aint(lo(int64(t^._high))), hregister, t^.statement);
                     cg.a_label(exprasmlist,l1);
                     cg.a_label(exprasmlist,l1);
                   end
                   end
                 else
                 else
 {$endif cpu64bit}
 {$endif cpu64bit}
                   begin
                   begin
-                     cg.a_cmp_const_reg_label(exprasmlist, opsize, jmp_le, aword(t^._high), hregister, t^.statement);
+                     cg.a_cmp_const_reg_label(exprasmlist, opsize, jmp_le, aint(t^._high), hregister, t^.statement);
                   end;
                   end;
 
 
                 last:=t^._high;
                 last:=t^._high;
@@ -775,12 +762,12 @@ implementation
       var
       var
          lv,hv,
          lv,hv,
          max_label: tconstexprint;
          max_label: tconstexprint;
-         labels : longint;
-         max_linear_list : longint;
+         labels : aint;
+         max_linear_list : aint;
          otl, ofl: tasmlabel;
          otl, ofl: tasmlabel;
          isjump : boolean;
          isjump : boolean;
          max_dist,
          max_dist,
-         dist : cardinal;
+         dist : aword;
          hp : tstatementnode;
          hp : tstatementnode;
       begin
       begin
          location_reset(location,LOC_VOID,OS_NO);
          location_reset(location,LOC_VOID,OS_NO);
@@ -866,14 +853,14 @@ implementation
                    getrange(left.resulttype.def,lv,hv);
                    getrange(left.resulttype.def,lv,hv);
                    jumptable_no_range:=(lv=min_label) and (hv=max_label);
                    jumptable_no_range:=(lv=min_label) and (hv=max_label);
                    { hack a little bit, because the range can be greater }
                    { hack a little bit, because the range can be greater }
-                   { than the positive range of a longint            }
+                   { than the positive range of a aint            }
 
 
                    if (min_label<0) and (max_label>0) then
                    if (min_label<0) and (max_label>0) then
                      begin
                      begin
-                        if min_label=TConstExprInt($80000000) then
-                          dist:=Cardinal(max_label)+Cardinal($80000000)
+                        if min_label=TConstExprInt(low(aint)) then
+                          dist:=aword(max_label)+aword(low(aint))
                         else
                         else
-                          dist:=Cardinal(max_label)+Cardinal(-min_label)
+                          dist:=aword(max_label)+aword(-min_label)
                      end
                      end
                    else
                    else
                      dist:=max_label-min_label;
                      dist:=max_label-min_label;
@@ -897,7 +884,7 @@ implementation
                      end
                      end
                    else
                    else
                      begin
                      begin
-                        max_dist:=4*cardinal(labels);
+                        max_dist:=4*aword(labels);
                         if jumptable_no_range then
                         if jumptable_no_range then
                           max_linear_list:=4
                           max_linear_list:=4
                         else
                         else
@@ -984,9 +971,28 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.61  2004-05-30 21:18:22  jonas
+  Revision 1.62  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.61  2004/05/30 21:18:22  jonas
     * some optimizations and associated fixes for better regvar code
     * some optimizations and associated fixes for better regvar code
 
 
+  Revision 1.60.2.5  2004/05/02 16:49:12  peter
+    * 64 bit fixes
+
+  Revision 1.60.2.4  2004/05/02 14:09:54  peter
+    * fix case 64bit issues
+
+  Revision 1.60.2.3  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.60.2.2  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.60.2.1  2004/04/26 21:02:34  peter
+    * 64bit fixes
+
   Revision 1.60  2004/02/27 10:21:05  florian
   Revision 1.60  2004/02/27 10:21:05  florian
     * top_symbol killed
     * top_symbol killed
     + refaddr to treference added
     + refaddr to treference added
@@ -1244,4 +1250,3 @@ end.
   + generic sets
   + generic sets
 
 
 }
 }
-

+ 222 - 240
compiler/ncgutil.pas

@@ -53,8 +53,8 @@ interface
 
 
     procedure gen_proc_symbol(list:Taasmoutput);
     procedure gen_proc_symbol(list:Taasmoutput);
     procedure gen_proc_symbol_end(list:Taasmoutput);
     procedure gen_proc_symbol_end(list:Taasmoutput);
-    procedure gen_stackalloc_code(list:Taasmoutput);
-    procedure gen_stackfree_code(list:Taasmoutput;usesacc,usesacchi:boolean);
+    procedure gen_proc_entry_code(list:Taasmoutput);
+    procedure gen_proc_exit_code(list:Taasmoutput);
     procedure gen_save_used_regs(list:TAAsmoutput);
     procedure gen_save_used_regs(list:TAAsmoutput);
     procedure gen_restore_used_regs(list:TAAsmoutput;const funcretparaloc:tparalocation);
     procedure gen_restore_used_regs(list:TAAsmoutput;const funcretparaloc:tparalocation);
     procedure gen_initialize_code(list:TAAsmoutput;inlined:boolean);
     procedure gen_initialize_code(list:TAAsmoutput;inlined:boolean);
@@ -62,7 +62,7 @@ interface
     procedure gen_entry_code(list:TAAsmoutput);
     procedure gen_entry_code(list:TAAsmoutput);
     procedure gen_exit_code(list:TAAsmoutput);
     procedure gen_exit_code(list:TAAsmoutput);
     procedure gen_load_para_value(list:TAAsmoutput);
     procedure gen_load_para_value(list:TAAsmoutput);
-    procedure gen_load_return_value(list:TAAsmoutput; var uses_acc,uses_acchi,uses_fpu : boolean);
+    procedure gen_load_return_value(list:TAAsmoutput);
 
 
 (*
 (*
     procedure geninlineentrycode(list:TAAsmoutput;stackframe:longint);
     procedure geninlineentrycode(list:TAAsmoutput;stackframe:longint);
@@ -86,7 +86,8 @@ interface
     }
     }
 
 
     const
     const
-      EXCEPT_BUF_SIZE = 12;
+
+      EXCEPT_BUF_SIZE = 4*2*sizeof(aint);
     type
     type
       texceptiontemps=record
       texceptiontemps=record
         jmpbuf,
         jmpbuf,
@@ -96,8 +97,8 @@ interface
 
 
     procedure get_exception_temps(list:taasmoutput;var t:texceptiontemps);
     procedure get_exception_temps(list:taasmoutput;var t:texceptiontemps);
     procedure unget_exception_temps(list:taasmoutput;const t:texceptiontemps);
     procedure unget_exception_temps(list:taasmoutput;const t:texceptiontemps);
-    procedure new_exception(list:TAAsmoutput;const t:texceptiontemps;a:aword;exceptlabel:tasmlabel);
-    procedure free_exception(list:TAAsmoutput;const t:texceptiontemps;a:aword;endexceptlabel:tasmlabel;onlyfree:boolean);
+    procedure new_exception(list:TAAsmoutput;const t:texceptiontemps;a:aint;exceptlabel:tasmlabel);
+    procedure free_exception(list:TAAsmoutput;const t:texceptiontemps;a:aint;endexceptlabel:tasmlabel;onlyfree:boolean);
 
 
     procedure insertconstdata(sym : ttypedconstsym);
     procedure insertconstdata(sym : ttypedconstsym);
     procedure insertbssdata(sym : tvarsym);
     procedure insertbssdata(sym : tvarsym);
@@ -125,7 +126,7 @@ implementation
     globals,systems,verbose,
     globals,systems,verbose,
     ppu,defutil,
     ppu,defutil,
     procinfo,paramgr,fmodule,
     procinfo,paramgr,fmodule,
-    regvars,
+    regvars,dwarf,
 {$ifdef GDB}
 {$ifdef GDB}
     gdb,
     gdb,
 {$endif GDB}
 {$endif GDB}
@@ -274,6 +275,7 @@ implementation
       end;
       end;
         *)
         *)
 
 
+
 {*****************************************************************************
 {*****************************************************************************
                             EXCEPTION MANAGEMENT
                             EXCEPTION MANAGEMENT
 *****************************************************************************}
 *****************************************************************************}
@@ -282,7 +284,7 @@ implementation
       begin
       begin
         tg.GetTemp(list,EXCEPT_BUF_SIZE,tt_persistent,t.envbuf);
         tg.GetTemp(list,EXCEPT_BUF_SIZE,tt_persistent,t.envbuf);
         tg.GetTemp(list,JMP_BUF_SIZE,tt_persistent,t.jmpbuf);
         tg.GetTemp(list,JMP_BUF_SIZE,tt_persistent,t.jmpbuf);
-        tg.GetTemp(list,sizeof(aword),tt_persistent,t.reasonbuf);
+        tg.GetTemp(list,sizeof(aint),tt_persistent,t.reasonbuf);
       end;
       end;
 
 
 
 
@@ -294,7 +296,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure new_exception(list:TAAsmoutput;const t:texceptiontemps;a:aword;exceptlabel:tasmlabel);
+    procedure new_exception(list:TAAsmoutput;const t:texceptiontemps;a:aint;exceptlabel:tasmlabel);
       var
       var
         paraloc1,paraloc2,paraloc3 : tparalocation;
         paraloc1,paraloc2,paraloc3 : tparalocation;
       begin
       begin
@@ -328,7 +330,7 @@ implementation
      end;
      end;
 
 
 
 
-    procedure free_exception(list:TAAsmoutput;const t:texceptiontemps;a:aword;endexceptlabel:tasmlabel;onlyfree:boolean);
+    procedure free_exception(list:TAAsmoutput;const t:texceptiontemps;a:aint;endexceptlabel:tasmlabel;onlyfree:boolean);
      begin
      begin
          cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
          cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
          cg.a_call_name(list,'FPC_POPADDRSTACK');
          cg.a_call_name(list,'FPC_POPADDRSTACK');
@@ -400,7 +402,7 @@ implementation
                  if l.loc=LOC_CONSTANT then
                  if l.loc=LOC_CONSTANT then
                   begin
                   begin
                     if (longint(l.value)<0) then
                     if (longint(l.value)<0) then
-                     cg.a_load_const_reg(list,OS_32,$ffffffff,hregisterhi)
+                     cg.a_load_const_reg(list,OS_32,aint($ffffffff),hregisterhi)
                     else
                     else
                      cg.a_load_const_reg(list,OS_32,0,hregisterhi);
                      cg.a_load_const_reg(list,OS_32,0,hregisterhi);
                   end
                   end
@@ -446,7 +448,7 @@ implementation
             allocator eliminates unnecessary moves, so it's not needed
             allocator eliminates unnecessary moves, so it's not needed
             and trying to recycle registers can cause problems because
             and trying to recycle registers can cause problems because
             the registers changes size and may need aditional constraints.
             the registers changes size and may need aditional constraints.
-            
+
             Not if it's about LOC_CREGISTER's (JM)
             Not if it's about LOC_CREGISTER's (JM)
             }
             }
            const_location :=
            const_location :=
@@ -523,6 +525,7 @@ implementation
         hl : tasmlabel;
         hl : tasmlabel;
         oldloc : tlocation;
         oldloc : tlocation;
       begin
       begin
+        oldloc:=l;
         {Do not bother to recycle the existing register. The register
         {Do not bother to recycle the existing register. The register
          allocator eliminates unnecessary moves, so it's not needed
          allocator eliminates unnecessary moves, so it's not needed
          and trying to recycle registers can cause problems because
          and trying to recycle registers can cause problems because
@@ -665,12 +668,14 @@ implementation
           LOC_CREGISTER :
           LOC_CREGISTER :
             begin
             begin
               tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,r);
               tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,r);
+{$ifndef cpu64bit}
               if l.size in [OS_64,OS_S64] then
               if l.size in [OS_64,OS_S64] then
                 begin
                 begin
                   cg64.a_load64_loc_ref(list,l,r);
                   cg64.a_load64_loc_ref(list,l,r);
                   location_release(list,l);
                   location_release(list,l);
                 end
                 end
               else
               else
+{$endif cpu64bit}
                 begin
                 begin
                   location_release(list,l);
                   location_release(list,l);
                   cg.a_load_loc_ref(list,l.size,l,r);
                   cg.a_load_loc_ref(list,l.size,l,r);
@@ -701,6 +706,8 @@ implementation
           end
           end
         else
         else
           maybe_pushfpu:=false;
           maybe_pushfpu:=false;
+{$else i386}
+        maybe_pushfpu:=false;
 {$endif i386}
 {$endif i386}
       end;
       end;
 
 
@@ -950,9 +957,7 @@ implementation
       var
       var
         hp : ptemprecord;
         hp : ptemprecord;
         href : treference;
         href : treference;
-        paraloc1 : tparalocation;
       begin
       begin
-        paraloc1:=paramanager.getintparaloc(pocall_default,1);
         hp:=tg.templist;
         hp:=tg.templist;
         while assigned(hp) do
         while assigned(hp) do
          begin
          begin
@@ -968,13 +973,14 @@ implementation
       end;
       end;
 
 
 
 
-    procedure gen_load_return_value(list:TAAsmoutput; var uses_acc,uses_acchi,uses_fpu : boolean);
+    procedure gen_load_return_value(list:TAAsmoutput);
       var
       var
         ressym : tvarsym;
         ressym : tvarsym;
         resloc : tlocation;
         resloc : tlocation;
-        href   : treference;
         hreg   : tregister;
         hreg   : tregister;
+        resultloc : tparalocation;
       begin
       begin
+        resultloc:=current_procinfo.procdef.funcret_paraloc[calleeside];
         { Is the loading needed? }
         { Is the loading needed? }
         if is_void(current_procinfo.procdef.rettype.def) or
         if is_void(current_procinfo.procdef.rettype.def) or
            (
            (
@@ -982,53 +988,37 @@ implementation
             (not(assigned(current_procinfo.procdef.funcretsym)) or
             (not(assigned(current_procinfo.procdef.funcretsym)) or
              (tvarsym(current_procinfo.procdef.funcretsym).refs=0))
              (tvarsym(current_procinfo.procdef.funcretsym).refs=0))
            ) then
            ) then
-          exit;
+           exit;
 
 
-        { Constructors need to return self }
+        { constructors return self }
         if (current_procinfo.procdef.proctypeoption=potype_constructor) then
         if (current_procinfo.procdef.proctypeoption=potype_constructor) then
+          ressym:=tvarsym(current_procinfo.procdef.parast.search('self'))
+        else
+          ressym := tvarsym(current_procinfo.procdef.funcretsym);
+        if (ressym.refs>0) then
           begin
           begin
-            cg.getexplicitregister(list,NR_FUNCTION_RETURN_REG);
-            { return the self pointer }
-            ressym:=tvarsym(current_procinfo.procdef.parast.search('self'));
-            if not assigned(ressym) then
-              internalerror(200305058);
-            cg.ungetregister(list,NR_FUNCTION_RETURN_REG);
-            // for the optimizer
-            cg.a_reg_alloc(list,NR_FUNCTION_RETURN_REG);
             case ressym.localloc.loc of
             case ressym.localloc.loc of
-              LOC_REFERENCE :
+              LOC_FPUREGISTER:
                 begin
                 begin
-                  reference_reset_base(href,ressym.localloc.reference.index,ressym.localloc.reference.offset);
-                  cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,NR_FUNCTION_RETURN_REG);
+                  location_reset(resloc,LOC_CREGISTER,resultloc.size);
+                  resloc.register:=ressym.localloc.register;
                 end;
                 end;
+
               LOC_REGISTER:
               LOC_REGISTER:
-                cg.a_load_reg_reg(list,OS_ADDR,OS_ADDR,ressym.localloc.register,NR_FUNCTION_RETURN_REG);
-              else
-                internalerror(2004020409);
-            end;
-            uses_acc:=true;
-            exit;
-          end;
+                begin
+                  location_reset(resloc,LOC_CREGISTER,resultloc.size);
+                  resloc.register:=ressym.localloc.register;
+                end;
 
 
-        ressym := tvarsym(current_procinfo.procdef.funcretsym);
-        if (ressym.refs>0) then
-          begin
-            case ressym.localloc.loc of
-              LOC_FPUREGISTER,
-              LOC_REGISTER :
+              LOC_MMREGISTER:
                 begin
                 begin
-                  if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
-                    location_reset(resloc,LOC_CREGISTER,OS_ADDR)
-                  else
-                    if ressym.vartype.def.deftype = floatdef then
-                      location_reset(resloc,LOC_CFPUREGISTER,def_cgsize(current_procinfo.procdef.rettype.def))
-                    else
-                      location_reset(resloc,LOC_CREGISTER,def_cgsize(current_procinfo.procdef.rettype.def));
+                  location_reset(resloc,LOC_CMMREGISTER,resultloc.size);
                   resloc.register:=ressym.localloc.register;
                   resloc.register:=ressym.localloc.register;
                 end;
                 end;
-              LOC_REFERENCE :
+
+              LOC_REFERENCE:
                 begin
                 begin
-                  location_reset(resloc,LOC_REFERENCE,def_cgsize(current_procinfo.procdef.rettype.def));
+                  location_reset(resloc,LOC_REFERENCE,resultloc.size);
                   reference_reset_base(resloc.reference,ressym.localloc.reference.index,ressym.localloc.reference.offset);
                   reference_reset_base(resloc.reference,ressym.localloc.reference.index,ressym.localloc.reference.offset);
                 end;
                 end;
               else
               else
@@ -1038,78 +1028,46 @@ implementation
             { Here, we return the function result. In most architectures, the value is
             { Here, we return the function result. In most architectures, the value is
               passed into the FUNCTION_RETURN_REG, but in a windowed architecure like sparc a
               passed into the FUNCTION_RETURN_REG, but in a windowed architecure like sparc a
               function returns in a register and the caller receives it in an other one }
               function returns in a register and the caller receives it in an other one }
-            case current_procinfo.procdef.rettype.def.deftype of
-              orddef,
-              enumdef :
+            case resultloc.loc of
+              LOC_REGISTER:
                 begin
                 begin
-                  uses_acc:=true;
-    {$ifndef cpu64bit}
+{$ifndef cpu64bit}
                   if resloc.size in [OS_64,OS_S64] then
                   if resloc.size in [OS_64,OS_S64] then
-                   begin
-                     uses_acchi:=true;
-                     cg.getexplicitregister(list,NR_FUNCTION_RETURN64_LOW_REG);
-                     cg.getexplicitregister(list,NR_FUNCTION_RETURN64_HIGH_REG);
-                     cg.ungetregister(list,NR_FUNCTION_RETURN64_LOW_REG);
-                     cg.ungetregister(list,NR_FUNCTION_RETURN64_HIGH_REG);
-                     // for the optimizer
-                     cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_LOW_REG);
-                     cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_HIGH_REG);
-                     cg64.a_load64_loc_reg(list,resloc,joinreg64(NR_FUNCTION_RETURN64_LOW_REG,
-                                           NR_FUNCTION_RETURN64_HIGH_REG));
-                   end
+                    begin
+                      cg.getexplicitregister(list,NR_FUNCTION_RETURN64_LOW_REG);
+                      cg.getexplicitregister(list,NR_FUNCTION_RETURN64_HIGH_REG);
+                      cg.ungetregister(list,NR_FUNCTION_RETURN64_LOW_REG);
+                      cg.ungetregister(list,NR_FUNCTION_RETURN64_HIGH_REG);
+                      // for the optimizer
+                      cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_LOW_REG);
+                      cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_HIGH_REG);
+                      cg64.a_load64_loc_reg(list,resloc,joinreg64(NR_FUNCTION_RETURN64_LOW_REG,
+                                            NR_FUNCTION_RETURN64_HIGH_REG));
+                    end
                   else
                   else
-    {$endif cpu64bit}
-                   begin
-                     cg.getexplicitregister(list,NR_FUNCTION_RETURN_REG);
-                     hreg:=cg.makeregsize(list,NR_FUNCTION_RETURN_REG,resloc.size);
-                     cg.ungetregister(list,hreg);
-                     // for the optimizer
-                     cg.a_reg_alloc(list,NR_FUNCTION_RETURN_REG);
-                     cg.a_load_loc_reg(list,resloc.size,resloc,hreg);
-                   end;
+{$endif cpu64bit}
+                    begin
+                      cg.getexplicitregister(list,resultloc.register);
+                      hreg:=cg.makeregsize(list,resultloc.register,resloc.size);
+                      cg.ungetregister(list,hreg);
+                      // for the optimizer
+                      cg.a_reg_alloc(list,resultloc.register);
+                      cg.a_load_loc_reg(list,resloc.size,resloc,hreg);
+                    end;
                 end;
                 end;
-              floatdef :
+              LOC_FPUREGISTER:
                 begin
                 begin
-                  uses_fpu := true;
-    {$ifdef cpufpemu}
-                  if cs_fp_emulation in aktmoduleswitches then
-                    cg.a_loadfpu_loc_reg(list,resloc,NR_FUNCTION_RETURN_REG)
-                  else
-    {$endif cpufpemu}
-                    cg.a_loadfpu_loc_reg(list,resloc,NR_FPU_RESULT_REG);
+                  cg.a_loadfpu_loc_reg(list,resloc,resultloc.register);
                 end;
                 end;
-              else
+              LOC_MMREGISTER:
                 begin
                 begin
-                  if not paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
-                   begin
-                     uses_acc:=true;
-    {$ifndef cpu64bit}
-                     { Win32 can return records in EAX:EDX }
-                     if resloc.size in [OS_64,OS_S64] then
-                      begin
-                        uses_acchi:=true;
-                        cg.getexplicitregister(list,NR_FUNCTION_RETURN64_LOW_REG);
-                        cg.getexplicitregister(list,NR_FUNCTION_RETURN64_HIGH_REG);
-                        cg.ungetregister(list,NR_FUNCTION_RETURN64_LOW_REG);
-                        cg.ungetregister(list,NR_FUNCTION_RETURN64_HIGH_REG);
-                        // for the optimizer
-                        cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_LOW_REG);
-                        cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_HIGH_REG);
-                        cg64.a_load64_loc_reg(list,resloc,joinreg64(NR_FUNCTION_RETURN64_LOW_REG,
-                                              NR_FUNCTION_RETURN64_HIGH_REG));
-                      end
-                     else
-    {$endif cpu64bit}
-                      begin
-                        cg.getexplicitregister(list,NR_FUNCTION_RETURN_REG);
-                        hreg:=cg.makeregsize(list,NR_FUNCTION_RETURN_REG,resloc.size);
-                        cg.ungetregister(list,hreg);
-                        // for the optimizer
-                        cg.a_reg_alloc(list,NR_FUNCTION_RETURN_REG);
-                        cg.a_load_loc_reg(list,resloc.size,resloc,hreg);
-                      end;
-                    end
+                  cg.a_loadmm_loc_reg(list,resloc.size,resloc,resultloc.register,mms_movescalar);
                 end;
                 end;
+              LOC_INVALID,
+              LOC_REFERENCE:
+                ;
+              else
+                internalerror(200405025);
             end;
             end;
          end;
          end;
       end;
       end;
@@ -1141,36 +1099,39 @@ implementation
                       { cg.a_load_param_reg will first allocate and then deallocate paraloc }
                       { cg.a_load_param_reg will first allocate and then deallocate paraloc }
                       { register (if the parameter resides in a register) and then allocate }
                       { register (if the parameter resides in a register) and then allocate }
                       { the regvar (which is currently not allocated)                       }
                       { the regvar (which is currently not allocated)                       }
-                      cg.a_loadany_param_reg(list,hp.paraloc[calleeside],tvarsym(hp.parasym).localloc.register,nil);
+                      cg.a_loadany_param_reg(list,hp.paraloc[calleeside],tvarsym(hp.parasym).localloc.register,mms_movescalar);
                     end;
                     end;
                   LOC_REFERENCE :
                   LOC_REFERENCE :
                     begin
                     begin
                       if hp.paraloc[calleeside].loc<>LOC_REFERENCE then
                       if hp.paraloc[calleeside].loc<>LOC_REFERENCE then
                         begin
                         begin
-                          if getsupreg(hp.paraloc[calleeside].register)<first_int_imreg then
+                          if getregtype(hp.paraloc[calleeside].register)=R_INTREGISTER then
                             begin
                             begin
+                              if getsupreg(hp.paraloc[calleeside].register)<first_int_imreg then
+                                begin
+{$ifndef cpu64bit}
+                                  if (hp.paraloc[calleeside].size in [OS_S64,OS_64]) then
+                                    begin
+                                      cg.getexplicitregister(list,hp.paraloc[calleeside].registerlow);
+                                      cg.getexplicitregister(list,hp.paraloc[calleeside].registerhigh);
+                                    end
+                                  else
+{$endif cpu64bit}
+                                    cg.getexplicitregister(list,hp.paraloc[calleeside].register);
+                                end;
+                              { Release parameter register }
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
                               if (hp.paraloc[calleeside].size in [OS_S64,OS_64]) then
                               if (hp.paraloc[calleeside].size in [OS_S64,OS_64]) then
                                 begin
                                 begin
-                                  cg.getexplicitregister(list,hp.paraloc[calleeside].registerlow);
-                                  cg.getexplicitregister(list,hp.paraloc[calleeside].registerhigh);
+                                  cg.ungetregister(list,hp.paraloc[calleeside].registerlow);
+                                  cg.ungetregister(list,hp.paraloc[calleeside].registerhigh);
                                 end
                                 end
                               else
                               else
 {$endif cpu64bit}
 {$endif cpu64bit}
-                                cg.getexplicitregister(list,hp.paraloc[calleeside].register);
+                                cg.ungetregister(list,hp.paraloc[calleeside].register);
                             end;
                             end;
-                          { Release parameter register }
-{$ifndef cpu64bit}
-                          if (hp.paraloc[calleeside].size in [OS_S64,OS_64]) then
-                            begin
-                              cg.ungetregister(list,hp.paraloc[calleeside].registerlow);
-                              cg.ungetregister(list,hp.paraloc[calleeside].registerhigh);
-                            end
-                          else
-{$endif cpu64bit}
-                            cg.ungetregister(list,hp.paraloc[calleeside].register);
                           reference_reset_base(href,tvarsym(hp.parasym).localloc.reference.index,tvarsym(hp.parasym).localloc.reference.offset);
                           reference_reset_base(href,tvarsym(hp.parasym).localloc.reference.index,tvarsym(hp.parasym).localloc.reference.offset);
-                          cg.a_loadany_param_ref(list,hp.paraloc[calleeside],href,nil);
+                          cg.a_loadany_param_ref(list,hp.paraloc[calleeside],href,mms_movescalar);
                         end;
                         end;
                     end;
                     end;
                   else
                   else
@@ -1323,11 +1284,11 @@ implementation
                while assigned(hp) do
                while assigned(hp) do
                  begin
                  begin
                    If (hp.u.flags and uf_has_debuginfo)=uf_has_debuginfo then
                    If (hp.u.flags and uf_has_debuginfo)=uf_has_debuginfo then
-                     current_procinfo.aktlocaldata.concat(Tai_const_symbol.Createname(make_mangledname('DEBUGINFO',hp.u.globalsymtable,''),AT_DATA,0));
+                     current_procinfo.aktlocaldata.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',hp.u.globalsymtable,''),AT_DATA,0));
                    hp:=tused_unit(hp.next);
                    hp:=tused_unit(hp.next);
                  end;
                  end;
                { include reference to debuginfo for this program }
                { include reference to debuginfo for this program }
-               current_procinfo.aktlocaldata.concat(Tai_const_symbol.Createname(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_DATA,0));
+               current_procinfo.aktlocaldata.concat(Tai_const.Createname(make_mangledname('DEBUGINFO',current_module.localsymtable,''),AT_DATA,0));
              end;
              end;
 {$endif GDB}
 {$endif GDB}
          end;
          end;
@@ -1478,7 +1439,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure gen_stackalloc_code(list:Taasmoutput);
+    procedure gen_proc_entry_code(list:Taasmoutput);
       var
       var
         hitemp,
         hitemp,
         lotemp,
         lotemp,
@@ -1487,6 +1448,11 @@ implementation
         paraloc1   : tparalocation;
         paraloc1   : tparalocation;
         href       : treference;
         href       : treference;
       begin
       begin
+        { generate call frame marker for dwarf call frame info }
+        dwarfcfi.start_frame(list);
+
+        { allocate temp for saving the argument used when
+          stack checking uses a register for pushing the stackframe size }
         check:=(cs_check_stack in aktlocalswitches) and (current_procinfo.procdef.proctypeoption<>potype_proginit);
         check:=(cs_check_stack in aktlocalswitches) and (current_procinfo.procdef.proctypeoption<>potype_proginit);
         if check then
         if check then
           begin
           begin
@@ -1494,8 +1460,9 @@ implementation
               is destroyed when calling stackchecking code }
               is destroyed when calling stackchecking code }
             paraloc1:=paramanager.getintparaloc(pocall_default,1);
             paraloc1:=paramanager.getintparaloc(pocall_default,1);
             if paraloc1.loc=LOC_REGISTER then
             if paraloc1.loc=LOC_REGISTER then
-              tg.GetTemp(list,POINTER_SIZE,tt_normal,href);
+              tg.GetTemp(list,sizeof(aint),tt_normal,href);
           end;
           end;
+
         { Calculate size of stackframe }
         { Calculate size of stackframe }
         stackframe:=current_procinfo.calc_stackframe_size;
         stackframe:=current_procinfo.calc_stackframe_size;
 
 
@@ -1516,94 +1483,56 @@ implementation
               tostr_with_plus(lotemp)+' and '+std_regname(current_procinfo.framepointer)+tostr_with_plus(hitemp))));
               tostr_with_plus(lotemp)+' and '+std_regname(current_procinfo.framepointer)+tostr_with_plus(hitemp))));
           end;
           end;
 
 
-{$ifndef powerpc}
-        { at least for the ppc this applies always, so this code isn't usable (FK) }
-        { omit stack frame ? }
-        if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
-          begin
-            CGmessage(cg_d_stackframe_omited);
-            if stackframe<>0 then
-              cg.g_stackpointer_alloc(list,stackframe);
-          end
-        else
-{$endif powerpc}
-          begin
-            if (po_interrupt in current_procinfo.procdef.procoptions) then
-              cg.g_interrupt_stackframe_entry(list);
+         { generate target specific proc entry code }
+         cg.g_proc_entry(list,stackframe,(po_nostackframe in current_procinfo.procdef.procoptions));
 
 
-            cg.g_stackframe_entry(list,stackframe);
-
-            { Add stack checking code? }
-            if check then
-              begin
-                { The tempspace to store original register is already
-                  allocated above before the stackframe size is calculated. }
-                if paraloc1.loc=LOC_REGISTER then
-                  cg.a_load_reg_ref(list,OS_INT,OS_INT,paraloc1.register,href);
-                paramanager.allocparaloc(list,paraloc1);
-                cg.a_param_const(list,OS_INT,stackframe,paraloc1);
-                paramanager.freeparaloc(list,paraloc1);
-                { No register saving needed, saveregisters is used }
-{$ifndef x86}
-                cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
-{$endif x86}
-                cg.a_call_name(list,'FPC_STACKCHECK');
-{$ifndef x86}
-                cg.deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
-{$endif x86}
-                if paraloc1.loc=LOC_REGISTER then
-                  begin
-                    cg.a_load_ref_reg(list,OS_INT,OS_INT,href,paraloc1.register);
-                    tg.UnGetTemp(list,href);
-                  end;
-              end;
-          end;
+         { Add stack checking code? }
+         if check then
+           begin
+             { The tempspace to store original register is already
+               allocated above before the stackframe size is calculated. }
+             if paraloc1.loc=LOC_REGISTER then
+               cg.a_load_reg_ref(list,OS_INT,OS_INT,paraloc1.register,href);
+             paramanager.allocparaloc(list,paraloc1);
+             cg.a_param_const(list,OS_INT,stackframe,paraloc1);
+             paramanager.freeparaloc(list,paraloc1);
+             cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
+             cg.a_call_name(list,'FPC_STACKCHECK');
+             cg.deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
+             if paraloc1.loc=LOC_REGISTER then
+               begin
+                 cg.a_load_ref_reg(list,OS_INT,OS_INT,href,paraloc1.register);
+                 tg.UnGetTemp(list,href);
+               end;
+           end;
       end;
       end;
 
 
 
 
-    procedure gen_stackfree_code(list:Taasmoutput;usesacc,usesacchi:boolean);
+    procedure gen_proc_exit_code(list:Taasmoutput);
       var
       var
-        stacksize,
-        retsize : longint;
+        parasize : longint;
       begin
       begin
-{$ifndef powerpc}
-        { remove stackframe }
-        if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
-          begin
-            stacksize:=current_procinfo.calc_stackframe_size;
-            if (stacksize<>0) then
-              cg.a_op_const_reg(list,OP_ADD,OS_ADDR,stacksize,current_procinfo.framepointer);
-          end
-        else
-          cg.g_restore_frame_pointer(list);
-{$endif}
-{$ifdef x86}
-        { at last, the return is generated }
-        if (po_interrupt in current_procinfo.procdef.procoptions) then
-          cg.g_interrupt_stackframe_exit(list,usesacc,usesacchi)
-        else
-{$endif x86}
-          begin
-            if current_procinfo.procdef.proccalloption in clearstack_pocalls then
-              begin
-                retsize:=0;
-                if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
-                  inc(retsize,POINTER_SIZE);
-              end
-            else
-              retsize:=current_procinfo.para_stack_size;
-            cg.g_return_from_proc(list,retsize);
-          end;
-{$ifndef cpu64bit}
-        if usesacchi then
+        { c style clearstack does not need to remove parameters from the stack, only the
+          return value when it was pushed by arguments }
+        if current_procinfo.procdef.proccalloption in clearstack_pocalls then
           begin
           begin
-            cg.a_reg_dealloc(list,NR_FUNCTION_RETURN64_LOW_REG);
-            cg.a_reg_dealloc(list,NR_FUNCTION_RETURN64_HIGH_REG);
+            parasize:=0;
+            if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
+              inc(parasize,sizeof(aint));
           end
           end
         else
         else
-{$endif cpu64bit}
-        if usesacc then
-          cg.a_reg_dealloc(list,NR_FUNCTION_RETURN_REG);
+          parasize:=current_procinfo.para_stack_size;
+
+        { generate target specific proc exit code }
+        cg.g_proc_exit(list,parasize,(po_nostackframe in current_procinfo.procdef.procoptions));
+
+        { release return registers, needed for optimizer }
+        if current_procinfo.procdef.funcret_paraloc[calleeside].loc<>LOC_INVALID then
+          paramanager.freeparaloc(list,
+            current_procinfo.procdef.funcret_paraloc[calleeside]);
+
+        { end of frame marker for call frame info }
+        dwarfcfi.end_frame(list);
       end;
       end;
 
 
 
 
@@ -1797,8 +1726,6 @@ implementation
         storefilepos : tfileposinfo;
         storefilepos : tfileposinfo;
         curconstsegment : taasmoutput;
         curconstsegment : taasmoutput;
         l : longint;
         l : longint;
-        stabstr:Pchar;
-
       begin
       begin
         storefilepos:=aktfilepos;
         storefilepos:=aktfilepos;
         aktfilepos:=sym.fileinfo;
         aktfilepos:=sym.fileinfo;
@@ -1808,11 +1735,10 @@ implementation
           curconstsegment:=consts;
           curconstsegment:=consts;
         l:=sym.getsize;
         l:=sym.getsize;
         { insert cut for smartlinking or alignment }
         { insert cut for smartlinking or alignment }
-        if (cs_create_smart in aktmoduleswitches) then
-          curconstSegment.concat(Tai_cut.Create);
-        curconstSegment.concat(Tai_align.create(const_align(l)));
+        maybe_new_object_file(curconstSegment);
+        new_section(curconstSegment,sec_rodata,lower(sym.mangledname),const_align(l));
         if (sym.owner.symtabletype=globalsymtable) or
         if (sym.owner.symtabletype=globalsymtable) or
-           (cs_create_smart in aktmoduleswitches) or
+           maybe_smartlink_symbol or
            (assigned(current_procinfo) and
            (assigned(current_procinfo) and
             (current_procinfo.procdef.proccalloption=pocall_inline)) or
             (current_procinfo.procdef.proccalloption=pocall_inline)) or
            DLLSource then
            DLLSource then
@@ -1827,24 +1753,17 @@ implementation
       var
       var
         l,varalign : longint;
         l,varalign : longint;
         storefilepos : tfileposinfo;
         storefilepos : tfileposinfo;
-        stabstr:Pchar;
       begin
       begin
         storefilepos:=aktfilepos;
         storefilepos:=aktfilepos;
         aktfilepos:=sym.fileinfo;
         aktfilepos:=sym.fileinfo;
         l:=sym.getvaluesize;
         l:=sym.getvaluesize;
         if (vo_is_thread_var in sym.varoptions) then
         if (vo_is_thread_var in sym.varoptions) then
-          inc(l,pointer_size);
+          inc(l,sizeof(aint));
         varalign:=var_align(l);
         varalign:=var_align(l);
-        {
-        sym.address:=align(datasize,varalign);
-        datasize:=tvarsym(sym).address+l;
-        }
-        { insert cut for smartlinking or alignment }
-        if (cs_create_smart in aktmoduleswitches) then
-          bssSegment.concat(Tai_cut.Create);
-        bssSegment.concat(Tai_align.create(varalign));
+        maybe_new_object_file(bssSegment);
+        new_section(bssSegment,sec_bss,lower(sym.mangledname),varalign);
         if (sym.owner.symtabletype=globalsymtable) or
         if (sym.owner.symtabletype=globalsymtable) or
-           (cs_create_smart in aktmoduleswitches) or
+           maybe_smartlink_symbol or
            DLLSource or
            DLLSource or
            (assigned(current_procinfo) and
            (assigned(current_procinfo) and
             (current_procinfo.procdef.proccalloption=pocall_inline)) or
             (current_procinfo.procdef.proccalloption=pocall_inline)) or
@@ -2015,7 +1934,7 @@ implementation
                   begin
                   begin
 {$warning TODO Allocate register paras}
 {$warning TODO Allocate register paras}
                     localloc.loc:=LOC_REFERENCE;
                     localloc.loc:=LOC_REFERENCE;
-                    localloc.size:=int_cgsize(paramanager.push_size(vs_value,vartype.def,pocall_inline));
+                    localloc.size:=int_cgsize(paramanager.push_size(varspez,vartype.def,pocall_inline));
                     tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
                     tg.GetLocal(list,tcgsize2size[localloc.size],vartype.def,localloc.reference);
                     if cs_asm_source in aktglobalswitches then
                     if cs_asm_source in aktglobalswitches then
                       begin
                       begin
@@ -2083,7 +2002,7 @@ implementation
         { rtti can only be generated for classes that are always typesyms }
         { rtti can only be generated for classes that are always typesyms }
         def:=tstoreddef(ttypesym(p).restype.def);
         def:=tstoreddef(ttypesym(p).restype.def);
         { there is an error, skip rtti info }
         { there is an error, skip rtti info }
-        if def.deftype=errordef then
+        if (def.deftype=errordef) or (Errorcount>0) then
           exit;
           exit;
         { only create rtti once for each definition }
         { only create rtti once for each definition }
         if not(df_has_rttitable in def.defoptions) then
         if not(df_has_rttitable in def.defoptions) then
@@ -2099,9 +2018,8 @@ implementation
            def.rttitablesym:=rsym;
            def.rttitablesym:=rsym;
            { write rtti data }
            { write rtti data }
            def.write_child_rtti_data(fullrtti);
            def.write_child_rtti_data(fullrtti);
-           if (cs_create_smart in aktmoduleswitches) then
-            rttiList.concat(Tai_cut.Create);
-           rttilist.concat(tai_align.create(const_align(pointer_size)));
+           maybe_new_object_file(rttilist);
+           new_section(rttilist,sec_rodata,rsym.get_label.name,const_align(sizeof(aint)));
            rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
            rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
            def.write_rtti_data(fullrtti);
            def.write_rtti_data(fullrtti);
            rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
            rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
@@ -2138,9 +2056,8 @@ implementation
            def.inittablesym:=rsym;
            def.inittablesym:=rsym;
            { write inittable data }
            { write inittable data }
            def.write_child_rtti_data(initrtti);
            def.write_child_rtti_data(initrtti);
-           if (cs_create_smart in aktmoduleswitches) then
-            rttiList.concat(Tai_cut.Create);
-           rttilist.concat(tai_align.create(const_align(pointer_size)));
+           maybe_new_object_file(rttilist);
+           new_section(rttilist,sec_rodata,rsym.get_label.name,const_align(sizeof(aint)));
            rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
            rttiList.concat(Tai_symbol.Create_global(rsym.get_label,0));
            def.write_rtti_data(initrtti);
            def.write_rtti_data(initrtti);
            rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
            rttiList.concat(Tai_symbol_end.Create(rsym.get_label));
@@ -2150,7 +2067,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.206  2004-06-01 20:39:33  jonas
+  Revision 1.207  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.206  2004/06/01 20:39:33  jonas
     * fixed bug regarding parameters on the ppc (they were allocated twice
     * fixed bug regarding parameters on the ppc (they were allocated twice
       under some circumstances and not at all in others)
       under some circumstances and not at all in others)
 
 
@@ -2184,6 +2104,68 @@ end.
   Revision 1.198  2004/05/02 17:26:19  peter
   Revision 1.198  2004/05/02 17:26:19  peter
     * fix stabs for globals
     * fix stabs for globals
 
 
+  Revision 1.197.2.19  2004/05/31 16:39:42  peter
+    * add ungetiftemp in a few locations
+
+  Revision 1.197.2.18  2004/05/27 23:36:18  peter
+    * nostackframe procdirective added
+
+  Revision 1.197.2.17  2004/05/10 21:28:34  peter
+    * section_smartlink enabled for gas under linux
+
+  Revision 1.197.2.16  2004/05/02 21:07:30  florian
+    * fixed constructor results
+
+  Revision 1.197.2.15  2004/05/02 20:56:54  florian
+    * more fixes to handle_return_value update
+
+  Revision 1.197.2.14  2004/05/02 20:20:59  florian
+    * started to fix callee side result value handling
+
+  Revision 1.197.2.13  2004/05/02 16:49:43  peter
+    * generate stabs for globals/locals at the end of a unit compile
+
+  Revision 1.197.2.12  2004/05/01 23:34:43  peter
+    * don't generate rtti when there is an error
+
+  Revision 1.197.2.11  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.197.2.10  2004/04/29 23:30:28  peter
+    * fix i386 compiler
+
+  Revision 1.197.2.9  2004/04/27 18:47:51  florian
+    * exception addr record size for 64 bit systems fixed
+
+  Revision 1.197.2.8  2004/04/27 18:18:25  peter
+    * aword -> aint
+
+  Revision 1.197.2.7  2004/04/26 21:02:34  peter
+    * 64bit fixes
+
+  Revision 1.197.2.6  2004/04/26 19:57:39  florian
+    * first part of single parameter fix
+
+  Revision 1.197.2.5  2004/04/26 15:54:33  peter
+    * small x86-64 fixes
+
+  Revision 1.197.2.4  2004/04/18 16:55:37  peter
+    * procedure entry and exit code restructured, some x86 specific
+      things are removed from the generic ncgutil code and moved to
+      the target depend cg.g_proc_entry and cg.g_proc_exit that now
+      contain all the code during startup including stackframe allocation
+      only the saving of registers is excluded from this code
+
+  Revision 1.197.2.3  2004/04/12 19:34:45  peter
+    * basic framework for dwarf CFI
+
+  Revision 1.197.2.2  2004/04/10 12:36:41  peter
+    * fixed alignment issues
+
+  Revision 1.197.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
   Revision 1.197  2004/03/29 14:43:47  peter
   Revision 1.197  2004/03/29 14:43:47  peter
     * cleaner temp get/unget for exceptions
     * cleaner temp get/unget for exceptions
 
 

+ 59 - 16
compiler/ncnv.pas

@@ -603,7 +603,7 @@ implementation
     function ttypeconvnode.resulttype_string_to_chararray : tnode;
     function ttypeconvnode.resulttype_string_to_chararray : tnode;
 
 
       var
       var
-        arrsize: aword;
+        arrsize : aint;
 
 
       begin
       begin
          with tarraydef(resulttype.def) do
          with tarraydef(resulttype.def) do
@@ -1331,7 +1331,7 @@ implementation
                      if assigned(htype.def) then
                      if assigned(htype.def) then
                        inserttypeconv_explicit(left,htype)
                        inserttypeconv_explicit(left,htype)
                      else
                      else
-                       CGMessage2(cg_e_illegal_type_conversion,left.resulttype.def.gettypename,resulttype.def.gettypename);
+                       CGMessage2(type_e_illegal_type_conversion,left.resulttype.def.gettypename,resulttype.def.gettypename);
                    end;
                    end;
 
 
                  { check if the result could be in a register }
                  { check if the result could be in a register }
@@ -1380,7 +1380,7 @@ implementation
                              (left.nodetype=derefn)
                              (left.nodetype=derefn)
                             )
                             )
                            ) then
                            ) then
-                       CGMessage2(cg_e_illegal_type_conversion,left.resulttype.def.gettypename,resulttype.def.gettypename);
+                       CGMessage2(type_e_illegal_type_conversion,left.resulttype.def.gettypename,resulttype.def.gettypename);
                    end;
                    end;
                end
                end
               else
               else
@@ -1391,12 +1391,22 @@ implementation
             internalerror(200211231);
             internalerror(200211231);
         end;
         end;
 
 
-        { Give hint for unportable code }
-        if ((left.resulttype.def.deftype=orddef) and
-            (resulttype.def.deftype in [pointerdef,procvardef,classrefdef])) or
-           ((resulttype.def.deftype=orddef) and
-            (left.resulttype.def.deftype in [pointerdef,procvardef,classrefdef])) then
-          CGMessage(cg_h_pointer_to_longint_conv_not_portable);
+        { Give hint or warning for unportable code, exceptions are
+           - typecasts from constants
+           - void }
+        if (left.nodetype<>ordconstn) and
+           not(is_void(left.resulttype.def)) and
+           (((left.resulttype.def.deftype=orddef) and
+             (resulttype.def.deftype in [pointerdef,procvardef,classrefdef])) or
+            ((resulttype.def.deftype=orddef) and
+             (left.resulttype.def.deftype in [pointerdef,procvardef,classrefdef]))) then
+          begin
+            { Give a warning when sizes don't match, because then info will be lost }
+            if left.resulttype.def.size=resulttype.def.size then
+              CGMessage(type_h_pointer_to_longint_conv_not_portable)
+            else
+              CGMessage(type_w_pointer_to_longint_conv_not_portable);
+          end;
 
 
         { Constant folding and other node transitions to
         { Constant folding and other node transitions to
           remove the typeconv node }
           remove the typeconv node }
@@ -1438,8 +1448,15 @@ implementation
               { ordinal contants can be directly converted }
               { ordinal contants can be directly converted }
               { but not char to char because it is a widechar to char or via versa }
               { but not char to char because it is a widechar to char or via versa }
               { which needs extra code to do the code page transistion             }
               { which needs extra code to do the code page transistion             }
-              if is_ordinal(resulttype.def) and
-                 not(convtype=tc_char_2_char) then
+              { constant ordinal to pointer }
+              if (resulttype.def.deftype=pointerdef) then
+                begin
+                   hp:=cpointerconstnode.create(TConstPtrUInt(tordconstnode(left).value),resulttype);
+                   result:=hp;
+                   exit;
+                end
+              else if is_ordinal(resulttype.def) and
+                      not(convtype=tc_char_2_char) then
                 begin
                 begin
                    { replace the resulttype and recheck the range }
                    { replace the resulttype and recheck the range }
                    left.resulttype:=resulttype;
                    left.resulttype:=resulttype;
@@ -1463,7 +1480,7 @@ implementation
               { constant pointer to ordinal }
               { constant pointer to ordinal }
               else if is_ordinal(resulttype.def) then
               else if is_ordinal(resulttype.def) then
                 begin
                 begin
-                   hp:=cordconstnode.create(tpointerconstnode(left).value,
+                   hp:=cordconstnode.create(TConstExprInt(tpointerconstnode(left).value),
                      resulttype,true);
                      resulttype,true);
                    result:=hp;
                    result:=hp;
                    exit;
                    exit;
@@ -1630,7 +1647,7 @@ implementation
            exit;
            exit;
          { when converting to 64bit, first convert to a 32bit int and then   }
          { when converting to 64bit, first convert to a 32bit int and then   }
          { convert to a 64bit int (only necessary for 32bit processors) (JM) }
          { convert to a 64bit int (only necessary for 32bit processors) (JM) }
-         if resulttype.def.size > sizeof(aword) then
+         if resulttype.def.size > sizeof(aint) then
            begin
            begin
              result := ctypeconvnode.create_explicit(left,u32inttype);
              result := ctypeconvnode.create_explicit(left,u32inttype);
              result := ctypeconvnode.create(result,resulttype);
              result := ctypeconvnode.create(result,resulttype);
@@ -1687,7 +1704,7 @@ implementation
          if assigned(tunarynode(left).left) then
          if assigned(tunarynode(left).left) then
           begin
           begin
             if (left.expectloc<>LOC_CREFERENCE) then
             if (left.expectloc<>LOC_CREFERENCE) then
-              CGMessage(cg_e_illegal_expression);
+              CGMessage(parser_e_illegal_expression);
             registersint:=left.registersint;
             registersint:=left.registersint;
             expectloc:=left.expectloc
             expectloc:=left.expectloc
           end
           end
@@ -2446,7 +2463,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.147  2004-05-23 18:28:41  peter
+  Revision 1.148  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.147  2004/05/23 18:28:41  peter
     * methodpointer is loaded into a temp when it was a calln
     * methodpointer is loaded into a temp when it was a calln
 
 
   Revision 1.146  2004/05/23 15:03:40  peter
   Revision 1.146  2004/05/23 15:03:40  peter
@@ -2458,6 +2478,29 @@ end.
   Revision 1.144  2004/04/29 19:56:37  daniel
   Revision 1.144  2004/04/29 19:56:37  daniel
     * Prepare compiler infrastructure for multiple ansistring types
     * Prepare compiler infrastructure for multiple ansistring types
 
 
+  Revision 1.143.2.4  2004/05/30 10:45:50  peter
+    * merged fixes from main branch
+
+  Revision 1.146  2004/05/23 15:03:40  peter
+    * some typeconvs don't allow assignment or passing to var para
+
+  Revision 1.145  2004/05/23 14:14:18  florian
+    + added set of widechar support (limited to 256 chars, is delphi compatible)
+
+  Revision 1.144  2004/04/29 19:56:37  daniel
+    * Prepare compiler infrastructure for multiple ansistring types
+
+  Revision 1.143.2.3  2004/04/28 20:37:27  peter
+    * don't give ordinal->pointer warning when typecasting from
+      constant or void type
+
+  Revision 1.143.2.2  2004/04/28 19:55:51  peter
+    * new warning for ordinal-pointer when size is different
+    * fixed some cg_e_ messages to the correct section type_e_ or parser_e_
+
+  Revision 1.143.2.1  2004/04/27 18:18:26  peter
+    * aword -> aint
+
   Revision 1.143  2004/03/23 22:34:49  peter
   Revision 1.143  2004/03/23 22:34:49  peter
     * constants ordinals now always have a type assigned
     * constants ordinals now always have a type assigned
     * integer constants have the smallest type, unsigned prefered over
     * integer constants have the smallest type, unsigned prefered over
@@ -2782,4 +2825,4 @@ end.
   Revision 1.58  2002/05/18 13:34:09  peter
   Revision 1.58  2002/05/18 13:34:09  peter
     * readded missing revisions
     * readded missing revisions
 
 
-}
+}

+ 18 - 3
compiler/ncon.pas

@@ -88,7 +88,7 @@ interface
 
 
        tstringconstnode = class(tnode)
        tstringconstnode = class(tnode)
           value_str : pchar;
           value_str : pchar;
-          len     : aword;
+          len     : longint;
           lab_str : tasmlabel;
           lab_str : tasmlabel;
           st_type : tstringtype;
           st_type : tstringtype;
           constructor createstr(const s : string;st:tstringtype);virtual;
           constructor createstr(const s : string;st:tstringtype);virtual;
@@ -915,12 +915,27 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.62  2004-05-24 20:39:41  florian
+  Revision 1.63  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.62  2004/05/24 20:39:41  florian
     * stricter handling of formal const parameters and IE fixed
     * stricter handling of formal const parameters and IE fixed
 
 
   Revision 1.61  2004/04/29 19:56:37  daniel
   Revision 1.61  2004/04/29 19:56:37  daniel
     * Prepare compiler infrastructure for multiple ansistring types
     * Prepare compiler infrastructure for multiple ansistring types
 
 
+  Revision 1.60.2.2  2004/05/30 10:45:50  peter
+    * merged fixes from main branch
+
+  Revision 1.62  2004/05/24 20:39:41  florian
+    * stricter handling of formal const parameters and IE fixed
+
+  Revision 1.61  2004/04/29 19:56:37  daniel
+    * Prepare compiler infrastructure for multiple ansistring types
+
+  Revision 1.60.2.1  2004/04/27 18:18:26  peter
+    * aword -> aint
+
   Revision 1.60  2004/03/23 22:34:49  peter
   Revision 1.60  2004/03/23 22:34:49  peter
     * constants ordinals now always have a type assigned
     * constants ordinals now always have a type assigned
     * integer constants have the smallest type, unsigned prefered over
     * integer constants have the smallest type, unsigned prefered over
@@ -1087,4 +1102,4 @@ end.
   Revision 1.25  2002/03/04 19:10:11  peter
   Revision 1.25  2002/03/04 19:10:11  peter
     * removed compiler warnings
     * removed compiler warnings
 
 
-}
+}

+ 11 - 4
compiler/nflw.pas

@@ -695,7 +695,7 @@ implementation
 
 
          if left.nodetype<>assignn then
          if left.nodetype<>assignn then
            begin
            begin
-              CGMessage(cg_e_illegal_expression);
+              CGMessage(parser_e_illegal_expression);
               exit;
               exit;
            end;
            end;
 
 
@@ -764,7 +764,7 @@ implementation
               CGMessagePos(hp.fileinfo,type_e_ordinal_expr_expected);
               CGMessagePos(hp.fileinfo,type_e_ordinal_expr_expected);
           end
           end
          else
          else
-           CGMessagePos(hp.fileinfo,cg_e_illegal_count_var);
+           CGMessagePos(hp.fileinfo,type_e_illegal_count_var);
 
 
          resulttypepass(right);
          resulttypepass(right);
          set_varstate(right,vs_used,true);
          set_varstate(right,vs_used,true);
@@ -1471,9 +1471,16 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.96  2004-05-23 15:04:13  peter
+  Revision 1.97  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.96  2004/05/23 15:04:13  peter
     * remvoe writeln
     * remvoe writeln
 
 
+  Revision 1.95.2.1  2004/04/28 19:55:51  peter
+    * new warning for ordinal-pointer when size is different
+    * fixed some cg_e_ messages to the correct section type_e_ or parser_e_
+
   Revision 1.95  2004/03/18 16:19:03  peter
   Revision 1.95  2004/03/18 16:19:03  peter
     * fixed operator overload allowing for pointer-string
     * fixed operator overload allowing for pointer-string
     * replaced some type_e_mismatch with more informational messages
     * replaced some type_e_mismatch with more informational messages
@@ -1751,4 +1758,4 @@ end.
   + generic constructor calls
   + generic constructor calls
   + start of tassembler / tmodulebase class cleanup
   + start of tassembler / tmodulebase class cleanup
 
 
-}
+}

+ 102 - 30
compiler/ninl.pas

@@ -160,7 +160,7 @@ implementation
           begin
           begin
             { the parser will give this message already because we }
             { the parser will give this message already because we }
             { return an errornode (JM)                             }
             { return an errornode (JM)                             }
-            { CGMessagePos(fileinfo,cg_e_illegal_expression);      }
+            { CGMessagePos(fileinfo,parser_e_illegal_expression);      }
             exit;
             exit;
           end;
           end;
 
 
@@ -241,15 +241,20 @@ implementation
           procname := procname + 'float'
           procname := procname + 'float'
         else
         else
           case torddef(source.resulttype.def).typ of
           case torddef(source.resulttype.def).typ of
+{$ifdef cpu64bit}
+            u64bit:
+              procname := procname + 'uint';
+{$else}
             u32bit:
             u32bit:
-              procname := procname + 'longword';
+              procname := procname + 'uint';
             u64bit:
             u64bit:
               procname := procname + 'qword';
               procname := procname + 'qword';
             scurrency,
             scurrency,
             s64bit:
             s64bit:
               procname := procname + 'int64';
               procname := procname + 'int64';
+{$endif}
             else
             else
-              procname := procname + 'longint';
+              procname := procname + 'sint';
           end;
           end;
 
 
         { free the errornode we generated in the beginning }
         { free the errornode we generated in the beginning }
@@ -284,6 +289,12 @@ implementation
     function tinlinenode.handle_read_write: tnode;
     function tinlinenode.handle_read_write: tnode;
 
 
       const
       const
+{$ifdef cpu64bit}
+        hasownreadfunc = [uchar,uwidechar,bool8bit,bool16bit,bool32bit];
+{$else cpu64bit}
+        hasownreadfunc = [uchar,uwidechar,bool8bit,bool16bit,bool32bit,s64bit,u64bit];
+{$endif cpu64bit}
+
         procnames: array[boolean,boolean] of string[11] =
         procnames: array[boolean,boolean] of string[11] =
           (('write_text_','read_text_'),('typed_write','typed_read'));
           (('write_text_','read_text_'),('typed_write','typed_read'));
 
 
@@ -598,18 +609,30 @@ implementation
                     begin
                     begin
                       is_ordinal := true;
                       is_ordinal := true;
                       case torddef(para.left.resulttype.def).typ of
                       case torddef(para.left.resulttype.def).typ of
-                        s8bit,s16bit,s32bit :
+{$ifdef cpu64bit}
+                        s64bit,
+{$endif cpu64bit}
+                        s8bit,
+                        s16bit,
+                        s32bit :
                           name := procprefix+'sint';
                           name := procprefix+'sint';
-                        u8bit,u16bit,u32bit :
+{$ifdef cpu64bit}
+                        u64bit,
+{$endif cpu64bit}
+                        u8bit,
+                        u16bit,
+                        u32bit :
                           name := procprefix+'uint';
                           name := procprefix+'uint';
                         uchar :
                         uchar :
                           name := procprefix+'char';
                           name := procprefix+'char';
                         uwidechar :
                         uwidechar :
                           name := procprefix+'widechar';
                           name := procprefix+'widechar';
+{$ifndef cpu64bit}
                         s64bit :
                         s64bit :
                           name := procprefix+'int64';
                           name := procprefix+'int64';
                         u64bit :
                         u64bit :
                           name := procprefix+'qword';
                           name := procprefix+'qword';
+{$endif cpu64bit}
                         bool8bit,
                         bool8bit,
                         bool16bit,
                         bool16bit,
                         bool32bit :
                         bool32bit :
@@ -694,7 +717,7 @@ implementation
                           begin
                           begin
                             if not assigned(lenpara) then
                             if not assigned(lenpara) then
                               lenpara := ccallparanode.create(
                               lenpara := ccallparanode.create(
-                                cordconstnode.create(0,s32inttype,false),nil)
+                                cordconstnode.create(0,sinttype,false),nil)
                             else
                             else
                               { make sure we don't pass the successive }
                               { make sure we don't pass the successive }
                               { parameters too. We also already have a }
                               { parameters too. We also already have a }
@@ -706,24 +729,25 @@ implementation
                           begin
                           begin
                             if not assigned(lenpara) then
                             if not assigned(lenpara) then
                               lenpara := ccallparanode.create(
                               lenpara := ccallparanode.create(
-                                cordconstnode.create(-32767,s32inttype,false),nil);
+                                cordconstnode.create(-32767,sinttype,false),nil);
                             { also create a default fracpara if necessary }
                             { also create a default fracpara if necessary }
                             if not assigned(fracpara) then
                             if not assigned(fracpara) then
                               fracpara := ccallparanode.create(
                               fracpara := ccallparanode.create(
-                                cordconstnode.create(-1,s32inttype,false),nil);
+                                cordconstnode.create(-1,sinttype,false),nil);
                             { add it to the lenpara }
                             { add it to the lenpara }
                             lenpara.right := fracpara;
                             lenpara.right := fracpara;
                             { and add the realtype para (this also removes the link }
                             { and add the realtype para (this also removes the link }
                             { to any parameters coming after it)                    }
                             { to any parameters coming after it)                    }
                             fracpara.right := ccallparanode.create(
                             fracpara.right := ccallparanode.create(
                                 cordconstnode.create(ord(tfloatdef(para.left.resulttype.def).typ),
                                 cordconstnode.create(ord(tfloatdef(para.left.resulttype.def).typ),
-                                s32inttype,true),nil);
+                                sinttype,true),nil);
                           end;
                           end;
                       end;
                       end;
 
 
                     if do_read and
                     if do_read and
                       ((is_ordinal and
                       ((is_ordinal and
-                        (torddef(para.left.resulttype.def).typ in [s8bit,s16bit,u8bit,u16bit])
+                        not(torddef(para.left.resulttype.def).typ in hasownreadfunc) and
+                        (para.left.resulttype.def.size<>sinttype.def.size)
                        ) or
                        ) or
                        (is_real and
                        (is_real and
                         not equal_defs(para.left.resulttype.def,pbestrealtype^.def)
                         not equal_defs(para.left.resulttype.def,pbestrealtype^.def)
@@ -738,9 +762,9 @@ implementation
                         if is_real then
                         if is_real then
                           restype := pbestrealtype
                           restype := pbestrealtype
                         else if is_signed(para.left.resulttype.def) then
                         else if is_signed(para.left.resulttype.def) then
-                          restype := @s32inttype
+                          restype := @sinttype
                         else
                         else
-                          restype := @u32inttype;
+                          restype := @uinttype;
 
 
                         { create the parameter list: the temp ... }
                         { create the parameter list: the temp ... }
                         temp := ctempcreatenode.create(restype^,restype^.def.size,tt_persistent);
                         temp := ctempcreatenode.create(restype^,restype^.def.size,tt_persistent);
@@ -877,8 +901,12 @@ implementation
 
 
         { check if codepara is valid }
         { check if codepara is valid }
         if assigned(codepara) and
         if assigned(codepara) and
-           ((codepara.resulttype.def.deftype <> orddef) or
-            is_64bitint(codepara.resulttype.def)) then
+           (
+            (codepara.resulttype.def.deftype <> orddef)
+{$ifndef cpu64bit}
+            or is_64bitint(codepara.resulttype.def)
+{$endif cpu64bit}
+            ) then
           begin
           begin
             CGMessagePos1(codepara.fileinfo,type_e_integer_expr_expected,codepara.resulttype.def.typename);
             CGMessagePos1(codepara.fileinfo,type_e_integer_expr_expected,codepara.resulttype.def.typename);
             exit;
             exit;
@@ -904,9 +932,9 @@ implementation
         { code is not a 32bit parameter (we already checked whether the }
         { code is not a 32bit parameter (we already checked whether the }
         { the code para, if specified, was an orddef)                   }
         { the code para, if specified, was an orddef)                   }
         if not assigned(codepara) or
         if not assigned(codepara) or
-           (torddef(codepara.resulttype.def).typ in [u8bit,u16bit,s8bit,s16bit]) then
+           (codepara.resulttype.def.size<>sinttype.def.size) then
           begin
           begin
-            tempcode := ctempcreatenode.create(s32inttype,4,tt_persistent);
+            tempcode := ctempcreatenode.create(sinttype,sinttype.def.size,tt_persistent);
             addstatement(newstatement,tempcode);
             addstatement(newstatement,tempcode);
             { set the resulttype of the temp (needed to be able to get }
             { set the resulttype of the temp (needed to be able to get }
             { the resulttype of the tempref used in the new code para) }
             { the resulttype of the tempref used in the new code para) }
@@ -923,13 +951,13 @@ implementation
             { we need its resulttype later on }
             { we need its resulttype later on }
             codepara.get_paratype;
             codepara.get_paratype;
           end
           end
-        else if (torddef(codepara.resulttype.def).typ = u32bit) then
+        else if (torddef(codepara.resulttype.def).typ = torddef(sinttype.def).typ) then
           { because code is a var parameter, it must match types exactly    }
           { because code is a var parameter, it must match types exactly    }
           { however, since it will return values in [0..255], both longints }
           { however, since it will return values in [0..255], both longints }
           { and cardinals are fine. Since the formal code para type is      }
           { and cardinals are fine. Since the formal code para type is      }
           { longint, insert a typecoversion to longint for cardinal para's  }
           { longint, insert a typecoversion to longint for cardinal para's  }
           begin
           begin
-            codepara.left := ctypeconvnode.create_explicit(codepara.left,s32inttype);
+            codepara.left := ctypeconvnode.create_explicit(codepara.left,sinttype);
             { make it explicit, oterwise you may get a nonsense range }
             { make it explicit, oterwise you may get a nonsense range }
             { check error if the cardinal already contained a value   }
             { check error if the cardinal already contained a value   }
             { > $7fffffff                                             }
             { > $7fffffff                                             }
@@ -943,18 +971,31 @@ implementation
           orddef:
           orddef:
             begin
             begin
               case torddef(destpara.resulttype.def).typ of
               case torddef(destpara.resulttype.def).typ of
-                s8bit,s16bit,s32bit:
+{$ifdef cpu64bit}
+                scurrency,
+                s64bit,
+{$endif cpu64bit}
+                s8bit,
+                s16bit,
+                s32bit:
                   begin
                   begin
                     suffix := 'sint_';
                     suffix := 'sint_';
                     { we also need a destsize para in this case }
                     { we also need a destsize para in this case }
                     sizepara := ccallparanode.create(cordconstnode.create
                     sizepara := ccallparanode.create(cordconstnode.create
                       (destpara.resulttype.def.size,s32inttype,true),nil);
                       (destpara.resulttype.def.size,s32inttype,true),nil);
                   end;
                   end;
-                u8bit,u16bit,u32bit:
+{$ifdef cpu64bit}
+                u64bit,
+{$endif cpu64bit}
+                u8bit,
+                u16bit,
+                u32bit:
                    suffix := 'uint_';
                    suffix := 'uint_';
+{$ifndef cpu64bit}
                 scurrency,
                 scurrency,
                 s64bit: suffix := 'int64_';
                 s64bit: suffix := 'int64_';
                 u64bit: suffix := 'qword_';
                 u64bit: suffix := 'qword_';
+{$endif cpu64bit}
                 else
                 else
                   internalerror(200304225);
                   internalerror(200304225);
               end;
               end;
@@ -1194,7 +1235,7 @@ implementation
                      vl2:=tordconstnode(tcallparanode(tcallparanode(left).right).left).value;
                      vl2:=tordconstnode(tcallparanode(tcallparanode(left).right).left).value;
                    end;
                    end;
                  else
                  else
-                   CGMessage(cg_e_illegal_expression);
+                   CGMessage(parser_e_illegal_expression);
                end;
                end;
                case inlinenumber of
                case inlinenumber of
                  in_const_trunc :
                  in_const_trunc :
@@ -1402,16 +1443,16 @@ implementation
                      if assigned(hightree) then
                      if assigned(hightree) then
                       begin
                       begin
                         hp:=caddnode.create(addn,hightree,
                         hp:=caddnode.create(addn,hightree,
-                                         cordconstnode.create(1,s32inttype,false));
+                                         cordconstnode.create(1,sinttype,false));
                         if (left.resulttype.def.deftype=arraydef) and
                         if (left.resulttype.def.deftype=arraydef) and
                            (tarraydef(left.resulttype.def).elesize<>1) then
                            (tarraydef(left.resulttype.def).elesize<>1) then
                           hp:=caddnode.create(muln,hp,cordconstnode.create(tarraydef(
                           hp:=caddnode.create(muln,hp,cordconstnode.create(tarraydef(
-                            left.resulttype.def).elesize,s32inttype,true));
+                            left.resulttype.def).elesize,sinttype,true));
                         result:=hp;
                         result:=hp;
                       end;
                       end;
                    end
                    end
                   else
                   else
-                   resulttype:=s32inttype;
+                   resulttype:=sinttype;
                 end;
                 end;
 
 
               in_typeof_x:
               in_typeof_x:
@@ -1425,7 +1466,7 @@ implementation
                    if (left.nodetype=ordconstn) then
                    if (left.nodetype=ordconstn) then
                     begin
                     begin
                       hp:=cordconstnode.create(
                       hp:=cordconstnode.create(
-                         tordconstnode(left).value,s32inttype,true);
+                         tordconstnode(left).value,sinttype,true);
                       result:=hp;
                       result:=hp;
                       goto myexit;
                       goto myexit;
                     end;
                     end;
@@ -1592,7 +1633,7 @@ implementation
                   if is_shortstring(left.resulttype.def) then
                   if is_shortstring(left.resulttype.def) then
                    resulttype:=u8inttype
                    resulttype:=u8inttype
                   else
                   else
-                   resulttype:=s32inttype;
+                   resulttype:=sinttype;
                 end;
                 end;
 
 
               in_typeinfo_x:
               in_typeinfo_x:
@@ -1697,7 +1738,7 @@ implementation
                              set_varstate(tcallparanode(tcallparanode(left).right).left,vs_used,true);
                              set_varstate(tcallparanode(tcallparanode(left).right).left,vs_used,true);
                              inserttypeconv_explicit(tcallparanode(tcallparanode(left).right).left,tcallparanode(left).left.resulttype);
                              inserttypeconv_explicit(tcallparanode(tcallparanode(left).right).left,tcallparanode(left).left.resulttype);
                              if assigned(tcallparanode(tcallparanode(left).right).right) then
                              if assigned(tcallparanode(tcallparanode(left).right).right) then
-                               CGMessage(cg_e_illegal_expression);
+                               CGMessage(parser_e_illegal_expression);
                            end;
                            end;
                         end
                         end
                        else
                        else
@@ -2126,7 +2167,7 @@ implementation
                        hpp := tcallparanode(tcallparanode(left).right).left;
                        hpp := tcallparanode(tcallparanode(left).right).left;
                        tcallparanode(tcallparanode(left).right).left := nil;
                        tcallparanode(tcallparanode(left).right).left := nil;
                        if assigned(tcallparanode(tcallparanode(left).right).right) then
                        if assigned(tcallparanode(tcallparanode(left).right).right) then
-                         CGMessage(cg_e_illegal_expression);
+                         CGMessage(parser_e_illegal_expression);
                      end
                      end
                    else
                    else
                      { no, create constant 1 }
                      { no, create constant 1 }
@@ -2359,13 +2400,44 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.135  2004-05-28 21:15:20  peter
+  Revision 1.136  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.135  2004/05/28 21:15:20  peter
     * inc(x,y) makes y always of type x to prevent 64bit operations
     * inc(x,y) makes y always of type x to prevent 64bit operations
       when x is a u32bit and y is signed
       when x is a u32bit and y is signed
 
 
   Revision 1.134  2004/05/23 18:28:41  peter
   Revision 1.134  2004/05/23 18:28:41  peter
     * methodpointer is loaded into a temp when it was a calln
     * methodpointer is loaded into a temp when it was a calln
 
 
+  Revision 1.133.2.9  2004/05/03 16:49:00  peter
+    * sizeof fixed
+
+  Revision 1.133.2.8  2004/05/02 11:26:05  peter
+    * fixed i386 readln(qword)
+
+  Revision 1.133.2.7  2004/05/01 21:30:17  peter
+    * fixed read for int64/qword
+
+  Revision 1.133.2.6  2004/05/01 20:51:19  peter
+    * fix val code parameter
+
+  Revision 1.133.2.5  2004/05/01 16:35:51  florian
+    * fixed length(<ansi/widestring>) for 64 Bit CPUs
+
+  Revision 1.133.2.4  2004/04/29 19:50:36  peter
+    * fixed val for 64bit
+
+  Revision 1.133.2.3  2004/04/29 19:07:22  peter
+    * compile fixes
+
+  Revision 1.133.2.2  2004/04/28 19:55:51  peter
+    * new warning for ordinal-pointer when size is different
+    * fixed some cg_e_ messages to the correct section type_e_ or parser_e_
+
+  Revision 1.133.2.1  2004/04/26 21:05:09  peter
+    * size of classes is now stored as aint
+
   Revision 1.133  2004/03/18 16:19:03  peter
   Revision 1.133  2004/03/18 16:19:03  peter
     * fixed operator overload allowing for pointer-string
     * fixed operator overload allowing for pointer-string
     * replaced some type_e_mismatch with more informational messages
     * replaced some type_e_mismatch with more informational messages
@@ -2660,4 +2732,4 @@ end.
   Revision 1.68  2002/01/19 11:53:56  peter
   Revision 1.68  2002/01/19 11:53:56  peter
     * constant evaluation for assinged added
     * constant evaluation for assinged added
 
 
-}
+}

+ 10 - 3
compiler/nld.pas

@@ -1018,7 +1018,7 @@ implementation
         resulttype:=restype;
         resulttype:=restype;
         { check if it's valid }
         { check if it's valid }
         if restype.def.deftype = errordef then
         if restype.def.deftype = errordef then
-          CGMessage(cg_e_illegal_expression);
+          CGMessage(parser_e_illegal_expression);
       end;
       end;
 
 
 
 
@@ -1137,9 +1137,16 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.126  2004-04-29 19:56:37  daniel
+  Revision 1.127  2004-06-16 20:07:08  florian
+    * dwarf branch merged
+
+  Revision 1.126  2004/04/29 19:56:37  daniel
     * Prepare compiler infrastructure for multiple ansistring types
     * Prepare compiler infrastructure for multiple ansistring types
 
 
+  Revision 1.125.2.1  2004/04/28 19:55:51  peter
+    * new warning for ordinal-pointer when size is different
+    * fixed some cg_e_ messages to the correct section type_e_ or parser_e_
+
   Revision 1.125  2004/03/02 17:32:12  florian
   Revision 1.125  2004/03/02 17:32:12  florian
     * make cycle fixed
     * make cycle fixed
     + pic support for darwin
     + pic support for darwin
@@ -1542,4 +1549,4 @@ end.
       one or more statements
       one or more statements
     * moved finalize and setlength from ninl to pinline
     * moved finalize and setlength from ninl to pinline
 
 
-}
+}

+ 14 - 14
compiler/nmat.pas

@@ -459,18 +459,12 @@ implementation
               exit;
               exit;
            end;
            end;
 
 
-         { expand to cpu wordsize, but don't change sign. For
-           32bit ignore 64bit since that has it's own code }
-{$ifndef cpu64bit}
-         if not is_64bit(left.resulttype.def) then
-{$endif}
-           begin
-             { constants generate signed integers }
-             if is_signed(left.resulttype.def) then
-               inserttypeconv(left,sinttype)
-             else
-               inserttypeconv(left,uinttype);
-           end;
+         { calculations for ordinals < 32 bit have to be done in
+           32 bit for backwards compatibility. That way 'shl 33' is
+           the same as 'shl 1'. It's ugly but compatible with delphi/tp/gcc }
+         if (not is_64bit(left.resulttype.def)) and
+            (torddef(left.resulttype.def).typ<>u32bit) then
+           inserttypeconv(left,s32inttype);
 
 
          inserttypeconv(right,sinttype);
          inserttypeconv(right,sinttype);
 
 
@@ -861,13 +855,19 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.63  2004-05-28 21:14:34  peter
+  Revision 1.64  2004-06-16 20:07:09  florian
+    * dwarf branch merged
+
+  Revision 1.63  2004/05/28 21:14:34  peter
     * fixed div qword
     * fixed div qword
 
 
   Revision 1.62  2004/05/19 23:29:25  peter
   Revision 1.62  2004/05/19 23:29:25  peter
     * don't change sign for unsigned shl/shr operations
     * don't change sign for unsigned shl/shr operations
     * cleanup for u32bit
     * cleanup for u32bit
 
 
+  Revision 1.61.2.1  2004/05/03 16:27:38  peter
+    * fixed shl for x86-64
+
   Revision 1.61  2004/03/29 14:44:10  peter
   Revision 1.61  2004/03/29 14:44:10  peter
     * fixes to previous constant integer commit
     * fixes to previous constant integer commit
 
 
@@ -1021,4 +1021,4 @@ end.
   Revision 1.28  2002/02/11 11:45:51  michael
   Revision 1.28  2002/02/11 11:45:51  michael
   * Compilation without mmx support fixed from Peter
   * Compilation without mmx support fixed from Peter
 
 
-}
+}

+ 14 - 7
compiler/nmem.pas

@@ -333,7 +333,7 @@ implementation
                begin
                begin
                  { a load of a procvar can't have parameters }
                  { a load of a procvar can't have parameters }
                  if assigned(tcallnode(left).left) then
                  if assigned(tcallnode(left).left) then
-                   CGMessage(cg_e_illegal_expression);
+                   CGMessage(parser_e_illegal_expression);
                  { is it a procvar? }
                  { is it a procvar? }
                  hp:=tcallnode(left).right;
                  hp:=tcallnode(left).right;
                  if assigned(hp) then
                  if assigned(hp) then
@@ -367,7 +367,7 @@ implementation
          { if it were a valid construct, the addr node would already have }
          { if it were a valid construct, the addr node would already have }
          { been removed in the parser. This happens for (in FPC mode)     }
          { been removed in the parser. This happens for (in FPC mode)     }
          { procvar1 := @procvar2(parameters);                             }
          { procvar1 := @procvar2(parameters);                             }
-         CGMessage(cg_e_illegal_expression)
+         CGMessage(parser_e_illegal_expression)
         else
         else
          if (left.nodetype=loadn) and (tloadnode(left).symtableentry.typ=procsym) then
          if (left.nodetype=loadn) and (tloadnode(left).symtableentry.typ=procsym) then
           begin
           begin
@@ -482,7 +482,7 @@ implementation
          if not(left.expectloc in [LOC_CREFERENCE,LOC_REFERENCE]) then
          if not(left.expectloc in [LOC_CREFERENCE,LOC_REFERENCE]) then
            begin
            begin
              aktfilepos:=left.fileinfo;
              aktfilepos:=left.fileinfo;
-             CGMessage(cg_e_illegal_expression);
+             CGMessage(parser_e_illegal_expression);
            end;
            end;
 
 
          registersint:=left.registersint;
          registersint:=left.registersint;
@@ -522,7 +522,7 @@ implementation
          if left.resulttype.def.deftype=pointerdef then
          if left.resulttype.def.deftype=pointerdef then
           resulttype:=tpointerdef(left.resulttype.def).pointertype
           resulttype:=tpointerdef(left.resulttype.def).pointertype
          else
          else
-          CGMessage(cg_e_invalid_qualifier);
+          CGMessage(parser_e_invalid_qualifier);
       end;
       end;
 
 
     procedure Tderefnode.mark_write;
     procedure Tderefnode.mark_write;
@@ -638,7 +638,7 @@ implementation
            begin
            begin
               if (left.expectloc<>LOC_CREFERENCE) and
               if (left.expectloc<>LOC_CREFERENCE) and
                  (left.expectloc<>LOC_REFERENCE) then
                  (left.expectloc<>LOC_REFERENCE) then
-                CGMessage(cg_e_illegal_expression);
+                CGMessage(parser_e_illegal_expression);
               expectloc:=left.expectloc;
               expectloc:=left.expectloc;
            end;
            end;
       end;
       end;
@@ -981,9 +981,16 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.83  2004-04-29 19:56:37  daniel
+  Revision 1.84  2004-06-16 20:07:09  florian
+    * dwarf branch merged
+
+  Revision 1.83  2004/04/29 19:56:37  daniel
     * Prepare compiler infrastructure for multiple ansistring types
     * Prepare compiler infrastructure for multiple ansistring types
 
 
+  Revision 1.82.2.1  2004/04/28 19:55:51  peter
+    * new warning for ordinal-pointer when size is different
+    * fixed some cg_e_ messages to the correct section type_e_ or parser_e_
+
   Revision 1.82  2004/03/29 14:42:52  peter
   Revision 1.82  2004/03/29 14:42:52  peter
     * variant array support
     * variant array support
 
 
@@ -1251,4 +1258,4 @@ end.
         constructs with either too many or too little parameters)
         constructs with either too many or too little parameters)
     (both merged, includes second typo fix of pexpr.pas)
     (both merged, includes second typo fix of pexpr.pas)
 
 
-}
+}

+ 97 - 73
compiler/nobj.pas

@@ -110,7 +110,7 @@ interface
         { adjusts the self value with ioffset when casting a interface
         { adjusts the self value with ioffset when casting a interface
           to a class
           to a class
         }
         }
-        procedure adjustselfvalue(procdef: tprocdef;ioffset: aword);virtual;
+        procedure adjustselfvalue(procdef: tprocdef;ioffset: aint);virtual;
         { generates the wrapper for a call to a method via an interface }
         { generates the wrapper for a call to a method via an interface }
         procedure cgintfwrapper(asmlist: TAAsmoutput; procdef: tprocdef; const labelname: string; ioffset: longint);virtual;abstract;
         procedure cgintfwrapper(asmlist: TAAsmoutput; procdef: tprocdef; const labelname: string; ioffset: longint);virtual;abstract;
       public
       public
@@ -147,7 +147,7 @@ implementation
 {$else}
 {$else}
        strings,
        strings,
 {$endif}
 {$endif}
-       globals,verbose,
+       globals,verbose,systems,
        symtable,symconst,symtype,symsym,defcmp,paramgr,
        symtable,symconst,symtype,symsym,defcmp,paramgr,
 {$ifdef GDB}
 {$ifdef GDB}
        gdb,
        gdb,
@@ -285,7 +285,7 @@ implementation
          objectlibrary.getdatalabel(p^.nl);
          objectlibrary.getdatalabel(p^.nl);
          if assigned(p^.l) then
          if assigned(p^.l) then
            writenames(p^.l);
            writenames(p^.l);
-         datasegment.concat(tai_align.create(const_align(POINTER_SIZE)));
+         datasegment.concat(tai_align.create(const_align(sizeof(aint))));
          dataSegment.concat(Tai_label.Create(p^.nl));
          dataSegment.concat(Tai_label.Create(p^.nl));
          len:=strlen(p^.data.messageinf.str);
          len:=strlen(p^.data.messageinf.str);
          datasegment.concat(tai_const.create_8bit(len));
          datasegment.concat(tai_const.create_8bit(len));
@@ -303,8 +303,8 @@ implementation
            writestrentry(p^.l);
            writestrentry(p^.l);
 
 
          { write name label }
          { write name label }
-         dataSegment.concat(Tai_const_symbol.Create(p^.nl));
-         dataSegment.concat(Tai_const_symbol.Createname(p^.data.mangledname,AT_FUNCTION,0));
+         dataSegment.concat(Tai_const.Create_sym(p^.nl));
+         dataSegment.concat(Tai_const.Createname(p^.data.mangledname,AT_FUNCTION,0));
 
 
          if assigned(p^.r) then
          if assigned(p^.r) then
            writestrentry(p^.r);
            writestrentry(p^.r);
@@ -326,7 +326,7 @@ implementation
 
 
          { now start writing of the message string table }
          { now start writing of the message string table }
          objectlibrary.getdatalabel(r);
          objectlibrary.getdatalabel(r);
-         datasegment.concat(tai_align.create(const_align(POINTER_SIZE)));
+         datasegment.concat(tai_align.create(const_align(sizeof(aint))));
          dataSegment.concat(Tai_label.Create(r));
          dataSegment.concat(Tai_label.Create(r));
          genstrmsgtab:=r;
          genstrmsgtab:=r;
          dataSegment.concat(Tai_const.Create_32bit(count));
          dataSegment.concat(Tai_const.Create_32bit(count));
@@ -345,7 +345,7 @@ implementation
 
 
          { write name label }
          { write name label }
          dataSegment.concat(Tai_const.Create_32bit(p^.data.messageinf.i));
          dataSegment.concat(Tai_const.Create_32bit(p^.data.messageinf.i));
-         dataSegment.concat(Tai_const_symbol.Createname(p^.data.mangledname,AT_FUNCTION,0));
+         dataSegment.concat(Tai_const.Createname(p^.data.mangledname,AT_FUNCTION,0));
 
 
          if assigned(p^.r) then
          if assigned(p^.r) then
            writeintentry(p^.r);
            writeintentry(p^.r);
@@ -363,7 +363,7 @@ implementation
 
 
          { now start writing of the message string table }
          { now start writing of the message string table }
          objectlibrary.getdatalabel(r);
          objectlibrary.getdatalabel(r);
-         datasegment.concat(tai_align.create(const_align(POINTER_SIZE)));
+         datasegment.concat(tai_align.create(const_align(sizeof(aint))));
          dataSegment.concat(Tai_label.Create(r));
          dataSegment.concat(Tai_label.Create(r));
          genintmsgtab:=r;
          genintmsgtab:=r;
          dataSegment.concat(Tai_const.Create_32bit(count));
          dataSegment.concat(Tai_const.Create_32bit(count));
@@ -441,7 +441,7 @@ implementation
            begin
            begin
               objectlibrary.getdatalabel(r);
               objectlibrary.getdatalabel(r);
               gendmt:=r;
               gendmt:=r;
-              datasegment.concat(tai_align.create(const_align(POINTER_SIZE)));
+              datasegment.concat(tai_align.create(const_align(sizeof(aint))));
               dataSegment.concat(Tai_label.Create(r));
               dataSegment.concat(Tai_label.Create(r));
               { entries for caching }
               { entries for caching }
               dataSegment.concat(Tai_const.Create_ptr(0));
               dataSegment.concat(Tai_const.Create_ptr(0));
@@ -484,13 +484,13 @@ implementation
               hp:=tprocsym(p).first_procdef;
               hp:=tprocsym(p).first_procdef;
               objectlibrary.getdatalabel(l);
               objectlibrary.getdatalabel(l);
 
 
-              consts.concat(tai_align.create(const_align(POINTER_SIZE)));
+              consts.concat(tai_align.create(const_align(sizeof(aint))));
               Consts.concat(Tai_label.Create(l));
               Consts.concat(Tai_label.Create(l));
               Consts.concat(Tai_const.Create_8bit(length(p.name)));
               Consts.concat(Tai_const.Create_8bit(length(p.name)));
               Consts.concat(Tai_string.Create(p.name));
               Consts.concat(Tai_string.Create(p.name));
 
 
-              dataSegment.concat(Tai_const_symbol.Create(l));
-              dataSegment.concat(Tai_const_symbol.Createname(hp.mangledname,AT_FUNCTION,0));
+              dataSegment.concat(Tai_const.Create_sym(l));
+              dataSegment.concat(Tai_const.Createname(hp.mangledname,AT_FUNCTION,0));
            end;
            end;
       end;
       end;
 
 
@@ -505,7 +505,7 @@ implementation
          if count>0 then
          if count>0 then
            begin
            begin
               objectlibrary.getdatalabel(l);
               objectlibrary.getdatalabel(l);
-              datasegment.concat(tai_align.create(const_align(POINTER_SIZE)));
+              datasegment.concat(tai_align.create(const_align(sizeof(aint))));
               dataSegment.concat(Tai_label.Create(l));
               dataSegment.concat(Tai_label.Create(l));
               dataSegment.concat(Tai_const.Create_32bit(count));
               dataSegment.concat(Tai_const.Create_32bit(count));
               _class.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}genpubmethodtableentry,nil);
               _class.symtable.foreach({$ifdef FPCPROCVAR}@{$endif}genpubmethodtableentry,nil);
@@ -853,8 +853,8 @@ implementation
       begin
       begin
         implintf:=_class.implementedinterfaces;
         implintf:=_class.implementedinterfaces;
         curintf:=implintf.interfaces(intfindex);
         curintf:=implintf.interfaces(intfindex);
-        rawdata.concat(tai_align.create(const_align(POINTER_SIZE)));
-        if (cs_create_smart in aktmoduleswitches) then
+        rawdata.concat(tai_align.create(const_align(sizeof(aint))));
+        if maybe_smartlink_symbol then
          rawdata.concat(Tai_symbol.Createname_global(gintfgetvtbllabelname(intfindex),AT_DATA ,0))
          rawdata.concat(Tai_symbol.Createname_global(gintfgetvtbllabelname(intfindex),AT_DATA ,0))
         else
         else
          rawdata.concat(Tai_symbol.Createname(gintfgetvtbllabelname(intfindex),AT_DATA,0));
          rawdata.concat(Tai_symbol.Createname(gintfgetvtbllabelname(intfindex),AT_DATA,0));
@@ -867,7 +867,7 @@ implementation
             { create wrapper code }
             { create wrapper code }
             cgintfwrapper(rawcode,implintf.implprocs(intfindex,i),tmps,implintf.ioffsets(intfindex)^);
             cgintfwrapper(rawcode,implintf.implprocs(intfindex,i),tmps,implintf.ioffsets(intfindex)^);
             { create reference }
             { create reference }
-            rawdata.concat(Tai_const_symbol.Createname(tmps,AT_FUNCTION,0));
+            rawdata.concat(Tai_const.Createname(tmps,AT_FUNCTION,0));
           end;
           end;
       end;
       end;
 
 
@@ -886,34 +886,34 @@ implementation
           begin
           begin
             { label for GUID }
             { label for GUID }
             objectlibrary.getdatalabel(tmplabel);
             objectlibrary.getdatalabel(tmplabel);
-            rawdata.concat(tai_align.create(const_align(pointer_size)));
+            rawdata.concat(tai_align.create(const_align(sizeof(aint))));
             rawdata.concat(Tai_label.Create(tmplabel));
             rawdata.concat(Tai_label.Create(tmplabel));
             rawdata.concat(Tai_const.Create_32bit(longint(curintf.iidguid^.D1)));
             rawdata.concat(Tai_const.Create_32bit(longint(curintf.iidguid^.D1)));
             rawdata.concat(Tai_const.Create_16bit(curintf.iidguid^.D2));
             rawdata.concat(Tai_const.Create_16bit(curintf.iidguid^.D2));
             rawdata.concat(Tai_const.Create_16bit(curintf.iidguid^.D3));
             rawdata.concat(Tai_const.Create_16bit(curintf.iidguid^.D3));
             for i:=Low(curintf.iidguid^.D4) to High(curintf.iidguid^.D4) do
             for i:=Low(curintf.iidguid^.D4) to High(curintf.iidguid^.D4) do
               rawdata.concat(Tai_const.Create_8bit(curintf.iidguid^.D4[i]));
               rawdata.concat(Tai_const.Create_8bit(curintf.iidguid^.D4[i]));
-            dataSegment.concat(Tai_const_symbol.Create(tmplabel));
+            dataSegment.concat(Tai_const.Create_sym(tmplabel));
           end
           end
         else
         else
           begin
           begin
             { nil for Corba interfaces }
             { nil for Corba interfaces }
-            dataSegment.concat(Tai_const.Create_ptr(0)); { nil }
+            dataSegment.concat(Tai_const.Create_sym(nil));
           end;
           end;
         { VTable }
         { VTable }
-        dataSegment.concat(Tai_const_symbol.Createname(gintfgetvtbllabelname(contintfindex),AT_DATA,0));
+        dataSegment.concat(Tai_const.Createname(gintfgetvtbllabelname(contintfindex),AT_DATA,0));
         { IOffset field }
         { IOffset field }
         dataSegment.concat(Tai_const.Create_32bit(implintf.ioffsets(contintfindex)^));
         dataSegment.concat(Tai_const.Create_32bit(implintf.ioffsets(contintfindex)^));
         { IIDStr }
         { IIDStr }
         objectlibrary.getdatalabel(tmplabel);
         objectlibrary.getdatalabel(tmplabel);
-        rawdata.concat(tai_align.create(const_align(pointer_size)));
+        rawdata.concat(tai_align.create(const_align(sizeof(aint))));
         rawdata.concat(Tai_label.Create(tmplabel));
         rawdata.concat(Tai_label.Create(tmplabel));
         rawdata.concat(Tai_const.Create_8bit(length(curintf.iidstr^)));
         rawdata.concat(Tai_const.Create_8bit(length(curintf.iidstr^)));
         if curintf.objecttype=odt_interfacecom then
         if curintf.objecttype=odt_interfacecom then
           rawdata.concat(Tai_string.Create(upper(curintf.iidstr^)))
           rawdata.concat(Tai_string.Create(upper(curintf.iidstr^)))
         else
         else
           rawdata.concat(Tai_string.Create(curintf.iidstr^));
           rawdata.concat(Tai_string.Create(curintf.iidstr^));
-        dataSegment.concat(Tai_const_symbol.Create(tmplabel));
+        dataSegment.concat(Tai_const.Create_sym(tmplabel));
       end;
       end;
 
 
 
 
@@ -1020,9 +1020,9 @@ implementation
                 { allocate a pointer in the object memory }
                 { allocate a pointer in the object memory }
                 with tobjectsymtable(_class.symtable) do
                 with tobjectsymtable(_class.symtable) do
                   begin
                   begin
-                    datasize:=align(datasize,min(POINTER_SIZE,fieldalignment));
+                    datasize:=align(datasize,min(sizeof(aint),fieldalignment));
                     _class.implementedinterfaces.ioffsets(i)^:=datasize;
                     _class.implementedinterfaces.ioffsets(i)^:=datasize;
-                    inc(datasize,POINTER_SIZE);
+                    inc(datasize,sizeof(aint));
                   end;
                   end;
                 { write vtbl }
                 { write vtbl }
                 gintfcreatevtbl(i,rawdata,rawcode);
                 gintfcreatevtbl(i,rawdata,rawcode);
@@ -1139,7 +1139,7 @@ implementation
         { 2. step calc required fieldcount and their offsets in the object memory map
         { 2. step calc required fieldcount and their offsets in the object memory map
              and write data }
              and write data }
         objectlibrary.getdatalabel(intftable);
         objectlibrary.getdatalabel(intftable);
-        dataSegment.concat(tai_align.create(const_align(POINTER_SIZE)));
+        dataSegment.concat(tai_align.create(const_align(sizeof(aint))));
         dataSegment.concat(Tai_label.Create(intftable));
         dataSegment.concat(Tai_label.Create(intftable));
         gintfwritedata;
         gintfwritedata;
         _class.implementedinterfaces.clearimplprocs; { release temporary information }
         _class.implementedinterfaces.clearimplprocs; { release temporary information }
@@ -1150,22 +1150,25 @@ implementation
   { Write interface identifiers to the data section }
   { Write interface identifiers to the data section }
   procedure tclassheader.writeinterfaceids;
   procedure tclassheader.writeinterfaceids;
     var
     var
-      i: longint;
+      i : longint;
+      s : string;
     begin
     begin
       if assigned(_class.iidguid) then
       if assigned(_class.iidguid) then
         begin
         begin
-          if (cs_create_smart in aktmoduleswitches) then
-            dataSegment.concat(Tai_cut.Create);
-          dataSegment.concat(Tai_symbol.Createname_global(make_mangledname('IID',_class.owner,_class.objname^),AT_DATA,0));
-          dataSegment.concat(Tai_const.Create_32bit(_class.iidguid^.D1));
+          s:=make_mangledname('IID',_class.owner,_class.objname^);
+          maybe_new_object_file(dataSegment);
+          new_section(dataSegment,sec_rodata,s,const_align(sizeof(aint)));
+          dataSegment.concat(Tai_symbol.Createname_global(s,AT_DATA,0));
+          dataSegment.concat(Tai_const.Create_32bit(longint(_class.iidguid^.D1)));
           dataSegment.concat(Tai_const.Create_16bit(_class.iidguid^.D2));
           dataSegment.concat(Tai_const.Create_16bit(_class.iidguid^.D2));
           dataSegment.concat(Tai_const.Create_16bit(_class.iidguid^.D3));
           dataSegment.concat(Tai_const.Create_16bit(_class.iidguid^.D3));
           for i:=Low(_class.iidguid^.D4) to High(_class.iidguid^.D4) do
           for i:=Low(_class.iidguid^.D4) to High(_class.iidguid^.D4) do
             dataSegment.concat(Tai_const.Create_8bit(_class.iidguid^.D4[i]));
             dataSegment.concat(Tai_const.Create_8bit(_class.iidguid^.D4[i]));
         end;
         end;
-      if (cs_create_smart in aktmoduleswitches) then
-        dataSegment.concat(Tai_cut.Create);
-      dataSegment.concat(Tai_symbol.Createname_global(make_mangledname('IIDSTR',_class.owner,_class.objname^),AT_DATA,0));
+      maybe_new_object_file(dataSegment);
+      s:=make_mangledname('IIDSTR',_class.owner,_class.objname^);
+      new_section(dataSegment,sec_rodata,s,0);
+      dataSegment.concat(Tai_symbol.Createname_global(s,AT_DATA,0));
       dataSegment.concat(Tai_const.Create_8bit(length(_class.iidstr^)));
       dataSegment.concat(Tai_const.Create_8bit(length(_class.iidstr^)));
       dataSegment.concat(Tai_string.Create(_class.iidstr^));
       dataSegment.concat(Tai_string.Create(_class.iidstr^));
     end;
     end;
@@ -1201,9 +1204,9 @@ implementation
                                   { class abstract and it's not allow to      }
                                   { class abstract and it's not allow to      }
                                   { generates an instance                     }
                                   { generates an instance                     }
                                   if (po_abstractmethod in procdefcoll^.data.procoptions) then
                                   if (po_abstractmethod in procdefcoll^.data.procoptions) then
-                                    List.concat(Tai_const_symbol.Createname('FPC_ABSTRACTERROR',AT_FUNCTION,0))
+                                    List.concat(Tai_const.Createname('FPC_ABSTRACTERROR',AT_FUNCTION,0))
                                   else
                                   else
-                                    List.concat(Tai_const_symbol.createname(procdefcoll^.data.mangledname,AT_FUNCTION,0));
+                                    List.concat(Tai_const.createname(procdefcoll^.data.mangledname,AT_FUNCTION,0));
                                end;
                                end;
                           end;
                           end;
                         procdefcoll:=procdefcoll^.next;
                         procdefcoll:=procdefcoll^.next;
@@ -1229,26 +1232,21 @@ implementation
          dmtlabel:=gendmt;
          dmtlabel:=gendmt;
 {$endif WITHDMT}
 {$endif WITHDMT}
 
 
-         if (cs_create_smart in aktmoduleswitches) then
-           dataSegment.concat(Tai_cut.Create);
-
          { write tables for classes, this must be done before the actual
          { write tables for classes, this must be done before the actual
            class is written, because we need the labels defined }
            class is written, because we need the labels defined }
          if is_class(_class) then
          if is_class(_class) then
           begin
           begin
+            objectlibrary.getdatalabel(classnamelabel);
+            maybe_new_object_file(dataSegment);
+            new_section(dataSegment,sec_rodata,classnamelabel.name,const_align(sizeof(aint)));
+
             { interface table }
             { interface table }
             if _class.implementedinterfaces.count>0 then
             if _class.implementedinterfaces.count>0 then
-             begin
-               if (cs_create_smart in aktmoduleswitches) then
-                codeSegment.concat(Tai_cut.Create);
-               interfacetable:=genintftable;
-             end;
+              interfacetable:=genintftable;
 
 
             methodnametable:=genpublishedmethodstable;
             methodnametable:=genpublishedmethodstable;
             fieldtablelabel:=_class.generate_field_table;
             fieldtablelabel:=_class.generate_field_table;
             { write class name }
             { write class name }
-            objectlibrary.getdatalabel(classnamelabel);
-            dataSegment.concat(tai_align.create(const_align(POINTER_SIZE)));
             dataSegment.concat(Tai_label.Create(classnamelabel));
             dataSegment.concat(Tai_label.Create(classnamelabel));
             dataSegment.concat(Tai_const.Create_8bit(length(_class.objrealname^)));
             dataSegment.concat(Tai_const.Create_8bit(length(_class.objrealname^)));
             dataSegment.concat(Tai_string.Create(_class.objrealname^));
             dataSegment.concat(Tai_string.Create(_class.objrealname^));
@@ -1261,6 +1259,8 @@ implementation
           end;
           end;
 
 
         { write debug info }
         { write debug info }
+        maybe_new_object_file(dataSegment);
+        new_section(dataSegment,sec_rodata,_class.vmt_mangledname,const_align(sizeof(aint)));
 {$ifdef GDB}
 {$ifdef GDB}
         if (cs_debuginfo in aktmoduleswitches) then
         if (cs_debuginfo in aktmoduleswitches) then
          begin
          begin
@@ -1270,13 +1270,12 @@ implementation
                tstoreddef(vmttype.def).numberstring+'",'+tostr(N_STSYM)+',0,0,'+_class.vmt_mangledname)));
                tstoreddef(vmttype.def).numberstring+'",'+tostr(N_STSYM)+',0,0,'+_class.vmt_mangledname)));
          end;
          end;
 {$endif GDB}
 {$endif GDB}
-         dataSegment.concat(tai_align.create(const_align(POINTER_SIZE)));
          dataSegment.concat(Tai_symbol.Createname_global(_class.vmt_mangledname,AT_DATA,0));
          dataSegment.concat(Tai_symbol.Createname_global(_class.vmt_mangledname,AT_DATA,0));
 
 
          { determine the size with symtable.datasize, because }
          { determine the size with symtable.datasize, because }
          { size gives back 4 for classes                    }
          { size gives back 4 for classes                    }
-         dataSegment.concat(Tai_const.Create_32bit(tobjectsymtable(_class.symtable).datasize));
-         dataSegment.concat(Tai_const.Create_32bit(Cardinal(-tobjectsymtable(_class.symtable).datasize)));
+         dataSegment.concat(Tai_const.Create(ait_const_ptr,tobjectsymtable(_class.symtable).datasize));
+         dataSegment.concat(Tai_const.Create(ait_const_ptr,-int64(tobjectsymtable(_class.symtable).datasize)));
 {$ifdef WITHDMT}
 {$ifdef WITHDMT}
          if _class.classtype=ct_object then
          if _class.classtype=ct_object then
            begin
            begin
@@ -1292,49 +1291,46 @@ implementation
          { it is not written for parents that don't have any vmt !! }
          { it is not written for parents that don't have any vmt !! }
          if assigned(_class.childof) and
          if assigned(_class.childof) and
             (oo_has_vmt in _class.childof.objectoptions) then
             (oo_has_vmt in _class.childof.objectoptions) then
-           dataSegment.concat(Tai_const_symbol.Createname(_class.childof.vmt_mangledname,AT_DATA,0))
+           dataSegment.concat(Tai_const.Createname(_class.childof.vmt_mangledname,AT_DATA,0))
          else
          else
-           dataSegment.concat(Tai_const.Create_ptr(0));
+           dataSegment.concat(Tai_const.Create_sym(nil));
 
 
          { write extended info for classes, for the order see rtl/inc/objpash.inc }
          { write extended info for classes, for the order see rtl/inc/objpash.inc }
          if is_class(_class) then
          if is_class(_class) then
           begin
           begin
             { pointer to class name string }
             { pointer to class name string }
-            dataSegment.concat(Tai_const_symbol.Create(classnamelabel));
-            { pointer to dynamic table }
+            dataSegment.concat(Tai_const.Create_sym(classnamelabel));
+            { pointer to dynamic table or nil }
             if (oo_has_msgint in _class.objectoptions) then
             if (oo_has_msgint in _class.objectoptions) then
-              dataSegment.concat(Tai_const_symbol.Create(intmessagetable))
-            else
-              dataSegment.concat(Tai_const.Create_ptr(0));
-            { pointer to method table }
-            if assigned(methodnametable) then
-              dataSegment.concat(Tai_const_symbol.Create(methodnametable))
+              dataSegment.concat(Tai_const.Create_sym(intmessagetable))
             else
             else
-              dataSegment.concat(Tai_const.Create_ptr(0));
+              dataSegment.concat(Tai_const.Create_sym(nil));
+            { pointer to method table or nil }
+            dataSegment.concat(Tai_const.Create_sym(methodnametable));
             { pointer to field table }
             { pointer to field table }
-            dataSegment.concat(Tai_const_symbol.Create(fieldtablelabel));
+            dataSegment.concat(Tai_const.Create_sym(fieldtablelabel));
             { pointer to type info of published section }
             { pointer to type info of published section }
             if (oo_can_have_published in _class.objectoptions) then
             if (oo_can_have_published in _class.objectoptions) then
-              dataSegment.concat(Tai_const_symbol.Create(_class.get_rtti_label(fullrtti)))
+              dataSegment.concat(Tai_const.Create_sym(_class.get_rtti_label(fullrtti)))
             else
             else
-              dataSegment.concat(Tai_const.Create_ptr(0));
+              dataSegment.concat(Tai_const.Create_sym(nil));
             { inittable for con-/destruction }
             { inittable for con-/destruction }
             if _class.members_need_inittable then
             if _class.members_need_inittable then
-              dataSegment.concat(Tai_const_symbol.Create(_class.get_rtti_label(initrtti)))
+              dataSegment.concat(Tai_const.Create_sym(_class.get_rtti_label(initrtti)))
             else
             else
-              dataSegment.concat(Tai_const.Create_ptr(0));
+              dataSegment.concat(Tai_const.Create_sym(nil));
             { auto table }
             { auto table }
-            dataSegment.concat(Tai_const.Create_ptr(0));
+            dataSegment.concat(Tai_const.Create_sym(nil));
             { interface table }
             { interface table }
             if _class.implementedinterfaces.count>0 then
             if _class.implementedinterfaces.count>0 then
-              dataSegment.concat(Tai_const_symbol.Create(interfacetable))
+              dataSegment.concat(Tai_const.Create_sym(interfacetable))
             else
             else
-              dataSegment.concat(Tai_const.Create_ptr(0));
+              dataSegment.concat(Tai_const.Create_sym(nil));
             { table for string messages }
             { table for string messages }
             if (oo_has_msgstr in _class.objectoptions) then
             if (oo_has_msgstr in _class.objectoptions) then
-              dataSegment.concat(Tai_const_symbol.Create(strmessagetable))
+              dataSegment.concat(Tai_const.Create_sym(strmessagetable))
             else
             else
-              dataSegment.concat(Tai_const.Create_ptr(0));
+              dataSegment.concat(Tai_const.Create_sym(nil));
           end;
           end;
          { write virtual methods }
          { write virtual methods }
          writevirtualmethods(dataSegment);
          writevirtualmethods(dataSegment);
@@ -1343,7 +1339,7 @@ implementation
       end;
       end;
 
 
 
 
-  procedure tclassheader.adjustselfvalue(procdef: tprocdef;ioffset: aword);
+  procedure tclassheader.adjustselfvalue(procdef: tprocdef;ioffset: aint);
     var
     var
       hsym : tsym;
       hsym : tsym;
       href : treference;
       href : treference;
@@ -1368,7 +1364,7 @@ implementation
           begin
           begin
              { offset in the wrapper needs to be adjusted for the stored
              { offset in the wrapper needs to be adjusted for the stored
                return address }
                return address }
-             reference_reset_base(href,locpara.reference.index,locpara.reference.offset+POINTER_SIZE);
+             reference_reset_base(href,locpara.reference.index,locpara.reference.offset+sizeof(aint));
              cg.a_op_const_ref(exprasmlist,OP_SUB,locpara.size,ioffset,href);
              cg.a_op_const_ref(exprasmlist,OP_SUB,locpara.size,ioffset,href);
           end
           end
         else
         else
@@ -1382,7 +1378,35 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.69  2004-03-31 21:01:01  florian
+  Revision 1.70  2004-06-16 20:07:09  florian
+    * dwarf branch merged
+
+  Revision 1.69.2.8  2004/05/10 21:28:34  peter
+    * section_smartlink enabled for gas under linux
+
+  Revision 1.69.2.7  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.69.2.6  2004/04/28 20:36:13  florian
+    * fixed writing of sizes in classes/object vmts
+
+  Revision 1.69.2.5  2004/04/27 18:18:26  peter
+    * aword -> aint
+
+  Revision 1.69.2.4  2004/04/26 21:02:34  peter
+    * 64bit fixes
+
+  Revision 1.69.2.3  2004/04/12 14:45:11  peter
+    * tai_const_symbol and tai_const merged
+
+  Revision 1.69.2.2  2004/04/10 12:36:41  peter
+    * fixed alignment issues
+
+  Revision 1.69.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
+  Revision 1.69  2004/03/31 21:01:01  florian
     * vtbls are now properly aligned
     * vtbls are now properly aligned
 
 
   Revision 1.68  2004/03/18 11:43:57  olle
   Revision 1.68  2004/03/18 11:43:57  olle
@@ -1642,7 +1666,7 @@ end.
       on demand from tprocdef.mangledname
       on demand from tprocdef.mangledname
 
 
   Revision 1.14  2002/04/15 18:59:07  carl
   Revision 1.14  2002/04/15 18:59:07  carl
-  + target_info.size_of_pointer -> pointer_Size
+  + target_info.size_of_pointer -> sizeof(aint)
 
 
   Revision 1.13  2002/02/11 18:51:35  peter
   Revision 1.13  2002/02/11 18:51:35  peter
     * fixed vmt generation for private procedures that were skipped after
     * fixed vmt generation for private procedures that were skipped after

+ 15 - 2
compiler/node.pas

@@ -1132,7 +1132,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.85  2004-05-24 20:39:41  florian
+  Revision 1.86  2004-06-16 20:07:09  florian
+    * dwarf branch merged
+
+  Revision 1.85  2004/05/24 20:39:41  florian
     * stricter handling of formal const parameters and IE fixed
     * stricter handling of formal const parameters and IE fixed
 
 
   Revision 1.84  2004/05/23 18:28:41  peter
   Revision 1.84  2004/05/23 18:28:41  peter
@@ -1146,6 +1149,16 @@ end.
     + <pointer> - <pointer> result is divided by the pointer element size now
     + <pointer> - <pointer> result is divided by the pointer element size now
       this is delphi compatible as well as resulting in the expected result for p1+(p2-p1)
       this is delphi compatible as well as resulting in the expected result for p1+(p2-p1)
 
 
+  Revision 1.81.2.1  2004/05/30 10:45:50  peter
+    * merged fixes from main branch
+
+  Revision 1.85  2004/05/24 20:39:41  florian
+    * stricter handling of formal const parameters and IE fixed
+
+  Revision 1.82  2004/05/20 21:54:33  florian
+    + <pointer> - <pointer> result is divided by the pointer element size now
+      this is delphi compatible as well as resulting in the expected result for p1+(p2-p1)
+
   Revision 1.81  2004/02/03 22:32:54  peter
   Revision 1.81  2004/02/03 22:32:54  peter
     * renamed xNNbittype to xNNinttype
     * renamed xNNbittype to xNNinttype
     * renamed registers32 to registersint
     * renamed registers32 to registersint
@@ -1410,4 +1423,4 @@ end.
     - list field removed of the tnode class because it's not used currently
     - list field removed of the tnode class because it's not used currently
       and can cause hard-to-find bugs
       and can cause hard-to-find bugs
 
 
-}
+}

+ 15 - 4
compiler/nset.pas

@@ -27,7 +27,7 @@ unit nset;
 interface
 interface
 
 
     uses
     uses
-       node,globals,
+       node,globtype,globals,
        aasmbase,aasmtai,symtype;
        aasmbase,aasmtai,symtype;
 
 
     type
     type
@@ -114,7 +114,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      globtype,systems,
+      systems,
       verbose,
       verbose,
       symconst,symdef,symsym,symtable,defutil,defcmp,
       symconst,symdef,symsym,symtable,defutil,defcmp,
       htypechk,pass_1,
       htypechk,pass_1,
@@ -354,7 +354,7 @@ implementation
             { upper limit must be greater or equal than lower limit }
             { upper limit must be greater or equal than lower limit }
             if (tordconstnode(left).value>tordconstnode(right).value) and
             if (tordconstnode(left).value>tordconstnode(right).value) and
                ((tordconstnode(left).value<0) or (tordconstnode(right).value>=0)) then
                ((tordconstnode(left).value<0) or (tordconstnode(right).value>=0)) then
-              CGMessage(cg_e_upper_lower_than_lower);
+              CGMessage(parser_e_upper_lower_than_lower);
           end;
           end;
         resulttype:=left.resulttype;
         resulttype:=left.resulttype;
       end;
       end;
@@ -694,7 +694,18 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.53  2004-03-18 16:19:03  peter
+  Revision 1.54  2004-06-16 20:07:09  florian
+    * dwarf branch merged
+
+  Revision 1.53.2.2  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.53.2.1  2004/04/28 19:55:51  peter
+    * new warning for ordinal-pointer when size is different
+    * fixed some cg_e_ messages to the correct section type_e_ or parser_e_
+
+  Revision 1.53  2004/03/18 16:19:03  peter
     * fixed operator overload allowing for pointer-string
     * fixed operator overload allowing for pointer-string
     * replaced some type_e_mismatch with more informational messages
     * replaced some type_e_mismatch with more informational messages
 
 

+ 14 - 7
compiler/nutils.pas

@@ -246,7 +246,7 @@ implementation
             resulttypepass(result);
             resulttypepass(result);
           end
           end
         else
         else
-          CGMessage(cg_e_illegal_expression);
+          CGMessage(parser_e_illegal_expression);
       end;
       end;
 
 
 
 
@@ -263,7 +263,7 @@ implementation
             resulttypepass(result);
             resulttypepass(result);
           end
           end
         else
         else
-          CGMessage(cg_e_illegal_expression);
+          CGMessage(parser_e_illegal_expression);
       end;
       end;
 
 
 
 
@@ -280,7 +280,7 @@ implementation
             resulttypepass(result);
             resulttypepass(result);
           end
           end
         else
         else
-          CGMessage(cg_e_illegal_expression);
+          CGMessage(parser_e_illegal_expression);
       end;
       end;
 
 
 
 
@@ -298,7 +298,7 @@ implementation
             resulttypepass(result);
             resulttypepass(result);
           end
           end
         else
         else
-          CGMessage(cg_e_illegal_expression);
+          CGMessage(parser_e_illegal_expression);
       end;
       end;
 
 
 
 
@@ -315,7 +315,7 @@ implementation
             resulttypepass(result);
             resulttypepass(result);
           end
           end
         else
         else
-          CGMessage(cg_e_illegal_expression);
+          CGMessage(parser_e_illegal_expression);
       end;
       end;
 
 
 
 
@@ -438,12 +438,19 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2004-05-23 18:28:41  peter
+  Revision 1.13  2004-06-16 20:07:09  florian
+    * dwarf branch merged
+
+  Revision 1.12  2004/05/23 18:28:41  peter
     * methodpointer is loaded into a temp when it was a calln
     * methodpointer is loaded into a temp when it was a calln
 
 
   Revision 1.11  2004/05/23 15:04:49  peter
   Revision 1.11  2004/05/23 15:04:49  peter
     * generate better code for ansistring initialization
     * generate better code for ansistring initialization
 
 
+  Revision 1.10.2.1  2004/04/28 19:55:52  peter
+    * new warning for ordinal-pointer when size is different
+    * fixed some cg_e_ messages to the correct section type_e_ or parser_e_
+
   Revision 1.10  2004/02/20 21:55:59  peter
   Revision 1.10  2004/02/20 21:55:59  peter
     * procvar cleanup
     * procvar cleanup
 
 
@@ -484,4 +491,4 @@ end.
     + applied a patch from Jonas for nested function calls (PowerPC only)
     + applied a patch from Jonas for nested function calls (PowerPC only)
     * ...
     * ...
 
 
-}
+}

+ 63 - 100
compiler/ogbase.pas

@@ -63,7 +63,6 @@ interface
          { reader }
          { reader }
          FReader    : tobjectreader;
          FReader    : tobjectreader;
        protected
        protected
-         function  str2sec(const s:string):TSection;
          function  readobjectdata(data:TAsmObjectData):boolean;virtual;abstract;
          function  readobjectdata(data:TAsmObjectData):boolean;virtual;abstract;
        public
        public
          constructor create;
          constructor create;
@@ -73,9 +72,8 @@ interface
          property Reader:TObjectReader read FReader;
          property Reader:TObjectReader read FReader;
        end;
        end;
 
 
-       texesection = class
+       texesection = class(tnamedindexitem)
        public
        public
-         name      : string[32];
          available : boolean;
          available : boolean;
          secsymidx,
          secsymidx,
          datasize,
          datasize,
@@ -83,21 +81,22 @@ interface
          memsize,
          memsize,
          mempos    : longint;
          mempos    : longint;
          flags     : cardinal;
          flags     : cardinal;
-         DataList  : TLinkedList;
+         secdatalist : TLinkedList;
          constructor create(const n:string);
          constructor create(const n:string);
          destructor  destroy;override;
          destructor  destroy;override;
        end;
        end;
 
 
        texeoutput = class
        texeoutput = class
+       private
+         procedure Sections_FixUpSymbol(s:tnamedindexitem;arg:pointer);
        protected
        protected
          { writer }
          { writer }
          FWriter : tobjectwriter;
          FWriter : tobjectwriter;
-         procedure WriteZeros(l:longint);
          procedure MapObjectdata(var datapos:longint;var mempos:longint);
          procedure MapObjectdata(var datapos:longint;var mempos:longint);
          function  writedata:boolean;virtual;abstract;
          function  writedata:boolean;virtual;abstract;
        public
        public
          { info for each section }
          { info for each section }
-         sections     : array[TSection] of texesection;
+         sections     : tdictionary;
          { global symbols }
          { global symbols }
          externalsyms : tsinglelist;
          externalsyms : tsinglelist;
          commonsyms   : tsinglelist;
          commonsyms   : tsinglelist;
@@ -193,7 +192,7 @@ implementation
 
 
     constructor texesection.create(const n:string);
     constructor texesection.create(const n:string);
       begin
       begin
-        name:=n;
+        inherited createname(n);
         mempos:=0;
         mempos:=0;
         memsize:=0;
         memsize:=0;
         datapos:=0;
         datapos:=0;
@@ -201,7 +200,7 @@ implementation
         secsymidx:=0;
         secsymidx:=0;
         available:=false;
         available:=false;
         flags:=0;
         flags:=0;
-        datalist:=TLinkedList.Create;
+        secdatalist:=TLinkedList.Create;
       end;
       end;
 
 
 
 
@@ -215,8 +214,6 @@ implementation
 ****************************************************************************}
 ****************************************************************************}
 
 
     constructor texeoutput.create;
     constructor texeoutput.create;
-      var
-        sec : TSection;
       begin
       begin
         { init writer }
         { init writer }
         FWriter:=tobjectwriter.create;
         FWriter:=tobjectwriter.create;
@@ -228,18 +225,13 @@ implementation
         globalsyms.noclear:=true;
         globalsyms.noclear:=true;
         externalsyms:=tsinglelist.create;
         externalsyms:=tsinglelist.create;
         commonsyms:=tsinglelist.create;
         commonsyms:=tsinglelist.create;
-        { sections }
-        for sec:=low(TSection) to high(TSection) do
-         sections[sec]:=texesection.create(target_asm.secnames[sec]);
+        sections:=tdictionary.create;
       end;
       end;
 
 
 
 
     destructor texeoutput.destroy;
     destructor texeoutput.destroy;
-      var
-        sec : TSection;
       begin
       begin
-        for sec:=low(TSection) to high(TSection) do
-         sections[sec].free;
+        sections.free;
         globalsyms.free;
         globalsyms.free;
         externalsyms.free;
         externalsyms.free;
         commonsyms.free;
         commonsyms.free;
@@ -273,23 +265,13 @@ implementation
 
 
 
 
     procedure texeoutput.addobjdata(objdata:TAsmObjectData);
     procedure texeoutput.addobjdata(objdata:TAsmObjectData);
-      var
-        sec : TSection;
       begin
       begin
         objdatalist.concat(objdata);
         objdatalist.concat(objdata);
-        { check which sections are available }
-        for sec:=low(TSection) to high(TSection) do
-         begin
-           if assigned(objdata.sects[sec]) then
-            begin
-              sections[sec].available:=true;
-              sections[sec].flags:=objdata.sects[sec].flags;
-            end;
-         end;
       end;
       end;
 
 
 
 
     procedure texeoutput.MapObjectdata(var datapos:longint;var mempos:longint);
     procedure texeoutput.MapObjectdata(var datapos:longint;var mempos:longint);
+{$ifdef needrewrite}
       var
       var
         sec : TSection;
         sec : TSection;
         s   : TAsmSection;
         s   : TAsmSection;
@@ -333,27 +315,54 @@ implementation
               sections[sec].memsize:=mempos-sections[sec].mempos;
               sections[sec].memsize:=mempos-sections[sec].mempos;
             end;
             end;
          end;
          end;
+{$endif needrewrite}
+      begin
       end;
       end;
 
 
 
 
-    procedure texeoutput.WriteZeros(l:longint);
+    procedure texeoutput.Sections_FixUpSymbol(s:tnamedindexitem;arg:pointer);
+{$ifdef needrewrite}
       var
       var
-        empty : array[0..63] of char;
+        secdata : TAsmSection;
+        hsym    : TAsmSymbol;
+      begin
+        with texesection(s) do
+          begin
+            if assigned(exemap) then
+              exemap.AddMemoryMapExeSection(TExeSection(s));
+            secdata:=TAsmSection(secdatalist.first);
+            while assigned(secdata) do
+             begin
+               if assigned(exemap) then
+                 exemap.AddMemoryMapObjectSection(secdata);
+               hsym:=tasmsymbol(secdata.owner.symbols.first);
+               while assigned(hsym) do
+                 begin
+                   { process only the symbols that are defined in this section
+                     and are located in this module }
+                   if ((hsym.section=secdata) or
+                       ((secdata.sectype=sec_bss) and (hsym.section.sectype=sec_common))) then
+                     begin
+                       if hsym.currbind=AB_EXTERNAL then
+                         internalerror(200206303);
+                       inc(hsym.address,secdata.mempos);
+                       if assigned(exemap) then
+                         exemap.AddMemoryMapSymbol(hsym);
+                     end;
+                   hsym:=tasmsymbol(hsym.indexnext);
+                 end;
+               secdata:=TAsmSection(secdata.indexnext);
+             end;
+          end;
+      end;
+{$endif needrewrite}
       begin
       begin
-        if l>0 then
-         begin
-           fillchar(empty,l,0);
-           FWriter.Write(empty,l);
-         end;
       end;
       end;
 
 
 
 
     procedure texeoutput.FixUpSymbols;
     procedure texeoutput.FixUpSymbols;
       var
       var
-        sec : TSection;
-        objdata : TAsmObjectData;
-        sym,
-        hsym : tasmsymbol;
+        sym : tasmsymbol;
       begin
       begin
         {
         {
           Fixing up symbols is done in the following steps:
           Fixing up symbols is done in the following steps:
@@ -363,39 +372,8 @@ implementation
         }
         }
         { Step 1, Update addresses }
         { Step 1, Update addresses }
         if assigned(exemap) then
         if assigned(exemap) then
-         exemap.AddMemoryMapHeader;
-        for sec:=low(TSection) to high(TSection) do
-         if sections[sec].available then
-          begin
-            if assigned(exemap) then
-              exemap.AddMemoryMapSection(sections[sec]);
-            objdata:=TAsmObjectData(objdatalist.first);
-            while assigned(objdata) do
-             begin
-               if assigned(objdata.sects[sec]) then
-                begin
-                  if assigned(exemap) then
-                    exemap.AddMemoryMapObjectData(objdata,sec);
-                  hsym:=tasmsymbol(objdata.symbols.first);
-                  while assigned(hsym) do
-                   begin
-                     { process only the symbols that are defined in this section
-                       and are located in this module }
-                     if ((hsym.section=sec) or
-                         ((sec=sec_bss) and (hsym.section=sec_common))) then
-                      begin
-                        if hsym.currbind=AB_EXTERNAL then
-                         internalerror(200206303);
-                        inc(hsym.address,TAsmObjectData(hsym.objectdata).sects[sec].mempos);
-                        if assigned(exemap) then
-                          exemap.AddMemoryMapSymbol(hsym);
-                      end;
-                     hsym:=tasmsymbol(hsym.indexnext);
-                   end;
-                end;
-               objdata:=TAsmObjectData(objdata.next);
-             end;
-          end;
+          exemap.AddMemoryMapHeader;
+        sections.foreach(@sections_fixupsymbol,nil);
         { Step 2, Update commons }
         { Step 2, Update commons }
         sym:=tasmsymbol(commonsyms.first);
         sym:=tasmsymbol(commonsyms.first);
         while assigned(sym) do
         while assigned(sym) do
@@ -408,7 +386,7 @@ implementation
               sym.size:=sym.altsymbol.size;
               sym.size:=sym.altsymbol.size;
               sym.section:=sym.altsymbol.section;
               sym.section:=sym.altsymbol.section;
               sym.typ:=sym.altsymbol.typ;
               sym.typ:=sym.altsymbol.typ;
-              sym.objectdata:=sym.altsymbol.objectdata;
+              sym.owner:=sym.altsymbol.owner;
             end;
             end;
            sym:=tasmsymbol(sym.listnext);
            sym:=tasmsymbol(sym.listnext);
          end;
          end;
@@ -424,7 +402,7 @@ implementation
               sym.size:=sym.altsymbol.size;
               sym.size:=sym.altsymbol.size;
               sym.section:=sym.altsymbol.section;
               sym.section:=sym.altsymbol.section;
               sym.typ:=sym.altsymbol.typ;
               sym.typ:=sym.altsymbol.typ;
-              sym.objectdata:=sym.altsymbol.objectdata;
+              sym.owner:=sym.altsymbol.owner;
             end;
             end;
            sym:=tasmsymbol(sym.listnext);
            sym:=tasmsymbol(sym.listnext);
          end;
          end;
@@ -463,7 +441,6 @@ implementation
       var
       var
         commonobjdata,
         commonobjdata,
         objdata : TAsmObjectData;
         objdata : TAsmObjectData;
-        s : TAsmSection;
         sym,p : tasmsymbol;
         sym,p : tasmsymbol;
       begin
       begin
         commonobjdata:=nil;
         commonobjdata:=nil;
@@ -484,7 +461,7 @@ implementation
            sym:=tasmsymbol(objdata.symbols.first);
            sym:=tasmsymbol(objdata.symbols.first);
            while assigned(sym) do
            while assigned(sym) do
             begin
             begin
-              if not assigned(sym.objectdata) then
+              if not assigned(sym.owner) then
                internalerror(200206302);
                internalerror(200206302);
               case sym.currbind of
               case sym.currbind of
                 AB_GLOBAL :
                 AB_GLOBAL :
@@ -495,7 +472,7 @@ implementation
                     else
                     else
                       begin
                       begin
                         Comment(V_Error,'Multiple defined symbol '+sym.name);
                         Comment(V_Error,'Multiple defined symbol '+sym.name);
-                        CalculateSymbols:=false;
+                        result:=false;
                       end;
                       end;
                   end;
                   end;
                 AB_EXTERNAL :
                 AB_EXTERNAL :
@@ -528,17 +505,12 @@ implementation
                     if assigned(exemap) then
                     if assigned(exemap) then
                       exemap.AddCommonSymbolsHeader;
                       exemap.AddCommonSymbolsHeader;
                     { create .bss section and add to list }
                     { create .bss section and add to list }
-                    s:=TAsmSection.create(target_asm.secnames[sec_common],0,true);
                     commonobjdata:=TAsmObjectData.create('*COMMON*');
                     commonobjdata:=TAsmObjectData.create('*COMMON*');
-                    commonobjdata.sects[sec_bss]:=s;
+                    commonobjdata.createsection(sec_bss,'',0,[aso_alloconly]);
                     addobjdata(commonobjdata);
                     addobjdata(commonobjdata);
                   end;
                   end;
                  p:=TAsmSymbol.Create(sym.name,AB_GLOBAL,AT_FUNCTION);
                  p:=TAsmSymbol.Create(sym.name,AB_GLOBAL,AT_FUNCTION);
-                 p.SetAddress(0,sec_common,s.datasize,sym.size);
-                 p.objectdata:=commonobjdata;
-                 commonobjdata.sects[sec_bss].alloc(sym.size);
-                 commonobjdata.symbols.insert(p);
-                 { update this symbol }
+                 commonobjdata.writesymbol(p);
                  if assigned(exemap) then
                  if assigned(exemap) then
                    exemap.AddCommonSymbol(p);
                    exemap.AddCommonSymbol(p);
                  { make this symbol available as a global }
                  { make this symbol available as a global }
@@ -605,25 +577,16 @@ implementation
       end;
       end;
 
 
 
 
-    function tobjectinput.str2sec(const s:string):TSection;
-      var
-        t : TSection;
-      begin
-        for t:=low(TSection) to high(TSection) do
-         begin
-           if (s=target_asm.secnames[t]) then
-            begin
-              str2sec:=t;
-              exit;
-            end;
-         end;
-        str2sec:=sec_none;
-      end;
-
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2003-04-22 14:33:38  peter
+  Revision 1.14  2004-06-16 20:07:09  florian
+    * dwarf branch merged
+
+  Revision 1.13.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
+  Revision 1.13  2003/04/22 14:33:38  peter
     * removed some notes/hints
     * removed some notes/hints
 
 
   Revision 1.12  2002/07/01 18:46:24  peter
   Revision 1.12  2002/07/01 18:46:24  peter

File diff suppressed because it is too large
+ 412 - 283
compiler/ogcoff.pas


+ 288 - 211
compiler/ogelf.pas

@@ -32,11 +32,11 @@ interface
 
 
     uses
     uses
        { common }
        { common }
-       cclasses,
+       cclasses,globtype,
        { target }
        { target }
        systems,
        systems,
        { assembler }
        { assembler }
-       cpubase,aasmbase,assemble,
+       cpuinfo,cpubase,aasmbase,aasmtai,assemble,
        { output }
        { output }
        ogbase;
        ogbase;
 
 
@@ -52,8 +52,8 @@ interface
           entsize   : longint;
           entsize   : longint;
           { relocation }
           { relocation }
           relocsect : telf32Section;
           relocsect : telf32Section;
-          constructor createsec(sec:TSection);
-          constructor createname(const Aname:string;Atype,Aflags,Alink,Ainfo,Aalign,Aentsize:longint);
+          constructor create(const Aname:string;Atype:TAsmSectionType;Aalign:longint;Aoptions:TAsmSectionOptions);override;
+          constructor create_ext(const Aname:string;Atype:TAsmSectionType;Ashtype,Ashflags,Ashlink,Ashinfo,Aalign,Aentsize:longint);
           destructor  destroy;override;
           destructor  destroy;override;
        end;
        end;
 
 
@@ -70,13 +70,13 @@ interface
          syms     : Tdynamicarray;
          syms     : Tdynamicarray;
          constructor create(const n:string);
          constructor create(const n:string);
          destructor  destroy;override;
          destructor  destroy;override;
-         procedure createsection(sec:TSection);override;
-         procedure seTSectionsizes(var s:TAsmSectionSizes);override;
-         procedure writereloc(data,len:longint;p:tasmsymbol;relative:TAsmRelocationType);override;
+         function  sectionname(atype:tasmsectiontype;const aname:string):string;override;
+         procedure writereloc(data,len:aint;p:tasmsymbol;relative:TAsmRelocationType);override;
          procedure writesymbol(p:tasmsymbol);override;
          procedure writesymbol(p:tasmsymbol);override;
-         procedure writestabs(section:TSection;offset:longint;p:pchar;nidx,nother,line:longint;reloc:boolean);override;
-         procedure writesymstabs(section:TSection;offset:longint;p:pchar;ps:tasmsymbol;
-                                 nidx,nother,line:longint;reloc:boolean);override;
+         procedure writestabs(offset:aint;p:pchar;nidx,nother,line:longint;reloc:boolean);override;
+         procedure writesymstabs(offset:aint;p:pchar;ps:tasmsymbol;nidx,nother,line:longint;reloc:boolean);override;
+         procedure beforealloc;override;
+         procedure beforewrite;override;
        end;
        end;
 
 
        telf32objectoutput = class(tobjectoutput)
        telf32objectoutput = class(tobjectoutput)
@@ -87,6 +87,17 @@ interface
          procedure createshstrtab;
          procedure createshstrtab;
          procedure createsymtab;
          procedure createsymtab;
          procedure writesectionheader(s:telf32section);
          procedure writesectionheader(s:telf32section);
+         procedure writesectiondata(s:telf32section);
+         procedure section_write_symbol(p:tnamedindexitem;arg:pointer);
+         procedure section_write_sh_string(p:tnamedindexitem;arg:pointer);
+         procedure section_number_symbol(p:tnamedindexitem;arg:pointer);
+         procedure section_count_sects(p:tnamedindexitem;arg:pointer);
+         procedure section_create_relocsec(p:tnamedindexitem;arg:pointer);
+         procedure section_set_datapos(p:tnamedindexitem;arg:pointer);
+         procedure section_relocsec_set_datapos(p:tnamedindexitem;arg:pointer);
+         procedure section_write_data(p:tnamedindexitem;arg:pointer);
+         procedure section_write_sechdr(p:tnamedindexitem;arg:pointer);
+         procedure section_write_relocsec(p:tnamedindexitem;arg:pointer);
        protected
        protected
          function writedata(data:TAsmObjectData):boolean;override;
          function writedata(data:TAsmObjectData):boolean;override;
        public
        public
@@ -107,7 +118,7 @@ implementation
         strings,
         strings,
 {$endif}
 {$endif}
         verbose,
         verbose,
-        globtype,cutils,globals,fmodule;
+        cutils,globals,fmodule;
 
 
     const
     const
       symbolresize = 200*18;
       symbolresize = 200*18;
@@ -210,58 +221,62 @@ implementation
                                TSection
                                TSection
 ****************************************************************************}
 ****************************************************************************}
 
 
-    constructor telf32section.createsec(sec:TSection);
+    constructor telf32section.create(const Aname:string;Atype:TAsmSectionType;Aalign:longint;Aoptions:TAsmSectionOptions);
       var
       var
-        Aflags,Atype,Aalign,Aentsize : longint;
+        Ashflags,Ashtype,Aentsize : longint;
       begin
       begin
-        Aflags:=0;
-        Atype:=0;
-        Aalign:=0;
+        Ashflags:=0;
+        Ashtype:=0;
         Aentsize:=0;
         Aentsize:=0;
-        case sec of
+        case Atype of
           sec_code :
           sec_code :
             begin
             begin
-              Aflags:=SHF_ALLOC or SHF_EXECINSTR;
-              AType:=SHT_PROGBITS;
-              AAlign:=16;
+              Ashflags:=SHF_ALLOC or SHF_EXECINSTR;
+              AshType:=SHT_PROGBITS;
+              AAlign:=max(sizeof(aint),AAlign);
             end;
             end;
           sec_data :
           sec_data :
             begin
             begin
-              Aflags:=SHF_ALLOC or SHF_WRITE;
-              AType:=SHT_PROGBITS;
-              AAlign:=4;
+              Ashflags:=SHF_ALLOC or SHF_WRITE;
+              AshType:=SHT_PROGBITS;
+              AAlign:=max(sizeof(aint),AAlign);
             end;
             end;
           sec_bss :
           sec_bss :
             begin
             begin
-              Aflags:=SHF_ALLOC or SHF_WRITE;
-              AType:=SHT_NOBITS;
-              AAlign:=4;
+              Ashflags:=SHF_ALLOC or SHF_WRITE;
+              AshType:=SHT_NOBITS;
+              AAlign:=max(sizeof(aint),AAlign);
             end;
             end;
           sec_stab :
           sec_stab :
             begin
             begin
-              AType:=SHT_PROGBITS;
-              AAlign:=4;
+              AshType:=SHT_PROGBITS;
+              AAlign:=max(sizeof(aint),AAlign);
               Aentsize:=sizeof(telf32stab);
               Aentsize:=sizeof(telf32stab);
             end;
             end;
           sec_stabstr :
           sec_stabstr :
             begin
             begin
-              AType:=SHT_STRTAB;
+              AshType:=SHT_STRTAB;
               AAlign:=1;
               AAlign:=1;
             end;
             end;
         end;
         end;
-        createname(target_asm.secnames[sec],Atype,Aflags,0,0,Aalign,Aentsize);
+        create_ext(Aname,Atype,Ashtype,Ashflags,0,0,Aalign,Aentsize);
       end;
       end;
 
 
 
 
-    constructor telf32section.createname(const Aname:string;Atype,Aflags,Alink,Ainfo,Aalign,Aentsize:longint);
+    constructor telf32section.create_ext(const Aname:string;Atype:TAsmSectionType;Ashtype,Ashflags,Ashlink,Ashinfo,Aalign,Aentsize:longint);
+      var
+        aoptions : TAsmSectionOptions;
       begin
       begin
-        inherited create(Aname,Aalign,(AType=SHT_NOBITS));
+        aoptions:=[];
+        if (AshType=SHT_NOBITS) then
+          include(aoptions,aso_alloconly);
+        inherited create(Aname,Atype,Aalign,aoptions);
         secshidx:=0;
         secshidx:=0;
         shstridx:=0;
         shstridx:=0;
-        shtype:=AType;
-        shflags:=AFlags;
-        shlink:=Alink;
-        shinfo:=Ainfo;
+        shtype:=AshType;
+        shflags:=AshFlags;
+        shlink:=Ashlink;
+        shinfo:=Ashinfo;
         entsize:=Aentsize;
         entsize:=Aentsize;
         relocsect:=nil;
         relocsect:=nil;
       end;
       end;
@@ -284,28 +299,25 @@ implementation
         s : string;
         s : string;
       begin
       begin
         inherited create(n);
         inherited create(n);
+        CAsmSection:=TElf32Section;
         { reset }
         { reset }
         Syms:=TDynamicArray.Create(symbolresize);
         Syms:=TDynamicArray.Create(symbolresize);
         { default sections }
         { default sections }
-        symtabsect:=telf32section.createname('.symtab',2,0,0,0,4,16);
-        strtabsect:=telf32section.createname('.strtab',3,0,0,0,1,0);
-        shstrtabsect:=telf32section.createname('.shstrtab',3,0,0,0,1,0);
+        symtabsect:=telf32section.create_ext('.symtab',sec_custom,2,0,0,0,4,16);
+        strtabsect:=telf32section.create_ext('.strtab',sec_custom,3,0,0,0,1,0);
+        shstrtabsect:=telf32section.create_ext('.shstrtab',sec_custom,3,0,0,0,1,0);
         { insert the empty and filename as first in strtab }
         { insert the empty and filename as first in strtab }
         strtabsect.writestr(#0);
         strtabsect.writestr(#0);
         strtabsect.writestr(SplitFileName(current_module.mainsource^)+#0);
         strtabsect.writestr(SplitFileName(current_module.mainsource^)+#0);
         { we need at least the following sections }
         { we need at least the following sections }
-        createsection(sec_code);
-        createsection(sec_data);
-        createsection(sec_bss);
+        createsection(sec_code,'',0,[]);
+        createsection(sec_data,'',0,[]);
+        createsection(sec_bss,'',0,[]);
         { create stabs sections if debugging }
         { create stabs sections if debugging }
         if (cs_debuginfo in aktmoduleswitches) then
         if (cs_debuginfo in aktmoduleswitches) then
          begin
          begin
-           createsection(sec_stab);
-           createsection(sec_stabstr);
-           writestabs(sec_none,0,nil,0,0,0,false);
-           { write zero pchar and name together (PM) }
-           s:=#0+SplitFileName(current_module.mainsource^)+#0;
-           sects[sec_stabstr].write(s[1],length(s));
+           stabssec:=createsection(sec_stab,'',0,[]);
+           stabstrsec:=createsection(sec_stabstr,'',0,[]);
          end;
          end;
       end;
       end;
 
 
@@ -320,20 +332,35 @@ implementation
       end;
       end;
 
 
 
 
-    procedure telf32objectdata.createsection(sec:TSection);
+    function telf32objectdata.sectionname(atype:tasmsectiontype;const aname:string):string;
+      const
+        secnames : array[tasmsectiontype] of string[12] = ('',
+{$warning TODO .rodata not yet working}
+          '.text','.data','.data','.bss',
+          'common',
+          '.note',
+          '.stab','.stabstr',
+          '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+          '.eh_frame',
+          '.debug_frame'
+        );
       begin
       begin
-        sects[sec]:=telf32Section.createsec(Sec);
+        if use_smartlink_section and
+           (atype<>sec_bss) and
+           (aname<>'') then
+          result:='.gnu.linkonce'+copy(secnames[atype],1,2)+'.'+aname
+        else
+          result:=secnames[atype];
       end;
       end;
 
 
 
 
     procedure telf32objectdata.writesymbol(p:tasmsymbol);
     procedure telf32objectdata.writesymbol(p:tasmsymbol);
       begin
       begin
+        if currsec=nil then
+          internalerror(200403291);
         { already written ? }
         { already written ? }
         if p.indexnr<>-1 then
         if p.indexnr<>-1 then
          exit;
          exit;
-        { be sure that the section will exists }
-        if (p.section<>sec_none) and not(assigned(sects[p.section])) then
-          createsection(p.section);
         { calculate symbol index }
         { calculate symbol index }
         if (p.currbind<>AB_LOCAL) then
         if (p.currbind<>AB_LOCAL) then
          begin
          begin
@@ -346,12 +373,12 @@ implementation
       end;
       end;
 
 
 
 
-    procedure telf32objectdata.writereloc(data,len:longint;p:tasmsymbol;relative:TAsmRelocationType);
+    procedure telf32objectdata.writereloc(data,len:aint;p:tasmsymbol;relative:TAsmRelocationType);
       var
       var
         symaddr : longint;
         symaddr : longint;
       begin
       begin
-        if not assigned(sects[currsec]) then
-         createsection(currsec);
+        if currsec=nil then
+          internalerror(200403292);
         if assigned(p) then
         if assigned(p) then
          begin
          begin
            { real address of the symbol }
            { real address of the symbol }
@@ -362,12 +389,12 @@ implementation
                case relative of
                case relative of
                  RELOC_ABSOLUTE :
                  RELOC_ABSOLUTE :
                    begin
                    begin
-                     sects[currsec].addsectionreloc(sects[currsec].datasize,currsec,RELOC_ABSOLUTE);
+                     currsec.addsectionreloc(currsec.datasize,currsec,RELOC_ABSOLUTE);
                      inc(data,symaddr);
                      inc(data,symaddr);
                    end;
                    end;
                  RELOC_RELATIVE :
                  RELOC_RELATIVE :
                    begin
                    begin
-                     inc(data,symaddr-len-sects[currsec].datasize);
+                     inc(data,symaddr-len-currsec.datasize);
                    end;
                    end;
                  RELOC_RVA :
                  RELOC_RVA :
                    internalerror(3219583);
                    internalerror(3219583);
@@ -376,27 +403,30 @@ implementation
            else
            else
              begin
              begin
                writesymbol(p);
                writesymbol(p);
-               if (p.section<>sec_none) and (relative<>RELOC_RELATIVE) then
+               { For common (global .bss) symbols a reloc by sym is required }
+               if assigned(p.section) and
+                  (p.currbind<>AB_COMMON) and
+                  (relative<>RELOC_RELATIVE) then
                 begin
                 begin
-                  sects[currsec].addsectionreloc(sects[currsec].datasize,p.section,relative);
+                  currsec.addsectionreloc(currsec.datasize,p.section,relative);
                   inc(data,symaddr);
                   inc(data,symaddr);
                 end
                 end
                else
                else
-                sects[currsec].addsymreloc(sects[currsec].datasize,p,relative);
+                currsec.addsymreloc(currsec.datasize,p,relative);
                if relative=RELOC_RELATIVE then
                if relative=RELOC_RELATIVE then
                 begin
                 begin
                   if p.currbind=AB_EXTERNAL then
                   if p.currbind=AB_EXTERNAL then
                    dec(data,len)
                    dec(data,len)
                   else
                   else
-                   dec(data,len+sects[currsec].datasize);
+                   dec(data,len+currsec.datasize);
                 end;
                 end;
             end;
             end;
          end;
          end;
-        sects[currsec].write(data,len);
+        currsec.write(data,len);
       end;
       end;
 
 
 
 
-    procedure telf32objectdata.writestabs(section:TSection;offset:longint;p:pchar;nidx,nother,line:longint;reloc : boolean);
+    procedure telf32objectdata.writestabs(offset:aint;p:pchar;nidx,nother,line:longint;reloc : boolean);
       var
       var
         stab : telf32stab;
         stab : telf32stab;
       begin
       begin
@@ -404,55 +434,75 @@ implementation
          begin
          begin
            if (offset=-1) then
            if (offset=-1) then
             begin
             begin
-              if section=sec_none then
+              if currsec=nil then
                offset:=0
                offset:=0
               else
               else
-               offset:=sects[section].datasize;
+               offset:=currsec.datasize;
             end;
             end;
          end;
          end;
         fillchar(stab,sizeof(telf32stab),0);
         fillchar(stab,sizeof(telf32stab),0);
         if assigned(p) and (p[0]<>#0) then
         if assigned(p) and (p[0]<>#0) then
          begin
          begin
-           stab.strpos:=sects[sec_stabstr].datasize;
-           sects[sec_stabstr].write(p^,strlen(p)+1);
+           stab.strpos:=stabstrsec.datasize;
+           stabstrsec.write(p^,strlen(p)+1);
          end;
          end;
         stab.ntype:=nidx;
         stab.ntype:=nidx;
         stab.ndesc:=line;
         stab.ndesc:=line;
         stab.nother:=nother;
         stab.nother:=nother;
         stab.nvalue:=offset;
         stab.nvalue:=offset;
-        sects[sec_stab].write(stab,sizeof(stab));
+        stabssec.write(stab,sizeof(stab));
         { when the offset is not 0 then write a relocation, take also the
         { when the offset is not 0 then write a relocation, take also the
           hdrstab into account with the offset }
           hdrstab into account with the offset }
         if reloc then
         if reloc then
-         sects[sec_stab].addsectionreloc(sects[sec_stab].datasize-4,section,RELOC_ABSOLUTE);
+         stabssec.addsectionreloc(stabssec.datasize-4,currsec,RELOC_ABSOLUTE);
       end;
       end;
 
 
 
 
-    procedure telf32objectdata.writesymstabs(section:TSection;offset:longint;p:pchar;ps:tasmsymbol;
-                                             nidx,nother,line:longint;reloc:boolean);
+    procedure telf32objectdata.writesymstabs(offset:aint;p:pchar;ps:tasmsymbol;nidx,nother,line:longint;reloc:boolean);
       var
       var
         stab : telf32stab;
         stab : telf32stab;
       begin
       begin
         fillchar(stab,sizeof(telf32stab),0);
         fillchar(stab,sizeof(telf32stab),0);
         if assigned(p) and (p[0]<>#0) then
         if assigned(p) and (p[0]<>#0) then
          begin
          begin
-           stab.strpos:=sects[sec_stabstr].datasize;
-           sects[sec_stabstr].write(p^,strlen(p)+1);
+           stab.strpos:=stabstrsec.datasize;
+           stabstrsec.write(p^,strlen(p)+1);
          end;
          end;
         stab.ntype:=nidx;
         stab.ntype:=nidx;
         stab.ndesc:=line;
         stab.ndesc:=line;
         stab.nother:=nother;
         stab.nother:=nother;
         stab.nvalue:=0;
         stab.nvalue:=0;
-        sects[sec_stab].write(stab,sizeof(stab));
+        stabssec.write(stab,sizeof(stab));
         { when the offset is not 0 then write a relocation, take also the
         { when the offset is not 0 then write a relocation, take also the
           hdrstab into account with the offset }
           hdrstab into account with the offset }
         if reloc then
         if reloc then
-         sects[sec_stab].addsymreloc(sects[sec_stab].datasize-4,ps,RELOC_ABSOLUTE);
+         stabssec.addsymreloc(stabssec.datasize-4,ps,RELOC_ABSOLUTE);
       end;
       end;
 
 
 
 
-    procedure telf32objectdata.seTSectionsizes(var s:TAsmSectionSizes);
+    procedure telf32objectdata.beforealloc;
       begin
       begin
+        { create stabs sections if debugging }
+        if (cs_debuginfo in aktmoduleswitches) then
+          begin
+            StabsSec.Alloc(sizeof(telf32stab));
+            StabStrSec.Alloc(length(SplitFileName(current_module.mainsource^))+2);
+          end;
+      end;
+
+
+    procedure telf32objectdata.beforewrite;
+      var
+        s : string;
+      begin
+        { create stabs sections if debugging }
+        if (cs_debuginfo in aktmoduleswitches) then
+         begin
+           writestabs(0,nil,0,0,0,false);
+           { write zero pchar and name together (PM) }
+           s:=#0+SplitFileName(current_module.mainsource^)+#0;
+           stabstrsec.write(s[1],length(s));
+         end;
       end;
       end;
 
 
 
 
@@ -475,7 +525,7 @@ implementation
         with elf32data do
         with elf32data do
          begin
          begin
            { create the reloc section }
            { create the reloc section }
-           s.relocsect:=telf32section.createname('.rel'+s.name,9,0,symtabsect.secshidx,s.secshidx,4,8);
+           s.relocsect:=telf32section.create_ext('.rel'+s.name,sec_custom,9,0,symtabsect.secshidx,s.secshidx,4,8);
            { add the relocations }
            { add the relocations }
            r:=TasmRelocation(s.relocations.first);
            r:=TasmRelocation(s.relocations.first);
            while assigned(r) do
            while assigned(r) do
@@ -484,7 +534,7 @@ implementation
               if assigned(r.symbol) then
               if assigned(r.symbol) then
                begin
                begin
                  if (r.symbol.currbind=AB_LOCAL) then
                  if (r.symbol.currbind=AB_LOCAL) then
-                  relsym:=sects[r.symbol.section].secsymidx
+                  relsym:=r.symbol.section.secsymidx
                  else
                  else
                   begin
                   begin
                     if r.symbol.indexnr=-1 then
                     if r.symbol.indexnr=-1 then
@@ -494,8 +544,8 @@ implementation
                   end;
                   end;
                end
                end
               else
               else
-               if r.section<>sec_none then
-                relsym:=sects[r.section].secsymidx
+               if r.section<>nil then
+                relsym:=r.section.secsymidx
                else
                else
                 relsym:=SHN_UNDEF;
                 relsym:=SHN_UNDEF;
               case r.typ of
               case r.typ of
@@ -513,10 +563,23 @@ implementation
       end;
       end;
 
 
 
 
+    procedure telf32objectoutput.section_write_symbol(p:tnamedindexitem;arg:pointer);
+      var
+        elfsym : telf32symbol;
+      begin
+        fillchar(elfsym,sizeof(elfsym),0);
+        elfsym.st_name:=telf32section(p).shstridx;
+        elfsym.st_info:=STT_SECTION;
+        elfsym.st_shndx:=telf32section(p).secshidx;
+        elf32data.symtabsect.write(elfsym,sizeof(elfsym));
+        { increase locals count }
+        inc(plongint(arg)^);
+      end;
+
+
     procedure telf32objectoutput.createsymtab;
     procedure telf32objectoutput.createsymtab;
       var
       var
         elfsym : telf32symbol;
         elfsym : telf32symbol;
-        sec : TSection;
         locals : longint;
         locals : longint;
         sym : tasmsymbol;
         sym : tasmsymbol;
       begin
       begin
@@ -532,16 +595,7 @@ implementation
            elfsym.st_shndx:=SHN_ABS;
            elfsym.st_shndx:=SHN_ABS;
            symtabsect.write(elfsym,sizeof(elfsym));
            symtabsect.write(elfsym,sizeof(elfsym));
            { section }
            { section }
-           for sec:=low(TSection) to high(TSection) do
-            if assigned(sects[sec]) then
-             begin
-               fillchar(elfsym,sizeof(elfsym),0);
-               elfsym.st_name:=telf32section(sects[sec]).shstridx;
-               elfsym.st_info:=STT_SECTION;
-               elfsym.st_shndx:=telf32section(sects[sec]).secshidx;
-               symtabsect.write(elfsym,sizeof(elfsym));
-               inc(locals);
-             end;
+           sects.foreach(@section_write_symbol,@locals);
            { symbols }
            { symbols }
            sym:=Tasmsymbol(symbols.First);
            sym:=Tasmsymbol(symbols.First);
            while assigned(sym) do
            while assigned(sym) do
@@ -582,8 +636,8 @@ implementation
               if sym.currbind=AB_COMMON then
               if sym.currbind=AB_COMMON then
                elfsym.st_shndx:=SHN_COMMON
                elfsym.st_shndx:=SHN_COMMON
               else
               else
-               if assigned(sects[sym.section]) then
-                elfsym.st_shndx:=telf32section(sects[sym.section]).secshidx
+               if assigned(sym.section) then
+                elfsym.st_shndx:=telf32section(sym.section).secshidx
                else
                else
                 elfsym.st_shndx:=SHN_UNDEF;
                 elfsym.st_shndx:=SHN_UNDEF;
               symtabsect.write(elfsym,sizeof(elfsym));
               symtabsect.write(elfsym,sizeof(elfsym));
@@ -596,9 +650,15 @@ implementation
       end;
       end;
 
 
 
 
+    procedure telf32objectoutput.section_write_sh_string(p:tnamedindexitem;arg:pointer);
+      begin
+        telf32section(p).shstridx:=elf32data.shstrtabsect.writestr(tasmsection(p).name+#0);
+        if assigned(telf32section(p).relocsect) then
+          telf32section(p).relocsect.shstridx:=elf32data.shstrtabsect.writestr(telf32section(p).relocsect.name+#0);
+      end;
+
+
     procedure telf32objectoutput.createshstrtab;
     procedure telf32objectoutput.createshstrtab;
-      var
-        sec : TSection;
       begin
       begin
         with elf32data do
         with elf32data do
          begin
          begin
@@ -608,13 +668,7 @@ implementation
               symtabsect.shstridx:=writestr('.symtab'#0);
               symtabsect.shstridx:=writestr('.symtab'#0);
               strtabsect.shstridx:=writestr('.strtab'#0);
               strtabsect.shstridx:=writestr('.strtab'#0);
               shstrtabsect.shstridx:=writestr('.shstrtab'#0);
               shstrtabsect.shstridx:=writestr('.shstrtab'#0);
-              for sec:=low(TSection) to high(TSection) do
-               if assigned(sects[sec]) then
-                begin
-                  telf32section(sects[sec]).shstridx:=writestr(sects[sec].name+#0);
-                  if assigned(telf32section(sects[sec]).relocsect) then
-                   telf32section(sects[sec]).relocsect.shstridx:=writestr(telf32section(sects[sec]).relocsect.name+#0);
-                end;
+              sects.foreach(@section_write_sh_string,nil);
             end;
             end;
          end;
          end;
       end;
       end;
@@ -638,37 +692,108 @@ implementation
       end;
       end;
 
 
 
 
+
+    procedure telf32objectoutput.writesectiondata(s:telf32section);
+      var
+        hp : pdynamicblock;
+      begin
+        FWriter.writezeros(s.dataalignbytes);
+        s.alignsection;
+        hp:=s.data.firstblock;
+        while assigned(hp) do
+          begin
+            FWriter.write(hp^.data,hp^.used);
+            hp:=hp^.next;
+          end;
+      end;
+
+
+    procedure telf32objectoutput.section_number_symbol(p:tnamedindexitem;arg:pointer);
+      begin
+        tasmsection(p).secsymidx:=plongint(arg)^;
+        inc(plongint(arg)^);
+      end;
+
+
+    procedure telf32objectoutput.section_count_sects(p:tnamedindexitem;arg:pointer);
+      begin
+        telf32section(p).secshidx:=plongint(arg)^;
+        inc(plongint(arg)^);
+        if telf32section(p).relocations.count>0 then
+          inc(plongint(arg)^);
+      end;
+
+
+    procedure telf32objectoutput.section_create_relocsec(p:tnamedindexitem;arg:pointer);
+      begin
+        if (telf32section(p).relocations.count>0) then
+          createrelocsection(telf32section(p));
+      end;
+
+
+    procedure telf32objectoutput.section_set_datapos(p:tnamedindexitem;arg:pointer);
+      begin
+        if (aso_alloconly in tasmsection(p).secoptions) then
+          tasmsection(p).datapos:=paint(arg)^
+        else
+          tasmsection(p).setdatapos(paint(arg)^);
+      end;
+
+
+    procedure telf32objectoutput.section_relocsec_set_datapos(p:tnamedindexitem;arg:pointer);
+      begin
+        if assigned(telf32section(p).relocsect) then
+          telf32section(p).relocsect.setdatapos(paint(arg)^);
+      end;
+
+
+    procedure telf32objectoutput.section_write_data(p:tnamedindexitem;arg:pointer);
+      begin
+        if (aso_alloconly in tasmsection(p).secoptions) then
+          exit;
+        if tasmsection(p).data=nil then
+          internalerror(200403073);
+        writesectiondata(telf32section(p));
+      end;
+
+
+    procedure telf32objectoutput.section_write_sechdr(p:tnamedindexitem;arg:pointer);
+      begin
+        writesectionheader(telf32section(p));
+        if assigned(telf32section(p).relocsect) then
+          writesectionheader(telf32section(p).relocsect);
+      end;
+
+
+    procedure telf32objectoutput.section_write_relocsec(p:tnamedindexitem;arg:pointer);
+      begin
+        if assigned(telf32section(p).relocsect) then
+          writesectiondata(telf32section(p).relocsect);
+      end;
+
+
+
     function telf32objectoutput.writedata(data:TAsmObjectData):boolean;
     function telf32objectoutput.writedata(data:TAsmObjectData):boolean;
       var
       var
         header : telf32header;
         header : telf32header;
-        datapos,
+        datapos : aint;
         shoffset,
         shoffset,
         nsects : longint;
         nsects : longint;
         hstab  : telf32stab;
         hstab  : telf32stab;
-        sec    : TSection;
         empty  : array[0..63] of byte;
         empty  : array[0..63] of byte;
-        hp     : pdynamicblock;
       begin
       begin
         result:=false;
         result:=false;
         elf32data:=telf32objectdata(data);
         elf32data:=telf32objectdata(data);
         with elf32data do
         with elf32data do
          begin
          begin
-         { calc amount of sections we have }
-           fillchar(empty,sizeof(empty),0);
-           nsects:=1;
+           { calc amount of sections we have }
            initsym:=2;
            initsym:=2;
-           for sec:=low(TSection) to high(TSection) do
-            if assigned(sects[sec]) then
-             begin
-               { each section requires a symbol for relocation }
-               sects[sec].secsymidx:=initsym;
-               inc(initsym);
-               { also create the index in the section header table }
-               telf32section(sects[sec]).secshidx:=nsects;
-               inc(nsects);
-               if sects[sec].relocations.count>0 then
-                inc(nsects);
-             end;
+           nsects:=1;
+           fillchar(empty,sizeof(empty),0);
+           { each section requires a symbol for relocation }
+           sects.foreach(@section_number_symbol,@initsym);
+           { also create the index in the section header table }
+           sects.foreach(@section_count_sects,@nsects);
            { add default sections follows }
            { add default sections follows }
            shstrtabsect.secshidx:=nsects;
            shstrtabsect.secshidx:=nsects;
            inc(nsects);
            inc(nsects);
@@ -678,21 +803,18 @@ implementation
            inc(nsects);
            inc(nsects);
          { For the stab section we need an HdrSym which can now be
          { For the stab section we need an HdrSym which can now be
            calculated more easily }
            calculated more easily }
-           if assigned(sects[sec_stab]) then
+           if assigned(stabssec) then
             begin
             begin
               hstab.strpos:=1;
               hstab.strpos:=1;
               hstab.ntype:=0;
               hstab.ntype:=0;
               hstab.nother:=0;
               hstab.nother:=0;
-              hstab.ndesc:=(sects[sec_stab].datasize div sizeof(telf32stab))-1{+1 according to gas output PM};
-              hstab.nvalue:=sects[sec_stabstr].datasize;
-              sects[sec_stab].Data.seek(0);
-              sects[sec_stab].Data.write(hstab,sizeof(hstab));
+              hstab.ndesc:=(stabssec.datasize div sizeof(telf32stab))-1{+1 according to gas output PM};
+              hstab.nvalue:=stabstrsec.datasize;
+              stabssec.Data.seek(0);
+              stabssec.Data.write(hstab,sizeof(hstab));
             end;
             end;
          { Create the relocation sections }
          { Create the relocation sections }
-           for sec:=low(TSection) to high(TSection) do
-            if assigned(sects[sec]) and
-               (sects[sec].relocations.count>0) then
-              createrelocsection(telf32section(sects[sec]));
+           sects.foreach(@section_create_relocsec,nil);
          { create .symtab and .strtab }
          { create .symtab and .strtab }
            createsymtab;
            createsymtab;
          { create .shstrtab }
          { create .shstrtab }
@@ -700,33 +822,18 @@ implementation
          { Calculate the filepositions }
          { Calculate the filepositions }
            datapos:=$40; { elfheader + alignment }
            datapos:=$40; { elfheader + alignment }
            { sections first }
            { sections first }
-           for sec:=low(TSection) to high(TSection) do
-            if assigned(sects[sec]) then
-             begin
-               sects[sec].datapos:=datapos;
-               if assigned(sects[sec].data) then
-                 inc(datapos,sects[sec].aligneddatasize);
-             end;
+           sects.foreach(@section_set_datapos,@datapos);
            { shstrtab }
            { shstrtab }
-           shstrtabsect.datapos:=datapos;
-           inc(datapos,shstrtabsect.aligneddatasize);
+           shstrtabsect.setdatapos(datapos);
            { section headers }
            { section headers }
            shoffset:=datapos;
            shoffset:=datapos;
            inc(datapos,nsects*sizeof(telf32sechdr));
            inc(datapos,nsects*sizeof(telf32sechdr));
            { symtab }
            { symtab }
-           symtabsect.datapos:=datapos;
-           inc(datapos,symtabsect.aligneddatasize);
+           symtabsect.setdatapos(datapos);
            { strtab }
            { strtab }
-           strtabsect.datapos:=datapos;
-           inc(datapos,align(strtabsect.datasize,4));
+           strtabsect.setdatapos(datapos);
            { .rel sections }
            { .rel sections }
-           for sec:=low(TSection) to high(TSection) do
-            if assigned(sects[sec]) and
-               assigned(telf32section(sects[sec]).relocsect) then
-             begin
-               telf32section(sects[sec]).relocsect.datapos:=datapos;
-               inc(datapos,telf32section(sects[sec]).relocsect.aligneddatasize);
-             end;
+           sects.foreach(@section_relocsec_set_datapos,@datapos);
          { Write ELF Header }
          { Write ELF Header }
            fillchar(header,sizeof(header),0);
            fillchar(header,sizeof(header),0);
            header.magic0123:=$464c457f; { = #127'ELF' }
            header.magic0123:=$464c457f; { = #127'ELF' }
@@ -744,67 +851,21 @@ implementation
            writer.write(header,sizeof(header));
            writer.write(header,sizeof(header));
            writer.write(empty,$40-sizeof(header)); { align }
            writer.write(empty,$40-sizeof(header)); { align }
          { Sections }
          { Sections }
-           for sec:=low(TSection) to high(TSection) do
-            if assigned(sects[sec]) and
-               assigned(sects[sec].data) then
-             begin
-               sects[sec].alignsection;
-               hp:=sects[sec].Data.firstblock;
-               while assigned(hp) do
-                begin
-                  writer.write(hp^.data,hp^.used);
-                  hp:=hp^.next;
-                end;
-             end;
+           sects.foreach(@section_write_data,nil);
          { .shstrtab }
          { .shstrtab }
-           shstrtabsect.alignsection;
-           hp:=shstrtabsect.Data.firstblock;
-           while assigned(hp) do
-            begin
-              writer.write(hp^.data,hp^.used);
-              hp:=hp^.next;
-            end;
+           writesectiondata(shstrtabsect);
          { section headers, start with an empty header for sh_undef }
          { section headers, start with an empty header for sh_undef }
            writer.write(empty,sizeof(telf32sechdr));
            writer.write(empty,sizeof(telf32sechdr));
-           for sec:=low(TSection) to high(TSection) do
-            if assigned(sects[sec]) then
-             begin
-               writesectionheader(telf32section(sects[sec]));
-               if assigned(telf32section(sects[sec]).relocsect) then
-                writesectionheader(telf32section(sects[sec]).relocsect);
-             end;
+           sects.foreach(@section_write_sechdr,nil);
            writesectionheader(shstrtabsect);
            writesectionheader(shstrtabsect);
            writesectionheader(symtabsect);
            writesectionheader(symtabsect);
            writesectionheader(strtabsect);
            writesectionheader(strtabsect);
          { .symtab }
          { .symtab }
-           symtabsect.alignsection;
-           hp:=symtabsect.Data.firstblock;
-           while assigned(hp) do
-            begin
-              writer.write(hp^.data,hp^.used);
-              hp:=hp^.next;
-            end;
+           writesectiondata(symtabsect);
          { .strtab }
          { .strtab }
-           strtabsect.writealign(4);
-           hp:=strtabsect.Data.firstblock;
-           while assigned(hp) do
-            begin
-              writer.write(hp^.data,hp^.used);
-              hp:=hp^.next;
-            end;
+           writesectiondata(strtabsect);
          { .rel sections }
          { .rel sections }
-           for sec:=low(TSection) to high(TSection) do
-            if assigned(sects[sec]) and
-               assigned(telf32section(sects[sec]).relocsect) then
-             begin
-               telf32section(sects[sec]).relocsect.alignsection;
-               hp:=telf32section(sects[sec]).relocsect.Data.firstblock;
-               while assigned(hp) do
-                begin
-                  writer.write(hp^.data,hp^.used);
-                  hp:=hp^.next;
-                end;
-             end;
+           sects.foreach(@section_write_relocsec,nil);
          end;
          end;
         result:=true;
         result:=true;
       end;
       end;
@@ -833,16 +894,10 @@ implementation
             asmbin : '';
             asmbin : '';
             asmcmd : '';
             asmcmd : '';
             supported_target : system_any;  //target_i386_linux;
             supported_target : system_any;  //target_i386_linux;
-            outputbinary : true;
-            allowdirect : false;
-            needar : false;
-            labelprefix_only_inside_procedure: false;
+//            flags : [af_outputbinary,af_smartlink_sections];
+            flags : [af_outputbinary];
             labelprefix : '.L';
             labelprefix : '.L';
             comment : '';
             comment : '';
-            secnames : ('',
-              '.text','.data','.bss',
-              '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
-              '.stab','.stabstr','')
           );
           );
 
 
 
 
@@ -851,7 +906,29 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.19  2003-04-22 14:33:38  peter
+  Revision 1.20  2004-06-16 20:07:09  florian
+    * dwarf branch merged
+
+  Revision 1.19.2.6  2004/05/18 20:14:18  peter
+    * no section smartlink when using debuginfo
+
+  Revision 1.19.2.5  2004/05/10 21:28:34  peter
+    * section_smartlink enabled for gas under linux
+
+  Revision 1.19.2.4  2004/05/01 16:02:09  peter
+    * POINTER_SIZE replaced with sizeof(aint)
+    * aint,aword,tconst*int moved to globtype
+
+  Revision 1.19.2.3  2004/04/26 21:01:36  peter
+    * aint fixes
+
+  Revision 1.19.2.2  2004/04/12 19:34:46  peter
+    * basic framework for dwarf CFI
+
+  Revision 1.19.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
+  Revision 1.19  2003/04/22 14:33:38  peter
     * removed some notes/hints
     * removed some notes/hints
 
 
   Revision 1.18  2002/08/12 15:08:39  carl
   Revision 1.18  2002/08/12 15:08:39  carl

+ 14 - 8
compiler/ogmap.pas

@@ -44,8 +44,8 @@ interface
          procedure AddCommonSymbolsHeader;
          procedure AddCommonSymbolsHeader;
          procedure AddCommonSymbol(p:tasmsymbol);
          procedure AddCommonSymbol(p:tasmsymbol);
          procedure AddMemoryMapHeader;
          procedure AddMemoryMapHeader;
-         procedure AddMemoryMapSection(p:texesection);
-         procedure AddMemoryMapObjectData(p:TAsmObjectData;sec:TSection);
+         procedure AddMemoryMapExeSection(p:texesection);
+         procedure AddMemoryMapObjectSection(p:TAsmSection);
          procedure AddMemoryMapSymbol(p:tasmsymbol);
          procedure AddMemoryMapSymbol(p:tasmsymbol);
        end;
        end;
 
 
@@ -102,7 +102,7 @@ implementation
             writeln(t,p.name);
             writeln(t,p.name);
             s:='';
             s:='';
           end;
           end;
-         writeln(t,PadSpace(s,20)+'0x'+PadSpace(hexstr(p.size,1),16)+TAsmObjectData(p.objectdata).name);
+         writeln(t,PadSpace(s,20)+'0x'+PadSpace(hexstr(p.size,1),16)+p.owner.name);
        end;
        end;
 
 
 
 
@@ -114,18 +114,18 @@ implementation
        end;
        end;
 
 
 
 
-     procedure TExeMap.AddMemoryMapSection(p:texesection);
+     procedure TExeMap.AddMemoryMapExeSection(p:texesection);
        begin
        begin
          { .text           0x000018a8     0xd958 }
          { .text           0x000018a8     0xd958 }
          writeln(t,PadSpace(p.name,18)+PadSpace('0x'+HexStr(p.mempos,8),15)+'0x'+HexStr(p.memsize,1));
          writeln(t,PadSpace(p.name,18)+PadSpace('0x'+HexStr(p.mempos,8),15)+'0x'+HexStr(p.memsize,1));
        end;
        end;
 
 
 
 
-     procedure TExeMap.AddMemoryMapObjectData(p:TAsmObjectData;sec:TSection);
+     procedure TExeMap.AddMemoryMapObjectSection(p:TAsmSection);
        begin
        begin
          { .text           0x000018a8     0xd958     object.o }
          { .text           0x000018a8     0xd958     object.o }
-         writeln(t,' '+PadSpace(p.sects[sec].name,17)+PadSpace('0x'+HexStr(p.sects[sec].mempos,8),16)+
-                   '0x'+HexStr(p.sects[sec].memsize,1)+' '+p.name);
+         writeln(t,' '+PadSpace(p.name,17)+PadSpace('0x'+HexStr(p.mempos,8),16)+
+                   '0x'+HexStr(p.memsize,1)+' '+p.owner.name);
        end;
        end;
 
 
 
 
@@ -138,7 +138,13 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2003-04-22 14:33:38  peter
+  Revision 1.3  2004-06-16 20:07:09  florian
+    * dwarf branch merged
+
+  Revision 1.2.2.1  2004/04/08 18:33:22  peter
+    * rewrite of TAsmSection
+
+  Revision 1.2  2003/04/22 14:33:38  peter
     * removed some notes/hints
     * removed some notes/hints
 
 
   Revision 1.1  2002/07/01 18:46:24  peter
   Revision 1.1  2002/07/01 18:46:24  peter

Some files were not shown because too many files changed in this diff