Sfoglia il codice sorgente

* generic tlocation
* move tlocation to cgutils

peter 21 anni fa
parent
commit
c95a859f0a
97 ha cambiato i file con 1020 aggiunte e 870 eliminazioni
  1. 7 3
      compiler/aasmbase.pas
  2. 11 7
      compiler/alpha/cpubase.pas
  3. 8 4
      compiler/alpha/cpupara.pas
  4. 6 2
      compiler/aopt.pas
  5. 6 2
      compiler/aoptbase.pas
  6. 6 2
      compiler/aoptobj.pas
  7. 8 4
      compiler/arm/cpubase.pas
  8. 7 3
      compiler/arm/narmcnv.pas
  9. 5 5
      compiler/assemble.pas
  10. 12 8
      compiler/cg64f32.pas
  11. 6 2
      compiler/cg64f64.pas
  12. 10 11
      compiler/cgbase.pas
  13. 7 52
      compiler/cgobj.pas
  14. 93 4
      compiler/cgutils.pas
  15. 5 2
      compiler/defcmp.pas
  16. 6 2
      compiler/defutil.pas
  17. 6 3
      compiler/dwarf.pas
  18. 7 2
      compiler/globals.pas
  19. 11 1
      compiler/globtype.pas
  20. 6 3
      compiler/i386/ag386int.pas
  21. 6 2
      compiler/i386/ag386nsm.pas
  22. 7 4
      compiler/i386/cgcpu.pas
  23. 12 2
      compiler/i386/cpubase.inc
  24. 5 14
      compiler/i386/cpuinfo.pas
  25. 6 2
      compiler/i386/cpupara.pas
  26. 7 3
      compiler/i386/csopt386.pas
  27. 6 2
      compiler/i386/daopt386.pas
  28. 22 18
      compiler/i386/n386add.pas
  29. 5 4
      compiler/i386/n386cal.pas
  30. 6 2
      compiler/i386/n386con.pas
  31. 36 32
      compiler/i386/n386mat.pas
  32. 8 4
      compiler/i386/n386mem.pas
  33. 6 2
      compiler/i386/n386obj.pas
  34. 6 2
      compiler/i386/ra386int.pas
  35. 11 7
      compiler/m68k/cpubase.pas
  36. 6 2
      compiler/m68k/n68kmat.pas
  37. 15 11
      compiler/m68k/ncpuadd.pas
  38. 9 4
      compiler/nbas.pas
  39. 6 2
      compiler/ncal.pas
  40. 16 12
      compiler/ncgadd.pas
  41. 7 4
      compiler/ncgbas.pas
  42. 15 11
      compiler/ncgcal.pas
  43. 7 3
      compiler/ncgcnv.pas
  44. 6 2
      compiler/ncgcon.pas
  45. 7 4
      compiler/ncginl.pas
  46. 23 1
      compiler/ncgld.pas
  47. 9 5
      compiler/ncgmat.pas
  48. 6 2
      compiler/ncgopt.pas
  49. 8 4
      compiler/ncgset.pas
  50. 35 31
      compiler/ncgutil.pas
  51. 7 3
      compiler/new/powerpc/cpubase.pas
  52. 6 2
      compiler/ninl.pas
  53. 5 9
      compiler/nld.pas
  54. 6 2
      compiler/node.pas
  55. 16 11
      compiler/parabase.pas
  56. 6 2
      compiler/paramgr.pas
  57. 6 2
      compiler/powerpc/aasmcpu.pas
  58. 6 2
      compiler/powerpc/agppcgas.pas
  59. 8 4
      compiler/powerpc/agppcmpw.pas
  60. 10 7
      compiler/powerpc/cgcpu.pas
  61. 12 92
      compiler/powerpc/cpubase.pas
  62. 5 14
      compiler/powerpc/cpuinfo.pas
  63. 47 43
      compiler/powerpc/nppcadd.pas
  64. 8 4
      compiler/powerpc/nppccnv.pas
  65. 6 2
      compiler/powerpc/nppcinl.pas
  66. 47 43
      compiler/powerpc/nppcmat.pas
  67. 7 3
      compiler/procinfo.pas
  68. 13 14
      compiler/rautils.pas
  69. 6 6
      compiler/rgobj.pas
  70. 7 3
      compiler/scanner.pas
  71. 6 2
      compiler/sparc/aasmcpu.pas
  72. 7 3
      compiler/sparc/cgcpu.pas
  73. 11 74
      compiler/sparc/cpubase.pas
  74. 6 2
      compiler/sparc/cpugas.pas
  75. 5 13
      compiler/sparc/cpuinfo.pas
  76. 6 2
      compiler/sparc/ncpuadd.pas
  77. 10 6
      compiler/sparc/ncpuinln.pas
  78. 25 21
      compiler/sparc/ncpumat.pas
  79. 8 4
      compiler/sparc/rgcpu.pas
  80. 6 2
      compiler/symdef.pas
  81. 8 4
      compiler/symsym.pas
  82. 6 4
      compiler/symutil.pas
  83. 21 5
      compiler/tgobj.pas
  84. 12 8
      compiler/vis/cpubase.pas
  85. 10 5
      compiler/x86/aasmcpu.pas
  86. 6 3
      compiler/x86/agx86att.pas
  87. 6 2
      compiler/x86/cga.pas
  88. 6 3
      compiler/x86/cgx86.pas
  89. 6 93
      compiler/x86/cpubase.pas
  90. 7 3
      compiler/x86/nx86add.pas
  91. 8 4
      compiler/x86/nx86cnv.pas
  92. 6 2
      compiler/x86/nx86inl.pas
  93. 9 5
      compiler/x86/nx86mat.pas
  94. 7 3
      compiler/x86/nx86set.pas
  95. 6 2
      compiler/x86/rax86.pas
  96. 7 3
      compiler/x86/rax86att.pas
  97. 8 4
      compiler/x86/rgx86.pas

+ 7 - 3
compiler/aasmbase.pas

@@ -34,8 +34,8 @@ interface
 
     uses
        cutils,cclasses,
-       globtype,globals,systems,
-       cpuinfo;
+       globtype,globals,systems
+       ;
 
     type
        TAsmSection = class;
@@ -941,7 +941,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.22  2004-10-15 09:14:16  mazen
+  Revision 1.23  2004-10-31 21:45:02  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.22  2004/10/15 09:14:16  mazen
   - remove $IFDEF DELPHI and related code
   - remove $IFDEF FPCPROCVAR and related code
 

+ 11 - 7
compiler/alpha/cpubase.pas

@@ -281,9 +281,9 @@ unit cpubase;
             { segment in reference at the same place as in loc_register }
             LOC_REGISTER,LOC_CREGISTER : (
               case longint of
-                1 : (register,registerhigh : tregister);
-                { overlay a registerlow }
-                2 : (registerlow : tregister);
+                1 : (register,register64.reghi : tregister);
+                { overlay a register64.reglo }
+                2 : (register64.reglo : tregister);
                 { overlay a 64 Bit register type }
                 3 : (reg64 : tregister64);
                 4 : (register64 : tregister64);
@@ -308,9 +308,9 @@ unit cpubase;
             { segment in reference at the same place as in loc_register }
             LOC_REGISTER,LOC_CREGISTER : (
               case longint of
-                1 : (register,registerhigh,segment : tregister);
-                { overlay a registerlow }
-                2 : (registerlow : tregister);
+                1 : (register,register64.reghi,segment : tregister);
+                { overlay a register64.reglo }
+                2 : (register64.reglo : tregister);
                 { overlay a 64 Bit register type }
                 3 : (reg64 : tregister64);
                 4 : (register64 : tregister64);
@@ -458,7 +458,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.7  2004-06-20 08:55:31  florian
+  Revision 1.8  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.7  2004/06/20 08:55:31  florian
     * logs truncated
 
 }

+ 8 - 4
compiler/alpha/cpupara.pas

@@ -161,11 +161,11 @@ unit cpupara;
                       if nextintreg<=tregister(ord(R_10)-ord(is_64bit))  then
                         begin
                            hp.paraloc.loc:=LOC_REGISTER;
-                           hp.paraloc.registerlow:=nextintreg;
+                           hp.paraloc.register64.reglo:=nextintreg;
                            inc(nextintreg);
                            if is_64bit then
                              begin
-                               hp.paraloc.registerhigh:=nextintreg;
+                               hp.paraloc.register64.reghi:=nextintreg;
                                inc(nextintreg);
                              end;
                         end
@@ -257,7 +257,7 @@ unit cpupara;
                 getfuncretparaloc.register:=R_3;
                 getfuncretparaloc.size:=def_cgsize(p.rettype.def);
                 if getfuncretparaloc.size in [OS_S64,OS_64] then
-                  getfuncretparaloc.registerhigh:=R_4;
+                  getfuncretparaloc.register64.reghi:=R_4;
               end;
             floatdef:
               begin
@@ -291,7 +291,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.2  2004-06-20 08:55:31  florian
+  Revision 1.3  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.2  2004/06/20 08:55:31  florian
     * logs truncated
 
 }

+ 6 - 2
compiler/aopt.pas

@@ -55,7 +55,7 @@ Unit aopt;
   Implementation
 
     uses
-      cpuinfo, globtype, globals,
+      globtype, globals,
       aoptda,aoptcpu,aoptcpud;
 
     Constructor TAsmOptimizer.create(_AsmL: taasmoutput);
@@ -252,7 +252,11 @@ end.
 
 {
  $Log$
- Revision 1.7  2004-10-30 15:21:37  florian
+ Revision 1.8  2004-10-31 21:45:02  peter
+   * generic tlocation
+   * move tlocation to cgutils
+
+ Revision 1.7  2004/10/30 15:21:37  florian
    * fixed generic optimizer
    * enabled generic optimizer for sparc
 

+ 6 - 2
compiler/aoptbase.pas

@@ -93,7 +93,7 @@ unit aoptbase;
   implementation
 
     uses
-      globtype,globals, aoptcpub, cpuinfo;
+      globtype,globals, aoptcpub;
 
   constructor taoptbase.create;
     begin
@@ -258,7 +258,11 @@ end.
 
 {
   $Log$
-  Revision 1.8  2004-10-30 15:21:37  florian
+  Revision 1.9  2004-10-31 21:45:02  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.8  2004/10/30 15:21:37  florian
     * fixed generic optimizer
     * enabled generic optimizer for sparc
 

+ 6 - 2
compiler/aoptobj.pas

@@ -36,7 +36,7 @@ Unit AoptObj;
       aasmbase,aasmcpu,aasmtai,
       cclasses,
       cgbase,
-      cpuinfo, cpubase,
+      cpubase,
       aoptbase, aoptcpub, aoptda;
 
     { ************************************************************************* }
@@ -1085,7 +1085,11 @@ End.
 
 {
  $Log$
- Revision 1.12  2004-10-30 15:21:37  florian
+ Revision 1.13  2004-10-31 21:45:02  peter
+   * generic tlocation
+   * move tlocation to cgutils
+
+ Revision 1.12  2004/10/30 15:21:37  florian
    * fixed generic optimizer
    * enabled generic optimizer for sparc
 

+ 8 - 4
compiler/arm/cpubase.pas

@@ -273,9 +273,9 @@ unit cpubase;
             { segment in reference at the same place as in loc_register }
             LOC_REGISTER,LOC_CREGISTER : (
               case longint of
-                1 : (register,registerhigh,segment : tregister);
-                { overlay a registerlow }
-                2 : (registerlow : tregister);
+                1 : (register,register64.reghi,segment : tregister);
+                { overlay a register64.reglo }
+                2 : (register64.reglo : tregister);
                 { overlay a 64 Bit register type }
                 3 : (reg64 : tregister64);
                 4 : (register64 : tregister64);
@@ -565,7 +565,11 @@ unit cpubase;
 end.
 {
   $Log$
-  Revision 1.35  2004-10-31 12:37:11  florian
+  Revision 1.36  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.35  2004/10/31 12:37:11  florian
     * another couple of arm fixed
 
   Revision 1.34  2004/10/24 17:32:53  florian

+ 7 - 3
compiler/arm/narmcnv.pas

@@ -177,9 +177,9 @@ implementation
                 if left.location.size in [OS_64,OS_S64] then
                  begin
                    hregister:=cg.getintregister(exprasmlist,OS_32);
-                   cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,left.location.registerlow,hregister);
+                   cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,left.location.register64.reglo,hregister);
                    tcgarm(cg).setflags:=true;
-                   cg.a_op_reg_reg(exprasmlist,OP_OR,OS_32,left.location.registerhigh,hregister);
+                   cg.a_op_reg_reg(exprasmlist,OP_OR,OS_32,left.location.register64.reghi,hregister);
                    tcgarm(cg).setflags:=false;
                  end
                 else
@@ -220,7 +220,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.11  2004-10-24 07:54:25  florian
+  Revision 1.12  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.11  2004/10/24 07:54:25  florian
     * fixed compilation of arm compiler
 
   Revision 1.10  2004/06/20 08:55:31  florian

+ 5 - 5
compiler/assemble.pas

@@ -186,7 +186,6 @@ Implementation
   {$endif}
 {$endif}
       cutils,script,fmodule,verbose,
-      cpuinfo,
 {$ifdef memdebug}
       cclasses,
 {$endif memdebug}
@@ -194,9 +193,6 @@ Implementation
       finput,
       gdb,
 {$endif GDB}
-{$ifdef m68k}
-      cpuinfo,
-{$endif m68k}
       cpubase,aasmcpu
       ;
 
@@ -1684,7 +1680,11 @@ Implementation
 end.
 {
   $Log$
-  Revision 1.80  2004-10-14 14:47:52  mazen
+  Revision 1.81  2004-10-31 21:45:02  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.80  2004/10/14 14:47:52  mazen
   * Merge is complete for this file, cycles !
 
   Revision 1.79  2004/10/13 17:58:54  peter

+ 12 - 8
compiler/cg64f32.pas

@@ -33,8 +33,8 @@ unit cg64f32;
 
     uses
        aasmbase,aasmtai,aasmcpu,
-       cpuinfo,cpubase,cpupara,
-       cgbase,cgobj,parabase,
+       cpubase,cpupara,
+       cgbase,cgobj,parabase,cgutils,
        node,symtype
        ;
 
@@ -375,7 +375,7 @@ unit cg64f32;
           LOC_CREFERENCE :
             a_load64low_ref_reg(list,l.reference,reg);
           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.register64.reglo,reg);
           LOC_CONSTANT :
             cg.a_load_const_reg(list,OS_32,aint(lo(l.value64)),reg);
           else
@@ -391,7 +391,7 @@ unit cg64f32;
           LOC_CREFERENCE :
             a_load64high_ref_reg(list,l.reference,reg);
           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.register64.reghi,reg);
           LOC_CONSTANT :
             cg.a_load_const_reg(list,OS_32,hi(l.value64),reg);
           else
@@ -568,7 +568,7 @@ unit cg64f32;
              { get the high dword in a register }
              if l.loc in [LOC_REGISTER,LOC_CREGISTER] then
                begin
-                 hreg := l.registerhigh;
+                 hreg := l.register64.reghi;
                end
              else
                begin
@@ -613,7 +613,7 @@ unit cg64f32;
                  cg.a_label(list,neglabel);
                  if l.loc in [LOC_REGISTER,LOC_CREGISTER] then
                    begin
-                     hreg := l.registerlow;
+                     hreg := l.register64.reglo;
                    end
                  else
                    begin
@@ -654,7 +654,7 @@ unit cg64f32;
                  begin
                    if is_64bit(fromdef) then
                      begin
-                       hreg := l.registerhigh;
+                       hreg := l.register64.reghi;
                        opsize := OS_32;
                      end
                    else
@@ -777,7 +777,11 @@ unit cg64f32;
 end.
 {
   $Log$
-  Revision 1.64  2004-10-15 09:14:16  mazen
+  Revision 1.65  2004-10-31 21:45:02  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.64  2004/10/15 09:14:16  mazen
   - remove $IFDEF DELPHI and related code
   - remove $IFDEF FPCPROCVAR and related code
 

+ 6 - 2
compiler/cg64f64.pas

@@ -33,7 +33,7 @@ unit cg64f64;
 
     uses
        aasmbase,aasmtai,aasmcpu,
-       cpuinfo, cpubase,
+       cpubase,
        cgbase,cgobj,
        symtype;
 
@@ -271,7 +271,11 @@ unit cg64f64;
 end.
 {
   $Log$
-  Revision 1.13  2004-06-20 08:55:28  florian
+  Revision 1.14  2004-10-31 21:45:02  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.13  2004/06/20 08:55:28  florian
     * logs truncated
 
   Revision 1.12  2004/06/16 20:07:07  florian

+ 10 - 11
compiler/cgbase.pas

@@ -29,7 +29,7 @@ interface
 
     uses
       globtype,
-      cpuinfo,
+      aasmbase,
       symconst;
 
     type
@@ -166,12 +166,12 @@ interface
 {$ifdef cpu64bit}
       tregister64 = tregister;
 {$else cpu64bit}
-      tregister64 = packed record
+      tregister64 = record
          reglo,reghi : tregister;
       end;
 {$endif cpu64bit}
 
-      Tregistermmxset = packed record
+      Tregistermmxset = record
         reg0,reg1,reg2,reg3:Tregister
       end;
 
@@ -179,11 +179,6 @@ interface
       tcpuregisterset = set of byte;
       tsuperregisterset = array[byte] of set of byte;
 
-      { Temp types }
-      ttemptype = (tt_none,
-                   tt_free,tt_normal,tt_persistent,
-                   tt_noreuse,tt_freenoreuse);
-
       pmmshuffle = ^tmmshuffle;
 
       { this record describes shuffle operations for mm operations; if a pointer a shuffle record
@@ -231,7 +226,7 @@ interface
          { integer values }
         (0,1,2,4,8,16,1,2,4,8,16,
          { floating point values }
-         4,8,EXTENDED_SIZE,8,16,
+         4,8,10,8,16,
          { multimedia values }
          1,2,4,8,16,1,2,4,8,16);
 
@@ -607,7 +602,11 @@ finalization
 end.
 {
   $Log$
-  Revision 1.95  2004-10-14 10:59:58  michael
+  Revision 1.96  2004-10-31 21:45:02  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.95  2004/10/14 10:59:58  michael
   * fix clearing of superregset (from Peter)
 
   Revision 1.94  2004/08/24 21:02:32  florian
@@ -651,7 +650,7 @@ end.
 
   Revision 1.87  2004/02/09 22:14:17  peter
     * more x86_64 parameter fixes
-    * tparalocation.lochigh is now used to indicate if registerhigh
+    * tparalocation.lochigh is now used to indicate if register64.reghi
       is used and what the type is
 
 }

+ 7 - 52
compiler/cgobj.pas

@@ -38,7 +38,7 @@ unit cgobj;
 
     uses
        cclasses,globtype,
-       cpubase,cpuinfo,cgbase,parabase,
+       cpubase,cgbase,cgutils,parabase,
        aasmbase,aasmtai,aasmcpu,
        symconst,symbase,symtype,symdef,symtable,rgobj
        ;
@@ -46,7 +46,6 @@ unit cgobj;
     type
        talignment = (AM_NATURAL,AM_NONE,AM_2BYTE,AM_4BYTE,AM_8BYTE);
 
-
        {# @abstract(Abstract code generator)
           This class implements an abstract instruction generator. Some of
           the methods of this class are generic, while others must
@@ -478,14 +477,6 @@ unit cgobj;
     end;
 {$endif cpu64bit}
 
-    { tlocation handling }
-
-    procedure location_reset(var l : tlocation;lt:TCGLoc;lsize:TCGSize);
-    procedure location_freetemp(list: taasmoutput; const l : tlocation);
-    procedure location_copy(var destloc:tlocation; const sourceloc : tlocation);
-    procedure location_swap(var destloc,sourceloc : tlocation);
-
-
     var
        {# Main code generator class }
        cg : tcg;
@@ -500,8 +491,7 @@ implementation
     uses
        globals,options,systems,
        verbose,defutil,paramgr,
-       tgobj,cutils,procinfo,
-       cgutils;
+       tgobj,cutils,procinfo;
 
     const
       { Please leave this here, this module should NOT use
@@ -2028,45 +2018,6 @@ implementation
 {$endif cpu64bit}
 
 
-{****************************************************************************
-                                  TLocation
-****************************************************************************}
-
-    procedure location_reset(var l : tlocation;lt:TCGLoc;lsize:TCGSize);
-      begin
-        FillChar(l,sizeof(tlocation),0);
-        l.loc:=lt;
-        l.size:=lsize;
-{$ifdef arm}
-        if l.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
-          l.reference.signindex:=1;
-{$endif arm}
-      end;
-
-
-    procedure location_freetemp(list:taasmoutput; const l : tlocation);
-      begin
-        if (l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
-         tg.ungetiftemp(list,l.reference);
-      end;
-
-
-    procedure location_copy(var destloc:tlocation; const sourceloc : tlocation);
-      begin
-        destloc:=sourceloc;
-      end;
-
-
-    procedure location_swap(var destloc,sourceloc : tlocation);
-      var
-        swapl : tlocation;
-      begin
-        swapl := destloc;
-        destloc := sourceloc;
-        sourceloc := swapl;
-      end;
-
-
 
 initialization
     ;
@@ -2078,7 +2029,11 @@ finalization
 end.
 {
   $Log$
-  Revision 1.182  2004-10-25 15:36:47  peter
+  Revision 1.183  2004-10-31 21:45:02  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.182  2004/10/25 15:36:47  peter
     * save standard registers moved to tcgobj
 
   Revision 1.181  2004/10/24 20:01:08  peter

+ 93 - 4
compiler/cgutils.pas

@@ -28,9 +28,52 @@ unit cgutils;
   interface
 
     uses
+      globtype,
       aasmbase,
-      cgbase,
-      cpubase;
+      cpubase,cgbase;
+
+    type
+      { reference record, reordered for best alignment }
+      preference = ^treference;
+      treference = record
+         offset      : aint;
+         symbol,
+         relsymbol   : tasmsymbol;
+         segment,
+         base,
+         index       : tregister;
+         refaddr     : trefaddr;
+         scalefactor : byte;
+      end;
+
+      tlocation = record
+         loc  : TCGLoc;
+         size : TCGSize;
+         case TCGLoc of
+            LOC_FLAGS : (resflags : tresflags);
+            LOC_CONSTANT : (
+              case longint of
+{$ifdef FPC_BIG_ENDIAN}
+                1 : (_valuedummy,value : aint);
+{$else FPC_BIG_ENDIAN}
+                1 : (value : aint);
+{$endif FPC_BIG_ENDIAN}
+                2 : (value64 : Int64);
+              );
+            LOC_CREFERENCE,
+            LOC_REFERENCE : (reference : treference);
+            { segment in reference at the same place as in loc_register }
+            LOC_REGISTER,
+            LOC_CREGISTER : (
+              case longint of
+                1 : (register : tregister);
+{$ifndef cpu64bit}
+                { overlay a 64 Bit register type }
+                2 : (register64 : tregister64);
+{$endif cpu64bit}
+              );
+      end;
+
 
     { trerefence handling }
 
@@ -46,7 +89,15 @@ unit cgutils;
     }
     function references_equal(sref : treference;dref : treference) : boolean;
 
-  implementation
+    { tlocation handling }
+
+    procedure location_reset(var l : tlocation;lt:TCGLoc;lsize:TCGSize);
+    procedure location_copy(var destloc:tlocation; const sourceloc : tlocation);
+    procedure location_swap(var destloc,sourceloc : tlocation);
+
+
+
+implementation
 
 {****************************************************************************
                                   TReference
@@ -82,10 +133,48 @@ unit cgutils;
         references_equal:=CompareByte(sref,dref,sizeof(treference))=0;
       end;
 
+
+{****************************************************************************
+                                  TLocation
+****************************************************************************}
+
+    procedure location_reset(var l : tlocation;lt:TCGLoc;lsize:TCGSize);
+      begin
+        FillChar(l,sizeof(tlocation),0);
+        l.loc:=lt;
+        l.size:=lsize;
+{$ifdef arm}
+        if l.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
+          l.reference.signindex:=1;
+{$endif arm}
+      end;
+
+
+    procedure location_copy(var destloc:tlocation; const sourceloc : tlocation);
+      begin
+        destloc:=sourceloc;
+      end;
+
+
+    procedure location_swap(var destloc,sourceloc : tlocation);
+      var
+        swapl : tlocation;
+      begin
+        swapl := destloc;
+        destloc := sourceloc;
+        sourceloc := swapl;
+      end;
+
+
+
 end.
 {
   $Log$
-  Revision 1.1  2004-02-27 10:21:05  florian
+  Revision 1.2  2004-10-31 21:45:02  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.1  2004/02/27 10:21:05  florian
     * top_symbol killed
     + refaddr to treference added
     + refsymbol to treference added

+ 5 - 2
compiler/defcmp.pas

@@ -28,7 +28,6 @@ interface
 
     uses
        cclasses,
-       cpuinfo,
        globtype,globals,tokens,
        node,
        symconst,symbase,symtype,symdef;
@@ -1300,7 +1299,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.53  2004-09-21 15:52:35  peter
+  Revision 1.54  2004-10-31 21:45:02  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.53  2004/09/21 15:52:35  peter
     * prefer pchar-string over pchar-pointer
 
   Revision 1.52  2004/09/16 16:32:44  peter

+ 6 - 2
compiler/defutil.pas

@@ -203,7 +203,7 @@ interface
 implementation
 
     uses
-       tokens,systems,verbose;
+       systems,verbose;
 
     { returns true, if def uses FPU }
     function is_fpu(def : tdef) : boolean;
@@ -888,7 +888,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.19  2004-08-24 21:02:32  florian
+  Revision 1.20  2004-10-31 21:45:02  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.19  2004/08/24 21:02:32  florian
     * fixed longbool(<int64>) on sparc
 
   Revision 1.18  2004/06/20 08:55:29  florian

+ 6 - 3
compiler/dwarf.pas

@@ -100,8 +100,7 @@ interface
 implementation
 
     uses
-      verbose,
-      cpuinfo;
+      verbose;
 
     const
       { Call frame information }
@@ -422,7 +421,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.3  2004-06-20 08:55:29  florian
+  Revision 1.4  2004-10-31 21:45:02  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.3  2004/06/20 08:55:29  florian
     * logs truncated
 
   Revision 1.2  2004/06/16 20:07:07  florian

+ 7 - 2
compiler/globals.pas

@@ -47,7 +47,8 @@ interface
       dos,
 {$ENDIF USE_SYSUTILS}
       cutils,cclasses,
-      globtype,version,systems,cpuinfo;
+      cpuinfo,
+      globtype,version,systems;
 
     const
        delphimodeswitches : tmodeswitches=
@@ -2134,7 +2135,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.151  2004-10-31 19:09:54  peter
+  Revision 1.152  2004-10-31 21:45:02  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.151  2004/10/31 19:09:54  peter
     * default paths fixed
 
   Revision 1.150  2004/10/31 18:54:24  peter

+ 11 - 1
compiler/globtype.pas

@@ -178,6 +178,12 @@ than 255 characters. That's why using Ansi Strings}
          bt_general,bt_type,bt_const,bt_except,bt_body
        );
 
+       { Temp types }
+       ttemptype = (tt_none,
+                    tt_free,tt_normal,tt_persistent,
+                    tt_noreuse,tt_freenoreuse);
+       ttemptypeset = set of ttemptype;
+
        { calling convention for tprocdef and tprocvardef }
        tproccalloption=(pocall_none,
          { procedure uses C styled calling }
@@ -307,7 +313,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.63  2004-10-25 15:38:41  peter
+  Revision 1.64  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.63  2004/10/25 15:38:41  peter
     * heap and heapsize removed
     * checkpointer fixes
 

+ 6 - 3
compiler/i386/ag386int.pas

@@ -31,7 +31,7 @@ interface
 
     uses
       cpubase,
-      aasmbase,aasmtai,aasmcpu,assemble;
+      aasmbase,aasmtai,aasmcpu,assemble,cgutils;
 
     type
       T386IntelAssembler = class(TExternalAssembler)
@@ -354,7 +354,6 @@ implementation
       InlineLevel : longint;
       i,j,l    : longint;
       consttyp : taitype;
-      found,
       do_line,DoNotSplitLine,
       quoted   : boolean;
     begin
@@ -875,7 +874,11 @@ initialization
 end.
 {
   $Log$
-  Revision 1.52  2004-10-15 09:16:21  mazen
+  Revision 1.53  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.52  2004/10/15 09:16:21  mazen
   - remove $IFDEF DELPHI and related code
   - remove $IFDEF FPCPROCVAR and related code
 

+ 6 - 2
compiler/i386/ag386nsm.pas

@@ -29,7 +29,7 @@ interface
 
     uses
       cpubase,
-      aasmbase,aasmtai,aasmcpu,assemble;
+      aasmbase,aasmtai,aasmcpu,assemble,cgutils;
 
     type
       T386NasmAssembler = class(texternalassembler)
@@ -906,7 +906,11 @@ initialization
 end.
 {
   $Log$
-  Revision 1.49  2004-10-15 09:16:21  mazen
+  Revision 1.50  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.49  2004/10/15 09:16:21  mazen
   - remove $IFDEF DELPHI and related code
   - remove $IFDEF FPCPROCVAR and related code
 

+ 7 - 4
compiler/i386/cgcpu.pas

@@ -30,7 +30,7 @@ unit cgcpu;
        globtype,
        cgbase,cgobj,cg64f32,cgx86,
        aasmbase,aasmtai,aasmcpu,
-       cpubase,cpuinfo,parabase,
+       cpubase,cpuinfo,parabase,cgutils,
        node,symconst
        ;
 
@@ -65,8 +65,7 @@ unit cgcpu;
     uses
        globals,verbose,systems,cutils,
        paramgr,procinfo,
-       rgcpu,rgx86,tgobj,
-       cgutils;
+       rgcpu,rgx86,tgobj;
 
     procedure Tcg386.init_register_allocators;
       begin
@@ -520,7 +519,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.59  2004-10-24 20:01:08  peter
+  Revision 1.60  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.59  2004/10/24 20:01:08  peter
     * remove saveregister calling convention
 
   Revision 1.58  2004/10/24 11:44:28  peter

+ 12 - 2
compiler/i386/cpubase.inc

@@ -23,7 +23,6 @@
 { This include file contains the basic declarations for the i386 architecture.
 }
 
-
 {*****************************************************************************
                                 Operand Sizes
 *****************************************************************************}
@@ -167,9 +166,20 @@
       }
       std_param_align = 4;
 
+      { size of the buffer used for setjump/longjmp
+        the size of this buffer is deduced from the
+        jmp_buf structure in setjumph.inc file
+      }
+      jmp_buf_size = 24;
+
+
 {
   $Log$
-  Revision 1.14  2004-06-20 08:55:31  florian
+  Revision 1.15  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.14  2004/06/20 08:55:31  florian
     * logs truncated
 
   Revision 1.13  2004/06/16 20:07:10  florian

+ 5 - 14
compiler/i386/cpuinfo.pas

@@ -59,19 +59,6 @@ Type
 
 
 Const
-   {# Size of native extended floating point type }
-   extended_size = 10;
-   {# Size of a multimedia register               }
-   mmreg_size = 8;
-
-   { target cpu string (used by compiler options) }
-   target_cpu_string = 'i386';
-   { size of the buffer used for setjump/longjmp
-     the size of this buffer is deduced from the
-     jmp_buf structure in setjumph.inc file
-   }
-   jmp_buf_size = 24;
-
    { calling conventions supported by the code generator }
    supported_calling_conventions : tproccalloptions = [
      pocall_internproc,
@@ -110,7 +97,11 @@ Implementation
 end.
 {
   $Log$
-  Revision 1.26  2004-06-20 08:55:31  florian
+  Revision 1.27  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.26  2004/06/20 08:55:31  florian
     * logs truncated
 
   Revision 1.25  2004/06/16 20:07:10  florian

+ 6 - 2
compiler/i386/cpupara.pas

@@ -523,7 +523,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.55  2004-09-21 17:25:12  peter
+  Revision 1.56  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.55  2004/09/21 17:25:12  peter
     * paraloc branch merged
 
   Revision 1.54.4.1  2004/08/31 20:43:06  peter
@@ -555,7 +559,7 @@ end.
 
   Revision 1.50  2004/02/09 22:14:17  peter
     * more x86_64 parameter fixes
-    * tparalocation.lochigh is now used to indicate if registerhigh
+    * tparalocation.lochigh is now used to indicate if register64.reghi
       is used and what the type is
 
 }

+ 7 - 3
compiler/i386/csopt386.pas

@@ -45,7 +45,7 @@ uses
 {$else}
   {$ifdef replaceregdebug}cutils,{$endif}
 {$endif}
-  globtype, verbose, procinfo, globals, daopt386, rgobj, rropt386;
+  globtype, verbose, procinfo, globals, daopt386, rgobj, rropt386,cgutils;
 
 {
 function TaiInSequence(P: tai; Const Seq: TContent): Boolean;
@@ -1567,7 +1567,7 @@ begin
         else
           AllocRegBetween(asml,newreg(R_INTREGISTER,reginfo.new2oldreg[regcounter],R_SUBWHOLE),
             prevseqstart,curseqstart,ptaiprop(prevseqstart.optinfo)^.usedregs);
- 
+
         if curprev <> prevseqstart then
           begin
             if assigned(reginfo.lastReload[regCounter]) then
@@ -2122,7 +2122,11 @@ end.
 
 {
   $Log$
-  Revision 1.68  2004-10-10 15:01:19  jonas
+  Revision 1.69  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.68  2004/10/10 15:01:19  jonas
     * several fixes to allocregbetween()
 
   Revision 1.67  2004/10/06 19:24:38  jonas

+ 6 - 2
compiler/i386/daopt386.pas

@@ -30,7 +30,7 @@ interface
 
 uses
   globtype,
-  cclasses,aasmbase,aasmtai,aasmcpu,cgbase,
+  cclasses,aasmbase,aasmtai,aasmcpu,cgbase,cgutils,
   cpubase,optbase;
 
 {******************************* Constants *******************************}
@@ -2783,7 +2783,11 @@ end.
 
 {
   $Log$
-  Revision 1.73  2004-10-10 15:01:19  jonas
+  Revision 1.74  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.73  2004/10/10 15:01:19  jonas
     * several fixes to allocregbetween()
 
   Revision 1.72  2004/10/06 19:24:38  jonas

+ 22 - 18
compiler/i386/n386add.pas

@@ -49,7 +49,7 @@ interface
       symconst,symdef,paramgr,
       aasmbase,aasmtai,aasmcpu,
       cgbase,
-      ncon,nset,
+      ncon,nset,cgutils,tgobj,
       cga,ncgutil,cgobj,cg64f32;
 
 {*****************************************************************************
@@ -195,8 +195,8 @@ interface
               hregister2:=cg.getintregister(exprasmlist,OS_INT);
               cg64.a_load64_loc_reg(exprasmlist,left.location,joinreg64(hregister,hregister2));
               location_reset(left.location,LOC_REGISTER,OS_64);
-              left.location.registerlow:=hregister;
-              left.location.registerhigh:=hregister2;
+              left.location.register64.reglo:=hregister;
+              left.location.register64.reghi:=hregister2;
             end
            else
             begin
@@ -231,12 +231,12 @@ interface
             begin
               r:=cg.getintregister(exprasmlist,OS_INT);
               cg64.a_load64low_loc_reg(exprasmlist,right.location,r);
-              emit_reg_reg(op1,opsize,left.location.registerlow,r);
-              emit_reg_reg(A_MOV,opsize,r,left.location.registerlow);
+              emit_reg_reg(op1,opsize,left.location.register64.reglo,r);
+              emit_reg_reg(A_MOV,opsize,r,left.location.register64.reglo);
               cg64.a_load64high_loc_reg(exprasmlist,right.location,r);
               { the carry flag is still ok }
-              emit_reg_reg(op2,opsize,left.location.registerhigh,r);
-              emit_reg_reg(A_MOV,opsize,r,left.location.registerhigh);
+              emit_reg_reg(op2,opsize,left.location.register64.reghi,r);
+              emit_reg_reg(A_MOV,opsize,r,left.location.register64.reghi);
             end
            else
             begin
@@ -365,8 +365,8 @@ interface
                  hregister2:=cg.getintregister(exprasmlist,OS_INT);
                  cg64.a_load64_loc_reg(exprasmlist,left.location,joinreg64(hregister,hregister2));
                  location_reset(left.location,LOC_REGISTER,OS_64);
-                 left.location.registerlow:=hregister;
-                 left.location.registerhigh:=hregister2;
+                 left.location.register64.reglo:=hregister;
+                 left.location.register64.reghi:=hregister2;
                end;
             end
            else
@@ -379,9 +379,9 @@ interface
         { at this point, left.location.loc should be LOC_REGISTER }
         if right.location.loc=LOC_REGISTER then
          begin
-           emit_reg_reg(A_CMP,S_L,right.location.registerhigh,left.location.registerhigh);
+           emit_reg_reg(A_CMP,S_L,right.location.register64.reghi,left.location.register64.reghi);
            firstjmp64bitcmp;
-           emit_reg_reg(A_CMP,S_L,right.location.registerlow,left.location.registerlow);
+           emit_reg_reg(A_CMP,S_L,right.location.register64.reglo,left.location.register64.reglo);
            secondjmp64bitcmp;
          end
         else
@@ -389,9 +389,9 @@ interface
            case right.location.loc of
              LOC_CREGISTER :
                begin
-                 emit_reg_reg(A_CMP,S_L,right.location.registerhigh,left.location.registerhigh);
+                 emit_reg_reg(A_CMP,S_L,right.location.register64.reghi,left.location.register64.reghi);
                  firstjmp64bitcmp;
-                 emit_reg_reg(A_CMP,S_L,right.location.registerlow,left.location.registerlow);
+                 emit_reg_reg(A_CMP,S_L,right.location.register64.reglo,left.location.register64.reglo);
                  secondjmp64bitcmp;
                end;
              LOC_CREFERENCE,
@@ -399,18 +399,18 @@ interface
                begin
                  href:=right.location.reference;
                  inc(href.offset,4);
-                 emit_ref_reg(A_CMP,S_L,href,left.location.registerhigh);
+                 emit_ref_reg(A_CMP,S_L,href,left.location.register64.reghi);
                  firstjmp64bitcmp;
-                 emit_ref_reg(A_CMP,S_L,right.location.reference,left.location.registerlow);
+                 emit_ref_reg(A_CMP,S_L,right.location.reference,left.location.register64.reglo);
                  secondjmp64bitcmp;
                  cg.a_jmp_always(exprasmlist,falselabel);
                  location_freetemp(exprasmlist,right.location);
                end;
              LOC_CONSTANT :
                begin
-                 exprasmlist.concat(taicpu.op_const_reg(A_CMP,S_L,aint(hi(right.location.value64)),left.location.registerhigh));
+                 exprasmlist.concat(taicpu.op_const_reg(A_CMP,S_L,aint(hi(right.location.value64)),left.location.register64.reghi));
                  firstjmp64bitcmp;
-                 exprasmlist.concat(taicpu.op_const_reg(A_CMP,S_L,aint(lo(right.location.value64)),left.location.registerlow));
+                 exprasmlist.concat(taicpu.op_const_reg(A_CMP,S_L,aint(lo(right.location.value64)),left.location.register64.reglo));
                  secondjmp64bitcmp;
                end;
              else
@@ -654,7 +654,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.99  2004-09-25 14:23:54  peter
+  Revision 1.100  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.99  2004/09/25 14:23:54  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 5 - 4
compiler/i386/n386cal.pas

@@ -44,9 +44,6 @@ implementation
     uses
       globtype,systems,
       cutils,verbose,globals,
-{$ifdef GDB}
-      gdb,
-{$endif GDB}
       cgbase,
       cpubase,paramgr,
       aasmtai,aasmcpu,
@@ -99,7 +96,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.102  2004-09-25 14:23:54  peter
+  Revision 1.103  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.102  2004/09/25 14:23:54  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 6 - 2
compiler/i386/n386con.pas

@@ -41,7 +41,7 @@ implementation
       systems,globals,
       defutil,
       cpubase,
-      cga,cgx86,cgobj,cgbase;
+      cga,cgx86,cgobj,cgbase,cgutils;
 
 {*****************************************************************************
                            TI386REALCONSTNODE
@@ -91,7 +91,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.25  2004-06-20 08:55:31  florian
+  Revision 1.26  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.25  2004/06/20 08:55:31  florian
     * logs truncated
 
 }

+ 36 - 32
compiler/i386/n386mat.pas

@@ -53,10 +53,10 @@ implementation
       globtype,systems,
       cutils,verbose,globals,
       symconst,symdef,aasmbase,aasmtai,defutil,
-      cgbase,pass_1,pass_2,
+      cgbase,pass_2,
       ncon,
       cpubase,cpuinfo,
-      cga,ncgutil,cgobj;
+      cga,ncgutil,cgobj,cgutils;
 
 {*****************************************************************************
                              TI386MODDIVNODE
@@ -181,7 +181,7 @@ implementation
 
     procedure ti386shlshrnode.pass_2;
 
-    var hregisterhigh,hregisterlow:Tregister;
+    var hreg64hi,hreg64lo:Tregister;
         op:Tasmop;
         v : TConstExprInt;
         l1,l2,l3:Tasmlabel;
@@ -202,8 +202,8 @@ implementation
 
           { load left operator in a register }
           location_force_reg(exprasmlist,left.location,OS_64,false);
-          hregisterhigh:=left.location.registerhigh;
-          hregisterlow:=left.location.registerlow;
+          hreg64hi:=left.location.register64.reghi;
+          hreg64lo:=left.location.register64.reglo;
 
           { shifting by a constant directly coded: }
           if (right.nodetype=ordconstn) then
@@ -213,33 +213,33 @@ implementation
                 begin
                   if nodetype=shln then
                     begin
-                      emit_reg_reg(A_XOR,S_L,hregisterhigh,hregisterhigh);
+                      emit_reg_reg(A_XOR,S_L,hreg64hi,hreg64hi);
                       if ((v and 31) <> 0) then
-                        emit_const_reg(A_SHL,S_L,v and 31,hregisterlow);
+                        emit_const_reg(A_SHL,S_L,v and 31,hreg64lo);
                     end
                   else
                     begin
-                      emit_reg_reg(A_XOR,S_L,hregisterlow,hregisterlow);
+                      emit_reg_reg(A_XOR,S_L,hreg64lo,hreg64lo);
                       if ((v and 31) <> 0) then
-                        emit_const_reg(A_SHR,S_L,v and 31,hregisterhigh);
+                        emit_const_reg(A_SHR,S_L,v and 31,hreg64hi);
                     end;
-                  location.registerhigh:=hregisterlow;
-                  location.registerlow:=hregisterhigh;
+                  location.register64.reghi:=hreg64lo;
+                  location.register64.reglo:=hreg64hi;
                 end
               else
                 begin
                   if nodetype=shln then
                     begin
-                      emit_const_reg_reg(A_SHLD,S_L,v and 31,hregisterlow,hregisterhigh);
-                      emit_const_reg(A_SHL,S_L,v and 31,hregisterlow);
+                      emit_const_reg_reg(A_SHLD,S_L,v and 31,hreg64lo,hreg64hi);
+                      emit_const_reg(A_SHL,S_L,v and 31,hreg64lo);
                     end
                   else
                     begin
-                      emit_const_reg_reg(A_SHRD,S_L,v and 31,hregisterhigh,hregisterlow);
-                      emit_const_reg(A_SHR,S_L,v and 31,hregisterhigh);
+                      emit_const_reg_reg(A_SHRD,S_L,v and 31,hreg64hi,hreg64lo);
+                      emit_const_reg(A_SHR,S_L,v and 31,hreg64hi);
                     end;
-                  location.registerlow:=hregisterlow;
-                  location.registerhigh:=hregisterhigh;
+                  location.register64.reglo:=hreg64lo;
+                  location.register64.reghi:=hreg64hi;
                 end;
             end
           else
@@ -259,8 +259,8 @@ implementation
               objectlibrary.getlabel(l3);
               emit_const_reg(A_CMP,S_L,64,NR_ECX);
               cg.a_jmp_flags(exprasmlist,F_L,l1);
-              emit_reg_reg(A_XOR,S_L,hregisterlow,hregisterlow);
-              emit_reg_reg(A_XOR,S_L,hregisterhigh,hregisterhigh);
+              emit_reg_reg(A_XOR,S_L,hreg64lo,hreg64lo);
+              emit_reg_reg(A_XOR,S_L,hreg64hi,hreg64hi);
               cg.a_jmp_always(exprasmlist,l3);
               cg.a_label(exprasmlist,l1);
               emit_const_reg(A_CMP,S_L,32,NR_ECX);
@@ -268,29 +268,29 @@ implementation
               emit_const_reg(A_SUB,S_L,32,NR_ECX);
               if nodetype=shln then
                 begin
-                  emit_reg_reg(A_SHL,S_L,NR_CL,hregisterlow);
-                  emit_reg_reg(A_MOV,S_L,hregisterlow,hregisterhigh);
-                  emit_reg_reg(A_XOR,S_L,hregisterlow,hregisterlow);
+                  emit_reg_reg(A_SHL,S_L,NR_CL,hreg64lo);
+                  emit_reg_reg(A_MOV,S_L,hreg64lo,hreg64hi);
+                  emit_reg_reg(A_XOR,S_L,hreg64lo,hreg64lo);
                   cg.a_jmp_always(exprasmlist,l3);
                   cg.a_label(exprasmlist,l2);
-                  emit_reg_reg_reg(A_SHLD,S_L,NR_CL,hregisterlow,hregisterhigh);
-                  emit_reg_reg(A_SHL,S_L,NR_CL,hregisterlow);
+                  emit_reg_reg_reg(A_SHLD,S_L,NR_CL,hreg64lo,hreg64hi);
+                  emit_reg_reg(A_SHL,S_L,NR_CL,hreg64lo);
                 end
               else
                 begin
-                  emit_reg_reg(A_SHR,S_L,NR_CL,hregisterhigh);
-                  emit_reg_reg(A_MOV,S_L,hregisterhigh,hregisterlow);
-                  emit_reg_reg(A_XOR,S_L,hregisterhigh,hregisterhigh);
+                  emit_reg_reg(A_SHR,S_L,NR_CL,hreg64hi);
+                  emit_reg_reg(A_MOV,S_L,hreg64hi,hreg64lo);
+                  emit_reg_reg(A_XOR,S_L,hreg64hi,hreg64hi);
                   cg.a_jmp_always(exprasmlist,l3);
                   cg.a_label(exprasmlist,l2);
-                  emit_reg_reg_reg(A_SHRD,S_L,NR_CL,hregisterhigh,hregisterlow);
-                  emit_reg_reg(A_SHR,S_L,NR_CL,hregisterhigh);
+                  emit_reg_reg_reg(A_SHRD,S_L,NR_CL,hreg64hi,hreg64lo);
+                  emit_reg_reg(A_SHR,S_L,NR_CL,hreg64hi);
                 end;
               cg.a_label(exprasmlist,l3);
 
               cg.ungetcpuregister(exprasmlist,NR_ECX);
-              location.registerlow:=hregisterlow;
-              location.registerhigh:=hregisterhigh;
+              location.register64.reglo:=hreg64lo;
+              location.register64.reghi:=hreg64hi;
             end;
         end
       else
@@ -325,7 +325,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.72  2004-09-25 14:23:54  peter
+  Revision 1.73  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.72  2004/09/25 14:23:54  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 8 - 4
compiler/i386/n386mem.pas

@@ -63,9 +63,9 @@ implementation
 
       begin
         inherited pass_2;
-        { for use of other segments }
-        if left.location.reference.segment<>NR_NO then
-          location.segment:=left.location.reference.segment;
+        { for use of other segments, not used }
+        {if left.location.reference.segment<>NR_NO then
+          location.segment:=left.location.reference.segment;}
       end;
 
 
@@ -141,7 +141,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.64  2004-10-15 09:16:22  mazen
+  Revision 1.65  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.64  2004/10/15 09:16:22  mazen
   - remove $IFDEF DELPHI and related code
   - remove $IFDEF FPCPROCVAR and related code
 

+ 6 - 2
compiler/i386/n386obj.pas

@@ -36,7 +36,7 @@ uses
   symconst,symdef,
   fmodule,
   nobj,
-  cpuinfo,cpubase,
+  cpubase,
   cga,cgutils,cgobj;
 
    type
@@ -238,7 +238,11 @@ initialization
 end.
 {
   $Log$
-  Revision 1.35  2004-10-24 20:01:08  peter
+  Revision 1.36  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.35  2004/10/24 20:01:08  peter
     * remove saveregister calling convention
 
   Revision 1.34  2004/06/20 08:55:31  florian

+ 6 - 2
compiler/i386/ra386int.pas

@@ -1768,7 +1768,7 @@ Unit Ra386int;
                   AS_BYTE  : size:=1;
                   AS_QWORD : size:=8;
                   AS_DQWORD : size:=16;
-                  AS_TBYTE : size:=extended_size;
+                  AS_TBYTE : size:=10;
                 end;
                 Consume(actasmtoken);
                 case actasmtoken of
@@ -2014,7 +2014,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.77  2004-09-13 20:25:52  peter
+  Revision 1.78  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.77  2004/09/13 20:25:52  peter
     * support byte() typecast
     * support array index
 

+ 11 - 7
compiler/m68k/cpubase.pas

@@ -229,9 +229,9 @@ unit cpubase;
             { segment in reference at the same place as in loc_register }
             LOC_REGISTER,LOC_CREGISTER : (
               case longint of
-                1 : (register,registerhigh : tregister);
-                { overlay a registerlow }
-                2 : (registerlow : tregister);
+                1 : (register,register64.reghi : tregister);
+                { overlay a register64.reglo }
+                2 : (register64.reglo : tregister);
                 { overlay a 64 Bit register type }
                 3 : (reg64 : tregister64);
                 4 : (register64 : tregister64);
@@ -257,9 +257,9 @@ unit cpubase;
             { segment in reference at the same place as in loc_register }
             LOC_REGISTER,LOC_CREGISTER : (
               case longint of
-                1 : (register,registerhigh,segment : tregister);
-                { overlay a registerlow }
-                2 : (registerlow : tregister);
+                1 : (register,register64.reghi,segment : tregister);
+                { overlay a register64.reglo }
+                2 : (register64.reglo : tregister);
                 { overlay a 64 Bit register type }
                 3 : (reg64 : tregister64);
                 4 : (register64 : tregister64);
@@ -515,7 +515,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.31  2004-06-20 08:55:31  florian
+  Revision 1.32  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.31  2004/06/20 08:55:31  florian
     * logs truncated
 
   Revision 1.30  2004/06/20 08:47:33  florian

+ 6 - 2
compiler/m68k/n68kmat.pas

@@ -116,7 +116,7 @@ implementation
               location_copy(location,left.location);
               location_force_reg(exprasmlist,location,OS_64,false);
               cg64.a_op64_loc_reg(exprasmlist,OP_NOT,location,
-                joinreg64(location.registerlow,location.registerhigh));
+                joinreg64(location.register64.reglo,location.register64.reghi));
            end
          else
           begin
@@ -246,7 +246,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.10  2004-09-25 14:23:54  peter
+  Revision 1.11  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.10  2004/09/25 14:23:54  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 15 - 11
compiler/m68k/ncpuadd.pas

@@ -344,19 +344,19 @@ implementation
                     begin
                       if left.location.loc = LOC_REGISTER then
                         begin
-                          tempreg64.reglo := left.location.registerlow;
-                          tempreg64.reghi := left.location.registerhigh;
+                          tempreg64.reglo := left.location.register64.reglo;
+                          tempreg64.reghi := left.location.register64.reghi;
                         end
                       else
                         begin
                           if (aword(right.location.valueqword) <> 0) then
                             tempreg64.reglo := cg.getintregister(exprasmlist)
                           else
-                            tempreg64.reglo := left.location.registerlow;
+                            tempreg64.reglo := left.location.register64.reglo;
                           if ((right.location.valueqword shr 32) <> 0) then
                             tempreg64.reghi := cg.getintregister(exprasmlist)
                           else
-                            tempreg64.reghi := left.location.registerhigh;
+                            tempreg64.reghi := left.location.register64.reghi;
                         end;
 
                       if (aword(right.location.valueqword) <> 0) then
@@ -366,22 +366,22 @@ implementation
                            (longint(right.location.valueqword) < 0) then
                           cg.a_op_const_reg_reg(exprasmlist,OP_SUB,OS_INT,
                             aword(right.location.valueqword),
-                            left.location.registerlow,tempreg64.reglo)
+                            left.location.register64.reglo,tempreg64.reglo)
                         else
                           cg.a_op_const_reg_reg(exprasmlist,OP_XOR,OS_INT,
                             aword(right.location.valueqword),
-                            left.location.registerlow,tempreg64.reglo);
+                            left.location.register64.reglo,tempreg64.reglo);
 
                       if ((right.location.valueqword shr 32) <> 0) then
                         if (longint(right.location.valueqword shr 32) >= -32767) and
                            (longint(right.location.valueqword shr 32) < 0) then
                           cg.a_op_const_reg_reg(exprasmlist,OP_SUB,OS_INT,
                             aword(right.location.valueqword shr 32),
-                            left.location.registerhigh,tempreg64.reghi)
+                            left.location.register64.reghi,tempreg64.reghi)
                         else
                           cg.a_op_const_reg_reg(exprasmlist,OP_XOR,OS_INT,
                             aword(right.location.valueqword shr 32),
-                            left.location.registerhigh,tempreg64.reghi);
+                            left.location.register64.reghi,tempreg64.reghi);
                     end
                   else
                     begin
@@ -396,9 +396,9 @@ implementation
                   exprasmlist.concat(taicpu.op_reg_reg_reg(A_OR_,R_0,
                     tempreg64.reglo,tempreg64.reghi));
                   cg.a_reg_dealloc(exprasmlist,R_0);
-                  if (tempreg64.reglo <> left.location.registerlow) then
+                  if (tempreg64.reglo <> left.location.register64.reglo) then
                     cg.ungetregister(exprasmlist,tempreg64.reglo);
-                  if (tempreg64.reghi <> left.location.registerhigh) then
+                  if (tempreg64.reghi <> left.location.register64.reghi) then
                     cg.ungetregister(exprasmlist,tempreg64.reghi);
 
                   location_reset(location,LOC_FLAGS,OS_NO);
@@ -426,7 +426,11 @@ end.
 
 {
   $Log$
-  Revision 1.5  2004-06-20 08:55:31  florian
+  Revision 1.6  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.5  2004/06/20 08:55:31  florian
     * logs truncated
 
   Revision 1.4  2004/04/25 21:26:16  florian

+ 9 - 4
compiler/nbas.pas

@@ -27,9 +27,10 @@ unit nbas;
 interface
 
     uses
-       cpuinfo,cpubase,cgbase,
+       globtype,
+       cpuinfo,cpubase,cgbase,cgutils,
        aasmbase,aasmtai,aasmcpu,
-       node,tgobj,
+       node,
        symtype;
 
     type
@@ -201,7 +202,7 @@ implementation
 
     uses
       cutils,
-      verbose,globals,globtype,systems,
+      verbose,globals,systems,
       symconst,symdef,defutil,defcmp,
       pass_1,
       nld,ncal,nflw,
@@ -1027,7 +1028,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.88  2004-10-12 14:36:38  peter
+  Revision 1.89  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.88  2004/10/12 14:36:38  peter
     * gen high tree makes copy in temp when there is a calln
 
   Revision 1.87  2004/09/26 17:45:30  peter

+ 6 - 2
compiler/ncal.pas

@@ -185,7 +185,7 @@ implementation
       systems,
       verbose,globals,
       symconst,defutil,defcmp,
-      htypechk,pass_1,
+      htypechk,pass_1,tgobj,
       ncnv,nld,ninl,nadd,ncon,nmem,
       procinfo,
       cgbase
@@ -2416,7 +2416,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.253  2004-10-25 15:38:41  peter
+  Revision 1.254  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.253  2004/10/25 15:38:41  peter
     * heap and heapsize removed
     * checkpointer fixes
 

+ 16 - 12
compiler/ncgadd.pas

@@ -73,8 +73,8 @@ interface
       cutils,verbose,globals,
       symconst,symdef,paramgr,
       aasmbase,aasmtai,defutil,
-      cgbase,cpuinfo,pass_2,
-      ncon,nset,ncgutil,cgobj
+      cgbase,pass_2,
+      ncon,nset,ncgutil,cgobj,cgutils
       ;
 
 
@@ -154,8 +154,8 @@ interface
 {$ifndef cpu64bit}
             if location.size in [OS_64,OS_S64] then
               begin
-                location.registerlow := left.location.registerlow;
-                location.registerhigh := left.location.registerhigh;
+                location.register64.reglo := left.location.register64.reglo;
+                location.register64.reghi := left.location.register64.reghi;
               end
             else
 {$endif}
@@ -169,8 +169,8 @@ interface
 {$ifndef cpu64bit}
             if location.size in [OS_64,OS_S64] then
               begin
-                location.registerlow := right.location.registerlow;
-                location.registerhigh := right.location.registerhigh;
+                location.register64.reglo := right.location.register64.reglo;
+                location.register64.reghi := right.location.register64.reghi;
               end
             else
 {$endif}
@@ -181,8 +181,8 @@ interface
 {$ifndef cpu64bit}
             if location.size in [OS_64,OS_S64] then
               begin
-                location.registerlow := cg.getintregister(exprasmlist,OS_INT);
-                location.registerhigh := cg.getintregister(exprasmlist,OS_INT);
+                location.register64.reglo := cg.getintregister(exprasmlist,OS_INT);
+                location.register64.reghi := cg.getintregister(exprasmlist,OS_INT);
               end
             else
 {$endif}
@@ -500,10 +500,10 @@ interface
 
               if left.location.loc <> LOC_CONSTANT then
                 begin
-                  if (location.registerlow = NR_NO) then
+                  if (location.register64.reglo = NR_NO) then
                     begin
-                     location.registerlow := cg.getintregister(exprasmlist,OS_INT);
-                     location.registerhigh := cg.getintregister(exprasmlist,OS_INT);
+                     location.register64.reglo := cg.getintregister(exprasmlist,OS_INT);
+                     location.register64.reghi := cg.getintregister(exprasmlist,OS_INT);
                   end;
                   if right.location.loc <> LOC_CONSTANT then
                     // reg64 - reg64
@@ -778,7 +778,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.34  2004-09-29 18:55:40  florian
+  Revision 1.35  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.34  2004/09/29 18:55:40  florian
     * fixed more sparc overflow stuff
     * fixed some op64 stuff for sparc
 

+ 7 - 4
compiler/ncgbas.pas

@@ -27,7 +27,7 @@ unit ncgbas;
 interface
 
     uses
-       cpubase,
+       cpubase,cgutils,
        node,nbas;
 
     type
@@ -72,8 +72,7 @@ interface
       aasmbase,aasmtai,aasmcpu,symsym,symconst,
       defutil,
       nflw,pass_2,
-      cgbase,
-      cgutils,cgobj,
+      cgbase,cgobj,
       procinfo,
       tgobj
       ;
@@ -492,7 +491,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.68  2004-09-26 17:45:30  peter
+  Revision 1.69  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.68  2004/09/26 17:45:30  peter
     * simple regvar support, not yet finished
 
   Revision 1.67  2004/09/25 14:23:54  peter

+ 15 - 11
compiler/ncgcal.pas

@@ -29,7 +29,7 @@ interface
     uses
       cpubase,
       globtype,
-      parabase,
+      parabase,cgutils,
       symdef,node,ncal;
 
     type
@@ -90,7 +90,7 @@ implementation
       cga,cgx86,
 {$endif x86}
       ncgutil,
-      cgutils,cgobj,tgobj,
+      cgobj,tgobj,
       procinfo;
 
 
@@ -575,14 +575,14 @@ implementation
                              if retloc.loc<>LOC_REGISTER then
                                internalerror(200409141);
                              { the function result registers are already allocated }
-                             if getsupreg(retloc.registerlow)<first_int_imreg then
-                               cg.ungetcpuregister(exprasmlist,retloc.registerlow);
-                             location.registerlow:=cg.getintregister(exprasmlist,OS_32);
-                             cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,retloc.registerlow,location.registerlow);
-                             if getsupreg(retloc.registerhigh)<first_int_imreg then
-                               cg.ungetcpuregister(exprasmlist,retloc.registerhigh);
-                             location.registerhigh:=cg.getintregister(exprasmlist,OS_32);
-                             cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,retloc.registerhigh,location.registerhigh);
+                             if getsupreg(retloc.register64.reglo)<first_int_imreg then
+                               cg.ungetcpuregister(exprasmlist,retloc.register64.reglo);
+                             location.register64.reglo:=cg.getintregister(exprasmlist,OS_32);
+                             cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,retloc.register64.reglo,location.register64.reglo);
+                             if getsupreg(retloc.register64.reghi)<first_int_imreg then
+                               cg.ungetcpuregister(exprasmlist,retloc.register64.reghi);
+                             location.register64.reghi:=cg.getintregister(exprasmlist,OS_32);
+                             cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,retloc.register64.reghi,location.register64.reghi);
                            end
                           else
 {$endif cpu64bit}
@@ -1247,7 +1247,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.181  2004-10-24 20:01:08  peter
+  Revision 1.182  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.181  2004/10/24 20:01:08  peter
     * remove saveregister calling convention
 
   Revision 1.180  2004/10/24 11:53:45  peter

+ 7 - 3
compiler/ncgcnv.pas

@@ -60,9 +60,9 @@ interface
       cutils,verbose,globtype,globals,
       aasmbase,aasmtai,aasmcpu,symconst,symdef,paramgr,
       ncon,ncal,
-      cpubase,cpuinfo,systems,
+      cpubase,systems,
       pass_2,
-      procinfo,cgbase,
+      cgbase,
       cgutils,cgobj,
       ncgutil,
       tgobj
@@ -529,7 +529,11 @@ end.
 
 {
   $Log$
-  Revision 1.60  2004-09-25 14:23:54  peter
+  Revision 1.61  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.60  2004/09/25 14:23:54  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 6 - 2
compiler/ncgcon.pas

@@ -67,7 +67,7 @@ implementation
       verbose,globals,
       symconst,symdef,aasmbase,aasmtai,aasmcpu,defutil,
       cpuinfo,cpubase,
-      cgbase,cgobj,
+      cgbase,cgobj,cgutils,
       ncgutil
       ;
 
@@ -751,7 +751,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.46  2004-10-15 09:14:17  mazen
+  Revision 1.47  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.46  2004/10/15 09:14:17  mazen
   - remove $IFDEF DELPHI and related code
   - remove $IFDEF FPCPROCVAR and related code
 

+ 7 - 4
compiler/ncginl.pas

@@ -62,8 +62,7 @@ implementation
       cpuinfo,cpubase,paramgr,procinfo,
       nbas,ncon,ncal,ncnv,nld,
       tgobj,ncgutil,
-      cgutils,cgobj,
-      rgobj
+      cgutils,cgobj
 {$ifndef cpu64bit}
       ,cg64f32
 {$endif cpu64bit}
@@ -428,7 +427,7 @@ implementation
                   location_force_reg(exprasmlist,tcallparanode(tcallparanode(left).right).left.location,cgsize,addvalue<=1);
                   hregister:=tcallparanode(tcallparanode(left).right).left.location.register;
 {$ifndef cpu64bit}
-                  hregisterhi:=tcallparanode(tcallparanode(left).right).left.location.registerhigh;
+                  hregisterhi:=tcallparanode(tcallparanode(left).right).left.location.register64.reghi;
 {$endif cpu64bit}
                   { insert multiply with addvalue if its >1 }
                   if addvalue>1 then
@@ -685,7 +684,11 @@ end.
 
 {
   $Log$
-  Revision 1.64  2004-09-25 14:23:54  peter
+  Revision 1.65  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.64  2004/09/25 14:23:54  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 23 - 1
compiler/ncgld.pas

@@ -44,6 +44,10 @@ interface
           procedure pass_2;override;
        end;
 
+       tcgrttinode = class(trttinode)
+          procedure pass_2;override;
+       end;
+
 
 implementation
 
@@ -926,14 +930,32 @@ implementation
          end;
       end;
 
+
+{*****************************************************************************
+                           SecondRTTI
+*****************************************************************************}
+
+    procedure tcgrttinode.pass_2;
+      begin
+        location_reset(location,LOC_CREFERENCE,OS_NO);
+        location.reference.symbol:=rttidef.get_rtti_label(rttitype);
+      end;
+
+
+
 begin
    cloadnode:=tcgloadnode;
    cassignmentnode:=tcgassignmentnode;
    carrayconstructornode:=tcgarrayconstructornode;
+   crttinode:=tcgrttinode;
 end.
 {
   $Log$
-  Revision 1.128  2004-10-24 11:44:28  peter
+  Revision 1.129  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.128  2004/10/24 11:44:28  peter
     * small regvar fixes
     * loadref parameter removed from concatcopy,incrrefcount,etc
 

+ 9 - 5
compiler/ncgmat.pas

@@ -132,7 +132,7 @@ implementation
       parabase,
       pass_2,
       ncon,
-      tgobj,ncgutil,cgobj,paramgr
+      tgobj,ncgutil,cgobj,cgutils,paramgr
 {$ifndef cpu64bit}
       ,cg64f32
 {$endif cpu64bit}
@@ -180,7 +180,7 @@ implementation
         location_copy(location,left.location);
         location_force_reg(exprasmlist,location,OS_64,false);
         cg64.a_op64_loc_reg(exprasmlist,OP_NEG,
-           location,joinreg64(location.registerlow,location.registerhigh));
+           location,joinreg64(location.register64.reglo,location.register64.reghi));
       end;
 {$endif cpu64bit}
 
@@ -286,8 +286,8 @@ implementation
              location_copy(location,left.location);
              location_force_reg(exprasmlist,right.location,OS_64,false);
              emit64_div_reg_reg(is_signed(left.resulttype.def),
-               joinreg64(right.location.registerlow,right.location.registerhigh),
-               joinreg64(location.registerlow,location.registerhigh));
+               joinreg64(right.location.register64.reglo,right.location.register64.reghi),
+               joinreg64(location.register64.reglo,location.register64.reghi));
            end
          else
 {$endif cpu64bit}
@@ -473,7 +473,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.29  2004-09-25 14:23:54  peter
+  Revision 1.30  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.29  2004/09/25 14:23:54  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 6 - 2
compiler/ncgopt.pas

@@ -44,7 +44,7 @@ uses
   aasmbase,aasmtai,
   ncnv, ncon, pass_2,
   cgbase, cpubase,
-  tgobj, cgobj, ncgutil;
+  tgobj, cgobj, cgutils,ncgutil;
 
 
 {*****************************************************************************
@@ -196,7 +196,11 @@ end.
 
 {
   $Log$
-  Revision 1.16  2004-10-24 11:44:28  peter
+  Revision 1.17  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.16  2004/10/24 11:44:28  peter
     * small regvar fixes
     * loadref parameter removed from concatcopy,incrrefcount,etc
 

+ 8 - 4
compiler/ncgset.pas

@@ -89,7 +89,7 @@ implementation
       verbose,
       symconst,symdef,defutil,
       paramgr,
-      pass_2,
+      pass_2,tgobj,
       nbas,ncon,nflw,
       ncgutil,regvars,cpuinfo,
       cgutils;
@@ -787,8 +787,8 @@ implementation
 {$ifndef cpu64bit}
          if opsize in [OS_S64,OS_64] then
            begin
-             hregister:=left.location.registerlow;
-             hregister2:=left.location.registerhigh;
+             hregister:=left.location.register64.reglo;
+             hregister2:=left.location.register64.reghi;
            end
          else
 {$endif cpu64bit}
@@ -944,7 +944,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.69  2004-10-30 22:01:11  florian
+  Revision 1.70  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.69  2004/10/30 22:01:11  florian
     * jmp table code generation for case statement on sparc
 
   Revision 1.68  2004/09/25 14:23:54  peter

+ 35 - 31
compiler/ncgutil.pas

@@ -29,7 +29,7 @@ interface
     uses
       node,cpuinfo,
       globtype,
-      cpubase,cgbase,parabase,
+      cpubase,cgbase,parabase,cgutils,
       aasmbase,aasmtai,aasmcpu,
       symconst,symbase,symdef,symsym,symtype,symtable
 {$ifndef cpu64bit}
@@ -127,7 +127,7 @@ implementation
 {$endif GDB}
     pass_1,pass_2,
     ncon,nld,nutils,
-    tgobj,cgutils,cgobj;
+    tgobj,cgobj;
 
 
 {*****************************************************************************
@@ -250,8 +250,8 @@ implementation
             begin
               { can't be a regvar, since it would be LOC_CREGISTER then }
               exclude(regs,getsupreg(t.register));
-              if t.registerhigh<>NR_NO then
-                exclude(regs,getsupreg(t.registerhigh));
+              if t.register64.reghi<>NR_NO then
+                exclude(regs,getsupreg(t.register64.reghi));
             end;
           LOC_CREFERENCE,LOC_REFERENCE:
             begin
@@ -367,8 +367,8 @@ implementation
               { load a smaller size to OS_64 }
               if l.loc=LOC_REGISTER then
                begin
-                 hregister:=cg.makeregsize(list,l.registerlow,OS_32);
-                 cg.a_load_reg_reg(list,l.size,OS_32,l.registerlow,hregister);
+                 hregister:=cg.makeregsize(list,l.register64.reglo,OS_32);
+                 cg.a_load_reg_reg(list,l.size,OS_32,l.register64.reglo,hregister);
                end
               else
                hregister:=cg.getintregister(list,OS_INT);
@@ -409,8 +409,8 @@ implementation
               else
                cg.a_load_const_reg(list,OS_32,0,hregisterhi);
               location_reset(l,LOC_REGISTER,dst_size);
-              l.registerlow:=hregister;
-              l.registerhigh:=hregisterhi;
+              l.register64.reglo:=hregister;
+              l.register64.reghi:=hregisterhi;
             end
            else
             begin
@@ -418,8 +418,8 @@ implementation
               if (l.loc=LOC_REGISTER) or
                  ((l.loc=LOC_CREGISTER) and maybeconst) then
                begin
-                 hregister:=l.registerlow;
-                 hregisterhi:=l.registerhigh;
+                 hregister:=l.register64.reglo;
+                 hregisterhi:=l.register64.reghi;
                end
               else
                begin
@@ -431,8 +431,8 @@ implementation
               { load value in new register }
               cg64.a_load64_loc_reg(list,l,hreg64);
               location_reset(l,LOC_REGISTER,dst_size);
-              l.registerlow:=hregister;
-              l.registerhigh:=hregisterhi;
+              l.register64.reglo:=hregister;
+              l.register64.reghi:=hregisterhi;
             end;
          end
         else
@@ -1089,12 +1089,12 @@ implementation
                         internalerror(200409141);
                       { Load low and high register separate to generate better register
                         allocation info }
-                      if getsupreg(resloc.registerlow)<first_int_imreg then
+                      if getsupreg(resloc.register64.reglo)<first_int_imreg then
                         begin
-                          cg.getcpuregister(list,resloc.registerlow);
-                          cg.ungetcpuregister(list,resloc.registerlow);
+                          cg.getcpuregister(list,resloc.register64.reglo);
+                          cg.ungetcpuregister(list,resloc.register64.reglo);
                           { for the optimizer }
-                          cg.a_reg_alloc(list,resloc.registerlow);
+                          cg.a_reg_alloc(list,resloc.register64.reglo);
                         end;
                       case restmploc.loc of
                         LOC_REFERENCE :
@@ -1102,19 +1102,19 @@ implementation
                             href:=restmploc.reference;
                             if target_info.endian=ENDIAN_BIG then
                               inc(href.offset,4);
-                            cg.a_load_ref_reg(list,OS_32,OS_32,href,resloc.registerlow);
+                            cg.a_load_ref_reg(list,OS_32,OS_32,href,resloc.register64.reglo);
                           end;
                         LOC_CREGISTER :
-                          cg.a_load_reg_reg(list,OS_32,OS_32,restmploc.registerlow,resloc.registerlow);
+                          cg.a_load_reg_reg(list,OS_32,OS_32,restmploc.register64.reglo,resloc.register64.reglo);
                         else
                           internalerror(200409203);
                       end;
-                      if getsupreg(resloc.registerhigh)<first_int_imreg then
+                      if getsupreg(resloc.register64.reghi)<first_int_imreg then
                         begin
-                          cg.getcpuregister(list,resloc.registerhigh);
-                          cg.ungetcpuregister(list,resloc.registerhigh);
+                          cg.getcpuregister(list,resloc.register64.reghi);
+                          cg.ungetcpuregister(list,resloc.register64.reghi);
                           { for the optimizer }
-                          cg.a_reg_alloc(list,resloc.registerhigh);
+                          cg.a_reg_alloc(list,resloc.register64.reghi);
                         end;
                       case restmploc.loc of
                         LOC_REFERENCE :
@@ -1122,10 +1122,10 @@ implementation
                             href:=restmploc.reference;
                             if target_info.endian=ENDIAN_LITTLE then
                               inc(href.offset,4);
-                            cg.a_load_ref_reg(list,OS_32,OS_32,href,resloc.registerhigh);
+                            cg.a_load_ref_reg(list,OS_32,OS_32,href,resloc.register64.reghi);
                           end;
                         LOC_CREGISTER :
-                          cg.a_load_reg_reg(list,OS_32,OS_32,restmploc.registerhigh,resloc.registerhigh);
+                          cg.a_load_reg_reg(list,OS_32,OS_32,restmploc.register64.reghi,resloc.register64.reghi);
                         else
                           internalerror(200409204);
                       end;
@@ -1323,17 +1323,17 @@ implementation
                       { First 32bits }
                       unget_para(paraloc^);
                       if (target_info.endian=ENDIAN_BIG) then
-                        gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerhigh)
+                        gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.register64.reghi)
                       else
-                        gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerlow);
+                        gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.register64.reglo);
                       { Second 32bits }
                       if not assigned(paraloc^.next) then
                         internalerror(200410104);
                       unget_para(paraloc^);
                       if (target_info.endian=ENDIAN_BIG) then
-                        gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerlow)
+                        gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.register64.reglo)
                       else
-                        gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.registerhigh);
+                        gen_load_reg(paraloc^,tvarsym(hp.parasym).localloc.register64.reghi);
                     end
                   else
 {$endif cpu64bit}
@@ -1874,8 +1874,8 @@ implementation
 {$ifndef cpu64bit}
                                   if cgsize in [OS_64,OS_S64] then
                                     begin
-                                      localloc.registerlow:=cg.getintregister(list,OS_32);
-                                      localloc.registerhigh:=cg.getintregister(list,OS_32);
+                                      localloc.register64.reglo:=cg.getintregister(list,OS_32);
+                                      localloc.register64.reghi:=cg.getintregister(list,OS_32);
                                     end
                                   else
 {$endif cpu64bit}
@@ -2207,7 +2207,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.233  2004-10-28 18:29:44  olle
+  Revision 1.234  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.233  2004/10/28 18:29:44  olle
     * reverted, for macos only, last change.
 
   Revision 1.232  2004/10/26 15:03:31  peter

+ 7 - 3
compiler/new/powerpc/cpubase.pas

@@ -338,8 +338,8 @@ type
         LOC_FPU, LOC_CFPUREGISTER, LOC_MMREGISTER, LOC_CMMREGISTER,
           LOC_REGISTER,LOC_CREGISTER : (
             case longint of
-              1 : (registerlow,registerhigh : tregister);
-              { overlay a registerlow }
+              1 : (register64.reglo,register64.reghi : tregister);
+              { overlay a register64.reglo }
               2 : (register : tregister);
             );
 
@@ -599,7 +599,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.4  2001-09-09 17:10:26  jonas
+  Revision 1.5  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.4  2001/09/09 17:10:26  jonas
     * some more things implemented
 
   Revision 1.3  2001/08/26 13:35:06  florian

+ 6 - 2
compiler/ninl.pas

@@ -73,7 +73,7 @@ implementation
       verbose,globals,systems,
       globtype, cutils,
       symbase,symconst,symdef,symsym,symtable,paramgr,defutil,defcmp,
-      pass_1,
+      pass_1,tgobj,
       ncal,ncon,ncnv,nadd,nld,nbas,nflw,nmem,nmat,nutils,
       cgbase,procinfo
       ;
@@ -2442,7 +2442,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.145  2004-09-16 16:32:27  peter
+  Revision 1.146  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.145  2004/09/16 16:32:27  peter
     * another fix for reading of subranges
 
   Revision 1.144  2004/09/13 20:32:06  peter

+ 5 - 9
compiler/nld.pas

@@ -119,7 +119,6 @@ interface
           procedure derefimpl;override;
           function  getcopy : tnode;override;
           function pass_1 : tnode;override;
-          procedure pass_2;override;
           function det_resulttype:tnode;override;
           function docompare(p: tnode): boolean; override;
        end;
@@ -1155,13 +1154,6 @@ implementation
       end;
 
 
-    procedure trttinode.pass_2;
-      begin
-        location_reset(location,LOC_CREFERENCE,OS_NO);
-        location.reference.symbol:=rttidef.get_rtti_label(rttitype);
-      end;
-
-
 begin
    cloadnode:=tloadnode;
    cassignmentnode:=tassignmentnode;
@@ -1172,7 +1164,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.135  2004-10-24 11:44:28  peter
+  Revision 1.136  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.135  2004/10/24 11:44:28  peter
     * small regvar fixes
     * loadref parameter removed from concatcopy,incrrefcount,etc
 

+ 6 - 2
compiler/node.pas

@@ -29,7 +29,7 @@ interface
     uses
        cclasses,
        globtype,globals,
-       cpubase,cgbase,
+       cpubase,cgbase,cgutils,
        aasmbase,
        symtype;
 
@@ -1132,7 +1132,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.87  2004-06-20 08:55:29  florian
+  Revision 1.88  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.87  2004/06/20 08:55:29  florian
     * logs truncated
 
   Revision 1.86  2004/06/16 20:07:09  florian

+ 16 - 11
compiler/parabase.pas

@@ -27,20 +27,21 @@ unit parabase;
 
     uses
        cclasses,globtype,
-       cpubase,cgbase;
+       cpubase,cgbase,cgutils;
 
     type
-       { tparamlocation describes where a parameter for a procedure is stored.
-         References are given from the caller's point of view. The usual
-         TLocation isn't used, because contains a lot of unnessary fields.
-       }
+       TCGParaReference = record
+          index       : tregister;
+          offset      : aint;
+       end;
+
        PCGParaLocation = ^TCGParaLocation;
        TCGParaLocation = record
          Next : PCGParaLocation;
          Size : TCGSize; { size of this location }
          Loc  : TCGLoc;
          case TCGLoc of
-           LOC_REFERENCE : (reference : tparareference);
+           LOC_REFERENCE : (reference : TCGParaReference);
            LOC_FPUREGISTER,
            LOC_CFPUREGISTER,
            LOC_MMREGISTER,
@@ -179,13 +180,13 @@ implementation
                     internalerror(200408207);
                   if (target_info.endian = ENDIAN_BIG) then
                     begin
-                      newloc.registerhigh:=location^.register;
-                      newloc.registerlow:=location^.next^.register;
+                      newloc.register64.reghi:=location^.register;
+                      newloc.register64.reglo:=location^.next^.register;
                     end
                   else
                     begin
-                      newloc.registerlow:=location^.register;
-                      newloc.registerhigh:=location^.next^.register;
+                      newloc.register64.reglo:=location^.register;
+                      newloc.register64.reghi:=location^.next^.register;
                     end;
                 end
               else
@@ -207,7 +208,11 @@ end.
 
 {
    $Log$
-   Revision 1.3  2004-10-10 20:22:53  peter
+   Revision 1.4  2004-10-31 21:45:03  peter
+     * generic tlocation
+     * move tlocation to cgutils
+
+   Revision 1.3  2004/10/10 20:22:53  peter
      * symtable allocation rewritten
      * loading of parameters to local temps/regs cleanup
      * regvar support for parameters

+ 6 - 2
compiler/paramgr.pas

@@ -126,7 +126,7 @@ implementation
 
     uses
        systems,
-       cgobj,tgobj,
+       cgobj,tgobj,cgutils,
        defutil,verbose;
 
     { true if uses a parameter as return value }
@@ -447,7 +447,11 @@ end.
 
 {
    $Log$
-   Revision 1.79  2004-09-25 14:23:54  peter
+   Revision 1.80  2004-10-31 21:45:03  peter
+     * generic tlocation
+     * move tlocation to cgutils
+
+   Revision 1.79  2004/09/25 14:23:54  peter
      * ungetregister is now only used for cpuregisters, renamed to
        ungetcpuregister
      * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 6 - 2
compiler/powerpc/aasmcpu.pas

@@ -30,7 +30,7 @@ uses
   cclasses,
   globtype,globals,verbose,
   aasmbase,aasmtai,
-  cpubase,cpuinfo,cgbase;
+  cpubase,cpuinfo,cgbase,cgutils;
 
     const
       { "mov reg,reg" source operand number }
@@ -410,7 +410,11 @@ uses cutils,rgobj;
 end.
 {
   $Log$
-  Revision 1.27  2004-06-20 08:55:31  florian
+  Revision 1.28  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.27  2004/06/20 08:55:31  florian
     * logs truncated
 
   Revision 1.26  2004/06/17 16:55:46  peter

+ 6 - 2
compiler/powerpc/agppcgas.pas

@@ -46,7 +46,7 @@ unit agppcgas;
 
     uses
        cutils,globals,verbose,
-       cgbase,systems,
+       cgbase,cgutils,systems,
        assemble,
        itcpugas,
        aasmcpu;
@@ -365,7 +365,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.44  2004-06-20 08:55:31  florian
+  Revision 1.45  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.44  2004/06/20 08:55:31  florian
     * logs truncated
 
   Revision 1.43  2004/06/17 16:55:46  peter

+ 8 - 4
compiler/powerpc/agppcmpw.pas

@@ -59,7 +59,7 @@ interface
     uses
       cutils,globtype,systems,cclasses,
       verbose,finput,fmodule,script,cpuinfo,
-      cgbase,
+      cgbase,cgutils,
       itcpugas
       ;
 
@@ -1022,7 +1022,7 @@ var
                    end
                  else
                    begin
-                     s:= tostr(tai_const(hp).value); 
+                     s:= tostr(tai_const(hp).value);
                      AsmWrite(s);
                      inc(l,length(s));
                    end;
@@ -1036,7 +1036,7 @@ var
                until false;
                AsmLn;
              end;
- 
+
             ait_real_64bit :
               begin
                 AsmWriteLn(target_asm.comment+'value: '+double2str(tai_real_64bit(hp).value));
@@ -1462,7 +1462,11 @@ initialization
 end.
 {
   $Log$
-  Revision 1.41  2004-10-31 15:32:13  olle
+  Revision 1.42  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.41  2004/10/31 15:32:13  olle
     + Change of the way global variables, with multiple entrypoints,
       are referenced, fixes a lot of failed tests
 

+ 10 - 7
compiler/powerpc/cgcpu.pas

@@ -30,7 +30,7 @@ unit cgcpu;
        globtype,symtype,
        cgbase,cgobj,
        aasmbase,aasmcpu,aasmtai,
-       cpubase,cpuinfo,node,cg64f32,rgcpu,
+       cpubase,cpuinfo,cgutils,cg64f32,rgcpu,
        parabase;
 
     type
@@ -96,7 +96,7 @@ unit cgcpu;
         function get_rlwi_const(a: aint; var l1, l2: longint): boolean;
 
         procedure a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
-        
+
       private
 
         (* NOT IN USE: *)
@@ -156,8 +156,7 @@ const
     uses
        globals,verbose,systems,cutils,
        symconst,symdef,symsym,
-       rgobj,tgobj,cpupi,procinfo,paramgr,
-       cgutils;
+       rgobj,tgobj,cpupi,procinfo,paramgr;
 
 
     procedure tcgppc.init_register_allocators;
@@ -980,8 +979,8 @@ const
       begin
         { this work is done in g_proc_entry }
       end;
-      
-    
+
+
     procedure tcgppc.g_restore_standard_registers(list:Taasmoutput);
       begin
         { this work is done in g_proc_exit }
@@ -2357,7 +2356,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.183  2004-10-26 18:21:29  jonas
+  Revision 1.184  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.183  2004/10/26 18:21:29  jonas
     + empty g_save_standard_registers/g_restore_standard_registers overrides
       (their work was/is done by g_proc_entry/g_proc_exit, and the generic
        version saves the registers in the wrong place)

+ 12 - 92
compiler/powerpc/cpubase.pas

@@ -242,35 +242,6 @@ uses
                                 Reference
 *****************************************************************************}
 
-    type
-      trefoptions=(ref_none,ref_parafixup,ref_localfixup,ref_selffixup);
-
-      { reference record }
-      preference = ^treference;
-      treference = packed record
-         { base register, R_NO if none }
-         base,
-         { index register, R_NO if none }
-         index       : tregister;
-         { offset, 0 if none }
-         offset      : aint;
-         { symbol this reference refers to, nil if none }
-         symbol      : tasmsymbol;
-         { symbol the symbol of this reference is relative to, nil if none }
-         relsymbol      : tasmsymbol;
-         { reference type addr or symbol itself }
-         refaddr : trefaddr;
-         { alignment this reference is guaranteed to have }
-         alignment   : byte;
-      end;
-
-      { reference record }
-      pparareference = ^tparareference;
-      tparareference = packed record
-         index       : tregister;
-         offset      : aword;
-      end;
-
     const
       symaddr2str: array[trefaddr] of string[3] = ('','','@ha','@l');
 
@@ -283,68 +254,6 @@ uses
                                 Operand Sizes
 *****************************************************************************}
 
-{*****************************************************************************
-                               Generic Location
-*****************************************************************************}
-
-    type
-      { tparamlocation describes where a parameter for a procedure is stored.
-        References are given from the caller's point of view. The usual
-        TLocation isn't used, because contains a lot of unnessary fields.
-      }
-      tparalocation = packed record
-         size : TCGSize;
-         { The location type where the parameter is passed, usually
-           LOC_REFERENCE,LOC_REGISTER or LOC_FPUREGISTER
-         }
-         loc  : TCGLoc;
-         lochigh : TCGLoc;
-         { Word alignment on stack 4 --> 32 bit }
-         Alignment:Byte;
-         case TCGLoc of
-            LOC_REFERENCE : (reference : tparareference);
-            LOC_FPUREGISTER, LOC_CFPUREGISTER, LOC_MMREGISTER, LOC_CMMREGISTER,
-              LOC_REGISTER,LOC_CREGISTER : (
-              case longint of
-                1 : (register,registerhigh : tregister);
-                { overlay a registerlow }
-                2 : (registerlow : tregister);
-{$ifndef cpu64bit}
-                { overlay a 64 Bit register type }
-                3 : (register64 : tregister64);
-{$endif cpu64bit}
-            );
-      end;
-
-      tlocation = packed record
-         size : TCGSize;
-         loc : tcgloc;
-         case tcgloc of
-            LOC_CREFERENCE,LOC_REFERENCE : (reference : treference);
-            LOC_CONSTANT : (
-              case longint of
-{$ifdef FPC_BIG_ENDIAN}
-                1 : (_valuedummy,value : aint);
-{$else FPC_BIG_ENDIAN}
-                1 : (value : aint);
-{$endif FPC_BIG_ENDIAN}
-                { can't do this, this layout depends on the host cpu. Use }
-                { lo(valueqword)/hi(valueqword) instead (JM)              }
-                { overlay a complete 64 Bit value }
-                2 : (value64 : Int64);
-              );
-            LOC_FPUREGISTER, LOC_CFPUREGISTER, LOC_MMREGISTER, LOC_CMMREGISTER,
-              LOC_REGISTER,LOC_CREGISTER : (
-                case longint of
-                  1 : (registerlow,registerhigh : tregister);
-                  2 : (register : tregister);
-{$ifndef cpu64bit}
-                  { overlay a 64 Bit register type }
-                  3 : (register64 : tregister64);
-{$endif cpu64bit}
-                );
-            LOC_FLAGS : (resflags : tresflags);
-      end;
 
 {*****************************************************************************
                                  Constants
@@ -455,6 +364,13 @@ uses
       }
       std_param_align = 4;  { for 32-bit version only }
 
+      { size of the buffer used for setjump/longjmp
+        the size of this buffer is deduced from the
+        jmp_buf structure in setjumph.inc file
+      }
+      { for linux: }
+      jmp_buf_size = 232;
+
 {*****************************************************************************
                             CPU Dependent Constants
 *****************************************************************************}
@@ -642,7 +558,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.91  2004-10-26 18:22:04  jonas
+  Revision 1.92  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.91  2004/10/26 18:22:04  jonas
     * fixed tlocation record again for big endian
     * fixed (currently unused) saved_standard_registers array
 

+ 5 - 14
compiler/powerpc/cpuinfo.pas

@@ -45,19 +45,6 @@ Type
 
 
 Const
-   {# Size of native extended floating point type }
-   extended_size = 8;
-   {# Size of a multimedia register               }
-   mmreg_size = 16;
-   { target cpu string (used by compiler options) }
-   target_cpu_string = 'powerpc';
-   { size of the buffer used for setjump/longjmp
-     the size of this buffer is deduced from the
-     jmp_buf structure in setjumph.inc file
-   }
-   { for linux: }
-   jmp_buf_size = 232;
-
    { calling conventions supported by the code generator }
    supported_calling_conventions : tproccalloptions = [
      pocall_internproc,
@@ -85,7 +72,11 @@ Implementation
 end.
 {
   $Log$
-  Revision 1.20  2004-06-20 08:55:32  florian
+  Revision 1.21  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.20  2004/06/20 08:55:32  florian
     * logs truncated
 
   Revision 1.19  2004/06/16 20:07:10  florian

+ 47 - 43
compiler/powerpc/nppcadd.pas

@@ -55,7 +55,7 @@ interface
       symconst,symdef,paramgr,
       aasmbase,aasmtai,aasmcpu,defutil,htypechk,
       cgbase,cpuinfo,pass_1,pass_2,regvars,
-      cpupara,cgcpu,
+      cpupara,cgcpu,cgutils,
       ncon,nset,
       ncgutil,tgobj,rgobj,rgcpu,cgobj,cg64f32;
 
@@ -110,7 +110,7 @@ interface
                 begin
                   location.register := n.location.register;
                   if is_64bit(n.resulttype.def) then
-                    location.registerhigh := n.location.registerhigh;
+                    location.register64.reghi := n.location.register64.reghi;
                 end;
             LOC_REFERENCE,LOC_CREFERENCE:
               begin
@@ -119,7 +119,7 @@ interface
                   begin
                     location.register := n.location.register;
                     if is_64bit(n.resulttype.def) then
-                      location.registerhigh := n.location.registerhigh;
+                      location.register64.reghi := n.location.register64.reghi;
                   end;
               end;
             LOC_CONSTANT:
@@ -130,7 +130,7 @@ interface
                     if not cmpop then
                       location.register := n.location.register;
                       if is_64bit(n.resulttype.def) then
-                        location.registerhigh := n.location.registerhigh;
+                        location.register64.reghi := n.location.register64.reghi;
                   end;
               end;
           end;
@@ -144,7 +144,7 @@ interface
          begin
            location.register := cg.getintregister(exprasmlist,OS_INT);
            if is_64bit(resulttype.def) then
-             location.registerhigh := cg.getintregister(exprasmlist,OS_INT);
+             location.register64.reghi := cg.getintregister(exprasmlist,OS_INT);
          end;
       end;
 
@@ -664,11 +664,11 @@ interface
           if left.location.loc = LOC_CONSTANT then
             left.location.value64 := left.location.value64 shr 32
           else
-            left.location.registerlow := left.location.registerhigh;
+            left.location.register64.reglo := left.location.register64.reghi;
           if right.location.loc = LOC_CONSTANT then
             right.location.value64 := right.location.value64 shr 32
           else
-            right.location.registerlow := right.location.registerhigh;
+            right.location.register64.reglo := right.location.register64.reghi;
 
           // and call the normal emit_compare
           emit_compare(unsigned);
@@ -834,19 +834,19 @@ interface
                     begin
                       if left.location.loc = LOC_REGISTER then
                         begin
-                          tempreg64.reglo := left.location.registerlow;
-                          tempreg64.reghi := left.location.registerhigh;
+                          tempreg64.reglo := left.location.register64.reglo;
+                          tempreg64.reghi := left.location.register64.reghi;
                         end
                       else
                         begin
                           if (aint(right.location.value64) <> 0) then
                             tempreg64.reglo := cg.getintregister(exprasmlist,OS_32)
                           else
-                            tempreg64.reglo := left.location.registerlow;
+                            tempreg64.reglo := left.location.register64.reglo;
                           if ((right.location.value64 shr 32) <> 0) then
                             tempreg64.reghi := cg.getintregister(exprasmlist,OS_32)
                           else
-                            tempreg64.reghi := left.location.registerhigh;
+                            tempreg64.reghi := left.location.register64.reghi;
                         end;
 
                       if (aint(right.location.value64) <> 0) then
@@ -856,22 +856,22 @@ interface
                            (longint(right.location.value64) < 0) then
                           cg.a_op_const_reg_reg(exprasmlist,OP_SUB,OS_INT,
                             aint(right.location.value64),
-                            left.location.registerlow,tempreg64.reglo)
+                            left.location.register64.reglo,tempreg64.reglo)
                         else
                           cg.a_op_const_reg_reg(exprasmlist,OP_XOR,OS_INT,
                             aint(right.location.value64),
-                            left.location.registerlow,tempreg64.reglo);
+                            left.location.register64.reglo,tempreg64.reglo);
 
                       if ((right.location.value64 shr 32) <> 0) then
                         if (longint(right.location.value64 shr 32) >= -32767) and
                            (longint(right.location.value64 shr 32) < 0) then
                           cg.a_op_const_reg_reg(exprasmlist,OP_SUB,OS_INT,
                             aint(right.location.value64 shr 32),
-                            left.location.registerhigh,tempreg64.reghi)
+                            left.location.register64.reghi,tempreg64.reghi)
                         else
                           cg.a_op_const_reg_reg(exprasmlist,OP_XOR,OS_INT,
                             aint(right.location.value64 shr 32),
-                            left.location.registerhigh,tempreg64.reghi);
+                            left.location.register64.reghi,tempreg64.reghi);
                     end
                   else
                     begin
@@ -892,10 +892,10 @@ interface
                 end;
               xorn,orn,andn,addn:
                 begin
-                  if (location.registerlow = NR_NO) then
+                  if (location.register64.reglo = NR_NO) then
                     begin
-                      location.registerlow := cg.getintregister(exprasmlist,OS_INT);
-                      location.registerhigh := cg.getintregister(exprasmlist,OS_INT);
+                      location.register64.reglo := cg.getintregister(exprasmlist,OS_INT);
+                      location.register64.reghi := cg.getintregister(exprasmlist,OS_INT);
                     end;
 
                   if (left.location.loc = LOC_CONSTANT) then
@@ -914,10 +914,10 @@ interface
 
                   if left.location.loc <> LOC_CONSTANT then
                     begin
-                      if (location.registerlow = NR_NO) then
+                      if (location.register64.reglo = NR_NO) then
                         begin
-                         location.registerlow := cg.getintregister(exprasmlist,OS_INT);
-                         location.registerhigh := cg.getintregister(exprasmlist,OS_INT);
+                         location.register64.reglo := cg.getintregister(exprasmlist,OS_INT);
+                         location.register64.reghi := cg.getintregister(exprasmlist,OS_INT);
                       end;
                       if right.location.loc <> LOC_CONSTANT then
                         // reg64 - reg64
@@ -932,17 +932,17 @@ interface
                     end
                   else if ((left.location.value64 shr 32) = 0) then
                     begin
-                      if (location.registerlow = NR_NO) then
+                      if (location.register64.reglo = NR_NO) then
                         begin
-                         location.registerlow := cg.getintregister(exprasmlist,OS_INT);
-                         location.registerhigh := cg.getintregister(exprasmlist,OS_INT);
+                         location.register64.reglo := cg.getintregister(exprasmlist,OS_INT);
+                         location.register64.reghi := cg.getintregister(exprasmlist,OS_INT);
                       end;
                       if (int64(left.location.value64) >= low(smallint)) and
                          (int64(left.location.value64) <= high(smallint)) then
                         begin
                           // consts16 - reg64
                           exprasmlist.concat(taicpu.op_reg_reg_const(A_SUBFIC,
-                            location.registerlow,right.location.registerlow,
+                            location.register64.reglo,right.location.register64.reglo,
                             left.location.value));
                         end
                       else
@@ -951,26 +951,26 @@ interface
                           location_force_reg(exprasmlist,left.location,
                             OS_32,true);
                           exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUBC,
-                            location.registerlow,left.location.registerlow,
-                            right.location.registerlow));
+                            location.register64.reglo,left.location.register64.reglo,
+                            right.location.register64.reglo));
                         end;
                       exprasmlist.concat(taicpu.op_reg_reg(A_SUBFZE,
-                        location.registerhigh,right.location.registerhigh));
+                        location.register64.reghi,right.location.register64.reghi));
                     end
                   else if (aint(left.location.value64) = 0) then
                     begin
                       // (const32 shl 32) - reg64
-                      if (location.registerlow = NR_NO) then
+                      if (location.register64.reglo = NR_NO) then
                         begin
-                         location.registerlow := cg.getintregister(exprasmlist,OS_INT);
-                         location.registerhigh := cg.getintregister(exprasmlist,OS_INT);
+                         location.register64.reglo := cg.getintregister(exprasmlist,OS_INT);
+                         location.register64.reghi := cg.getintregister(exprasmlist,OS_INT);
                       end;
                       exprasmlist.concat(taicpu.op_reg_reg_const(A_SUBFIC,
-                        location.registerlow,right.location.registerlow,0));
+                        location.register64.reglo,right.location.register64.reglo,0));
                       left.location.value64 := left.location.value64 shr 32;
                       location_force_reg(exprasmlist,left.location,OS_32,true);
                       exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUBFE,
-                        location.registerhigh,right.location.registerhigh,
+                        location.register64.reghi,right.location.register64.reghi,
                         left.location.register));
                     end
                   else
@@ -980,10 +980,10 @@ interface
                         def_cgsize(left.resulttype.def),false);
                       if (left.location.loc = LOC_REGISTER) then
                         location.register64 := left.location.register64
-                      else if (location.registerlow = NR_NO) then
+                      else if (location.register64.reglo = NR_NO) then
                         begin
-                         location.registerlow := cg.getintregister(exprasmlist,OS_INT);
-                         location.registerhigh := cg.getintregister(exprasmlist,OS_INT);
+                         location.register64.reglo := cg.getintregister(exprasmlist,OS_INT);
+                         location.register64.reghi := cg.getintregister(exprasmlist,OS_INT);
                         end;
                       cg64.a_op64_reg_reg_reg(exprasmlist,OP_SUB,
                         right.location.register64,left.location.register64,
@@ -1028,15 +1028,15 @@ interface
                     end;
                 end;
               end;
-            exprasmlist.concat(taicpu.op_reg_reg_reg(op1,location.registerlow,
-              left.location.registerlow,right.location.registerlow));
-            exprasmlist.concat(taicpu.op_reg_reg_reg(op2,location.registerhigh,
-              right.location.registerhigh,left.location.registerhigh));
+            exprasmlist.concat(taicpu.op_reg_reg_reg(op1,location.register64.reglo,
+              left.location.register64.reglo,right.location.register64.reglo));
+            exprasmlist.concat(taicpu.op_reg_reg_reg(op2,location.register64.reghi,
+              right.location.register64.reghi,left.location.register64.reghi));
             if not(is_signed(resulttype.def)) then
               if nodetype = addn then
-                exprasmlist.concat(taicpu.op_reg_reg(A_CMPLW,location.registerhigh,left.location.registerhigh))
+                exprasmlist.concat(taicpu.op_reg_reg(A_CMPLW,location.register64.reghi,left.location.register64.reghi))
               else
-                exprasmlist.concat(taicpu.op_reg_reg(A_CMPLW,left.location.registerhigh,location.registerhigh));
+                exprasmlist.concat(taicpu.op_reg_reg(A_CMPLW,left.location.register64.reghi,location.register64.reghi));
             cg.g_overflowcheck(exprasmlist,location,resulttype.def);
           end;
 
@@ -1458,7 +1458,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.51  2004-10-26 18:22:31  jonas
+  Revision 1.52  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.51  2004/10/26 18:22:31  jonas
     * fixed bugs due to change of the value field of tlocation from aword to
       aint
 

+ 8 - 4
compiler/powerpc/nppccnv.pas

@@ -57,10 +57,10 @@ interface
 implementation
 
    uses
-      verbose,globals,systems,
+      verbose,globtype,globals,systems,
       symconst,symdef,aasmbase,aasmtai,
       defutil,
-      cgbase,pass_1,pass_2,
+      cgbase,cgutils,pass_1,pass_2,
       ncon,ncal,
       ncgutil,
       cpubase,aasmcpu,
@@ -305,7 +305,7 @@ implementation
                      if left.location.size in [OS_64,OS_S64] then
                        begin
                           hreg1:=cg.getintregister(exprasmlist,OS_32);
-                          cg.a_op_reg_reg_reg(exprasmlist,OP_OR,OS_32,left.location.registerhigh,left.location.registerlow,hreg1);
+                          cg.a_op_reg_reg_reg(exprasmlist,OP_OR,OS_32,left.location.register64.reghi,left.location.register64.reglo,hreg1);
                        end
                      else
                        hreg1 := left.location.register;
@@ -345,7 +345,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.54  2004-09-25 14:23:55  peter
+  Revision 1.55  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.54  2004/09/25 14:23:55  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 6 - 2
compiler/powerpc/nppcinl.pas

@@ -53,7 +53,7 @@ implementation
       defutil,
       cgbase,pass_2,
       cpubase,ncgutil,
-      cgobj,rgobj;
+      cgutils,cgobj,rgobj;
 
 
 {*****************************************************************************
@@ -147,7 +147,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.16  2004-09-25 14:23:55  peter
+  Revision 1.17  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.16  2004/09/25 14:23:55  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 47 - 43
compiler/powerpc/nppcmat.pas

@@ -57,7 +57,7 @@ implementation
       symconst,symdef,
       aasmbase,aasmcpu,aasmtai,
       defutil,
-      cgbase,cgobj,pass_1,pass_2,
+      cgbase,cgutils,cgobj,pass_1,pass_2,
       ncon,procinfo,
       cpubase,cpuinfo,
       ncgutil,cgcpu,cg64f32,rgobj;
@@ -184,7 +184,7 @@ implementation
 
       var
          resultreg, hregister1,hregister2,
-         hregisterhigh,hregisterlow : tregister;
+         hreg64hi,hreg64lo : tregister;
          op : topcg;
          asmop1, asmop2: tasmop;
          shiftval: aint;
@@ -199,35 +199,35 @@ implementation
              location_force_reg(exprasmlist,left.location,
                def_cgsize(left.resulttype.def),true);
              location_copy(location,left.location);
-             hregisterhigh := location.registerhigh;
-             hregisterlow := location.registerlow;
+             hreg64hi := location.register64.reghi;
+             hreg64lo := location.register64.reglo;
              if (location.loc = LOC_CREGISTER) then
                begin
                  location.loc := LOC_REGISTER;
-                 location.registerhigh := cg.getintregister(exprasmlist,OS_32);
-                 location.registerlow := cg.getintregister(exprasmlist,OS_32);
+                 location.register64.reghi := cg.getintregister(exprasmlist,OS_32);
+                 location.register64.reglo := cg.getintregister(exprasmlist,OS_32);
                end;
              if (right.nodetype = ordconstn) then
                begin
                  shiftval := tordconstnode(right).value;
                  if shiftval > 63 then
                    begin
-                     cg.a_load_const_reg(exprasmlist,OS_32,0,location.registerlow);
-                     cg.a_load_const_reg(exprasmlist,OS_32,0,location.registerlow);
+                     cg.a_load_const_reg(exprasmlist,OS_32,0,location.register64.reglo);
+                     cg.a_load_const_reg(exprasmlist,OS_32,0,location.register64.reglo);
                    end
                  else if shiftval > 31 then
                    begin
                      if nodetype = shln then
                        begin
                          cg.a_op_const_reg_reg(exprasmlist,OP_SHL,OS_32,
-                           shiftval and 31,hregisterlow,location.registerhigh);
-                         cg.a_load_const_reg(exprasmlist,OS_32,0,location.registerlow);
+                           shiftval and 31,hreg64lo,location.register64.reghi);
+                         cg.a_load_const_reg(exprasmlist,OS_32,0,location.register64.reglo);
                        end
                      else
                        begin
                          cg.a_op_const_reg_reg(exprasmlist,OP_SHR,OS_32,
-                           shiftval and 31,hregisterhigh,location.registerlow);
-                         cg.a_load_const_reg(exprasmlist,OS_32,0,location.registerhigh);
+                           shiftval and 31,hreg64hi,location.register64.reglo);
+                         cg.a_load_const_reg(exprasmlist,OS_32,0,location.register64.reghi);
                        end;
                    end
                  else
@@ -235,25 +235,25 @@ implementation
                      if nodetype = shln then
                        begin
                          exprasmlist.concat(taicpu.op_reg_reg_const_const_const(
-                           A_RLWINM,location.registerhigh,hregisterhigh,shiftval,
+                           A_RLWINM,location.register64.reghi,hreg64hi,shiftval,
                            0,31-shiftval));
                          exprasmlist.concat(taicpu.op_reg_reg_const_const_const(
-                           A_RLWIMI,location.registerhigh,hregisterlow,shiftval,
+                           A_RLWIMI,location.register64.reghi,hreg64lo,shiftval,
                            32-shiftval,31));
                          exprasmlist.concat(taicpu.op_reg_reg_const_const_const(
-                           A_RLWINM,location.registerlow,hregisterlow,shiftval,
+                           A_RLWINM,location.register64.reglo,hreg64lo,shiftval,
                            0,31-shiftval));
                        end
                      else
                        begin
                          exprasmlist.concat(taicpu.op_reg_reg_const_const_const(
-                           A_RLWINM,location.registerlow,hregisterlow,32-shiftval,
+                           A_RLWINM,location.register64.reglo,hreg64lo,32-shiftval,
                            shiftval,31));
                          exprasmlist.concat(taicpu.op_reg_reg_const_const_const(
-                           A_RLWIMI,location.registerlow,hregisterhigh,32-shiftval,
+                           A_RLWIMI,location.register64.reglo,hreg64hi,32-shiftval,
                            0,shiftval-1));
                          exprasmlist.concat(taicpu.op_reg_reg_const_const_const(
-                           A_RLWINM,location.registerhigh,hregisterhigh,32-shiftval,
+                           A_RLWINM,location.register64.reghi,hreg64hi,32-shiftval,
                            shiftval,31));
                        end;
                    end;
@@ -272,38 +272,38 @@ implementation
                    begin
                      asmop1 := A_SRW;
                      asmop2 := A_SLW;
-                     resultreg := hregisterhigh;
-                     hregisterhigh := hregisterlow;
-                     hregisterlow := resultreg;
-                     resultreg := location.registerhigh;
-                     location.registerhigh := location.registerlow;
-                     location.registerlow := resultreg;
+                     resultreg := hreg64hi;
+                     hreg64hi := hreg64lo;
+                     hreg64lo := resultreg;
+                     resultreg := location.register64.reghi;
+                     location.register64.reghi := location.register64.reglo;
+                     location.register64.reglo := resultreg;
                    end;
 
                  cg.getcpuregister(exprasmlist,NR_R0);
                  exprasmlist.concat(taicpu.op_reg_reg_const(A_SUBFIC,
                    NR_R0,hregister1,32));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(asmop1,
-                   location.registerhigh,hregisterhigh,hregister1));
+                   location.register64.reghi,hreg64hi,hregister1));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(asmop2,
-                   NR_R0,hregisterlow,NR_R0));
+                   NR_R0,hreg64lo,NR_R0));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(A_OR,
-                   location.registerhigh,location.registerhigh,NR_R0));
+                   location.register64.reghi,location.register64.reghi,NR_R0));
                  exprasmlist.concat(taicpu.op_reg_reg_const(A_SUBI,
                    NR_R0,hregister1,32));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(asmop1,
-                   NR_R0,hregisterlow,NR_R0));
+                   NR_R0,hreg64lo,NR_R0));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(A_OR,
-                   location.registerhigh,location.registerhigh,NR_R0));
+                   location.register64.reghi,location.register64.reghi,NR_R0));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(asmop1,
-                   location.registerlow,hregisterlow,hregister1));
+                   location.register64.reglo,hreg64lo,hregister1));
                  cg.ungetcpuregister(exprasmlist,NR_R0);
 
                  if nodetype = shrn then
                    begin
-                     resultreg := location.registerhigh;
-                     location.registerhigh := location.registerlow;
-                     location.registerlow := resultreg;
+                     resultreg := location.register64.reghi;
+                     location.register64.reghi := location.register64.reglo;
+                     location.register64.reglo := resultreg;
                    end;
                end
            end
@@ -362,18 +362,18 @@ implementation
              location_copy(location,left.location);
              if (location.loc = LOC_CREGISTER) then
                begin
-                 location.registerlow := cg.getintregister(exprasmlist,OS_INT);
-                 location.registerhigh := cg.getintregister(exprasmlist,OS_INT);
+                 location.register64.reglo := cg.getintregister(exprasmlist,OS_INT);
+                 location.register64.reghi := cg.getintregister(exprasmlist,OS_INT);
                  location.loc := LOC_REGISTER;
                end;
              exprasmlist.concat(taicpu.op_reg_reg_const(A_SUBFIC,
-               location.registerlow,left.location.registerlow,0));
+               location.register64.reglo,left.location.register64.reglo,0));
              if not(cs_check_overflow in aktlocalswitches) then
                exprasmlist.concat(taicpu.op_reg_reg(A_SUBFZE,
-                 location.registerhigh,left.location.registerhigh))
+                 location.register64.reghi,left.location.register64.reghi))
              else
                exprasmlist.concat(taicpu.op_reg_reg(A_SUBFZEO_,
-                 location.registerhigh,left.location.registerhigh));
+                 location.register64.reghi,left.location.register64.reghi));
            end
          else
            begin
@@ -495,10 +495,10 @@ implementation
              location_force_reg(exprasmlist,left.location,def_cgsize(left.resulttype.def),false);
              location_copy(location,left.location);
              { perform the NOT operation }
-             exprasmlist.concat(taicpu.op_reg_reg(A_NOT,location.registerhigh,
-               location.registerhigh));
-             exprasmlist.concat(taicpu.op_reg_reg(A_NOT,location.registerlow,
-               location.registerlow));
+             exprasmlist.concat(taicpu.op_reg_reg(A_NOT,location.register64.reghi,
+               location.register64.reghi));
+             exprasmlist.concat(taicpu.op_reg_reg(A_NOT,location.register64.reglo,
+               location.register64.reglo));
            end
          else
            begin
@@ -521,7 +521,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.41  2004-10-25 15:36:47  peter
+  Revision 1.42  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.41  2004/10/25 15:36:47  peter
     * save standard registers moved to tcgobj
 
   Revision 1.40  2004/09/25 14:23:55  peter

+ 7 - 3
compiler/procinfo.pas

@@ -34,7 +34,7 @@ unit procinfo;
       { symtable }
       symconst,symtype,symdef,symsym,
       { aasm }
-      cpubase,cpuinfo,cgbase,
+      cpubase,cpuinfo,cgbase,cgutils,
       aasmbase,aasmtai
       ;
 
@@ -123,7 +123,7 @@ implementation
 
      uses
         cutils,systems,
-        tgobj,cgutils,cgobj,
+        tgobj,cgobj,
         paramgr
         ;
 
@@ -184,7 +184,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.16  2004-06-20 08:55:30  florian
+  Revision 1.17  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.16  2004/06/20 08:55:30  florian
     * logs truncated
 
   Revision 1.15  2004/06/16 20:07:09  florian

+ 13 - 14
compiler/rautils.pas

@@ -28,7 +28,7 @@ Interface
 
 Uses
   cutils,cclasses,
-  globtype,aasmbase,aasmtai,cpubase,cpuinfo,cgbase,
+  globtype,aasmbase,aasmtai,cpubase,cpuinfo,cgbase,cgutils,
   symconst,symbase,symtype,symdef,symsym;
 
 Const
@@ -710,20 +710,15 @@ end;
 Procedure TOperand.SetSize(_size:longint;force:boolean);
 begin
   if force or
-     ((size = OS_NO) and (_size<=extended_size)) then
+     ((size = OS_NO) and (_size<=16)) then
    Begin
      case _size of
-      1 : size:=OS_8;
-      2 : size:=OS_16{ could be S_IS};
-      4 : size:=OS_32{ could be S_IL or S_FS};
-      8 : size:=OS_64{ could be S_D or S_FL};
-     else
-      begin
-        { extended_size can also be 8, resulting in a
-          duplicate label }
-        if _size=extended_size then
-          size:=OS_F80;
-      end;
+        1 : size:=OS_8;
+        2 : size:=OS_16{ could be S_IS};
+        4 : size:=OS_32{ could be S_IL or S_FS};
+        8 : size:=OS_64{ could be S_D or S_FL};
+       10 : size:=OS_F80;
+       16 : size:=OS_128;
      end;
    end;
 end;
@@ -1664,7 +1659,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.92  2004-10-24 11:44:28  peter
+  Revision 1.93  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.92  2004/10/24 11:44:28  peter
     * small regvar fixes
     * loadref parameter removed from concatcopy,incrrefcount,etc
 

+ 6 - 6
compiler/rgobj.pas

@@ -33,7 +33,7 @@ unit rgobj;
     uses
       cutils, cpubase,
       aasmbase,aasmtai,aasmcpu,
-      cclasses,globtype,cgbase,node,
+      cclasses,globtype,cgbase,cgutils,
       cpuinfo
       ;
 
@@ -518,7 +518,6 @@ unit rgobj;
       var
         spillingcounter:byte;
         endspill:boolean;
-        i:Tsuperregister;
       begin
         { Insert regalloc info for imaginary registers }
         insert_regalloc_info_all(list);
@@ -789,9 +788,6 @@ unit rgobj;
 
 
     procedure trgobj.prepare_colouring;
-
-    var i:word;
-
     begin
       make_work_list;
       active_moves:=Tlinkedlist.create;
@@ -1997,7 +1993,11 @@ unit rgobj;
 end.
 {
   $Log$
-  Revision 1.146  2004-10-31 16:04:30  florian
+  Revision 1.147  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.146  2004/10/31 16:04:30  florian
     * fixed compilation of system unit on arm
 
   Revision 1.145  2004/10/30 15:21:37  florian

+ 7 - 3
compiler/scanner.pas

@@ -1680,7 +1680,7 @@ implementation
         oldaktfilepos:=aktfilepos;
         repeat
           current_scanner.gettokenpos;
-          p.proc;
+          p.proc();
           { accept the text ? }
           if (current_scanner.preprocstack=nil) or current_scanner.preprocstack.accept then
            break
@@ -1777,7 +1777,7 @@ implementation
                else
                 begin
                   Message1(scan_d_handling_switch,'$'+hs);
-                  t.proc;
+                  t.proc();
                 end;
              end
             else
@@ -3290,7 +3290,11 @@ exit_label:
 end.
 {
   $Log$
-  Revision 1.94  2004-10-31 18:54:25  peter
+  Revision 1.95  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.94  2004/10/31 18:54:25  peter
     * $fpctarget expands to <cpu>-<os>
     * allow * in middle of the path to support ../*/units/$fpctarget
 

+ 6 - 2
compiler/sparc/aasmcpu.pas

@@ -30,7 +30,7 @@ uses
   cclasses,
   globtype,globals,verbose,
   aasmbase,aasmtai,
-  cgbase,cpubase,cpuinfo;
+  cgbase,cgutils,cpubase,cpuinfo;
 
     const
       { "mov reg,reg" source operand number }
@@ -313,7 +313,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.51  2004-10-30 15:21:38  florian
+  Revision 1.52  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.51  2004/10/30 15:21:38  florian
     * fixed generic optimizer
     * enabled generic optimizer for sparc
 

+ 7 - 3
compiler/sparc/cgcpu.pas

@@ -28,7 +28,7 @@ interface
 
     uses
        globtype,parabase,
-       cgbase,cgobj,cg64f32,
+       cgbase,cgutils,cgobj,cg64f32,
        aasmbase,aasmtai,aasmcpu,
        cpubase,cpuinfo,
        node,symconst,SymType,
@@ -120,7 +120,7 @@ implementation
   uses
     globals,verbose,systems,cutils,
     symdef,paramgr,
-    tgobj,cpupi,cgutils;
+    tgobj,cpupi;
 
 
 {****************************************************************************
@@ -1245,7 +1245,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.97  2004-10-24 20:01:08  peter
+  Revision 1.98  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.97  2004/10/24 20:01:08  peter
     * remove saveregister calling convention
 
   Revision 1.96  2004/10/24 11:53:45  peter

+ 11 - 74
compiler/sparc/cpubase.pas

@@ -157,72 +157,11 @@ uses
         F_FLE  {Less or Equal}
       );
 
-{*****************************************************************************
-                                Reference
-*****************************************************************************}
-
-    type
-      { reference record }
-      preference = ^treference;
-      treference = record
-         { base register, R_NO if none }
-         base,
-         { index register, R_NO if none }
-         index       : tregister;
-         { offset, 0 if none }
-         offset      : aint;
-         { symbol this reference refers to, nil if none }
-         symbol      : tasmsymbol;
-         { symbol the symbol of this reference is relative to, nil if none }
-         relsymbol   : tasmsymbol;
-         { reference type addr or symbol itself }
-         refaddr     : trefaddr;
-      end;
-
-      { reference record }
-      pparareference = ^tparareference;
-      tparareference = packed record
-         index       : tregister;
-         offset      : aint;
-      end;
-
 {*****************************************************************************
                                 Operand Sizes
 *****************************************************************************}
 
 
-{*****************************************************************************
-                               Generic Location
-*****************************************************************************}
-
-    type
-      TLocation = record
-         size : TCGSize;
-         loc : tcgloc;
-         case tcgloc of
-            LOC_CREFERENCE,LOC_REFERENCE : (reference : treference);
-            LOC_CONSTANT : (
-              case longint of
-{$ifdef FPC_BIG_ENDIAN}
-                1 : (_valuedummy,value : Aint);
-{$else FPC_BIG_ENDIAN}
-                1 : (value : Aint);
-{$endif FPC_BIG_ENDIAN}
-                2 : (value64 : int64);
-              );
-            LOC_FPUREGISTER,LOC_CFPUREGISTER,
-            LOC_MMREGISTER,LOC_CMMREGISTER,
-            LOC_REGISTER,LOC_CREGISTER : (
-                case longint of
-                  1 : (registerlow,registerhigh : tregister);
-                  2 : (register : tregister);
-                  { overlay a 64 Bit register type }
-                  3 : (reg64 : tregister64);
-                  4 : (register64 : tregister64);
-                );
-            LOC_FLAGS : (resflags : tresflags);
-      end;
-
 {*****************************************************************************
                                  Constants
 *****************************************************************************}
@@ -381,6 +320,12 @@ uses
       }
       std_param_align = 4;  { for 32-bit version only }
 
+     { size of the buffer used for setjump/longjmp
+       the size of this buffer is deduced from the
+       jmp_buf structure in setjumph.inc file }
+     JMP_BUF_SIZE = 12+16;
+
+
 {*****************************************************************************
                             CPU Dependent Constants
 *****************************************************************************}
@@ -393,7 +338,6 @@ uses
                                   Helpers
 *****************************************************************************}
 
-    function RefsEqual(Const r1,r2: TReference) : Boolean;
     function  is_calljmp(o:tasmop):boolean;
 
     procedure inverse_flags(var f: TResFlags);
@@ -428,17 +372,6 @@ implementation
                                   Helpers
 *****************************************************************************}
 
-    function RefsEqual(Const r1,r2: TReference) : Boolean;
-      begin
-        RefsEqual := (r1.Offset=r2.Offset) and
-                     (r1.Base=r2.Base) and
-                     (r1.Index=r2.Index) and
-                     (r1.symbol=r2.symbol) and
-                     (r1.relsymbol=r2.relsymbol) and
-                     (r1.refaddr=r2.refaddr);
-      end;
-
-
     function is_calljmp(o:tasmop):boolean;
       const
         CallJmpOp=[A_JMPL..A_CBccc];
@@ -521,7 +454,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.74  2004-10-30 15:21:38  florian
+  Revision 1.75  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.74  2004/10/30 15:21:38  florian
     * fixed generic optimizer
     * enabled generic optimizer for sparc
 

+ 6 - 2
compiler/sparc/cpugas.pas

@@ -39,7 +39,7 @@ implementation
 
     uses
       cutils,systems,
-      verbose,itcpugas,cgbase;
+      verbose,itcpugas,cgbase,cgutils;
 
 
     function GetReferenceString(var ref:TReference):string;
@@ -189,7 +189,11 @@ begin
 end.
 {
     $Log$
-    Revision 1.29  2004-10-03 12:42:22  florian
+    Revision 1.30  2004-10-31 21:45:04  peter
+      * generic tlocation
+      * move tlocation to cgutils
+
+    Revision 1.29  2004/10/03 12:42:22  florian
       * made sqrt, sqr and abs internal for the sparc
 
     Revision 1.28  2004/06/20 08:55:32  florian

+ 5 - 13
compiler/sparc/cpuinfo.pas

@@ -45,18 +45,6 @@ type
 
 
 const
-{# Size of native extended floating point type }
-{SPARC architecture uses IEEE double floating point numbers}
-  extended_size = 8;
-{# Size of a multimedia register               }
-  mmreg_size = 8;
-{ target cpu string (used by compiler options) }
-  target_cpu_string = 'sparc';
-{ size of the buffer used for setjump/longjmp
-  the size of this buffer is deduced from the
-  jmp_buf structure in setjumph.inc file }
-  JMP_BUF_SIZE = 12+16;
-
   { calling conventions supported by the code generator }
   supported_calling_conventions : tproccalloptions = [
     pocall_internproc,
@@ -83,7 +71,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.19  2004-09-21 17:25:13  peter
+  Revision 1.20  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.19  2004/09/21 17:25:13  peter
     * paraloc branch merged
 
   Revision 1.18.4.1  2004/09/12 12:04:41  peter

+ 6 - 2
compiler/sparc/ncpuadd.pas

@@ -50,7 +50,7 @@ interface
       cutils,verbose,
       paramgr,
       aasmtai,aasmcpu,defutil,
-      cgbase,cgcpu,
+      cgbase,cgcpu,cgutils,
       cpupara,
       ncon,nset,nadd,
       ncgutil,cgobj;
@@ -377,7 +377,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.27  2004-09-25 14:23:55  peter
+  Revision 1.28  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.27  2004/09/25 14:23:55  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 10 - 6
compiler/sparc/ncpuinln.pas

@@ -45,14 +45,14 @@ interface
 implementation
 
     uses
-      globtype,systems,
-      cutils,verbose,globals,fmodule,
+      systems,
+      cutils,verbose,
       symconst,symdef,
-      aasmbase,aasmtai,aasmcpu,
-      cgbase,pass_1,pass_2,
+      aasmtai,aasmcpu,
+      cgbase,pass_2,
       cpubase,paramgr,
       nbas,ncon,ncal,ncnv,nld,
-      tgobj,ncgutil,cgobj,cg64f32,rgobj,rgcpu;
+      ncgutil,cgobj,cgutils;
 
 {*****************************************************************************
                               tsparcinlinenode
@@ -150,7 +150,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.10  2004-10-03 12:42:22  florian
+  Revision 1.11  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.10  2004/10/03 12:42:22  florian
     * made sqrt, sqr and abs internal for the sparc
 
   Revision 1.9  2004/06/20 08:55:32  florian

+ 25 - 21
compiler/sparc/ncpumat.pas

@@ -55,7 +55,7 @@ implementation
       cgbase,cgobj,pass_2,
       ncon,
       cpubase,
-      ncgutil,cgcpu;
+      ncgutil,cgcpu,cgutils;
 
 {*****************************************************************************
                              TSparcMODDIVNODE
@@ -178,7 +178,7 @@ implementation
     procedure tSparcshlshrnode.pass_2;
       var
         hregister,resultreg,hregister1,
-        hregisterhigh,hregisterlow : tregister;
+        hreg64hi,hreg64lo : tregister;
         op : topcg;
         shiftval: aword;
       begin
@@ -196,46 +196,46 @@ implementation
 
             { load left operator in a register }
             location_force_reg(exprasmlist,left.location,OS_64,false);
-            hregisterhigh:=left.location.registerhigh;
-            hregisterlow:=left.location.registerlow;
+            hreg64hi:=left.location.register64.reghi;
+            hreg64lo:=left.location.register64.reglo;
 
             shiftval := tordconstnode(right).value and 63;
             if shiftval > 31 then
               begin
                 if nodetype = shln then
                   begin
-                    cg.a_load_const_reg(exprasmlist,OS_32,0,hregisterhigh);
+                    cg.a_load_const_reg(exprasmlist,OS_32,0,hreg64hi);
                     if (shiftval and 31) <> 0 then
-                      cg.a_op_const_reg_reg(exprasmlist,OP_SHL,OS_32,shiftval and 31,hregisterlow,hregisterlow);
+                      cg.a_op_const_reg_reg(exprasmlist,OP_SHL,OS_32,shiftval and 31,hreg64lo,hreg64lo);
                   end
                 else
                   begin
-                    cg.a_load_const_reg(exprasmlist,OS_32,0,hregisterlow);
+                    cg.a_load_const_reg(exprasmlist,OS_32,0,hreg64lo);
                     if (shiftval and 31) <> 0 then
-                      cg.a_op_const_reg_reg(exprasmlist,OP_SHR,OS_32,shiftval and 31,hregisterhigh,hregisterhigh);
+                      cg.a_op_const_reg_reg(exprasmlist,OP_SHR,OS_32,shiftval and 31,hreg64hi,hreg64hi);
                   end;
-                location.registerlow:=hregisterhigh;
-                location.registerhigh:=hregisterlow;
+                location.register64.reglo:=hreg64hi;
+                location.register64.reghi:=hreg64lo;
               end
             else
               begin
                 hregister:=cg.getintregister(exprasmlist,OS_32);
                 if nodetype = shln then
                   begin
-                    cg.a_op_const_reg_reg(exprasmlist,OP_SHR,OS_32,32-shiftval,hregisterlow,hregister);
-                    cg.a_op_const_reg_reg(exprasmlist,OP_SHL,OS_32,shiftval,hregisterhigh,hregisterhigh);
-                    cg.a_op_reg_reg_reg(exprasmlist,OP_OR,OS_32,hregister,hregisterhigh,hregisterhigh);
-                    cg.a_op_const_reg_reg(exprasmlist,OP_SHL,OS_32,shiftval,hregisterlow,hregisterlow);
+                    cg.a_op_const_reg_reg(exprasmlist,OP_SHR,OS_32,32-shiftval,hreg64lo,hregister);
+                    cg.a_op_const_reg_reg(exprasmlist,OP_SHL,OS_32,shiftval,hreg64hi,hreg64hi);
+                    cg.a_op_reg_reg_reg(exprasmlist,OP_OR,OS_32,hregister,hreg64hi,hreg64hi);
+                    cg.a_op_const_reg_reg(exprasmlist,OP_SHL,OS_32,shiftval,hreg64lo,hreg64lo);
                   end
                 else
                   begin
-                    cg.a_op_const_reg_reg(exprasmlist,OP_SHL,OS_32,32-shiftval,hregisterhigh,hregister);
-                    cg.a_op_const_reg_reg(exprasmlist,OP_SHR,OS_32,shiftval,hregisterlow,hregisterlow);
-                    cg.a_op_reg_reg_reg(exprasmlist,OP_OR,OS_32,hregister,hregisterlow,hregisterlow);
-                    cg.a_op_const_reg_reg(exprasmlist,OP_SHR,OS_32,shiftval,hregisterhigh,hregisterhigh);
+                    cg.a_op_const_reg_reg(exprasmlist,OP_SHL,OS_32,32-shiftval,hreg64hi,hregister);
+                    cg.a_op_const_reg_reg(exprasmlist,OP_SHR,OS_32,shiftval,hreg64lo,hreg64lo);
+                    cg.a_op_reg_reg_reg(exprasmlist,OP_OR,OS_32,hregister,hreg64lo,hreg64lo);
+                    cg.a_op_const_reg_reg(exprasmlist,OP_SHR,OS_32,shiftval,hreg64hi,hreg64hi);
                   end;
-                location.registerhigh:=hregisterhigh;
-                location.registerlow:=hregisterlow;
+                location.register64.reghi:=hreg64hi;
+                location.register64.reglo:=hreg64lo;
               end;
           end
         else
@@ -325,7 +325,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.21  2004-09-25 14:23:55  peter
+  Revision 1.22  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.21  2004/09/25 14:23:55  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 8 - 4
compiler/sparc/rgcpu.pas

@@ -28,7 +28,7 @@ unit rgcpu;
 
     uses
       aasmbase,aasmcpu,aasmtai,
-      cgbase,
+      cgbase,cgutils,
       cpubase,
       rgobj;
 
@@ -44,8 +44,8 @@ unit rgcpu;
 implementation
 
     uses
-      verbose, cutils,
-      cgutils,cgobj;
+      verbose,cutils,
+      cgobj;
 
     procedure trgcpu.add_constraints(reg:tregister);
       var
@@ -164,7 +164,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.30  2004-10-05 21:29:29  florian
+  Revision 1.31  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.30  2004/10/05 21:29:29  florian
     * fixed generation of refs wiht large offsets, code still broken though
 
   Revision 1.29  2004/10/05 20:41:02  peter

+ 6 - 2
compiler/symdef.pas

@@ -2092,7 +2092,7 @@ implementation
       begin
          case typ of
            s32real : savesize:=4;
-           s80real : savesize:=extended_size;
+           s80real : savesize:=10;
            s64real,
            s64currency,
            s64comp : savesize:=8;
@@ -6200,7 +6200,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.260  2004-10-26 15:02:33  peter
+  Revision 1.261  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.260  2004/10/26 15:02:33  peter
     * align arraydef rtti
 
   Revision 1.259  2004/10/15 09:14:17  mazen

+ 8 - 4
compiler/symsym.pas

@@ -37,7 +37,7 @@ interface
        cclasses,symnot,
        { aasm }
        aasmbase,
-       cpuinfo,cpubase,cgbase,parabase
+       cpuinfo,cpubase,cgbase,cgutils,parabase
        ;
 
     type
@@ -305,7 +305,7 @@ interface
 implementation
 
     uses
-       strings,
+//       strings,
        { global }
        verbose,
        { target }
@@ -315,7 +315,7 @@ implementation
        { tree }
        node,
        { aasm }
-       aasmcpu,
+//       aasmcpu,
        { codegen }
        paramgr,cresstr,
        procinfo
@@ -2251,7 +2251,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.188  2004-10-15 09:14:17  mazen
+  Revision 1.189  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.188  2004/10/15 09:14:17  mazen
   - remove $IFDEF DELPHI and related code
   - remove $IFDEF FPCPROCVAR and related code
 

+ 6 - 4
compiler/symutil.pas

@@ -41,9 +41,7 @@ interface
 implementation
 
     uses
-       globtype,
-       cpuinfo,
-       procinfo,
+       globtype,cpuinfo,procinfo,
        symconst;
 
 
@@ -116,7 +114,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.5  2004-06-20 08:55:30  florian
+  Revision 1.6  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.5  2004/06/20 08:55:30  florian
     * logs truncated
 
   Revision 1.4  2004/03/23 22:34:50  peter

+ 21 - 5
compiler/tgobj.pas

@@ -36,12 +36,10 @@ unit tgobj;
       cclasses,
       globals,globtype,
       symtype,
-      cpubase,cpuinfo,cgbase,
+      cpubase,cpuinfo,cgbase,cgutils,
       aasmbase,aasmtai;
 
     type
-      ttemptypeset = set of ttemptype;
-
       ptemprecord = ^ttemprecord;
       ttemprecord = record
          temptype   : ttemptype;
@@ -110,8 +108,10 @@ unit tgobj;
      var
        tg: ttgobj;
 
+    procedure location_freetemp(list:taasmoutput; const l : tlocation);
+
 
-    implementation
+implementation
 
     uses
        cutils,
@@ -138,6 +138,18 @@ unit tgobj;
       );
 
 
+{*****************************************************************************
+                                    Helpers
+*****************************************************************************}
+
+    procedure location_freetemp(list:taasmoutput; const l : tlocation);
+      begin
+        if (l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
+         tg.ungetiftemp(list,l.reference);
+      end;
+
+
+
 {*****************************************************************************
                                     TTGOBJ
 *****************************************************************************}
@@ -611,7 +623,11 @@ unit tgobj;
 end.
 {
   $Log$
-  Revision 1.48  2004-09-21 17:25:12  peter
+  Revision 1.49  2004-10-31 21:45:03  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.48  2004/09/21 17:25:12  peter
     * paraloc branch merged
 
   Revision 1.47  2004/09/20 15:40:21  peter

+ 12 - 8
compiler/vis/cpubase.pas

@@ -304,9 +304,9 @@ uses
             LOC_FPUREGISTER, LOC_CFPUREGISTER, LOC_MMREGISTER, LOC_CMMREGISTER,
               LOC_REGISTER,LOC_CREGISTER : (
               case longint of
-                1 : (register,registerhigh : tregister);
-                { overlay a registerlow }
-                2 : (registerlow : tregister);
+                1 : (register,register64.reghi : tregister);
+                { overlay a register64.reglo }
+                2 : (register64.reglo : tregister);
                 { overlay a 64 Bit register type }
                 3 : (reg64 : tregister64);
                 4 : (register64 : tregister64);
@@ -315,9 +315,9 @@ uses
 
       treglocation = packed record
         case longint of
-          1 : (register,registerhigh : tregister);
-          { overlay a registerlow }
-          2 : (registerlow : tregister);
+          1 : (register,register64.reghi : tregister);
+          { overlay a register64.reglo }
+          2 : (register64.reglo : tregister);
           { overlay a 64 Bit register type }
           3 : (reg64 : tregister64);
           4 : (register64 : tregister64);
@@ -341,7 +341,7 @@ uses
             LOC_FPUREGISTER, LOC_CFPUREGISTER, LOC_MMREGISTER, LOC_CMMREGISTER,
               LOC_REGISTER,LOC_CREGISTER : (
                 case longint of
-                  1 : (registerlow,registerhigh : tregister);
+                  1 : (register64.reglo,register64.reghi : tregister);
                   2 : (register : tregister);
                   { overlay a 64 Bit register type }
                   3 : (reg64 : tregister64);
@@ -644,7 +644,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.6  2004-06-20 08:55:32  florian
+  Revision 1.7  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.6  2004/06/20 08:55:32  florian
     * logs truncated
 
 }

+ 10 - 5
compiler/x86/aasmcpu.pas

@@ -33,8 +33,8 @@ interface
     uses
       cclasses,globtype,globals,verbose,
       cpuinfo,cpubase,
-      cgbase,
-      symtype,symsym,
+      cgbase,cgutils,
+      symtype,
       aasmbase,aasmtai;
 
     const
@@ -134,7 +134,7 @@ interface
 
     type
       { What an instruction can change. Needed for optimizer and spilling code.
-      
+
         Note: The order of this enumeration is should not be changed! }
       TInsChange = (Ch_None,
         {Read from a register}
@@ -278,7 +278,8 @@ implementation
 
      uses
        cutils,
-       itcpugas;
+       itcpugas,
+       symsym;
 
 {*****************************************************************************
                               Instruction table
@@ -2110,7 +2111,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.61  2004-10-04 21:11:24  peter
+  Revision 1.62  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.61  2004/10/04 21:11:24  peter
     * reverted a minor move in the order of tinschange. The order
       is required by the optimizer. Added also a remark
 

+ 6 - 3
compiler/x86/agx86att.pas

@@ -30,7 +30,7 @@ interface
 
     uses
       cclasses,cpubase,
-      globals,
+      globals,cgutils,
       aasmbase,aasmtai,assemble,aggas;
 
     type
@@ -50,7 +50,6 @@ interface
       cutils,systems,
       verbose,
       itcpugas,
-      cpuinfo,
       cgbase,
       aasmcpu;
 
@@ -280,7 +279,11 @@ initialization
 end.
 {
   $Log$
-  Revision 1.16  2004-06-29 21:00:08  peter
+  Revision 1.17  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.16  2004/06/29 21:00:08  peter
     * only enable dwarf for supported platforms
 
   Revision 1.15  2004/06/20 08:55:32  florian

+ 6 - 2
compiler/x86/cga.pas

@@ -29,7 +29,7 @@ interface
 
     uses
        globtype,
-       cpuinfo,cpubase,cgbase,
+       cpuinfo,cpubase,cgbase,cgutils,
        symconst,symtype,symdef,aasmbase,aasmtai,aasmcpu;
 
     procedure emit_none(i : tasmop;s : topsize);
@@ -129,7 +129,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.9  2004-06-20 08:55:32  florian
+  Revision 1.10  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.9  2004/06/20 08:55:32  florian
     * logs truncated
 
   Revision 1.8  2004/06/16 20:07:11  florian

+ 6 - 3
compiler/x86/cgx86.pas

@@ -30,7 +30,7 @@ unit cgx86;
 
     uses
        globtype,
-       cgbase,cgobj,
+       cgbase,cgutils,cgobj,
        aasmbase,aasmtai,aasmcpu,
        cpubase,cpuinfo,rgobj,rgx86,rgcpu,
        symconst,symtype;
@@ -150,7 +150,6 @@ unit cgx86;
 
     uses
        globals,verbose,systems,cutils,
-       cgutils,
        dwarf,
        symdef,defutil,paramgr,tgobj,procinfo;
 
@@ -1627,7 +1626,11 @@ unit cgx86;
 end.
 {
   $Log$
-  Revision 1.132  2004-10-25 15:36:47  peter
+  Revision 1.133  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.132  2004/10/25 15:36:47  peter
     * save standard registers moved to tcgobj
 
   Revision 1.131  2004/10/24 20:10:08  peter

+ 6 - 93
compiler/x86/cpubase.pas

@@ -36,9 +36,7 @@ interface
 
 uses
   cutils,cclasses,
-  globtype,globals,
-  cpuinfo,
-  aasmbase,
+  globtype,
   cgbase
   ;
 
@@ -226,95 +224,6 @@ uses
                    F_A,F_AE,F_B,F_BE,
                    F_S,F_NS,F_O,F_NO);
 
-{*****************************************************************************
-                                Reference
-*****************************************************************************}
-
-    type
-      { reference record, reordered for best alignment }
-      preference = ^treference;
-      treference = record
-         offset      : aint;
-         symbol,
-         relsymbol   : tasmsymbol;
-         segment,
-         base,
-         index       : tregister;
-         refaddr     : trefaddr;
-         scalefactor : byte;
-      end;
-
-      { reference record }
-      pparareference = ^tparareference;
-      tparareference = packed record
-         index       : tregister;
-         offset      : aint;
-      end;
-
-{*****************************************************************************
-                               Generic Location
-*****************************************************************************}
-
-    type
-      { tparamlocation describes where a parameter for a procedure is stored.
-        References are given from the caller's point of view. The usual
-        TLocation isn't used, because contains a lot of unnessary fields.
-      }
-      tparalocation = record
-         size : TCGSize;
-         loc  : TCGLoc;
-         { Location type of registerhigh, for x86_64 this can
-           be different from loc when pushing structures of 16 bytes }
-         lochigh : TCGLoc;
-         alignment : byte;
-         case TCGLoc of
-            LOC_REFERENCE : (reference : tparareference);
-            { segment in reference at the same place as in loc_register }
-            LOC_REGISTER,LOC_CREGISTER : (
-              case longint of
-                1 : (register,registerhigh : tregister);
-                { overlay a registerlow }
-                2 : (registerlow : tregister);
-{$ifndef cpu64bit}
-                { overlay a 64 Bit register type }
-                3 : (register64 : tregister64);
-{$endif cpu64bit}
-              );
-            { it's only for better handling }
-            LOC_MMXREGISTER,LOC_CMMXREGISTER : (
-              case longint of
-              0: (mmxreg : tregister);
-              1: (mmxregset : Tregistermmxset);
-            );
-      end;
-
-      tlocation = packed record
-         loc  : TCGLoc;
-         size : TCGSize;
-         case TCGLoc of
-            LOC_FLAGS : (resflags : tresflags);
-            LOC_CONSTANT : (
-              case longint of
-                1 : (value : AInt);
-                { can't do this, this layout depends on the host cpu. Use }
-                { lo(valueqword)/hi(valueqword) instead (JM)              }
-                { overlay a complete 64 Bit value }
-                2 : (value64 : Int64);
-              );
-            LOC_CREFERENCE,
-            LOC_REFERENCE : (reference : treference);
-            { segment in reference at the same place as in loc_register }
-            LOC_REGISTER,LOC_CREGISTER : (
-              case longint of
-                1 : (register,registerhigh,segment : tregister);
-                { overlay a registerlow }
-                2 : (registerlow : tregister);
-                { overlay a 64 Bit register type }
-                3 : (register64 : tregister64);
-              );
-            { it's only for better handling }
-            LOC_MMXREGISTER,LOC_CMMXREGISTER : (mmxreg : tregister);
-      end;
 
 {*****************************************************************************
                                  Constants
@@ -539,7 +448,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.48  2004-10-25 15:36:47  peter
+  Revision 1.49  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.48  2004/10/25 15:36:47  peter
     * save standard registers moved to tcgobj
 
   Revision 1.47  2004/10/15 09:22:23  mazen

+ 7 - 3
compiler/x86/nx86add.pas

@@ -67,9 +67,9 @@ unit nx86add;
       cpuinfo,
       aasmbase,aasmtai,aasmcpu,
       symconst,symdef,
-      cgobj,cgx86,cga,
+      cgobj,cgx86,cga,cgutils,
       paramgr,parabase,
-      htypechk,
+      htypechk,tgobj,
       pass_2,ncgutil,
       ncon,nset,
       defutil;
@@ -906,7 +906,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.13  2004-09-25 14:23:55  peter
+  Revision 1.14  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.13  2004/09/25 14:23:55  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 8 - 4
compiler/x86/nx86cnv.pas

@@ -59,7 +59,7 @@ interface
 implementation
 
    uses
-      verbose,systems,globals,
+      verbose,systems,globals,globtype,
       aasmbase,aasmtai,aasmcpu,
       symconst,symdef,
       cgbase,cga,pass_2,
@@ -152,8 +152,8 @@ implementation
                 if left.location.size in [OS_64,OS_S64] then
                  begin
                    hregister:=cg.getintregister(exprasmlist,OS_32);
-                   cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,left.location.registerlow,hregister);
-                   cg.a_op_reg_reg(exprasmlist,OP_OR,OS_32,left.location.registerhigh,hregister);
+                   cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,left.location.register64.reglo,hregister);
+                   cg.a_op_reg_reg(exprasmlist,OP_OR,OS_32,left.location.register64.reghi,hregister);
                  end
                 else
 {$endif cpu64bit}
@@ -292,7 +292,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.16  2004-09-30 19:32:19  hajny
+  Revision 1.17  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.16  2004/09/30 19:32:19  hajny
     * explicit typecast added to avoid range check error
 
   Revision 1.15  2004/09/26 09:12:50  florian

+ 6 - 2
compiler/x86/nx86inl.pas

@@ -63,7 +63,7 @@ implementation
 
     uses
       systems,
-      globtype,globals,
+      globals,
       cutils,verbose,
       defutil,
       aasmtai,aasmcpu,
@@ -344,7 +344,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.6  2004-09-25 14:23:55  peter
+  Revision 1.7  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.6  2004/09/25 14:23:55  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 9 - 5
compiler/x86/nx86mat.pas

@@ -48,13 +48,13 @@ interface
   implementation
 
     uses
-      globtype,systems,
+      systems,
       cutils,verbose,globals,
-      symconst,symdef,aasmbase,aasmtai,defutil,
+      symconst,aasmbase,aasmtai,defutil,
       cgbase,pass_1,pass_2,
       ncon,
-      cpubase,cpuinfo,
-      cga,ncgutil,cgobj,cgx86;
+      cpubase,
+      cga,ncgutil,cgobj,cgx86,cgutils;
 
 
 {*****************************************************************************
@@ -304,7 +304,11 @@ end.
 
 {
   $Log$
-  Revision 1.6  2004-09-25 14:23:55  peter
+  Revision 1.7  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.6  2004/09/25 14:23:55  peter
     * ungetregister is now only used for cpuregisters, renamed to
       ungetcpuregister
     * renamed (get|unget)explicitregister(s) to ..cpuregister

+ 7 - 3
compiler/x86/nx86set.pas

@@ -44,10 +44,10 @@ implementation
       verbose,globals,
       symconst,symdef,defutil,
       aasmbase,aasmtai,aasmcpu,
-      cgbase,pass_2,
+      cgbase,pass_2,tgobj,
       ncon,
       cpubase,
-      cga,cgobj,ncgutil,
+      cga,cgobj,cgutils,ncgutil,
       cgx86;
 
 {*****************************************************************************
@@ -463,7 +463,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.7  2004-10-24 20:10:08  peter
+  Revision 1.8  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.7  2004/10/24 20:10:08  peter
     * -Or fixes
 
   Revision 1.6  2004/10/01 17:32:16  peter

+ 6 - 2
compiler/x86/rax86.pas

@@ -84,7 +84,7 @@ implementation
 
 uses
   globtype,globals,systems,verbose,
-  cpuinfo,cgbase,
+  cpuinfo,cgbase,cgutils,
   itcpugas,cgx86;
 
 {$define ATTOP}
@@ -742,7 +742,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.19  2004-06-20 08:55:32  florian
+  Revision 1.20  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.19  2004/06/20 08:55:32  florian
     * logs truncated
 
   Revision 1.18  2004/06/16 20:07:11  florian

+ 7 - 3
compiler/x86/rax86att.pas

@@ -51,9 +51,9 @@ Implementation
       globtype,globals,verbose,
       systems,
       { aasm }
-      cpuinfo,aasmbase,aasmtai,aasmcpu,
+      aasmbase,aasmtai,aasmcpu,
       { symtable }
-      symconst,symbase,symtype,symsym,symtable,
+      symconst,symsym,
       { parser }
       scanner,
       procinfo,
@@ -788,7 +788,11 @@ Implementation
 end.
 {
   $Log$
-  Revision 1.5  2004-06-20 08:55:32  florian
+  Revision 1.6  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.5  2004/06/20 08:55:32  florian
     * logs truncated
 
   Revision 1.4  2004/06/16 20:07:11  florian

+ 8 - 4
compiler/x86/rgx86.pas

@@ -29,10 +29,10 @@ unit rgx86;
   interface
 
     uses
-      cpubase,
-      cpuinfo,
+      cclasses,globtype,
+      cpubase,cpuinfo,cgbase,cgutils,
       aasmbase,aasmtai,aasmcpu,
-      cclasses,globtype,cgbase,rgobj;
+      rgobj;
 
     type
        trgx86 = class(trgobj)
@@ -315,7 +315,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.9  2004-10-10 16:30:26  peter
+  Revision 1.10  2004-10-31 21:45:04  peter
+    * generic tlocation
+    * move tlocation to cgutils
+
+  Revision 1.9  2004/10/10 16:30:26  peter
     * optimized spilling writing when the reg operand can be
       replaced by reference