Browse Source

* NEWRA branch merged

peter 22 years ago
parent
commit
6a8d5eb25d
100 changed files with 4659 additions and 6946 deletions
  1. 311 35
      compiler/aasmtai.pas
  2. 15 13
      compiler/aggas.pas
  3. 13 2
      compiler/assemble.pas
  4. 24 91
      compiler/cg64f32.pas
  5. 14 7
      compiler/cgbase.pas
  6. 165 1
      compiler/cginfo.pas
  7. 44 458
      compiler/cgobj.pas
  8. 22 16
      compiler/cutils.pas
  9. 22 16
      compiler/fpcdefs.inc
  10. 4 3
      compiler/globtype.pas
  11. 40 145
      compiler/i386/ag386int.pas
  12. 37 58
      compiler/i386/ag386nsm.pas
  13. 11 5
      compiler/i386/cgcpu.pas
  14. 25 53
      compiler/i386/cpubase.inc
  15. 17 15
      compiler/i386/cpupara.pas
  16. 8 2
      compiler/i386/cpupi.pas
  17. 31 208
      compiler/i386/n386add.pas
  18. 12 33
      compiler/i386/n386cal.pas
  19. 25 42
      compiler/i386/n386cnv.pas
  20. 9 3
      compiler/i386/n386con.pas
  21. 41 56
      compiler/i386/n386inl.pas
  22. 69 584
      compiler/i386/n386mat.pas
  23. 16 19
      compiler/i386/n386mem.pas
  24. 20 33
      compiler/i386/n386obj.pas
  25. 18 53
      compiler/i386/n386set.pas
  26. 72 0
      compiler/i386/r386ari.inc
  27. 72 0
      compiler/i386/r386att.inc
  28. 72 0
      compiler/i386/r386con.inc
  29. 72 0
      compiler/i386/r386int.inc
  30. 72 0
      compiler/i386/r386iri.inc
  31. 72 0
      compiler/i386/r386nasm.inc
  32. 2 0
      compiler/i386/r386nor.inc
  33. 72 0
      compiler/i386/r386nri.inc
  34. 72 0
      compiler/i386/r386num.inc
  35. 72 0
      compiler/i386/r386op.inc
  36. 72 0
      compiler/i386/r386ot.inc
  37. 72 0
      compiler/i386/r386rni.inc
  38. 72 0
      compiler/i386/r386sri.inc
  39. 72 0
      compiler/i386/r386stab.inc
  40. 72 0
      compiler/i386/r386std.inc
  41. 14 29
      compiler/i386/ra386att.pas
  42. 22 37
      compiler/i386/ra386int.pas
  43. 41 291
      compiler/i386/rgcpu.pas
  44. 0 791
      compiler/i386/tgcpu.pas
  45. 46 120
      compiler/nadd.pas
  46. 7 5
      compiler/nbas.pas
  47. 14 138
      compiler/ncal.pas
  48. 12 36
      compiler/ncgadd.pas
  49. 7 8
      compiler/ncgbas.pas
  50. 59 284
      compiler/ncgcal.pas
  51. 5 6
      compiler/ncgcon.pas
  52. 47 166
      compiler/ncgflw.pas
  53. 8 41
      compiler/ncginl.pas
  54. 35 83
      compiler/ncgld.pas
  55. 16 32
      compiler/ncgmat.pas
  56. 11 86
      compiler/ncgmem.pas
  57. 12 7
      compiler/ncgopt.pas
  58. 14 86
      compiler/ncgset.pas
  59. 56 344
      compiler/ncgutil.pas
  60. 4 21
      compiler/ncnv.pas
  61. 9 42
      compiler/ncon.pas
  62. 4 7
      compiler/node.pas
  63. 7 25
      compiler/nset.pas
  64. 21 4
      compiler/options.pas
  65. 11 5
      compiler/paramgr.pas
  66. 18 21
      compiler/pass_2.pas
  67. 7 6
      compiler/powerpc/aasmcpu.pas
  68. 100 327
      compiler/powerpc/cgcpu.pas
  69. 132 0
      compiler/powerpc/ppcreg.dat
  70. 111 0
      compiler/powerpc/rppccon.inc
  71. 111 0
      compiler/powerpc/rppcmot.inc
  72. 111 0
      compiler/powerpc/rppcmri.inc
  73. 2 0
      compiler/powerpc/rppcnor.inc
  74. 111 0
      compiler/powerpc/rppcnum.inc
  75. 111 0
      compiler/powerpc/rppcrni.inc
  76. 111 0
      compiler/powerpc/rppcsri.inc
  77. 111 0
      compiler/powerpc/rppcstab.inc
  78. 111 0
      compiler/powerpc/rppcstd.inc
  79. 24 22
      compiler/pstatmnt.pas
  80. 10 14
      compiler/psub.pas
  81. 5 13
      compiler/ptconst.pas
  82. 7 6
      compiler/rautils.pas
  83. 62 133
      compiler/regvars.pas
  84. 138 435
      compiler/rgobj.pas
  85. 59 268
      compiler/sparc/aasmcpu.pas
  86. 90 251
      compiler/sparc/cgcpu.pas
  87. 210 572
      compiler/sparc/cpubase.pas
  88. 14 8
      compiler/sparc/cpugas.pas
  89. 7 1
      compiler/sparc/cpuinfo.pas
  90. 29 33
      compiler/sparc/cpupara.pas
  91. 8 2
      compiler/sparc/cpupi.pas
  92. 0 63
      compiler/sparc/cpuregs.inc
  93. 13 21
      compiler/sparc/ncpuadd.pas
  94. 10 39
      compiler/sparc/ncpumat.pas
  95. 12 7
      compiler/sparc/radirect.pas
  96. 8 1
      compiler/sparc/rasm.pas
  97. 23 58
      compiler/sparc/rgcpu.pas
  98. 138 0
      compiler/sparc/rspcon.inc
  99. 2 0
      compiler/sparc/rspnor.inc
  100. 138 0
      compiler/sparc/rspnum.inc

+ 311 - 35
compiler/aasmtai.pas

@@ -35,7 +35,7 @@ interface
     uses
     uses
        cutils,cclasses,
        cutils,cclasses,
        globtype,globals,systems,
        globtype,globals,systems,
-       cpuinfo,cpubase,
+       cginfo,cpuinfo,cpubase,
        symppu,
        symppu,
        aasmbase;
        aasmbase;
 
 
@@ -407,7 +407,7 @@ interface
       Taasmoutput=class;
       Taasmoutput=class;
 
 
       Trggetproc=procedure(list:Taasmoutput;position:Tai;subreg:Tsubregister;var result:Tregister) of object;
       Trggetproc=procedure(list:Taasmoutput;position:Tai;subreg:Tsubregister;var result:Tregister) of object;
-      Trgungetproc=procedure(list:Taasmoutput;position:Tai;const r:Tregister) of object;
+      Trgungetproc=procedure(list:Taasmoutput;position:Tai;r:Tregister) of object;
 
 
        { Class template for assembler instructions
        { Class template for assembler instructions
        }
        }
@@ -445,15 +445,19 @@ interface
           procedure clearop(opidx:longint);
           procedure clearop(opidx:longint);
           function is_nop:boolean;virtual;abstract;
           function is_nop:boolean;virtual;abstract;
           function is_move:boolean;virtual;abstract;
           function is_move:boolean;virtual;abstract;
-{$ifdef NEWRA}
           { register allocator }
           { register allocator }
+          function get_insert_pos(p:Tai;huntfor1,huntfor2,huntfor3:Tsuperregister;var unusedregsint:Tsuperregisterset):Tai;
+          procedure forward_allocation(p:Tai;var unusedregsint:Tsuperregisterset);
           function spill_registers(list:Taasmoutput;
           function spill_registers(list:Taasmoutput;
                                    rgget:Trggetproc;
                                    rgget:Trggetproc;
                                    rgunget:Trgungetproc;
                                    rgunget:Trgungetproc;
-                                   r:Tsupregset;
-                                   var unusedregsint:Tsupregset;
-                                   const spilltemplist:Tspill_temp_list):boolean;virtual;abstract;
-{$endif NEWRA}
+                                   r:Tsuperregisterset;
+                                   var unusedregsint:Tsuperregisterset;
+                                   const spilltemplist:Tspill_temp_list):boolean;virtual;
+          function spilling_decode_loadstore(op: tasmop; var counterpart: tasmop; var wasload: boolean): boolean;virtual;abstract;
+          function spilling_create_loadstore(op: tasmop; r:tregister; const ref:treference): tai;virtual;abstract;
+          function spilling_create_load(const ref:treference;r:tregister): tai;virtual;abstract;
+          function spilling_create_store(r:tregister; const ref:treference): tai;virtual;abstract;
        end;
        end;
 
 
        { alignment for operator }
        { alignment for operator }
@@ -1536,8 +1540,6 @@ implementation
 
 
     procedure taicpu_abstract.loadref(opidx:longint;const r:treference);
     procedure taicpu_abstract.loadref(opidx:longint;const r:treference);
       begin
       begin
-        if (r.base.enum=R_NO) or (r.index.enum=R_NO) then
-          internalerror(200308192);
         if opidx>=ops then
         if opidx>=ops then
          ops:=opidx+1;
          ops:=opidx+1;
         with oper[opidx] do
         with oper[opidx] do
@@ -1552,14 +1554,8 @@ implementation
 {$ifdef i386}
 {$ifdef i386}
             { We allow this exception for i386, since overloading this would be
             { We allow this exception for i386, since overloading this would be
               too much of a a speed penalty}
               too much of a a speed penalty}
-            if ref^.segment.enum=R_INTREGISTER then
-              begin
-                if (ref^.segment.number <> NR_NO) and (ref^.segment.number <> NR_DS) then
-                  segprefix:=ref^.segment;
-              end
-            else
-              if not(ref^.segment.enum in [R_DS,R_NO]) then
-                segprefix:=ref^.segment;
+            if (ref^.segment<>NR_NO) and (ref^.segment<>NR_DS) then
+              segprefix:=ref^.segment;
 {$endif}
 {$endif}
             typ:=top_ref;
             typ:=top_ref;
             { mark symbol as used }
             { mark symbol as used }
@@ -1621,6 +1617,269 @@ implementation
       end;
       end;
 
 
 
 
+{ ---------------------------------------------------------------------
+    Register allocator methods.
+  ---------------------------------------------------------------------}
+
+    function taicpu_abstract.get_insert_pos(p:Tai;huntfor1,huntfor2,huntfor3:Tsuperregister;var unusedregsint:Tsuperregisterset):Tai;
+      var
+        back   : Tsuperregisterset;
+        supreg : tsuperregister;
+      begin
+        back:=unusedregsint;
+        get_insert_pos:=p;
+        while (p<>nil) and (p.typ=ait_regalloc) do
+          begin
+            supreg:=getsupreg(Tai_regalloc(p).reg);
+            {Rewind the register allocation.}
+            if Tai_regalloc(p).allocation then
+              include(unusedregsint,supreg)
+            else
+              begin
+                exclude(unusedregsint,supreg);
+                if supreg=huntfor1 then
+                  begin
+                    get_insert_pos:=Tai(p.previous);
+                    back:=unusedregsint;
+                  end;
+                if supreg=huntfor2 then
+                  begin
+                    get_insert_pos:=Tai(p.previous);
+                    back:=unusedregsint;
+                  end;
+                if supreg=huntfor3 then
+                  begin
+                    get_insert_pos:=Tai(p.previous);
+                    back:=unusedregsint;
+                  end;
+              end;
+            p:=Tai(p.previous);
+          end;
+        unusedregsint:=back;
+      end;
+
+
+    procedure taicpu_abstract.forward_allocation(p:Tai;var unusedregsint:Tsuperregisterset);
+      begin
+        {Forward the register allocation again.}
+        while (p<>self) do
+          begin
+            if p.typ<>ait_regalloc then
+              internalerror(200305311);
+            if Tai_regalloc(p).allocation then
+              exclude(unusedregsint,getsupreg(Tai_regalloc(p).reg))
+            else
+              include(unusedregsint,getsupreg(Tai_regalloc(p).reg));
+            p:=Tai(p.next);
+          end;
+      end;
+
+
+    function taicpu_abstract.spill_registers(list:Taasmoutput;
+                             rgget:Trggetproc;
+                             rgunget:Trgungetproc;
+                             r:Tsuperregisterset;
+                             var unusedregsint:Tsuperregisterset;
+                              const spilltemplist:Tspill_temp_list): boolean;
+      var
+        i:byte;
+        supreg, reg1, reg2, reg3: Tsuperregister;
+        helpreg:Tregister;
+        helpins:Tai;
+        op:Tasmop;
+        pos:Tai;
+        wasload: boolean;
+
+      begin
+        spill_registers:=false;
+        if (ops = 2) and
+           (oper[1].typ=top_ref) and
+           { oper[1] can also be ref in case of "lis r3,symbol@ha" or so }
+           spilling_decode_loadstore(opcode,op,wasload) then
+          begin
+            { the register that's being stored/loaded }
+            supreg:=getsupreg(oper[0].reg);
+            if supreg in r then
+              begin
+                // Example:
+                //   l?? r20d, 8(r1)   ; r20d must be spilled into -60(r1)
+                //
+                //   Change into:
+                //
+                //   l?? r21d, 8(r1)
+                //   st? r21d, -60(r1)
+                //
+                // And:
+                //
+                //   st? r20d, 8(r1)   ; r20d must be spilled into -60(r1)
+                //
+                //   Change into:
+                //
+                //   l?? r21d, -60(r1)
+                //   st? r21d, 8(r1)
+
+                pos := get_insert_pos(Tai(previous),supreg,
+                                      getsupreg(oper[1].ref^.base),
+                                      getsupreg(oper[1].ref^.index),
+                                      unusedregsint);
+                rgget(list,pos,R_SUBWHOLE,helpreg);
+                spill_registers := true;
+                if wasload then
+                  begin
+                    helpins:=spilling_create_loadstore(opcode,helpreg,oper[1].ref^);
+                    loadref(1,spilltemplist[supreg]);
+                    opcode := op;
+                  end
+                else
+                  helpins:=spilling_create_loadstore(op,helpreg,spilltemplist[supreg]);
+                if pos=nil then
+                  list.insertafter(helpins,list.first)
+                else
+                  list.insertafter(helpins,pos.next);
+                loadreg(0,helpreg);
+                rgunget(list,helpins,helpreg);
+                forward_allocation(tai(helpins.next),unusedregsint);
+{
+                writeln('spilling!');
+                list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
+}
+              end;
+
+            { now the registers used in the reference }
+            { a) base                                 }
+            supreg := getsupreg(oper[1].ref^.base);
+            if supreg in r then
+              begin
+                if wasload then
+                  pos:=get_insert_pos(Tai(previous),getsupreg(oper[1].ref^.index),getsupreg(oper[0].reg),0,unusedregsint)
+                else
+                  pos:=get_insert_pos(Tai(previous),getsupreg(oper[1].ref^.index),0,0,unusedregsint);
+                rgget(list,pos,R_SUBWHOLE,helpreg);
+                spill_registers:=true;
+                helpins:=spilling_create_load(spilltemplist[supreg],helpreg);
+                if pos=nil then
+                  list.insertafter(helpins,list.first)
+                else
+                  list.insertafter(helpins,pos.next);
+                oper[1].ref^.base:=helpreg;
+                rgunget(list,helpins,helpreg);
+                forward_allocation(Tai(helpins.next),unusedregsint);
+{
+                writeln('spilling!');
+                list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
+}
+              end;
+
+            { b) index }
+            supreg := getsupreg(oper[1].ref^.index);
+            if supreg in r then
+              begin
+                if wasload then
+                  pos:=get_insert_pos(Tai(previous),getsupreg(oper[1].ref^.base),getsupreg(oper[0].reg),0,unusedregsint)
+                else
+                  pos:=get_insert_pos(Tai(previous),getsupreg(oper[1].ref^.base),0,0,unusedregsint);
+                rgget(list,pos,R_SUBWHOLE,helpreg);
+                spill_registers:=true;
+                helpins:=spilling_create_load(spilltemplist[supreg],helpreg);
+                if pos=nil then
+                  list.insertafter(helpins,list.first)
+                else
+                  list.insertafter(helpins,pos.next);
+                oper[1].ref^.index:=helpreg;
+                rgunget(list,helpins,helpreg);
+                forward_allocation(Tai(helpins.next),unusedregsint);
+{
+                writeln('spilling!');
+                list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
+}
+              end;
+            { load/store is done }
+            exit;
+          end;
+
+        { all other instructions the compiler generates are the same (I hope):   }
+        { operand 0 is a register and is the destination, the others are sources }
+        { and can be either registers or constants                               }
+        { exception: branches (is_jmp isn't always set for them)                 }
+        if oper[0].typ <> top_reg then
+          exit;
+        reg1 := getsupreg(oper[0].reg);
+        if oper[1].typ = top_reg then
+          reg2 := getsupreg(oper[1].reg)
+        else
+          reg2 := 0;
+        if (ops >= 3) and
+           (oper[2].typ = top_reg) then
+          reg3 := getsupreg(oper[2].reg)
+        else
+          reg3 := 0;
+
+        supreg:=reg1;
+        if supreg in r then
+          begin
+            // Example:
+            //   add r20d, r21d, r22d   ; r20d must be spilled into -60(r1)
+            //
+            //   Change into:
+            //
+            //   lwz r23d, -60(r1)
+            //   add r23d, r21d, r22d
+            //   stw r23d, -60(r1)
+
+            pos := get_insert_pos(Tai(previous),reg1,reg2,reg3,unusedregsint);
+            rgget(list,pos,R_SUBWHOLE,helpreg);
+            spill_registers := true;
+            helpins:=spilling_create_store(helpreg,spilltemplist[supreg]);
+            list.insertafter(helpins,self);
+            helpins:=spilling_create_load(spilltemplist[supreg],helpreg);
+            if pos=nil then
+              list.insertafter(helpins,list.first)
+            else
+              list.insertafter(helpins,pos.next);
+            loadreg(0,helpreg);
+            rgunget(list,helpins,helpreg);
+            forward_allocation(tai(helpins.next),unusedregsint);
+{
+            writeln('spilling!');
+            list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
+}
+          end;
+
+        for i := 1 to 2 do
+          if (oper[i].typ = top_reg) then
+            begin
+              supreg:=getsupreg(oper[i].reg);
+              if supreg in r then
+                begin
+                  // Example:
+                  //   add r20d, r21d, r22d   ; r20d must be spilled into -60(r1)
+                  //
+                  //   Change into:
+                  //
+                  //   lwz r23d, -60(r1)
+                  //   add r23d, r21d, r22d
+                  //   stw r23d, -60(r1)
+
+                  pos := get_insert_pos(Tai(previous),reg1,reg2,reg3,unusedregsint);
+                  rgget(list,pos,R_SUBWHOLE,helpreg);
+                  spill_registers := true;
+                  helpins:=spilling_create_load(spilltemplist[supreg],helpreg);
+                  if pos=nil then
+                    list.insertafter(helpins,list.first)
+                  else
+                    list.insertafter(helpins,pos.next);
+                  loadreg(i,helpreg);
+                  rgunget(list,helpins,helpreg);
+                  forward_allocation(tai(helpins.next),unusedregsint);
+{
+                  writeln('spilling!');
+                  list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
+}
+                end;
+            end;
+      end;
+
+
 { ---------------------------------------------------------------------
 { ---------------------------------------------------------------------
     Miscellaneous methods.
     Miscellaneous methods.
   ---------------------------------------------------------------------}
   ---------------------------------------------------------------------}
@@ -1802,24 +2061,20 @@ implementation
         begin
         begin
           case p.typ of
           case p.typ of
             ait_regalloc:
             ait_regalloc:
-              Tai_regalloc(p).reg.number:=(Tai_regalloc(p).reg.number and $ff) or
-                                          (table[Tai_regalloc(p).reg.number shr 8] shl 8);
+              setsupreg(Tai_regalloc(p).reg,table[getsupreg(Tai_regalloc(p).reg)]);
             ait_instruction:
             ait_instruction:
               begin
               begin
                 for i:=0 to Taicpu_abstract(p).ops-1 do
                 for i:=0 to Taicpu_abstract(p).ops-1 do
                   case Taicpu_abstract(p).oper[i].typ of
                   case Taicpu_abstract(p).oper[i].typ of
                     Top_reg:
                     Top_reg:
-                      Taicpu_abstract(p).oper[i].reg.number:=(Taicpu_abstract(p).oper[i].reg.number and $ff) or
-                                                             (table[Taicpu_abstract(p).oper[i].reg.number shr 8] shl 8);
+                      setsupreg(Taicpu_abstract(p).oper[i].reg,table[getsupreg(Taicpu_abstract(p).oper[i].reg)]);
                     Top_ref:
                     Top_ref:
                       begin
                       begin
                         r:=Taicpu_abstract(p).oper[i].ref;
                         r:=Taicpu_abstract(p).oper[i].ref;
-                        if r^.base.number<>NR_NO then
-                          r^.base.number:=(r^.base.number and $ff) or
-                                          (table[r^.base.number shr 8] shl 8);
-                        if r^.index.number<>NR_NO then
-                          r^.index.number:=(r^.index.number and $ff) or
-                                           (table[r^.index.number shr 8] shl 8);
+                        if r^.base<>NR_NO then
+                          setsupreg(r^.base,table[getsupreg(r^.base)]);
+                        if r^.index<>NR_NO then
+                          setsupreg(r^.index,table[getsupreg(r^.index)]);
                       end;
                       end;
 {$ifdef arm}
 {$ifdef arm}
                     Top_shifterop:
                     Top_shifterop:
@@ -1831,13 +2086,16 @@ implementation
                       end;
                       end;
 {$endif arm}
 {$endif arm}
                   end;
                   end;
-                  if Taicpu_abstract(p).is_nop then
-                    begin
-                      q:=p;
-                      p:=Tai(p.next);
-                      remove(q);
-                      continue;
-                    end;
+
+                { Maybe the operation can be removed when
+                  it is a move and both arguments are the same }
+                if Taicpu_abstract(p).is_nop then
+                  begin
+                    q:=p;
+                    p:=Tai(p.next);
+                    remove(q);
+                    continue;
+                  end;
               end;
               end;
           end;
           end;
           p:=Tai(p.next);
           p:=Tai(p.next);
@@ -1847,13 +2105,31 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.36  2003-09-03 11:18:36  florian
+  Revision 1.37  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.36  2003/09/03 11:18:36  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.35.2.5  2003/08/31 21:08:16  peter
+    * first batch of sparc fixes
+
+  Revision 1.35.2.4  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.35.2.3  2003/08/28 18:35:07  peter
+    * tregister changed to cardinal
+
+  Revision 1.35.2.2  2003/08/27 20:23:55  peter
+    * remove old ra code
+
+  Revision 1.35.2.1  2003/08/27 19:55:54  peter
+    * first tregister patch
+
   Revision 1.35  2003/08/21 14:47:41  peter
   Revision 1.35  2003/08/21 14:47:41  peter
     * remove convert_registers
     * remove convert_registers
 
 

+ 15 - 13
compiler/aggas.pas

@@ -71,7 +71,7 @@ implementation
       dos,
       dos,
 {$endif Delphi}
 {$endif Delphi}
       cutils,globtype,systems,
       cutils,globtype,systems,
-      fmodule,finput,verbose,cpubase
+      fmodule,finput,verbose,cpubase,cginfo
 {$ifdef GDB}
 {$ifdef GDB}
   {$ifdef delphi}
   {$ifdef delphi}
       ,sysutils
       ,sysutils
@@ -314,11 +314,10 @@ var
       co       : comp;
       co       : comp;
       sin      : single;
       sin      : single;
       d        : double;
       d        : double;
+{$ifdef cpuextended}
       e        : extended;
       e        : extended;
+{$endif cpuextended}
       do_line  : boolean;
       do_line  : boolean;
-{$ifdef delphi}
-      _64bitarray : t64bitarray;
-{$endif}
     begin
     begin
       if not assigned(p) then
       if not assigned(p) then
        exit;
        exit;
@@ -399,14 +398,8 @@ var
            ait_regalloc :
            ait_regalloc :
              begin
              begin
                if (cs_asm_regalloc in aktglobalswitches) then
                if (cs_asm_regalloc in aktglobalswitches) then
-                 begin
-                   if Tai_Regalloc(hp).reg.enum=R_INTREGISTER then
-                     AsmWriteLn(#9+target_asm.comment+'Register '+gas_regname(Tai_regalloc(hp).reg.number)+
-                       allocstr[tai_regalloc(hp).allocation])
-                   else
-                     AsmWriteLn(#9+target_asm.comment+'Register '+std_reg2str[tai_regalloc(hp).reg.enum]+
-                       allocstr[tai_regalloc(hp).allocation]);
-                 end;
+                 AsmWriteLn(#9+target_asm.comment+'Register '+gas_regname(Tai_regalloc(hp).reg)+
+                            allocstr[tai_regalloc(hp).allocation]);
              end;
              end;
 
 
            ait_tempalloc :
            ait_tempalloc :
@@ -835,13 +828,22 @@ var
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.30  2003-09-03 11:18:36  florian
+  Revision 1.31  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.30  2003/09/03 11:18:36  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.29.2.2  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.29.2.1  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
   Revision 1.29  2003/08/19 11:53:03  daniel
   Revision 1.29  2003/08/19 11:53:03  daniel
     * Fixed PowerPC compilation
     * Fixed PowerPC compilation
 
 

+ 13 - 2
compiler/assemble.pas

@@ -1018,7 +1018,12 @@ Implementation
     function TInternalAssembler.TreePass1(hp:Tai):Tai;
     function TInternalAssembler.TreePass1(hp:Tai):Tai;
       var
       var
         InlineLevel,
         InlineLevel,
-        i,l : longint;
+        l : longint;
+{$ifdef i386}
+{$ifndef NOAG386BIN}
+        i : longint;
+{$endif NOAG386BIN}
+{$endif i386}
       begin
       begin
         inlinelevel:=0;
         inlinelevel:=0;
         while assigned(hp) do
         while assigned(hp) do
@@ -1635,7 +1640,13 @@ Implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.53  2003-07-04 22:40:58  pierre
+  Revision 1.54  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.53.2.1  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.53  2003/07/04 22:40:58  pierre
    * add support for constant offset in stabs address, needed by threadvar debugging support
    * add support for constant offset in stabs address, needed by threadvar debugging support
 
 
   Revision 1.52  2003/04/23 13:48:07  peter
   Revision 1.52  2003/04/23 13:48:07  peter

+ 24 - 91
compiler/cg64f32.pas

@@ -50,10 +50,10 @@ unit cg64f32;
         procedure a_reg_dealloc(list : taasmoutput;r : tregister64);override;
         procedure a_reg_dealloc(list : taasmoutput;r : tregister64);override;
         procedure a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);override;
         procedure a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);override;
         procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);override;
         procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);override;
-        procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64{$ifdef newra};delete:boolean{$endif});override;
-        procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64{$ifdef newra};delete:boolean{$endif});override;
+        procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64;delete:boolean);override;
+        procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64;delete:boolean);override;
         procedure a_load64_const_reg(list : taasmoutput;value: qword;reg : tregister64);override;
         procedure a_load64_const_reg(list : taasmoutput;value: qword;reg : tregister64);override;
-        procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64{$ifdef newra};delete: boolean{$endif});override;
+        procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64;delete: boolean);override;
         procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);override;
         procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);override;
         procedure a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);override;
         procedure a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);override;
         procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);override;
         procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);override;
@@ -158,7 +158,7 @@ unit cg64f32;
       end;
       end;
 
 
 
 
-    procedure tcg64f32.a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64{$ifdef newra};delete:boolean{$endif});
+    procedure tcg64f32.a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64;delete:boolean);
       var
       var
         tmpreg: tregister;
         tmpreg: tregister;
         tmpref: treference;
         tmpref: treference;
@@ -172,13 +172,9 @@ unit cg64f32;
           end;
           end;
         got_scratch:=false;
         got_scratch:=false;
         tmpref := ref;
         tmpref := ref;
-        if (tmpref.base.number=reg.reglo.number) then
+        if (tmpref.base=reg.reglo) then
          begin
          begin
-         {$ifdef newra}
            tmpreg:=rg.getaddressregister(list);
            tmpreg:=rg.getaddressregister(list);
-         {$else}
-           tmpreg := cg.get_scratch_reg_address(list);
-         {$endif}
            got_scratch:=true;
            got_scratch:=true;
            cg.a_load_reg_reg(list,OS_ADDR,OS_ADDR,tmpref.base,tmpreg);
            cg.a_load_reg_reg(list,OS_ADDR,OS_ADDR,tmpref.base,tmpreg);
            tmpref.base:=tmpreg;
            tmpref.base:=tmpreg;
@@ -187,49 +183,34 @@ unit cg64f32;
          { this works only for the i386, thus the i386 needs to override  }
          { this works only for the i386, thus the i386 needs to override  }
          { this method and this method must be replaced by a more generic }
          { this method and this method must be replaced by a more generic }
          { implementation FK                                              }
          { implementation FK                                              }
-         if (tmpref.index.number=reg.reglo.number) then
+         if (tmpref.index=reg.reglo) then
           begin
           begin
-          {$ifdef newra}
             tmpreg:=rg.getaddressregister(list);
             tmpreg:=rg.getaddressregister(list);
-          {$else}
-            tmpreg:=cg.get_scratch_reg_address(list);
-          {$endif}
             got_scratch:=true;
             got_scratch:=true;
             cg.a_load_reg_reg(list,OS_ADDR,OS_ADDR,tmpref.index,tmpreg);
             cg.a_load_reg_reg(list,OS_ADDR,OS_ADDR,tmpref.index,tmpreg);
             tmpref.index:=tmpreg;
             tmpref.index:=tmpreg;
           end;
           end;
         cg.a_load_ref_reg(list,OS_32,OS_32,tmpref,reg.reglo);
         cg.a_load_ref_reg(list,OS_32,OS_32,tmpref,reg.reglo);
         inc(tmpref.offset,4);
         inc(tmpref.offset,4);
-{$ifdef newra}
         if delete then
         if delete then
           begin
           begin
             tg.ungetiftemp(list,tmpref);
             tg.ungetiftemp(list,tmpref);
             reference_release(list,tmpref);
             reference_release(list,tmpref);
           end;
           end;
-{$endif}
         cg.a_load_ref_reg(list,OS_32,OS_32,tmpref,reg.reghi);
         cg.a_load_ref_reg(list,OS_32,OS_32,tmpref,reg.reghi);
-{$ifdef newra}
         if got_scratch then
         if got_scratch then
           rg.ungetregisterint(list,tmpreg);
           rg.ungetregisterint(list,tmpreg);
-{$else}
-        if got_scratch then
-          cg.free_scratch_reg(list,tmpreg);
-{$endif}
       end;
       end;
 
 
 
 
-    procedure tcg64f32.a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64{$ifdef newra};delete:boolean{$endif});
+    procedure tcg64f32.a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64;delete:boolean);
 
 
       begin
       begin
-      {$ifdef newra}
         if delete then
         if delete then
           rg.ungetregisterint(list,regsrc.reglo);
           rg.ungetregisterint(list,regsrc.reglo);
-      {$endif}
         cg.a_load_reg_reg(list,OS_32,OS_32,regsrc.reglo,regdst.reglo);
         cg.a_load_reg_reg(list,OS_32,OS_32,regsrc.reglo,regdst.reglo);
-      {$ifdef newra}
         if delete then
         if delete then
           rg.ungetregisterint(list,regsrc.reghi);
           rg.ungetregisterint(list,regsrc.reghi);
-      {$endif}
         cg.a_load_reg_reg(list,OS_32,OS_32,regsrc.reghi,regdst.reghi);
         cg.a_load_reg_reg(list,OS_32,OS_32,regsrc.reghi,regdst.reghi);
       end;
       end;
 
 
@@ -242,14 +223,14 @@ unit cg64f32;
       end;
       end;
 
 
 
 
-    procedure tcg64f32.a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64{$ifdef newra};delete :boolean{$endif});
+    procedure tcg64f32.a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64;delete :boolean);
 
 
       begin
       begin
         case l.loc of
         case l.loc of
           LOC_REFERENCE, LOC_CREFERENCE:
           LOC_REFERENCE, LOC_CREFERENCE:
-            a_load64_ref_reg(list,l.reference,reg{$ifdef newra},delete{$endif});
+            a_load64_ref_reg(list,l.reference,reg,delete);
           LOC_REGISTER,LOC_CREGISTER:
           LOC_REGISTER,LOC_CREGISTER:
-            a_load64_reg_reg(list,l.register64,reg{$ifdef newra},delete{$endif});
+            a_load64_reg_reg(list,l.register64,reg,delete);
           LOC_CONSTANT :
           LOC_CONSTANT :
             a_load64_const_reg(list,l.valueqword,reg);
             a_load64_const_reg(list,l.valueqword,reg);
           else
           else
@@ -292,7 +273,7 @@ unit cg64f32;
           LOC_REFERENCE, LOC_CREFERENCE:
           LOC_REFERENCE, LOC_CREFERENCE:
             a_load64_reg_ref(list,reg,l.reference);
             a_load64_reg_ref(list,reg,l.reference);
           LOC_REGISTER,LOC_CREGISTER:
           LOC_REGISTER,LOC_CREGISTER:
-            a_load64_reg_reg(list,reg,l.register64{$ifdef newra},false{$endif});
+            a_load64_reg_reg(list,reg,l.register64,false);
           else
           else
             internalerror(200112293);
             internalerror(200112293);
         end;
         end;
@@ -435,22 +416,12 @@ unit cg64f32;
       var
       var
         tempreg: tregister64;
         tempreg: tregister64;
       begin
       begin
-      {$ifdef newra}
         tempreg.reghi:=rg.getregisterint(list,OS_INT);
         tempreg.reghi:=rg.getregisterint(list,OS_INT);
         tempreg.reglo:=rg.getregisterint(list,OS_INT);
         tempreg.reglo:=rg.getregisterint(list,OS_INT);
-      {$else}
-        tempreg.reghi := cg.get_scratch_reg_int(list,OS_INT);
-        tempreg.reglo := cg.get_scratch_reg_int(list,OS_INT);
-      {$endif}
-        a_load64_ref_reg(list,ref,tempreg{$ifdef newra},false{$endif});
+        a_load64_ref_reg(list,ref,tempreg,false);
         a_op64_reg_reg(list,op,tempreg,reg);
         a_op64_reg_reg(list,op,tempreg,reg);
-      {$ifdef newra}
         rg.ungetregisterint(list,tempreg.reglo);
         rg.ungetregisterint(list,tempreg.reglo);
         rg.ungetregisterint(list,tempreg.reghi);
         rg.ungetregisterint(list,tempreg.reghi);
-      {$else}
-        cg.free_scratch_reg(list,tempreg.reglo);
-        cg.free_scratch_reg(list,tempreg.reghi);
-      {$endif}
       end;
       end;
 
 
 
 
@@ -458,23 +429,13 @@ unit cg64f32;
       var
       var
         tempreg: tregister64;
         tempreg: tregister64;
       begin
       begin
-      {$ifdef newra}
         tempreg.reghi:=rg.getregisterint(list,OS_INT);
         tempreg.reghi:=rg.getregisterint(list,OS_INT);
         tempreg.reglo:=rg.getregisterint(list,OS_INT);
         tempreg.reglo:=rg.getregisterint(list,OS_INT);
-      {$else}
-        tempreg.reghi := cg.get_scratch_reg_int(list,OS_INT);
-        tempreg.reglo := cg.get_scratch_reg_int(list,OS_INT);
-      {$endif}
-        a_load64_ref_reg(list,ref,tempreg{$ifdef newra},false{$endif});
+        a_load64_ref_reg(list,ref,tempreg,false);
         a_op64_reg_reg(list,op,reg,tempreg);
         a_op64_reg_reg(list,op,reg,tempreg);
         a_load64_reg_ref(list,tempreg,ref);
         a_load64_reg_ref(list,tempreg,ref);
-      {$ifdef newra}
         rg.ungetregisterint(list,tempreg.reglo);
         rg.ungetregisterint(list,tempreg.reglo);
         rg.ungetregisterint(list,tempreg.reghi);
         rg.ungetregisterint(list,tempreg.reghi);
-      {$else}
-        cg.free_scratch_reg(list,tempreg.reglo);
-        cg.free_scratch_reg(list,tempreg.reghi);
-      {$endif}
       end;
       end;
 
 
 
 
@@ -482,23 +443,13 @@ unit cg64f32;
       var
       var
         tempreg: tregister64;
         tempreg: tregister64;
       begin
       begin
-      {$ifdef newra}
         tempreg.reghi:=rg.getregisterint(list,OS_INT);
         tempreg.reghi:=rg.getregisterint(list,OS_INT);
         tempreg.reglo:=rg.getregisterint(list,OS_INT);
         tempreg.reglo:=rg.getregisterint(list,OS_INT);
-      {$else}
-        tempreg.reghi := cg.get_scratch_reg_int(list,OS_INT);
-        tempreg.reglo := cg.get_scratch_reg_int(list,OS_INT);
-      {$endif}
-        a_load64_ref_reg(list,ref,tempreg{$ifdef newra},false{$endif});
+        a_load64_ref_reg(list,ref,tempreg,false);
         a_op64_const_reg(list,op,value,tempreg);
         a_op64_const_reg(list,op,value,tempreg);
         a_load64_reg_ref(list,tempreg,ref);
         a_load64_reg_ref(list,tempreg,ref);
-      {$ifdef newra}
         rg.ungetregisterint(list,tempreg.reglo);
         rg.ungetregisterint(list,tempreg.reglo);
         rg.ungetregisterint(list,tempreg.reghi);
         rg.ungetregisterint(list,tempreg.reghi);
-      {$else}
-        cg.free_scratch_reg(list,tempreg.reglo);
-        cg.free_scratch_reg(list,tempreg.reghi);
-      {$endif}
       end;
       end;
 
 
 
 
@@ -587,11 +538,7 @@ unit cg64f32;
                end
                end
              else
              else
                begin
                begin
-               {$ifdef newra}
                  hreg:=rg.getregisterint(list,OS_INT);
                  hreg:=rg.getregisterint(list,OS_INT);
-               {$else}
-                 hreg := cg.get_scratch_reg_int(list,OS_INT);
-               {$endif}
                  got_scratch := true;
                  got_scratch := true;
                  a_load64high_ref_reg(list,l.reference,hreg);
                  a_load64high_ref_reg(list,l.reference,hreg);
                end;
                end;
@@ -607,13 +554,8 @@ unit cg64f32;
                  cg.a_cmp_const_reg_label(list,OS_32,OC_EQ,aword(-1),hreg,neglabel);
                  cg.a_cmp_const_reg_label(list,OS_32,OC_EQ,aword(-1),hreg,neglabel);
                end;
                end;
              { !!! freeing of register should happen directly after compare! (JM) }
              { !!! freeing of register should happen directly after compare! (JM) }
-           {$ifdef newra}
              if got_scratch then
              if got_scratch then
                rg.ungetregisterint(list,hreg);
                rg.ungetregisterint(list,hreg);
-           {$else}
-             if got_scratch then
-               cg.free_scratch_reg(list,hreg);
-           {$endif}
              { For all other values we have a range check error }
              { For all other values we have a range check error }
              cg.a_call_name(list,'FPC_RANGEERROR');
              cg.a_call_name(list,'FPC_RANGEERROR');
 
 
@@ -642,11 +584,7 @@ unit cg64f32;
                    end
                    end
                  else
                  else
                    begin
                    begin
-                   {$ifdef newra}
                      hreg:=rg.getregisterint(list,OS_INT);
                      hreg:=rg.getregisterint(list,OS_INT);
-                   {$else}
-                     hreg := cg.get_scratch_reg_int(list,OS_INT);
-                   {$endif}
                      got_scratch := true;
                      got_scratch := true;
                      a_load64low_ref_reg(list,l.reference,hreg);
                      a_load64low_ref_reg(list,l.reference,hreg);
                    end;
                    end;
@@ -654,13 +592,8 @@ unit cg64f32;
                  objectlibrary.getlabel(neglabel);
                  objectlibrary.getlabel(neglabel);
                  cg.a_cmp_const_reg_label(list,OS_32,OC_LT,0,hreg,neglabel);
                  cg.a_cmp_const_reg_label(list,OS_32,OC_LT,0,hreg,neglabel);
                  { !!! freeing of register should happen directly after compare! (JM) }
                  { !!! freeing of register should happen directly after compare! (JM) }
-               {$ifdef newra}
                  if got_scratch then
                  if got_scratch then
                    rg.ungetregisterint(list,hreg);
                    rg.ungetregisterint(list,hreg);
-               {$else}
-                 if got_scratch then
-                   cg.free_scratch_reg(list,hreg);
-               {$endif}
 
 
                  cg.a_call_name(list,'FPC_RANGEERROR');
                  cg.a_call_name(list,'FPC_RANGEERROR');
 
 
@@ -704,11 +637,7 @@ unit cg64f32;
                  end
                  end
                else
                else
                  begin
                  begin
-                 {$ifdef newra}
                    hreg:=rg.getregisterint(list,OS_INT);
                    hreg:=rg.getregisterint(list,OS_INT);
-                 {$else}
-                   hreg := cg.get_scratch_reg_int(list,OS_INT);
-                 {$endif}
                    got_scratch := true;
                    got_scratch := true;
 
 
                    opsize := def_cgsize(fromdef);
                    opsize := def_cgsize(fromdef);
@@ -721,13 +650,8 @@ unit cg64f32;
                cg.a_cmp_const_reg_label(list,opsize,OC_GTE,0,hreg,poslabel);
                cg.a_cmp_const_reg_label(list,opsize,OC_GTE,0,hreg,poslabel);
 
 
                { !!! freeing of register should happen directly after compare! (JM) }
                { !!! freeing of register should happen directly after compare! (JM) }
-             {$ifdef newra}
                if got_scratch then
                if got_scratch then
                  rg.ungetregisterint(list,hreg);
                  rg.ungetregisterint(list,hreg);
-             {$else}
-               if got_scratch then
-                 cg.free_scratch_reg(list,hreg);
-             {$endif}
                cg.a_call_name(list,'FPC_RANGEERROR');
                cg.a_call_name(list,'FPC_RANGEERROR');
                cg.a_label(list,poslabel);
                cg.a_label(list,poslabel);
              end;
              end;
@@ -838,7 +762,16 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.48  2003-07-02 22:18:04  peter
+  Revision 1.49  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.48.2.2  2003/08/28 18:35:07  peter
+    * tregister changed to cardinal
+
+  Revision 1.48.2.1  2003/08/27 20:23:55  peter
+    * remove old ra code
+
+  Revision 1.48  2003/07/02 22:18:04  peter
     * paraloc splitted in callerparaloc,calleeparaloc
     * paraloc splitted in callerparaloc,calleeparaloc
     * sparc calling convention updates
     * sparc calling convention updates
 
 

+ 14 - 7
compiler/cgbase.pas

@@ -320,8 +320,7 @@ implementation
         parent_framepointer_offset:=0;
         parent_framepointer_offset:=0;
         firsttemp_offset:=0;
         firsttemp_offset:=0;
         flags:=[];
         flags:=[];
-        framepointer.enum:=R_INTREGISTER;
-        framepointer.number:=NR_FRAME_POINTER_REG;
+        framepointer:=NR_FRAME_POINTER_REG;
         { asmlists }
         { asmlists }
         aktproccode:=Taasmoutput.Create;
         aktproccode:=Taasmoutput.Create;
         aktlocaldata:=Taasmoutput.Create;
         aktlocaldata:=Taasmoutput.Create;
@@ -376,6 +375,7 @@ implementation
     procedure tprocinfo.handle_body_start;
     procedure tprocinfo.handle_body_start;
       var
       var
         paramloc : tparalocation;
         paramloc : tparalocation;
+        regidx : tregisterindex;
       begin
       begin
          { generate callee paraloc register info }
          { generate callee paraloc register info }
          paramanager.create_paraloc_info(current_procinfo.procdef,calleeside);
          paramanager.create_paraloc_info(current_procinfo.procdef,calleeside);
@@ -396,18 +396,19 @@ implementation
                LOC_MMREGISTER,
                LOC_MMREGISTER,
                LOC_CMMREGISTER :
                LOC_CMMREGISTER :
                  begin
                  begin
-                   include(rg.used_in_proc_other,paramloc.register.enum);
+                   regidx:=findreg_by_number(paramloc.register);
+                   include(rg.used_in_proc_other,regidx);
                  end;
                  end;
                LOC_REGISTER,LOC_CREGISTER :
                LOC_REGISTER,LOC_CREGISTER :
                  begin
                  begin
                    if ((paramloc.size in [OS_S64,OS_64]) and
                    if ((paramloc.size in [OS_S64,OS_64]) and
                       (sizeof(aword) < 8)) then
                       (sizeof(aword) < 8)) then
                      begin
                      begin
-                       include(rg.used_in_proc_int,paramloc.registerhigh.number shr 8);
-                       include(rg.used_in_proc_int,paramloc.registerlow.number shr 8);
+                       include(rg.used_in_proc_int,getsupreg(paramloc.registerhigh));
+                       include(rg.used_in_proc_int,getsupreg(paramloc.registerlow));
                      end
                      end
                    else
                    else
-                     include(rg.used_in_proc_int,paramloc.register.number shr 8);
+                     include(rg.used_in_proc_int,getsupreg(paramloc.register));
                  end;
                  end;
              end;
              end;
            end;
            end;
@@ -581,7 +582,13 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.60  2003-08-26 12:43:02  peter
+  Revision 1.61  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.60.2.1  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.60  2003/08/26 12:43:02  peter
     * methodpointer fixes
     * methodpointer fixes
 
 
   Revision 1.59  2003/08/20 17:48:49  peter
   Revision 1.59  2003/08/20 17:48:49  peter

+ 165 - 1
compiler/cginfo.pas

@@ -103,6 +103,64 @@ interface
                   OS_M8,OS_M16,OS_M32,OS_M64,OS_M128,OS_MS8,OS_MS16,OS_MS32,
                   OS_M8,OS_M16,OS_M32,OS_M64,OS_M128,OS_MS8,OS_MS16,OS_MS32,
                   OS_MS64,OS_MS128);
                   OS_MS64,OS_MS128);
 
 
+      { Register types }
+      TRegisterType = (
+        R_INVALIDREGISTER, { = 0 }
+        R_INTREGISTER,     { = 1 }
+        R_FPUREGISTER,     { = 2 }
+        R_MMXREGISTER,     { = 3 }
+        R_KNIREGISTER,     { = 4 }
+        R_SPECIALREGISTER, { = 5 }
+        R_ADDRESSREGISTER  { = 6 }
+      );
+
+      { Sub registers }
+      TSubRegister = (
+        R_SUBNONE, { = 0; no sub register possible }
+        R_SUBL,    { = 1; 8 bits, Like AL }
+        R_SUBH,    { = 2; 8 bits, Like AH }
+        R_SUBW,    { = 3; 16 bits, Like AX }
+        R_SUBD,    { = 4; 32 bits, Like EAX }
+        R_SUBQ     { = 5; 64 bits, Like RAX }
+      );
+
+      TSuperRegister = type byte;
+
+      {
+        The new register coding:
+
+        SuperRegister   (bits 0..7)
+        Unused          (bits 8..15)
+        Subregister     (bits 16..23)
+        Register type   (bits 24..31)
+      }
+      TRegister = type cardinal;
+      TRegisterRec=packed record
+{$ifdef FPC_ENDIAN_BIG}
+         regtype : Tregistertype;
+         subreg  : Tsubregister;
+         unused  : byte;
+         supreg  : Tsuperregister;
+{$else FPC_ENDIAN_BIG}
+         supreg  : Tsuperregister;
+         unused  : byte;
+         subreg  : Tsubregister;
+         regtype : Tregistertype;
+{$endif FPC_ENDIAN_BIG}
+      end;
+
+      { A type to store register locations for 64 Bit values. }
+{$ifdef cpu64bit}
+      tregister64 = tregister;
+{$else cpu64bit}
+      tregister64 = packed record
+         reglo,reghi : tregister;
+      end;
+{$endif cpu64bit}
+
+      { Set type definition for registers }
+      tsuperregisterset = set of tsuperregister;
+
     const
     const
        tcgsize2size : Array[tcgsize] of integer =
        tcgsize2size : Array[tcgsize] of integer =
          { integer values }
          { integer values }
@@ -145,12 +203,118 @@ interface
             'LOC_MMREG',
             'LOC_MMREG',
             'LOC_CMMREG');
             'LOC_CMMREG');
 
 
+    function newreg(rt:tregistertype;sr:tsuperregister;sb:tsubregister):tregister;{$ifdef USEINLINE}inline;{$endif}
+    function getsubreg(r:tregister):tsubregister;{$ifdef USEINLINE}inline;{$endif}
+    function getsupreg(r:tregister):tsuperregister;{$ifdef USEINLINE}inline;{$endif}
+    function getregtype(r:tregister):tregistertype;{$ifdef USEINLINE}inline;{$endif}
+    procedure setsubreg(var r:tregister;sr:tsubregister);{$ifdef USEINLINE}inline;{$endif}
+    procedure setsupreg(var r:tregister;sr:tsuperregister);{$ifdef USEINLINE}inline;{$endif}
+    function generic_regname(r:tregister):string;
+
+
 implementation
 implementation
 
 
+    uses
+      verbose;
+
+    function newreg(rt:tregistertype;sr:tsuperregister;sb:tsubregister):tregister;{$ifdef USEINLINE}inline;{$endif}
+      begin
+        tregisterrec(result).regtype:=rt;
+        tregisterrec(result).unused:=0;
+        tregisterrec(result).supreg:=sr;
+        tregisterrec(result).subreg:=sb;
+      end;
+
+
+    function getsubreg(r:tregister):tsubregister;{$ifdef USEINLINE}inline;{$endif}
+      begin
+        result:=tregisterrec(r).subreg;
+      end;
+
+
+    function getsupreg(r:tregister):tsuperregister;{$ifdef USEINLINE}inline;{$endif}
+      begin
+        result:=tregisterrec(r).supreg;
+      end;
+
+
+    function getregtype(r:tregister):tregistertype;{$ifdef USEINLINE}inline;{$endif}
+      begin
+        result:=tregisterrec(r).regtype;
+      end;
+
+
+    procedure setsubreg(var r:tregister;sr:tsubregister);{$ifdef USEINLINE}inline;{$endif}
+      begin
+        tregisterrec(r).subreg:=sr;
+      end;
+
+
+    procedure setsupreg(var r:tregister;sr:tsuperregister);{$ifdef USEINLINE}inline;{$endif}
+      begin
+        tregisterrec(r).supreg:=sr;
+      end;
+
+
+    function generic_regname(r:tregister):string;
+      var
+        t,sub : char;
+        nr    : string[12];
+      begin
+        case getregtype(r) of
+          R_INTREGISTER:
+            t:='i';
+          R_FPUREGISTER:
+            t:='f';
+          R_MMXREGISTER:
+            t:='m';
+          R_KNIREGISTER:
+            t:='k';
+          else
+            internalerror(200308251);
+        end;
+        str(getsupreg(r),nr);
+        case getsubreg(r) of
+          R_SUBNONE:
+            sub:=' ';
+          R_SUBL:
+            sub:='l';
+          R_SUBH:
+            sub:='h';
+          R_SUBW:
+            sub:='w';
+          R_SUBD:
+            sub:='d';
+          R_SUBQ:
+            sub:='q';
+          else
+            internalerror(200308252);
+        end;
+        if sub<>' ' then
+          result:=t+'reg'+nr+sub
+        else
+          result:=t+'reg'+nr;
+      end;
+
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.21  2003-04-25 20:59:33  peter
+  Revision 1.22  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.21.2.4  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.21.2.3  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.21.2.2  2003/08/28 18:35:07  peter
+    * tregister changed to cardinal
+
+  Revision 1.21.2.1  2003/08/27 19:55:54  peter
+    * first tregister patch
+
+  Revision 1.21  2003/04/25 20:59:33  peter
     * removed funcretn,funcretsym, function result is now in varsym
     * removed funcretn,funcretsym, function result is now in varsym
       and aliases for result and function name are added using absolutesym
       and aliases for result and function name are added using absolutesym
     * vs_hidden parameter for funcret passed in parameter
     * vs_hidden parameter for funcret passed in parameter

+ 44 - 458
compiler/cgobj.pas

@@ -59,11 +59,6 @@ unit cgobj;
           sould be @link(tcg64f32) and not @var(tcg).
           sould be @link(tcg64f32) and not @var(tcg).
        }
        }
        tcg = class
        tcg = class
-{$ifndef newra}
-          {# List of currently unused scratch registers }
-          unusedscratchregisters:Tsupregset;
-{$endif}
-
           alignment : talignment;
           alignment : talignment;
           {************************************************}
           {************************************************}
           {                 basic routines                 }
           {                 basic routines                 }
@@ -80,31 +75,6 @@ unit cgobj;
           {# Deallocates register r by inserting a pa_regdealloc record}
           {# Deallocates register r by inserting a pa_regdealloc record}
           procedure a_reg_dealloc(list : taasmoutput;r : tregister);
           procedure a_reg_dealloc(list : taasmoutput;r : tregister);
 
 
-{$ifndef newra}
-          {# @abstract(Returns an int register for use as scratch register)
-             This routine returns a register which can be used by
-             the code generator as a general purpose scratch register.
-             Since scratch_registers are scarce resources, the register
-             should be freed by calling @link(free_scratch_reg) as
-             soon as it is no longer required.
-          }
-          function get_scratch_reg_int(list : taasmoutput;size:Tcgsize) : tregister;virtual;
-          {# @abstract(Returns an address register for use as scratch register)
-             This routine returns a register which can be used by
-             the code generator as a pointer scratch register.
-             Since scratch_registers are scarce resources, the register
-             should be freed by calling @link(free_scratch_reg) as
-             soon as it is no longer required.
-          }
-          function get_scratch_reg_address(list : taasmoutput) : tregister;virtual;
-          {# @abstract(Releases a scratch register)
-
-             Releases a scratch register.
-             This routine is used to free a register which
-             was previously allocated using @link(get_scratch_reg).
-          }
-          procedure free_scratch_reg(list : taasmoutput;r : tregister);
-{$endif newra}
           {# Pass a parameter, which is located in a register, to a routine.
           {# Pass a parameter, which is located in a register, to a routine.
 
 
              This routine should push/send the parameter to the routine, as
              This routine should push/send the parameter to the routine, as
@@ -370,7 +340,6 @@ unit cgobj;
           procedure g_overflowcheck(list: taasmoutput; const l:tlocation; def:tdef); virtual; abstract;
           procedure g_overflowcheck(list: taasmoutput; const l:tlocation; def:tdef); virtual; abstract;
 
 
           procedure g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:integer);virtual;abstract;
           procedure g_copyvaluepara_openarray(list : taasmoutput;const ref, lenref:treference;elesize:integer);virtual;abstract;
-//          procedure g_copyvaluepara_openarray(list : taasmoutput;const arrayref,lenref:tparalocation;elesize:integer);virtual;
           {# Emits instructions which should be emitted when entering
           {# Emits instructions which should be emitted when entering
              a routine declared as @var(interrupt). The default
              a routine declared as @var(interrupt). The default
              behavior does nothing, should be overriden as required.
              behavior does nothing, should be overriden as required.
@@ -422,14 +391,14 @@ unit cgobj;
 
 
              @param(usedinproc Registers which are used in the code of this routine)
              @param(usedinproc Registers which are used in the code of this routine)
           }
           }
-          procedure g_save_standard_registers(list:Taasmoutput;usedinproc:Tsupregset);virtual;abstract;
+          procedure g_save_standard_registers(list:Taasmoutput;usedinproc:Tsuperregisterset);virtual;abstract;
           {# This routine is called when generating the code for the exit point
           {# This routine is called when generating the code for the exit point
              of a routine. It should restore all registers which were previously
              of a routine. It should restore all registers which were previously
              saved in @var(g_save_standard_registers).
              saved in @var(g_save_standard_registers).
 
 
              @param(usedinproc Registers which are used in the code of this routine)
              @param(usedinproc Registers which are used in the code of this routine)
           }
           }
-          procedure g_restore_standard_registers(list:Taasmoutput;usedinproc:Tsupregset);virtual;abstract;
+          procedure g_restore_standard_registers(list:Taasmoutput;usedinproc:Tsuperregisterset);virtual;abstract;
           procedure g_save_all_registers(list : taasmoutput);virtual;abstract;
           procedure g_save_all_registers(list : taasmoutput);virtual;abstract;
           procedure g_restore_all_registers(list : taasmoutput;accused,acchiused:boolean);virtual;abstract;
           procedure g_restore_all_registers(list : taasmoutput;accused,acchiused:boolean);virtual;abstract;
        end;
        end;
@@ -445,10 +414,10 @@ unit cgobj;
         procedure a_reg_dealloc(list : taasmoutput;r : tregister64);virtual;abstract;
         procedure a_reg_dealloc(list : taasmoutput;r : tregister64);virtual;abstract;
         procedure a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);virtual;abstract;
         procedure a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);virtual;abstract;
         procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);virtual;abstract;
         procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);virtual;abstract;
-        procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64{$ifdef newra};delete : boolean{$endif});virtual;abstract;
-        procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64{$ifdef newra};delete : boolean{$endif});virtual;abstract;
+        procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64;delete : boolean);virtual;abstract;
+        procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64;delete : boolean);virtual;abstract;
         procedure a_load64_const_reg(list : taasmoutput;value : qword;reg : tregister64);virtual;abstract;
         procedure a_load64_const_reg(list : taasmoutput;value : qword;reg : tregister64);virtual;abstract;
-        procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64{$ifdef newra};delete : boolean{$endif});virtual;abstract;
+        procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64;delete : boolean);virtual;abstract;
         procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);virtual;abstract;
         procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);virtual;abstract;
         procedure a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);virtual;abstract;
         procedure a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);virtual;abstract;
         procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);virtual;abstract;
         procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);virtual;abstract;
@@ -509,10 +478,6 @@ unit cgobj;
        rgobj,cutils;
        rgobj,cutils;
 
 
     const
     const
-{$ifndef newra}
-      max_scratch_regs = high(scratch_regs) - low(scratch_regs) + 1;
-{$endif}
-
       { Please leave this here, this module should NOT use
       { Please leave this here, this module should NOT use
         exprasmlist, the lists are always passed as arguments.
         exprasmlist, the lists are always passed as arguments.
         Declaring it as string here results in an error when compiling (PFV) }
         Declaring it as string here results in an error when compiling (PFV) }
@@ -524,14 +489,7 @@ unit cgobj;
 
 
     constructor tcg.create;
     constructor tcg.create;
 
 
-      var
-         i : longint;
-
       begin
       begin
-{$ifndef newra}
-         for i:=low(scratch_regs) to high(scratch_regs) do
-           include(unusedscratchregisters,scratch_regs[i]);
-{$endif}
       end;
       end;
 
 
     procedure tcg.a_reg_alloc(list : taasmoutput;r : tregister);
     procedure tcg.a_reg_alloc(list : taasmoutput;r : tregister);
@@ -552,57 +510,14 @@ unit cgobj;
          list.concat(tai_label.create(l));
          list.concat(tai_label.create(l));
       end;
       end;
 
 
-{$ifndef newra}
-    function tcg.get_scratch_reg_int(list:taasmoutput;size:Tcgsize):tregister;
-
-      var
-         r : tregister;
-         i : longint;
-
-      begin
-         if unusedscratchregisters=[] then
-           internalerror(68996);
-
-         for i:=low(scratch_regs) to high(scratch_regs) do
-           if scratch_regs[i] in unusedscratchregisters then
-             begin
-                r.enum:=R_INTREGISTER;
-                r.number:=scratch_regs[i] shl 8 or cgsize2subreg(size);
-                break;
-             end;
-         exclude(unusedscratchregisters,r.number shr 8);
-         include(rg.used_in_proc_int,r.number shr 8);
-         a_reg_alloc(list,r);
-         get_scratch_reg_int:=r;
-      end;
-
-    { the default behavior simply returns a general purpose register }
-    function tcg.get_scratch_reg_address(list : taasmoutput) : tregister;
-     begin
-       get_scratch_reg_address := get_scratch_reg_int(list,OS_ADDR);
-     end;
-
-
-    procedure tcg.free_scratch_reg(list : taasmoutput;r : tregister);
-
-      begin
-         if r.enum<>R_INTREGISTER then
-           internalerror(200302058);
-         include(unusedscratchregisters,r.number shr 8);
-         a_reg_dealloc(list,r);
-      end;
-{$endif newra}
 
 
 {*****************************************************************************
 {*****************************************************************************
           for better code generation these methods should be overridden
           for better code generation these methods should be overridden
 ******************************************************************************}
 ******************************************************************************}
 
 
     procedure tcg.a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;const locpara : tparalocation);
     procedure tcg.a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;const locpara : tparalocation);
-
       var
       var
          ref : treference;
          ref : treference;
-         t : Tregister;
-
       begin
       begin
          case locpara.loc of
          case locpara.loc of
             LOC_REGISTER,LOC_CREGISTER:
             LOC_REGISTER,LOC_CREGISTER:
@@ -610,11 +525,7 @@ unit cgobj;
             LOC_REFERENCE,LOC_CREFERENCE:
             LOC_REFERENCE,LOC_CREFERENCE:
               begin
               begin
                  if locpara.sp_fixup<>0 then
                  if locpara.sp_fixup<>0 then
-                   begin
-                      t.enum:=R_INTREGISTER;;
-                      t.number:=NR_STACK_POINTER_REG;
-                      a_op_const_reg(list,OP_ADD,OS_ADDR,locpara.sp_fixup,t);
-                   end;
+                   a_op_const_reg(list,OP_ADD,OS_ADDR,locpara.sp_fixup,NR_STACK_POINTER_REG);
                  reference_reset(ref);
                  reference_reset(ref);
                  ref.base:=locpara.reference.index;
                  ref.base:=locpara.reference.index;
                  ref.offset:=locpara.reference.offset;
                  ref.offset:=locpara.reference.offset;
@@ -631,36 +542,20 @@ unit cgobj;
          hr : tregister;
          hr : tregister;
 
 
       begin
       begin
-      {$ifdef newra}
          hr:=rg.getregisterint(list,size);
          hr:=rg.getregisterint(list,size);
-      {$else}
-         hr:=get_scratch_reg_int(list,size);
-      {$endif}
          a_load_const_reg(list,size,a,hr);
          a_load_const_reg(list,size,a,hr);
          a_param_reg(list,size,hr,locpara);
          a_param_reg(list,size,hr,locpara);
-      {$ifdef newra}
          rg.ungetregisterint(list,hr);
          rg.ungetregisterint(list,hr);
-      {$else}
-         free_scratch_reg(list,hr);
-      {$endif}
       end;
       end;
 
 
     procedure tcg.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);
     procedure tcg.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);
       var
       var
          hr : tregister;
          hr : tregister;
       begin
       begin
-      {$ifdef newra}
          hr:=rg.getregisterint(list,size);
          hr:=rg.getregisterint(list,size);
-      {$else}
-         hr:=get_scratch_reg_int(list,size);
-      {$endif}
          a_load_ref_reg(list,size,size,r,hr);
          a_load_ref_reg(list,size,size,r,hr);
          a_param_reg(list,size,hr,locpara);
          a_param_reg(list,size,hr,locpara);
-      {$ifdef newra}
          rg.ungetregisterint(list,hr);
          rg.ungetregisterint(list,hr);
-      {$else}
-         free_scratch_reg(list,hr);
-      {$endif}
       end;
       end;
 
 
 
 
@@ -685,18 +580,10 @@ unit cgobj;
       var
       var
          hr : tregister;
          hr : tregister;
       begin
       begin
-      {$ifdef newra}
          hr:=rg.getaddressregister(list);
          hr:=rg.getaddressregister(list);
-      {$else newra}
-         hr:=get_scratch_reg_address(list);
-      {$endif}
          a_loadaddr_ref_reg(list,r,hr);
          a_loadaddr_ref_reg(list,r,hr);
          a_param_reg(list,OS_ADDR,hr,locpara);
          a_param_reg(list,OS_ADDR,hr,locpara);
-      {$ifdef newra}
          rg.ungetregisterint(list,hr);
          rg.ungetregisterint(list,hr);
-      {$else}
-         free_scratch_reg(list,hr);
-      {$endif}
       end;
       end;
 
 
 
 
@@ -721,24 +608,20 @@ unit cgobj;
             begin
             begin
               if (locpara.size in [OS_S64,OS_64]) then
               if (locpara.size in [OS_S64,OS_64]) then
                 begin
                 begin
-{$ifdef newra}
-{$ifdef cpu64bit} 
+{$ifdef cpu64bit}
                   rg.ungetregisterint(list,locpara.register64);
                   rg.ungetregisterint(list,locpara.register64);
 {$else cpu64bit}
 {$else cpu64bit}
-                  rg.getexplicitregisterint(list,locpara.registerlow.number);
-                  rg.getexplicitregisterint(list,locpara.registerhigh.number);
+                  rg.getexplicitregisterint(list,locpara.registerlow);
+                  rg.getexplicitregisterint(list,locpara.registerhigh);
                   rg.ungetregisterint(list,locpara.registerlow);
                   rg.ungetregisterint(list,locpara.registerlow);
                   rg.ungetregisterint(list,locpara.registerhigh);
                   rg.ungetregisterint(list,locpara.registerhigh);
 {$endif cpu64bit}
 {$endif cpu64bit}
-{$endif newra}
                   cg64.a_load64_reg_ref(list,locpara.register64,ref)
                   cg64.a_load64_reg_ref(list,locpara.register64,ref)
                 end
                 end
               else
               else
                 begin
                 begin
-{$ifdef newra}
-                  rg.getexplicitregisterint(list,locpara.register.number);
+                  rg.getexplicitregisterint(list,locpara.register);
                   rg.ungetregisterint(list,locpara.register);
                   rg.ungetregisterint(list,locpara.register);
-{$endif newra}
                   cg.a_load_reg_ref(list,locpara.size,locpara.size,locpara.register,ref);
                   cg.a_load_reg_ref(list,locpara.size,locpara.size,locpara.register,ref);
                 end;
                 end;
             end;
             end;
@@ -761,11 +644,9 @@ unit cgobj;
             begin
             begin
               if not(locpara.size in [OS_S64,OS_64]) then
               if not(locpara.size in [OS_S64,OS_64]) then
                 begin
                 begin
-{$ifdef newra}
-                  rg.getexplicitregisterint(list,locpara.register.number);
+                  rg.getexplicitregisterint(list,locpara.register);
                   rg.ungetregisterint(list,locpara.register);
                   rg.ungetregisterint(list,locpara.register);
-                  rg.getexplicitregisterint(list,reg.number);
-{$endif newra}
+                  rg.getexplicitregisterint(list,reg);
                   cg.a_load_reg_reg(list,locpara.size,locpara.size,locpara.register,reg)
                   cg.a_load_reg_reg(list,locpara.size,locpara.size,locpara.register,reg)
                 end
                 end
               else
               else
@@ -778,9 +659,7 @@ unit cgobj;
           LOC_CREFERENCE:
           LOC_CREFERENCE:
             begin
             begin
               reference_reset_base(href,locpara.reference.index,locpara.reference.offset);
               reference_reset_base(href,locpara.reference.index,locpara.reference.offset);
-{$ifdef newra}
-              rg.getexplicitregisterint(list,reg.number);
-{$endif newra}
+              rg.getexplicitregisterint(list,reg);
               cg.a_load_ref_reg(list,locpara.size,locpara.size,href,reg);
               cg.a_load_ref_reg(list,locpara.size,locpara.size,href,reg);
             end;
             end;
           else
           else
@@ -794,94 +673,27 @@ unit cgobj;
 ****************************************************************************}
 ****************************************************************************}
 
 
     procedure tcg.a_load_ref_ref(list : taasmoutput;fromsize,tosize : tcgsize;const sref : treference;const dref : treference);
     procedure tcg.a_load_ref_ref(list : taasmoutput;fromsize,tosize : tcgsize;const sref : treference;const dref : treference);
-
       var
       var
         tmpreg: tregister;
         tmpreg: tregister;
-{$ifdef i386}
-        pushed_reg: tregister;
-{$endif i386}
-
       begin
       begin
         { verify if we have the same reference }
         { verify if we have the same reference }
         if references_equal(sref,dref) then
         if references_equal(sref,dref) then
           exit;
           exit;
-{$ifdef i386}
-        { the following is done with defines to avoid a speed penalty,  }
-        { since all this is only necessary for the 80x86 (because EDI   }
-        { doesn't have an 8bit component which is directly addressable) }
-        pushed_reg.enum:=R_INTREGISTER;
-        pushed_reg.number:=NR_NO;
-        if tosize in [OS_8,OS_S8] then
-        {$ifndef newra}
-          if (rg.countunusedregsint = 0) then
-            begin
-              if (dref.base.enum<>R_NO) and (dref.base.enum<>R_INTREGISTER) then
-                internalerror(200302037);
-              if (dref.index.enum<>R_NO) and (dref.index.enum<>R_INTREGISTER) then
-                internalerror(200302037);
-
-              if (dref.base.number shr 8<>RS_EBX) and
-                 (dref.index.number shr 8<>RS_EBX) then
-                pushed_reg.number:=NR_EBX
-              else if (dref.base.number<>RS_EAX) and
-                      (dref.index.number<>RS_EAX) then
-                pushed_reg.number:=NR_EAX
-              else
-                pushed_reg.number:=NR_ECX;
-              tmpreg.enum:=R_INTREGISTER;
-              tmpreg.number:=(pushed_reg.number and not $ff) or R_SUBL;
-              list.concat(taicpu.op_reg(A_PUSH,S_L,pushed_reg));
-            end
-          else
-        {$endif}
-            tmpreg := rg.getregisterint(list,tosize)
-        else
-{$endif i386}
-{$ifdef newra}
         tmpreg:=rg.getregisterint(list,tosize);
         tmpreg:=rg.getregisterint(list,tosize);
-{$else}
-        tmpreg := get_scratch_reg_int(list,tosize);
-{$endif}
         a_load_ref_reg(list,fromsize,tosize,sref,tmpreg);
         a_load_ref_reg(list,fromsize,tosize,sref,tmpreg);
         a_load_reg_ref(list,tosize,tosize,tmpreg,dref);
         a_load_reg_ref(list,tosize,tosize,tmpreg,dref);
-{$ifdef i386}
-{$ifndef newra}
-        if tosize in [OS_8,OS_S8] then
-          begin
-            if (pushed_reg.number<>NR_NO) then
-              list.concat(taicpu.op_reg(A_POP,S_L,pushed_reg))
-            else
-              rg.ungetregisterint(list,tmpreg)
-          end
-        else
-{$endif}
-{$endif i386}
-{$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
         rg.ungetregisterint(list,tmpreg);
-{$else}
-        free_scratch_reg(list,tmpreg);
-{$endif}
       end;
       end;
 
 
 
 
     procedure tcg.a_load_const_ref(list : taasmoutput;size : tcgsize;a : aword;const ref : treference);
     procedure tcg.a_load_const_ref(list : taasmoutput;size : tcgsize;a : aword;const ref : treference);
-
       var
       var
         tmpreg: tregister;
         tmpreg: tregister;
-
       begin
       begin
-{$ifdef newra}
         tmpreg:=rg.getregisterint(list,size);
         tmpreg:=rg.getregisterint(list,size);
-{$else}
-        tmpreg := get_scratch_reg_int(list,size);
-{$endif}
         a_load_const_reg(list,size,a,tmpreg);
         a_load_const_reg(list,size,a,tmpreg);
         a_load_reg_ref(list,size,size,tmpreg,ref);
         a_load_reg_ref(list,size,size,tmpreg,ref);
-{$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
         rg.ungetregisterint(list,tmpreg);
-{$else}
-        free_scratch_reg(list,tmpreg);
-{$endif}
       end;
       end;
 
 
 
 
@@ -912,7 +724,6 @@ unit cgobj;
 
 
 
 
     procedure tcg.a_load_loc_reg(list : taasmoutput; tosize: tcgsize; const loc: tlocation; reg : tregister);
     procedure tcg.a_load_loc_reg(list : taasmoutput; tosize: tcgsize; const loc: tlocation; reg : tregister);
-
       begin
       begin
         case loc.loc of
         case loc.loc of
           LOC_REFERENCE,LOC_CREFERENCE:
           LOC_REFERENCE,LOC_CREFERENCE:
@@ -928,7 +739,6 @@ unit cgobj;
 
 
 
 
     procedure tcg.a_load_loc_ref(list : taasmoutput;tosize: tcgsize; const loc: tlocation; const ref : treference);
     procedure tcg.a_load_loc_ref(list : taasmoutput;tosize: tcgsize; const loc: tlocation; const ref : treference);
-
       begin
       begin
         case loc.loc of
         case loc.loc of
           LOC_REFERENCE,LOC_CREFERENCE:
           LOC_REFERENCE,LOC_CREFERENCE:
@@ -947,18 +757,10 @@ unit cgobj;
       var
       var
         tmpreg: tregister;
         tmpreg: tregister;
       begin
       begin
-{$ifdef newra}
         tmpreg:=rg.getaddressregister(list);
         tmpreg:=rg.getaddressregister(list);
-{$else}
-        tmpreg := get_scratch_reg_address(list);
-{$endif}
         a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,tmpreg);
         a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,tmpreg);
         a_call_reg(list,tmpreg);
         a_call_reg(list,tmpreg);
-{$ifdef newra}
         rg.ungetaddressregister(list,tmpreg);
         rg.ungetaddressregister(list,tmpreg);
-{$else}
-        free_scratch_reg(list,tmpreg);
-{$endif}
       end;
       end;
 
 
 
 
@@ -1028,8 +830,8 @@ unit cgobj;
         end;
         end;
       end;
       end;
 
 
-    procedure tcg.a_loadfpu_loc_reg(list: taasmoutput; const loc: tlocation; const reg: tregister);
 
 
+    procedure tcg.a_loadfpu_loc_reg(list: taasmoutput; const loc: tlocation; const reg: tregister);
       begin
       begin
         case loc.loc of
         case loc.loc of
           LOC_REFERENCE, LOC_CREFERENCE:
           LOC_REFERENCE, LOC_CREFERENCE:
@@ -1043,7 +845,6 @@ unit cgobj;
 
 
 
 
     procedure tcg.a_loadfpu_reg_loc(list: taasmoutput; size: tcgsize; const reg: tregister; const loc: tlocation);
     procedure tcg.a_loadfpu_reg_loc(list: taasmoutput; size: tcgsize; const reg: tregister; const loc: tlocation);
-
       begin
       begin
         case loc.loc of
         case loc.loc of
           LOC_REFERENCE, LOC_CREFERENCE:
           LOC_REFERENCE, LOC_CREFERENCE:
@@ -1057,11 +858,8 @@ unit cgobj;
 
 
 
 
     procedure tcg.a_paramfpu_reg(list : taasmoutput;size : tcgsize;const r : tregister;const locpara : tparalocation);
     procedure tcg.a_paramfpu_reg(list : taasmoutput;size : tcgsize;const r : tregister;const locpara : tparalocation);
-
       var
       var
          ref : treference;
          ref : treference;
-         t : Tregister;
-
       begin
       begin
          case locpara.loc of
          case locpara.loc of
             LOC_FPUREGISTER,LOC_CFPUREGISTER:
             LOC_FPUREGISTER,LOC_CFPUREGISTER:
@@ -1069,11 +867,7 @@ unit cgobj;
             LOC_REFERENCE,LOC_CREFERENCE:
             LOC_REFERENCE,LOC_CREFERENCE:
               begin
               begin
                  if locpara.sp_fixup<>0 then
                  if locpara.sp_fixup<>0 then
-                   begin
-                      t.enum:=R_INTREGISTER;
-                      t.number:=NR_STACK_POINTER_REG;
-                      a_op_const_reg(list,OP_ADD,OS_ADDR,locpara.sp_fixup,t);
-                   end;
+                   a_op_const_reg(list,OP_ADD,OS_ADDR,locpara.sp_fixup,NR_STACK_POINTER_REG);
                  reference_reset(ref);
                  reference_reset(ref);
                  ref.base:=locpara.reference.index;
                  ref.base:=locpara.reference.index;
                  ref.offset:=locpara.reference.offset;
                  ref.offset:=locpara.reference.offset;
@@ -1102,19 +896,11 @@ unit cgobj;
         tmpreg: tregister;
         tmpreg: tregister;
 
 
       begin
       begin
-      {$ifdef newra}
         tmpreg:=rg.getregisterint(list,size);
         tmpreg:=rg.getregisterint(list,size);
-      {$else}
-        tmpreg := get_scratch_reg_int(list,size);
-      {$endif}
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_op_const_reg(list,op,size,a,tmpreg);
         a_op_const_reg(list,op,size,a,tmpreg);
         a_load_reg_ref(list,size,size,tmpreg,ref);
         a_load_reg_ref(list,size,size,tmpreg,ref);
-      {$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
         rg.ungetregisterint(list,tmpreg);
-      {$else}
-        free_scratch_reg(list,tmpreg);
-      {$endif}
       end;
       end;
 
 
 
 
@@ -1138,19 +924,11 @@ unit cgobj;
         tmpreg: tregister;
         tmpreg: tregister;
 
 
       begin
       begin
-      {$ifdef newra}
         tmpreg:=rg.getregisterint(list,size);
         tmpreg:=rg.getregisterint(list,size);
-      {$else}
-        tmpreg := get_scratch_reg_int(list,size);
-      {$endif}
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_op_reg_reg(list,op,size,reg,tmpreg);
         a_op_reg_reg(list,op,size,reg,tmpreg);
         a_load_reg_ref(list,size,size,tmpreg,ref);
         a_load_reg_ref(list,size,size,tmpreg,ref);
-      {$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
         rg.ungetregisterint(list,tmpreg);
-      {$else}
-        free_scratch_reg(list,tmpreg);
-      {$endif}
       end;
       end;
 
 
 
 
@@ -1169,18 +947,10 @@ unit cgobj;
             end;
             end;
           else
           else
             begin
             begin
-            {$ifdef newra}
               tmpreg:=rg.getregisterint(list,size);
               tmpreg:=rg.getregisterint(list,size);
-            {$else}
-              tmpreg := get_scratch_reg_int(list,size);
-            {$endif}
               a_load_ref_reg(list,size,size,ref,tmpreg);
               a_load_ref_reg(list,size,size,ref,tmpreg);
               a_op_reg_reg(list,op,size,tmpreg,reg);
               a_op_reg_reg(list,op,size,tmpreg,reg);
-            {$ifdef newra}
               rg.ungetregisterint(list,tmpreg);
               rg.ungetregisterint(list,tmpreg);
-            {$else}
-              free_scratch_reg(list,tmpreg);
-            {$endif}
             end;
             end;
         end;
         end;
       end;
       end;
@@ -1211,18 +981,10 @@ unit cgobj;
             a_op_ref_reg(list,op,loc.size,ref,loc.register);
             a_op_ref_reg(list,op,loc.size,ref,loc.register);
           LOC_REFERENCE,LOC_CREFERENCE:
           LOC_REFERENCE,LOC_CREFERENCE:
             begin
             begin
-            {$ifdef newra}
               tmpreg:=rg.getregisterint(list,loc.size);
               tmpreg:=rg.getregisterint(list,loc.size);
-            {$else}
-              tmpreg := get_scratch_reg_int(list,loc.size);
-            {$endif}
               a_load_ref_reg(list,loc.size,loc.size,ref,tmpreg);
               a_load_ref_reg(list,loc.size,loc.size,ref,tmpreg);
               a_op_reg_ref(list,op,loc.size,tmpreg,loc.reference);
               a_op_reg_ref(list,op,loc.size,tmpreg,loc.reference);
-            {$ifdef newra}
               rg.ungetregisterint(list,tmpreg);
               rg.ungetregisterint(list,tmpreg);
-            {$else}
-              free_scratch_reg(list,tmpreg);
-            {$endif}
             end;
             end;
           else
           else
             internalerror(200109061);
             internalerror(200109061);
@@ -1238,27 +1000,21 @@ unit cgobj;
 
 
     procedure tcg.a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
     procedure tcg.a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
         size: tcgsize; src1, src2, dst: tregister);
         size: tcgsize; src1, src2, dst: tregister);
-{$ifdef newra}
       var
       var
         tmpreg: tregister;
         tmpreg: tregister;
-{$endif newra}
       begin
       begin
-        if (dst.number <> src1.number) then
+        if (dst<>src1) then
           begin
           begin
             a_load_reg_reg(list,size,size,src2,dst);
             a_load_reg_reg(list,size,size,src2,dst);
             a_op_reg_reg(list,op,size,src1,dst);
             a_op_reg_reg(list,op,size,src1,dst);
           end
           end
         else
         else
           begin
           begin
-{$ifdef newra}
             tmpreg := rg.getregisterint(list,size);
             tmpreg := rg.getregisterint(list,size);
             a_load_reg_reg(list,size,size,src2,tmpreg);
             a_load_reg_reg(list,size,size,src2,tmpreg);
             a_op_reg_reg(list,op,size,src1,tmpreg);
             a_op_reg_reg(list,op,size,src1,tmpreg);
             a_load_reg_reg(list,size,size,tmpreg,dst);
             a_load_reg_reg(list,size,size,tmpreg,dst);
             rg.ungetregisterint(list,tmpreg);
             rg.ungetregisterint(list,tmpreg);
-{$else newra}
-            internalerror(200305011);
-{$endif newra}
           end;
           end;
       end;
       end;
 
 
@@ -1271,18 +1027,10 @@ unit cgobj;
         tmpreg: tregister;
         tmpreg: tregister;
 
 
       begin
       begin
-      {$ifdef newra}
         tmpreg:=rg.getregisterint(list,size);
         tmpreg:=rg.getregisterint(list,size);
-      {$else}
-        tmpreg := get_scratch_reg_int(list,size);
-      {$endif}
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_cmp_const_reg_label(list,size,cmp_op,a,tmpreg,l);
         a_cmp_const_reg_label(list,size,cmp_op,a,tmpreg,l);
-      {$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
         rg.ungetregisterint(list,tmpreg);
-      {$else}
-        free_scratch_reg(list,tmpreg);
-      {$endif}
       end;
       end;
 
 
     procedure tcg.a_cmp_const_loc_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;const loc : tlocation;
     procedure tcg.a_cmp_const_loc_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;const loc : tlocation;
@@ -1305,18 +1053,10 @@ unit cgobj;
         tmpreg: tregister;
         tmpreg: tregister;
 
 
       begin
       begin
-      {$ifdef newra}
         tmpreg:=rg.getregisterint(list,size);
         tmpreg:=rg.getregisterint(list,size);
-      {$else}
-        tmpreg := get_scratch_reg_int(list,size);
-      {$endif}
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_cmp_reg_reg_label(list,size,cmp_op,tmpreg,reg,l);
         a_cmp_reg_reg_label(list,size,cmp_op,tmpreg,reg,l);
-      {$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
         rg.ungetregisterint(list,tmpreg);
-      {$else}
-        free_scratch_reg(list,tmpreg);
-      {$endif}
       end;
       end;
 
 
     procedure tcg.a_cmp_loc_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const loc: tlocation; reg : tregister; l : tasmlabel);
     procedure tcg.a_cmp_loc_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const loc: tlocation; reg : tregister; l : tasmlabel);
@@ -1348,30 +1088,10 @@ unit cgobj;
             a_cmp_ref_reg_label(list,size,cmp_op,ref,loc.register,l);
             a_cmp_ref_reg_label(list,size,cmp_op,ref,loc.register,l);
           LOC_REFERENCE,LOC_CREFERENCE:
           LOC_REFERENCE,LOC_CREFERENCE:
             begin
             begin
-{$ifdef newra}
               tmpreg := rg.getregisterint(list,size);
               tmpreg := rg.getregisterint(list,size);
               a_load_ref_reg(list,size,size,loc.reference,tmpreg);
               a_load_ref_reg(list,size,size,loc.reference,tmpreg);
               a_cmp_ref_reg_label(list,size,cmp_op,ref,tmpreg,l);
               a_cmp_ref_reg_label(list,size,cmp_op,ref,tmpreg,l);
               rg.ungetregisterint(list,tmpreg);
               rg.ungetregisterint(list,tmpreg);
-{$else newra}
-{$ifdef i386}
-              { the following is done with defines to avoid a speed penalty,  }
-              { since all this is only necessary for the 80x86 (because EDI   }
-              { doesn't have an 8bit component which is directly addressable) }
-              if size in [OS_8,OS_S8] then
-                tmpreg := rg.getregisterint(list,size)
-              else
-{$endif i386}
-                tmpreg := get_scratch_reg_int(list,size);
-              a_load_ref_reg(list,size,size,loc.reference,tmpreg);
-              a_cmp_ref_reg_label(list,size,cmp_op,ref,tmpreg,l);
-{$ifdef i386}
-              if size in [OS_8,OS_S8] then
-                rg.ungetregisterint(list,tmpreg)
-              else
-{$endif i386}
-                free_scratch_reg(list,tmpreg);
-{$endif newra}
             end
             end
           else
           else
             internalerror(200109061);
             internalerror(200109061);
@@ -1426,13 +1146,9 @@ unit cgobj;
         paramanager.freeintparaloc(list,3);
         paramanager.freeintparaloc(list,3);
         paramanager.freeintparaloc(list,2);
         paramanager.freeintparaloc(list,2);
         paramanager.freeintparaloc(list,1);
         paramanager.freeintparaloc(list,1);
-{$ifdef newra}
         rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
         rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
         a_call_name(list,'FPC_SHORTSTR_ASSIGN');
         a_call_name(list,'FPC_SHORTSTR_ASSIGN');
-{$ifdef newra}
         rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
         rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
       end;
       end;
 
 
 
 
@@ -1459,13 +1175,9 @@ unit cgobj;
             { these functions get the pointer by value }
             { these functions get the pointer by value }
             a_param_ref(list,OS_ADDR,ref,paramanager.getintparaloc(list,1));
             a_param_ref(list,OS_ADDR,ref,paramanager.getintparaloc(list,1));
             paramanager.freeintparaloc(list,1);
             paramanager.freeintparaloc(list,1);
-{$ifdef newra}
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             a_call_name(list,incrfunc);
             a_call_name(list,incrfunc);
-{$ifdef newra}
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
           end
           end
          else
          else
           begin
           begin
@@ -1477,13 +1189,9 @@ unit cgobj;
               a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
               a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
             paramanager.freeintparaloc(list,1);
             paramanager.freeintparaloc(list,1);
             paramanager.freeintparaloc(list,2);
             paramanager.freeintparaloc(list,2);
-{$ifdef newra}
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             a_call_name(list,'FPC_ADDREF');
             a_call_name(list,'FPC_ADDREF');
-{$ifdef newra}
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
          end;
          end;
       end;
       end;
 
 
@@ -1521,13 +1229,9 @@ unit cgobj;
             else
             else
               a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
               a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
             paramanager.freeintparaloc(list,1);
             paramanager.freeintparaloc(list,1);
-{$ifdef newra}
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             a_call_name(list,decrfunc);
             a_call_name(list,decrfunc);
-{$ifdef newra}
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             if needrtti then
             if needrtti then
               paramanager.freeintparaloc(list,2);
               paramanager.freeintparaloc(list,2);
           end
           end
@@ -1541,13 +1245,9 @@ unit cgobj;
               a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
               a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
             paramanager.freeintparaloc(list,1);
             paramanager.freeintparaloc(list,1);
             paramanager.freeintparaloc(list,2);
             paramanager.freeintparaloc(list,2);
-{$ifdef newra}
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             a_call_name(list,'FPC_DECREF');
             a_call_name(list,'FPC_DECREF');
-{$ifdef newra}
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
          end;
          end;
       end;
       end;
 
 
@@ -1570,13 +1270,9 @@ unit cgobj;
                 a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
                 a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
               paramanager.freeintparaloc(list,1);
               paramanager.freeintparaloc(list,1);
               paramanager.freeintparaloc(list,2);
               paramanager.freeintparaloc(list,2);
-{$ifdef newra}
               rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
               a_call_name(list,'FPC_INITIALIZE');
               a_call_name(list,'FPC_INITIALIZE');
-{$ifdef newra}
               rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
            end;
            end;
       end;
       end;
 
 
@@ -1599,13 +1295,9 @@ unit cgobj;
                 a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
                 a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
               paramanager.freeintparaloc(list,1);
               paramanager.freeintparaloc(list,1);
               paramanager.freeintparaloc(list,2);
               paramanager.freeintparaloc(list,2);
-{$ifdef newra}
               rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
               a_call_name(list,'FPC_FINALIZE');
               a_call_name(list,'FPC_FINALIZE');
-{$ifdef newra}
               rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
            end;
            end;
       end;
       end;
 
 
@@ -1708,21 +1400,13 @@ unit cgobj;
               if lto < 0 then
               if lto < 0 then
                 lto := 0;
                 lto := 0;
             end;
             end;
-{$ifdef newra}
         hreg:=rg.getregisterint(list,OS_INT);
         hreg:=rg.getregisterint(list,OS_INT);
-{$else}
-        hreg:=get_scratch_reg_int(list,OS_INT);
-{$endif}
         a_load_loc_reg(list,OS_INT,l,hreg);
         a_load_loc_reg(list,OS_INT,l,hreg);
         a_op_const_reg(list,OP_SUB,OS_INT,aword(lto),hreg);
         a_op_const_reg(list,OP_SUB,OS_INT,aword(lto),hreg);
         objectlibrary.getlabel(neglabel);
         objectlibrary.getlabel(neglabel);
         a_cmp_const_reg_label(list,OS_INT,OC_BE,aword(hto-lto),hreg,neglabel);
         a_cmp_const_reg_label(list,OS_INT,OC_BE,aword(hto-lto),hreg,neglabel);
         { !!! should happen right after the compare (JM) }
         { !!! should happen right after the compare (JM) }
-{$ifdef newra}
         rg.ungetregisterint(list,hreg);
         rg.ungetregisterint(list,hreg);
-{$else}
-        free_scratch_reg(list,hreg);
-{$endif}
         a_call_name(list,'FPC_RANGEERROR');
         a_call_name(list,'FPC_RANGEERROR');
         a_label(list,neglabel);
         a_label(list,neglabel);
       end;
       end;
@@ -1742,18 +1426,10 @@ unit cgobj;
       var
       var
         tmpreg : tregister;
         tmpreg : tregister;
       begin
       begin
-      {$ifdef newra}
         tmpreg:=rg.getregisterint(list,size);
         tmpreg:=rg.getregisterint(list,size);
-      {$else}
-        tmpreg := get_scratch_reg_int(list,size);
-      {$endif}
         g_flags2reg(list,size,f,tmpreg);
         g_flags2reg(list,size,f,tmpreg);
         a_load_reg_ref(list,size,size,tmpreg,ref);
         a_load_reg_ref(list,size,size,tmpreg,ref);
-      {$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
         rg.ungetregisterint(list,tmpreg);
-      {$else}
-        free_scratch_reg(list,tmpreg);
-      {$endif}
       end;
       end;
 
 
 
 
@@ -1785,26 +1461,18 @@ unit cgobj;
            a_param_reg(list,OS_ADDR,reg,paramanager.getintparaloc(list,1));
            a_param_reg(list,OS_ADDR,reg,paramanager.getintparaloc(list,1));
            paramanager.freeintparaloc(list,2);
            paramanager.freeintparaloc(list,2);
            paramanager.freeintparaloc(list,1);
            paramanager.freeintparaloc(list,1);
-{$ifdef newra}
            rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
            rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
            a_call_name(list,'FPC_CHECK_OBJECT_EXT');
            a_call_name(list,'FPC_CHECK_OBJECT_EXT');
-{$ifdef newra}
            rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
            rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
          end
          end
         else
         else
          if (cs_check_range in aktlocalswitches) then
          if (cs_check_range in aktlocalswitches) then
           begin
           begin
             a_param_reg(list,OS_ADDR,reg,paramanager.getintparaloc(list,1));
             a_param_reg(list,OS_ADDR,reg,paramanager.getintparaloc(list,1));
             paramanager.freeintparaloc(list,1);
             paramanager.freeintparaloc(list,1);
-{$ifdef newra}
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             a_call_name(list,'FPC_CHECK_OBJECT');
             a_call_name(list,'FPC_CHECK_OBJECT');
-{$ifdef newra}
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
           end;
           end;
       end;
       end;
 
 
@@ -1813,91 +1481,6 @@ unit cgobj;
                             Entry/Exit Code Functions
                             Entry/Exit Code Functions
 *****************************************************************************}
 *****************************************************************************}
 
 
-{    procedure tcg.g_copyvaluepara_openarray(list : taasmoutput;const arrayloc,lenloc : tparalocation;elesize:integer);
-      var
-        power,len  : longint;
-        opsize : topsize;
-        r,r2,rsp:Tregister;
-      begin
-      {
-        { get stack space }
-        r.enum:=R_INTREGISTER;
-        r.number:=NR_EDI;
-        rsp.enum:=R_INTREGISTER;
-        rsp.number:=NR_ESP;
-        r2.enum:=R_INTREGISTER;
-        rg.getexplicitregisterint(list,NR_EDI);
-        list.concat(Taicpu.op_ref_reg(A_MOV,S_L,lenref,r));
-        list.concat(Taicpu.op_reg(A_INC,S_L,r));
-        if (elesize<>1) then
-         begin
-           if ispowerof2(elesize, power) then
-             list.concat(Taicpu.op_const_reg(A_SHL,S_L,power,r))
-           else
-             list.concat(Taicpu.op_const_reg(A_IMUL,S_L,elesize,r));
-         end;
-        list.concat(Taicpu.op_reg_reg(A_SUB,S_L,r,rsp));
-        { align stack on 4 bytes }
-        list.concat(Taicpu.op_const_reg(A_AND,S_L,$fffffff4,rsp));
-        { load destination }
-        a_load_reg_reg(list,OS_INT,OS_INT,rsp,r);
-
-        { don't destroy the registers! }
-        r2.number:=NR_ECX;
-        list.concat(Taicpu.op_reg(A_PUSH,S_L,r2));
-        r2.number:=NR_ESI;
-        list.concat(Taicpu.op_reg(A_PUSH,S_L,r2));
-
-        { load count }
-        r2.number:=NR_ECX;
-        a_load_ref_reg(list,OS_INT,OS_INT,lenref,r2);
-
-        { load source }
-        r2.number:=NR_ESI;
-        a_load_ref_reg(list,OS_INT,OS_INT,ref,r2);
-
-        { scheduled .... }
-        r2.number:=NR_ECX;
-        list.concat(Taicpu.op_reg(A_INC,S_L,r2));
-
-        { calculate size }
-        len:=elesize;
-        opsize:=S_B;
-        if (len and 3)=0 then
-         begin
-           opsize:=S_L;
-           len:=len shr 2;
-         end
-        else
-         if (len and 1)=0 then
-          begin
-            opsize:=S_W;
-            len:=len shr 1;
-          end;
-
-        if ispowerof2(len, power) then
-          list.concat(Taicpu.op_const_reg(A_SHL,S_L,power,r2))
-        else
-          list.concat(Taicpu.op_const_reg(A_IMUL,S_L,len,r2));
-        list.concat(Taicpu.op_none(A_REP,S_NO));
-        case opsize of
-          S_B : list.concat(Taicpu.Op_none(A_MOVSB,S_NO));
-          S_W : list.concat(Taicpu.Op_none(A_MOVSW,S_NO));
-          S_L : list.concat(Taicpu.Op_none(A_MOVSD,S_NO));
-        end;
-        rg.ungetregisterint(list,r);
-        r2.number:=NR_ESI;
-        list.concat(Taicpu.op_reg(A_POP,S_L,r2));
-        r2.number:=NR_ECX;
-        list.concat(Taicpu.op_reg(A_POP,S_L,r2));
-
-        { patch the new address }
-        a_load_reg_ref(list,OS_INT,OS_INT,rsp,ref);
-      }
-      end;
-
-}
-
     procedure tcg.g_interrupt_stackframe_entry(list : taasmoutput);
     procedure tcg.g_interrupt_stackframe_entry(list : taasmoutput);
       begin
       begin
       end;
       end;
@@ -1914,49 +1497,37 @@ unit cgobj;
 
 
 
 
     procedure tcg.g_exception_reason_save(list : taasmoutput; const href : treference);
     procedure tcg.g_exception_reason_save(list : taasmoutput; const href : treference);
-
-    var r:Tregister;
-
-     begin
-       r.enum:=R_INTREGISTER;;
-       r.number:=NR_FUNCTION_RETURN_REG;
-       a_load_reg_ref(list, OS_S32, OS_32, r, href);
-     end;
+      begin
+        a_load_reg_ref(list, OS_S32, OS_32, NR_FUNCTION_RETURN_REG, href);
+      end;
 
 
 
 
     procedure tcg.g_exception_reason_save_const(list : taasmoutput; const href : treference; a: aword);
     procedure tcg.g_exception_reason_save_const(list : taasmoutput; const href : treference; a: aword);
-     begin
-       a_load_const_ref(list, OS_S32, a, href);
-     end;
+      begin
+        a_load_const_ref(list, OS_S32, a, href);
+      end;
 
 
 
 
     procedure tcg.g_exception_reason_load(list : taasmoutput; const href : treference);
     procedure tcg.g_exception_reason_load(list : taasmoutput; const href : treference);
-
-    var r:Tregister;
-
-     begin
-       r.enum:=R_INTREGISTER;
-       r.number:=NR_FUNCTION_RETURN_REG;
-       a_load_ref_reg(list, OS_S32, OS_S32, href, r);
-     end;
+      begin
+        a_load_ref_reg(list, OS_S32, OS_S32, href, NR_FUNCTION_RETURN_REG);
+      end;
 
 
 
 
-    procedure tcg64.a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword;
-       regsrc,regdst : tregister64);
+    procedure tcg64.a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword; regsrc,regdst : tregister64);
       begin
       begin
-        a_load64_reg_reg(list,regsrc,regdst{$ifdef newra},false{$endif});
+        a_load64_reg_reg(list,regsrc,regdst,false);
         a_op64_const_reg(list,op,value,regdst);
         a_op64_const_reg(list,op,value,regdst);
       end;
       end;
 
 
 
 
     procedure tcg64.a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);
     procedure tcg64.a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);
       begin
       begin
-        a_load64_reg_reg(list,regsrc2,regdst{$ifdef newra},false{$endif});
+        a_load64_reg_reg(list,regsrc2,regdst,false);
         a_op64_reg_reg(list,op,regsrc1,regdst);
         a_op64_reg_reg(list,op,regsrc1,regdst);
       end;
       end;
 
 
 
 
-
 initialization
 initialization
     ;
     ;
 finalization
 finalization
@@ -1965,13 +1536,28 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.117  2003-09-03 11:18:36  florian
+  Revision 1.118  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.117  2003/09/03 11:18:36  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.116.2.4  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.116.2.3  2003/08/28 18:35:07  peter
+    * tregister changed to cardinal
+
+  Revision 1.116.2.2  2003/08/27 20:23:55  peter
+    * remove old ra code
+
+  Revision 1.116.2.1  2003/08/27 19:55:54  peter
+    * first tregister patch
+
   Revision 1.116  2003/08/17 16:59:20  jonas
   Revision 1.116  2003/08/17 16:59:20  jonas
     * fixed regvars so they work with newra (at least for ppc)
     * fixed regvars so they work with newra (at least for ppc)
     * fixed some volatile register bugs
     * fixed some volatile register bugs

+ 22 - 16
compiler/cutils.pas

@@ -363,12 +363,18 @@ uses
     {
     {
       return string of value i, but for cardinals
       return string of value i, but for cardinals
     }
     }
-       var
-         hs : string;
-       begin
-         str(i,hs);
-         tostru:=hs;
-       end;
+      begin
+        str(i,result);
+      end;
+
+
+   function tostr(i : longint) : string;
+   {
+     return string of value i
+   }
+     begin
+       str(i,result);
+     end;
 
 
 
 
     function DStr(l:longint):string;
     function DStr(l:longint):string;
@@ -495,15 +501,6 @@ uses
       end;
       end;
 
 
 
 
-   function tostr(i : longint) : string;
-   {
-     return string of value i
-   }
-     begin
-        str(i,result);
-     end;
-
-
    function realtostr(e:extended):string;
    function realtostr(e:extended):string;
      begin
      begin
         str(e,result);
         str(e,result);
@@ -866,7 +863,16 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.27  2003-07-05 20:06:28  jonas
+  Revision 1.28  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.27.2.2  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.27.2.1  2003/08/29 09:41:25  daniel
+    * Further mkx86reg development
+
+  Revision 1.27  2003/07/05 20:06:28  jonas
     * fixed some range check errors that occurred on big endian systems
     * fixed some range check errors that occurred on big endian systems
     * slightly optimized the swap*() functions
     * slightly optimized the swap*() functions
 
 

+ 22 - 16
compiler/fpcdefs.inc

@@ -38,60 +38,66 @@
 
 
 {$ifdef i386}
 {$ifdef i386}
   {$ifdef delphi}
   {$ifdef delphi}
-  {$define oldset}
+    {$define oldset}
   {$endif}
   {$endif}
   {$define x86}
   {$define x86}
   {$define cpuextended}
   {$define cpuextended}
-{$else}
-  {$define oldset}
 {$endif i386}
 {$endif i386}
 
 
 {$ifdef x86_64}
 {$ifdef x86_64}
   {$define x86}
   {$define x86}
   {$define cpu64bit}
   {$define cpu64bit}
   {$define cpuextended}
   {$define cpuextended}
-  {$define callparatemp}
 {$endif x86_64}
 {$endif x86_64}
 
 
 {$ifdef alpha}
 {$ifdef alpha}
   {$define cpu64bit}
   {$define cpu64bit}
   {$undef cpuflags}
   {$undef cpuflags}
-  {$define callparatemp}
+  {$define noopt}
+  {$define oldset}
 {$endif alpha}
 {$endif alpha}
 
 
 {$ifdef sparc}
 {$ifdef sparc}
-  {$define usetempparaloc}
-  { define callparatemp}
+  {$define noopt}
+  {$define oldset}
 {$endif sparc}
 {$endif sparc}
 
 
 {$ifdef powerpc}
 {$ifdef powerpc}
-  {$define callparatemp}
+  {$define noopt}
+  {$define oldset}
 {$endif powerpc}
 {$endif powerpc}
 
 
 {$ifdef arm}
 {$ifdef arm}
-  {$define callparatemp}
   {$define cpuneedsdiv32helper}
   {$define cpuneedsdiv32helper}
+  {$define noopt}
+  {$define oldset}
 {$endif arm}
 {$endif arm}
 
 
-{ FPU Emulator support }
 {$ifdef m68k}
 {$ifdef m68k}
   {$define cpufpemu}
   {$define cpufpemu}
-{$endif m68k}
-
-{ Optimizer is x86 only }
-{$ifndef i386}
   {$define noopt}
   {$define noopt}
-{$endif i386}
+  {$define oldset}
+{$endif m68k}
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.23  2003-09-03 11:18:36  florian
+  Revision 1.24  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.23  2003/09/03 11:18:36  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.22.2.2  2003/08/31 21:07:44  daniel
+    * callparatemp ripped
+
+  Revision 1.22.2.1  2003/08/27 20:11:29  peter
+    * newra default
+
+>>>>>>> 1.22.2.2
   Revision 1.22  2003/08/11 21:18:20  peter
   Revision 1.22  2003/08/11 21:18:20  peter
     * start of sparc support for newra
     * start of sparc support for newra
 
 

+ 4 - 3
compiler/globtype.pas

@@ -165,8 +165,6 @@ interface
        tnormalset = set of byte; { 256 elements set }
        tnormalset = set of byte; { 256 elements set }
        pnormalset = ^tnormalset;
        pnormalset = ^tnormalset;
 
 
-
-
        pboolean   = ^boolean;
        pboolean   = ^boolean;
        pdouble    = ^double;
        pdouble    = ^double;
        pbyte      = ^byte;
        pbyte      = ^byte;
@@ -208,7 +206,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.39  2003-08-09 18:56:54  daniel
+  Revision 1.40  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.39  2003/08/09 18:56:54  daniel
     * cs_regalloc renamed to cs_regvars to avoid confusion with register
     * cs_regalloc renamed to cs_regvars to avoid confusion with register
       allocator
       allocator
     * Some preventive changes to i386 spillinh code
     * Some preventive changes to i386 spillinh code

+ 40 - 145
compiler/i386/ag386int.pas

@@ -46,70 +46,16 @@ interface
         procedure WriteExternals;
         procedure WriteExternals;
       end;
       end;
 
 
-    const
-      regname_count=45;
-      regname_count_bsstart=32;   {Largest power of 2 out of regname_count.}
-     
-      intel_regname2regnum:array[0..regname_count-1] of regname2regnumrec=(
-        (name:'ah';     number:NR_AH),
-        (name:'al';     number:NR_AL),
-        (name:'ax';     number:NR_AX),
-        (name:'bh';     number:NR_BH),
-        (name:'bl';     number:NR_BL),
-        (name:'bp';     number:NR_BP),
-        (name:'bx';     number:NR_BX),
-        (name:'ch';     number:NR_CH),
-        (name:'cl';     number:NR_CL),
-        (name:'cs';     number:NR_CS),
-        (name:'cr0';    number:NR_CR0),
-        (name:'cr2';    number:NR_CR2),
-        (name:'cr3';    number:NR_CR3),
-        (name:'cr4';    number:NR_CR4),
-        (name:'cx';     number:NR_CX),
-        (name:'dh';     number:NR_DH),
-        (name:'dl';     number:NR_DL),
-        (name:'di';     number:NR_DI),
-        (name:'dr0';    number:NR_DR0),
-        (name:'dr1';    number:NR_DR1),
-        (name:'dr2';    number:NR_DR2),
-        (name:'dr3';    number:NR_DR3),
-        (name:'dr6';    number:NR_DR6),
-        (name:'dr7';    number:NR_DR7),
-        (name:'ds';     number:NR_DS),
-        (name:'dx';     number:NR_DX),
-        (name:'eax';    number:NR_EAX),
-        (name:'ebp';    number:NR_EBP),
-        (name:'ebx';    number:NR_EBX),
-        (name:'ecx';    number:NR_ECX),
-        (name:'edi';    number:NR_EDI),
-        (name:'edx';    number:NR_EDX),
-        (name:'es';     number:NR_ES),
-        (name:'esi';    number:NR_ESI),
-        (name:'esp';    number:NR_ESP),
-        (name:'fs';     number:NR_FS),
-        (name:'gs';     number:NR_GS),
-        (name:'si';     number:NR_SI),
-        (name:'sp';     number:NR_SP),
-        (name:'ss';     number:NR_SS),
-        (name:'tr3';    number:NR_DR0),
-        (name:'tr4';    number:NR_DR1),
-        (name:'tr5';    number:NR_DR2),
-        (name:'tr6';    number:NR_DR6),
-        (name:'tr7';    number:NR_DR7)
-      );
-
-     function intel_regnum_search(const s:string):Tnewregister;
-     function intel_regname(const r:Tnewregister):string;
-
-
-  implementation
+
+implementation
 
 
     uses
     uses
 {$ifdef delphi}
 {$ifdef delphi}
       sysutils,
       sysutils,
 {$endif}
 {$endif}
       cutils,globtype,globals,systems,cclasses,
       cutils,globtype,globals,systems,cclasses,
-      verbose,finput,fmodule,script,cpuinfo
+      verbose,finput,fmodule,script,cpuinfo,
+      itx86int
       ;
       ;
 
 
     const
     const
@@ -211,17 +157,11 @@ interface
       begin
       begin
         with ref do
         with ref do
          begin
          begin
-           if segment.enum>lastreg then
-             internalerror(200301081);
-           if base.enum>lastreg then
-             internalerror(200301081);
-           if index.enum>lastreg then
-             internalerror(200301081);
            first:=true;
            first:=true;
            inc(offset,offsetfixup);
            inc(offset,offsetfixup);
            offsetfixup:=0;
            offsetfixup:=0;
-           if segment.enum<>R_NO then
-            AsmWrite(std_reg2str[segment.enum]+':[')
+           if segment<>NR_NO then
+            AsmWrite(masm_regname(segment)+':[')
            else
            else
             AsmWrite('[');
             AsmWrite('[');
            if assigned(symbol) then
            if assigned(symbol) then
@@ -231,21 +171,21 @@ interface
               AsmWrite(symbol.name);
               AsmWrite(symbol.name);
               first:=false;
               first:=false;
             end;
             end;
-           if (base.enum<>R_NO) then
+           if (base<>NR_NO) then
             begin
             begin
               if not(first) then
               if not(first) then
                AsmWrite('+')
                AsmWrite('+')
               else
               else
                first:=false;
                first:=false;
-               AsmWrite(std_reg2str[base.enum]);
+               AsmWrite(masm_regname(base));
             end;
             end;
-           if (index.enum<>R_NO) then
+           if (index<>NR_NO) then
             begin
             begin
               if not(first) then
               if not(first) then
                AsmWrite('+')
                AsmWrite('+')
               else
               else
                first:=false;
                first:=false;
-              AsmWrite(std_reg2str[index.enum]);
+              AsmWrite(masm_regname(index));
               if scalefactor<>0 then
               if scalefactor<>0 then
                AsmWrite('*'+tostr(scalefactor));
                AsmWrite('*'+tostr(scalefactor));
             end;
             end;
@@ -270,11 +210,7 @@ interface
       begin
       begin
         case o.typ of
         case o.typ of
           top_reg :
           top_reg :
-            begin
-              if o.reg.enum>lastreg then
-                internalerror(200301081);
-              AsmWrite(std_reg2str[o.reg.enum]);
-            end;
+            AsmWrite(masm_regname(o.reg));
           top_const :
           top_const :
             AsmWrite(tostr(longint(o.val)));
             AsmWrite(tostr(longint(o.val)));
           top_symbol :
           top_symbol :
@@ -333,11 +269,7 @@ interface
     begin
     begin
       case o.typ of
       case o.typ of
         top_reg :
         top_reg :
-          begin
-            if o.reg.enum>lastreg then
-              internalerror(200301081);
-            AsmWrite(std_reg2str[o.reg.enum]);
-          end;
+          AsmWrite(masm_regname(o.reg));
         top_const :
         top_const :
           AsmWrite(tostr(longint(o.val)));
           AsmWrite(tostr(longint(o.val)));
         top_symbol :
         top_symbol :
@@ -481,7 +413,7 @@ interface
            ait_regalloc :
            ait_regalloc :
              begin
              begin
                if (cs_asm_regalloc in aktglobalswitches) then
                if (cs_asm_regalloc in aktglobalswitches) then
-                 AsmWriteLn(target_asm.comment+'Register '+std_reg2str[tai_regalloc(hp).reg.enum]+
+                 AsmWriteLn(target_asm.comment+'Register '+masm_regname(tai_regalloc(hp).reg)+
                    allocstr[tai_regalloc(hp).allocation]);
                    allocstr[tai_regalloc(hp).allocation]);
              end;
              end;
 
 
@@ -669,15 +601,21 @@ interface
                          word prefix to get selectors
                          word prefix to get selectors
                          to be pushed in 2 bytes  PM }
                          to be pushed in 2 bytes  PM }
                        if (taicpu(hp).opsize=S_W) and
                        if (taicpu(hp).opsize=S_W) and
-                          ((taicpu(hp).opcode=A_PUSH) or
-                           (taicpu(hp).opcode=A_POP)) and
-                           (taicpu(hp).oper[0].typ=top_reg) and
-                           ((taicpu(hp).oper[0].reg.enum in [firstsreg..lastsreg])) then
+                          (
+                           (
+                            (
+                             (taicpu(hp).opcode=A_PUSH) or
+                             (taicpu(hp).opcode=A_POP)
+                            ) and
+                            (taicpu(hp).oper[0].typ=top_reg) and
+                            is_segment_reg(taicpu(hp).oper[0].reg)
+                           ) or
+                           (
+                            (taicpu(hp).opcode=A_PUSH) and
+                            (taicpu(hp).oper[0].typ=top_const)
+                           )
+                          ) then
                          AsmWriteln(#9#9'DB'#9'066h');
                          AsmWriteln(#9#9'DB'#9'066h');
-                       if (taicpu(hp).opsize=S_W) and
-                           (taicpu(hp).opcode=A_PUSH) and
-                           (taicpu(hp).oper[0].typ=top_const) then
-                        AsmWriteln(#9#9'DB'#9'066h');
 
 
                        { added prefix instructions, must be on same line as opcode }
                        { added prefix instructions, must be on same line as opcode }
                        if (taicpu(hp).ops = 0) and
                        if (taicpu(hp).ops = 0) and
@@ -866,61 +804,6 @@ ait_stab_function_name : ;
 {$endif EXTDEBUG}
 {$endif EXTDEBUG}
    end;
    end;
 
 
-     function intel_regnum_search(const s:string):Tnewregister;
-     
-     {Searches the register number that belongs to the register in s.
-      s must be in uppercase!.}
-     
-     var i,p:byte;
-     
-     begin
-        {Binary search.}
-        p:=0;
-        i:=regname_count_bsstart;
-        while i<>0 do
-          begin
-            if (p+i<regname_count) and (upper(intel_regname2regnum[p+i].name)<=s) then
-              p:=p+i;
-            i:=i shr 1;
-          end;
-        if upper(intel_regname2regnum[p].name)=s then
-          intel_regnum_search:=intel_regname2regnum[p].number
-        else
-          intel_regnum_search:=NR_NO;
-     end;
-
-    function intel_regname(const r:Tnewregister):string;
-
-    var i:byte;
-        nr:string[3];
-        sub:char;
-
-    begin
-      intel_regname:='';
-      for i:=0 to regname_count-1 do
-        if r=intel_regname2regnum[i].number then
-            intel_regname:=intel_regname2regnum[i].name;
-      {If not found, generate a systematic name.}
-      if intel_regname='' then
-        begin
-          str(r shr 8,nr);
-          case r and $ff of
-            R_SUBL:
-              sub:='l';
-            R_SUBH:
-              sub:='h';
-            R_SUBW:
-              sub:='w';
-            R_SUBD:
-              sub:='d';
-            R_SUBQ:
-              sub:='q';
-          else
-            internalerror(200303081);
-          end;
-          intel_regname:='reg'+nr+sub;
-        end;
-    end;
 
 
 {*****************************************************************************
 {*****************************************************************************
                                   Initialize
                                   Initialize
@@ -971,7 +854,19 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.36  2003-08-18 11:52:57  marco
+  Revision 1.37  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.36.2.3  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.36.2.2  2003/08/27 21:07:03  peter
+    * more updates
+
+  Revision 1.36.2.1  2003/08/27 19:55:54  peter
+    * first tregister patch
+
+  Revision 1.36  2003/08/18 11:52:57  marco
    * fix for 2592, pushw imm
    * fix for 2592, pushw imm
 
 
   Revision 1.35  2003/08/09 18:56:54  daniel
   Revision 1.35  2003/08/09 18:56:54  daniel

+ 37 - 58
compiler/i386/ag386nsm.pas

@@ -52,30 +52,34 @@ interface
       sysutils,
       sysutils,
 {$endif}
 {$endif}
       cutils,globtype,globals,systems,cclasses,
       cutils,globtype,globals,systems,cclasses,
-      fmodule,finput,verbose,cpuinfo,ag386int
+      fmodule,finput,verbose,cpuinfo,cginfo
       ;
       ;
 
 
     const
     const
       line_length = 64;
       line_length = 64;
 
 
-    int_nasmreg2str : reg2strtable = ('',
-     'eax','ecx','edx','ebx','esp','ebp','esi','edi',
-     'ax','cx','dx','bx','sp','bp','si','di',
-     'al','cl','dl','bl','ah','ch','bh','dh',
-     'cs','ds','es','ss','fs','gs',
-     'st0','st0','st1','st2','st3','st4','st5','st6','st7',
-     'dr0','dr1','dr2','dr3','dr6','dr7',
-     'cr0','cr2','cr3','cr4',
-     'tr3','tr4','tr5','tr6','tr7',
-     'mm0','mm1','mm2','mm3','mm4','mm5','mm6','mm7',
-     'xmm0','xmm1','xmm2','xmm3','xmm4','xmm5','xmm6','xmm7'
-   );
+      nasm_regname_table : array[tregisterindex] of string[7] = (
+        {r386nasm.inc contains the Nasm name of each register.}
+        {$i r386nasm.inc}
+      );
 
 
     var
     var
       lastfileinfo : tfileposinfo;
       lastfileinfo : tfileposinfo;
       infile,
       infile,
       lastinfile   : tinputfile;
       lastinfile   : tinputfile;
 
 
+    function nasm_regname(r:Tregister):string;
+      var
+        p : tregisterindex;
+      begin
+        p:=findreg_by_number(r);
+        if p<>0 then
+          result:=nasm_regname_table[p]
+        else
+          result:=generic_regname(r);
+      end;
+
+
    function fixline(s:string):string;
    function fixline(s:string):string;
    {
    {
      return s with all leading and ending spaces and tabs removed
      return s with all leading and ending spaces and tabs removed
@@ -217,48 +221,36 @@ interface
 
 
     procedure T386NasmAssembler.WriteReference(var ref : treference);
     procedure T386NasmAssembler.WriteReference(var ref : treference);
       var
       var
-        first,no_s,no_b,no_i : boolean;
+        first : boolean;
       begin
       begin
         with ref do
         with ref do
          begin
          begin
-           no_s:=(segment.enum=R_NO) or ((segment.enum=R_INTREGISTER) and (segment.number=NR_NO));
-           no_b:=(base.enum=R_NO) or ((base.enum=R_INTREGISTER) and (base.number=NR_NO));
-           no_i:=(index.enum=R_NO) or ((index.enum=R_INTREGISTER) and (index.number=NR_NO));
            AsmWrite('[');
            AsmWrite('[');
            first:=true;
            first:=true;
            inc(offset,offsetfixup);
            inc(offset,offsetfixup);
            offsetfixup:=0;
            offsetfixup:=0;
-           if not no_s then
-            if segment.enum=R_INTREGISTER then
-              asmwrite(intel_regname(segment.number))
-            else
-              asmwrite(std_reg2str[segment.enum]+':');
+           if (segment<>NR_NO) then
+             AsmWrite(nasm_regname(segment)+':');
            if assigned(symbol) then
            if assigned(symbol) then
             begin
             begin
               AsmWrite(symbol.name);
               AsmWrite(symbol.name);
               first:=false;
               first:=false;
             end;
             end;
-           if not no_b then
+           if (base<>NR_NO) then
             begin
             begin
               if not(first) then
               if not(first) then
                AsmWrite('+')
                AsmWrite('+')
               else
               else
                first:=false;
                first:=false;
-            if base.enum=R_INTREGISTER then
-              asmwrite(intel_regname(base.number))
-            else
-              asmwrite(int_nasmreg2str[base.enum]);
+              AsmWrite(nasm_regname(base))
             end;
             end;
-           if not no_i then
+           if (index<>NR_NO) then
              begin
              begin
                if not(first) then
                if not(first) then
                  AsmWrite('+')
                  AsmWrite('+')
                else
                else
                  first:=false;
                  first:=false;
-              if index.enum=R_INTREGISTER then
-                asmwrite(intel_regname(index.number))
-              else
-               AsmWrite(int_nasmreg2str[index.enum]);
+               AsmWrite(nasm_regname(index));
                if scalefactor<>0 then
                if scalefactor<>0 then
                  AsmWrite('*'+tostr(scalefactor));
                  AsmWrite('*'+tostr(scalefactor));
              end;
              end;
@@ -283,16 +275,7 @@ interface
       begin
       begin
         case o.typ of
         case o.typ of
           top_reg :
           top_reg :
-            begin
-              if o.reg.enum=R_INTREGISTER then
-                asmwrite(intel_regname(o.reg.number))
-              else
-                begin
-                  if o.reg.enum>high(Toldregister) then
-                    internalerror(01010101);
-                  asmwrite(int_nasmreg2str[o.reg.enum]);
-                end;
-            end;
+            AsmWrite(nasm_regname(o.reg));
           top_const :
           top_const :
             begin
             begin
               if (ops=1) and (opcode<>A_RET) then
               if (ops=1) and (opcode<>A_RET) then
@@ -333,12 +316,7 @@ interface
       begin
       begin
         case o.typ of
         case o.typ of
           top_reg :
           top_reg :
-            begin
-              if o.reg.enum=R_INTREGISTER then
-                asmwrite(intel_regname(o.reg.number))
-              else
-                asmwrite(int_nasmreg2str[o.reg.enum]);
-            end;
+            AsmWrite(nasm_regname(o.reg));
           top_ref :
           top_ref :
             WriteReference(o.ref^);
             WriteReference(o.ref^);
           top_const :
           top_const :
@@ -387,7 +365,6 @@ interface
       found,
       found,
       do_line,
       do_line,
       quoted   : boolean;
       quoted   : boolean;
-      regstr:string[6];
     begin
     begin
       if not assigned(p) then
       if not assigned(p) then
        exit;
        exit;
@@ -458,12 +435,8 @@ interface
 
 
            ait_regalloc :
            ait_regalloc :
              begin
              begin
-               if tai_regalloc(hp).reg.enum=R_INTREGISTER then
-                regstr:=intel_regname(tai_regalloc(hp).reg.number)
-               else
-                regstr:=std_reg2str[tai_regalloc(hp).reg.enum];
                if (cs_asm_regalloc in aktglobalswitches) then
                if (cs_asm_regalloc in aktglobalswitches) then
-                 AsmWriteLn(#9#9+target_asm.comment+'Register '+regstr+
+                 AsmWriteLn(#9#9+target_asm.comment+'Register '+nasm_regname(tai_regalloc(hp).reg)+
                    allocstr[tai_regalloc(hp).allocation]);
                    allocstr[tai_regalloc(hp).allocation]);
              end;
              end;
 
 
@@ -678,9 +651,9 @@ interface
                  begin
                  begin
                    taicpu(hp).ops:=2;
                    taicpu(hp).ops:=2;
                    taicpu(hp).oper[0].typ:=top_reg;
                    taicpu(hp).oper[0].typ:=top_reg;
-                   taicpu(hp).oper[0].reg.enum:=R_ST1;
+                   taicpu(hp).oper[0].reg:=NR_ST1;
                    taicpu(hp).oper[1].typ:=top_reg;
                    taicpu(hp).oper[1].typ:=top_reg;
-                   taicpu(hp).oper[1].reg.enum:=R_ST;
+                   taicpu(hp).oper[1].reg:=NR_ST;
                  end;
                  end;
                if taicpu(hp).opcode=A_FWAIT then
                if taicpu(hp).opcode=A_FWAIT then
                 AsmWriteln(#9#9'DB'#9'09bh')
                 AsmWriteln(#9#9'DB'#9'09bh')
@@ -693,7 +666,7 @@ interface
                      ((taicpu(hp).opcode=A_PUSH) or
                      ((taicpu(hp).opcode=A_PUSH) or
                       (taicpu(hp).opcode=A_POP)) and
                       (taicpu(hp).opcode=A_POP)) and
                       (taicpu(hp).oper[0].typ=top_reg) and
                       (taicpu(hp).oper[0].typ=top_reg) and
-                      ((taicpu(hp).oper[0].reg.enum in [firstsreg..lastsreg])) then
+                      (is_segment_reg(taicpu(hp).oper[0].reg)) then
                     AsmWriteln(#9#9'DB'#9'066h');
                     AsmWriteln(#9#9'DB'#9'066h');
                   AsmWrite(#9#9+std_op2str[taicpu(hp).opcode]+cond2str[taicpu(hp).condition]);
                   AsmWrite(#9#9+std_op2str[taicpu(hp).opcode]+cond2str[taicpu(hp).condition]);
                   if taicpu(hp).ops<>0 then
                   if taicpu(hp).ops<>0 then
@@ -929,7 +902,13 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.37  2003-08-09 18:56:54  daniel
+  Revision 1.38  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.37.2.1  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.37  2003/08/09 18:56:54  daniel
     * cs_regalloc renamed to cs_regvars to avoid confusion with register
     * cs_regalloc renamed to cs_regvars to avoid confusion with register
       allocator
       allocator
     * Some preventive changes to i386 spillinh code
     * Some preventive changes to i386 spillinh code

+ 11 - 5
compiler/i386/cgcpu.pas

@@ -115,8 +115,8 @@ unit cgcpu;
         case op of
         case op of
           OP_NEG :
           OP_NEG :
             begin
             begin
-              if (regsrc.reglo.number<>regdst.reglo.number) then
-                a_load64_reg_reg(list,regsrc,regdst{$ifdef newra},false{$endif});
+              if (regsrc.reglo<>regdst.reglo) then
+                a_load64_reg_reg(list,regsrc,regdst,false);
               list.concat(taicpu.op_reg(A_NOT,S_L,regdst.reghi));
               list.concat(taicpu.op_reg(A_NOT,S_L,regdst.reghi));
               list.concat(taicpu.op_reg(A_NEG,S_L,regdst.reglo));
               list.concat(taicpu.op_reg(A_NEG,S_L,regdst.reglo));
               list.concat(taicpu.op_const_reg(A_SBB,S_L,aword(-1),regdst.reghi));
               list.concat(taicpu.op_const_reg(A_SBB,S_L,aword(-1),regdst.reghi));
@@ -124,8 +124,8 @@ unit cgcpu;
             end;
             end;
           OP_NOT :
           OP_NOT :
             begin
             begin
-              if (regsrc.reglo.number<>regdst.reglo.number) then
-                a_load64_reg_reg(list,regsrc,regdst{$ifdef newra},false{$endif});
+              if (regsrc.reglo<>regdst.reglo) then
+                a_load64_reg_reg(list,regsrc,regdst,false);
               list.concat(taicpu.op_reg(A_NOT,S_L,regdst.reghi));
               list.concat(taicpu.op_reg(A_NOT,S_L,regdst.reghi));
               list.concat(taicpu.op_reg(A_NOT,S_L,regdst.reglo));
               list.concat(taicpu.op_reg(A_NOT,S_L,regdst.reglo));
               exit;
               exit;
@@ -193,7 +193,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.36  2003-06-12 18:31:18  peter
+  Revision 1.37  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.36.2.1  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.36  2003/06/12 18:31:18  peter
     * fix newra cycle for i386
     * fix newra cycle for i386
 
 
   Revision 1.35  2003/06/03 21:11:09  peter
   Revision 1.35  2003/06/03 21:11:09  peter

+ 25 - 53
compiler/i386/cpubase.inc

@@ -46,64 +46,34 @@
       }
       }
       std_op2str:op2strtable={$i i386int.inc}
       std_op2str:op2strtable={$i i386int.inc}
 
 
-      {# Standard register table (for each tregister enumeration). The
-         register strings should conform to the the names as defined
-         by the processor manufacturer
-      }
-      std_reg2str : reg2strtable = ('',
-        'eax','ecx','edx','ebx','esp','ebp','esi','edi',
-        'ax','cx','dx','bx','sp','bp','si','di',
-        'al','cl','dl','bl','ah','ch','bh','dh',
-        'cs','ds','es','ss','fs','gs',
-        'st','st(0)','st(1)','st(2)','st(3)','st(4)','st(5)','st(6)','st(7)',
-        'dr0','dr1','dr2','dr3','dr6','dr7',
-        'cr0','cr2','cr3','cr4',
-        'tr3','tr4','tr5','tr6','tr7',
-        'mm0','mm1','mm2','mm3','mm4','mm5','mm6','mm7',
-        'xmm0','xmm1','xmm2','xmm3','xmm4','xmm5','xmm6','xmm7'
-      );
-
 {*****************************************************************************
 {*****************************************************************************
                                  Constants
                                  Constants
 *****************************************************************************}
 *****************************************************************************}
 
 
       firstsaveintreg = RS_EAX;
       firstsaveintreg = RS_EAX;
       lastsaveintreg  = RS_EDX;
       lastsaveintreg  = RS_EDX;
-      firstsavefpureg = R_NO;
-      lastsavefpureg  = R_NO;
-      firstsavemmreg  = R_MM0;
-      lastsavemmreg   = R_MM7;
+      firstsavefpureg = RS_INVALID;
+      lastsavefpureg  = RS_INVALID;
+      firstsavemmreg  = RS_MM0;
+      lastsavemmreg   = RS_MM7;
 
 
-      general_registers = [R_EAX,R_EBX,R_ECX,R_EDX];
       general_superregisters = [RS_EAX,RS_EBX,RS_ECX,RS_EDX];
       general_superregisters = [RS_EAX,RS_EBX,RS_ECX,RS_EDX];
 
 
-{$ifdef newra}
-      usableregsint = [first_imreg..last_imreg];
-{$else}
-      usableregsint = [RS_EAX,RS_EBX,RS_ECX,RS_EDX];
-{$endif}
+      usableregsint = [first_int_imreg..last_int_imreg];
       c_countusableregsint = 4;
       c_countusableregsint = 4;
 
 
       maxaddrregs = 1;
       maxaddrregs = 1;
-      addrregs    = [R_ESI];
       usableregsaddr = [RS_ESI];
       usableregsaddr = [RS_ESI];
       c_countusableregsaddr = 1;
       c_countusableregsaddr = 1;
 
 
       maxvarregs = 4;
       maxvarregs = 4;
-      varregs : array[1..maxvarregs] of tnewregister =
+      varregs : array[1..maxvarregs] of tsuperregister =
          (RS_EBX,RS_EDX,RS_ECX,RS_EAX);
          (RS_EBX,RS_EDX,RS_ECX,RS_EAX);
 
 
       maxfpuvarregs = 8;
       maxfpuvarregs = 8;
 
 
       maxmmvarregs = 8;
       maxmmvarregs = 8;
 
 
-      {# Registers which are defined as scratch and no need to save across
-         routine calls or in assembler blocks.
-      }
-{$ifndef newra}
-      max_scratch_regs = 1;
-      scratch_regs : array[1..max_scratch_regs] of Tsuperregister = (RS_EDI);
-{$endif}
 
 
 {*****************************************************************************
 {*****************************************************************************
                                GDB Information
                                GDB Information
@@ -116,20 +86,11 @@
           (FIXED_REGISTERS) from GCC 3.x source code
           (FIXED_REGISTERS) from GCC 3.x source code
 
 
       }
       }
-      stab_regindex : array[firstreg..lastreg] of shortint =
-        (-1,
-        0,1,2,3,4,5,6,7,
-        0,1,2,3,4,5,6,7,
-        0,1,2,3,0,1,2,3,
-        -1,-1,-1,-1,-1,-1,
-        12,12,13,14,15,16,17,18,19,
-        -1,-1,-1,-1,-1,-1,
-        -1,-1,-1,-1,
-        -1,-1,-1,-1,-1,
-        29,30,31,32,33,34,35,36,
-        21,22,23,24,25,26,27,28
+      reg_stab_table : array[tregisterindex] of shortint = (
+        {$i r386stab.inc}
       );
       );
 
 
+
 {*****************************************************************************
 {*****************************************************************************
                           Default generic sizes
                           Default generic sizes
 *****************************************************************************}
 *****************************************************************************}
@@ -151,7 +112,6 @@
       NR_STACK_POINTER_REG = NR_ESP;
       NR_STACK_POINTER_REG = NR_ESP;
       RS_STACK_POINTER_REG = RS_ESP;
       RS_STACK_POINTER_REG = RS_ESP;
       {# Frame pointer register }
       {# Frame pointer register }
-      frame_pointer_reg = R_EBP;
       RS_FRAME_POINTER_REG = RS_EBP;
       RS_FRAME_POINTER_REG = RS_EBP;
       NR_FRAME_POINTER_REG = NR_EBP;
       NR_FRAME_POINTER_REG = NR_EBP;
       {# Register for addressing absolute data in a position independant way,
       {# Register for addressing absolute data in a position independant way,
@@ -180,8 +140,8 @@
 
 
       { WARNING: don't change to R_ST0!! See comments above implementation of }
       { WARNING: don't change to R_ST0!! See comments above implementation of }
       { a_loadfpu* methods in rgcpu (JM)                                      }
       { a_loadfpu* methods in rgcpu (JM)                                      }
-      fpu_result_reg = R_ST;
-      mmresultreg = R_MM0;
+      NR_fpu_result_reg = NR_ST;
+      NR_mm_result_reg = NR_MM0;
 
 
       { Offset where the parent framepointer is pushed }
       { Offset where the parent framepointer is pushed }
       PARENT_FRAMEPOINTER_OFFSET = 8;
       PARENT_FRAMEPOINTER_OFFSET = 8;
@@ -198,7 +158,7 @@
          This value can be deduced from the CALLED_USED_REGISTERS array in the
          This value can be deduced from the CALLED_USED_REGISTERS array in the
          GCC source.
          GCC source.
       }
       }
-      std_saved_registers = [R_ESI,R_EDI,R_EBX];
+      std_saved_registers = [RS_ESI,RS_EDI,RS_EBX];
       {# Required parameter alignment when calling a routine declared as
       {# Required parameter alignment when calling a routine declared as
          stdcall and cdecl. The alignment value should be the one defined
          stdcall and cdecl. The alignment value should be the one defined
          by GCC or the target ABI.
          by GCC or the target ABI.
@@ -210,13 +170,25 @@
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.8  2003-09-03 11:18:37  florian
+  Revision 1.9  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.8  2003/09/03 11:18:37  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.7.2.3  2003/08/29 17:29:00  peter
+    * next batch of updates
+
+  Revision 1.7.2.2  2003/08/28 18:35:08  peter
+    * tregister changed to cardinal
+
+  Revision 1.7.2.1  2003/08/27 20:05:04  peter
+    * forgotten
+
   Revision 1.7  2003/07/06 17:58:22  peter
   Revision 1.7  2003/07/06 17:58:22  peter
     * framepointer fixes for sparc
     * framepointer fixes for sparc
     * parent framepointer code more generic
     * parent framepointer code more generic

+ 17 - 15
compiler/i386/cpupara.pas

@@ -115,7 +115,7 @@ unit cpupara;
     function ti386paramanager.getintparaloc(list: taasmoutput; nr : longint) : tparalocation;
     function ti386paramanager.getintparaloc(list: taasmoutput; nr : longint) : tparalocation;
       begin
       begin
          getintparaloc.loc:=LOC_REFERENCE;
          getintparaloc.loc:=LOC_REFERENCE;
-         getintparaloc.reference.index.enum:=R_EBP;
+         getintparaloc.reference.index:=NR_EBP;
          getintparaloc.reference.offset:=4*nr;
          getintparaloc.reference.offset:=4*nr;
       end;
       end;
 
 
@@ -148,10 +148,7 @@ unit cpupara;
             if assigned(current_procinfo) then
             if assigned(current_procinfo) then
               paraloc.reference.index:=current_procinfo.framepointer
               paraloc.reference.index:=current_procinfo.framepointer
             else
             else
-              begin
-                paraloc.reference.index.enum:=R_INTREGISTER;
-                paraloc.reference.index.number:=NR_FRAME_POINTER_REG;
-              end;
+              paraloc.reference.index:=NR_FRAME_POINTER_REG;
             paraloc.reference.offset:=tvarsym(hp.parasym).adjusted_address;
             paraloc.reference.offset:=tvarsym(hp.parasym).adjusted_address;
             hp.paraloc[side]:=paraloc;
             hp.paraloc[side]:=paraloc;
 {$warning callerparaloc shall not be the same as calleeparaloc}
 {$warning callerparaloc shall not be the same as calleeparaloc}
@@ -165,7 +162,7 @@ unit cpupara;
         if p.rettype.def.deftype=floatdef then
         if p.rettype.def.deftype=floatdef then
           begin
           begin
             paraloc.loc:=LOC_FPUREGISTER;
             paraloc.loc:=LOC_FPUREGISTER;
-            paraloc.register.enum:=FPU_RESULT_REG;
+            paraloc.register:=NR_FPU_RESULT_REG;
           end
           end
         else
         else
          { Return in register? }
          { Return in register? }
@@ -175,16 +172,13 @@ unit cpupara;
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
             if paraloc.size in [OS_64,OS_S64] then
             if paraloc.size in [OS_64,OS_S64] then
              begin
              begin
-               paraloc.register64.reglo.enum:=R_INTREGISTER;
-               paraloc.register64.reglo.number:=NR_FUNCTION_RETURN64_LOW_REG;
-               paraloc.register64.reghi.enum:=R_INTREGISTER;
-               paraloc.register64.reghi.number:=NR_FUNCTION_RETURN64_HIGH_REG;
+               paraloc.register64.reglo:=NR_FUNCTION_RETURN64_LOW_REG;
+               paraloc.register64.reghi:=NR_FUNCTION_RETURN64_HIGH_REG;
              end
              end
             else
             else
 {$endif cpu64bit}
 {$endif cpu64bit}
              begin
              begin
-               paraloc.register.enum:=R_INTREGISTER;
-               paraloc.register.number:=NR_FUNCTION_RETURN_REG;
+               paraloc.register:=NR_FUNCTION_RETURN_REG;
              end;
              end;
           end
           end
         else
         else
@@ -204,8 +198,7 @@ unit cpupara;
            internalerror(200305251);
            internalerror(200305251);
          getselflocation.loc:=LOC_REFERENCE;
          getselflocation.loc:=LOC_REFERENCE;
          getselflocation.sp_fixup:=POINTER_SIZE;
          getselflocation.sp_fixup:=POINTER_SIZE;
-         getselflocation.reference.index.enum:=R_INTREGISTER;
-         getselflocation.reference.index.number:=NR_STACK_POINTER_REG;
+         getselflocation.reference.index:=NR_STACK_POINTER_REG;
          getselflocation.reference.offset:=hsym.adjusted_address;
          getselflocation.reference.offset:=hsym.adjusted_address;
       end;
       end;
 
 
@@ -214,7 +207,16 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.22  2003-08-11 21:18:20  peter
+  Revision 1.23  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.22.2.2  2003/08/28 18:35:08  peter
+    * tregister changed to cardinal
+
+  Revision 1.22.2.1  2003/08/27 19:55:54  peter
+    * first tregister patch
+
+  Revision 1.22  2003/08/11 21:18:20  peter
     * start of sparc support for newra
     * start of sparc support for newra
 
 
   Revision 1.21  2003/07/05 20:11:41  jonas
   Revision 1.21  2003/07/05 20:11:41  jonas

+ 8 - 2
compiler/i386/cpupi.pas

@@ -54,7 +54,7 @@ unit cpupi;
 
 
     procedure ti386procinfo.allocate_framepointer_reg;
     procedure ti386procinfo.allocate_framepointer_reg;
       begin
       begin
-        if framepointer.number=NR_EBP then
+        if framepointer=NR_EBP then
           begin
           begin
             { Make sure the register allocator won't allocate registers
             { Make sure the register allocator won't allocate registers
               into ebp }
               into ebp }
@@ -69,7 +69,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.9  2003-07-06 17:58:22  peter
+  Revision 1.10  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.9.2.1  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.9  2003/07/06 17:58:22  peter
     * framepointer fixes for sparc
     * framepointer fixes for sparc
     * parent framepointer code more generic
     * parent framepointer code more generic
 
 

+ 31 - 208
compiler/i386/n386add.pas

@@ -71,8 +71,6 @@ interface
          opsize_2_cgsize : array[S_B..S_L] of tcgsize = (OS_8,OS_16,OS_32);
          opsize_2_cgsize : array[S_B..S_L] of tcgsize = (OS_8,OS_16,OS_32);
 
 
     procedure ti386addnode.pass_left_and_right(var pushedfpu:boolean);
     procedure ti386addnode.pass_left_and_right(var pushedfpu:boolean);
-      var
-        pushedregs : tmaybesave;
       begin
       begin
         { calculate the operator which is more difficult }
         { calculate the operator which is more difficult }
         firstcomplex(self);
         firstcomplex(self);
@@ -83,17 +81,11 @@ interface
         secondpass(left);
         secondpass(left);
 
 
         { are too few registers free? }
         { are too few registers free? }
-      {$ifndef newra}
-        maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-      {$endif newra}
         if location.loc=LOC_FPUREGISTER then
         if location.loc=LOC_FPUREGISTER then
           pushedfpu:=maybe_pushfpu(exprasmlist,right.registersfpu,left.location)
           pushedfpu:=maybe_pushfpu(exprasmlist,right.registersfpu,left.location)
         else
         else
           pushedfpu:=false;
           pushedfpu:=false;
         secondpass(right);
         secondpass(right);
-      {$ifndef newra}
-        maybe_restore(exprasmlist,left.location,pushedregs);
-      {$endif}
       end;
       end;
 
 
 
 
@@ -230,13 +222,7 @@ interface
             begin
             begin
               if extra_not then
               if extra_not then
                 emit_reg(A_NOT,opsize,left.location.register);
                 emit_reg(A_NOT,opsize,left.location.register);
-            {$ifdef newra}
               r:=rg.getregisterint(exprasmlist,OS_INT);
               r:=rg.getregisterint(exprasmlist,OS_INT);
-            {$else}
-              r.enum:=R_INTREGISTER;
-              r.number:=NR_EDI;
-              rg.getexplicitregisterint(exprasmlist,NR_EDI);
-            {$endif}
               cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,r);
               cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,r);
               emit_reg_reg(op,opsize,left.location.register,r);
               emit_reg_reg(op,opsize,left.location.register,r);
               emit_reg_reg(A_MOV,opsize,r,left.location.register);
               emit_reg_reg(A_MOV,opsize,r,left.location.register);
@@ -280,13 +266,7 @@ interface
                  begin
                  begin
                    if extra_not then
                    if extra_not then
                      begin
                      begin
-                     {$ifdef newra}
                         r:=rg.getregisterint(exprasmlist,OS_INT);
                         r:=rg.getregisterint(exprasmlist,OS_INT);
-                     {$else}
-                        rg.getexplicitregisterint(exprasmlist,NR_EDI);
-                        r.enum:=R_INTREGISTER;
-                        r.number:=NR_EDI;
-                     {$endif}
                         cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,r);
                         cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,r);
                         emit_reg(A_NOT,S_L,r);
                         emit_reg(A_NOT,S_L,r);
                         emit_reg_reg(A_AND,S_L,r,left.location.register);
                         emit_reg_reg(A_AND,S_L,r,left.location.register);
@@ -350,14 +330,6 @@ interface
 
 
     procedure ti386addnode.second_addstring;
     procedure ti386addnode.second_addstring;
 
 
-      var
-      {$ifdef newra}
-        r          : Tregister;
-        i          : Tsuperregister;
-      {$else}
-        pushed     : Tpushedsavedint;
-      {$endif}
-        regstopush : Tsupregset;
       begin
       begin
         { string operations are not commutative }
         { string operations are not commutative }
         if nf_swaped in flags then
         if nf_swaped in flags then
@@ -368,28 +340,17 @@ interface
                 case nodetype of
                 case nodetype of
                    ltn,lten,gtn,gten,equaln,unequaln :
                    ltn,lten,gtn,gten,equaln,unequaln :
                      begin
                      begin
-                     {$ifndef newra}
-                       rg.saveusedintregisters(exprasmlist,pushed,VOLATILE_INTREGISTERS);
-                     {$endif newra}
                        secondpass(left);
                        secondpass(left);
                        location_release(exprasmlist,left.location);
                        location_release(exprasmlist,left.location);
                        cg.a_paramaddr_ref(exprasmlist,left.location.reference,paramanager.getintparaloc(exprasmlist,2));
                        cg.a_paramaddr_ref(exprasmlist,left.location.reference,paramanager.getintparaloc(exprasmlist,2));
                        secondpass(right);
                        secondpass(right);
                        location_release(exprasmlist,right.location);
                        location_release(exprasmlist,right.location);
                        cg.a_paramaddr_ref(exprasmlist,right.location.reference,paramanager.getintparaloc(exprasmlist,1));
                        cg.a_paramaddr_ref(exprasmlist,right.location.reference,paramanager.getintparaloc(exprasmlist,1));
-                      {$ifdef newra}
-                       rg.allocexplicitregistersint(exprasmlist,[first_supreg..last_supreg]-[RS_FRAME_POINTER_REG,RS_STACK_POINTER_REG]);
-                      {$else}
-                       rg.saveintregvars(exprasmlist,regstopush);
-                      {$endif}
+                       rg.allocexplicitregistersint(exprasmlist,[first_int_supreg..last_int_supreg]-[RS_FRAME_POINTER_REG,RS_STACK_POINTER_REG]);
                        cg.a_call_name(exprasmlist,'FPC_SHORTSTR_COMPARE');
                        cg.a_call_name(exprasmlist,'FPC_SHORTSTR_COMPARE');
                        paramanager.freeintparaloc(exprasmlist,2);
                        paramanager.freeintparaloc(exprasmlist,2);
                        paramanager.freeintparaloc(exprasmlist,1);
                        paramanager.freeintparaloc(exprasmlist,1);
-                      {$ifdef newra}
-                       rg.deallocexplicitregistersint(exprasmlist,[first_supreg..last_supreg]-[RS_FRAME_POINTER_REG,RS_STACK_POINTER_REG]);
-                      {$else}
-                        rg.restoreusedintregisters(exprasmlist,pushed);
-                      {$endif}
+                       rg.deallocexplicitregistersint(exprasmlist,[first_int_supreg..last_int_supreg]-[RS_FRAME_POINTER_REG,RS_STACK_POINTER_REG]);
                        location_freetemp(exprasmlist,left.location);
                        location_freetemp(exprasmlist,left.location);
                        location_freetemp(exprasmlist,right.location);
                        location_freetemp(exprasmlist,right.location);
                      end;
                      end;
@@ -413,7 +374,6 @@ interface
         cmpop,
         cmpop,
         isjump  : boolean;
         isjump  : boolean;
         otl,ofl : tasmlabel;
         otl,ofl : tasmlabel;
-        pushedregs : tmaybesave;
       begin
       begin
         { calculate the operator which is more difficult }
         { calculate the operator which is more difficult }
         firstcomplex(self);
         firstcomplex(self);
@@ -452,9 +412,6 @@ interface
                falselabel:=ofl;
                falselabel:=ofl;
              end;
              end;
 
 
-          {$ifndef newra}
-            maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-          {$endif}
             isjump:=(right.location.loc=LOC_JUMP);
             isjump:=(right.location.loc=LOC_JUMP);
             if isjump then
             if isjump then
               begin
               begin
@@ -464,9 +421,6 @@ interface
                  objectlibrary.getlabel(falselabel);
                  objectlibrary.getlabel(falselabel);
               end;
               end;
             secondpass(right);
             secondpass(right);
-          {$ifndef newra}
-            maybe_restore(exprasmlist,left.location,pushedregs);
-          {$endif newra}
             if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
             if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
              location_force_reg(exprasmlist,right.location,opsize_2_cgsize[opsize],false);
              location_force_reg(exprasmlist,right.location,opsize_2_cgsize[opsize],false);
             if isjump then
             if isjump then
@@ -553,7 +507,7 @@ interface
         resflags   : tresflags;
         resflags   : tresflags;
         pushedfpu,
         pushedfpu,
         cmpop      : boolean;
         cmpop      : boolean;
-        r,r2:Tregister;
+        r : Tregister;
       begin
       begin
         pass_left_and_right(pushedfpu);
         pass_left_and_right(pushedfpu);
 
 
@@ -579,14 +533,13 @@ interface
 
 
         if (right.location.loc<>LOC_FPUREGISTER) then
         if (right.location.loc<>LOC_FPUREGISTER) then
          begin
          begin
-           r.enum:=R_ST;
-           cg.a_loadfpu_loc_reg(exprasmlist,right.location,r);
+           cg.a_loadfpu_loc_reg(exprasmlist,right.location,NR_ST);
            if (right.location.loc <> LOC_CFPUREGISTER) and
            if (right.location.loc <> LOC_CFPUREGISTER) and
               pushedfpu then
               pushedfpu then
              location_freetemp(exprasmlist,left.location);
              location_freetemp(exprasmlist,left.location);
            if (left.location.loc<>LOC_FPUREGISTER) then
            if (left.location.loc<>LOC_FPUREGISTER) then
             begin
             begin
-              cg.a_loadfpu_loc_reg(exprasmlist,left.location,r);
+              cg.a_loadfpu_loc_reg(exprasmlist,left.location,NR_ST);
               if (left.location.loc <> LOC_CFPUREGISTER) and
               if (left.location.loc <> LOC_CFPUREGISTER) and
                  pushedfpu then
                  pushedfpu then
                 location_freetemp(exprasmlist,left.location);
                 location_freetemp(exprasmlist,left.location);
@@ -603,8 +556,7 @@ interface
         { the nominator in st0 }
         { the nominator in st0 }
         else if (left.location.loc<>LOC_FPUREGISTER) then
         else if (left.location.loc<>LOC_FPUREGISTER) then
          begin
          begin
-           r.enum:=R_ST;
-           cg.a_loadfpu_loc_reg(exprasmlist,left.location,r);
+           cg.a_loadfpu_loc_reg(exprasmlist,left.location,NR_ST);
            if (left.location.loc <> LOC_CFPUREGISTER) and
            if (left.location.loc <> LOC_CFPUREGISTER) and
               pushedfpu then
               pushedfpu then
              location_freetemp(exprasmlist,left.location);
              location_freetemp(exprasmlist,left.location);
@@ -635,9 +587,7 @@ interface
         { the Intel assemblers want operands }
         { the Intel assemblers want operands }
         if op<>A_FCOMPP then
         if op<>A_FCOMPP then
           begin
           begin
-             r.enum:=R_ST;
-             r2.enum:=R_ST1;
-             emit_reg_reg(op,S_NO,r,r2);
+             emit_reg_reg(op,S_NO,NR_ST,NR_ST1);
              dec(trgcpu(rg).fpuvaroffset);
              dec(trgcpu(rg).fpuvaroffset);
           end
           end
         else
         else
@@ -649,36 +599,10 @@ interface
         { on comparison load flags }
         { on comparison load flags }
         if cmpop then
         if cmpop then
          begin
          begin
-         {$ifdef newra}
            r:=rg.getexplicitregisterint(exprasmlist,NR_AX);
            r:=rg.getexplicitregisterint(exprasmlist,NR_AX);
-         {$else}
-           if not(RS_EAX in rg.unusedregsint) then
-             begin
-               rg.getexplicitregisterint(exprasmlist,NR_EDI);
-               r.enum:=R_INTREGISTER;
-               r.number:=NR_EAX;
-               r2.enum:=R_INTREGISTER;;
-               r2.number:=NR_EDI;
-               emit_reg_reg(A_MOV,S_L,r,r2);
-             end;
-           r.enum:=R_INTREGISTER;
-           r.number:=NR_AX;
-         {$endif}
            emit_reg(A_FNSTSW,S_NO,r);
            emit_reg(A_FNSTSW,S_NO,r);
            emit_none(A_SAHF,S_NO);
            emit_none(A_SAHF,S_NO);
-         {$ifdef newra}
            rg.ungetregisterint(exprasmlist,r);
            rg.ungetregisterint(exprasmlist,r);
-         {$else}
-           if not(RS_EAX in rg.unusedregsint) then
-             begin
-               r.enum:=R_INTREGISTER;
-               r.number:=NR_EAX;
-               r2.enum:=R_INTREGISTER;;
-               r2.number:=NR_EDI;
-               emit_reg_reg(A_MOV,S_L,r2,r);
-               rg.ungetregisterint(exprasmlist,r2);
-             end;
-         {$endif}
            if nf_swaped in flags then
            if nf_swaped in flags then
             begin
             begin
               case nodetype of
               case nodetype of
@@ -707,7 +631,7 @@ interface
         else
         else
          begin
          begin
            location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
            location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-           location.register.enum:=R_ST;
+           location.register:=NR_ST;
          end;
          end;
       end;
       end;
 
 
@@ -962,22 +886,10 @@ interface
               { we can reuse a CREGISTER for comparison }
               { we can reuse a CREGISTER for comparison }
               if not((left.location.loc=LOC_CREGISTER) and cmpop) then
               if not((left.location.loc=LOC_CREGISTER) and cmpop) then
                begin
                begin
-               {$ifdef newra}
                  delete:=left.location.loc<>LOC_CREGISTER;
                  delete:=left.location.loc<>LOC_CREGISTER;
-               {$else}
-                 if (left.location.loc<>LOC_CREGISTER) then
-                  begin
-                    location_freetemp(exprasmlist,left.location);
-                    location_release(exprasmlist,left.location);
-                  end;
-               {$endif}
                  hregister:=rg.getregisterint(exprasmlist,OS_INT);
                  hregister:=rg.getregisterint(exprasmlist,OS_INT);
                  hregister2:=rg.getregisterint(exprasmlist,OS_INT);
                  hregister2:=rg.getregisterint(exprasmlist,OS_INT);
-               {$ifdef newra}
                  cg64.a_load64_loc_reg(exprasmlist,left.location,joinreg64(hregister,hregister2),delete);
                  cg64.a_load64_loc_reg(exprasmlist,left.location,joinreg64(hregister,hregister2),delete);
-               {$else}
-                 cg64.a_load64_loc_reg(exprasmlist,left.location,joinreg64(hregister,hregister2));
-               {$endif}
                  location_reset(left.location,LOC_REGISTER,OS_64);
                  location_reset(left.location,LOC_REGISTER,OS_64);
                  left.location.registerlow:=hregister;
                  left.location.registerlow:=hregister;
                  left.location.registerhigh:=hregister2;
                  left.location.registerhigh:=hregister2;
@@ -1022,13 +934,7 @@ interface
            { right.location<>LOC_REGISTER }
            { right.location<>LOC_REGISTER }
            if (nodetype=subn) and (nf_swaped in flags) then
            if (nodetype=subn) and (nf_swaped in flags) then
             begin
             begin
-{$ifdef newra}
               r:=rg.getregisterint(exprasmlist,OS_INT);
               r:=rg.getregisterint(exprasmlist,OS_INT);
-{$else}
-              rg.getexplicitregisterint(exprasmlist,NR_EDI);
-              r.enum:=R_INTREGISTER;
-              r.number:=NR_EDI;
-{$endif}
               cg64.a_load64low_loc_reg(exprasmlist,right.location,r);
               cg64.a_load64low_loc_reg(exprasmlist,right.location,r);
               emit_reg_reg(op1,opsize,left.location.registerlow,r);
               emit_reg_reg(op1,opsize,left.location.registerlow,r);
               emit_reg_reg(A_MOV,opsize,r,left.location.registerlow);
               emit_reg_reg(A_MOV,opsize,r,left.location.registerlow);
@@ -1251,29 +1157,26 @@ interface
          begin
          begin
            if (nodetype=subn) and (nf_swaped in flags) then
            if (nodetype=subn) and (nf_swaped in flags) then
             begin
             begin
-              r.enum:=R_MM7;
               if right.location.loc=LOC_CMMXREGISTER then
               if right.location.loc=LOC_CMMXREGISTER then
                begin
                begin
-                 emit_reg_reg(A_MOVQ,S_NO,right.location.register,r);
-                 emit_reg_reg(op,S_NO,left.location.register,r);
-                 emit_reg_reg(A_MOVQ,S_NO,r,left.location.register);
+                 emit_reg_reg(A_MOVQ,S_NO,right.location.register,NR_MM7);
+                 emit_reg_reg(op,S_NO,left.location.register,NR_MM7);
+                 emit_reg_reg(A_MOVQ,S_NO,NR_MM7,left.location.register);
                end
                end
               else
               else
                begin
                begin
                  if not(left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
                  if not(left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
                   internalerror(200203247);
                   internalerror(200203247);
-                 emit_ref_reg(A_MOVQ,S_NO,right.location.reference,r);
-                 emit_reg_reg(op,S_NO,left.location.register,r);
-                 emit_reg_reg(A_MOVQ,S_NO,r,left.location.register);
+                 emit_ref_reg(A_MOVQ,S_NO,right.location.reference,NR_MM7);
+                 emit_reg_reg(op,S_NO,left.location.register,NR_MM7);
+                 emit_reg_reg(A_MOVQ,S_NO,NR_MM7,left.location.register);
                  location_release(exprasmlist,right.location);
                  location_release(exprasmlist,right.location);
                end;
                end;
             end
             end
            else
            else
             begin
             begin
               if (right.location.loc=LOC_CMMXREGISTER) then
               if (right.location.loc=LOC_CMMXREGISTER) then
-               begin
-                 emit_reg_reg(op,S_NO,right.location.register,left.location.register);
-               end
+                emit_reg_reg(op,S_NO,right.location.register,left.location.register)
               else
               else
                begin
                begin
                  if not(right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
                  if not(right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
@@ -1313,10 +1216,9 @@ interface
                                 MUL
                                 MUL
 *****************************************************************************}
 *****************************************************************************}
 
 
-{$ifdef newra}
     procedure ti386addnode.second_mul;
     procedure ti386addnode.second_mul;
 
 
-    var r,r_eax:Tregister;
+    var r:Tregister;
 
 
     begin
     begin
       {The location.register will be filled in later (JM)}
       {The location.register will be filled in later (JM)}
@@ -1328,10 +1230,8 @@ interface
       location_release(exprasmlist,left.location);
       location_release(exprasmlist,left.location);
       {Allocate EAX.}
       {Allocate EAX.}
       rg.getexplicitregisterint(exprasmlist,NR_EAX);
       rg.getexplicitregisterint(exprasmlist,NR_EAX);
-      r_eax.enum:=R_INTREGISTER;
-      r_eax.number:=NR_EAX;
       {Load the right value.}
       {Load the right value.}
-      cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,r_eax);
+      cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,NR_EAX);
       location_release(exprasmlist,right.location);
       location_release(exprasmlist,right.location);
       {The mul instruction frees register r.}
       {The mul instruction frees register r.}
       rg.ungetregisterint(exprasmlist,r);
       rg.ungetregisterint(exprasmlist,r);
@@ -1339,103 +1239,16 @@ interface
       rg.getexplicitregisterint(exprasmlist,NR_EDX);
       rg.getexplicitregisterint(exprasmlist,NR_EDX);
       emit_reg(A_MUL,S_L,r);
       emit_reg(A_MUL,S_L,r);
       {Free EDX}
       {Free EDX}
-      r.enum:=R_INTREGISTER;
-      r.number:=NR_EDX;
-      rg.ungetregisterint(exprasmlist,r);
+      rg.ungetregisterint(exprasmlist,NR_EDX);
       {Free EAX}
       {Free EAX}
-      rg.ungetregisterint(exprasmlist,r_eax);
+      rg.ungetregisterint(exprasmlist,NR_EAX);
       {Allocate a new register and store the result in EAX in it.}
       {Allocate a new register and store the result in EAX in it.}
       location.register:=rg.getregisterint(exprasmlist,OS_INT);
       location.register:=rg.getregisterint(exprasmlist,OS_INT);
-      emit_reg_reg(A_MOV,S_L,r_eax,location.register);
+      emit_reg_reg(A_MOV,S_L,NR_EAX,location.register);
       location_freetemp(exprasmlist,left.location);
       location_freetemp(exprasmlist,left.location);
       location_freetemp(exprasmlist,right.location);
       location_freetemp(exprasmlist,right.location);
     end;
     end;
 
 
-{$else}
-    procedure ti386addnode.second_mul;
-
-    var popeax,popedx:boolean;
-        regstopush:Tsupregset;
-        r:Tregister;
-
-    begin
-      popeax:=false;
-      popedx:=false;
-      { here you need to free the symbol first }
-      { left.location and right.location must }
-      { only be freed when they are really released,  }
-      { because the optimizer NEEDS correct regalloc  }
-      { info!!! (JM)                                  }
-      { the location.register will be filled in later (JM) }
-      location_reset(location,LOC_REGISTER,OS_INT);
-
-      regstopush := VOLATILE_INTREGISTERS;
-      remove_non_regvars_from_loc(right.location,regstopush);
-      remove_non_regvars_from_loc(left.location,regstopush);
-      { now, regstopush does NOT contain EAX and/or EDX if they are }
-      { used in either the left or the right location, excepts if   }
-      {they are regvars. It DOES contain them if they are used in   }
-      { another location (JM)                                       }
-      r.enum:=R_INTREGISTER;
-      if not(RS_EAX in rg.unusedregsint) and
-         (RS_EAX in regstopush) then
-        begin
-          r.number:=NR_EAX;
-          emit_reg(A_PUSH,S_L,r);
-          popeax:=true;
-        end;
-      if not(RS_EDX in rg.unusedregsint) and
-         (RS_EDX in regstopush) then
-        begin
-          r.number:=NR_EDX;
-          emit_reg(A_PUSH,S_L,r);
-          popedx:=true;
-        end;
-      { left.location can be R_EAX !!! }
-      rg.getexplicitregisterint(exprasmlist,NR_EDI);
-      { load the left value }
-      r.number:=NR_EDI;
-      cg.a_load_loc_reg(exprasmlist,OS_INT,left.location,r);
-      location_release(exprasmlist,left.location);
-      { allocate EAX }
-      r.number:=NR_EAX;
-      if RS_EAX in rg.unusedregsint then
-        exprasmList.concat(tai_regalloc.Alloc(r));
-      { load he right value }
-      cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,r);
-      location_release(exprasmlist,right.location);
-      { allocate EAX if it isn't yet allocated (JM) }
-      if (RS_EAX in rg.unusedregsint) then
-        exprasmlist.concat(tai_regalloc.Alloc(r));
-      { also allocate EDX, since it is also modified by }
-      { a mul (JM)                                      }
-      r.number:=NR_EDX;
-      if RS_EDX in rg.unusedregsint then
-        exprasmlist.concat(tai_regalloc.Alloc(r));
-      r.number:=NR_EDI;
-      emit_reg(A_MUL,S_L,r);
-      rg.ungetregisterint(exprasmlist,r);
-      r.enum:=R_INTREGISTER;
-      r.number:=NR_EDX;
-      if RS_EDX in rg.unusedregsint then
-        exprasmlist.concat(tai_regalloc.DeAlloc(r));
-      r.number:=NR_EAX;
-      if RS_EAX in rg.unusedregsint then
-        exprasmlist.concat(tai_regalloc.DeAlloc(r));
-      location.register:=rg.getregisterint(exprasmlist,OS_INT);
-      r.number:=NR_EAX;
-      emit_reg_reg(A_MOV,S_L,r,location.register);
-      r.number:=NR_EDX;
-      if popedx then
-        emit_reg(A_POP,S_L,r);
-      r.number:=NR_EAX;
-      if popeax then
-        emit_reg(A_POP,S_L,r);
-      location_freetemp(exprasmlist,left.location);
-      location_freetemp(exprasmlist,right.location);
-    end;
-{$endif}
-
 
 
 {*****************************************************************************
 {*****************************************************************************
                                 pass_2
                                 pass_2
@@ -1633,7 +1446,17 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.75  2003-08-03 20:38:00  daniel
+  Revision 1.76  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.75.2.2  2003/08/31 13:50:16  daniel
+    * Remove sorting and use pregenerated indexes
+    * Some work on making things compile
+
+  Revision 1.75.2.1  2003/08/29 17:29:00  peter
+    * next batch of updates
+
+  Revision 1.75  2003/08/03 20:38:00  daniel
     * Made code generator reverse or/add/and/xor/imul instructions when
     * Made code generator reverse or/add/and/xor/imul instructions when
       possible to reduce the slowdown of spills.
       possible to reduce the slowdown of spills.
 
 

+ 12 - 33
compiler/i386/n386cal.pas

@@ -67,12 +67,9 @@ implementation
 
 
 
 
     procedure ti386callnode.extra_interrupt_code;
     procedure ti386callnode.extra_interrupt_code;
-      var
-        r : Tregister;
       begin
       begin
         emit_none(A_PUSHF,S_L);
         emit_none(A_PUSHF,S_L);
-        r.enum:=R_CS;
-        emit_reg(A_PUSH,S_L,r);
+        emit_reg(A_PUSH,S_L,NR_CS);
       end;
       end;
 
 
 
 
@@ -84,7 +81,6 @@ implementation
          push_size : longint;
          push_size : longint;
 {$endif OPTALIGN}
 {$endif OPTALIGN}
          i : integer;
          i : integer;
-         rsp : tregister;
       begin
       begin
         pop_size:=0;
         pop_size:=0;
         { This parasize aligned on 4 ? }
         { This parasize aligned on 4 ? }
@@ -97,9 +93,7 @@ implementation
         if pop_size>0 then
         if pop_size>0 then
          begin
          begin
            inc(pushedparasize,pop_size);
            inc(pushedparasize,pop_size);
-           rsp.enum:=R_INTREGISTER;
-           rsp.number:=NR_ESP;
-           exprasmlist.concat(taicpu.op_const_reg(A_SUB,S_L,pop_size,rsp));
+           exprasmlist.concat(taicpu.op_const_reg(A_SUB,S_L,pop_size,NR_ESP));
 {$ifdef GDB}
 {$ifdef GDB}
            if (cs_debuginfo in aktmoduleswitches) and
            if (cs_debuginfo in aktmoduleswitches) and
               (exprasmList.first=exprasmList.last) then
               (exprasmList.first=exprasmList.last) then
@@ -142,52 +136,31 @@ implementation
         { better than an add on all processors }
         { better than an add on all processors }
         if pop_size=4 then
         if pop_size=4 then
           begin
           begin
-          {$ifdef newra}
             hreg:=rg.getregisterint(exprasmlist,OS_INT);
             hreg:=rg.getregisterint(exprasmlist,OS_INT);
-          {$else}
-            hreg:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
-          {$endif}
             exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
             exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
-          {$ifdef newra}
             rg.ungetregisterint(exprasmlist,hreg);
             rg.ungetregisterint(exprasmlist,hreg);
-          {$else}
-            cg.free_scratch_reg(exprasmlist,hreg);
-          {$endif newra}
           end
           end
         { the pentium has two pipes and pop reg is pairable }
         { the pentium has two pipes and pop reg is pairable }
         { but the registers must be different!        }
         { but the registers must be different!        }
         else
         else
           if (pop_size=8) and
           if (pop_size=8) and
              not(cs_littlesize in aktglobalswitches) and
              not(cs_littlesize in aktglobalswitches) and
-             (aktoptprocessor=ClassP5)
-             {$ifndef newra} and (rg.countunusedregsint>0){$endif} then
+             (aktoptprocessor=ClassP5) then
             begin
             begin
-            {$ifdef newra}
                hreg:=rg.getregisterint(exprasmlist,OS_INT);
                hreg:=rg.getregisterint(exprasmlist,OS_INT);
-            {$else}
-               hreg:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
-            {$endif}
                exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
                exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
-            {$ifdef newra}
                rg.ungetregisterint(exprasmlist,hreg);
                rg.ungetregisterint(exprasmlist,hreg);
-            {$else}
-               cg.free_scratch_reg(exprasmlist,hreg);
-            {$endif}
                hreg:=rg.getregisterint(exprasmlist,OS_INT);
                hreg:=rg.getregisterint(exprasmlist,OS_INT);
                exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
                exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
                rg.ungetregisterint(exprasmlist,hreg);
                rg.ungetregisterint(exprasmlist,hreg);
             end
             end
         else
         else
           if pop_size<>0 then
           if pop_size<>0 then
-            begin
-              hreg.enum:=R_INTREGISTER;
-              hreg.number:=NR_ESP;
-              exprasmlist.concat(taicpu.op_const_reg(A_ADD,S_L,pop_size,hreg));
-            end;
+            exprasmlist.concat(taicpu.op_const_reg(A_ADD,S_L,pop_size,NR_ESP));
 
 
 {$ifdef OPTALIGN}
 {$ifdef OPTALIGN}
         if pop_esp then
         if pop_esp then
-          emit_reg(A_POP,S_L,rsp);
+          emit_reg(A_POP,S_L,NR_ESP);
 {$endif OPTALIGN}
 {$endif OPTALIGN}
       end;
       end;
 
 
@@ -197,7 +170,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.93  2003-05-30 23:57:08  peter
+  Revision 1.94  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.93.2.1  2003/08/29 17:29:00  peter
+    * next batch of updates
+
+  Revision 1.93  2003/05/30 23:57:08  peter
     * more sparc cleanup
     * more sparc cleanup
     * accumulator removed, splitted in function_return_reg (called) and
     * accumulator removed, splitted in function_return_reg (called) and
       function_result_reg (caller)
       function_result_reg (caller)

+ 25 - 42
compiler/i386/n386cnv.pas

@@ -87,11 +87,10 @@ implementation
          hregister : tregister;
          hregister : tregister;
          l1,l2 : tasmlabel;
          l1,l2 : tasmlabel;
          freereg : boolean;
          freereg : boolean;
-         r:Tregister;
 
 
       begin
       begin
          location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
          location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-         hregister.enum:=R_NO;
+         hregister:=NR_NO;
          freereg:=false;
          freereg:=false;
 
 
          { for u32bit a solution is to push $0 and to load a comp }
          { for u32bit a solution is to push $0 and to load a comp }
@@ -113,11 +112,7 @@ implementation
                    hregister:=left.location.register;
                    hregister:=left.location.register;
                  else
                  else
                    begin
                    begin
-                    {$ifdef newra}
                      hregister:=rg.getregisterint(exprasmlist,OS_32);
                      hregister:=rg.getregisterint(exprasmlist,OS_32);
-                    {$else}
-                     hregister:=cg.get_scratch_reg_int(exprasmlist,OS_32);
-                    {$endif}
                      freereg:=true;
                      freereg:=true;
                      cg.a_load_reg_reg(exprasmlist,left.location.size,OS_32,left.location.register,hregister);
                      cg.a_load_reg_reg(exprasmlist,left.location.size,OS_32,left.location.register,hregister);
                    end;
                    end;
@@ -126,11 +121,7 @@ implementation
            LOC_REFERENCE,
            LOC_REFERENCE,
            LOC_CREFERENCE :
            LOC_CREFERENCE :
              begin
              begin
-              {$ifdef newra}
                hregister:=rg.getregisterint(exprasmlist,OS_INT);
                hregister:=rg.getregisterint(exprasmlist,OS_INT);
-              {$else}
-               hregister:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
-              {$endif newra}
                freereg:=true;
                freereg:=true;
                if left.location.size in [OS_64,OS_S64] then
                if left.location.size in [OS_64,OS_S64] then
                 begin
                 begin
@@ -151,27 +142,20 @@ implementation
 
 
          { for 64 bit integers, the high dword is already pushed }
          { for 64 bit integers, the high dword is already pushed }
          exprasmlist.concat(taicpu.op_reg(A_PUSH,S_L,hregister));
          exprasmlist.concat(taicpu.op_reg(A_PUSH,S_L,hregister));
-        {$ifdef newra}
          if freereg then
          if freereg then
            rg.ungetregisterint(exprasmlist,hregister);
            rg.ungetregisterint(exprasmlist,hregister);
-        {$else}
-         if freereg then
-           cg.free_scratch_reg(exprasmlist,hregister);
-        {$endif}
-         r.enum:=R_INTREGISTER;
-         r.number:=NR_ESP;
-         reference_reset_base(href,r,0);
+         reference_reset_base(href,NR_ESP,0);
          case torddef(left.resulttype.def).typ of
          case torddef(left.resulttype.def).typ of
            u32bit:
            u32bit:
              begin
              begin
                 emit_ref(A_FILD,S_IQ,href);
                 emit_ref(A_FILD,S_IQ,href);
-                emit_const_reg(A_ADD,S_L,8,r);
+                emit_const_reg(A_ADD,S_L,8,NR_ESP);
              end;
              end;
            scurrency,
            scurrency,
            s64bit:
            s64bit:
              begin
              begin
                 emit_ref(A_FILD,S_IQ,href);
                 emit_ref(A_FILD,S_IQ,href);
-                emit_const_reg(A_ADD,S_L,8,r);
+                emit_const_reg(A_ADD,S_L,8,NR_ESP);
              end;
              end;
            u64bit:
            u64bit:
              begin
              begin
@@ -179,22 +163,14 @@ implementation
                 { we load bits 0..62 and then check bit 63:  }
                 { we load bits 0..62 and then check bit 63:  }
                 { if it is 1 then we add $80000000 000000000 }
                 { if it is 1 then we add $80000000 000000000 }
                 { as double                                  }
                 { as double                                  }
-                r.enum:=R_INTREGISTER;
-                r.number:=NR_EDI;
                 inc(href.offset,4);
                 inc(href.offset,4);
-                rg.getexplicitregisterint(exprasmlist,NR_EDI);
-                emit_ref_reg(A_MOV,S_L,href,r);
-                r.enum:=R_INTREGISTER;
-                r.number:=NR_ESP;
-                reference_reset_base(href,r,4);
+                hregister:=rg.getregisterint(exprasmlist,OS_32);
+                emit_ref_reg(A_MOV,S_L,href,hregister);
+                reference_reset_base(href,NR_ESP,4);
                 emit_const_ref(A_AND,S_L,$7fffffff,href);
                 emit_const_ref(A_AND,S_L,$7fffffff,href);
-                r.enum:=R_INTREGISTER;
-                r.number:=NR_EDI;
-                emit_const_reg(A_TEST,S_L,longint($80000000),r);
-                rg.ungetregisterint(exprasmlist,r);
-                r.enum:=R_INTREGISTER;
-                r.number:=NR_ESP;
-                reference_reset_base(href,r,0);
+                emit_const_reg(A_TEST,S_L,longint($80000000),hregister);
+                rg.ungetregisterint(exprasmlist,hregister);
+                reference_reset_base(href,NR_ESP,0);
                 emit_ref(A_FILD,S_IQ,href);
                 emit_ref(A_FILD,S_IQ,href);
                 objectlibrary.getdatalabel(l1);
                 objectlibrary.getdatalabel(l1);
                 objectlibrary.getlabel(l2);
                 objectlibrary.getlabel(l2);
@@ -206,20 +182,18 @@ implementation
                 reference_reset_symbol(href,l1,0);
                 reference_reset_symbol(href,l1,0);
                 emit_ref(A_FADD,S_FL,href);
                 emit_ref(A_FADD,S_FL,href);
                 cg.a_label(exprasmlist,l2);
                 cg.a_label(exprasmlist,l2);
-                emit_const_reg(A_ADD,S_L,8,r);
+                emit_const_reg(A_ADD,S_L,8,NR_ESP);
              end
              end
            else
            else
              begin
              begin
                 emit_ref(A_FILD,S_IL,href);
                 emit_ref(A_FILD,S_IL,href);
-                rg.getexplicitregisterint(exprasmlist,NR_EDI);
-                r.enum:=R_INTREGISTER;
-                r.number:=NR_EDI;
-                emit_reg(A_POP,S_L,r);
-                rg.ungetregisterint(exprasmlist,r);
+                hregister:=rg.getregisterint(exprasmlist,OS_32);
+                emit_reg(A_POP,S_L,hregister);
+                rg.ungetregisterint(exprasmlist,hregister);
              end;
              end;
          end;
          end;
          inc(trgcpu(rg).fpuvaroffset);
          inc(trgcpu(rg).fpuvaroffset);
-         location.register.enum:=R_ST;
+         location.register:=NR_ST;
       end;
       end;
 
 
 
 
@@ -358,7 +332,16 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.62  2003-06-03 21:11:09  peter
+  Revision 1.63  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.62.2.2  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.62.2.1  2003/08/31 13:58:46  daniel
+    * Some more work to make things compile
+
+  Revision 1.62  2003/06/03 21:11:09  peter
     * cg.a_load_* get a from and to size specifier
     * cg.a_load_* get a from and to size specifier
     * makeregsize only accepts newregister
     * makeregsize only accepts newregister
     * i386 uses generic tcgnotnode,tcgunaryminus
     * i386 uses generic tcgnotnode,tcgunaryminus

+ 9 - 3
compiler/i386/n386con.pas

@@ -65,14 +65,14 @@ implementation
            begin
            begin
               emit_none(A_FLD1,S_NO);
               emit_none(A_FLD1,S_NO);
               location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
               location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-              location.register.enum:=R_ST;
+              location.register:=NR_ST;
               inc(trgcpu(rg).fpuvaroffset);
               inc(trgcpu(rg).fpuvaroffset);
            end
            end
          else if (value_real=0.0) then
          else if (value_real=0.0) then
            begin
            begin
               emit_none(A_FLDZ,S_NO);
               emit_none(A_FLDZ,S_NO);
               location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
               location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-              location.register.enum:=R_ST;
+              location.register:=NR_ST;
               inc(trgcpu(rg).fpuvaroffset);
               inc(trgcpu(rg).fpuvaroffset);
            end
            end
          else
          else
@@ -85,7 +85,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.19  2003-04-22 23:50:23  peter
+  Revision 1.20  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.19.2.1  2003/08/29 17:29:00  peter
+    * next batch of updates
+
+  Revision 1.19  2003/04/22 23:50:23  peter
     * firstpass uses expectloc
     * firstpass uses expectloc
     * checks if there are differences between the expectloc and
     * checks if there are differences between the expectloc and
       location.loc from secondpass in EXTDEBUG
       location.loc from secondpass in EXTDEBUG

+ 41 - 56
compiler/i386/n386inl.pas

@@ -164,35 +164,35 @@ implementation
          location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
          location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
          emit_none(A_FLDPI,S_NO);
          emit_none(A_FLDPI,S_NO);
          inc(trgcpu(rg).fpuvaroffset);
          inc(trgcpu(rg).fpuvaroffset);
-         location.register.enum:=FPU_RESULT_REG;
-
+         location.register:=NR_FPU_RESULT_REG;
        end;
        end;
 
 
-       { load the FPU into the an fpu register }
-       procedure ti386inlinenode.load_fpu_location;
-         begin
-           location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-           location.register.enum:=FPU_RESULT_REG;
-           secondpass(left);
-           case left.location.loc of
-             LOC_FPUREGISTER:
-                      ;
-             LOC_CFPUREGISTER:
-               begin
-                 cg.a_loadfpu_reg_reg(exprasmlist,left.location.size,
-                   left.location.register,location.register);
-               end;
-             LOC_REFERENCE,LOC_CREFERENCE:
-               begin
-                 cg.a_loadfpu_ref_reg(exprasmlist,
-                    def_cgsize(left.resulttype.def),
-                    left.location.reference,location.register);
-                 location_release(exprasmlist,left.location);
-               end
-           else
-              internalerror(309991);
-           end;
+     { load the FPU into the an fpu register }
+     procedure ti386inlinenode.load_fpu_location;
+       begin
+         location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
+         location.register:=NR_FPU_RESULT_REG;
+         secondpass(left);
+         case left.location.loc of
+           LOC_FPUREGISTER:
+                    ;
+           LOC_CFPUREGISTER:
+             begin
+               cg.a_loadfpu_reg_reg(exprasmlist,left.location.size,
+                 left.location.register,location.register);
+             end;
+           LOC_REFERENCE,LOC_CREFERENCE:
+             begin
+               cg.a_loadfpu_ref_reg(exprasmlist,
+                  def_cgsize(left.resulttype.def),
+                  left.location.reference,location.register);
+               location_release(exprasmlist,left.location);
+             end
+         else
+            internalerror(309991);
          end;
          end;
+       end;
+
 
 
      procedure ti386inlinenode.second_arctan_real;
      procedure ti386inlinenode.second_arctan_real;
        begin
        begin
@@ -207,14 +207,12 @@ implementation
          emit_none(A_FABS,S_NO);
          emit_none(A_FABS,S_NO);
        end;
        end;
 
 
-     procedure ti386inlinenode.second_sqr_real;
 
 
-     var r:Tregister;
+     procedure ti386inlinenode.second_sqr_real;
 
 
        begin
        begin
          load_fpu_location;
          load_fpu_location;
-         r.enum:=R_ST0;
-         emit_reg_reg(A_FMUL,S_NO,r,r);
+         emit_reg_reg(A_FMUL,S_NO,NR_ST0,NR_ST0);
        end;
        end;
 
 
      procedure ti386inlinenode.second_sqrt_real;
      procedure ti386inlinenode.second_sqrt_real;
@@ -249,11 +247,9 @@ implementation
 
 
       procedure ti386inlinenode.second_IncludeExclude;
       procedure ti386inlinenode.second_IncludeExclude;
         var
         var
-         scratch_reg : boolean;
          hregister : tregister;
          hregister : tregister;
          asmop : tasmop;
          asmop : tasmop;
          L : cardinal;
          L : cardinal;
-         pushedregs : TMaybesave;
          cgop : topcg;
          cgop : topcg;
         begin
         begin
           secondpass(tcallparanode(left).left);
           secondpass(tcallparanode(left).left);
@@ -287,14 +283,7 @@ implementation
           else
           else
             begin
             begin
               { generate code for the element to set }
               { generate code for the element to set }
-            {$ifndef newra}
-              maybe_save(exprasmlist,tcallparanode(tcallparanode(left).right).left.registers32,
-                        tcallparanode(left).left.location,pushedregs);
-            {$endif}
               secondpass(tcallparanode(tcallparanode(left).right).left);
               secondpass(tcallparanode(tcallparanode(left).right).left);
-            {$ifndef newra}
-              maybe_restore(exprasmlist,tcallparanode(left).left.location,pushedregs);
-            {$endif}
               { determine asm operator }
               { determine asm operator }
               if inlinenumber=in_include_x_y then
               if inlinenumber=in_include_x_y then
                  asmop:=A_BTS
                  asmop:=A_BTS
@@ -311,33 +300,20 @@ implementation
                 { need a cmp and jmp, but this should be done by the         }
                 { need a cmp and jmp, but this should be done by the         }
                 { type cast code which does range checking if necessary (FK) }
                 { type cast code which does range checking if necessary (FK) }
                 begin
                 begin
-                  scratch_reg := FALSE;
-                  hregister.enum:=R_INTREGISTER;
-                  hregister.number:=(Tcallparanode(Tcallparanode(left).right).left.location.register.number and not $ff)
-                    or R_SUBWHOLE;
+                  hregister:=Tcallparanode(Tcallparanode(left).right).left.location.register;
+                  setsubreg(hregister,R_SUBWHOLE);
                 end
                 end
               else
               else
                 begin
                 begin
-                  scratch_reg := TRUE;
-                {$ifdef newra}
                   hregister:=rg.getregisterint(exprasmlist,OS_INT);
                   hregister:=rg.getregisterint(exprasmlist,OS_INT);
-                {$else}
-                  hregister:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
-                {$endif newra}
                 end;
                 end;
               cg.a_load_loc_reg(exprasmlist,OS_INT,tcallparanode(tcallparanode(left).right).left.location,hregister);
               cg.a_load_loc_reg(exprasmlist,OS_INT,tcallparanode(tcallparanode(left).right).left.location,hregister);
               if (tcallparanode(left).left.location.loc=LOC_REFERENCE) then
               if (tcallparanode(left).left.location.loc=LOC_REFERENCE) then
                 emit_reg_ref(asmop,S_L,hregister,tcallparanode(left).left.location.reference)
                 emit_reg_ref(asmop,S_L,hregister,tcallparanode(left).left.location.reference)
               else
               else
                 emit_reg_reg(asmop,S_L,hregister,tcallparanode(left).left.location.register);
                 emit_reg_reg(asmop,S_L,hregister,tcallparanode(left).left.location.register);
-            {$ifdef newra}
-{              if scratch_reg then}
-                rg.ungetregisterint(exprasmlist,hregister);
+              rg.ungetregisterint(exprasmlist,hregister);
               location_release(exprasmlist,Tcallparanode(left).left.location);
               location_release(exprasmlist,Tcallparanode(left).left.location);
-            {$else}
-              if scratch_reg then
-                cg.free_scratch_reg(exprasmlist,hregister);
-            {$endif newra}
             end;
             end;
         end;
         end;
 
 
@@ -347,7 +323,16 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.64  2003-07-02 22:18:04  peter
+  Revision 1.65  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.64.2.2  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.64.2.1  2003/08/29 17:29:00  peter
+    * next batch of updates
+
+  Revision 1.64  2003/07/02 22:18:04  peter
     * paraloc splitted in callerparaloc,calleeparaloc
     * paraloc splitted in callerparaloc,calleeparaloc
     * sparc calling convention updates
     * sparc calling convention updates
 
 

+ 69 - 584
compiler/i386/n386mat.pas

@@ -71,14 +71,12 @@ implementation
                              TI386MODDIVNODE
                              TI386MODDIVNODE
 *****************************************************************************}
 *****************************************************************************}
 
 
-{$ifdef newra}
     procedure ti386moddivnode.pass_2;
     procedure ti386moddivnode.pass_2;
 
 
-    var  r,r2,hreg1,hreg2:Tregister;
+    var  hreg1,hreg2:Tregister;
          power:longint;
          power:longint;
          hl:Tasmlabel;
          hl:Tasmlabel;
          op:Tasmop;
          op:Tasmop;
-         pushedregs:Tmaybesave;
 
 
     begin
     begin
       secondpass(left);
       secondpass(left);
@@ -146,15 +144,11 @@ implementation
           {Bring denominator to a register.}
           {Bring denominator to a register.}
           rg.ungetregisterint(exprasmlist,hreg1);
           rg.ungetregisterint(exprasmlist,hreg1);
           rg.getexplicitregisterint(exprasmlist,NR_EAX);
           rg.getexplicitregisterint(exprasmlist,NR_EAX);
-          r.enum:=R_INTREGISTER;
-          r.number:=NR_EAX;
-          r2.enum:=R_INTREGISTER;
-          r2.number:=NR_EDX;
-          emit_reg_reg(A_MOV,S_L,hreg1,r);
+          emit_reg_reg(A_MOV,S_L,hreg1,NR_EAX);
           rg.getexplicitregisterint(exprasmlist,NR_EDX);
           rg.getexplicitregisterint(exprasmlist,NR_EDX);
           {Sign extension depends on the left type.}
           {Sign extension depends on the left type.}
           if torddef(left.resulttype.def).typ=u32bit then
           if torddef(left.resulttype.def).typ=u32bit then
-            emit_reg_reg(A_XOR,S_L,r2,r2)
+            emit_reg_reg(A_XOR,S_L,NR_EDX,NR_EDX)
           else
           else
             emit_none(A_CDQ,S_NO);
             emit_none(A_CDQ,S_NO);
 
 
@@ -180,239 +174,20 @@ implementation
           {Copy the result into a new register. Release EAX & EDX.}
           {Copy the result into a new register. Release EAX & EDX.}
           if nodetype=divn then
           if nodetype=divn then
             begin
             begin
-              rg.ungetregisterint(exprasmlist,r2);
-              rg.ungetregisterint(exprasmlist,r);
+              rg.ungetregisterint(exprasmlist,NR_EDX);
+              rg.ungetregisterint(exprasmlist,NR_EAX);
               location.register:=rg.getregisterint(exprasmlist,OS_INT);
               location.register:=rg.getregisterint(exprasmlist,OS_INT);
-              emit_reg_reg(A_MOV,S_L,r,location.register);
+              emit_reg_reg(A_MOV,S_L,NR_EAX,location.register);
             end
             end
           else
           else
             begin
             begin
-              rg.ungetregisterint(exprasmlist,r);
-              rg.ungetregisterint(exprasmlist,r2);
+              rg.ungetregisterint(exprasmlist,NR_EAX);
+              rg.ungetregisterint(exprasmlist,NR_EDX);
               location.register:=rg.getregisterint(exprasmlist,OS_INT);
               location.register:=rg.getregisterint(exprasmlist,OS_INT);
-              emit_reg_reg(A_MOV,S_L,r2,location.register);
+              emit_reg_reg(A_MOV,S_L,NR_EDX,location.register);
             end;
             end;
         end;
         end;
     end;
     end;
-{$else}
-    procedure ti386moddivnode.pass_2;
-      var
-         hreg1 : tregister;
-         hreg2 : tregister;
-         r,r2  : Tregister;
-         shrdiv,popeax,popedx : boolean;
-         power : longint;
-         hl : tasmlabel;
-         pushedregs : tmaybesave;
-      begin
-         shrdiv := false;
-         secondpass(left);
-         if codegenerror then
-          exit;
-         maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-         secondpass(right);
-         maybe_restore(exprasmlist,left.location,pushedregs);
-         if codegenerror then
-          exit;
-         location_copy(location,left.location);
-
-         if is_64bitint(resulttype.def) then
-           begin
-             { should be handled in pass_1 (JM) }
-             internalerror(200109052);
-           end
-         else
-           begin
-              { put numerator in register }
-              location_force_reg(exprasmlist,left.location,OS_INT,false);
-              hreg1:=left.location.register;
-              if hreg1.enum<>R_INTREGISTER then
-                internalerror(200302042);
-
-              if (nodetype=divn) and (right.nodetype=ordconstn) and
-                 ispowerof2(tordconstnode(right).value,power) then
-                begin
-                  shrdiv := true;
-                  { for signed numbers, the numerator must be adjusted before the
-                    shift instruction, but not wih unsigned numbers! Otherwise,
-                    "Cardinal($ffffffff) div 16" overflows! (JM) }
-                  if is_signed(left.resulttype.def) Then
-                    begin
-                      if (aktOptProcessor <> class386) and
-                         not(CS_LittleSize in aktglobalswitches) then
-                         { use a sequence without jumps, saw this in
-                           comp.compilers (JM) }
-                        begin
-                          { no jumps, but more operations }
-                          if (hreg1.number = NR_EAX) and
-                             (RS_EDX in rg.unusedregsint) then
-                            begin
-                              hreg2 := rg.getexplicitregisterint(exprasmlist,NR_EDX);
-                              emit_none(A_CDQ,S_NO);
-                            end
-                          else
-                            begin
-                              rg.getexplicitregisterint(exprasmlist,NR_EDI);
-                              hreg2.enum := R_INTREGISTER;
-                              hreg2.number := NR_EDI;
-                              emit_reg_reg(A_MOV,S_L,hreg1,hreg2);
-                              { if the left value is signed, R_EDI := $ffffffff,
-                                otherwise 0 }
-                              emit_const_reg(A_SAR,S_L,31,hreg2);
-                              { if signed, R_EDI := right value-1, otherwise 0 }
-                            end;
-                          emit_const_reg(A_AND,S_L,tordconstnode(right).value-1,hreg2);
-                          { add to the left value }
-                          emit_reg_reg(A_ADD,S_L,hreg2,hreg1);
-                          { release EDX if we used it }
-                          { also releas EDI }
-                          rg.ungetregisterint(exprasmlist,hreg2);
-                          { do the shift }
-                          emit_const_reg(A_SAR,S_L,power,hreg1);
-                        end
-                      else
-                        begin
-                          { a jump, but less operations }
-                          emit_reg_reg(A_TEST,S_L,hreg1,hreg1);
-                          objectlibrary.getlabel(hl);
-                          emitjmp(C_NS,hl);
-                          if power=1 then
-                            emit_reg(A_INC,S_L,hreg1)
-                          else
-                            emit_const_reg(A_ADD,S_L,tordconstnode(right).value-1,hreg1);
-                          cg.a_label(exprasmlist,hl);
-                          emit_const_reg(A_SAR,S_L,power,hreg1);
-                        end
-                    end
-                  else
-                    emit_const_reg(A_SHR,S_L,power,hreg1);
-                end
-              else
-                begin
-                  { bring denominator to EDI }
-                  { EDI is always free, it's }
-                  { only used for temporary  }
-                  { purposes              }
-                  rg.getexplicitregisterint(exprasmlist,NR_EDI);
-                  if right.location.loc<>LOC_CREGISTER then
-                   location_release(exprasmlist,right.location);
-                  r.enum:=R_INTREGISTER;
-                  r.number:=NR_EDI;
-                  cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,r);
-                  popedx:=false;
-                  popeax:=false;
-                  r.number:=NR_EAX;
-                  r2.enum:=R_INTREGISTER;
-                  r2.number:=NR_EDX;
-                  if hreg1.number=NR_EDX then
-                    begin
-                      if not(RS_EAX in rg.unusedregsint) then
-                         begin
-                            emit_reg(A_PUSH,S_L,r);
-                            popeax:=true;
-                         end
-                       else
-                         rg.getexplicitregisterint(exprasmlist,NR_EAX);
-                      emit_reg_reg(A_MOV,S_L,r2,r);
-                    end
-                  else
-                    begin
-                       if not(RS_EDX in rg.unusedregsint) then
-                         begin
-                            emit_reg(A_PUSH,S_L,r2);
-                            popedx:=true;
-                         end
-                       else
-                         rg.getexplicitregisterint(exprasmlist,NR_EDX);
-                       if hreg1.number<>NR_EAX then
-                         begin
-                            if not(RS_EAX in rg.unusedregsint) then
-                              begin
-                                 emit_reg(A_PUSH,S_L,r);
-                                 popeax:=true;
-                              end
-                            else
-                              rg.getexplicitregisterint(exprasmlist,NR_EAX);
-                            emit_reg_reg(A_MOV,S_L,hreg1,r);
-                         end;
-                    end;
-                  { sign extension depends on the left type }
-                  if torddef(left.resulttype.def).typ=u32bit then
-                     emit_reg_reg(A_XOR,S_L,r2,r2)
-                  else
-                     emit_none(A_CDQ,S_NO);
-
-                  { division depends on the right type }
-                  r.enum:=R_INTREGISTER;
-                  r.number:=NR_EDI;
-                  if torddef(right.resulttype.def).typ=u32bit then
-                    emit_reg(A_DIV,S_L,r)
-                  else
-                    emit_reg(A_IDIV,S_L,r);
-                  rg.ungetregisterint(exprasmlist,r);
-                  r.enum:=R_INTREGISTER;
-                  r.number:=NR_EAX;
-                  if nodetype=divn then
-                    begin
-                       if not popedx and (hreg1.number <> NR_EDX) then
-                        begin
-                           r2.enum:=R_INTREGISTER;
-                           r2.number:=NR_EDX;
-                           rg.ungetregisterint(exprasmlist,r2);
-                        end;
-                       { if result register is busy then copy }
-                       if popeax then
-                         begin
-                            if hreg1.number=NR_EAX then
-                              internalerror(112);
-                            emit_reg_reg(A_MOV,S_L,r,hreg1)
-                         end
-                       else
-                         if hreg1.number<>NR_EAX then
-                           begin
-                             rg.ungetregisterint(exprasmlist,hreg1);
-                             { no need to allocate eax, that's already done before }
-                             { the div (JM)                                        }
-                             hreg1.number:=NR_EAX;
-                           end;
-                    end
-                  else
-                    begin
-                      if not popeax and (hreg1.number <> NR_EAX)then
-                        begin
-                          r.number:=NR_EAX;
-                          rg.ungetregisterint(exprasmlist,r);
-                        end;
-                      if popedx then
-                       {the mod was done by an (i)div (so the result is now in
-                        edx), but edx was occupied prior to the division, so
-                        move the result into a safe place (JM)}
-                        emit_reg_reg(A_MOV,S_L,r2,hreg1)
-                      else
-                        begin
-                          if hreg1.number <> NR_EDX then
-                            rg.ungetregisterint(exprasmlist,hreg1);
-                          hreg1.number:=NR_EDX
-                        end;
-                    end;
-                  if popeax then
-                    emit_reg(A_POP,S_L,r);
-                  if popedx then
-                    emit_reg(A_POP,S_L,r2);
-                end;
-              If not(shrdiv) then
-               { shrdiv only use hreg1 (which is already in usedinproc,   }
-               { since it was acquired with getregister), the others also }
-               { use both EAX and EDX (JM)                                }
-                begin
-                  include(rg.used_in_proc_int,RS_EAX);
-                  include(rg.used_in_proc_int,RS_EDX);
-                end;
-              location_reset(location,LOC_REGISTER,OS_INT);
-              location.register:=hreg1;
-           end;
-      end;
-{$endif}
 
 
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -426,14 +201,11 @@ implementation
       result := nil;
       result := nil;
     end;
     end;
 
 
-{$ifdef newra}
     procedure ti386shlshrnode.pass_2;
     procedure ti386shlshrnode.pass_2;
 
 
     var hregister2,hregisterhigh,hregisterlow:Tregister;
     var hregister2,hregisterhigh,hregisterlow:Tregister;
-        r,r2:Tregister;
         op:Tasmop;
         op:Tasmop;
         l1,l2,l3:Tasmlabel;
         l1,l2,l3:Tasmlabel;
-        pushedregs:Tmaybesave;
 
 
     begin
     begin
       secondpass(left);
       secondpass(left);
@@ -508,10 +280,6 @@ implementation
               { left operator is already in a register }
               { left operator is already in a register }
               { hence are both in a register }
               { hence are both in a register }
               { is it in the case ECX ? }
               { is it in the case ECX ? }
-              r.enum:=R_INTREGISTER;
-              r.number:=NR_ECX;
-              r2.enum:=R_INTREGISTER;
-              r2.number:=NR_CL;
 
 
               { the damned shift instructions work only til a count of 32 }
               { the damned shift instructions work only til a count of 32 }
               { so we've to do some tricks here                           }
               { so we've to do some tricks here                           }
@@ -529,23 +297,23 @@ implementation
               emit_const_reg(A_SUB,S_L,32,hregister2);
               emit_const_reg(A_SUB,S_L,32,hregister2);
               if nodetype=shln then
               if nodetype=shln then
                 begin
                 begin
-                  emit_reg_reg(A_SHL,S_L,r2,hregisterlow);
+                  emit_reg_reg(A_SHL,S_L,NR_CL,hregisterlow);
                   emit_reg_reg(A_MOV,S_L,hregisterlow,hregisterhigh);
                   emit_reg_reg(A_MOV,S_L,hregisterlow,hregisterhigh);
                   emit_reg_reg(A_XOR,S_L,hregisterlow,hregisterlow);
                   emit_reg_reg(A_XOR,S_L,hregisterlow,hregisterlow);
                   cg.a_jmp_always(exprasmlist,l3);
                   cg.a_jmp_always(exprasmlist,l3);
                   cg.a_label(exprasmlist,l2);
                   cg.a_label(exprasmlist,l2);
-                  emit_reg_reg_reg(A_SHLD,S_L,r2,hregisterlow,hregisterhigh);
-                  emit_reg_reg(A_SHL,S_L,r2,hregisterlow);
+                  emit_reg_reg_reg(A_SHLD,S_L,NR_CL,hregisterlow,hregisterhigh);
+                  emit_reg_reg(A_SHL,S_L,NR_CL,hregisterlow);
                 end
                 end
               else
               else
                 begin
                 begin
-                  emit_reg_reg(A_SHR,S_L,r2,hregisterhigh);
+                  emit_reg_reg(A_SHR,S_L,NR_CL,hregisterhigh);
                   emit_reg_reg(A_MOV,S_L,hregisterhigh,hregisterlow);
                   emit_reg_reg(A_MOV,S_L,hregisterhigh,hregisterlow);
                   emit_reg_reg(A_XOR,S_L,hregisterhigh,hregisterhigh);
                   emit_reg_reg(A_XOR,S_L,hregisterhigh,hregisterhigh);
                   cg.a_jmp_always(exprasmlist,l3);
                   cg.a_jmp_always(exprasmlist,l3);
                   cg.a_label(exprasmlist,l2);
                   cg.a_label(exprasmlist,l2);
-                  emit_reg_reg_reg(A_SHRD,S_L,r2,hregisterhigh,hregisterlow);
-                  emit_reg_reg(A_SHR,S_L,r2,hregisterhigh);
+                  emit_reg_reg_reg(A_SHRD,S_L,NR_CL,hregisterhigh,hregisterlow);
+                  emit_reg_reg(A_SHR,S_L,NR_CL,hregisterhigh);
                 end;
                 end;
               cg.a_label(exprasmlist,l3);
               cg.a_label(exprasmlist,l3);
 
 
@@ -560,9 +328,6 @@ implementation
           location_copy(location,left.location);
           location_copy(location,left.location);
           location_force_reg(exprasmlist,location,OS_INT,false);
           location_force_reg(exprasmlist,location,OS_INT,false);
 
 
-          r2.enum:=R_INTREGISTER;
-          r2.number:=NR_CL;
-
           { shifting by a constant directly coded: }
           { shifting by a constant directly coded: }
           if (right.nodetype=ordconstn) then
           if (right.nodetype=ordconstn) then
             { l shl 32 should 0 imho, but neither TP nor Delphi do it in this way (FK)}
             { l shl 32 should 0 imho, but neither TP nor Delphi do it in this way (FK)}
@@ -576,290 +341,11 @@ implementation
               cg.a_load_loc_reg(exprasmlist,OS_32,right.location,hregister2);
               cg.a_load_loc_reg(exprasmlist,OS_32,right.location,hregister2);
 
 
               { right operand is in ECX }
               { right operand is in ECX }
-              emit_reg_reg(op,S_L,r2,location.register);
+              emit_reg_reg(op,S_L,NR_CL,location.register);
               rg.ungetregisterint(exprasmlist,hregister2);
               rg.ungetregisterint(exprasmlist,hregister2);
             end;
             end;
         end;
         end;
     end;
     end;
-{$else}
-    procedure ti386shlshrnode.pass_2;
-      var
-         hregister2,hregister3,
-         hregisterhigh,hregisterlow : tregister;
-         popecx : boolean;
-         op : tasmop;
-         l1,l2,l3 : tasmlabel;
-         pushedregs : tmaybesave;
-         r,r2:Tregister;
-      begin
-         popecx:=false;
-
-         secondpass(left);
-         maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-         secondpass(right);
-         maybe_restore(exprasmlist,left.location,pushedregs);
-
-         { determine operator }
-         case nodetype of
-           shln: op:=A_SHL;
-           shrn: op:=A_SHR;
-         end;
-
-         if is_64bitint(left.resulttype.def) then
-           begin
-              location_reset(location,LOC_REGISTER,OS_64);
-
-              { load left operator in a register }
-              location_force_reg(exprasmlist,left.location,OS_64,false);
-              hregisterhigh:=left.location.registerhigh;
-              hregisterlow:=left.location.registerlow;
-              if hregisterhigh.enum<>R_INTREGISTER then
-                internalerror(200302056);
-              if hregisterlow.enum<>R_INTREGISTER then
-                internalerror(200302056);
-
-              { shifting by a constant directly coded: }
-              if (right.nodetype=ordconstn) then
-                begin
-                   { shrd/shl works only for values <=31 !! }
-                   if tordconstnode(right).value>31 then
-                     begin
-                        if nodetype=shln then
-                          begin
-                             emit_reg_reg(A_XOR,S_L,hregisterhigh,
-                               hregisterhigh);
-                             if ((tordconstnode(right).value and 31) <> 0) then
-                               emit_const_reg(A_SHL,S_L,tordconstnode(right).value and 31,
-                                 hregisterlow);
-                          end
-                        else
-                          begin
-                             emit_reg_reg(A_XOR,S_L,hregisterlow,
-                               hregisterlow);
-                             if ((tordconstnode(right).value and 31) <> 0) then
-                               emit_const_reg(A_SHR,S_L,tordconstnode(right).value and 31,
-                                 hregisterhigh);
-                          end;
-                        location.registerhigh:=hregisterlow;
-                        location.registerlow:=hregisterhigh;
-                     end
-                   else
-                     begin
-                        if nodetype=shln then
-                          begin
-                             emit_const_reg_reg(A_SHLD,S_L,tordconstnode(right).value and 31,
-                               hregisterlow,hregisterhigh);
-                             emit_const_reg(A_SHL,S_L,tordconstnode(right).value and 31,
-                               hregisterlow);
-                          end
-                        else
-                          begin
-                             emit_const_reg_reg(A_SHRD,S_L,tordconstnode(right).value and 31,
-                               hregisterhigh,hregisterlow);
-                             emit_const_reg(A_SHR,S_L,tordconstnode(right).value and 31,
-                               hregisterhigh);
-                          end;
-                        location.registerlow:=hregisterlow;
-                        location.registerhigh:=hregisterhigh;
-                     end;
-                end
-              else
-                begin
-                   { load right operators in a register }
-                   if right.location.loc<>LOC_REGISTER then
-                     begin
-                       if right.location.loc<>LOC_CREGISTER then
-                        location_release(exprasmlist,right.location);
-                       if (RS_ECX in rg.unusedregsint) then
-                        hregister2:=rg.getexplicitregisterint(exprasmlist,NR_ECX)
-                       else
-                        hregister2:=rg.getregisterint(exprasmlist,OS_INT);
-                       cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,hregister2);
-                     end
-                   else
-                     hregister2:=right.location.register;
-
-                   { left operator is already in a register }
-                   { hence are both in a register }
-                   { is it in the case ECX ? }
-                   r.enum:=R_INTREGISTER;
-                   r.number:=NR_ECX;
-                   r2.enum:=R_INTREGISTER;
-                   r2.number:=NR_CL;
-                   if (hregisterlow.number=NR_ECX) then
-                     begin
-                        { then only swap }
-                        emit_reg_reg(A_XCHG,S_L,hregisterlow,hregister2);
-                        hregister3:=hregisterlow;
-                        hregisterlow:=hregister2;
-                        hregister2:=hregister3;
-                     end
-                   else if (hregisterhigh.number=NR_ECX) then
-                     begin
-                        { then only swap }
-                        emit_reg_reg(A_XCHG,S_L,hregisterhigh,hregister2);
-                        hregister3:=hregisterhigh;
-                        hregisterhigh:=hregister2;
-                        hregister2:=hregister3;
-                     end
-
-                   { if second operator not in ECX ? }
-                   else if (hregister2.number<>NR_ECX) then
-                     begin
-                        { ECX occupied then push it }
-                        if not (RS_ECX in rg.unusedregsint) then
-                         begin
-                           popecx:=true;
-                           emit_reg(A_PUSH,S_L,r);
-                         end
-                        else
-                          rg.getexplicitregisterint(exprasmlist,NR_ECX);
-                        emit_reg_reg(A_MOV,S_L,hregister2,r);
-                     end;
-
-                   if hregister2.number <> NR_ECX then
-                     rg.ungetregisterint(exprasmlist,hregister2);
-
-                   { the damned shift instructions work only til a count of 32 }
-                   { so we've to do some tricks here                           }
-                   if nodetype=shln then
-                     begin
-                        objectlibrary.getlabel(l1);
-                        objectlibrary.getlabel(l2);
-                        objectlibrary.getlabel(l3);
-                        emit_const_reg(A_CMP,S_L,64,r);
-                        emitjmp(C_L,l1);
-                        emit_reg_reg(A_XOR,S_L,hregisterlow,hregisterlow);
-                        emit_reg_reg(A_XOR,S_L,hregisterhigh,hregisterhigh);
-                        cg.a_jmp_always(exprasmlist,l3);
-                        cg.a_label(exprasmlist,l1);
-                        emit_const_reg(A_CMP,S_L,32,r);
-                        emitjmp(C_L,l2);
-                        emit_const_reg(A_SUB,S_L,32,r);
-                        emit_reg_reg(A_SHL,S_L,r2,
-                          hregisterlow);
-                        emit_reg_reg(A_MOV,S_L,hregisterlow,hregisterhigh);
-                        emit_reg_reg(A_XOR,S_L,hregisterlow,hregisterlow);
-                        cg.a_jmp_always(exprasmlist,l3);
-                        cg.a_label(exprasmlist,l2);
-                        emit_reg_reg_reg(A_SHLD,S_L,r2,
-                          hregisterlow,hregisterhigh);
-                        emit_reg_reg(A_SHL,S_L,r2,
-                          hregisterlow);
-                        cg.a_label(exprasmlist,l3);
-                     end
-                   else
-                     begin
-                        objectlibrary.getlabel(l1);
-                        objectlibrary.getlabel(l2);
-                        objectlibrary.getlabel(l3);
-                        emit_const_reg(A_CMP,S_L,64,r);
-                        emitjmp(C_L,l1);
-                        emit_reg_reg(A_XOR,S_L,hregisterlow,hregisterlow);
-                        emit_reg_reg(A_XOR,S_L,hregisterhigh,hregisterhigh);
-                        cg.a_jmp_always(exprasmlist,l3);
-                        cg.a_label(exprasmlist,l1);
-                        emit_const_reg(A_CMP,S_L,32,r);
-                        emitjmp(C_L,l2);
-                        emit_const_reg(A_SUB,S_L,32,r);
-                        emit_reg_reg(A_SHR,S_L,r2,
-                          hregisterhigh);
-                        emit_reg_reg(A_MOV,S_L,hregisterhigh,hregisterlow);
-                        emit_reg_reg(A_XOR,S_L,hregisterhigh,hregisterhigh);
-                        cg.a_jmp_always(exprasmlist,l3);
-                        cg.a_label(exprasmlist,l2);
-                        emit_reg_reg_reg(A_SHRD,S_L,r2,
-                          hregisterhigh,hregisterlow);
-                        emit_reg_reg(A_SHR,S_L,r2,
-                          hregisterhigh);
-                        cg.a_label(exprasmlist,l3);
-
-                     end;
-
-                   { maybe put ECX back }
-                   if popecx then
-                     emit_reg(A_POP,S_L,r)
-                   else
-                     rg.ungetregisterint(exprasmlist,r);
-
-                   location.registerlow:=hregisterlow;
-                   location.registerhigh:=hregisterhigh;
-                end;
-           end
-         else
-           begin
-              { load left operators in a register }
-              location_copy(location,left.location);
-              location_force_reg(exprasmlist,location,OS_INT,false);
-
-              r.enum:=R_INTREGISTER;
-              r.number:=NR_ECX;
-              r2.enum:=R_INTREGISTER;
-              r2.number:=NR_CL;
-
-              { shifting by a constant directly coded: }
-              if (right.nodetype=ordconstn) then
-                begin
-                   { l shl 32 should 0 imho, but neither TP nor Delphi do it in this way (FK)
-                   if right.value<=31 then
-                   }
-                   emit_const_reg(op,S_L,tordconstnode(right).value and 31,
-                     location.register);
-                   {
-                   else
-                     emit_reg_reg(A_XOR,S_L,hregister1,
-                       hregister1);
-                   }
-                end
-              else
-                begin
-                   { load right operators in a register }
-                   if right.location.loc<>LOC_REGISTER then
-                     begin
-                       if right.location.loc<>LOC_CREGISTER then
-                        location_release(exprasmlist,right.location);
-                       hregister2:=rg.getexplicitregisterint(exprasmlist,NR_ECX);
-                       cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,hregister2);
-                     end
-                   else
-                     hregister2:=right.location.register;
-
-                   { left operator is already in a register }
-                   { hence are both in a register }
-                   { is it in the case ECX ? }
-                   if (location.register.number=NR_ECX) then
-                     begin
-                        { then only swap }
-                        emit_reg_reg(A_XCHG,S_L,location.register,hregister2);
-                        hregister3:=location.register;
-                        location.register:=hregister2;
-                        hregister2:=hregister3;
-                     end
-                   { if second operator not in ECX ? }
-                   else if (hregister2.number<>NR_ECX) then
-                     begin
-                        { ECX occupied then push it }
-                        if not (RS_ECX in rg.unusedregsint) then
-                         begin
-                           popecx:=true;
-                           emit_reg(A_PUSH,S_L,r);
-                         end
-                        else
-                          rg.getexplicitregisterint(exprasmlist,NR_ECX);
-                        emit_reg_reg(A_MOV,S_L,hregister2,r);
-                     end;
-                   rg.ungetregisterint(exprasmlist,hregister2);
-                   { right operand is in ECX }
-                   emit_reg_reg(op,S_L,r2,location.register);
-                   { maybe ECX back }
-                   if popecx then
-                     emit_reg(A_POP,S_L,r)
-                   else
-                     rg.ungetregisterint(exprasmlist,r);
-                end;
-           end;
-      end;
-{$endif}
 
 
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -900,7 +386,6 @@ implementation
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
     procedure ti386unaryminusnode.second_mmx;
     procedure ti386unaryminusnode.second_mmx;
       var
       var
-        r : Tregister;
         op : tasmop;
         op : tasmop;
       begin
       begin
         secondpass(left);
         secondpass(left);
@@ -909,23 +394,20 @@ implementation
           LOC_MMXREGISTER:
           LOC_MMXREGISTER:
             begin
             begin
                location.register:=left.location.register;
                location.register:=left.location.register;
-               r.enum:=R_MM7;
-               emit_reg_reg(A_PXOR,S_NO,r,r);
+               emit_reg_reg(A_PXOR,S_NO,NR_MM7,NR_MM7);
             end;
             end;
           LOC_CMMXREGISTER:
           LOC_CMMXREGISTER:
             begin
             begin
                location.register:=rg.getregistermm(exprasmlist);
                location.register:=rg.getregistermm(exprasmlist);
-               r.enum:=R_MM7;
-               emit_reg_reg(A_PXOR,S_NO,r,r);
+               emit_reg_reg(A_PXOR,S_NO,NR_MM7,NR_MM7);
                emit_reg_reg(A_MOVQ,S_NO,left.location.register,location.register);
                emit_reg_reg(A_MOVQ,S_NO,left.location.register,location.register);
             end;
             end;
           LOC_REFERENCE,
           LOC_REFERENCE,
           LOC_CREFERENCE:
           LOC_CREFERENCE:
             begin
             begin
                reference_release(exprasmlist,left.location.reference);
                reference_release(exprasmlist,left.location.reference);
-               r.enum:=R_MM7;
                location.register:=rg.getregistermm(exprasmlist);
                location.register:=rg.getregistermm(exprasmlist);
-               emit_reg_reg(A_PXOR,S_NO,r,r);
+               emit_reg_reg(A_PXOR,S_NO,NR_MM7,NR_MM7);
                emit_ref_reg(A_MOVQ,S_NO,left.location.reference,location.register);
                emit_ref_reg(A_MOVQ,S_NO,left.location.reference,location.register);
             end;
             end;
           else
           else
@@ -951,16 +433,13 @@ implementation
              mmxs32bit,mmxu32bit:
              mmxs32bit,mmxu32bit:
                op:=A_PSUBD;
                op:=A_PSUBD;
           end;
           end;
-        r.enum:=R_MM7;
-        emit_reg_reg(op,S_NO,location.register,r);
-        emit_reg_reg(A_MOVQ,S_NO,r,location.register);
+        emit_reg_reg(op,S_NO,location.register,NR_MM7);
+        emit_reg_reg(A_MOVQ,S_NO,NR_MM7,location.register);
       end;
       end;
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
 
 
 
 
     procedure ti386unaryminusnode.second_float;
     procedure ti386unaryminusnode.second_float;
-      var
-        r : tregister;
       begin
       begin
         secondpass(left);
         secondpass(left);
         location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
         location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
@@ -969,7 +448,7 @@ implementation
           LOC_CREFERENCE:
           LOC_CREFERENCE:
             begin
             begin
               reference_release(exprasmlist,left.location.reference);
               reference_release(exprasmlist,left.location.reference);
-              location.register.enum:=R_ST;
+              location.register:=NR_ST;
               cg.a_loadfpu_ref_reg(exprasmlist,
               cg.a_loadfpu_ref_reg(exprasmlist,
                  def_cgsize(left.resulttype.def),
                  def_cgsize(left.resulttype.def),
                  left.location.reference,location.register);
                  left.location.reference,location.register);
@@ -979,9 +458,8 @@ implementation
           LOC_CFPUREGISTER:
           LOC_CFPUREGISTER:
             begin
             begin
                { "load st,st" is ignored by the code generator }
                { "load st,st" is ignored by the code generator }
-               r.enum:=R_ST;
-               cg.a_loadfpu_reg_reg(exprasmlist,left.location.size,left.location.register,r);
-               location.register.enum:=R_ST;
+               cg.a_loadfpu_reg_reg(exprasmlist,left.location.size,left.location.register,NR_ST);
+               location.register:=NR_ST;
                emit_none(A_FCHS,S_NO);
                emit_none(A_FCHS,S_NO);
             end;
             end;
         end;
         end;
@@ -1046,44 +524,41 @@ implementation
 
 
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
     procedure ti386notnode.second_mmx;
     procedure ti386notnode.second_mmx;
-      var
-         r,r2 : tregister;
-      begin
-        secondpass(left);
-        location_reset(location,LOC_MMXREGISTER,OS_NO);
-        { prepare EDI }
-        r.enum:=R_INTREGISTER;
-        r.number:=NR_EDI;
-        r2.enum:=R_MM7;
-        rg.getexplicitregisterint(exprasmlist,NR_EDI);
-        emit_const_reg(A_MOV,S_L,longint($ffffffff),r);
-        { load operand }
-        case left.location.loc of
-          LOC_MMXREGISTER:
-            location_copy(location,left.location);
-          LOC_CMMXREGISTER:
-            begin
-              location.register:=rg.getregistermm(exprasmlist);
-              emit_reg_reg(A_MOVQ,S_NO,left.location.register,location.register);
-            end;
-          LOC_REFERENCE,
-          LOC_CREFERENCE:
-            begin
-              location_release(exprasmlist,left.location);
-              location.register:=rg.getregistermm(exprasmlist);
-              emit_ref_reg(A_MOVQ,S_NO,left.location.reference,location.register);
-            end;
-        end;
-        { load mask }
-        emit_reg_reg(A_MOVD,S_NO,r,r2);
-        rg.ungetregisterint(exprasmlist,r);
-        { lower 32 bit }
-        emit_reg_reg(A_PXOR,S_D,r2,location.register);
-        { shift mask }
-        emit_const_reg(A_PSLLQ,S_NO,32,r2);
-        { higher 32 bit }
-        emit_reg_reg(A_PXOR,S_D,r2,location.register);
+
+    var r:Tregister;
+
+    begin
+      secondpass(left);
+      location_reset(location,LOC_MMXREGISTER,OS_NO);
+      r:=rg.getregisterint(exprasmlist,OS_INT);
+      emit_const_reg(A_MOV,S_L,longint($ffffffff),r);
+      { load operand }
+      case left.location.loc of
+        LOC_MMXREGISTER:
+          location_copy(location,left.location);
+        LOC_CMMXREGISTER:
+          begin
+            location.register:=rg.getregistermm(exprasmlist);
+            emit_reg_reg(A_MOVQ,S_NO,left.location.register,location.register);
+          end;
+        LOC_REFERENCE,
+        LOC_CREFERENCE:
+          begin
+            location_release(exprasmlist,left.location);
+            location.register:=rg.getregistermm(exprasmlist);
+            emit_ref_reg(A_MOVQ,S_NO,left.location.reference,location.register);
+          end;
       end;
       end;
+      { load mask }
+      emit_reg_reg(A_MOVD,S_NO,r,NR_MM7);
+      rg.ungetregisterint(exprasmlist,r);
+      { lower 32 bit }
+      emit_reg_reg(A_PXOR,S_D,NR_MM7,location.register);
+      { shift mask }
+      emit_const_reg(A_PSLLQ,S_NO,32,NR_MM7);
+      { higher 32 bit }
+      emit_reg_reg(A_PXOR,S_D,NR_MM7,location.register);
+    end;
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
 
 
 begin
 begin
@@ -1094,7 +569,17 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.59  2003-07-02 22:18:04  peter
+  Revision 1.60  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.59.2.2  2003/08/31 13:50:16  daniel
+    * Remove sorting and use pregenerated indexes
+    * Some work on making things compile
+
+  Revision 1.59.2.1  2003/08/29 17:29:00  peter
+    * next batch of updates
+
+  Revision 1.59  2003/07/02 22:18:04  peter
     * paraloc splitted in callerparaloc,calleeparaloc
     * paraloc splitted in callerparaloc,calleeparaloc
     * sparc calling convention updates
     * sparc calling convention updates
 
 

+ 16 - 19
compiler/i386/n386mem.pas

@@ -27,7 +27,7 @@ unit n386mem;
 interface
 interface
 
 
     uses
     uses
-      cpuinfo,cpubase,
+      cginfo,cpuinfo,cpubase,
       node,nmem,ncgmem;
       node,nmem,ncgmem;
 
 
     type
     type
@@ -54,7 +54,6 @@ implementation
       cutils,verbose,
       cutils,verbose,
       symdef,paramgr,
       symdef,paramgr,
       aasmtai,
       aasmtai,
-      cginfo,
       nld,ncon,nadd,
       nld,ncon,nadd,
       cgobj,tgobj,rgobj;
       cgobj,tgobj,rgobj;
 
 
@@ -67,7 +66,7 @@ implementation
       begin
       begin
         inherited pass_2;
         inherited pass_2;
         { for use of other segments }
         { for use of other segments }
-        if left.location.reference.segment.enum<>R_NO then
+        if left.location.reference.segment<>NR_NO then
           location.segment:=left.location.reference.segment;
           location.segment:=left.location.reference.segment;
       end;
       end;
 
 
@@ -80,10 +79,7 @@ implementation
       begin
       begin
          inherited pass_2;
          inherited pass_2;
          if tpointerdef(left.resulttype.def).is_far then
          if tpointerdef(left.resulttype.def).is_far then
-          begin
-            location.reference.segment.enum:=R_INTREGISTER;
-            location.reference.segment.number:=NR_FS;
-          end;
+           location.reference.segment:=NR_FS;
       end;
       end;
 
 
 
 
@@ -95,16 +91,12 @@ implementation
        var
        var
          l2 : integer;
          l2 : integer;
        begin
        begin
-         if location.reference.base.enum<>R_INTREGISTER then
-          internalerror(200302055);
-         if location.reference.index.enum<>R_INTREGISTER then
-          internalerror(200302055);
          { Optimized for x86 to use the index register and scalefactor }
          { Optimized for x86 to use the index register and scalefactor }
-         if location.reference.index.number=NR_NO then
+         if location.reference.index=NR_NO then
           begin
           begin
             { no preparations needed }
             { no preparations needed }
           end
           end
-         else if location.reference.base.number=NR_NO then
+         else if location.reference.base=NR_NO then
           begin
           begin
             case location.reference.scalefactor of
             case location.reference.scalefactor of
              2 : cg.a_op_const_reg(exprasmlist,OP_SHL,OS_ADDR,1,location.reference.index);
              2 : cg.a_op_const_reg(exprasmlist,OP_SHL,OS_ADDR,1,location.reference.index);
@@ -138,12 +130,8 @@ implementation
     procedure ti386vecnode.pass_2;
     procedure ti386vecnode.pass_2;
       begin
       begin
         inherited pass_2;
         inherited pass_2;
-
         if nf_memseg in flags then
         if nf_memseg in flags then
-          begin
-            location.reference.segment.enum:=R_INTREGISTER;
-            location.reference.segment.number:=NR_FS;
-          end;
+          location.reference.segment:=NR_FS;
       end;
       end;
 
 
 
 
@@ -154,7 +142,16 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.53  2003-06-01 21:38:06  peter
+  Revision 1.54  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.53.2.2  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.53.2.1  2003/08/29 17:29:00  peter
+    * next batch of updates
+
+  Revision 1.53  2003/06/01 21:38:06  peter
     * getregisterfpu size parameter added
     * getregisterfpu size parameter added
     * op_const_reg size parameter added
     * op_const_reg size parameter added
     * sparc updates
     * sparc updates

+ 20 - 33
compiler/i386/n386obj.pas

@@ -36,7 +36,7 @@ uses
   symconst,symtype,symdef,symsym,
   symconst,symtype,symdef,symsym,
   fmodule,
   fmodule,
   nobj,
   nobj,
-  cpubase,
+  cpubase,cginfo,
   cga,tgobj,rgobj,cgobj;
   cga,tgobj,rgobj,cgobj;
 
 
    type
    type
@@ -110,51 +110,38 @@ procedure ti386classheader.cgintfwrapper(asmlist: TAAsmoutput; procdef: tprocdef
   procedure getselftoeax(offs: longint);
   procedure getselftoeax(offs: longint);
   var
   var
     href : treference;
     href : treference;
-    r:Tregister;
   begin
   begin
     { mov offset(%esp),%eax }
     { mov offset(%esp),%eax }
-    r.enum:=R_INTREGISTER;
-    r.number:=NR_ESP;
-    reference_reset_base(href,r,getselfoffsetfromsp(procdef));
-    r.number:=NR_EAX;
-    cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,href,r);
+    reference_reset_base(href,NR_ESP,getselfoffsetfromsp(procdef));
+    cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,href,NR_EAX);
   end;
   end;
 
 
   procedure loadvmttoeax;
   procedure loadvmttoeax;
   var
   var
     href : treference;
     href : treference;
-    r:Tregister;
   begin
   begin
     checkvirtual;
     checkvirtual;
     { mov  0(%eax),%eax ; load vmt}
     { mov  0(%eax),%eax ; load vmt}
-    r.enum:=R_INTREGISTER;
-    r.number:=NR_EAX;
-    reference_reset_base(href,r,0);
-    emit_ref_reg(A_MOV,S_L,href,r);
+    reference_reset_base(href,NR_EAX,0);
+    emit_ref_reg(A_MOV,S_L,href,NR_EAX);
   end;
   end;
 
 
   procedure op_oneaxmethodaddr(op: TAsmOp);
   procedure op_oneaxmethodaddr(op: TAsmOp);
   var
   var
     href : treference;
     href : treference;
-    r:Tregister;
   begin
   begin
     { call/jmp  vmtoffs(%eax) ; method offs }
     { call/jmp  vmtoffs(%eax) ; method offs }
-    r.enum:=R_INTREGISTER;
-    r.number:=NR_EAX;
-    reference_reset_base(href,r,procdef._class.vmtmethodoffset(procdef.extnumber));
+    reference_reset_base(href,NR_EAX,procdef._class.vmtmethodoffset(procdef.extnumber));
     emit_ref(op,S_L,href);
     emit_ref(op,S_L,href);
   end;
   end;
 
 
   procedure loadmethodoffstoeax;
   procedure loadmethodoffstoeax;
   var
   var
     href : treference;
     href : treference;
-    r:Tregister;
   begin
   begin
     { mov  vmtoffs(%eax),%eax ; method offs }
     { mov  vmtoffs(%eax),%eax ; method offs }
-    r.enum:=R_INTREGISTER;
-    r.number:=NR_EAX;
-    reference_reset_base(href,r,procdef._class.vmtmethodoffset(procdef.extnumber));
-    emit_ref_reg(A_MOV,S_L,href,r);
+    reference_reset_base(href,NR_EAX,procdef._class.vmtmethodoffset(procdef.extnumber));
+    emit_ref_reg(A_MOV,S_L,href,NR_EAX);
   end;
   end;
 
 
 var
 var
@@ -162,7 +149,6 @@ var
   lab : tasmsymbol;
   lab : tasmsymbol;
   make_global : boolean;
   make_global : boolean;
   href : treference;
   href : treference;
-  r:Tregister;
 begin
 begin
   if procdef.proctypeoption<>potype_none then
   if procdef.proctypeoption<>potype_none then
     Internalerror(200006137);
     Internalerror(200006137);
@@ -207,21 +193,16 @@ begin
   { case 3 }
   { case 3 }
   else if [po_virtualmethod,po_saveregisters]*procdef.procoptions=[po_virtualmethod,po_saveregisters] then
   else if [po_virtualmethod,po_saveregisters]*procdef.procoptions=[po_virtualmethod,po_saveregisters] then
     begin
     begin
-      r.enum:=R_INTREGISTER;
-      r.number:=NR_EBX;
-      emit_reg(A_PUSH,S_L,r); { allocate space for address}
-      r.number:=NR_EAX;
-      emit_reg(A_PUSH,S_L,r);
+      emit_reg(A_PUSH,S_L,NR_EBX); { allocate space for address}
+      emit_reg(A_PUSH,S_L,NR_EAX);
       getselftoeax(8);
       getselftoeax(8);
       loadvmttoeax;
       loadvmttoeax;
       loadmethodoffstoeax;
       loadmethodoffstoeax;
       { mov %eax,4(%esp) }
       { mov %eax,4(%esp) }
-      r.number:=NR_ESP;
-      reference_reset_base(href,r,4);
-      r.number:=NR_EAX;
-      emit_reg_ref(A_MOV,S_L,r,href);
+      reference_reset_base(href,NR_ESP,4);
+      emit_reg_ref(A_MOV,S_L,NR_EAX,href);
       { pop  %eax }
       { pop  %eax }
-      emit_reg(A_POP,S_L,r);
+      emit_reg(A_POP,S_L,NR_EAX);
       { ret  ; jump to the address }
       { ret  ; jump to the address }
       emit_none(A_RET,S_L);
       emit_none(A_RET,S_L);
     end
     end
@@ -247,7 +228,13 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.20  2003-06-03 21:11:09  peter
+  Revision 1.21  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.20.2.1  2003/08/29 17:29:00  peter
+    * next batch of updates
+
+  Revision 1.20  2003/06/03 21:11:09  peter
     * cg.a_load_* get a from and to size specifier
     * cg.a_load_* get a from and to size specifier
     * makeregsize only accepts newregister
     * makeregsize only accepts newregister
     * i386 uses generic tcgnotnode,tcgunaryminus
     * i386 uses generic tcgnotnode,tcgunaryminus

+ 18 - 53
compiler/i386/n386set.pas

@@ -100,7 +100,6 @@ implementation
          setparts   : array[1..8] of Tsetpart;
          setparts   : array[1..8] of Tsetpart;
          i,numparts : byte;
          i,numparts : byte;
          adjustment : longint;
          adjustment : longint;
-         pushedregs : tmaybesave;
          l,l2       : tasmlabel;
          l,l2       : tasmlabel;
          r          : Tregister;
          r          : Tregister;
 {$ifdef CORRECT_SET_IN_FPC}
 {$ifdef CORRECT_SET_IN_FPC}
@@ -108,8 +107,6 @@ implementation
 {$endif CORRECT_SET_IN_FPC}
 {$endif CORRECT_SET_IN_FPC}
 
 
          function analizeset(Aset:pconstset;is_small:boolean):boolean;
          function analizeset(Aset:pconstset;is_small:boolean):boolean;
-           type
-             byteset=set of byte;
            var
            var
              compares,maxcompares:word;
              compares,maxcompares:word;
              i:byte;
              i:byte;
@@ -194,13 +191,7 @@ implementation
          { Only process the right if we are not generating jumps }
          { Only process the right if we are not generating jumps }
          if not genjumps then
          if not genjumps then
           begin
           begin
-          {$ifndef newra}
-            maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-          {$endif}
             secondpass(right);
             secondpass(right);
-          {$ifndef newra}
-            maybe_restore(exprasmlist,left.location,pushedregs);
-          {$endif newra}
           end;
           end;
          if codegenerror then
          if codegenerror then
           exit;
           exit;
@@ -221,10 +212,10 @@ implementation
              begin
              begin
                { for ranges we always need a 32bit register, because then we }
                { for ranges we always need a 32bit register, because then we }
                { use the register as base in a reference (JM)                }
                { use the register as base in a reference (JM)                }
-               pleftreg.enum:=R_INTREGISTER;
                if ranges then
                if ranges then
                  begin
                  begin
-                   pleftreg.number:=(left.location.register.number and not $ff) or R_SUBWHOLE;
+                   pleftreg:=left.location.register;
+                   setsubreg(pleftreg,R_SUBWHOLE);
                    cg.a_load_reg_reg(exprasmlist,left.location.size,OS_INT,left.location.register,pleftreg);
                    cg.a_load_reg_reg(exprasmlist,left.location.size,OS_INT,left.location.register,pleftreg);
                    if opsize <> S_L then
                    if opsize <> S_L then
                      emit_const_reg(A_AND,S_L,255,pleftreg);
                      emit_const_reg(A_AND,S_L,255,pleftreg);
@@ -234,18 +225,15 @@ implementation
                  { otherwise simply use the lower 8 bits (no "and" }
                  { otherwise simply use the lower 8 bits (no "and" }
                  { necessary this way) (JM)                        }
                  { necessary this way) (JM)                        }
                  begin
                  begin
-                   pleftreg.number:=(left.location.register.number and not $ff) or R_SUBL;
+                   pleftreg:=left.location.register;
+                   setsubreg(pleftreg,R_SUBL);
                    opsize := S_B;
                    opsize := S_B;
                  end;
                  end;
              end
              end
             else
             else
              begin
              begin
                { load the value in a register }
                { load the value in a register }
-             {$ifdef newra}
                pleftreg:=rg.getregisterint(exprasmlist,OS_INT);
                pleftreg:=rg.getregisterint(exprasmlist,OS_INT);
-             {$else}
-               pleftreg := rg.getexplicitregisterint(exprasmlist,NR_EDI);
-             {$endif}
                opsize := S_L;
                opsize := S_L;
                emit_ref_reg(A_MOVZX,S_BL,left.location.reference,pleftreg);
                emit_ref_reg(A_MOVZX,S_BL,left.location.reference,pleftreg);
                location_release(exprasmlist,left.location);
                location_release(exprasmlist,left.location);
@@ -267,7 +255,7 @@ implementation
             { "x in [y..z]" expression                               }
             { "x in [y..z]" expression                               }
             adjustment := 0;
             adjustment := 0;
 
 
-            r.enum:=R_NO;
+            r:=NR_NO;
             for i:=1 to numparts do
             for i:=1 to numparts do
              if setparts[i].range then
              if setparts[i].range then
               { use fact that a <= x <= b <=> cardinal(x-a) <= cardinal(b-a) }
               { use fact that a <= x <= b <=> cardinal(x-a) <= cardinal(b-a) }
@@ -281,17 +269,10 @@ implementation
                       { so in case of a LOC_CREGISTER first move the value }
                       { so in case of a LOC_CREGISTER first move the value }
                       { to edi (not done before because now we can do the  }
                       { to edi (not done before because now we can do the  }
                       { move and substract in one instruction with LEA)    }
                       { move and substract in one instruction with LEA)    }
-                      if {$ifndef newra}(pleftreg.number <> NR_EDI) and{$endif}
-                         (left.location.loc = LOC_CREGISTER) then
+                      if (left.location.loc = LOC_CREGISTER) then
                         begin
                         begin
                           rg.ungetregister(exprasmlist,pleftreg);
                           rg.ungetregister(exprasmlist,pleftreg);
-                        {$ifdef newra}
                           r:=rg.getregisterint(exprasmlist,OS_INT);
                           r:=rg.getregisterint(exprasmlist,OS_INT);
-                        {$else}
-                          r.enum:=R_INTREGISTER;
-                          r.number:=NR_EDI;
-                          rg.getexplicitregisterint(exprasmlist,NR_EDI);
-                        {$endif}
                           reference_reset_base(href,pleftreg,-setparts[i].start);
                           reference_reset_base(href,pleftreg,-setparts[i].start);
                           emit_ref_reg(A_LEA,S_L,href,r);
                           emit_ref_reg(A_LEA,S_L,href,r);
                           { only now change pleftreg since previous value is }
                           { only now change pleftreg since previous value is }
@@ -352,24 +333,9 @@ implementation
              right.location.reference.symbol:=nil;
              right.location.reference.symbol:=nil;
              { Now place the end label }
              { Now place the end label }
              cg.a_label(exprasmlist,l);
              cg.a_label(exprasmlist,l);
-          {$ifdef newra}
              rg.ungetregisterint(exprasmlist,pleftreg);
              rg.ungetregisterint(exprasmlist,pleftreg);
-             if r.enum=R_INTREGISTER then
+             if r<>NR_NO then
               rg.ungetregisterint(exprasmlist,r);
               rg.ungetregisterint(exprasmlist,r);
-          {$else}
-             case left.location.loc of
-               LOC_REGISTER,
-               LOC_CREGISTER :
-                 rg.ungetregisterint(exprasmlist,pleftreg);
-               else
-                 begin
-                   reference_release(exprasmlist,left.location.reference);
-                   r.enum:=R_INTREGISTER;
-                   r.number:=NR_EDI;
-                   rg.ungetregisterint(exprasmlist,r);
-                 end;
-             end;
-          {$endif}
           end
           end
          else
          else
           begin
           begin
@@ -414,11 +380,8 @@ implementation
                       { the set element isn't never samller than a byte  }
                       { the set element isn't never samller than a byte  }
                       { and because it's a small set we need only 5 bits }
                       { and because it's a small set we need only 5 bits }
                       { but 8 bits are easier to load               }
                       { but 8 bits are easier to load               }
-                      r.enum:=R_INTREGISTER;
-                      r.number:=NR_EDI;
-                      rg.getexplicitregisterint(exprasmlist,NR_EDI);
-                      emit_ref_reg(A_MOVZX,S_BL,left.location.reference,r);
-                      hr:=r;
+                      hr:=rg.getregisterint(exprasmlist,OS_INT);
+                      emit_ref_reg(A_MOVZX,S_BL,left.location.reference,hr);
                       location_release(exprasmlist,left.location);
                       location_release(exprasmlist,left.location);
                     end;
                     end;
                   end;
                   end;
@@ -532,15 +495,11 @@ implementation
                 begin
                 begin
                   if (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
                   if (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
                     begin
                     begin
-                      pleftreg.enum:=R_INTREGISTER;
-                      pleftreg.number:=(left.location.register.number and not $ff) or R_SUBWHOLE;
+                      pleftreg:=left.location.register;
+                      setsubreg(pleftreg,R_SUBWHOLE);
                     end
                     end
                   else
                   else
-                  {$ifdef newra}
                     pleftreg:=rg.getregisterint(exprasmlist,OS_INT);
                     pleftreg:=rg.getregisterint(exprasmlist,OS_INT);
-                  {$else}
-                    pleftreg:=rg.getexplicitregisterint(exprasmlist,NR_EDI);
-                  {$endif}
                   cg.a_load_loc_reg(exprasmlist,OS_INT,left.location,pleftreg);
                   cg.a_load_loc_reg(exprasmlist,OS_INT,left.location,pleftreg);
                   location_freetemp(exprasmlist,left.location);
                   location_freetemp(exprasmlist,left.location);
                   location_release(exprasmlist,left.location);
                   location_release(exprasmlist,left.location);
@@ -730,7 +689,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.62  2003-06-12 22:10:44  jonas
+  Revision 1.63  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.62.2.1  2003/08/29 17:29:00  peter
+    * next batch of updates
+
+  Revision 1.62  2003/06/12 22:10:44  jonas
     * t386innode.pass_2 already doesn't call a helper anymore since a long
     * t386innode.pass_2 already doesn't call a helper anymore since a long
       time
       time
 
 

+ 72 - 0
compiler/i386/r386ari.inc

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

+ 72 - 0
compiler/i386/r386att.inc

@@ -0,0 +1,72 @@
+{ don't edit, this file is generated from x86reg.dat }
+'INVALID',
+'%al',
+'%ah',
+'%ax',
+'%eax',
+'%cl',
+'%ch',
+'%cx',
+'%ecx',
+'%dl',
+'%dh',
+'%dx',
+'%edx',
+'%bl',
+'%bh',
+'%bx',
+'%ebx',
+'%si',
+'%esi',
+'%di',
+'%edi',
+'%bp',
+'%ebp',
+'%sp',
+'%esp',
+'%cs',
+'%ds',
+'%es',
+'%ss',
+'%fs',
+'%gs',
+'%dr0',
+'%dr1',
+'%dr2',
+'%dr3',
+'%dr6',
+'%dr7',
+'%cr0',
+'%cr2',
+'%cr3',
+'%cr4',
+'%tr3',
+'%tr4',
+'%tr5',
+'%tr6',
+'%tr7',
+'%st(0)',
+'%st(1)',
+'%st(2)',
+'%st(3)',
+'%st(4)',
+'%st(5)',
+'%st(6)',
+'%st(7)',
+'%st',
+'%mm0',
+'%mm1',
+'%mm2',
+'%mm3',
+'%mm4',
+'%mm5',
+'%mm6',
+'%mm7',
+'%xmm0',
+'%xmm1',
+'%xmm2',
+'%xmm3',
+'%xmm4',
+'%xmm5',
+'%xmm6',
+'%xmm7'

+ 72 - 0
compiler/i386/r386con.inc

@@ -0,0 +1,72 @@
+{ don't edit, this file is generated from x86reg.dat }
+NR_NO = $00000000;
+NR_AL = $01010000;
+NR_AH = $01020000;
+NR_AX = $01030000;
+NR_EAX = $01040000;
+NR_CL = $01010001;
+NR_CH = $01020001;
+NR_CX = $01030001;
+NR_ECX = $01040001;
+NR_DL = $01010002;
+NR_DH = $01020002;
+NR_DX = $01030002;
+NR_EDX = $01040002;
+NR_BL = $01010003;
+NR_BH = $01020003;
+NR_BX = $01030003;
+NR_EBX = $01040003;
+NR_SI = $01030004;
+NR_ESI = $01040004;
+NR_DI = $01030005;
+NR_EDI = $01040005;
+NR_BP = $01030006;
+NR_EBP = $01040006;
+NR_SP = $01030007;
+NR_ESP = $01040007;
+NR_CS = $05000001;
+NR_DS = $05000002;
+NR_ES = $05000003;
+NR_SS = $05000004;
+NR_FS = $05000005;
+NR_GS = $05000006;
+NR_DR0 = $05000007;
+NR_DR1 = $05000008;
+NR_DR2 = $05000009;
+NR_DR3 = $0500000a;
+NR_DR6 = $0500000b;
+NR_DR7 = $0500000c;
+NR_CR0 = $0500000d;
+NR_CR2 = $0500000e;
+NR_CR3 = $0500000f;
+NR_CR4 = $05000010;
+NR_TR3 = $05000011;
+NR_TR4 = $05000012;
+NR_TR5 = $05000013;
+NR_TR6 = $05000014;
+NR_TR7 = $05000015;
+NR_ST0 = $02000000;
+NR_ST1 = $02000001;
+NR_ST2 = $02000002;
+NR_ST3 = $02000003;
+NR_ST4 = $02000004;
+NR_ST5 = $02000005;
+NR_ST6 = $02000006;
+NR_ST7 = $02000007;
+NR_ST = $02000008;
+NR_MM0 = $03000000;
+NR_MM1 = $03000001;
+NR_MM2 = $03000002;
+NR_MM3 = $03000003;
+NR_MM4 = $03000004;
+NR_MM5 = $03000005;
+NR_MM6 = $03000006;
+NR_MM7 = $03000007;
+NR_XMM0 = $04000000;
+NR_XMM1 = $04000001;
+NR_XMM2 = $04000002;
+NR_XMM3 = $04000003;
+NR_XMM4 = $04000004;
+NR_XMM5 = $04000005;
+NR_XMM6 = $04000006;
+NR_XMM7 = $04000007;

+ 72 - 0
compiler/i386/r386int.inc

@@ -0,0 +1,72 @@
+{ don't edit, this file is generated from x86reg.dat }
+'INVALID',
+'al',
+'ah',
+'ax',
+'eax',
+'cl',
+'ch',
+'cx',
+'ecx',
+'dl',
+'dh',
+'dx',
+'edx',
+'bl',
+'bh',
+'bx',
+'ebx',
+'si',
+'esi',
+'di',
+'edi',
+'bp',
+'ebp',
+'sp',
+'esp',
+'cs',
+'ds',
+'es',
+'ss',
+'fs',
+'gs',
+'dr0',
+'dr1',
+'dr2',
+'dr3',
+'dr6',
+'dr7',
+'cr0',
+'cr2',
+'cr3',
+'cr4',
+'tr3',
+'tr4',
+'tr5',
+'tr6',
+'tr7',
+'st(0)',
+'st(1)',
+'st(2)',
+'st(3)',
+'st(4)',
+'st(5)',
+'st(6)',
+'st(7)',
+'st',
+'mm0',
+'mm1',
+'mm2',
+'mm3',
+'mm4',
+'mm5',
+'mm6',
+'mm7',
+'xmm0',
+'xmm1',
+'xmm2',
+'xmm3',
+'xmm4',
+'xmm5',
+'xmm6',
+'xmm7'

+ 72 - 0
compiler/i386/r386iri.inc

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

+ 72 - 0
compiler/i386/r386nasm.inc

@@ -0,0 +1,72 @@
+{ don't edit, this file is generated from x86reg.dat }
+'INVALID',
+'al',
+'ah',
+'ax',
+'eax',
+'cl',
+'ch',
+'cx',
+'ecx',
+'dl',
+'dh',
+'dx',
+'edx',
+'bl',
+'bh',
+'bx',
+'ebx',
+'si',
+'esi',
+'di',
+'edi',
+'bp',
+'ebp',
+'sp',
+'esp',
+'cs',
+'ds',
+'es',
+'ss',
+'fs',
+'gs',
+'dr0',
+'dr1',
+'dr2',
+'dr3',
+'dr6',
+'dr7',
+'cr0',
+'cr2',
+'cr3',
+'cr4',
+'tr3',
+'tr4',
+'tr5',
+'tr6',
+'tr7',
+'st0',
+'st1',
+'st2',
+'st3',
+'st4',
+'st5',
+'st6',
+'st7',
+'st',
+'mm0',
+'mm1',
+'mm2',
+'mm3',
+'mm4',
+'mm5',
+'mm6',
+'mm7',
+'xmm0',
+'xmm1',
+'xmm2',
+'xmm3',
+'xmm4',
+'xmm5',
+'xmm6',
+'xmm7'

+ 2 - 0
compiler/i386/r386nor.inc

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

+ 72 - 0
compiler/i386/r386nri.inc

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

+ 72 - 0
compiler/i386/r386num.inc

@@ -0,0 +1,72 @@
+{ don't edit, this file is generated from x86reg.dat }
+$00000000,
+$01010000,
+$01020000,
+$01030000,
+$01040000,
+$01010001,
+$01020001,
+$01030001,
+$01040001,
+$01010002,
+$01020002,
+$01030002,
+$01040002,
+$01010003,
+$01020003,
+$01030003,
+$01040003,
+$01030004,
+$01040004,
+$01030005,
+$01040005,
+$01030006,
+$01040006,
+$01030007,
+$01040007,
+$05000001,
+$05000002,
+$05000003,
+$05000004,
+$05000005,
+$05000006,
+$05000007,
+$05000008,
+$05000009,
+$0500000a,
+$0500000b,
+$0500000c,
+$0500000d,
+$0500000e,
+$0500000f,
+$05000010,
+$05000011,
+$05000012,
+$05000013,
+$05000014,
+$05000015,
+$02000000,
+$02000001,
+$02000002,
+$02000003,
+$02000004,
+$02000005,
+$02000006,
+$02000007,
+$02000008,
+$03000000,
+$03000001,
+$03000002,
+$03000003,
+$03000004,
+$03000005,
+$03000006,
+$03000007,
+$04000000,
+$04000001,
+$04000002,
+$04000003,
+$04000004,
+$04000005,
+$04000006,
+$04000007

+ 72 - 0
compiler/i386/r386op.inc

@@ -0,0 +1,72 @@
+{ don't edit, this file is generated from x86reg.dat }
+0,
+0,
+4,
+0,
+0,
+1,
+5,
+1,
+1,
+2,
+6,
+2,
+2,
+3,
+7,
+3,
+3,
+6,
+6,
+7,
+7,
+5,
+5,
+4,
+4,
+1,
+3,
+0,
+2,
+4,
+5,
+0,
+1,
+2,
+3,
+6,
+7,
+0,
+2,
+3,
+4,
+3,
+4,
+5,
+6,
+7,
+0,
+1,
+2,
+3,
+4,
+5,
+6,
+7,
+0,
+0,
+1,
+2,
+3,
+4,
+5,
+6,
+7,
+0,
+1,
+2,
+3,
+4,
+5,
+6,
+7

+ 72 - 0
compiler/i386/r386ot.inc

@@ -0,0 +1,72 @@
+{ don't edit, this file is generated from x86reg.dat }
+OT_NONE,
+OT_REG_AL,
+OT_REG8,
+OT_REG_AX,
+OT_REG_EAX,
+OT_REG_CL,
+OT_REG8,
+OT_REG_CX,
+OT_REG_ECX,
+OT_REG8,
+OT_REG8,
+OT_REG_DX,
+OT_REG32,
+OT_REG8,
+OT_REG8,
+OT_REG16,
+OT_REG32,
+OT_REG16,
+OT_REG32,
+OT_REG16,
+OT_REG32,
+OT_REG16,
+OT_REG32,
+OT_REG16,
+OT_REG32,
+OT_REG_CS,
+OT_REG_DESS,
+OT_REG_DESS,
+OT_REG_DESS,
+OT_REG_FSGS,
+OT_REG_FSGS,
+OT_REG_DREG,
+OT_REG_DREG,
+OT_REG_DREG,
+OT_REG_DREG,
+OT_REG_DREG,
+OT_REG_DREG,
+OT_REG_CREG,
+OT_REG_CREG,
+OT_REG_CREG,
+OT_REG_CR4,
+OT_REG_TREG,
+OT_REG_TREG,
+OT_REG_TREG,
+OT_REG_TREG,
+OT_REG_TREG,
+OT_FPU0,
+OT_FPUREG,
+OT_FPUREG,
+OT_FPUREG,
+OT_FPUREG,
+OT_FPUREG,
+OT_FPUREG,
+OT_FPUREG,
+OT_FPU0,
+OT_MMXREG,
+OT_MMXREG,
+OT_MMXREG,
+OT_MMXREG,
+OT_MMXREG,
+OT_MMXREG,
+OT_MMXREG,
+OT_MMXREG,
+OT_XMMREG,
+OT_XMMREG,
+OT_XMMREG,
+OT_XMMREG,
+OT_XMMREG,
+OT_XMMREG,
+OT_XMMREG,
+OT_XMMREG

+ 72 - 0
compiler/i386/r386rni.inc

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

+ 72 - 0
compiler/i386/r386sri.inc

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

+ 72 - 0
compiler/i386/r386stab.inc

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

+ 72 - 0
compiler/i386/r386std.inc

@@ -0,0 +1,72 @@
+{ don't edit, this file is generated from x86reg.dat }
+'INVALID',
+'al',
+'ah',
+'ax',
+'eax',
+'cl',
+'ch',
+'cx',
+'ecx',
+'dl',
+'dh',
+'dx',
+'edx',
+'bl',
+'bh',
+'bx',
+'ebx',
+'si',
+'esi',
+'di',
+'edi',
+'bp',
+'ebp',
+'sp',
+'esp',
+'cs',
+'ds',
+'es',
+'ss',
+'fs',
+'gs',
+'dr0',
+'dr1',
+'dr2',
+'dr3',
+'dr6',
+'dr7',
+'cr0',
+'cr2',
+'cr3',
+'cr4',
+'tr3',
+'tr4',
+'tr5',
+'tr6',
+'tr7',
+'st(0)',
+'st(1)',
+'st(2)',
+'st(3)',
+'st(4)',
+'st(5)',
+'st(6)',
+'st(7)',
+'st',
+'mm0',
+'mm1',
+'mm2',
+'mm3',
+'mm4',
+'mm5',
+'mm6',
+'mm7',
+'xmm0',
+'xmm1',
+'xmm2',
+'xmm3',
+'xmm4',
+'xmm5',
+'xmm6',
+'xmm7'

+ 14 - 29
compiler/i386/ra386att.pas

@@ -101,14 +101,12 @@ var
   actopsize      : topsize;
   actopsize      : topsize;
   actcondition   : tasmcond;
   actcondition   : tasmcond;
   iasmops        : tdictionary;
   iasmops        : tdictionary;
-  iasmregs       : ^reg2strtable;
 
 
 
 
 Procedure SetupTables;
 Procedure SetupTables;
 { creates uppercased symbol tables for speed access }
 { creates uppercased symbol tables for speed access }
 var
 var
   i : tasmop;
   i : tasmop;
-  j : Toldregister;
   str2opentry: tstr2opentry;
   str2opentry: tstr2opentry;
 Begin
 Begin
   { opcodes }
   { opcodes }
@@ -120,10 +118,6 @@ Begin
       str2opentry.op:=i;
       str2opentry.op:=i;
       iasmops.insert(str2opentry);
       iasmops.insert(str2opentry);
     end;
     end;
-  { registers }
-  new(iasmregs);
-  for j:=firstreg to lastreg do
-   iasmregs^[j] := upper(gas_reg2str[j]);
 end;
 end;
 
 
 
 
@@ -236,25 +230,10 @@ end;
 
 
 
 
 function is_register(const s:string):boolean;
 function is_register(const s:string):boolean;
-
-var i:Toldregister;
-
 begin
 begin
-  actasmregister.enum:=R_INTREGISTER;
-  actasmregister.number:=gas_regnum_search(s);
-  if actasmregister.number=NR_NO then
-    begin
-      for i:=firstreg to lastreg do
-       if s=iasmregs^[i] then
-        begin
-          actasmtoken:=AS_REGISTER;
-          actasmregister.enum:=i;
-          is_register:=true;
-          exit;
-        end;
-      is_register:=false;
-    end
-  else
+  is_register:=false;
+  actasmregister:=gas_regnum_search(lower(s));
+  if actasmregister<>NR_NO then
     begin
     begin
       is_register:=true;
       is_register:=true;
       actasmtoken:=AS_REGISTER;
       actasmtoken:=AS_REGISTER;
@@ -1180,8 +1159,7 @@ Begin
       Begin
       Begin
         { Check if there is already a base (mostly ebp,esp) than this is
         { Check if there is already a base (mostly ebp,esp) than this is
           not allowed,becuase it will give crashing code }
           not allowed,becuase it will give crashing code }
-        if not((opr.ref.base.enum=R_NO) or
-               ((opr.ref.base.enum=R_INTREGISTER) and (opr.ref.base.number=NR_NO))) then
+        if (opr.ref.base<>NR_NO) then
           message(asmr_e_cannot_index_relative_var);
           message(asmr_e_cannot_index_relative_var);
         opr.ref.base:=actasmregister;
         opr.ref.base:=actasmregister;
         Consume(AS_REGISTER);
         Consume(AS_REGISTER);
@@ -2131,13 +2109,20 @@ initialization
 finalization
 finalization
   if assigned(iasmops) then
   if assigned(iasmops) then
     iasmops.Free;
     iasmops.Free;
-  if assigned(iasmregs) then
-    dispose(iasmregs);
 
 
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.45  2003-05-30 23:57:08  peter
+  Revision 1.46  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.45.2.2  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.45.2.1  2003/08/28 18:35:08  peter
+    * tregister changed to cardinal
+
+  Revision 1.45  2003/05/30 23:57:08  peter
     * more sparc cleanup
     * more sparc cleanup
     * accumulator removed, splitted in function_return_reg (called) and
     * accumulator removed, splitted in function_return_reg (called) and
       function_result_reg (caller)
       function_result_reg (caller)

+ 22 - 37
compiler/i386/ra386int.pas

@@ -50,7 +50,7 @@ Implementation
        rgobj,
        rgobj,
        { register allocator }
        { register allocator }
        scanner,
        scanner,
-       rautils,rax86,ag386int,
+       rautils,rax86,itx86int,
        { codegen }
        { codegen }
        cginfo,cgbase,cgobj
        cginfo,cgbase,cgobj
        ;
        ;
@@ -117,14 +117,12 @@ var
   actopsize      : topsize;
   actopsize      : topsize;
   actcondition   : tasmcond;
   actcondition   : tasmcond;
   iasmops        : tdictionary;
   iasmops        : tdictionary;
-  iasmregs       : ^reg2strtable;
 
 
 
 
 Procedure SetupTables;
 Procedure SetupTables;
 { creates uppercased symbol tables for speed access }
 { creates uppercased symbol tables for speed access }
 var
 var
   i : tasmop;
   i : tasmop;
-  j : Toldregister;
   str2opentry: tstr2opentry;
   str2opentry: tstr2opentry;
 Begin
 Begin
   { opcodes }
   { opcodes }
@@ -136,10 +134,6 @@ Begin
       str2opentry.op:=i;
       str2opentry.op:=i;
       iasmops.insert(str2opentry);
       iasmops.insert(str2opentry);
     end;
     end;
-  { registers }
-  new(iasmregs);
-  for j:=firstreg to lastreg do
-   iasmregs^[j] := upper(std_reg2str[j]);
 end;
 end;
 
 
 
 
@@ -223,26 +217,12 @@ Begin
   is_asmdirective:=false;
   is_asmdirective:=false;
 end;
 end;
 
 
-function is_register(const s:string):boolean;
-
-var i:Toldregister;
 
 
+function is_register(const s:string):boolean;
 begin
 begin
-  actasmregister.enum:=R_INTREGISTER;
-  actasmregister.number:=intel_regnum_search(s);
-  if actasmregister.number=NR_NO then
-    begin
-      for i:=firstreg to lastreg do
-       if s=iasmregs^[i] then
-        begin
-          actasmtoken:=AS_REGISTER;
-          actasmregister.enum:=i;
-          is_register:=true;
-          exit;
-        end;
-      is_register:=false;
-    end
-  else
+  is_register:=false;
+  actasmregister:=masm_regnum_search(lower(s));
+  if actasmregister<>NR_NO then
     begin
     begin
       is_register:=true;
       is_register:=true;
       actasmtoken:=AS_REGISTER;
       actasmtoken:=AS_REGISTER;
@@ -1082,8 +1062,7 @@ Begin
              if negative then
              if negative then
                Message(asmr_e_only_add_relocatable_symbol);
                Message(asmr_e_only_add_relocatable_symbol);
              oldbase:=opr.ref.base;
              oldbase:=opr.ref.base;
-             opr.ref.base.enum:=R_INTREGISTER;
-             opr.ref.base.number:=NR_NO;
+             opr.ref.base:=NR_NO;
              tempstr:=actasmpattern;
              tempstr:=actasmpattern;
              Consume(AS_ID);
              Consume(AS_ID);
              { typecasting? }
              { typecasting? }
@@ -1109,10 +1088,9 @@ Begin
               end;
               end;
              if GotOffset then
              if GotOffset then
               begin
               begin
-                if hasvar and (opr.ref.base.number=current_procinfo.framepointer.number) then
+                if hasvar and (opr.ref.base=current_procinfo.framepointer) then
                  begin
                  begin
-                   opr.ref.base.enum:=R_INTREGISTER;
-                   opr.ref.base.number:=NR_NO;
+                   opr.ref.base:=NR_NO;
                    hasvar:=hadvar;
                    hasvar:=hadvar;
                  end
                  end
                 else
                 else
@@ -1123,10 +1101,10 @@ Begin
                  end;
                  end;
               end;
               end;
              { is the base register loaded by the var ? }
              { is the base register loaded by the var ? }
-             if (opr.ref.base.number<>NR_NO) then
+             if (opr.ref.base<>NR_NO) then
               begin
               begin
                 { check if we can move the old base to the index register }
                 { check if we can move the old base to the index register }
-                if (opr.ref.index.number<>NR_NO) then
+                if (opr.ref.index<>NR_NO) then
                  Message(asmr_e_wrong_base_index)
                  Message(asmr_e_wrong_base_index)
                 else
                 else
                  opr.ref.index:=oldbase;
                  opr.ref.index:=oldbase;
@@ -1214,9 +1192,9 @@ Begin
              3. base register is already used }
              3. base register is already used }
           if (GotStar) or
           if (GotStar) or
              (actasmtoken=AS_STAR) or
              (actasmtoken=AS_STAR) or
-             (opr.ref.base.number<>NR_NO) then
+             (opr.ref.base<>NR_NO) then
            begin
            begin
-             if (opr.ref.index.number<>NR_NO) then
+             if (opr.ref.index<>NR_NO) then
               Message(asmr_e_multiple_index);
               Message(asmr_e_multiple_index);
              opr.ref.index:=hreg;
              opr.ref.index:=hreg;
              if scale<>0 then
              if scale<>0 then
@@ -1941,13 +1919,20 @@ initialization
 finalization
 finalization
   if assigned(iasmops) then
   if assigned(iasmops) then
     iasmops.Free;
     iasmops.Free;
-  if assigned(iasmregs) then
-    dispose(iasmregs);
 
 
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.49  2003-06-06 14:41:59  peter
+  Revision 1.50  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.49.2.2  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.49.2.1  2003/08/28 18:35:08  peter
+    * tregister changed to cardinal
+
+  Revision 1.49  2003/06/06 14:41:59  peter
     * use setsize for size specifier
     * use setsize for size specifier
 
 
   Revision 1.48  2003/05/30 23:57:08  peter
   Revision 1.48  2003/05/30 23:57:08  peter

+ 41 - 291
compiler/i386/rgcpu.pas

@@ -39,14 +39,7 @@ unit rgcpu;
           fpuvaroffset : byte;
           fpuvaroffset : byte;
 
 
           { to keep the same allocation order as with the old routines }
           { to keep the same allocation order as with the old routines }
-{$ifdef newra}
-          procedure add_constraints(reg:Tnewregister);override;
-{$else}
-          function getregisterint(list:Taasmoutput;size:Tcgsize):Tregister;override;
-          function getaddressregister(list:Taasmoutput):Tregister;override;
-          procedure ungetregisterint(list:Taasmoutput;r:Tregister); override;
-          function getexplicitregisterint(list:Taasmoutput;r:Tnewregister):Tregister;override;
-{$endif newra}
+          procedure add_constraints(reg:Tregister);override;
 
 
           function getregisterfpu(list: taasmoutput;size:TCGSize) : tregister; override;
           function getregisterfpu(list: taasmoutput;size:TCGSize) : tregister; override;
           procedure ungetregisterfpu(list: taasmoutput; r : tregister;size:TCGSize); override;
           procedure ungetregisterfpu(list: taasmoutput; r : tregister;size:TCGSize); override;
@@ -59,37 +52,19 @@ unit rgcpu;
           function makeregsize(reg: tregister; size: tcgsize): tregister; override;
           function makeregsize(reg: tregister; size: tcgsize): tregister; override;
 
 
           { pushes and restores registers }
           { pushes and restores registers }
-{$ifndef newra}
-          procedure pushusedintregisters(list:Taasmoutput;
-                                         var pushed:Tpushedsavedint;
-                                         const s:Tsupregset);
-{$endif}
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
           procedure pushusedotherregisters(list:Taasmoutput;
           procedure pushusedotherregisters(list:Taasmoutput;
                                            var pushed:Tpushedsavedother;
                                            var pushed:Tpushedsavedother;
-                                           const s:Tregisterset);
+                                           const s:Totherregisterset);
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
-{$ifndef newra}
-          procedure popusedintregisters(list:Taasmoutput;
-                                        const pushed:Tpushedsavedint);
-{$endif}
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
           procedure popusedotherregisters(list:Taasmoutput;
           procedure popusedotherregisters(list:Taasmoutput;
                                           const pushed:Tpushedsavedother);
                                           const pushed:Tpushedsavedother);
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
 
 
-{$ifndef newra}
-          procedure saveusedintregisters(list:Taasmoutput;
-                                         var saved:Tpushedsavedint;
-                                         const s:Tsupregset);override;
-{$endif}
           procedure saveusedotherregisters(list:Taasmoutput;
           procedure saveusedotherregisters(list:Taasmoutput;
                                            var saved:Tpushedsavedother;
                                            var saved:Tpushedsavedother;
-                                           const s:Tregisterset);override;
-{$ifndef newra}
-          procedure restoreusedintregisters(list:Taasmoutput;
-                                            const saved:Tpushedsavedint);override;
-{$endif}
+                                           const s:Totherregisterset);override;
           procedure restoreusedotherregisters(list:Taasmoutput;
           procedure restoreusedotherregisters(list:Taasmoutput;
                                               const saved:Tpushedsavedother);override;
                                               const saved:Tpushedsavedother);override;
 
 
@@ -112,160 +87,19 @@ unit rgcpu;
 {                               trgcpu                                   }
 {                               trgcpu                                   }
 {************************************************************************}
 {************************************************************************}
 
 
-{$ifdef newra}
-    procedure Trgcpu.add_constraints(reg:Tnewregister);
-
+    procedure Trgcpu.add_constraints(reg:Tregister);
+    var
+      supreg : tsuperregister;
     begin
     begin
-      if reg and $ff in [R_SUBL,R_SUBH] then
+      if getsubreg(reg) in [R_SUBL,R_SUBH] then
         begin
         begin
+          supreg:=getsupreg(reg);
           {These registers have no 8-bit subregister, so add interferences.}
           {These registers have no 8-bit subregister, so add interferences.}
-          add_edge(reg shr 8,RS_ESI);
-          add_edge(reg shr 8,RS_EDI);
-          add_edge(reg shr 8,RS_EBP);
+          add_edge(supreg,RS_ESI);
+          add_edge(supreg,RS_EDI);
+          add_edge(supreg,RS_EBP);
         end;
         end;
     end;
     end;
-{$endif}
-
-{$ifndef newra}
-    function trgcpu.getregisterint(list:Taasmoutput;size:Tcgsize):Tregister;
-
-    var subreg:Tsubregister;
-
-    begin
-      subreg:=cgsize2subreg(size);
-
-      if countunusedregsint=0 then
-        internalerror(10);
-      result.enum:=R_INTREGISTER;
-{$ifdef TEMPREGDEBUG}
-      if curptree^.usableregsint-countunusedregsint>curptree^.registers32 then
-        internalerror(10);
-{$endif TEMPREGDEBUG}
-{$ifdef EXTTEMPREGDEBUG}
-      if curptree^.usableregs-countunusedregistersint>curptree^^.reallyusedregs then
-        curptree^.reallyusedregs:=curptree^^.usableregs-countunusedregistersint;
-{$endif EXTTEMPREGDEBUG}
-      if RS_EAX in unusedregsint then
-        begin
-          dec(countunusedregsint);
-          exclude(unusedregsint,RS_EAX);
-          include(used_in_proc_int,RS_EAX);
-          result.number:=RS_EAX shl 8 or subreg;
-{$ifdef TEMPREGDEBUG}
-          reg_user[R_EAX]:=curptree^;
-{$endif TEMPREGDEBUG}
-          exprasmlist.concat(tai_regalloc.alloc(result));
-        end
-      else if RS_EDX in unusedregsint then
-        begin
-          dec(countunusedregsint);
-          exclude(unusedregsint,RS_EDX);
-          include(used_in_proc_int,RS_EDX);
-          result.number:=RS_EDX shl 8 or subreg;
-{$ifdef TEMPREGDEBUG}
-          reg_user[R_EDX]:=curptree^;
-{$endif TEMPREGDEBUG}
-          exprasmlist.concat(tai_regalloc.alloc(result));
-        end
-      else if RS_EBX in unusedregsint then
-        begin
-          dec(countunusedregsint);
-          exclude(unusedregsint,RS_EBX);
-          include(used_in_proc_int,RS_EBX);
-          result.number:=RS_EBX shl 8 or subreg;
-{$ifdef TEMPREGDEBUG}
-          reg_user[R_EBX]:=curptree^;
-{$endif TEMPREGDEBUG}
-          exprasmlist.concat(tai_regalloc.alloc(result));
-        end
-      else if RS_ECX in unusedregsint then
-        begin
-          dec(countunusedregsint);
-          exclude(unusedregsint,RS_ECX);
-          include(used_in_proc_int,RS_ECX);
-          result.number:=RS_ECX shl 8 or subreg;
-{$ifdef TEMPREGDEBUG}
-          reg_user[R_ECX]:=curptree^;
-{$endif TEMPREGDEBUG}
-          exprasmlist.concat(tai_regalloc.alloc(result));
-        end
-      else
-        internalerror(10);
-{$ifdef TEMPREGDEBUG}
-      testregisters;
-{$endif TEMPREGDEBUG}
-    end;
-
-
-    function trgcpu.getaddressregister(list:Taasmoutput):Tregister;
-    begin
-      if countunusedregsaddr>0 then
-       begin
-         result.enum:=R_INTREGISTER;
-{$ifdef TEMPREGDEBUG}
-         if curptree^.usableregsaddr-countunusedregsaddr>curptree^.registers32 then
-           internalerror(10);
-{$endif TEMPREGDEBUG}
-{$ifdef EXTTEMPREGDEBUG}
-         if curptree^.usableregs-countunusedregistersaddr>curptree^^.reallyusedregs then
-           curptree^.reallyusedregs:=curptree^^.usableregs-countunusedregistersaddr;
-{$endif EXTTEMPREGDEBUG}
-         if RS_ESI in unusedregsaddr then
-           begin
-             dec(countunusedregsaddr);
-             exclude(unusedregsaddr,RS_ESI);
-             include(usedaddrinproc,RS_ESI);
-             result.number:=NR_ESI;
-{$ifdef TEMPREGDEBUG}
-             reg_user[R_ESI]:=curptree^;
-{$endif TEMPREGDEBUG}
-             exprasmlist.concat(tai_regalloc.alloc(result));
-           end
-         else
-           internalerror(10);
-       end
-      else
-       result:=getregisterint(list,OS_ADDR);
-    end;
-
-
-    procedure trgcpu.ungetregisterint(list: taasmoutput; r : tregister);
-
-    var supreg:Tsuperregister;
-
-      begin
-         if r.enum=R_NO then
-          exit;
-         if r.enum<>R_INTREGISTER then
-            internalerror(200301234);
-         supreg:=r.number shr 8;
-         if (supreg in [RS_EDI]) then
-           begin
-             list.concat(tai_regalloc.DeAlloc(r));
-             exit;
-           end;
-         if not(supreg in [RS_EAX,RS_EBX,RS_ECX,RS_EDX,RS_ESI]) then
-           exit;
-         inherited ungetregisterint(list,r);
-      end;
-
-
-   function trgcpu.getexplicitregisterint(list:Taasmoutput;r:Tnewregister):Tregister;
-
-   var r2:Tregister;
-
-    begin
-      if (r shr 8) in [RS_EDI] then
-        begin
-          r2.enum:=R_INTREGISTER;
-          r2.number:=r;
-          list.concat(Tai_regalloc.alloc(r2));
-          getexplicitregisterint:=r2;
-          exit;
-        end;
-      result:=inherited getexplicitregisterint(list,r);
-    end;
-{$endif newra}
 
 
 
 
     function trgcpu.getregisterfpu(list: taasmoutput;size: TCGSize) : tregister;
     function trgcpu.getregisterfpu(list: taasmoutput;size: TCGSize) : tregister;
@@ -273,7 +107,7 @@ unit rgcpu;
       begin
       begin
         { note: don't return R_ST0, see comments above implementation of }
         { note: don't return R_ST0, see comments above implementation of }
         { a_loadfpu_* methods in cgcpu (JM)                              }
         { a_loadfpu_* methods in cgcpu (JM)                              }
-        result.enum := R_ST;
+        result:=NR_ST;
       end;
       end;
 
 
 
 
@@ -285,52 +119,17 @@ unit rgcpu;
       end;
       end;
 
 
 
 
-{$ifndef newra}
-    procedure trgcpu.pushusedintregisters(list:Taasmoutput;
-                                         var pushed:Tpushedsavedint;
-                                         const s:Tsupregset);
-
-    var r:Tsuperregister;
-        r2:Tregister;
-
-    begin
-      used_in_proc_int:=used_in_proc_int+s;
-      for r:=firstsaveintreg to lastsaveintreg do
-        begin
-          r2.enum:=R_INTREGISTER;
-          r2.number:=r shl 8 or R_SUBWHOLE;
-          pushed[r].pushed:=false;
-          { if the register is used by the calling subroutine    }
-          if not(r in is_reg_var_int) and (r in s) and
-             { and is present in use }
-             not(r in unusedregsint) then
-            begin
-              { then save it }
-              list.concat(Taicpu.Op_reg(A_PUSH,S_L,r2));
-              include(unusedregsint,r);
-            {$ifndef newra}
-              inc(countunusedregsint);
-            {$endif}
-              pushed[r].pushed:=true;
-            end;
-        end;
-{$ifdef TEMPREGDEBUG}
-      testregisters;
-{$endif TEMPREGDEBUG}
-    end;
-{$endif}
-
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
     procedure trgcpu.pushusedotherregisters(list:Taasmoutput;
     procedure trgcpu.pushusedotherregisters(list:Taasmoutput;
                                             var pushed:Tpushedsavedother;
                                             var pushed:Tpushedsavedother;
-                                            const s:Tregisterset);
+                                            const s:Totherregisterset);
 
 
-    var r:Toldregister;
+{    var r:Toldregister;
         r2:Tregister;
         r2:Tregister;
-        hr:Treference;
+        hr:Treference;}
 
 
     begin
     begin
-      used_in_proc_other:=used_in_proc_other+s;
+(*      used_in_proc_other:=used_in_proc_other+s;
       for r:=R_MM0 to R_MM6 do
       for r:=R_MM0 to R_MM6 do
         begin
         begin
           pushed[r].pushed:=false;
           pushed[r].pushed:=false;
@@ -347,58 +146,27 @@ unit rgcpu;
               r2.enum:=r;
               r2.enum:=r;
               list.concat(Taicpu.Op_reg_ref(A_MOVQ,S_NO,r2,hr));
               list.concat(Taicpu.Op_reg_ref(A_MOVQ,S_NO,r2,hr));
               include(unusedregsmm,r);
               include(unusedregsmm,r);
-            {$ifndef newra}
-              inc(countunusedregsmm);
-            {$endif}
               pushed[r].pushed:=true;
               pushed[r].pushed:=true;
             end;
             end;
-        end;
+        end;*)
 {$ifdef TEMPREGDEBUG}
 {$ifdef TEMPREGDEBUG}
       testregisters;
       testregisters;
 {$endif TEMPREGDEBUG}
 {$endif TEMPREGDEBUG}
     end;
     end;
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
 
 
-{$ifndef newra}
-    procedure trgcpu.popusedintregisters(list:Taasmoutput;
-                                         const pushed:Tpushedsavedint);
-
-    var r:Tsuperregister;
-        r2:Tregister;
-    begin
-      { restore in reverse order: }
-      for r:=lastsaveintreg downto firstsaveintreg do
-        if pushed[r].pushed then
-          begin
-            r2.enum:=R_INTREGISTER;
-            r2.number:=r shl 8 or R_SUBWHOLE;
-            list.concat(Taicpu.op_reg(A_POP,S_L,r2));
-            if not (r in unusedregsint) then
-              { internalerror(10)
-                in cg386cal we always restore regs
-                that appear as used
-                due to a unused tmep storage PM }
-            else
-              {$ifndef newra}dec(countunusedregsint){$endif};
-            exclude(unusedregsint,r);
-          end;
-{$ifdef TEMPREGDEBUG}
-      testregisters;
-{$endif TEMPREGDEBUG}
-    end;
-{$endif}
 
 
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
     procedure trgcpu.popusedotherregisters(list:Taasmoutput;
     procedure trgcpu.popusedotherregisters(list:Taasmoutput;
                                            const pushed:Tpushedsavedother);
                                            const pushed:Tpushedsavedother);
 
 
-    var r:Toldregister;
+{    var r:Toldregister;
         r2,r3:Tregister;
         r2,r3:Tregister;
-        hr:Treference;
+        hr:Treference;}
 
 
     begin
     begin
       { restore in reverse order: }
       { restore in reverse order: }
-      for r:=R_MM6 downto R_MM0 do
+{      for r:=R_MM6 downto R_MM0 do
         if pushed[r].pushed then
         if pushed[r].pushed then
           begin
           begin
             r2.enum:=R_INTREGISTER;
             r2.enum:=R_INTREGISTER;
@@ -407,38 +175,18 @@ unit rgcpu;
             r3.enum:=r;
             r3.enum:=r;
             list.concat(Taicpu.op_ref_reg(A_MOVQ,S_NO,hr,r3));
             list.concat(Taicpu.op_ref_reg(A_MOVQ,S_NO,hr,r3));
             list.concat(Taicpu.op_const_reg(A_ADD,S_L,8,r2));
             list.concat(Taicpu.op_const_reg(A_ADD,S_L,8,r2));
-            if not (r in unusedregsmm) then
-              { internalerror(10)
-                in cg386cal we always restore regs
-                that appear as used
-                due to a unused tmep storage PM }
-            else
-              {$ifndef newra}dec(countunusedregsmm){$endif};
             exclude(unusedregsmm,r);
             exclude(unusedregsmm,r);
-          end;
+          end;}
 {$ifdef TEMPREGDEBUG}
 {$ifdef TEMPREGDEBUG}
       testregisters;
       testregisters;
 {$endif TEMPREGDEBUG}
 {$endif TEMPREGDEBUG}
     end;
     end;
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
 
 
-{$ifndef newra}
-    procedure trgcpu.saveusedintregisters(list:Taasmoutput;
-                                          var saved:Tpushedsavedint;
-                                          const s:Tsupregset);
-
-    begin
-      if (aktoptprocessor in [class386,classP5]) or
-         (CS_LittleSize in aktglobalswitches) then
-        pushusedintregisters(list,saved,s)
-      else
-        inherited saveusedintregisters(list,saved,s);
-    end;
-{$endif}
 
 
 
 
     procedure trgcpu.saveusedotherregisters(list:Taasmoutput;var saved:Tpushedsavedother;
     procedure trgcpu.saveusedotherregisters(list:Taasmoutput;var saved:Tpushedsavedother;
-                                            const s:tregisterset);
+                                            const s:totherregisterset);
 
 
     begin
     begin
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
@@ -450,18 +198,6 @@ unit rgcpu;
         inherited saveusedotherregisters(list,saved,s);
         inherited saveusedotherregisters(list,saved,s);
     end;
     end;
 
 
-{$ifndef newra}
-    procedure trgcpu.restoreusedintregisters(list:Taasmoutput;
-                                             const saved:tpushedsavedint);
-
-    begin
-      if (aktoptprocessor in [class386,classP5]) or
-         (CS_LittleSize in aktglobalswitches) then
-        popusedintregisters(list,saved)
-      else
-        inherited restoreusedintregisters(list,saved);
-    end;
-{$endif}
 
 
     procedure trgcpu.restoreusedotherregisters(list:Taasmoutput;
     procedure trgcpu.restoreusedotherregisters(list:Taasmoutput;
                                                const saved:tpushedsavedother);
                                                const saved:tpushedsavedother);
@@ -488,16 +224,17 @@ unit rgcpu;
    function trgcpu.correct_fpuregister(r : tregister;ofs : byte) : tregister;
    function trgcpu.correct_fpuregister(r : tregister;ofs : byte) : tregister;
 
 
      begin
      begin
-        correct_fpuregister.enum:=Toldregister(longint(r.enum)+ofs);
+        correct_fpuregister:=r;
+        setsupreg(correct_fpuregister,ofs);
      end;
      end;
 
 
 
 
     function trgcpu.makeregsize(reg: tregister; size: tcgsize): tregister;
     function trgcpu.makeregsize(reg: tregister; size: tcgsize): tregister;
       begin
       begin
-        if reg.enum<>R_INTREGISTER then
+        if getregtype(reg)<>R_INTREGISTER then
           internalerror(200306032);
           internalerror(200306032);
-        result.enum:=R_INTREGISTER;
-        result.number:=(reg.number and (not $ff)) or cgsize2subreg(size);
+        result:=reg;
+        setsubreg(result,cgsize2subreg(size));
       end;
       end;
 
 
 
 
@@ -508,7 +245,20 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.31  2003-08-20 09:07:00  daniel
+  Revision 1.32  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.31.2.3  2003/08/31 13:50:16  daniel
+    * Remove sorting and use pregenerated indexes
+    * Some work on making things compile
+
+  Revision 1.31.2.2  2003/08/28 18:35:08  peter
+    * tregister changed to cardinal
+
+  Revision 1.31.2.1  2003/08/27 19:55:54  peter
+    * first tregister patch
+
+  Revision 1.31  2003/08/20 09:07:00  daniel
     * New register coding now mandatory, some more convert_registers calls
     * New register coding now mandatory, some more convert_registers calls
       removed.
       removed.
 
 

+ 0 - 791
compiler/i386/tgcpu.pas

@@ -1,791 +0,0 @@
-{
-    $Id$
-    Copyright (C) 1998-2000 by Florian Klaempfl
-
-    This unit handles the temporary variables stuff for i386
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-unit tgcpu;
-
-{$i defines.inc}
-
-interface
-
-    uses
-       globals,
-       cgbase,verbose,aasm,
-       node,
-       cpubase,cpuasm
-       ;
-
-    type
-       tregisterset = set of tregister;
-
-       tpushed = array[R_EAX..R_MM6] of boolean;
-       tsaved = array[R_EAX..R_MM6] of longint;
-
-    const
-       usablereg32 : byte = 4;
-
-       { this value is used in tsaved, if the register isn't saved }
-       reg_not_saved = $7fffffff;
-{$ifdef SUPPORT_MMX}
-       usableregmmx : byte = 8;
-{$endif SUPPORT_MMX}
-
-    var
-       { tries to hold the amount of times which the current tree is processed  }
-       t_times : longint;
-
-{$ifdef TEMPREGDEBUG}
-    procedure testregisters32;
-{$endif TEMPREGDEBUG}
-    function getregisterint : tregister;
-    function getaddressregister: tregister;
-    procedure ungetregister32(r : tregister);
-    { tries to allocate the passed register, if possible }
-    function getexplicitregister32(r : tregister) : tregister;
-{$ifdef SUPPORT_MMX}
-    function getregistermmx : tregister;
-    procedure ungetregistermmx(r : tregister);
-{$endif SUPPORT_MMX}
-
-    function isaddressregister(reg: tregister): boolean;
-
-    procedure ungetregister(r : tregister);
-
-    procedure cleartempgen;
-    procedure del_reference(const ref : treference);
-    procedure del_locref(const location : tlocation);
-    procedure del_location(const l : tlocation);
-
-    { pushs and restores registers }
-    procedure pushusedregisters(var pushed : tpushed;b : tregisterset);
-    procedure popusedregisters(const pushed : tpushed);
-
-    { saves register variables (restoring happens automatically (JM) }
-    procedure saveregvars(b : tregisterset);
-
-    { saves and restores used registers to temp. values }
-    procedure saveusedregisters(var saved : tsaved;b : tregisterset);
-    procedure restoreusedregisters(const saved : tsaved);
-
-    { increments the push count of all registers in b}
-    procedure incrementregisterpushed(b : tregisterset);
-
-    procedure clearregistercount;
-    procedure resetusableregisters;
-
-    { corrects the fpu stack register by ofs }
-    function correct_fpuregister(r : tregister;ofs : byte) : tregister;
-
-    type
-{$ifdef SUPPORT_MMX}
-       regvar_longintarray = array[R_EAX..R_MM6] of longint;
-       regvar_booleanarray = array[R_EAX..R_MM6] of boolean;
-       regvar_ptreearray = array[R_EAX..R_MM6] of tnode;
-{$else SUPPORT_MMX}
-       regvar_longintarray = array[R_EAX..R_EDI] of longint;
-       regvar_booleanarray = array[R_EAX..R_EDI] of boolean;
-       regvar_ptreearray = array[R_EAX..R_EDI] of tnode;
-{$endif SUPPORT_MMX}
-
-    var
-       unused,usableregs : tregisterset;
-       c_usableregs : longint;
-
-       { uses only 1 byte while a set uses in FPC 32 bytes }
-       usedinproc : tregisterset;
-
-       fpuvaroffset : byte;
-
-       { count, how much a register must be pushed if it is used as register }
-       { variable                                                           }
-       reg_pushes : regvar_longintarray;
-       is_reg_var : regvar_booleanarray;
-       regvar_loaded: regvar_booleanarray;
-
-{$ifdef TEMPREGDEBUG}
-       reg_user   : regvar_ptreearray;
-       reg_releaser : regvar_ptreearray;
-{$endif TEMPREGDEBUG}
-
-
-implementation
-
-    uses
-      globtype,temp_gen,tainst,regvars;
-
-    procedure incrementregisterpushed(b : tregisterset);
-
-      var
-         regi : tregister;
-
-      begin
-         for regi:=R_EAX to R_EDI do
-           begin
-              if regi in b then
-                inc(reg_pushes[regi],t_times*2);
-           end;
-      end;
-
-    procedure pushusedregisters(var pushed : tpushed;b : tregisterset);
-
-      var
-         r : tregister;
-{$ifdef SUPPORT_MMX}
-         hr : preference;
-{$endif}
-      begin
-         usedinproc:=usedinproc+b;
-         for r:=R_EAX to R_EBX do
-           begin
-              pushed[r]:=false;
-              { if the register is used by the calling subroutine    }
-              if r in b then
-                begin
-                  { and is present in use }
-                  if not is_reg_var[r] then
-                    if not(r in unused) then
-                     begin
-                        { then save it }
-                        exprasmlist.concat(Taicpu.Op_reg(A_PUSH,S_L,r));
-
-                        { here was a big problem  !!!!!}
-                        { you cannot do that for a register that is
-                        globally assigned to a var
-                        this also means that you must push it much more
-                        often, but there must be a better way
-                        maybe by putting the value back to the stack !! }
-                        if not(is_reg_var[r]) then
-                          begin
-                            unused:=unused+[r];
-{$ifdef TEMPREGDEBUG}
-                            inc(usablereg32);
-{$endif TEMPREGDEBUG}
-                          end;
-                        pushed[r]:=true;
-                     end;
-                end;
-           end;
-{$ifdef SUPPORT_MMX}
-         for r:=R_MM0 to R_MM6 do
-           begin
-              pushed[r]:=false;
-              { if the mmx register is in use, save it }
-              if not(r in unused) then
-                begin
-                   exprasmList.concat(Taicpu.Op_const_reg(A_SUB,S_L,8,R_ESP));
-                   new(hr);
-                   reset_reference(hr^);
-                   hr^.base:=R_ESP;
-                   exprasmList.concat(Taicpu.Op_reg_ref(A_MOVQ,S_NO,r,hr));
-                   if not(is_reg_var[r]) then
-                     begin
-                       unused:=unused+[r];
-{$ifdef TEMPREGDEBUG}
-                       inc(usableregmmx);
-{$endif TEMPREGDEBUG}
-                     end;
-                   pushed[r]:=true;
-                end;
-           end;
-{$endif SUPPORT_MMX}
-{$ifdef TEMPREGDEBUG}
-        testregisters32;
-{$endif TEMPREGDEBUG}
-      end;
-
-
-    procedure saveregvars(b : tregisterset);
-
-      var
-         r : tregister;
-
-      begin
-         if not(cs_regalloc in aktglobalswitches) then
-           exit;
-         for r:=R_EAX to R_EBX do
-           { if the register is used by the calling subroutine    }
-           if (r in b) and is_reg_var[r] then
-             store_regvar(exprasmlist,r)
-      end;
-
-
-    procedure saveusedregisters(var saved : tsaved;b : tregisterset);
-
-      var
-         r : tregister;
-         hr : treference;
-
-      begin
-         usedinproc:=usedinproc+b;
-         for r:=R_EAX to R_EBX do
-           begin
-              saved[r]:=reg_not_saved;
-              { if the register is used by the calling subroutine    }
-              if r in b then
-                begin
-                   { and is present in use }
-                   if not(r in unused) then
-                     begin
-                        { then save it }
-                        gettempofsizereference(4,hr);
-                        saved[r]:=hr.offset;
-                        exprasmList.concat(Taicpu.Op_reg_ref(A_MOV,S_L,r,newreference(hr)));
-                        { here was a big problem  !!!!!}
-                        { you cannot do that for a register that is
-                        globally assigned to a var
-                        this also means that you must push it much more
-                        often, but there must be a better way
-                        maybe by putting the value back to the stack !! }
-                        if not(is_reg_var[r]) then
-                          begin
-                            unused:=unused+[r];
-{$ifdef TEMPREGDEBUG}
-                            inc(usablereg32);
-{$endif TEMPREGDEBUG}
-                          end;
-                     end;
-                end;
-           end;
-{$ifdef SUPPORT_MMX}
-         for r:=R_MM0 to R_MM6 do
-           begin
-              saved[r]:=reg_not_saved;
-              { if the mmx register is in use, save it }
-              if not(r in unused) then
-                begin
-                   gettempofsizereference(8,hr);
-                   exprasmList.concat(Taicpu.Op_reg_ref(A_MOVQ,S_NO,r,newreference(hr)));
-                   if not(is_reg_var[r]) then
-                     begin
-                       unused:=unused+[r];
-{$ifdef TEMPREGDEBUG}
-                       inc(usableregmmx);
-{$endif TEMPREGDEBUG}
-                     end;
-                   saved[r]:=hr.offset;
-                end;
-           end;
-{$endif SUPPORT_MMX}
-{$ifdef TEMPREGDEBUG}
-        testregisters32;
-{$endif TEMPREGDEBUG}
-      end;
-
-    procedure popusedregisters(const pushed : tpushed);
-
-      var
-         r : tregister;
-{$ifdef SUPPORT_MMX}
-         hr : preference;
-{$endif SUPPORT_MMX}
-      begin
-         { restore in reverse order: }
-{$ifdef SUPPORT_MMX}
-         for r:=R_MM6 downto R_MM0 do
-           begin
-              if pushed[r] then
-                begin
-                   new(hr);
-                   reset_reference(hr^);
-                   hr^.base:=R_ESP;
-                   exprasmList.concat(Taicpu.Op_ref_reg(
-                     A_MOVQ,S_NO,hr,r));
-                   exprasmList.concat(Taicpu.Op_const_reg(
-                     A_ADD,S_L,8,R_ESP));
-                   unused:=unused-[r];
-{$ifdef TEMPREGDEBUG}
-                   dec(usableregmmx);
-{$endif TEMPREGDEBUG}
-                end;
-           end;
-{$endif SUPPORT_MMX}
-         for r:=R_EBX downto R_EAX do
-           if pushed[r] then
-             begin
-                exprasmList.concat(Taicpu.Op_reg(A_POP,S_L,r));
-{$ifdef TEMPREGDEBUG}
-                if not (r in unused) then
-                  { internalerror(10)
-                    in cg386cal we always restore regs
-                    that appear as used
-                    due to a unused tmep storage PM }
-                else
-                  dec(usablereg32);
-{$endif TEMPREGDEBUG}
-                unused:=unused-[r];
-             end;
-{$ifdef TEMPREGDEBUG}
-        testregisters32;
-{$endif TEMPREGDEBUG}
-      end;
-
-    procedure restoreusedregisters(const saved : tsaved);
-      var
-         r : tregister;
-         hr : treference;
-
-      begin
-         { restore in reverse order: }
-{$ifdef SUPPORT_MMX}
-         for r:=R_MM6 downto R_MM0 do
-           begin
-              if saved[r]<>reg_not_saved then
-                begin
-                   reset_reference(hr);
-                   hr.base:=frame_pointer;
-                   hr.offset:=saved[r];
-                   exprasmList.concat(Taicpu.Op_ref_reg(
-                     A_MOVQ,S_NO,newreference(hr),r));
-                   unused:=unused-[r];
-{$ifdef TEMPREGDEBUG}
-                   dec(usableregmmx);
-{$endif TEMPREGDEBUG}
-                   ungetiftemp(hr);
-                end;
-           end;
-{$endif SUPPORT_MMX}
-         for r:=R_EBX downto R_EAX do
-           if saved[r]<>reg_not_saved then
-             begin
-                reset_reference(hr);
-                hr.base:=frame_pointer;
-                hr.offset:=saved[r];
-                exprasmList.concat(Taicpu.Op_ref_reg(A_MOV,S_L,newreference(hr),r));
-{$ifdef TEMPREGDEBUG}
-                if not (r in unused) then
-                  internalerror(10)
-                else
-                  dec(usablereg32);
-{$endif TEMPREGDEBUG}
-                unused:=unused-[r];
-                ungetiftemp(hr);
-             end;
-{$ifdef TEMPREGDEBUG}
-        testregisters32;
-{$endif TEMPREGDEBUG}
-      end;
-
-    procedure ungetregister(r : tregister);
-
-      begin
-         if r in [R_EAX,R_ECX,R_EDX,R_EBX,R_ESP,R_EBP,R_ESI,R_EDI] then
-           ungetregister32(r)
-          else if r in [R_AX,R_CX,R_DX,R_BX,R_SP,R_BP,R_SI,R_DI] then
-           ungetregister32(reg16toreg32(r))
-         else if r in [R_AL,R_BL,R_CL,R_DL] then
-           ungetregister32(reg8toreg32(r))
-{$ifdef SUPPORT_MMX}
-         else if r in [R_MM0..R_MM6] then
-           ungetregistermmx(r)
-{$endif SUPPORT_MMX}
-         else internalerror(200112021);
-      end;
-
-    procedure ungetregister32(r : tregister);
-
-      begin
-         if (r = R_EDI) or
-            ((not assigned(procinfo^._class)) and (r = R_ESI)) then
-           begin
-             exprasmList.concat(Tairegalloc.DeAlloc(r));
-             exit;
-           end;
-         if cs_regalloc in aktglobalswitches then
-           begin
-              { takes much time }
-              if not(r in usableregs) then
-                exit;
-              unused:=unused+[r];
-              inc(usablereg32);
-           end
-         else
-           begin
-              if not(r in [R_EAX,R_EBX,R_ECX,R_EDX]) then
-                exit;
-{$ifdef TEMPREGDEBUG}
-                if (r in unused) then
-{$ifdef EXTTEMPREGDEBUG}
-                  begin
-                    Comment(V_Debug,'register freed twice '+reg2str(r));
-                    testregisters32;
-                    exit;
-                  end
-{$else EXTTEMPREGDEBUG}
-                  exit
-{$endif EXTTEMPREGDEBUG}
-                else
-{$endif TEMPREGDEBUG}
-                  inc(usablereg32);
-              unused:=unused+[r];
-{$ifdef TEMPREGDEBUG}
-              reg_releaser[r]:=curptree^;
-{$endif TEMPREGDEBUG}
-           end;
-         exprasmList.concat(Tairegalloc.DeAlloc(r));
-{$ifdef TEMPREGDEBUG}
-        testregisters32;
-{$endif TEMPREGDEBUG}
-      end;
-
-{$ifdef SUPPORT_MMX}
-    function getregistermmx : tregister;
-
-      var
-         r : tregister;
-
-      begin
-         dec(usableregmmx);
-         for r:=R_MM0 to R_MM6 do
-           if r in unused then
-             begin
-                unused:=unused-[r];
-                usedinproc:=usedinproc or ($80 shr byte(R_EAX));
-                getregistermmx:=r;
-                exit;
-             end;
-         internalerror(10);
-      end;
-
-    procedure ungetregistermmx(r : tregister);
-
-      begin
-         if cs_regalloc in aktglobalswitches then
-           begin
-              { takes much time }
-              if not(r in usableregs) then
-                exit;
-              unused:=unused+[r];
-              inc(usableregmmx);
-           end
-         else
-           begin
-              unused:=unused+[r];
-              inc(usableregmmx);
-           end;
-      end;
-{$endif SUPPORT_MMX}
-
-    function isaddressregister(reg: tregister): boolean;
-
-      begin
-        isaddressregister := true;
-      end;
-
-    procedure del_reference(const ref : treference);
-
-      begin
-         if ref.is_immediate then
-           exit;
-         ungetregister32(ref.base);
-         ungetregister32(ref.index);
-      end;
-
-
-    procedure del_locref(const location : tlocation);
-      begin
-         if (location.loc<>loc_mem) and (location.loc<>loc_reference) then
-           exit;
-         if location.reference.is_immediate then
-           exit;
-         ungetregister32(location.reference.base);
-         ungetregister32(location.reference.index);
-      end;
-
-
-    procedure del_location(const l : tlocation);
-      begin
-        case l.loc of
-          LOC_REGISTER :
-            ungetregister(l.register);
-          LOC_MEM,LOC_REFERENCE :
-            del_reference(l.reference);
-        end;
-      end;
-
-
-{$ifdef TEMPREGDEBUG}
-    procedure testregisters32;
-     var test : byte;
-       begin
-         test:=0;
-         if R_EAX in unused then
-           inc(test);
-         if R_EBX in unused then
-           inc(test);
-         if R_ECX in unused then
-           inc(test);
-         if R_EDX in unused then
-           inc(test);
-         if test<>usablereg32 then
-           internalerror(10);
-       end;
-{$endif TEMPREGDEBUG}
-
-<<<<<<< tgcpu.pas
-    function getregister32 : tregister;
-      var
-         r : tregister;
-=======
-    function getregisterint : tregister;
->>>>>>> 1.8
-      begin
-         if usablereg32=0 then
-           internalerror(10);
-{$ifdef TEMPREGDEBUG}
-         if curptree^^.usableregs-usablereg32>curptree^^.registers32 then
-           internalerror(10);
-{$endif TEMPREGDEBUG}
-{$ifdef EXTTEMPREGDEBUG}
-         if curptree^^.usableregs-usablereg32>curptree^^.reallyusedregs then
-           curptree^^.reallyusedregs:=curptree^^.usableregs-usablereg32;
-{$endif EXTTEMPREGDEBUG}
-         dec(usablereg32);
-         if R_EAX in unused then
-           begin
-<<<<<<< tgcpu.pas
-              r:=R_EAX;
-=======
-              unused:=unused-[R_EAX];
-              usedinproc:=usedinproc or ($80 shr byte(R_EAX));
-              getregisterint:=R_EAX;
->>>>>>> 1.8
-{$ifdef TEMPREGDEBUG}
-              reg_user[R_EAX]:=curptree^;
-{$endif TEMPREGDEBUG}
-              exprasmList.concat(Tairegalloc.Alloc(R_EAX));
-           end
-         else if R_EDX in unused then
-           begin
-<<<<<<< tgcpu.pas
-              r:=R_EDX;
-=======
-              unused:=unused-[R_EDX];
-              usedinproc:=usedinproc or ($80 shr byte(R_EDX));
-              getregisterint:=R_EDX;
->>>>>>> 1.8
-{$ifdef TEMPREGDEBUG}
-              reg_user[R_EDX]:=curptree^;
-{$endif TEMPREGDEBUG}
-              exprasmList.concat(Tairegalloc.Alloc(R_EDX));
-           end
-         else if R_EBX in unused then
-           begin
-<<<<<<< tgcpu.pas
-              r:=R_EBX;
-=======
-              unused:=unused-[R_EBX];
-              usedinproc:=usedinproc or ($80 shr byte(R_EBX));
-              getregisterint:=R_EBX;
->>>>>>> 1.8
-{$ifdef TEMPREGDEBUG}
-              reg_user[R_EBX]:=curptree^;
-{$endif TEMPREGDEBUG}
-              exprasmList.concat(Tairegalloc.Alloc(R_EBX));
-           end
-         else if R_ECX in unused then
-           begin
-<<<<<<< tgcpu.pas
-              r:=R_ECX;
-=======
-              unused:=unused-[R_ECX];
-              usedinproc:=usedinproc or ($80 shr byte(R_ECX));
-              getregisterint:=R_ECX;
->>>>>>> 1.8
-{$ifdef TEMPREGDEBUG}
-              reg_user[R_ECX]:=curptree^;
-{$endif TEMPREGDEBUG}
-              exprasmList.concat(Tairegalloc.Alloc(R_ECX));
-           end
-         else internalerror(10);
-{$ifdef TEMPREGDEBUG}
-         testregisters32;
-{$endif TEMPREGDEBUG}
-         exclude(unused,r);
-         include(usedinproc,r);
-         getregister32:=r;
-      end;
-
-
-    function getaddressregister: tregister;
-
-      begin
-        getaddressregister := getregisterint;
-      end;
-
-    function getexplicitregister32(r : tregister) : tregister;
-
-      begin
-         if r in [R_ESI,R_EDI] then
-           begin
-             exprasmList.concat(Tairegalloc.Alloc(r));
-             getexplicitregister32 := r;
-             exit;
-           end;
-         if r in unused then
-           begin
-              dec(usablereg32);
-{$ifdef TEMPREGDEBUG}
-              if curptree^^.usableregs-usablereg32>curptree^^.registers32 then
-                internalerror(10);
-              reg_user[r]:=curptree^;
-{$endif TEMPREGDEBUG}
-              include(unused,r);
-              include(usedinproc,r);
-              exprasmList.concat(Tairegalloc.Alloc(r));
-              getexplicitregister32:=r;
-{$ifdef TEMPREGDEBUG}
-         testregisters32;
-{$endif TEMPREGDEBUG}
-           end
-         else
-           getexplicitregister32:=getregisterint;
-      end;
-
-    procedure cleartempgen;
-
-      begin
-         unused:=usableregs;
-         usablereg32:=c_usableregs;
-         {fpuvaroffset:=0;
-          this must only be resetted at each procedure
-          compilation start PM }
-      end;
-
-
-   procedure clearregistercount;
-      var
-        regi : tregister;
-      begin
-{$ifdef SUPPORT_MMX}
-         for regi:=R_EAX to R_MM6 do
-           begin
-              reg_pushes[regi]:=0;
-              is_reg_var[regi]:=false;
-           end;
-{$else SUPPORT_MMX}
-         for regi:=R_EAX to R_EDI do
-           begin
-              reg_pushes[regi]:=0;
-              is_reg_var[regi]:=false;
-           end;
-{$endif SUPPORT_MMX}
-      end;
-
-   function correct_fpuregister(r : tregister;ofs : byte) : tregister;
-
-     begin
-        correct_fpuregister:=tregister(longint(r)+ofs);
-     end;
-
-   procedure resetusableregisters;
-      begin
-{$ifdef SUPPORT_MMX}
-        usableregs:=[R_EAX,R_EBX,R_ECX,R_EDX,R_MM0..R_MM6];
-        c_usableregs:=4;
-        usableregmmx:=8;
-{$else}
-        usableregs:=[R_EAX,R_EBX,R_ECX,R_EDX];
-        c_usableregs:=4;
-{$endif SUPPORT_MMX}
-        fillchar(regvar_loaded,sizeof(regvar_loaded),false);
-        fillchar(is_reg_var,sizeof(is_reg_var),false);
-        fpuvaroffset:=0;
-      end;
-
-begin
-  resetusableregisters;
-end.
-{
-  $Log$
-  Revision 1.10  2002-07-04 20:43:02  florian
-    * first x86-64 patches
-
-  Revision 1.9  2002/03/31 20:26:42  jonas
-    + a_loadfpu_* and a_loadmm_* methods in tcg
-    * register allocation is now handled by a class and is mostly processor
-      independent (+rgobj.pas and i386/rgcpu.pas)
-    * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
-    * some small improvements and fixes to the optimizer
-    * some register allocation fixes
-    * some fpuvaroffset fixes in the unary minus node
-    * push/popusedregisters is now called rg.save/restoreusedregisters and
-      (for i386) uses temps instead of push/pop's when using -Op3 (that code is
-      also better optimizable)
-    * fixed and optimized register saving/restoring for new/dispose nodes
-    * LOC_FPU locations now also require their "register" field to be set to
-      R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
-    - list field removed of the tnode class because it's not used currently
-      and can cause hard-to-find bugs
-
-  Revision 1.8  2001/12/31 09:53:16  jonas
-    * changed remaining "getregister32" calls to "getregisterint"
-
-  Revision 1.7  2001/12/29 15:29:59  jonas
-    * powerpc/cgcpu.pas compiles :)
-    * several powerpc-related fixes
-    * cpuasm unit is now based on common tainst unit
-    + nppcmat unit for powerpc (almost complete)
-
-  Revision 1.5  2001/08/26 13:37:03  florian
-    * some cg reorganisation
-    * some PPC updates
-
-  Revision 1.4  2001/04/13 01:22:21  peter
-    * symtable change to classes
-    * range check generation and errors fixed, make cycle DEBUG=1 works
-    * memory leaks fixed
-
-  Revision 1.3  2000/12/25 00:07:34  peter
-    + new tlinkedlist class (merge of old tstringqueue,tcontainer and
-      tlinkedlist objects)
-
-  Revision 1.2  2000/12/05 11:44:34  jonas
-    + new integer regvar handling, should be much more efficient
-
-  Revision 1.1  2000/11/29 00:30:51  florian
-    * unused units removed from uses clause
-    * some changes for widestrings
-
-  Revision 1.9  2000/10/31 22:30:13  peter
-    * merged asm result patch part 2
-
-  Revision 1.8  2000/10/14 10:14:56  peter
-    * moehrendorf oct 2000 rewrite
-
-  Revision 1.7  2000/09/30 16:08:46  peter
-    * more cg11 updates
-
-  Revision 1.6  2000/09/24 15:06:32  peter
-    * use defines.inc
-
-  Revision 1.5  2000/08/27 16:11:55  peter
-    * moved some util functions from globals,cobjects to cutils
-    * splitted files into finput,fmodule
-
-  Revision 1.4  2000/08/05 13:32:39  peter
-    * fixed build prob without support_mmx
-
-  Revision 1.3  2000/08/04 05:09:49  jonas
-    * forgot to commit :( (part of regvar changes)
-
-  Revision 1.2  2000/07/13 11:32:52  michael
-  + removed logs
-}

+ 46 - 120
compiler/nadd.pas

@@ -26,10 +26,6 @@ unit nadd;
 
 
 { define addstringopt}
 { define addstringopt}
 
 
-{$ifdef callparatemp}
-  {$undef addstringopt}
-{$endif}
-
 interface
 interface
 
 
     uses
     uses
@@ -547,124 +543,48 @@ implementation
                  left:=nil;
                  left:=nil;
                  exit;
                  exit;
                end;
                end;
-{$ifdef oldset}
-          case nodetype of
-        addn :
-           begin
-              for i:=0 to 31 do
-                resultset[i]:=tsetconstnode(right).value_set^[i] or tsetconstnode(left).value_set^[i];
-              t:=csetconstnode.create(@resultset,left.resulttype);
-           end;
-        muln :
-           begin
-              for i:=0 to 31 do
-                resultset[i]:=tsetconstnode(right).value_set^[i] and tsetconstnode(left).value_set^[i];
-              t:=csetconstnode.create(@resultset,left.resulttype);
-           end;
-        subn :
-           begin
-              for i:=0 to 31 do
-                resultset[i]:=tsetconstnode(left).value_set^[i] and not(tsetconstnode(right).value_set^[i]);
-              t:=csetconstnode.create(@resultset,left.resulttype);
-           end;
-        symdifn :
-           begin
-              for i:=0 to 31 do
-                resultset[i]:=tsetconstnode(left).value_set^[i] xor tsetconstnode(right).value_set^[i];
-              t:=csetconstnode.create(@resultset,left.resulttype);
-           end;
-        unequaln :
-           begin
-              b:=true;
-              for i:=0 to 31 do
-               if tsetconstnode(right).value_set^[i]=tsetconstnode(left).value_set^[i] then
-                begin
-                  b:=false;
-                  break;
-                end;
-              t:=cordconstnode.create(ord(b),booltype,true);
-           end;
-        equaln :
-           begin
-              b:=true;
-              for i:=0 to 31 do
-               if tsetconstnode(right).value_set^[i]<>tsetconstnode(left).value_set^[i] then
-                begin
-                  b:=false;
-                  break;
-                end;
-              t:=cordconstnode.create(ord(b),booltype,true);
-           end;
-        lten :
-           begin
-             b := true;
-             for i := 0 to 31 Do
-               if (tsetconstnode(right).value_set^[i] And tsetconstnode(left).value_set^[i]) <>
-                   tsetconstnode(left).value_set^[i] Then
-                 begin
-                   b := false;
-                   break
-                 end;
-             t := cordconstnode.create(ord(b),booltype,true);
-           end;
-            gten :
+              case nodetype of
+                addn :
+                  begin
+                       resultset:=tsetconstnode(right).value_set^ + tsetconstnode(left).value_set^;
+                             t:=csetconstnode.create(@resultset,left.resulttype);
+                  end;
+                 muln :
                    begin
                    begin
-                    b := true;
-                    for i := 0 to 31 Do
-                       If (tsetconstnode(left).value_set^[i] And tsetconstnode(right).value_set^[i]) <>
-                       tsetconstnode(right).value_set^[i] Then
-                         begin
-                          b := false;
-                          break
-                         end;
-                     t := cordconstnode.create(ord(b),booltype,true);
+                 resultset:=tsetconstnode(right).value_set^ * tsetconstnode(left).value_set^;
+                             t:=csetconstnode.create(@resultset,left.resulttype);
+                   end;
+                subn :
+                   begin
+                     resultset:=tsetconstnode(left).value_set^ - tsetconstnode(right).value_set^;
+                             t:=csetconstnode.create(@resultset,left.resulttype);
+                   end;
+                symdifn :
+                   begin
+                     resultset:=tsetconstnode(right).value_set^ >< tsetconstnode(left).value_set^;
+                         t:=csetconstnode.create(@resultset,left.resulttype);
+                   end;
+                unequaln :
+                   begin
+                     b:=tsetconstnode(right).value_set^ <> tsetconstnode(left).value_set^;
+                     t:=cordconstnode.create(byte(b),booltype,true);
+                   end;
+                equaln :
+                   begin
+                     b:=tsetconstnode(right).value_set^ = tsetconstnode(left).value_set^;
+                     t:=cordconstnode.create(byte(b),booltype,true);
+                   end;
+                lten :
+                   begin
+                     b:=tsetconstnode(left).value_set^ <= tsetconstnode(right).value_set^;
+                     t:=cordconstnode.create(byte(b),booltype,true);
+                   end;
+                gten :
+                   begin
+                     b:=tsetconstnode(left).value_set^ >= tsetconstnode(right).value_set^;
+                     t:=cordconstnode.create(byte(b),booltype,true);
                    end;
                    end;
               end;
               end;
-
-{$else}
-           case nodetype of
-           addn :
-             begin
-                  resultset:=tsetconstnode(right).value_set^ + tsetconstnode(left).value_set^;
-                        t:=csetconstnode.create(@resultset,left.resulttype);
-             end;
-            muln :
-              begin
-            resultset:=tsetconstnode(right).value_set^ * tsetconstnode(left).value_set^;
-                        t:=csetconstnode.create(@resultset,left.resulttype);
-              end;
-           subn :
-              begin
-                resultset:=tsetconstnode(left).value_set^ - tsetconstnode(right).value_set^;
-                        t:=csetconstnode.create(@resultset,left.resulttype);
-              end;
-           symdifn :
-              begin
-                resultset:=tsetconstnode(right).value_set^ >< tsetconstnode(left).value_set^;
-                    t:=csetconstnode.create(@resultset,left.resulttype);
-              end;
-           unequaln :
-              begin
-                b:=tsetconstnode(right).value_set^ <> tsetconstnode(left).value_set^;
-                t:=cordconstnode.create(byte(b),booltype,true);
-              end;
-           equaln :
-              begin
-                b:=tsetconstnode(right).value_set^ = tsetconstnode(left).value_set^;
-                t:=cordconstnode.create(byte(b),booltype,true);
-              end;
-           lten :
-              begin
-                b:=tsetconstnode(left).value_set^ <= tsetconstnode(right).value_set^;
-                t:=cordconstnode.create(byte(b),booltype,true);
-              end;
-           gten :
-              begin
-                b:=tsetconstnode(left).value_set^ >= tsetconstnode(right).value_set^;
-                t:=cordconstnode.create(byte(b),booltype,true);
-              end;
-           end;
-{$endif}
               result:=t;
               result:=t;
               exit;
               exit;
            end;
            end;
@@ -1953,7 +1873,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.93  2003-06-05 20:05:55  peter
+  Revision 1.94  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.93.2.1  2003/08/31 21:07:44  daniel
+    * callparatemp ripped
+
+  Revision 1.93  2003/06/05 20:05:55  peter
     * removed changesettype because that will change the definition
     * removed changesettype because that will change the definition
       of the setdef forever and can result in a different between
       of the setdef forever and can result in a different between
       original interface and current implementation definition
       original interface and current implementation definition

+ 7 - 5
compiler/nbas.pas

@@ -332,10 +332,6 @@ implementation
 
 
       begin
       begin
          inherited create(blockn,l);
          inherited create(blockn,l);
-    {$ifndef newra}
-         if releasetemp then
-           include(flags,nf_releasetemps);
-    {$endif newra}
       end;
       end;
 
 
     function tblocknode.det_resulttype:tnode;
     function tblocknode.det_resulttype:tnode;
@@ -852,7 +848,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.59  2003-08-09 18:56:54  daniel
+  Revision 1.60  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.59.2.1  2003/08/27 20:23:55  peter
+    * remove old ra code
+
+  Revision 1.59  2003/08/09 18:56:54  daniel
     * cs_regalloc renamed to cs_regvars to avoid confusion with register
     * cs_regalloc renamed to cs_regvars to avoid confusion with register
       allocator
       allocator
     * Some preventive changes to i386 spillinh code
     * Some preventive changes to i386 spillinh code

+ 14 - 138
compiler/ncal.pas

@@ -130,9 +130,6 @@ interface
           procedure printnodedata(var t:text);override;
           procedure printnodedata(var t:text);override;
           function  para_count:longint;
           function  para_count:longint;
        private
        private
-{$ifdef callparatemp}
-          function extract_functioncall_paras: tblocknode;
-{$endif callparatemp}
           AbstractMethodsList : TStringList;
           AbstractMethodsList : TStringList;
        end;
        end;
        tcallnodeclass = class of tcallnode;
        tcallnodeclass = class of tcallnode;
@@ -2242,104 +2239,11 @@ type
       end;
       end;
 
 
 
 
-{$ifdef callparatemp}
-    function tree_contains_function_call(var n: tnode): foreachnoderesult;
-      begin
-        result := fen_false;
-        if (n.nodetype = calln) or
-           ((n.nodetype = loadn) and
-            (tloadnode(n).symtableentry.typ = varsym) and
-            (vo_is_thread_var in tvarsym(tloadnode(n).symtableentry).varoptions)) then
-          { stop when we encounter a call node }
-          result := fen_norecurse_true;
-      end;
-
-
-    function tcallnode.extract_functioncall_paras: tblocknode;
-      var
-        curpara: tcallparanode;
-        newblock: tblocknode;
-        newstatement: tstatementnode;
-        temp: ttempcreatenode;
-        curparaitem: tparaitem;
-        orgtype: ^ttype;
-        temptype: ttemptype;
-        foundcall: boolean;
-        take_addr: boolean;
-      begin
-        foundcall := false;
-        curpara := tcallparanode(left);
-        curparaitem:=tparaitem(procdefinition.Para.last);
-        if assigned(curpara) then
-          begin
-            curpara := tcallparanode(curpara.right);
-            curparaitem:=tparaitem(curparaitem.previous);
-          end;
-        newblock := nil;
-        while assigned(curpara) do
-          begin
-            if foreachnodestatic(curpara.left,@tree_contains_function_call) then
-              begin
-                if (not foundcall) then
-                  begin
-                    foundcall := true;
-                    newblock := internalstatements(newstatement,false);
-                  end;
-                take_addr := (curparaitem.paratyp in [vs_var,vs_out]) or
-                             ((curparaitem.paratype.def.deftype = formaldef));
-                if not(take_addr) then
-                  begin
-                    if is_ansistring(curpara.left.resulttype.def) then
-                      temptype := tt_ansistring
-                    else if is_widestring(curpara.left.resulttype.def) then
-                      temptype := tt_widestring
-                    else if is_interfacecom(curpara.left.resulttype.def) then
-                      temptype := tt_interfacecom
-                    else
-                      temptype := tt_persistent;
-                    temp := ctempcreatenode.create(curpara.left.resulttype,curpara.left.resulttype.def.size,temptype)
-                  end
-                else
-                  begin
-                    temptype := tt_persistent;
-                    temp := ctempcreatenode.create(voidpointertype,pointer_size,tt_persistent);
-                    orgtype := @curpara.left.resulttype;
-                  end;
-                addstatement(newstatement,temp);
-                if take_addr then
-                  curpara.left := caddrnode.create(curpara.left);
-                addstatement(newstatement,
-                  cassignmentnode.create(ctemprefnode.create(temp),curpara.left));
-                { after the assignment, turn the temp into a non-persistent one, so }
-                { that it will be freed once it's used as parameter                 }
-                if (temptype = tt_persistent) then
-                  addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
-                curpara.left := ctemprefnode.create(temp);
-                if take_addr then
-                  curpara.left := ctypeconvnode.create_explicit(cderefnode.create(curpara.left),orgtype^);
-                firstpass(curpara.left);
-              end;
-            curpara := tcallparanode(curpara.right);
-            curparaitem := tparaitem(curparaitem.previous);
-          end;
-        if assigned(newblock) then
-          firstpass(newblock);
-        result := newblock;
-      end;
-{$endif callparatemp}
-
-
     function tcallnode.pass_1 : tnode;
     function tcallnode.pass_1 : tnode;
 {$ifdef m68k}
 {$ifdef m68k}
       var
       var
          regi : tregister;
          regi : tregister;
 {$endif}
 {$endif}
-{$ifdef callparatemp}
-      var
-         callparatemps, newblock: tblocknode;
-         statement: tstatementnode;
-         paras, oldright, newcall: tnode;
-{$endif callparatemp}
       label
       label
         errorexit;
         errorexit;
       begin
       begin
@@ -2349,10 +2253,6 @@ type
          if assigned(left) then
          if assigned(left) then
            tcallparanode(left).det_registers;
            tcallparanode(left).det_registers;
 
 
-{$ifdef callparatemp}
-         callparatemps := extract_functioncall_paras;
-{$endif callparatemp}
-
          { function result node }
          { function result node }
          if assigned(_funcretnode) then
          if assigned(_funcretnode) then
            firstpass(_funcretnode);
            firstpass(_funcretnode);
@@ -2365,10 +2265,7 @@ type
               { procedure does a call }
               { procedure does a call }
               if not (block_type in [bt_const,bt_type]) then
               if not (block_type in [bt_const,bt_type]) then
                 include(current_procinfo.flags,pi_do_call);
                 include(current_procinfo.flags,pi_do_call);
-            {$ifndef newra}
-              rg.incrementintregisterpushed(VOLATILE_INTREGISTERS);
-            {$endif}
-              rg.incrementotherregisterpushed(all_registers);
+              rg.incrementotherregisterpushed(all_otherregisters);
            end
            end
          else
          else
          { not a procedure variable }
          { not a procedure variable }
@@ -2402,9 +2299,6 @@ type
                 end;
                 end;
 
 
              { It doesn't hurt to calculate it already though :) (JM) }
              { It doesn't hurt to calculate it already though :) (JM) }
-          {$ifndef newra}
-             rg.incrementintregisterpushed(tprocdef(procdefinition).usedintregisters);
-          {$endif}
              rg.incrementotherregisterpushed(tprocdef(procdefinition).usedotherregisters);
              rg.incrementotherregisterpushed(tprocdef(procdefinition).usedotherregisters);
            end;
            end;
 
 
@@ -2532,39 +2426,9 @@ type
               registersmmx:=max(left.registersmmx,registersmmx);
               registersmmx:=max(left.registersmmx,registersmmx);
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
            end;
            end;
-{$ifdef callparatemp}
-         if (callparatemps <> nil) then
-           begin
-             { we have to replace the callnode with a blocknode. firstpass will }
-             { free the original call node. Avoid copying all subnodes though   }
-             paras := left;
-             oldright := right;
-             left := nil;
-             right := nil;
-             newcall := self.getcopy;
-             tcallnode(newcall).left := paras;
-             tcallnode(newcall).right := oldright;
-
-             newblock := internalstatements(statement,false);
-             addstatement(statement,callparatemps);
-             { add the copy of the call node after the callparatemps block    }
-             { and return that. The last statement of a bocknode determines   }
-             { the resulttype & location of the block -> ok. Working with a   }
-             { new block is easier than going to the end of the callparatemps }
-             { block (JM)                                                     }
-             addstatement(statement,newcall);
-             result := newblock;
-             { set to nil so we can free this one in case of an errorexit }
-             callparatemps := nil;
-           end;
-{$endif callparatemp}
       errorexit:
       errorexit:
          if assigned(inlinecode) then
          if assigned(inlinecode) then
            procdefinition.proccalloption:=pocall_inline;
            procdefinition.proccalloption:=pocall_inline;
-{$ifdef callparatemp}
-         if assigned(callparatemps) then
-           callparatemps.free;
-{$endif callparatemp}
       end;
       end;
 
 
 {$ifdef state_tracking}
 {$ifdef state_tracking}
@@ -2650,7 +2514,19 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.176  2003-08-23 18:42:57  peter
+  Revision 1.177  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.176.2.3  2003/08/31 21:07:44  daniel
+    * callparatemp ripped
+
+  Revision 1.176.2.2  2003/08/27 20:23:55  peter
+    * remove old ra code
+
+  Revision 1.176.2.1  2003/08/27 19:55:54  peter
+    * first tregister patch
+
+  Revision 1.176  2003/08/23 18:42:57  peter
     * only check for size matches when parameter is enum,ord,float
     * only check for size matches when parameter is enum,ord,float
 
 
   Revision 1.175  2003/08/10 17:25:23  peter
   Revision 1.175  2003/08/10 17:25:23  peter

+ 12 - 36
compiler/ncgadd.pas

@@ -84,7 +84,6 @@ interface
 
 
     procedure tcgaddnode.pass_left_right;
     procedure tcgaddnode.pass_left_right;
       var
       var
-        pushedregs : tmaybesave;
         tmpreg     : tregister;
         tmpreg     : tregister;
         isjump,
         isjump,
         pushedfpu  : boolean;
         pushedfpu  : boolean;
@@ -115,9 +114,6 @@ interface
           end;
           end;
 
 
         { are too few registers free? }
         { are too few registers free? }
-{$ifndef newra}
-        maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-{$endif}
         if left.location.loc=LOC_FPUREGISTER then
         if left.location.loc=LOC_FPUREGISTER then
           pushedfpu:=maybe_pushfpu(exprasmlist,right.registersfpu,left.location)
           pushedfpu:=maybe_pushfpu(exprasmlist,right.registersfpu,left.location)
         else
         else
@@ -138,9 +134,6 @@ interface
             truelabel:=otl;
             truelabel:=otl;
             falselabel:=ofl;
             falselabel:=ofl;
           end;
           end;
-{$ifndef newra}
-        maybe_restore(exprasmlist,left.location,pushedregs);
-{$endif}
         if pushedfpu then
         if pushedfpu then
           begin
           begin
             tmpreg := rg.getregisterfpu(exprasmlist,left.location.size);
             tmpreg := rg.getregisterfpu(exprasmlist,left.location.size);
@@ -230,15 +223,13 @@ interface
         if (right.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
         if (right.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
            not(
            not(
                (location.loc=LOC_REGISTER) and
                (location.loc=LOC_REGISTER) and
-               (location.register.enum=right.location.register.enum) and
-               (location.register.number=right.location.register.number)
+               (location.register=right.location.register)
               ) then
               ) then
           location_release(exprasmlist,right.location);
           location_release(exprasmlist,right.location);
         if (left.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
         if (left.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
            not(
            not(
                (location.loc=LOC_REGISTER) and
                (location.loc=LOC_REGISTER) and
-               (location.register.enum=left.location.register.enum) and
-               (location.register.number=left.location.register.number)
+               (location.register=left.location.register)
               ) then
               ) then
           location_release(exprasmlist,left.location);
           location_release(exprasmlist,left.location);
       end;
       end;
@@ -295,11 +286,7 @@ interface
                       left.location.register,location.register)
                       left.location.register,location.register)
                   else
                   else
                     begin
                     begin
-{$ifdef newra}
                       tmpreg := rg.getregisterint(exprasmlist,location.size);
                       tmpreg := rg.getregisterint(exprasmlist,location.size);
-{$else}
-                      tmpreg := cg.get_scratch_reg_int(exprasmlist,location.size);
-{$endif}
                       cg.a_load_const_reg(exprasmlist,location.size,1,tmpreg);
                       cg.a_load_const_reg(exprasmlist,location.size,1,tmpreg);
                       cg.a_op_reg_reg(exprasmlist,OP_SHL,location.size,
                       cg.a_op_reg_reg(exprasmlist,OP_SHL,location.size,
                         right.location.register,tmpreg);
                         right.location.register,tmpreg);
@@ -309,11 +296,7 @@ interface
                       else
                       else
                         cg.a_op_const_reg_reg(exprasmlist,OP_OR,location.size,
                         cg.a_op_const_reg_reg(exprasmlist,OP_OR,location.size,
                             aword(left.location.value),tmpreg,location.register);
                             aword(left.location.value),tmpreg,location.register);
-{$ifdef newra}
                       rg.ungetregisterint(exprasmlist,tmpreg);
                       rg.ungetregisterint(exprasmlist,tmpreg);
-{$else}
-                      cg.free_scratch_reg(exprasmlist,tmpreg);
-{$endif}
                     end;
                     end;
                   opdone := true;
                   opdone := true;
                 end
                 end
@@ -343,21 +326,13 @@ interface
                 begin
                 begin
                   if left.location.loc = LOC_CONSTANT then
                   if left.location.loc = LOC_CONSTANT then
                     begin
                     begin
-{$ifdef newra}
                       tmpreg := rg.getregisterint(exprasmlist,location.size);
                       tmpreg := rg.getregisterint(exprasmlist,location.size);
-{$else}
-                      tmpreg := cg.get_scratch_reg_int(exprasmlist,location.size);
-{$endif}
                       cg.a_load_const_reg(exprasmlist,location.size,
                       cg.a_load_const_reg(exprasmlist,location.size,
                         aword(left.location.value),tmpreg);
                         aword(left.location.value),tmpreg);
                       cg.a_op_reg_reg(exprasmlist,OP_NOT,location.size,right.location.register,right.location.register);
                       cg.a_op_reg_reg(exprasmlist,OP_NOT,location.size,right.location.register,right.location.register);
                       cg.a_op_reg_reg(exprasmlist,OP_AND,location.size,right.location.register,tmpreg);
                       cg.a_op_reg_reg(exprasmlist,OP_AND,location.size,right.location.register,tmpreg);
                       cg.a_load_reg_reg(exprasmlist,OS_INT,location.size,tmpreg,location.register);
                       cg.a_load_reg_reg(exprasmlist,OS_INT,location.size,tmpreg,location.register);
-{$ifdef newra}
                       rg.ungetregisterint(exprasmlist,tmpreg);
                       rg.ungetregisterint(exprasmlist,tmpreg);
-{$else}
-                      cg.free_scratch_reg(exprasmlist,tmpreg);
-{$endif}
                     end
                     end
                   else
                   else
                     begin
                     begin
@@ -677,20 +652,12 @@ interface
             end
             end
           else
           else
             begin
             begin
-{$ifdef newra}
               tmpreg := rg.getregisterint(exprasmlist,location.size);
               tmpreg := rg.getregisterint(exprasmlist,location.size);
-{$else}
-              tmpreg := cg.get_scratch_reg_int(exprasmlist,location.size);
-{$endif}
               cg.a_load_const_reg(exprasmlist,location.size,
               cg.a_load_const_reg(exprasmlist,location.size,
                 aword(left.location.value),tmpreg);
                 aword(left.location.value),tmpreg);
               cg.a_op_reg_reg_reg(exprasmlist,OP_SUB,location.size,
               cg.a_op_reg_reg_reg(exprasmlist,OP_SUB,location.size,
                 right.location.register,tmpreg,location.register);
                 right.location.register,tmpreg,location.register);
-{$ifdef newra}
               rg.ungetregisterint(exprasmlist,tmpreg);
               rg.ungetregisterint(exprasmlist,tmpreg);
-{$else}
-              cg.free_scratch_reg(exprasmlist,tmpreg);
-{$endif}
             end;
             end;
         end;
         end;
 
 
@@ -760,13 +727,22 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.16  2003-09-03 11:18:36  florian
+  Revision 1.17  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.16  2003/09/03 11:18:36  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.15.2.2  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.15.2.1  2003/08/27 20:23:55  peter
+    * remove old ra code
+
   Revision 1.15  2003/07/08 21:24:59  peter
   Revision 1.15  2003/07/08 21:24:59  peter
     * sparc fixes
     * sparc fixes
 
 

+ 7 - 8
compiler/ncgbas.pas

@@ -96,9 +96,6 @@ interface
           begin
           begin
             if assigned(hp.left) then
             if assigned(hp.left) then
              begin
              begin
-             {$ifndef newra}
-               rg.cleartempgen;
-             {$endif newra}
                secondpass(hp.left);
                secondpass(hp.left);
                { Compiler inserted blocks can return values }
                { Compiler inserted blocks can return values }
                location_copy(hp.location,hp.left.location);
                location_copy(hp.location,hp.left.location);
@@ -244,10 +241,6 @@ interface
             begin
             begin
               if assigned(hp.left) then
               if assigned(hp.left) then
                begin
                begin
-               {$ifndef newra}
-                 if nf_releasetemps in flags then
-                   rg.cleartempgen;
-               {$endif newra}
                  secondpass(hp.left);
                  secondpass(hp.left);
                  location_copy(hp.location,hp.left.location);
                  location_copy(hp.location,hp.left.location);
                end;
                end;
@@ -316,7 +309,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.37  2003-06-13 21:19:30  peter
+  Revision 1.38  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.37.2.1  2003/08/27 20:23:55  peter
+    * remove old ra code
+
+  Revision 1.37  2003/06/13 21:19:30  peter
     * current_procdef removed, use current_procinfo.procdef instead
     * current_procdef removed, use current_procinfo.procdef instead
 
 
   Revision 1.36  2003/06/09 18:26:46  peter
   Revision 1.36  2003/06/09 18:26:46  peter

+ 59 - 284
compiler/ncgcal.pas

@@ -169,19 +169,11 @@ implementation
                   inc(pushedparasize,POINTER_SIZE);
                   inc(pushedparasize,POINTER_SIZE);
                   if calloption=pocall_inline then
                   if calloption=pocall_inline then
                     begin
                     begin
-                    {$ifdef newra}
                        tmpreg:=rg.getaddressregister(exprasmlist);
                        tmpreg:=rg.getaddressregister(exprasmlist);
-                    {$else}
-                       tmpreg:=cg.get_scratch_reg_address(exprasmlist);
-                    {$endif}
                        cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                        cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                        reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
                        reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
                        cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
                        cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
-                    {$ifdef newra}
                        rg.ungetregisterint(exprasmlist,tmpreg);
                        rg.ungetregisterint(exprasmlist,tmpreg);
-                    {$else}
-                       cg.free_scratch_reg(exprasmlist,tmpreg);
-                    {$endif}
                     end
                     end
                   else
                   else
                     cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
                     cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
@@ -228,19 +220,11 @@ implementation
 
 
                    if calloption=pocall_inline then
                    if calloption=pocall_inline then
                      begin
                      begin
-                     {$ifdef newra}
                        tmpreg:=rg.getaddressregister(exprasmlist);
                        tmpreg:=rg.getaddressregister(exprasmlist);
-                     {$else}
-                       tmpreg:=cg.get_scratch_reg_address(exprasmlist);
-                     {$endif newra}
                        cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                        cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                        reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
                        reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
                        cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
                        cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
-                     {$ifdef newra}
                        rg.ungetregisterint(exprasmlist,tmpreg);
                        rg.ungetregisterint(exprasmlist,tmpreg);
-                     {$else}
-                       cg.free_scratch_reg(exprasmlist,tmpreg);
-                     {$endif}
                      end
                      end
                    else
                    else
                      cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
                      cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
@@ -266,19 +250,11 @@ implementation
               inc(pushedparasize,POINTER_SIZE);
               inc(pushedparasize,POINTER_SIZE);
               if calloption=pocall_inline then
               if calloption=pocall_inline then
                 begin
                 begin
-                {$ifdef newra}
                    tmpreg:=rg.getaddressregister(exprasmlist);
                    tmpreg:=rg.getaddressregister(exprasmlist);
-                {$else}
-                   tmpreg:=cg.get_scratch_reg_address(exprasmlist);
-                {$endif}
                    cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                    cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                    reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
                    reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
                    cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
                    cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
-                {$ifdef newra}
                    rg.ungetregisterint(exprasmlist,tmpreg);
                    rg.ungetregisterint(exprasmlist,tmpreg);
-                {$else}
-                   cg.free_scratch_reg(exprasmlist,tmpreg);
-                {$endif}
                 end
                 end
               else
               else
                 cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
                 cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
@@ -316,19 +292,11 @@ implementation
                    inc(pushedparasize,POINTER_SIZE);
                    inc(pushedparasize,POINTER_SIZE);
                    if calloption=pocall_inline then
                    if calloption=pocall_inline then
                      begin
                      begin
-                     {$ifdef newra}
                         tmpreg:=rg.getaddressregister(exprasmlist);
                         tmpreg:=rg.getaddressregister(exprasmlist);
-                     {$else}
-                        tmpreg:=cg.get_scratch_reg_address(exprasmlist);
-                     {$endif}
                         cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                         cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                         reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
                         reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
                         cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
                         cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
-                     {$ifdef newra}
                         rg.ungetregisterint(exprasmlist,tmpreg);
                         rg.ungetregisterint(exprasmlist,tmpreg);
-                     {$else}
-                        cg.free_scratch_reg(exprasmlist,tmpreg);
-                     {$endif}
                      end
                      end
                    else
                    else
                      cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
                      cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
@@ -415,10 +383,7 @@ implementation
     procedure tcgcallnode.handle_return_value;
     procedure tcgcallnode.handle_return_value;
       var
       var
         cgsize : tcgsize;
         cgsize : tcgsize;
-        r,hregister : tregister;
-{$ifndef NEWRA}
-        href: treference;
-{$endif}
+        hregister : tregister;
         tempnode: tnode;
         tempnode: tnode;
       begin
       begin
         { structured results are easy to handle.... }
         { structured results are easy to handle.... }
@@ -434,33 +399,18 @@ implementation
          if is_ansistring(resulttype.def) or
          if is_ansistring(resulttype.def) or
             is_widestring(resulttype.def) then
             is_widestring(resulttype.def) then
           begin
           begin
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_FUNCTION_RESULT_REG;
-{$ifdef newra}
             { the FUNCTION_RESULT_REG is already allocated }
             { the FUNCTION_RESULT_REG is already allocated }
-            rg.ungetregisterint(exprasmlist,r);
-{$else}
-            cg.a_reg_alloc(exprasmlist,r);
-{$endif}
+            rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
             if not assigned(funcretnode) then
             if not assigned(funcretnode) then
               begin
               begin
                 location_reset(location,LOC_CREFERENCE,OS_ADDR);
                 location_reset(location,LOC_CREFERENCE,OS_ADDR);
                 location.reference:=refcountedtemp;
                 location.reference:=refcountedtemp;
-                cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,r,location.reference);
-{$ifndef newra}
-                cg.a_reg_dealloc(exprasmlist,r);
-{$endif newra}
+                cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,location.reference);
               end
               end
             else
             else
               begin
               begin
-{$ifndef newra}
-                tg.gettemp(exprasmlist,pointer_size,tt_normal,href);
-                cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,r,href);
-                cg.a_reg_dealloc(exprasmlist,r);
-{$else newra}
                 hregister := rg.getaddressregister(exprasmlist);
                 hregister := rg.getaddressregister(exprasmlist);
-                cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,r,hregister);
-{$endif newra}
+                cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,hregister);
                 { in case of a regular funcretnode with ret_in_param, the }
                 { in case of a regular funcretnode with ret_in_param, the }
                 { original funcretnode isn't touched -> make sure it's    }
                 { original funcretnode isn't touched -> make sure it's    }
                 { the same here (not sure if it's necessary)              }
                 { the same here (not sure if it's necessary)              }
@@ -469,15 +419,8 @@ implementation
                 location := tempnode.location;
                 location := tempnode.location;
                 tempnode.free;
                 tempnode.free;
                 cg.g_decrrefcount(exprasmlist,resulttype.def,location.reference, false);
                 cg.g_decrrefcount(exprasmlist,resulttype.def,location.reference, false);
-{$ifndef newra}
-                cg.a_load_ref_ref(exprasmlist,OS_ADDR,OS_ADDR,href,location.reference);
-                { since we used a normal temp, it won't be finalized or }
-                { decref'd later -> no need to zero it                  }
-                tg.ungettemp(exprasmlist,href);
-{$else newra}
-               cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference);
-               rg.ungetregisterint(exprasmlist,hregister);
-{$endif newra}
+                cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference);
+                rg.ungetregisterint(exprasmlist,hregister);
              end;
              end;
           end
           end
         else
         else
@@ -489,10 +432,10 @@ implementation
                 location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
                 location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
 {$ifdef cpufpemu}
 {$ifdef cpufpemu}
                 if cs_fp_emulation in aktmoduleswitches then
                 if cs_fp_emulation in aktmoduleswitches then
-                  location.register.enum := FUNCTION_RESULT_REG
+                  location.register:=NR_FUNCTION_RESULT_REG
                 else
                 else
 {$endif cpufpemu}
 {$endif cpufpemu}
-                  location.register.enum:=FPU_RESULT_REG;
+                  location.register:=NR_FPU_RESULT_REG;
 {$ifdef x86}
 {$ifdef x86}
                 inc(trgcpu(rg).fpuvaroffset);
                 inc(trgcpu(rg).fpuvaroffset);
 {$else x86}
 {$else x86}
@@ -517,64 +460,26 @@ implementation
                     begin
                     begin
                       { Move the function result to free registers, preferably the
                       { Move the function result to free registers, preferably the
                         FUNCTION_RESULT_REG/FUNCTION_RESULTHIGH_REG, so no move is necessary.}
                         FUNCTION_RESULT_REG/FUNCTION_RESULTHIGH_REG, so no move is necessary.}
-                      r.enum:=R_INTREGISTER;
-                      r.number:=NR_FUNCTION_RESULT64_LOW_REG;
-                      hregister.enum:=R_INTREGISTER;
-                      hregister.number:=NR_FUNCTION_RESULT64_HIGH_REG;
-{$ifdef newra}
                       { the FUNCTION_RESULT_LOW_REG/FUNCTION_RESULT_HIGH_REG
                       { the FUNCTION_RESULT_LOW_REG/FUNCTION_RESULT_HIGH_REG
                         are already allocated }
                         are already allocated }
-                      rg.ungetregisterint(exprasmlist,r);
+                      rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG);
                       location.registerlow:=rg.getregisterint(exprasmlist,OS_INT);
                       location.registerlow:=rg.getregisterint(exprasmlist,OS_INT);
-                      cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,r,location.registerlow);
-                      rg.ungetregisterint(exprasmlist,hregister);
+                      cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,NR_FUNCTION_RESULT64_LOW_REG,location.registerlow);
+                      rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_HIGH_REG);
                       location.registerhigh:=rg.getregisterint(exprasmlist,OS_INT);
                       location.registerhigh:=rg.getregisterint(exprasmlist,OS_INT);
-                      cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,hregister,location.registerhigh);
-{$else newra}
-                      if RS_FUNCTION_RESULT64_LOW_REG in rg.unusedregsint then
-                        location.registerlow:=rg.getexplicitregisterint(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG)
-                      else
-                        cg.a_reg_alloc(exprasmlist,r);
-                      if RS_FUNCTION_RESULT64_HIGH_REG in rg.unusedregsint then
-                        location.registerhigh:=rg.getexplicitregisterint(exprasmlist,NR_FUNCTION_RESULT64_HIGH_REG)
-                      else
-                        cg.a_reg_alloc(exprasmlist,hregister);
-                      { do this after both low,high are allocated, else it is possible that
-                        low will be loaded in the register that still contains high }
-                      if location.registerlow.number=NR_NO then
-                        location.registerlow:=rg.getregisterint(exprasmlist,OS_INT);
-                      if location.registerhigh.number=NR_NO then
-                        location.registerhigh:=rg.getregisterint(exprasmlist,OS_INT);
-                      cg64.a_load64_reg_reg(exprasmlist,joinreg64(r,hregister),
-                          location.register64{$ifdef newra},false{$endif});
-{$endif newra}
+                      cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,NR_FUNCTION_RESULT64_HIGH_REG,location.registerhigh);
                     end
                     end
                    else
                    else
 {$endif cpu64bit}
 {$endif cpu64bit}
                     begin
                     begin
                       {Move the function result to a free register, preferably the
                       {Move the function result to a free register, preferably the
                        FUNCTION_RESULT_REG, so no move is necessary.}
                        FUNCTION_RESULT_REG, so no move is necessary.}
-                      r.enum:=R_INTREGISTER;
-                      r.number:=NR_FUNCTION_RESULT_REG;
-{$ifdef newra}
                       { the FUNCTION_RESULT_REG is already allocated }
                       { the FUNCTION_RESULT_REG is already allocated }
-                      rg.ungetregisterint(exprasmlist,r);
+                      rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
                       { change register size after the unget because the
                       { change register size after the unget because the
                       getregister was done for the full register }
                       getregister was done for the full register }
-                      r:=rg.makeregsize(r,cgsize);
                       location.register:=rg.getregisterint(exprasmlist,cgsize);
                       location.register:=rg.getregisterint(exprasmlist,cgsize);
-{$else newra}
-                      r:=rg.makeregsize(r,cgsize);
-                      cg.a_reg_alloc(exprasmlist,r);
-                      if RS_FUNCTION_RESULT_REG in rg.unusedregsint then
-                        begin
-                          location.register:=rg.makeregsize(rg.getexplicitregisterint(
-                             exprasmlist,NR_FUNCTION_RESULT_REG),cgsize);
-                        end
-                      else
-                        location.register:=rg.getregisterint(exprasmlist,cgsize);
-{$endif newra}
-                      cg.a_load_reg_reg(exprasmlist,cgsize,cgsize,r,location.register);
+                      cg.a_load_reg_reg(exprasmlist,cgsize,cgsize,rg.makeregsize(NR_FUNCTION_RESULT_REG,cgsize),location.register);
                     end;
                     end;
                  end
                  end
                 else
                 else
@@ -586,7 +491,6 @@ implementation
           end
           end
         else
         else
           begin
           begin
-{$ifdef newra}
             cgsize:=def_cgsize(resulttype.def);
             cgsize:=def_cgsize(resulttype.def);
 
 
             { an object constructor is a function with pointer result }
             { an object constructor is a function with pointer result }
@@ -597,21 +501,12 @@ implementation
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
               if cgsize in [OS_64,OS_S64] then
               if cgsize in [OS_64,OS_S64] then
                 begin
                 begin
-                  r.enum:=R_INTREGISTER;
-                  r.number:=NR_FUNCTION_RESULT64_LOW_REG;
-                  hregister.enum:=R_INTREGISTER;
-                  hregister.number:=NR_FUNCTION_RESULT64_HIGH_REG;
-                  rg.ungetregisterint(exprasmlist,r);
-                  rg.ungetregisterint(exprasmlist,hregister);
+                  rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG);
+                  rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_HIGH_REG);
                 end
                 end
               else
               else
 {$endif cpu64bit}
 {$endif cpu64bit}
-                begin
-                  r.enum:=R_INTREGISTER;
-                  r.number:=NR_FUNCTION_RESULT_REG;
-                  rg.ungetregisterint(exprasmlist,r);
-                end;
-{$endif newra}
+                rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
             location_reset(location,LOC_VOID,OS_NO);
             location_reset(location,LOC_VOID,OS_NO);
           end;
           end;
       end;
       end;
@@ -630,17 +525,7 @@ implementation
                begin
                begin
                  { don't release the funcret temp }
                  { don't release the funcret temp }
                  if not(vo_is_funcret in tvarsym(ppn.paraitem.parasym).varoptions) then
                  if not(vo_is_funcret in tvarsym(ppn.paraitem.parasym).varoptions) then
-                   begin
-{$ifdef callparatemp}
-                     { free call-by-reference temps }
-                     if (ppn.left.nodetype = typeconvn) and
-                        (ttypeconvnode(ppn.left).left.nodetype = derefn) and
-                        (tderefnode(ttypeconvnode(ppn.left).left).left.nodetype = temprefn) then
-                       location_freetemp(exprasmlist,tderefnode(ttypeconvnode(ppn.left).left).left.location)
-                     else
-{$endif callparatemp}
-                       location_freetemp(exprasmlist,ppn.left.location);
-                   end;
+                   location_freetemp(exprasmlist,ppn.left.location);
                  { process also all nodes of an array of const }
                  { process also all nodes of an array of const }
                  if ppn.left.nodetype=arrayconstructorn then
                  if ppn.left.nodetype=arrayconstructorn then
                    begin
                    begin
@@ -662,15 +547,9 @@ implementation
 
 
     procedure tcgcallnode.normal_pass_2;
     procedure tcgcallnode.normal_pass_2;
       var
       var
-         regs_to_push_other : tregisterset;
+         regs_to_push_other : totherregisterset;
          unusedstate: pointer;
          unusedstate: pointer;
-      {$ifdef newra}
-         regs_to_alloc,regs_to_free:Tsupregset;
-      {$else}
-         regs_to_push_int : Tsupregset;
-         pushedint : tpushedsavedint;
-         pushedregs : tmaybesave;
-      {$endif}
+         regs_to_alloc,regs_to_free:Tsuperregisterset;
          pushedother : tpushedsavedother;
          pushedother : tpushedsavedother;
          oldpushedparasize : longint;
          oldpushedparasize : longint;
          { adress returned from an I/O-error }
          { adress returned from an I/O-error }
@@ -679,9 +558,6 @@ implementation
          href,helpref : treference;
          href,helpref : treference;
          para_alignment,
          para_alignment,
          pop_size : longint;
          pop_size : longint;
-{$ifdef x86}
-         accreg,
-{$endif x86}
          vmtreg,vmtreg2 : tregister;
          vmtreg,vmtreg2 : tregister;
          oldaktcallnode : tcallnode;
          oldaktcallnode : tcallnode;
 
 
@@ -714,7 +590,7 @@ implementation
                      end
                      end
                    else
                    else
 {$endif cpu64bit}
 {$endif cpu64bit}
-                     cg.a_load_reg_reg(exprasmlist,ppn.tempparaloc.size,ppn.paraitem.paraloc[callerside].size,
+                     cg.a_load_reg_reg(exprasmlist,ppn.tempparaloc.size,ppn.tempparaloc.size,
                          ppn.tempparaloc.register,ppn.paraitem.paraloc[callerside].register);
                          ppn.tempparaloc.register,ppn.paraitem.paraloc[callerside].register);
                  end;
                  end;
                ppn:=tcgcallparanode(ppn.right);
                ppn:=tcgcallparanode(ppn.right);
@@ -795,13 +671,7 @@ implementation
               else
               else
                 iolabel:=nil;
                 iolabel:=nil;
 
 
-{$ifdef newra}
               regs_to_alloc:=Tprocdef(procdefinition).usedintregisters;
               regs_to_alloc:=Tprocdef(procdefinition).usedintregisters;
-{$else}
-              { save all used registers and possible registers
-                used for the return value }
-              regs_to_push_int := tprocdef(procdefinition).usedintregisters;
-{$endif}
 
 
 {$ifdef i386}
 {$ifdef i386}
               regs_to_push_other := tprocdef(procdefinition).usedotherregisters;
               regs_to_push_other := tprocdef(procdefinition).usedotherregisters;
@@ -818,19 +688,15 @@ implementation
            end
            end
          else
          else
            begin
            begin
-{$ifdef newra}
               regs_to_alloc:=VOLATILE_INTREGISTERS;
               regs_to_alloc:=VOLATILE_INTREGISTERS;
-{$else}
-              regs_to_push_int := VOLATILE_INTREGISTERS;
-{$endif}
 {$ifdef i386}
 {$ifdef i386}
-              regs_to_push_other := all_registers;
+              regs_to_push_other := all_otherregisters;
 {$else i386}
 {$else i386}
               regs_to_push_other := VOLATILE_FPUREGISTERS;
               regs_to_push_other := VOLATILE_FPUREGISTERS;
 {$endif i386}
 {$endif i386}
 {$ifdef i386}
 {$ifdef i386}
               rg.used_in_proc_int:=VOLATILE_INTREGISTERS;
               rg.used_in_proc_int:=VOLATILE_INTREGISTERS;
-              rg.used_in_proc_other:=all_registers;
+              rg.used_in_proc_other:=all_otherregisters;
 {$endif i386}
 {$endif i386}
 
 
               { no IO check for methods and procedure variables }
               { no IO check for methods and procedure variables }
@@ -840,43 +706,23 @@ implementation
         { Include Function result registers }
         { Include Function result registers }
         if (not is_void(resulttype.def)) then
         if (not is_void(resulttype.def)) then
           begin
           begin
-{$ifdef NEWRA}
-            case procdefinition.funcret_paraloc[callerside].loc of
-              LOC_REGISTER,LOC_CREGISTER:
-                begin
-{$ifndef cpu64bit}
-                  if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
-                    begin
-                      include(regs_to_alloc,procdefinition.funcret_paraloc[callerside].registerlow.number shr 8);
-                      include(regs_to_alloc,procdefinition.funcret_paraloc[callerside].registerhigh.number shr 8);
-                    end
-                 else
-{$endif cpu64bit}
-                   include(regs_to_alloc,procdefinition.funcret_paraloc[callerside].register.number shr 8);
-                end;
-            end;
-{$else NEWRA}
             case procdefinition.funcret_paraloc[callerside].loc of
             case procdefinition.funcret_paraloc[callerside].loc of
               LOC_REGISTER,LOC_CREGISTER:
               LOC_REGISTER,LOC_CREGISTER:
                 begin
                 begin
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
                   if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
                   if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
                     begin
                     begin
-                      include(regs_to_push_int,procdefinition.funcret_paraloc[callerside].registerlow.number shr 8);
-                      include(regs_to_push_int,procdefinition.funcret_paraloc[callerside].registerhigh.number shr 8);
+                      include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].registerlow));
+                      include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].registerhigh));
                     end
                     end
                  else
                  else
 {$endif cpu64bit}
 {$endif cpu64bit}
-                   include(regs_to_push_int,procdefinition.funcret_paraloc[callerside].register.number shr 8);
+                   include(regs_to_alloc,getsupreg(procdefinition.funcret_paraloc[callerside].register));
                 end;
                 end;
             end;
             end;
-{$endif NEWRA}
           end;
           end;
 
 
          { Save registers destroyed by the call }
          { Save registers destroyed by the call }
-{$ifndef NEWRA}
-         rg.saveusedintregisters(exprasmlist,pushedint,regs_to_push_int);
-{$endif}
          rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
          rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
 
 
          { Initialize for pushing the parameters }
          { Initialize for pushing the parameters }
@@ -908,7 +754,7 @@ implementation
              if tprocdef(procdefinition).extnumber=-1 then
              if tprocdef(procdefinition).extnumber=-1 then
                internalerror(200304021);
                internalerror(200304021);
              { VMT should already be loaded in a register }
              { VMT should already be loaded in a register }
-             if methodpointer.location.register.number=NR_NO then
+             if methodpointer.location.register=NR_NO then
                internalerror(200304022);
                internalerror(200304022);
 
 
              { test validity of VMT }
              { test validity of VMT }
@@ -921,24 +767,9 @@ implementation
          { Process parameters }
          { Process parameters }
          if assigned(left) then
          if assigned(left) then
            begin
            begin
-            {$ifndef newra}
-              if assigned(right) then
-                maybe_save(exprasmlist,left.registers32,right.location,pushedregs)
-              else
-                if assigned(methodpointer) then
-                  maybe_save(exprasmlist,left.registers32,methodpointer.location,pushedregs);
-
-            {$endif}
               tcallparanode(left).secondcallparan(
               tcallparanode(left).secondcallparan(
                 (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
                 (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
                  para_alignment,0);
                  para_alignment,0);
-            {$ifndef newra}
-              if assigned(right) then
-                maybe_restore(exprasmlist,right.location,pushedregs)
-              else
-                if assigned(methodpointer) then
-                  maybe_restore(exprasmlist,methodpointer.location,pushedregs);
-            {$endif newra}
 
 
 {$ifdef usetempparaloc}
 {$ifdef usetempparaloc}
              pushparas;
              pushparas;
@@ -955,9 +786,6 @@ implementation
                  ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
                  ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
                 push_framepointer;
                 push_framepointer;
 
 
-{$ifndef newra}
-              rg.saveintregvars(exprasmlist,regs_to_push_int);
-{$endif}
               rg.saveotherregvars(exprasmlist,regs_to_push_other);
               rg.saveotherregvars(exprasmlist,regs_to_push_other);
 
 
               if (po_virtualmethod in procdefinition.procoptions) and
               if (po_virtualmethod in procdefinition.procoptions) and
@@ -972,7 +800,7 @@ implementation
                    if tprocdef(procdefinition).extnumber=-1 then
                    if tprocdef(procdefinition).extnumber=-1 then
                      internalerror(200304021);
                      internalerror(200304021);
                    { VMT should already be loaded in a register }
                    { VMT should already be loaded in a register }
-                   if vmtreg.number=NR_NO then
+                   if vmtreg=NR_NO then
                      internalerror(200304022);
                      internalerror(200304022);
 
 
                    { test validity of VMT }
                    { test validity of VMT }
@@ -982,36 +810,26 @@ implementation
 {$else}
 {$else}
                    vmtreg:=methodpointer.location.register;
                    vmtreg:=methodpointer.location.register;
 {$endif}
 {$endif}
-{$ifdef newra}
                    { release self }
                    { release self }
                    rg.ungetaddressregister(exprasmlist,vmtreg);
                    rg.ungetaddressregister(exprasmlist,vmtreg);
                    vmtreg2:=rg.getabtregisterint(exprasmlist,OS_ADDR);
                    vmtreg2:=rg.getabtregisterint(exprasmlist,OS_ADDR);
                    rg.ungetregisterint(exprasmlist,vmtreg2);
                    rg.ungetregisterint(exprasmlist,vmtreg2);
                    cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,vmtreg,vmtreg2);
                    cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,vmtreg,vmtreg2);
-{$endif newra}
                    { free the resources allocated for the parameters }
                    { free the resources allocated for the parameters }
                    freeparas;
                    freeparas;
 
 
-{$ifdef newra}
                    rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
                    rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
-{$endif}
                    { call method }
                    { call method }
-                   reference_reset_base(href,{$ifdef newra}vmtreg2{$else}vmtreg{$endif},
+                   reference_reset_base(href,vmtreg2,
                       tprocdef(procdefinition)._class.vmtmethodoffset(tprocdef(procdefinition).extnumber));
                       tprocdef(procdefinition)._class.vmtmethodoffset(tprocdef(procdefinition).extnumber));
                    cg.a_call_ref(exprasmlist,href);
                    cg.a_call_ref(exprasmlist,href);
-{$ifndef newra}
-                   { release self }
-                   rg.ungetaddressregister(exprasmlist,vmtreg);
-{$endif}
                 end
                 end
               else
               else
                 begin
                 begin
                   { free the resources allocated for the parameters }
                   { free the resources allocated for the parameters }
                   freeparas;
                   freeparas;
 
 
-{$ifdef newra}
                   rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
                   rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
-{$endif}
                   { Calling interrupt from the same code requires some
                   { Calling interrupt from the same code requires some
                     extra code }
                     extra code }
                   if (po_interrupt in procdefinition.procoptions) then
                   if (po_interrupt in procdefinition.procoptions) then
@@ -1025,18 +843,17 @@ implementation
 {$ifdef i386}
 {$ifdef i386}
               secondpass(right);
               secondpass(right);
 {$endif i386}
 {$endif i386}
-{$ifdef newra}
               if right.location.loc in  [LOC_REFERENCE,LOC_CREFERENCE] then
               if right.location.loc in  [LOC_REFERENCE,LOC_CREFERENCE] then
                 begin
                 begin
                   helpref:=right.location.reference;
                   helpref:=right.location.reference;
-                  if (helpref.index.number<>NR_NO) and (helpref.index.number<>NR_FRAME_POINTER_REG) then
+                  if (helpref.index<>NR_NO) and (helpref.index<>NR_FRAME_POINTER_REG) then
                     begin
                     begin
                       rg.ungetregisterint(exprasmlist,helpref.index);
                       rg.ungetregisterint(exprasmlist,helpref.index);
                       helpref.index:=rg.getabtregisterint(exprasmlist,OS_ADDR);
                       helpref.index:=rg.getabtregisterint(exprasmlist,OS_ADDR);
                       cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,
                       cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,
                                         right.location.reference.index,helpref.index);
                                         right.location.reference.index,helpref.index);
                     end;
                     end;
-                  if (helpref.base.number<>NR_NO) and (helpref.base.number<>NR_FRAME_POINTER_REG) then
+                  if (helpref.base<>NR_NO) and (helpref.base<>NR_FRAME_POINTER_REG) then
                     begin
                     begin
                       rg.ungetregisterint(exprasmlist,helpref.base);
                       rg.ungetregisterint(exprasmlist,helpref.base);
                       helpref.base:=rg.getabtregisterint(exprasmlist,OS_ADDR);
                       helpref.base:=rg.getabtregisterint(exprasmlist,OS_ADDR);
@@ -1049,24 +866,17 @@ implementation
                 rg.ungetregisterint(exprasmlist,right.location.register);
                 rg.ungetregisterint(exprasmlist,right.location.register);
 
 
               location_freetemp(exprasmlist,right.location);
               location_freetemp(exprasmlist,right.location);
-{$endif newra}
 
 
               { free the resources allocated for the parameters }
               { free the resources allocated for the parameters }
               freeparas;
               freeparas;
 
 
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
               rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
-{$endif}
               { Calling interrupt from the same code requires some
               { Calling interrupt from the same code requires some
                 extra code }
                 extra code }
               if (po_interrupt in procdefinition.procoptions) then
               if (po_interrupt in procdefinition.procoptions) then
                 extra_interrupt_code;
                 extra_interrupt_code;
 
 
-            {$ifndef newra}
-               helpref:=right.location.reference;
-               rg.saveintregvars(exprasmlist,VOLATILE_INTREGISTERS);
-            {$endif}
-               rg.saveotherregvars(exprasmlist,ALL_REGISTERS);
+               rg.saveotherregvars(exprasmlist,ALL_OTHERREGISTERS);
                if right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
                if right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
                  cg.a_call_ref(exprasmlist,helpref)
                  cg.a_call_ref(exprasmlist,helpref)
                else
                else
@@ -1101,7 +911,6 @@ implementation
          testregisters32;
          testregisters32;
 {$endif TEMPREGDEBUG}
 {$endif TEMPREGDEBUG}
 
 
-{$ifdef newra}
          { Release registers, but not the registers that contain the
          { Release registers, but not the registers that contain the
            function result }
            function result }
          regs_to_free:=regs_to_alloc;
          regs_to_free:=regs_to_alloc;
@@ -1113,17 +922,17 @@ implementation
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
                    if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
                    if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
                      begin
                      begin
-                       exclude(regs_to_free,procdefinition.funcret_paraloc[callerside].registerlow.number shr 8);
-                       exclude(regs_to_free,procdefinition.funcret_paraloc[callerside].registerhigh.number shr 8);
+                       exclude(regs_to_free,getsupreg(procdefinition.funcret_paraloc[callerside].registerlow));
+                       exclude(regs_to_free,getsupreg(procdefinition.funcret_paraloc[callerside].registerhigh));
                      end
                      end
                    else
                    else
 {$endif cpu64bit}
 {$endif cpu64bit}
-                     exclude(regs_to_free,procdefinition.funcret_paraloc[callerside].register.number shr 8);
+                     exclude(regs_to_free,getsupreg(procdefinition.funcret_paraloc[callerside].register));
                  end;
                  end;
              end;
              end;
            end;
            end;
          rg.deallocexplicitregistersint(exprasmlist,regs_to_free);
          rg.deallocexplicitregistersint(exprasmlist,regs_to_free);
-{$endif}
+
          { handle function results }
          { handle function results }
          if (not is_void(resulttype.def)) then
          if (not is_void(resulttype.def)) then
            handle_return_value
            handle_return_value
@@ -1136,20 +945,13 @@ implementation
               //reference_reset_symbol(href,iolabel,0);
               //reference_reset_symbol(href,iolabel,0);
               //cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(exprasmlist,1));
               //cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(exprasmlist,1));
               //paramanager.freeintparaloc(exprasmlist,1);
               //paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_IOCHECK');
               cg.a_call_name(exprasmlist,'FPC_IOCHECK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
            end;
            end;
 
 
          { restore registers }
          { restore registers }
          rg.restoreusedotherregisters(exprasmlist,pushedother);
          rg.restoreusedotherregisters(exprasmlist,pushedother);
-       {$ifndef newra}
-         rg.restoreusedintregisters(exprasmlist,pushedint);
-       {$endif}
 
 
          { release temps of paras }
          { release temps of paras }
          release_para_temps;
          release_para_temps;
@@ -1169,8 +971,7 @@ implementation
                 begin
                 begin
 {$ifdef x86}
 {$ifdef x86}
                   { release FPU stack }
                   { release FPU stack }
-                  accreg.enum:=FPU_RESULT_REG;
-                  emit_reg(A_FSTP,S_NO,accreg);
+                  emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG);
                   {
                   {
                     dec(trgcpu(rg).fpuvaroffset);
                     dec(trgcpu(rg).fpuvaroffset);
                     do NOT decrement as the increment before
                     do NOT decrement as the increment before
@@ -1184,22 +985,13 @@ implementation
 
 
     procedure tcgcallnode.inlined_pass_2;
     procedure tcgcallnode.inlined_pass_2;
       var
       var
-         regs_to_push_int : Tsupregset;
-         regs_to_push_other : tregisterset;
+         regs_to_push_int : Tsuperregisterset;
+         regs_to_push_other : totherregisterset;
          unusedstate: pointer;
          unusedstate: pointer;
          pushedother : tpushedsavedother;
          pushedother : tpushedsavedother;
-      {$ifndef newra}
-         pushedint : tpushedsavedint;
-         pushedregs : tmaybesave;
-      {$endif}
          oldpushedparasize : longint;
          oldpushedparasize : longint;
          { adress returned from an I/O-error }
          { adress returned from an I/O-error }
          iolabel : tasmlabel;
          iolabel : tasmlabel;
-         { help reference pointer }
-         href : treference;
-{$ifdef x86}
-         accreg : tregister;
-{$endif x86}
          oldaktcallnode : tcallnode;
          oldaktcallnode : tcallnode;
          oldprocdef : tprocdef;
          oldprocdef : tprocdef;
          i : longint;
          i : longint;
@@ -1246,9 +1038,6 @@ implementation
              { inlined code block are (JM)                                    }
              { inlined code block are (JM)                                    }
              rg.resetusableregisters;
              rg.resetusableregisters;
              rg.clearregistercount;
              rg.clearregistercount;
-           {$ifndef newra}
-             rg.cleartempgen;
-           {$endif}
              if assigned(tprocdef(procdefinition).regvarinfo) then
              if assigned(tprocdef(procdefinition).regvarinfo) then
                with pregvarinfo(tprocdef(procdefinition).regvarinfo)^ do
                with pregvarinfo(tprocdef(procdefinition).regvarinfo)^ do
                  for i := 1 to maxvarregs do
                  for i := 1 to maxvarregs do
@@ -1366,19 +1155,16 @@ implementation
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
                    if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
                    if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
                      begin
                      begin
-                       include(regs_to_push_int,procdefinition.funcret_paraloc[callerside].registerlow.number shr 8);
-                       include(regs_to_push_int,procdefinition.funcret_paraloc[callerside].registerhigh.number shr 8);
+                       include(regs_to_push_int,getsupreg(procdefinition.funcret_paraloc[callerside].registerlow));
+                       include(regs_to_push_int,getsupreg(procdefinition.funcret_paraloc[callerside].registerhigh));
                      end
                      end
                    else
                    else
 {$endif cpu64bit}
 {$endif cpu64bit}
-                    include(regs_to_push_int,procdefinition.funcret_paraloc[callerside].register.number shr 8);
+                    include(regs_to_push_int,getsupreg(procdefinition.funcret_paraloc[callerside].register));
                  end;
                  end;
              end;
              end;
            end;
            end;
 
 
-      {$ifndef newra}
-         rg.saveusedintregisters(exprasmlist,pushedint,regs_to_push_int);
-      {$endif}
          rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
          rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
 
 
 {$ifdef i386}
 {$ifdef i386}
@@ -1397,32 +1183,14 @@ implementation
 
 
          if assigned(left) then
          if assigned(left) then
            begin
            begin
-            {$ifndef newra}
-              if assigned(right) then
-                maybe_save(exprasmlist,left.registers32,right.location,pushedregs)
-              else
-                if assigned(methodpointer) then
-                  maybe_save(exprasmlist,left.registers32,methodpointer.location,pushedregs);
-
-            {$endif}
               { we push from right to left, so start with parameters at the end of
               { we push from right to left, so start with parameters at the end of
                 the parameter block }
                 the parameter block }
               tcallparanode(left).secondcallparan(
               tcallparanode(left).secondcallparan(
                   (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
                   (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
                   0,procdefinition.parast.address_fixup+procdefinition.parast.datasize);
                   0,procdefinition.parast.address_fixup+procdefinition.parast.datasize);
-            {$ifndef newra}
-              if assigned(right) then
-                maybe_restore(exprasmlist,right.location,pushedregs)
-              else
-                if assigned(methodpointer) then
-                  maybe_restore(exprasmlist,methodpointer.location,pushedregs);
-            {$endif newra}
            end;
            end;
          aktcallnode:=oldaktcallnode;
          aktcallnode:=oldaktcallnode;
 
 
-      {$ifndef newra}
-         rg.saveintregvars(exprasmlist,regs_to_push_int);
-      {$endif}
          rg.saveotherregvars(exprasmlist,regs_to_push_other);
          rg.saveotherregvars(exprasmlist,regs_to_push_other);
 
 
          { takes care of local data initialization }
          { takes care of local data initialization }
@@ -1493,20 +1261,13 @@ implementation
               //reference_reset_symbol(href,iolabel,0);
               //reference_reset_symbol(href,iolabel,0);
               //cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(exprasmlist,1));
               //cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(exprasmlist,1));
               //paramanager.freeintparaloc(exprasmlist,1);
               //paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_IOCHECK');
               cg.a_call_name(exprasmlist,'FPC_IOCHECK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
            end;
            end;
 
 
          { restore registers }
          { restore registers }
          rg.restoreusedotherregisters(exprasmlist,pushedother);
          rg.restoreusedotherregisters(exprasmlist,pushedother);
-      {$ifndef newra}
-         rg.restoreusedintregisters(exprasmlist,pushedint);
-      {$endif}
 
 
          { release temps of paras }
          { release temps of paras }
          release_para_temps;
          release_para_temps;
@@ -1527,8 +1288,7 @@ implementation
                 begin
                 begin
 {$ifdef x86}
 {$ifdef x86}
                   { release FPU stack }
                   { release FPU stack }
-                  accreg.enum:=FPU_RESULT_REG;
-                  emit_reg(A_FSTP,S_NO,accreg);
+                  emit_reg(A_FSTP,S_NO,NR_FPU_RESULT_REG);
                   {
                   {
                     dec(trgcpu(rg).fpuvaroffset);
                     dec(trgcpu(rg).fpuvaroffset);
                     do NOT decrement as the increment before
                     do NOT decrement as the increment before
@@ -1583,7 +1343,22 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.108  2003-08-21 22:14:16  olle
+  Revision 1.109  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.108.2.4  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.108.2.3  2003/08/31 21:07:44  daniel
+    * callparatemp ripped
+
+  Revision 1.108.2.2  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.108.2.1  2003/08/27 20:23:55  peter
+    * remove old ra code
+
+  Revision 1.108  2003/08/21 22:14:16  olle
     - removed parameter from fpc_iocheck
     - removed parameter from fpc_iocheck
 
 
   Revision 1.107  2003/08/17 16:59:20  jonas
   Revision 1.107  2003/08/17 16:59:20  jonas

+ 5 - 6
compiler/ncgcon.pas

@@ -442,12 +442,8 @@ implementation
                              i:=0;
                              i:=0;
                              while assigned(hp1) and (i<32) do
                              while assigned(hp1) and (i<32) do
                               begin
                               begin
-                            {$ifdef oldset}
-                                if tai_const(hp1).value<>value_set^[i xor indexadjust] then
-                            {$else}
                                 if tai_const(hp1).value<>Psetbytes(value_set)^[i xor indexadjust] then
                                 if tai_const(hp1).value<>Psetbytes(value_set)^[i xor indexadjust] then
-                            {$endif}
-                                 break;
+                                  break;
                                 inc(i);
                                 inc(i);
                                 hp1:=tai(hp1.next);
                                 hp1:=tai(hp1.next);
                               end;
                               end;
@@ -549,7 +545,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.28  2003-05-01 12:24:22  jonas
+  Revision 1.29  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.28  2003/05/01 12:24:22  jonas
     * fixed endian issues when writing out set constants
     * fixed endian issues when writing out set constants
 
 
   Revision 1.27  2003/04/24 22:29:57  florian
   Revision 1.27  2003/04/24 22:29:57  florian

+ 47 - 166
compiler/ncgflw.pas

@@ -135,9 +135,6 @@ implementation
 
 
          aktcontinuelabel:=lcont;
          aktcontinuelabel:=lcont;
          aktbreaklabel:=lbreak;
          aktbreaklabel:=lbreak;
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
          if assigned(right) then
          if assigned(right) then
            secondpass(right);
            secondpass(right);
 
 
@@ -156,9 +153,6 @@ implementation
             truelabel:=lloop;
             truelabel:=lloop;
             falselabel:=lbreak;
             falselabel:=lbreak;
           end;
           end;
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
          secondpass(left);
          secondpass(left);
 
 
          maketojumpbool(exprasmlist,left,lr_load_regvars);
          maketojumpbool(exprasmlist,left,lr_load_regvars);
@@ -187,7 +181,7 @@ implementation
          else_regvar_loaded_other : regvarother_booleanarray;
          else_regvar_loaded_other : regvarother_booleanarray;
          org_regvar_loaded_int,
          org_regvar_loaded_int,
          then_regvar_loaded_int,
          then_regvar_loaded_int,
-         else_regvar_loaded_int : Tsupregset;
+         else_regvar_loaded_int : Tsuperregisterset;
          org_list,
          org_list,
          then_list,
          then_list,
          else_list : taasmoutput;
          else_list : taasmoutput;
@@ -200,9 +194,6 @@ implementation
          oflabel:=falselabel;
          oflabel:=falselabel;
          objectlibrary.getlabel(truelabel);
          objectlibrary.getlabel(truelabel);
          objectlibrary.getlabel(falselabel);
          objectlibrary.getlabel(falselabel);
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
          secondpass(left);
          secondpass(left);
 
 
 {$ifdef i386}
 {$ifdef i386}
@@ -227,9 +218,6 @@ implementation
          if assigned(right) then
          if assigned(right) then
            begin
            begin
               cg.a_label(exprasmlist,truelabel);
               cg.a_label(exprasmlist,truelabel);
-           {$ifndef newra}
-              rg.cleartempgen;
-           {$endif}
               secondpass(right);
               secondpass(right);
            end;
            end;
 
 
@@ -265,9 +253,6 @@ implementation
                    cg.a_jmp_always(exprasmlist,hl);
                    cg.a_jmp_always(exprasmlist,hl);
                 end;
                 end;
               cg.a_label(exprasmlist,falselabel);
               cg.a_label(exprasmlist,falselabel);
-            {$ifndef newra}
-              rg.cleartempgen;
-            {$endif}
               secondpass(t1);
               secondpass(t1);
 {$ifdef i386}
 {$ifdef i386}
               { save current asmlist (previous instructions + else-block) }
               { save current asmlist (previous instructions + else-block) }
@@ -367,19 +352,12 @@ implementation
          objectlibrary.getlabel(l3);
          objectlibrary.getlabel(l3);
 
 
          { only calculate reference }
          { only calculate reference }
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
          secondpass(t2);
          secondpass(t2);
          hs := t2.resulttype.def.size;
          hs := t2.resulttype.def.size;
          opsize := def_cgsize(t2.resulttype.def);
          opsize := def_cgsize(t2.resulttype.def);
 
 
          { first set the to value
          { first set the to value
            because the count var can be in the expression !! }
            because the count var can be in the expression !! }
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
-
          do_loopvar_at_end:=lnf_dont_mind_loopvar_on_exit in loopflags;
          do_loopvar_at_end:=lnf_dont_mind_loopvar_on_exit in loopflags;
 
 
          secondpass(right);
          secondpass(right);
@@ -404,9 +382,6 @@ implementation
            temptovalue:=false;
            temptovalue:=false;
 
 
          { produce start assignment }
          { produce start assignment }
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
          secondpass(left);
          secondpass(left);
          count_var_is_signed:=is_signed(t2.resulttype.def);
          count_var_is_signed:=is_signed(t2.resulttype.def);
 
 
@@ -468,9 +443,6 @@ implementation
             end;
             end;
 
 
          { help register must not be in instruction block }
          { help register must not be in instruction block }
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
          if assigned(t1) then
          if assigned(t1) then
            begin
            begin
              secondpass(t1);
              secondpass(t1);
@@ -491,11 +463,6 @@ implementation
 
 
          cg.a_label(exprasmlist,aktcontinuelabel);
          cg.a_label(exprasmlist,aktcontinuelabel);
 
 
-         { makes no problems there }
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
-
          if do_loopvar_at_end then
          if do_loopvar_at_end then
            if lnf_backward in loopflags then
            if lnf_backward in loopflags then
              if count_var_is_signed then
              if count_var_is_signed then
@@ -787,9 +754,6 @@ implementation
 
 
          load_all_regvars(exprasmlist);
          load_all_regvars(exprasmlist);
          cg.a_label(exprasmlist,labelnr);
          cg.a_label(exprasmlist,labelnr);
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif newra}
          secondpass(left);
          secondpass(left);
       end;
       end;
 
 
@@ -803,43 +767,34 @@ implementation
       var
       var
          a : tasmlabel;
          a : tasmlabel;
          href2: treference;
          href2: treference;
-         r:Tregister;
       begin
       begin
          location_reset(location,LOC_VOID,OS_NO);
          location_reset(location,LOC_VOID,OS_NO);
 
 
          if assigned(left) then
          if assigned(left) then
            begin
            begin
-{$ifdef callparatemp}
-              { process object (may contain a call) }
+              { multiple parameters? }
+              if assigned(right) then
+                begin
+                  if assigned(frametree) then
+                    secondpass(frametree);
+                  secondpass(right);
+                end;
               secondpass(left);
               secondpass(left);
               if codegenerror then
               if codegenerror then
                 exit;
                 exit;
-{$endif callparatemp}
-              { multiple parameters? }
+
+              { Push parameters }
               if assigned(right) then
               if assigned(right) then
                 begin
                 begin
-{$ifdef callparatemp}
-                  { process address (in case it contains a call) }
-                  secondpass(right);
-                  if codegenerror then
-                    exit;
-{$endif callparatemp}
-                  { push frame }
                   if assigned(frametree) then
                   if assigned(frametree) then
                     begin
                     begin
-                      secondpass(frametree);
-                      if codegenerror then
-                        exit;
-                      cg.a_param_loc(exprasmlist,frametree.location,paramanager.getintparaloc(exprasmlist,3));
+                      location_release(exprasmlist,frametree.location);
+                      cg.a_param_loc(exprasmlist,frametree.location,paramanager.getintparaloc(exprasmlist,3))
                     end
                     end
                   else
                   else
                     cg.a_param_const(exprasmlist,OS_INT,0,paramanager.getintparaloc(exprasmlist,3));
                     cg.a_param_const(exprasmlist,OS_INT,0,paramanager.getintparaloc(exprasmlist,3));
-{$ifndef callparatemp}
                   { push address }
                   { push address }
-                  secondpass(right);
-                  if codegenerror then
-                    exit;
-{$endif not callparatemp}
+                  location_release(exprasmlist,right.location);
                   cg.a_param_loc(exprasmlist,right.location,paramanager.getintparaloc(exprasmlist,2));
                   cg.a_param_loc(exprasmlist,right.location,paramanager.getintparaloc(exprasmlist,2));
                 end
                 end
               else
               else
@@ -849,43 +804,28 @@ implementation
                    cg.a_label(exprasmlist,a);
                    cg.a_label(exprasmlist,a);
                    reference_reset_symbol(href2,a,0);
                    reference_reset_symbol(href2,a,0);
                    { push current frame }
                    { push current frame }
-                   r.enum:=R_INTREGISTER;
-                   r.number:=NR_FRAME_POINTER_REG;
-                   cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(exprasmlist,3));
+                   cg.a_param_reg(exprasmlist,OS_ADDR,NR_FRAME_POINTER_REG,paramanager.getintparaloc(exprasmlist,3));
                    { push current address }
                    { push current address }
                    if target_info.system <> system_powerpc_macos then
                    if target_info.system <> system_powerpc_macos then
                      cg.a_paramaddr_ref(exprasmlist,href2,paramanager.getintparaloc(exprasmlist,2))
                      cg.a_paramaddr_ref(exprasmlist,href2,paramanager.getintparaloc(exprasmlist,2))
                    else
                    else
                      cg.a_param_const(exprasmlist,OS_INT,0,paramanager.getintparaloc(exprasmlist,2));
                      cg.a_param_const(exprasmlist,OS_INT,0,paramanager.getintparaloc(exprasmlist,2));
                 end;
                 end;
-{$ifndef callparatemp}
-              { push object }
-              secondpass(left);
-              if codegenerror then
-                exit;
-{$endif not callparatemp}
+              location_release(exprasmlist,left.location);
               cg.a_param_loc(exprasmlist,left.location,paramanager.getintparaloc(exprasmlist,1));
               cg.a_param_loc(exprasmlist,left.location,paramanager.getintparaloc(exprasmlist,1));
               paramanager.freeintparaloc(exprasmlist,3);
               paramanager.freeintparaloc(exprasmlist,3);
               paramanager.freeintparaloc(exprasmlist,2);
               paramanager.freeintparaloc(exprasmlist,2);
               paramanager.freeintparaloc(exprasmlist,1);
               paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_RAISEEXCEPTION');
               cg.a_call_name(exprasmlist,'FPC_RAISEEXCEPTION');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
            end
            end
          else
          else
            begin
            begin
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
               cg.a_call_name(exprasmlist,'FPC_RERAISE');
               cg.a_call_name(exprasmlist,'FPC_RERAISE');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
            end;
            end;
        end;
        end;
 
 
@@ -922,27 +862,15 @@ implementation
     { in the except block                                    }
     { in the except block                                    }
     procedure cleanupobjectstack;
     procedure cleanupobjectstack;
 
 
-    var r:Tregister;
-
       begin
       begin
-{$ifdef newra}
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
          cg.a_call_name(exprasmlist,'FPC_POPOBJECTSTACK');
          cg.a_call_name(exprasmlist,'FPC_POPOBJECTSTACK');
-{$ifdef newra}
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
-         r.enum:=R_INTREGISTER;
-         r.number:=NR_FUNCTION_RESULT_REG;
-         cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(exprasmlist,1));
+         cg.a_param_reg(exprasmlist,OS_ADDR,NR_FUNCTION_RESULT_REG,paramanager.getintparaloc(exprasmlist,1));
          paramanager.freeintparaloc(exprasmlist,1);
          paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
          cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
          cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
-{$ifdef newra}
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
       end;
       end;
 
 
 
 
@@ -966,7 +894,6 @@ implementation
          exceptflowcontrol : tflowcontrol;
          exceptflowcontrol : tflowcontrol;
          tempbuf,tempaddr : treference;
          tempbuf,tempaddr : treference;
          href : treference;
          href : treference;
-         r:Tregister;
 
 
       label
       label
          errorexit;
          errorexit;
@@ -1048,13 +975,9 @@ implementation
               }
               }
               cg.a_param_const(exprasmlist,OS_ADDR,aword(-1),paramanager.getintparaloc(exprasmlist,1));
               cg.a_param_const(exprasmlist,OS_ADDR,aword(-1),paramanager.getintparaloc(exprasmlist,1));
               paramanager.freeintparaloc(exprasmlist,1);
               paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_CATCHES');
               cg.a_call_name(exprasmlist,'FPC_CATCHES');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
 
 
               { the destruction of the exception object must be also }
               { the destruction of the exception object must be also }
               { guarded by an exception frame                        }
               { guarded by an exception frame                        }
@@ -1072,25 +995,15 @@ implementation
 
 
               try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
               try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
 
 
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
               cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
 
 
-              r.enum:=R_INTREGISTER;
-              r.number:=NR_FUNCTION_RESULT_REG;
-              cg.a_param_reg(exprasmlist, OS_ADDR, r, paramanager.getintparaloc(exprasmlist,1));
+              cg.a_param_reg(exprasmlist, OS_ADDR, NR_FUNCTION_RESULT_REG, paramanager.getintparaloc(exprasmlist,1));
               paramanager.freeintparaloc(exprasmlist,1);
               paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
               cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               { we don't need to restore esi here because reraise never }
               { we don't need to restore esi here because reraise never }
               { returns                                                 }
               { returns                                                 }
               cg.a_call_name(exprasmlist,'FPC_RERAISE');
               cg.a_call_name(exprasmlist,'FPC_RERAISE');
@@ -1111,13 +1024,9 @@ implementation
               cg.a_label(exprasmlist,exitexceptlabel);
               cg.a_label(exprasmlist,exitexceptlabel);
               { we must also destroy the address frame which guards }
               { we must also destroy the address frame which guards }
               { exception object                                    }
               { exception object                                    }
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.g_exception_reason_load(exprasmlist,href);
               cg.g_exception_reason_load(exprasmlist,href);
               cleanupobjectstack;
               cleanupobjectstack;
               cg.a_jmp_always(exprasmlist,oldaktexitlabel);
               cg.a_jmp_always(exprasmlist,oldaktexitlabel);
@@ -1128,13 +1037,9 @@ implementation
               cg.a_label(exprasmlist,breakexceptlabel);
               cg.a_label(exprasmlist,breakexceptlabel);
               { we must also destroy the address frame which guards }
               { we must also destroy the address frame which guards }
               { exception object                                    }
               { exception object                                    }
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.g_exception_reason_load(exprasmlist,href);
               cg.g_exception_reason_load(exprasmlist,href);
               cleanupobjectstack;
               cleanupobjectstack;
               cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
               cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
@@ -1145,13 +1050,9 @@ implementation
               cg.a_label(exprasmlist,continueexceptlabel);
               cg.a_label(exprasmlist,continueexceptlabel);
               { we must also destroy the address frame which guards }
               { we must also destroy the address frame which guards }
               { exception object                                    }
               { exception object                                    }
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.g_exception_reason_load(exprasmlist,href);
               cg.g_exception_reason_load(exprasmlist,href);
               cleanupobjectstack;
               cleanupobjectstack;
               cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
               cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
@@ -1161,13 +1062,9 @@ implementation
            begin
            begin
               { do some magic for exit in the try block }
               { do some magic for exit in the try block }
               cg.a_label(exprasmlist,exittrylabel);
               cg.a_label(exprasmlist,exittrylabel);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.g_exception_reason_load(exprasmlist,href);
               cg.g_exception_reason_load(exprasmlist,href);
               cg.a_jmp_always(exprasmlist,oldaktexitlabel);
               cg.a_jmp_always(exprasmlist,oldaktexitlabel);
            end;
            end;
@@ -1175,13 +1072,9 @@ implementation
          if fc_break in tryflowcontrol then
          if fc_break in tryflowcontrol then
            begin
            begin
               cg.a_label(exprasmlist,breaktrylabel);
               cg.a_label(exprasmlist,breaktrylabel);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.g_exception_reason_load(exprasmlist,href);
               cg.g_exception_reason_load(exprasmlist,href);
               cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
               cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
            end;
            end;
@@ -1189,13 +1082,9 @@ implementation
          if fc_continue in tryflowcontrol then
          if fc_continue in tryflowcontrol then
            begin
            begin
               cg.a_label(exprasmlist,continuetrylabel);
               cg.a_label(exprasmlist,continuetrylabel);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.g_exception_reason_load(exprasmlist,href);
               cg.g_exception_reason_load(exprasmlist,href);
               cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
               cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
            end;
            end;
@@ -1235,7 +1124,6 @@ implementation
          tempbuf,tempaddr : treference;
          tempbuf,tempaddr : treference;
          href : treference;
          href : treference;
          href2: treference;
          href2: treference;
-         r:Tregister;
 
 
       begin
       begin
          location_reset(location,LOC_VOID,OS_NO);
          location_reset(location,LOC_VOID,OS_NO);
@@ -1248,25 +1136,19 @@ implementation
          reference_reset_symbol(href2,objectlibrary.newasmsymboldata(excepttype.vmt_mangledname),0);
          reference_reset_symbol(href2,objectlibrary.newasmsymboldata(excepttype.vmt_mangledname),0);
          cg.a_paramaddr_ref(exprasmlist,href2,paramanager.getintparaloc(exprasmlist,1));
          cg.a_paramaddr_ref(exprasmlist,href2,paramanager.getintparaloc(exprasmlist,1));
          paramanager.freeintparaloc(exprasmlist,1);
          paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
          cg.a_call_name(exprasmlist,'FPC_CATCHES');
          cg.a_call_name(exprasmlist,'FPC_CATCHES');
-{$ifdef newra}
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
 
 
          { is it this catch? No. go to next onlabel }
          { is it this catch? No. go to next onlabel }
-         r.enum:=R_INTREGISTER;
-         r.number:=NR_FUNCTION_RESULT_REG;
-         cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,r,nextonlabel);
+         cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,NR_FUNCTION_RESULT_REG,nextonlabel);
          ref.symbol:=nil;
          ref.symbol:=nil;
          tg.GetTemp(exprasmlist,pointer_size,tt_normal,ref);
          tg.GetTemp(exprasmlist,pointer_size,tt_normal,ref);
 
 
          { what a hack ! }
          { what a hack ! }
          if assigned(exceptsymtable) then
          if assigned(exceptsymtable) then
            tvarsym(exceptsymtable.symindex.first).address:=ref.offset;
            tvarsym(exceptsymtable.symindex.first).address:=ref.offset;
-         cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,r,ref);
+         cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,ref);
 
 
          { in the case that another exception is risen }
          { in the case that another exception is risen }
          { we've to destroy the old one                }
          { we've to destroy the old one                }
@@ -1297,22 +1179,14 @@ implementation
 
 
          try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
          try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
 
 
-{$ifdef newra}
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
          cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
          cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
-{$ifdef newra}
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
-         cg.a_param_reg(exprasmlist, OS_ADDR, r, paramanager.getintparaloc(exprasmlist,1));
+         cg.a_param_reg(exprasmlist, OS_ADDR, NR_FUNCTION_RESULT_REG, paramanager.getintparaloc(exprasmlist,1));
          paramanager.freeintparaloc(exprasmlist,1);
          paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
          cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
          cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
-{$ifdef newra}
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
          { we don't need to restore esi here because reraise never }
          { we don't need to restore esi here because reraise never }
          { returns                                                 }
          { returns                                                 }
          cg.a_call_name(exprasmlist,'FPC_RERAISE');
          cg.a_call_name(exprasmlist,'FPC_RERAISE');
@@ -1359,12 +1233,7 @@ implementation
          flowcontrol:=oldflowcontrol+flowcontrol;
          flowcontrol:=oldflowcontrol+flowcontrol;
          { next on node }
          { next on node }
          if assigned(left) then
          if assigned(left) then
-           begin
-            {$ifndef newra}
-              rg.cleartempgen;
-            {$endif newra}
-              secondpass(left);
-           end;
+           secondpass(left);
       end;
       end;
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -1386,7 +1255,6 @@ implementation
          decconst : longint;
          decconst : longint;
          tempbuf,tempaddr : treference;
          tempbuf,tempaddr : treference;
          href : treference;
          href : treference;
-         r:Tregister;
 
 
       begin
       begin
          location_reset(location,LOC_VOID,OS_NO);
          location_reset(location,LOC_VOID,OS_NO);
@@ -1450,11 +1318,9 @@ implementation
 
 
          { the value should now be in the exception handler }
          { the value should now be in the exception handler }
          cg.g_exception_reason_load(exprasmlist,href);
          cg.g_exception_reason_load(exprasmlist,href);
-         r.enum:=R_INTREGISTER;
-         r.number:=NR_FUNCTION_RESULT_REG;
          if implicitframe then
          if implicitframe then
            begin
            begin
-             cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,r,endfinallylabel);
+             cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,NR_FUNCTION_RESULT_REG,endfinallylabel);
              { finally code only needed to be executed on exception }
              { finally code only needed to be executed on exception }
              flowcontrol:=[];
              flowcontrol:=[];
              secondpass(t1);
              secondpass(t1);
@@ -1466,29 +1332,29 @@ implementation
            end
            end
          else
          else
            begin
            begin
-             cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,r,endfinallylabel);
-             cg.a_op_const_reg(exprasmlist,OP_SUB,OS_32,1,r);
-             cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,r,reraiselabel);
+             cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,NR_FUNCTION_RESULT_REG,endfinallylabel);
+             cg.a_op_const_reg(exprasmlist,OP_SUB,OS_32,1,NR_FUNCTION_RESULT_REG);
+             cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,NR_FUNCTION_RESULT_REG,reraiselabel);
              if fc_exit in tryflowcontrol then
              if fc_exit in tryflowcontrol then
                begin
                begin
-                  cg.a_op_const_reg(exprasmlist,OP_SUB,OS_32,1,r);
-                  cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,r,oldaktexitlabel);
+                  cg.a_op_const_reg(exprasmlist,OP_SUB,OS_32,1,NR_FUNCTION_RESULT_REG);
+                  cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,NR_FUNCTION_RESULT_REG,oldaktexitlabel);
                   decconst:=1;
                   decconst:=1;
                end
                end
              else
              else
                decconst:=2;
                decconst:=2;
              if fc_break in tryflowcontrol then
              if fc_break in tryflowcontrol then
                begin
                begin
-                  cg.a_op_const_reg(exprasmlist,OP_SUB,OS_32,decconst,r);
-                  cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,r,oldaktbreaklabel);
+                  cg.a_op_const_reg(exprasmlist,OP_SUB,OS_32,decconst,NR_FUNCTION_RESULT_REG);
+                  cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,NR_FUNCTION_RESULT_REG,oldaktbreaklabel);
                   decconst:=1;
                   decconst:=1;
                end
                end
              else
              else
                inc(decconst);
                inc(decconst);
              if fc_continue in tryflowcontrol then
              if fc_continue in tryflowcontrol then
                begin
                begin
-                  cg.a_op_const_reg(exprasmlist,OP_SUB,OS_32,decconst,r);
-                  cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,r,oldaktcontinuelabel);
+                  cg.a_op_const_reg(exprasmlist,OP_SUB,OS_32,decconst,NR_FUNCTION_RESULT_REG);
+                  cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,NR_FUNCTION_RESULT_REG,oldaktcontinuelabel);
                end;
                end;
              cg.a_label(exprasmlist,reraiselabel);
              cg.a_label(exprasmlist,reraiselabel);
              cg.a_call_name(exprasmlist,'FPC_RERAISE');
              cg.a_call_name(exprasmlist,'FPC_RERAISE');
@@ -1543,13 +1409,28 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.77  2003-09-03 11:18:36  florian
+  Revision 1.78  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.77  2003/09/03 11:18:36  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.76.2.4  2003/09/02 17:48:28  peter
+    * first process all parameters for raise before pushing the values
+
+  Revision 1.76.2.3  2003/08/31 21:07:44  daniel
+    * callparatemp ripped
+
+  Revision 1.76.2.2  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.76.2.1  2003/08/27 20:23:55  peter
+    * remove old ra code
+
   Revision 1.76  2003/08/24 21:38:43  olle
   Revision 1.76  2003/08/24 21:38:43  olle
     * made FPC_RAISEEXCEPTION compatible with MacOS
     * made FPC_RAISEEXCEPTION compatible with MacOS
 
 

+ 8 - 41
compiler/ncginl.pas

@@ -177,7 +177,6 @@ implementation
      var
      var
          hp2 : tstringconstnode;
          hp2 : tstringconstnode;
          otlabel,oflabel{,l1}   : tasmlabel;
          otlabel,oflabel{,l1}   : tasmlabel;
-         r: Tregister;
      begin
      begin
        { the node should be removed in the firstpass }
        { the node should be removed in the firstpass }
        if not (cs_do_assertion in aktlocalswitches) then
        if not (cs_do_assertion in aktlocalswitches) then
@@ -190,9 +189,7 @@ implementation
        maketojumpbool(exprasmlist,tcallparanode(left).left,lr_load_regvars);
        maketojumpbool(exprasmlist,tcallparanode(left).left,lr_load_regvars);
        cg.a_label(exprasmlist,falselabel);
        cg.a_label(exprasmlist,falselabel);
        { erroraddr }
        { erroraddr }
-       r.enum:=R_INTREGISTER;
-       r.number:=NR_FRAME_POINTER_REG;
-       cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(exprasmlist,4));
+       cg.a_param_reg(exprasmlist,OS_ADDR,NR_FRAME_POINTER_REG,paramanager.getintparaloc(exprasmlist,4));
        { lineno }
        { lineno }
        cg.a_param_const(exprasmlist,OS_INT,aktfilepos.line,paramanager.getintparaloc(exprasmlist,3));
        cg.a_param_const(exprasmlist,OS_INT,aktfilepos.line,paramanager.getintparaloc(exprasmlist,3));
        { filename string }
        { filename string }
@@ -211,13 +208,9 @@ implementation
        paramanager.freeintparaloc(exprasmlist,3);
        paramanager.freeintparaloc(exprasmlist,3);
        paramanager.freeintparaloc(exprasmlist,2);
        paramanager.freeintparaloc(exprasmlist,2);
        paramanager.freeintparaloc(exprasmlist,1);
        paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
        rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
        rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
        cg.a_call_name(exprasmlist,'FPC_ASSERT');
        cg.a_call_name(exprasmlist,'FPC_ASSERT');
-{$ifdef newra}
        rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
        rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
        cg.a_label(exprasmlist,truelabel);
        cg.a_label(exprasmlist,truelabel);
        truelabel:=otlabel;
        truelabel:=otlabel;
        falselabel:=oflabel;
        falselabel:=oflabel;
@@ -375,7 +368,6 @@ implementation
          hregisterhi,
          hregisterhi,
          hregister : tregister;
          hregister : tregister;
          cgsize : tcgsize;
          cgsize : tcgsize;
-         pushedregs : tmaybesave;
         begin
         begin
           { set defaults }
           { set defaults }
           addconstant:=true;
           addconstant:=true;
@@ -400,14 +392,7 @@ implementation
           { second_ argument specified?, must be a s32bit in register }
           { second_ argument specified?, must be a s32bit in register }
           if assigned(tcallparanode(left).right) then
           if assigned(tcallparanode(left).right) then
             begin
             begin
-            {$ifndef newra}
-              maybe_save(exprasmlist,tcallparanode(tcallparanode(left).right).left.registers32,
-                 tcallparanode(left).left.location,pushedregs);
-            {$endif}
               secondpass(tcallparanode(tcallparanode(left).right).left);
               secondpass(tcallparanode(tcallparanode(left).right).left);
-            {$ifndef newra}
-              maybe_restore(exprasmlist,tcallparanode(left).left.location,pushedregs);
-            {$endif}
               { when constant, just multiply the addvalue }
               { when constant, just multiply the addvalue }
               if is_constintnode(tcallparanode(tcallparanode(left).right).left) then
               if is_constintnode(tcallparanode(tcallparanode(left).right).left) then
                  addvalue:=addvalue*get_ordinal_value(tcallparanode(tcallparanode(left).right).left)
                  addvalue:=addvalue*get_ordinal_value(tcallparanode(tcallparanode(left).right).left)
@@ -472,7 +457,6 @@ implementation
         var
         var
          hregister : tregister;
          hregister : tregister;
          L : longint;
          L : longint;
-         pushedregs : TMaybesave;
          cgop : topcg;
          cgop : topcg;
          addrreg, hregister2: tregister;
          addrreg, hregister2: tregister;
          use_small : boolean;
          use_small : boolean;
@@ -519,21 +503,10 @@ implementation
                    (tenumdef(tcallparanode(tcallparanode(left).right).left.resulttype.def).max<=32));
                    (tenumdef(tcallparanode(tcallparanode(left).right).left.resulttype.def).max<=32));
 
 
               { generate code for the element to set }
               { generate code for the element to set }
-            {$ifndef newra}
-              maybe_save(exprasmlist,tcallparanode(tcallparanode(left).right).left.registers32,
-                        tcallparanode(left).left.location,pushedregs);
-            {$endif newra}
               secondpass(tcallparanode(tcallparanode(left).right).left);
               secondpass(tcallparanode(tcallparanode(left).right).left);
-            {$ifndef newra}
-              maybe_restore(exprasmlist,tcallparanode(left).left.location,pushedregs);
-            {$endif newra}
 
 
               { bitnumber - which must be loaded into register }
               { bitnumber - which must be loaded into register }
-            {$ifdef newra}
               hregister:=rg.getregisterint(exprasmlist,OS_INT);
               hregister:=rg.getregisterint(exprasmlist,OS_INT);
-            {$else}
-              hregister := cg.get_scratch_reg_int(exprasmlist,OS_INT);
-            {$endif}
               hregister2 := rg.getregisterint(exprasmlist,OS_INT);
               hregister2 := rg.getregisterint(exprasmlist,OS_INT);
 
 
               case tcallparanode(tcallparanode(left).right).left.location.loc of
               case tcallparanode(tcallparanode(left).right).left.location.loc of
@@ -596,11 +569,7 @@ implementation
 
 
                   cg.a_op_const_reg_reg(exprasmlist, OP_SHR, OS_32, 5, hregister,hregister2);
                   cg.a_op_const_reg_reg(exprasmlist, OP_SHR, OS_32, 5, hregister,hregister2);
                   cg.a_op_const_reg(exprasmlist, OP_SHL, OS_32, 2, hregister2);
                   cg.a_op_const_reg(exprasmlist, OP_SHL, OS_32, 2, hregister2);
-              {$ifdef newra}
                   addrreg:=rg.getaddressregister(exprasmlist);
                   addrreg:=rg.getaddressregister(exprasmlist);
-              {$else}
-                  addrreg := cg.get_scratch_reg_address(exprasmlist);
-              {$endif}
                   { calculate the correct address of the operand }
                   { calculate the correct address of the operand }
                   cg.a_loadaddr_ref_reg(exprasmlist, tcallparanode(left).left.location.reference,addrreg);
                   cg.a_loadaddr_ref_reg(exprasmlist, tcallparanode(left).left.location.reference,addrreg);
                   cg.a_op_reg_reg(exprasmlist, OP_ADD, OS_INT, hregister2, addrreg);
                   cg.a_op_reg_reg(exprasmlist, OP_ADD, OS_INT, hregister2, addrreg);
@@ -622,17 +591,9 @@ implementation
                          cg.a_op_reg_reg(exprasmlist, OP_NOT, OS_32, hregister2, hregister2);
                          cg.a_op_reg_reg(exprasmlist, OP_NOT, OS_32, hregister2, hregister2);
                          cg.a_op_reg_ref(exprasmlist, OP_AND, OS_32, hregister2, href);
                          cg.a_op_reg_ref(exprasmlist, OP_AND, OS_32, hregister2, href);
                        end;
                        end;
-                {$ifdef newra}
                   rg.ungetregisterint(exprasmlist,addrreg);
                   rg.ungetregisterint(exprasmlist,addrreg);
-                {$else}
-                  cg.free_scratch_reg(exprasmlist, addrreg);
-                {$endif}
                 end;
                 end;
-              {$ifdef newra}
                 rg.ungetregisterint(exprasmlist,hregister);
                 rg.ungetregisterint(exprasmlist,hregister);
-              {$else}
-                cg.free_scratch_reg(exprasmlist,hregister);
-              {$endif}
                 rg.ungetregisterint(exprasmlist,hregister2);
                 rg.ungetregisterint(exprasmlist,hregister2);
             end;
             end;
         end;
         end;
@@ -692,7 +653,13 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.39  2003-07-23 11:01:14  jonas
+  Revision 1.40  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.39.2.1  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.39  2003/07/23 11:01:14  jonas
     * several rg.allocexplicitregistersint/rg.deallocexplicitregistersint
     * several rg.allocexplicitregistersint/rg.deallocexplicitregistersint
       pairs round calls to helpers
       pairs round calls to helpers
 
 

+ 35 - 83
compiler/ncgld.pas

@@ -65,12 +65,8 @@ implementation
         r,hregister : tregister;
         r,hregister : tregister;
         supreg:Tsuperregister;
         supreg:Tsuperregister;
         symtabletype : tsymtabletype;
         symtabletype : tsymtabletype;
-        i : longint;
         href : treference;
         href : treference;
         newsize : tcgsize;
         newsize : tcgsize;
-      {$ifndef newra}
-        pushed : tpushedsavedint;
-      {$endif}
         dorelocatelab,
         dorelocatelab,
         norelocatelab : tasmlabel;
         norelocatelab : tasmlabel;
         paraloc: tparalocation;
         paraloc: tparalocation;
@@ -86,7 +82,7 @@ implementation
                    begin
                    begin
 {$ifdef i386}
 {$ifdef i386}
                      if tabsolutesym(symtableentry).absseg then
                      if tabsolutesym(symtableentry).absseg then
-                      location.reference.segment.enum:=R_FS;
+                      location.reference.segment:=NR_FS;
 {$endif i386}
 {$endif i386}
                      location.reference.offset:=tabsolutesym(symtableentry).address;
                      location.reference.offset:=tabsolutesym(symtableentry).address;
                    end
                    end
@@ -109,8 +105,7 @@ implementation
                   if (tvarsym(symtableentry).varspez=vs_const) then
                   if (tvarsym(symtableentry).varspez=vs_const) then
                     location_reset(location,LOC_CREFERENCE,newsize);
                     location_reset(location,LOC_CREFERENCE,newsize);
                   symtabletype:=symtable.symtabletype;
                   symtabletype:=symtable.symtabletype;
-                  hregister.enum:=R_INTREGISTER;
-                  hregister.number:=NR_NO;
+                  hregister:=NR_NO;
                   { C variable }
                   { C variable }
                   if (vo_is_C_var in tvarsym(symtableentry).varoptions) then
                   if (vo_is_C_var in tvarsym(symtableentry).varoptions) then
                     begin
                     begin
@@ -150,26 +145,15 @@ implementation
                        cg.a_jmp_always(exprasmlist,norelocatelab);
                        cg.a_jmp_always(exprasmlist,norelocatelab);
                        cg.a_label(exprasmlist,dorelocatelab);
                        cg.a_label(exprasmlist,dorelocatelab);
                        { don't save the allocated register else the result will be destroyed later }
                        { don't save the allocated register else the result will be destroyed later }
-                    {$ifndef newra}
-                       rg.saveusedintregisters(exprasmlist,pushed,[RS_FUNCTION_RESULT_REG]-[hregister.number shr 8]);
-                    {$endif}
                        reference_reset_symbol(href,objectlibrary.newasmsymboldata(tvarsym(symtableentry).mangledname),0);
                        reference_reset_symbol(href,objectlibrary.newasmsymboldata(tvarsym(symtableentry).mangledname),0);
                        cg.a_param_ref(exprasmlist,OS_ADDR,href,paraloc);
                        cg.a_param_ref(exprasmlist,OS_ADDR,href,paraloc);
                        { the called procedure isn't allowed to change }
                        { the called procedure isn't allowed to change }
                        { any register except EAX                    }
                        { any register except EAX                    }
                        cg.a_call_reg(exprasmlist,hregister);
                        cg.a_call_reg(exprasmlist,hregister);
                        paramanager.freeintparaloc(exprasmlist,1);
                        paramanager.freeintparaloc(exprasmlist,1);
-                    {$ifdef newra}
                        r:=rg.getexplicitregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
                        r:=rg.getexplicitregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
                        rg.ungetregisterint(exprasmlist,r);
                        rg.ungetregisterint(exprasmlist,r);
-                    {$else}
-                       r.enum:=R_INTREGISTER;
-                       r.number:=NR_FUNCTION_RESULT_REG;
-                    {$endif}
                        cg.a_load_reg_reg(exprasmlist,OS_INT,OS_ADDR,r,hregister);
                        cg.a_load_reg_reg(exprasmlist,OS_INT,OS_ADDR,r,hregister);
-                    {$ifndef newra}
-                       rg.restoreusedintregisters(exprasmlist,pushed);
-                    {$endif}
                        cg.a_label(exprasmlist,norelocatelab);
                        cg.a_label(exprasmlist,norelocatelab);
                        location.reference.base:=hregister;
                        location.reference.base:=hregister;
                     end
                     end
@@ -177,26 +161,28 @@ implementation
                   else
                   else
                     begin
                     begin
                        { in case it is a register variable: }
                        { in case it is a register variable: }
-                       if tvarsym(symtableentry).reg.number<>NR_NO then
+                       if tvarsym(symtableentry).reg<>NR_NO then
                          begin
                          begin
-                            if tvarsym(symtableentry).reg.enum in fpuregs then
-                              begin
-                                 location_reset(location,LOC_CFPUREGISTER,def_cgsize(resulttype.def));
-                                 location.register:=tvarsym(symtableentry).reg;
-                              end
-                            else if Tvarsym(symtableentry).reg.enum=R_INTREGISTER then
-                             begin
-                               supreg:=Tvarsym(symtableentry).reg.number shr 8;
-                               if (supreg in general_superregisters) and
-                                  not (supreg in rg.regvar_loaded_int) then
-                                 load_regvar(exprasmlist,tvarsym(symtableentry));
-                               location_reset(location,LOC_CREGISTER,def_cgsize(resulttype.def));
-                               location.register:=tvarsym(symtableentry).reg;
-                               exclude(rg.unusedregsint,supreg);
-                               hregister := location.register;
-                             end
-                           else
-                             internalerror(200301172);
+                            case getregtype(tvarsym(symtableentry).reg) of
+                              R_FPUREGISTER :
+                                begin
+                                   location_reset(location,LOC_CFPUREGISTER,def_cgsize(resulttype.def));
+                                   location.register:=tvarsym(symtableentry).reg;
+                                end;
+                              R_INTREGISTER :
+                                begin
+                                  supreg:=getsupreg(Tvarsym(symtableentry).reg);
+                                  if (supreg in general_superregisters) and
+                                     not (supreg in rg.regvar_loaded_int) then
+                                    load_regvar(exprasmlist,tvarsym(symtableentry));
+                                  location_reset(location,LOC_CREGISTER,def_cgsize(resulttype.def));
+                                  location.register:=tvarsym(symtableentry).reg;
+                                  exclude(rg.unusedregsint,supreg);
+                                  hregister := location.register;
+                                end;
+                              else
+                                internalerror(200301172);
+                            end;
                          end
                          end
                        else
                        else
                          begin
                          begin
@@ -241,7 +227,7 @@ implementation
                       paramanager.push_addr_param(tvarsym(symtableentry).vartype.def,tprocdef(symtable.defowner).proccalloption)
                       paramanager.push_addr_param(tvarsym(symtableentry).vartype.def,tprocdef(symtable.defowner).proccalloption)
                      ) then
                      ) then
                     begin
                     begin
-                      if hregister.number=NR_NO then
+                      if hregister=NR_NO then
                         hregister:=rg.getaddressregister(exprasmlist);
                         hregister:=rg.getaddressregister(exprasmlist);
                       { we need to load only an address }
                       { we need to load only an address }
                       location.size:=OS_ADDR;
                       location.size:=OS_ADDR;
@@ -327,18 +313,10 @@ implementation
                           rg.ungetregisterint(exprasmlist,hregister);
                           rg.ungetregisterint(exprasmlist,hregister);
                           { load address of the function }
                           { load address of the function }
                           reference_reset_symbol(href,objectlibrary.newasmsymbol(procdef.mangledname),0);
                           reference_reset_symbol(href,objectlibrary.newasmsymbol(procdef.mangledname),0);
-                        {$ifdef newra}
                           hregister:=rg.getaddressregister(exprasmlist);
                           hregister:=rg.getaddressregister(exprasmlist);
-                        {$else}
-                          hregister:=cg.get_scratch_reg_address(exprasmlist);
-                        {$endif}
                           cg.a_loadaddr_ref_reg(exprasmlist,href,hregister);
                           cg.a_loadaddr_ref_reg(exprasmlist,href,hregister);
                           cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference);
                           cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference);
-                        {$ifdef newra}
                           rg.ungetregisterint(exprasmlist,hregister);
                           rg.ungetregisterint(exprasmlist,hregister);
-                        {$else newra}
-                          cg.free_scratch_reg(exprasmlist,hregister);
-                        {$endif}
                         end;
                         end;
                     end
                     end
                   else
                   else
@@ -367,7 +345,6 @@ implementation
          href : treference;
          href : treference;
          old_allow_multi_pass2,
          old_allow_multi_pass2,
          releaseright : boolean;
          releaseright : boolean;
-         pushedregs : tmaybesave;
          cgsize : tcgsize;
          cgsize : tcgsize;
          r:Tregister;
          r:Tregister;
 
 
@@ -418,16 +395,10 @@ implementation
             begin
             begin
               { left can't be never a 64 bit LOC_REGISTER, so the 3. arg }
               { left can't be never a 64 bit LOC_REGISTER, so the 3. arg }
               { can be false                                             }
               { can be false                                             }
-            {$ifndef newra}
-              maybe_save(exprasmlist,left.registers32,right.location,pushedregs);
-            {$endif}
               secondpass(left);
               secondpass(left);
               { decrement destination reference counter }
               { decrement destination reference counter }
               if (left.resulttype.def.needs_inittable) then
               if (left.resulttype.def.needs_inittable) then
                cg.g_decrrefcount(exprasmlist,left.resulttype.def,left.location.reference,false);
                cg.g_decrrefcount(exprasmlist,left.resulttype.def,left.location.reference,false);
-            {$ifndef newra}
-              maybe_restore(exprasmlist,right.location,pushedregs);
-            {$endif newra}
               if codegenerror then
               if codegenerror then
                 exit;
                 exit;
             end;
             end;
@@ -448,18 +419,12 @@ implementation
 
 
            { left can't be never a 64 bit LOC_REGISTER, so the 3. arg }
            { left can't be never a 64 bit LOC_REGISTER, so the 3. arg }
            { can be false                                             }
            { can be false                                             }
-          {$ifndef newra}
-           maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-          {$endif newra}
            secondpass(right);
            secondpass(right);
            { increment source reference counter, this is
            { increment source reference counter, this is
              useless for string constants}
              useless for string constants}
            if (right.resulttype.def.needs_inittable) and
            if (right.resulttype.def.needs_inittable) and
               (right.nodetype<>stringconstn) then
               (right.nodetype<>stringconstn) then
             cg.g_incrrefcount(exprasmlist,right.resulttype.def,right.location.reference,false);
             cg.g_incrrefcount(exprasmlist,right.resulttype.def,right.location.reference,false);
-          {$ifndef newra}
-           maybe_restore(exprasmlist,left.location,pushedregs);
-          {$endif}
 
 
            if codegenerror then
            if codegenerror then
              exit;
              exit;
@@ -469,11 +434,9 @@ implementation
 
 
         { optimize temp to temp copies }
         { optimize temp to temp copies }
         if (left.nodetype = temprefn) and
         if (left.nodetype = temprefn) and
-{$ifdef newra}
            { we may store certain temps in registers in the future, then this }
            { we may store certain temps in registers in the future, then this }
            { optimization will have to be adapted                             }
            { optimization will have to be adapted                             }
            (left.location.loc = LOC_REFERENCE) and
            (left.location.loc = LOC_REFERENCE) and
-{$endif newra}
            (right.location.loc = LOC_REFERENCE) and
            (right.location.loc = LOC_REFERENCE) and
            tg.istemp(right.location.reference) and
            tg.istemp(right.location.reference) and
            (tg.sizeoftemp(exprasmlist,right.location.reference) = tg.sizeoftemp(exprasmlist,left.location.reference)) then
            (tg.sizeoftemp(exprasmlist,right.location.reference) = tg.sizeoftemp(exprasmlist,left.location.reference)) then
@@ -555,7 +518,7 @@ implementation
                         cgsize:=def_cgsize(left.resulttype.def);
                         cgsize:=def_cgsize(left.resulttype.def);
                         if cgsize in [OS_64,OS_S64] then
                         if cgsize in [OS_64,OS_S64] then
                          cg64.a_load64_ref_reg(exprasmlist,
                          cg64.a_load64_ref_reg(exprasmlist,
-                             right.location.reference,left.location.register64{$ifdef newra},false{$endif})
+                             right.location.reference,left.location.register64,false)
                         else
                         else
                          cg.a_load_ref_reg(exprasmlist,cgsize,cgsize,
                          cg.a_load_ref_reg(exprasmlist,cgsize,cgsize,
                              right.location.reference,left.location.register);
                              right.location.reference,left.location.register);
@@ -624,13 +587,7 @@ implementation
                   { generate the leftnode for the true case, and
                   { generate the leftnode for the true case, and
                     release the location }
                     release the location }
                   cg.a_label(exprasmlist,truelabel);
                   cg.a_label(exprasmlist,truelabel);
-                {$ifndef newra}
-                  maybe_save(exprasmlist,left.registers32,right.location,pushedregs);
-                {$endif newra}
                   secondpass(left);
                   secondpass(left);
-                {$ifndef newra}
-                  maybe_restore(exprasmlist,right.location,pushedregs);
-                {$endif newra}
                   if codegenerror then
                   if codegenerror then
                     exit;
                     exit;
                   cg.a_load_const_loc(exprasmlist,1,left.location);
                   cg.a_load_const_loc(exprasmlist,1,left.location);
@@ -638,16 +595,10 @@ implementation
                   cg.a_jmp_always(exprasmlist,hlabel);
                   cg.a_jmp_always(exprasmlist,hlabel);
                   { generate the leftnode for the false case }
                   { generate the leftnode for the false case }
                   cg.a_label(exprasmlist,falselabel);
                   cg.a_label(exprasmlist,falselabel);
-                {$ifndef newra}
-                  maybe_save(exprasmlist,left.registers32,right.location,pushedregs);
-                {$endif}
                   old_allow_multi_pass2:=allow_multi_pass2;
                   old_allow_multi_pass2:=allow_multi_pass2;
                   allow_multi_pass2:=true;
                   allow_multi_pass2:=true;
                   secondpass(left);
                   secondpass(left);
                   allow_multi_pass2:=old_allow_multi_pass2;
                   allow_multi_pass2:=old_allow_multi_pass2;
-                {$ifndef newra}
-                  maybe_restore(exprasmlist,right.location,pushedregs);
-                {$endif newra}
                   if codegenerror then
                   if codegenerror then
                     exit;
                     exit;
                   cg.a_load_const_loc(exprasmlist,0,left.location);
                   cg.a_load_const_loc(exprasmlist,0,left.location);
@@ -867,18 +818,10 @@ implementation
                     if vaddr then
                     if vaddr then
                      begin
                      begin
                        location_force_mem(exprasmlist,hp.left.location);
                        location_force_mem(exprasmlist,hp.left.location);
-                     {$ifdef newra}
                        tmpreg:=rg.getaddressregister(exprasmlist);
                        tmpreg:=rg.getaddressregister(exprasmlist);
-                     {$else}
-                       tmpreg:=cg.get_scratch_reg_address(exprasmlist);
-                     {$endif}
                        cg.a_loadaddr_ref_reg(exprasmlist,hp.left.location.reference,tmpreg);
                        cg.a_loadaddr_ref_reg(exprasmlist,hp.left.location.reference,tmpreg);
                        cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
                        cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
-                     {$ifdef newra}
                        rg.ungetregisterint(exprasmlist,tmpreg);
                        rg.ungetregisterint(exprasmlist,tmpreg);
-                     {$else}
-                       cg.free_scratch_reg(exprasmlist,tmpreg);
-                     {$endif}
                        location_release(exprasmlist,hp.left.location);
                        location_release(exprasmlist,hp.left.location);
                        if freetemp then
                        if freetemp then
                          location_freetemp(exprasmlist,hp.left.location);
                          location_freetemp(exprasmlist,hp.left.location);
@@ -938,13 +881,22 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.78  2003-09-03 11:18:37  florian
+  Revision 1.79  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.78  2003/09/03 11:18:37  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.77.2.2  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.77.2.1  2003/08/29 17:28:59  peter
+    * next batch of updates
+
   Revision 1.77  2003/08/20 20:13:08  daniel
   Revision 1.77  2003/08/20 20:13:08  daniel
     * Fixed the fixed trouble
     * Fixed the fixed trouble
 
 

+ 16 - 32
compiler/ncgmat.pas

@@ -266,18 +266,11 @@ implementation
          hdenom : tregister;
          hdenom : tregister;
          power : longint;
          power : longint;
          hl : tasmlabel;
          hl : tasmlabel;
-         pushedregs : tmaybesave;
       begin
       begin
          secondpass(left);
          secondpass(left);
          if codegenerror then
          if codegenerror then
           exit;
           exit;
-        {$ifndef newra}
-         maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-        {$endif}
          secondpass(right);
          secondpass(right);
-        {$ifndef newra}
-         maybe_restore(exprasmlist,left.location,pushedregs);
-        {$endif newra}
          if codegenerror then
          if codegenerror then
           exit;
           exit;
          location_copy(location,left.location);
          location_copy(location,left.location);
@@ -362,6 +355,9 @@ implementation
          op : topcg;
          op : topcg;
       begin
       begin
 {$ifdef cpu64bit}
 {$ifdef cpu64bit}
+         freescratch:=false;
+         secondpass(left);
+         secondpass(right);
          { determine operator }
          { determine operator }
          case nodetype of
          case nodetype of
            shln: op:=OP_SHL;
            shln: op:=OP_SHL;
@@ -383,21 +379,6 @@ implementation
            begin
            begin
              { this should be handled in pass_1 }
              { this should be handled in pass_1 }
              internalerror(2002081501);
              internalerror(2002081501);
-
-              if right.location.loc<>LOC_REGISTER then
-                begin
-                  if right.location.loc<>LOC_CREGISTER then
-                   location_release(exprasmlist,right.location);
-                  hcountreg:=cg.get_scratch_reg_int(exprasmlist);
-                  cg.a_load_loc_reg(exprasmlist,right.location.size,right.location,hcountreg);
-                  freescratch := true;
-                end
-              else
-                 hcountreg:=right.location.register;
-              cg64.a_op64_reg_reg(exprasmlist,op,hcountreg,
-                joinreg64(location.registerlow,location.registerhigh));
-              if freescratch then
-                 cg.free_scratch_reg(exprasmlist,hcountreg);
            end;
            end;
 {$else cpu64bit}
 {$else cpu64bit}
          { already hanled in 1st pass }
          { already hanled in 1st pass }
@@ -405,6 +386,7 @@ implementation
 {$endif cpu64bit}
 {$endif cpu64bit}
       end;
       end;
 
 
+
     procedure tcgshlshrnode.second_integer;
     procedure tcgshlshrnode.second_integer;
       var
       var
          freescratch : boolean;
          freescratch : boolean;
@@ -445,27 +427,19 @@ implementation
                 begin
                 begin
                   if right.location.loc<>LOC_CREGISTER then
                   if right.location.loc<>LOC_CREGISTER then
                    location_release(exprasmlist,right.location);
                    location_release(exprasmlist,right.location);
-                {$ifdef newra}
                   hcountreg:=rg.getregisterint(exprasmlist,OS_INT);
                   hcountreg:=rg.getregisterint(exprasmlist,OS_INT);
-                {$else}
-                  hcountreg:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
-                {$endif}
                   freescratch := true;
                   freescratch := true;
                   cg.a_load_loc_reg(exprasmlist,right.location.size,right.location,hcountreg);
                   cg.a_load_loc_reg(exprasmlist,right.location.size,right.location,hcountreg);
                 end
                 end
               else
               else
                 hcountreg:=right.location.register;
                 hcountreg:=right.location.register;
               cg.a_op_reg_reg(exprasmlist,op,OS_INT,hcountreg,location.register);
               cg.a_op_reg_reg(exprasmlist,op,OS_INT,hcountreg,location.register);
-            {$ifdef newra}
               if freescratch then
               if freescratch then
                 rg.ungetregisterint(exprasmlist,hcountreg);
                 rg.ungetregisterint(exprasmlist,hcountreg);
-            {$else}
-              if freescratch then
-                cg.free_scratch_reg(exprasmlist,hcountreg);
-            {$endif}
            end;
            end;
       end;
       end;
 
 
+
     procedure tcgshlshrnode.pass_2;
     procedure tcgshlshrnode.pass_2;
       begin
       begin
          secondpass(left);
          secondpass(left);
@@ -524,13 +498,23 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.16  2003-09-03 11:18:37  florian
+  Revision 1.17  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.16  2003/09/03 11:18:37  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.15.2.2  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.15.2.1  2003/08/31 13:50:15  daniel
+    * Remove sorting and use pregenerated indexes
+    * Some work on making things compile
+
   Revision 1.15  2003/07/02 22:18:04  peter
   Revision 1.15  2003/07/02 22:18:04  peter
     * paraloc splitted in callerparaloc,calleeparaloc
     * paraloc splitted in callerparaloc,calleeparaloc
     * sparc calling convention updates
     * sparc calling convention updates

+ 11 - 86
compiler/ncgmem.pas

@@ -30,7 +30,7 @@ unit ncgmem;
 interface
 interface
 
 
     uses
     uses
-      cpuinfo,cpubase,
+      cginfo,cpuinfo,cpubase,
       node,nmem;
       node,nmem;
 
 
     type
     type
@@ -87,7 +87,7 @@ implementation
       cutils,verbose,globals,
       cutils,verbose,globals,
       symconst,symdef,symsym,symtable,defutil,paramgr,
       symconst,symdef,symsym,symtable,defutil,paramgr,
       aasmbase,aasmtai,
       aasmbase,aasmtai,
-      cginfo,cgbase,pass_2,
+      cgbase,pass_2,
       pass_1,nld,ncon,nadd,
       pass_1,nld,ncon,nadd,
       cgobj,tgobj,rgobj,ncgutil,symbase
       cgobj,tgobj,rgobj,ncgutil,symbase
       ;
       ;
@@ -232,13 +232,9 @@ implementation
           begin
           begin
             cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,paramanager.getintparaloc(exprasmlist,1));
             cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,paramanager.getintparaloc(exprasmlist,1));
             paramanager.freeintparaloc(exprasmlist,1);
             paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
             rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
             rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
             cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER');
             cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER');
-{$ifdef newra}
             rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
             rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
           end;
           end;
       end;
       end;
 
 
@@ -286,13 +282,9 @@ implementation
               begin
               begin
                 cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,paramanager.getintparaloc(exprasmlist,1));
                 cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,paramanager.getintparaloc(exprasmlist,1));
                 paramanager.freeintparaloc(exprasmlist,1);
                 paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
                 rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
                 rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
                 cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER');
                 cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER');
-{$ifdef newra}
                 rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
                 rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               end;
               end;
            end
            end
          else if is_interfacecom(left.resulttype.def) then
          else if is_interfacecom(left.resulttype.def) then
@@ -306,13 +298,9 @@ implementation
               begin
               begin
                 cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,paramanager.getintparaloc(exprasmlist,1));
                 cg.a_param_reg(exprasmlist, OS_ADDR,location.reference.base,paramanager.getintparaloc(exprasmlist,1));
                 paramanager.freeintparaloc(exprasmlist,1);
                 paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
                 rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
                 rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
                 cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER');
                 cg.a_call_name(exprasmlist,'FPC_CHECKPOINTER');
-{$ifdef newra}
                 rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
                 rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               end;
               end;
 
 
            end
            end
@@ -412,12 +400,12 @@ implementation
        var
        var
          hreg: tregister;
          hreg: tregister;
        begin
        begin
-         if location.reference.base.number=NR_NO then
+         if location.reference.base=NR_NO then
           begin
           begin
             cg.a_op_const_reg(exprasmlist,OP_IMUL,OS_ADDR,l,reg);
             cg.a_op_const_reg(exprasmlist,OP_IMUL,OS_ADDR,l,reg);
             location.reference.base:=reg;
             location.reference.base:=reg;
           end
           end
-         else if location.reference.index.number=NR_NO then
+         else if location.reference.index=NR_NO then
           begin
           begin
             cg.a_op_const_reg(exprasmlist,OP_IMUL,OS_ADDR,l,reg);
             cg.a_op_const_reg(exprasmlist,OP_IMUL,OS_ADDR,l,reg);
             location.reference.index:=reg;
             location.reference.index:=reg;
@@ -451,9 +439,6 @@ implementation
          poslabel,
          poslabel,
          neglabel : tasmlabel;
          neglabel : tasmlabel;
          hreg : tregister;
          hreg : tregister;
-      {$ifndef newra}
-         pushed : tpushedsavedint;
-      {$endif}
        begin
        begin
          if is_open_array(left.resulttype.def) or
          if is_open_array(left.resulttype.def) or
             is_array_of_const(left.resulttype.def) then
             is_array_of_const(left.resulttype.def) then
@@ -474,11 +459,7 @@ implementation
                  hreg:=right.location.register
                  hreg:=right.location.register
                else
                else
                  begin
                  begin
-                 {$ifdef newra}
                    hreg:=rg.getregisterint(exprasmlist,OS_INT);
                    hreg:=rg.getregisterint(exprasmlist,OS_INT);
-                 {$else}
-                   hreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
-                 {$endif}
                    freereg:=true;
                    freereg:=true;
                    cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,hreg);
                    cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,hreg);
                  end;
                  end;
@@ -486,13 +467,8 @@ implementation
                objectlibrary.getlabel(poslabel);
                objectlibrary.getlabel(poslabel);
                cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_LT,0,hreg,poslabel);
                cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_LT,0,hreg,poslabel);
                cg.a_cmp_loc_reg_label(exprasmlist,OS_INT,OC_BE,hightree.location,hreg,neglabel);
                cg.a_cmp_loc_reg_label(exprasmlist,OS_INT,OC_BE,hightree.location,hreg,neglabel);
-             {$ifdef newra}
                if freereg then
                if freereg then
                  rg.ungetregisterint(exprasmlist,hreg);
                  rg.ungetregisterint(exprasmlist,hreg);
-             {$else}
-               if freereg then
-                 cg.free_scratch_reg(exprasmlist,hreg);
-             {$endif}
                cg.a_label(exprasmlist,poslabel);
                cg.a_label(exprasmlist,poslabel);
                cg.a_call_name(exprasmlist,'FPC_RANGEERROR');
                cg.a_call_name(exprasmlist,'FPC_RANGEERROR');
                cg.a_label(exprasmlist,neglabel);
                cg.a_label(exprasmlist,neglabel);
@@ -504,24 +480,13 @@ implementation
          else
          else
           if is_dynamic_array(left.resulttype.def) then
           if is_dynamic_array(left.resulttype.def) then
             begin
             begin
-            {$ifndef newra}
-               rg.saveusedintregisters(exprasmlist,pushed,VOLATILE_INTREGISTERS);
-            {$endif}
                cg.a_param_loc(exprasmlist,right.location,paramanager.getintparaloc(exprasmlist,2));
                cg.a_param_loc(exprasmlist,right.location,paramanager.getintparaloc(exprasmlist,2));
                cg.a_param_loc(exprasmlist,left.location,paramanager.getintparaloc(exprasmlist,1));
                cg.a_param_loc(exprasmlist,left.location,paramanager.getintparaloc(exprasmlist,1));
-            {$ifdef newra}
                rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
                rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-            {$else}
-               rg.saveintregvars(exprasmlist,VOLATILE_INTREGISTERS);
-            {$endif}
                cg.a_call_name(exprasmlist,'FPC_DYNARRAY_RANGECHECK');
                cg.a_call_name(exprasmlist,'FPC_DYNARRAY_RANGECHECK');
                paramanager.freeintparaloc(exprasmlist,2);
                paramanager.freeintparaloc(exprasmlist,2);
                paramanager.freeintparaloc(exprasmlist,1);
                paramanager.freeintparaloc(exprasmlist,1);
-            {$ifdef newra}
                rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
                rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-            {$else}
-               rg.restoreusedintregisters(exprasmlist,pushed);
-            {$endif}
             end
             end
          else
          else
            cg.g_rangecheck(exprasmlist,right.location,right.resulttype.def,left.resulttype.def);
            cg.g_rangecheck(exprasmlist,right.location,right.resulttype.def,left.resulttype.def);
@@ -534,15 +499,8 @@ implementation
          extraoffset : longint;
          extraoffset : longint;
          t : tnode;
          t : tnode;
          href : treference;
          href : treference;
-      {$ifdef newra}
-         hreg:Tregister;
-         i:Tsuperregister;
-      {$else}
-         pushed : tpushedsavedint;
-      {$endif}
          otl,ofl : tasmlabel;
          otl,ofl : tasmlabel;
          newsize : tcgsize;
          newsize : tcgsize;
-         pushedregs : tmaybesave;
          mulsize: longint;
          mulsize: longint;
          isjump  : boolean;
          isjump  : boolean;
       begin
       begin
@@ -581,22 +539,11 @@ implementation
                 we can use the ansistring routine here }
                 we can use the ansistring routine here }
               if (cs_check_range in aktlocalswitches) then
               if (cs_check_range in aktlocalswitches) then
                 begin
                 begin
-                {$ifndef newra}
-                   rg.saveusedintregisters(exprasmlist,pushed,VOLATILE_INTREGISTERS);
-                {$endif}
                    cg.a_param_reg(exprasmlist,OS_ADDR,location.reference.base,paramanager.getintparaloc(exprasmlist,1));
                    cg.a_param_reg(exprasmlist,OS_ADDR,location.reference.base,paramanager.getintparaloc(exprasmlist,1));
-                {$ifdef newra}
                    rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
                    rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-                {$else}
-                   rg.saveintregvars(exprasmlist,VOLATILE_INTREGISTERS);
-                {$endif}
                    cg.a_call_name(exprasmlist,'FPC_'+upper(tstringdef(left.resulttype.def).stringtypname)+'_CHECKZERO');
                    cg.a_call_name(exprasmlist,'FPC_'+upper(tstringdef(left.resulttype.def).stringtypname)+'_CHECKZERO');
                    paramanager.freeintparaloc(exprasmlist,1);
                    paramanager.freeintparaloc(exprasmlist,1);
-                {$ifdef newra}
                    rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
                    rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-                {$else}
-                   rg.restoreusedintregisters(exprasmlist,pushed);
-                {$endif}
                 end;
                 end;
 
 
               { in ansistrings/widestrings S[1] is p<w>char(S)[0] !! }
               { in ansistrings/widestrings S[1] is p<w>char(S)[0] !! }
@@ -669,26 +616,15 @@ implementation
                          st_widestring,
                          st_widestring,
                          st_ansistring:
                          st_ansistring:
                            begin
                            begin
-                            {$ifndef newra}
-                              rg.saveusedintregisters(exprasmlist,pushed,VOLATILE_INTREGISTERS);
-                            {$endif}
                               cg.a_param_const(exprasmlist,OS_INT,tordconstnode(right).value,paramanager.getintparaloc(exprasmlist,2));
                               cg.a_param_const(exprasmlist,OS_INT,tordconstnode(right).value,paramanager.getintparaloc(exprasmlist,2));
                               href:=location.reference;
                               href:=location.reference;
                               dec(href.offset,7);
                               dec(href.offset,7);
                               cg.a_param_ref(exprasmlist,OS_INT,href,paramanager.getintparaloc(exprasmlist,1));
                               cg.a_param_ref(exprasmlist,OS_INT,href,paramanager.getintparaloc(exprasmlist,1));
-                            {$ifdef newra}
                               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
                               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-                            {$else}
-                              rg.saveintregvars(exprasmlist,VOLATILE_INTREGISTERS);
-                            {$endif}
                               cg.a_call_name(exprasmlist,'FPC_'+upper(tstringdef(left.resulttype.def).stringtypname)+'_RANGECHECK');
                               cg.a_call_name(exprasmlist,'FPC_'+upper(tstringdef(left.resulttype.def).stringtypname)+'_RANGECHECK');
                               paramanager.freeintparaloc(exprasmlist,2);
                               paramanager.freeintparaloc(exprasmlist,2);
                               paramanager.freeintparaloc(exprasmlist,1);
                               paramanager.freeintparaloc(exprasmlist,1);
-                            {$ifdef newra}
                               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
                               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-                            {$else}
-                              rg.restoreusedintregisters(exprasmlist,pushed);
-                            {$endif}
                            end;
                            end;
 
 
                          st_shortstring:
                          st_shortstring:
@@ -779,13 +715,7 @@ implementation
                  ofl:=falselabel;
                  ofl:=falselabel;
                  objectlibrary.getlabel(falselabel);
                  objectlibrary.getlabel(falselabel);
                end;
                end;
-            {$ifndef newra}
-              maybe_save(exprasmlist,right.registers32,location,pushedregs);
-            {$endif}
               secondpass(right);
               secondpass(right);
-            {$ifndef newra}
-              maybe_restore(exprasmlist,location,pushedregs);
-            {$endif}
 
 
               if cs_check_range in aktlocalswitches then
               if cs_check_range in aktlocalswitches then
                begin
                begin
@@ -816,26 +746,15 @@ implementation
                          st_widestring,
                          st_widestring,
                          st_ansistring:
                          st_ansistring:
                            begin
                            begin
-                            {$ifndef newra}
-                              rg.saveusedintregisters(exprasmlist,pushed,VOLATILE_INTREGISTERS);
-                            {$endif}
                               cg.a_param_reg(exprasmlist,OS_INT,right.location.register,paramanager.getintparaloc(exprasmlist,2));
                               cg.a_param_reg(exprasmlist,OS_INT,right.location.register,paramanager.getintparaloc(exprasmlist,2));
                               href:=location.reference;
                               href:=location.reference;
                               dec(href.offset,7);
                               dec(href.offset,7);
                               cg.a_param_ref(exprasmlist,OS_INT,href,paramanager.getintparaloc(exprasmlist,1));
                               cg.a_param_ref(exprasmlist,OS_INT,href,paramanager.getintparaloc(exprasmlist,1));
-                            {$ifdef newra}
                               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
                               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-                            {$else}
-                              rg.saveintregvars(exprasmlist,VOLATILE_INTREGISTERS);
-                            {$endif}
                               cg.a_call_name(exprasmlist,'FPC_'+upper(tstringdef(left.resulttype.def).stringtypname)+'_RANGECHECK');
                               cg.a_call_name(exprasmlist,'FPC_'+upper(tstringdef(left.resulttype.def).stringtypname)+'_RANGECHECK');
                               paramanager.freeintparaloc(exprasmlist,2);
                               paramanager.freeintparaloc(exprasmlist,2);
                               paramanager.freeintparaloc(exprasmlist,1);
                               paramanager.freeintparaloc(exprasmlist,1);
-                            {$ifdef newra}
                               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
                               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-                            {$else}
-                              rg.restoreusedintregisters(exprasmlist,pushed);
-                            {$endif}
                            end;
                            end;
                          st_shortstring:
                          st_shortstring:
                            begin
                            begin
@@ -868,7 +787,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.69  2003-08-10 17:25:23  peter
+  Revision 1.70  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.69.2.1  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.69  2003/08/10 17:25:23  peter
     * fixed some reported bugs
     * fixed some reported bugs
 
 
   Revision 1.68  2003/08/09 18:56:54  daniel
   Revision 1.68  2003/08/09 18:56:54  daniel

+ 12 - 7
compiler/ncgopt.pas

@@ -107,8 +107,7 @@ begin
     end;
     end;
   secondpass(right);
   secondpass(right);
   { special case for string := string + char (JM) }
   { special case for string := string + char (JM) }
-  hreg.enum:=R_INTREGISTER;
-  hreg.number:=NR_NO;
+  hreg:=NR_NO;
 
 
   { we have to load the char before checking the length, because we }
   { we have to load the char before checking the length, because we }
   { may need registers from the reference                           }
   { may need registers from the reference                           }
@@ -154,8 +153,8 @@ begin
   { we need a new reference to store the character }
   { we need a new reference to store the character }
   { at the end of the string. Check if the base or }
   { at the end of the string. Check if the base or }
   { index register is still free                   }
   { index register is still free                   }
-  if (href2.base.number <> NR_NO) and
-     (href2.index.number <> NR_NO) then
+  if (href2.base <> NR_NO) and
+     (href2.index <> NR_NO) then
     begin
     begin
       { they're not free, so add the base reg to       }
       { they're not free, so add the base reg to       }
       { the string length (since the index can         }
       { the string length (since the index can         }
@@ -165,7 +164,7 @@ begin
     end
     end
   else
   else
     { at least one is still free, so put EDI there }
     { at least one is still free, so put EDI there }
-    if href2.base.number = NR_NO then
+    if href2.base = NR_NO then
       href2.base := lengthreg
       href2.base := lengthreg
     else
     else
       begin
       begin
@@ -186,7 +185,7 @@ begin
     end
     end
   else
   else
     cg.a_load_const_ref(exprasmlist,OS_8,tordconstnode(right).value,href2);
     cg.a_load_const_ref(exprasmlist,OS_8,tordconstnode(right).value,href2);
-  lengthreg.number:=(lengthreg.number and not $ff) or R_SUBL;
+  setsubreg(lengthreg,R_SUBL);
   { increase the string length }
   { increase the string length }
   cg.a_op_const_reg(exprasmlist,OP_ADD,OS_8,1,lengthreg);
   cg.a_op_const_reg(exprasmlist,OP_ADD,OS_8,1,lengthreg);
   cg.a_load_reg_ref(exprasmlist,OS_8,OS_8,lengthreg,left.location.reference);
   cg.a_load_reg_ref(exprasmlist,OS_8,OS_8,lengthreg,left.location.reference);
@@ -202,7 +201,13 @@ end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2003-06-03 21:11:09  peter
+  Revision 1.7  2003-09-03 15:55:00  peter
+    * NEWRA branch merged
+
+  Revision 1.6.2.1  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.6  2003/06/03 21:11:09  peter
     * cg.a_load_* get a from and to size specifier
     * cg.a_load_* get a from and to size specifier
     * makeregsize only accepts newregister
     * makeregsize only accepts newregister
     * i386 uses generic tcgnotnode,tcgunaryminus
     * i386 uses generic tcgnotnode,tcgunaryminus

+ 14 - 86
compiler/ncgset.pas

@@ -97,8 +97,6 @@ implementation
 *****************************************************************************}
 *****************************************************************************}
 
 
     procedure tcgsetelementnode.pass_2;
     procedure tcgsetelementnode.pass_2;
-       var
-         pushedregs : tmaybesave;
        begin
        begin
        { load first value in 32bit register }
        { load first value in 32bit register }
          secondpass(left);
          secondpass(left);
@@ -108,15 +106,9 @@ implementation
        { also a second value ? }
        { also a second value ? }
          if assigned(right) then
          if assigned(right) then
            begin
            begin
-           {$ifndef newra}
-             maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-           {$endif}
              secondpass(right);
              secondpass(right);
              if codegenerror then
              if codegenerror then
                exit;
                exit;
-           {$ifndef newra}
-             maybe_restore(exprasmlist,left.location,pushedregs);
-           {$endif newra}
              if right.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
              if right.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
               location_force_reg(exprasmlist,right.location,OS_32,false);
               location_force_reg(exprasmlist,right.location,OS_32,false);
            end;
            end;
@@ -162,24 +154,16 @@ implementation
          l,l2,l3       : tasmlabel;
          l,l2,l3       : tasmlabel;
          adjustment : longint;
          adjustment : longint;
          href : treference;
          href : treference;
-         r:Tregister;
          hr,hr2,hr3,
          hr,hr2,hr3,
          pleftreg   : tregister;
          pleftreg   : tregister;
          setparts   : array[1..8] of Tsetpart;
          setparts   : array[1..8] of Tsetpart;
-         pushedregs : tmaybesave;
          opsize     : tcgsize;
          opsize     : tcgsize;
          genjumps,
          genjumps,
          use_small,
          use_small,
          ranges     : boolean;
          ranges     : boolean;
          i,numparts : byte;
          i,numparts : byte;
 
 
-{$ifdef oldset}
-         function analizeset(Aset:Pconstset;is_small:boolean):boolean;
-       type
-             byteset=set of byte;
-{$else}
          function analizeset(const Aset:Tconstset;is_small:boolean):boolean;
          function analizeset(const Aset:Tconstset;is_small:boolean):boolean;
-{$endif}
            var
            var
              compares,maxcompares:word;
              compares,maxcompares:word;
              i:byte;
              i:byte;
@@ -200,11 +184,7 @@ implementation
              if is_small then
              if is_small then
               maxcompares:=3;
               maxcompares:=3;
              for i:=0 to 255 do
              for i:=0 to 255 do
-         {$ifdef oldset}
-              if i in byteset(Aset^) then
-         {$else}
               if i in Aset then
               if i in Aset then
-         {$endif}
                begin
                begin
                  if (numparts=0) or (i<>setparts[numparts].stop+1) then
                  if (numparts=0) or (i<>setparts[numparts].stop+1) then
                   begin
                   begin
@@ -252,30 +232,18 @@ implementation
                      (left.resulttype.def.deftype=enumdef) and (tenumdef(left.resulttype.def).max<=32));
                      (left.resulttype.def.deftype=enumdef) and (tenumdef(left.resulttype.def).max<=32));
 
 
          { Can we generate jumps? Possible for all types of sets }
          { Can we generate jumps? Possible for all types of sets }
-{$ifdef oldset}
-         genjumps:=(right.nodetype=setconstn) and
-                   analizeset(Tsetconstnode(right).value_set,use_small);
-{$else}
          genjumps:=(right.nodetype=setconstn) and
          genjumps:=(right.nodetype=setconstn) and
                    analizeset(Tsetconstnode(right).value_set^,use_small);
                    analizeset(Tsetconstnode(right).value_set^,use_small);
-{$endif}
+
          { calculate both operators }
          { calculate both operators }
          { the complex one first }
          { the complex one first }
          firstcomplex(self);
          firstcomplex(self);
          secondpass(left);
          secondpass(left);
          { Only process the right if we are not generating jumps }
          { Only process the right if we are not generating jumps }
          if not genjumps then
          if not genjumps then
-          begin
-          {$ifndef newra}
-            maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-          {$endif}
-            secondpass(right);
-          {$ifndef newra}
-            maybe_restore(exprasmlist,left.location,pushedregs);
-          {$endif}
-          end;
+           secondpass(right);
          if codegenerror then
          if codegenerror then
-          exit;
+           exit;
 
 
          { ofcourse not commutative }
          { ofcourse not commutative }
          if nf_swaped in flags then
          if nf_swaped in flags then
@@ -319,11 +287,7 @@ implementation
              begin
              begin
                { load the value in a register }
                { load the value in a register }
                opsize := OS_INT;
                opsize := OS_INT;
-             {$ifdef newra}
                pleftreg:=rg.getregisterint(exprasmlist,opsize);
                pleftreg:=rg.getregisterint(exprasmlist,opsize);
-             {$else}
-               pleftreg := cg.get_scratch_reg_int(exprasmlist,opsize);
-             {$endif}
                cg.a_load_ref_reg(exprasmlist,def_cgsize(left.resulttype.def),opsize,left.location.reference,pleftreg);
                cg.a_load_ref_reg(exprasmlist,def_cgsize(left.resulttype.def),opsize,left.location.reference,pleftreg);
              end;
              end;
 
 
@@ -332,8 +296,7 @@ implementation
             { how much have we already substracted from the x in the }
             { how much have we already substracted from the x in the }
             { "x in [y..z]" expression                               }
             { "x in [y..z]" expression                               }
             adjustment := 0;
             adjustment := 0;
-            hr.enum:=R_INTREGISTER;
-            hr.number:=NR_NO;
+            hr:=NR_NO;
 
 
             for i:=1 to numparts do
             for i:=1 to numparts do
              if setparts[i].range then
              if setparts[i].range then
@@ -349,13 +312,9 @@ implementation
                       { to edi (not done before because now we can do the  }
                       { to edi (not done before because now we can do the  }
                       { move and substract in one instruction with LEA)    }
                       { move and substract in one instruction with LEA)    }
                       if (left.location.loc = LOC_CREGISTER) and
                       if (left.location.loc = LOC_CREGISTER) and
-                         (hr.enum <> pleftreg.enum) then
+                         (hr<>pleftreg) then
                         begin
                         begin
-                        {$ifdef newra}
                           hr:=rg.getregisterint(exprasmlist,OS_INT);
                           hr:=rg.getregisterint(exprasmlist,OS_INT);
-                        {$else}
-                          hr:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
-                        {$endif}
                           cg.a_op_const_reg_reg(exprasmlist,OP_SUB,opsize,setparts[i].start,pleftreg,hr);
                           cg.a_op_const_reg_reg(exprasmlist,OP_SUB,opsize,setparts[i].start,pleftreg,hr);
                           pleftreg:=hr;
                           pleftreg:=hr;
                           opsize := OS_INT;
                           opsize := OS_INT;
@@ -403,21 +362,13 @@ implementation
              cg.a_label(exprasmlist,l3);
              cg.a_label(exprasmlist,l3);
              case left.location.loc of
              case left.location.loc of
                LOC_CREGISTER :
                LOC_CREGISTER :
-                {$ifdef newra}
                  rg.ungetregisterint(exprasmlist,pleftreg);
                  rg.ungetregisterint(exprasmlist,pleftreg);
-                {$else}
-                 cg.free_scratch_reg(exprasmlist,pleftreg);
-                {$endif}
                LOC_REGISTER :
                LOC_REGISTER :
                  rg.ungetregisterint(exprasmlist,pleftreg);
                  rg.ungetregisterint(exprasmlist,pleftreg);
                else
                else
                  begin
                  begin
                    reference_release(exprasmlist,left.location.reference);
                    reference_release(exprasmlist,left.location.reference);
-                  {$ifdef newra}
                    rg.ungetregisterint(exprasmlist,pleftreg);
                    rg.ungetregisterint(exprasmlist,pleftreg);
-                  {$else}
-                   cg.free_scratch_reg(exprasmlist,pleftreg);
-                  {$endif}
                  end;
                  end;
              end;
              end;
           end
           end
@@ -449,20 +400,12 @@ implementation
                        begin
                        begin
                           hr3:=rg.makeregsize(left.location.register,OS_INT);
                           hr3:=rg.makeregsize(left.location.register,OS_INT);
                           cg.a_load_reg_reg(exprasmlist,left.location.size,OS_INT,left.location.register,hr3);
                           cg.a_load_reg_reg(exprasmlist,left.location.size,OS_INT,left.location.register,hr3);
-                        {$ifdef newra}
                           hr:=rg.getregisterint(exprasmlist,OS_INT);
                           hr:=rg.getregisterint(exprasmlist,OS_INT);
-                        {$else}
-                          hr:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
-                        {$endif}
                           cg.a_load_reg_reg(exprasmlist,OS_INT,OS_INT,hr3,hr);
                           cg.a_load_reg_reg(exprasmlist,OS_INT,OS_INT,hr3,hr);
                        end;
                        end;
                   else
                   else
                     begin
                     begin
-                    {$ifdef newra}
                       hr:=rg.getregisterint(exprasmlist,OS_INT);
                       hr:=rg.getregisterint(exprasmlist,OS_INT);
-                    {$else}
-                      hr:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
-                    {$endif}
                       cg.a_load_ref_reg(exprasmlist,def_cgsize(left.resulttype.def),OS_INT,
                       cg.a_load_ref_reg(exprasmlist,def_cgsize(left.resulttype.def),OS_INT,
                          left.location.reference,hr);
                          left.location.reference,hr);
                       location_release(exprasmlist,left.location);
                       location_release(exprasmlist,left.location);
@@ -475,11 +418,7 @@ implementation
                   { free the resources }
                   { free the resources }
                   rg.ungetregisterint(exprasmlist,right.location.register);
                   rg.ungetregisterint(exprasmlist,right.location.register);
                   { free bitnumber register }
                   { free bitnumber register }
-                {$ifdef newra}
                   rg.ungetregisterint(exprasmlist,hr);
                   rg.ungetregisterint(exprasmlist,hr);
-                {$else}
-                  cg.free_scratch_reg(exprasmlist,hr);
-                {$endif}
                 end;
                 end;
              end
              end
             else
             else
@@ -559,9 +498,9 @@ implementation
                   cg.a_op_const_reg(exprasmlist,OP_SHL,OS_32,2,hr);
                   cg.a_op_const_reg(exprasmlist,OP_SHL,OS_32,2,hr);
 
 
                   href := right.location.reference;
                   href := right.location.reference;
-                  if (href.base.number = NR_NO) then
+                  if (href.base = NR_NO) then
                     href.base := hr
                     href.base := hr
-                  else if (right.location.reference.index.number = NR_NO) then
+                  else if (right.location.reference.index = NR_NO) then
                     href.index := hr
                     href.index := hr
                   else
                   else
                     begin
                     begin
@@ -682,17 +621,9 @@ implementation
            begin
            begin
               last:=0;
               last:=0;
               first:=true;
               first:=true;
-            {$ifdef newra}
               scratch_reg:=rg.getregisterint(exprasmlist,opsize);
               scratch_reg:=rg.getregisterint(exprasmlist,opsize);
-            {$else newra}
-              scratch_reg := cg.get_scratch_reg_int(exprasmlist,opsize);
-            {$endif}
               genitem(hp);
               genitem(hp);
-            {$ifdef newra}
               rg.ungetregisterint(exprasmlist,scratch_reg);
               rg.ungetregisterint(exprasmlist,scratch_reg);
-            {$else}
-              cg.free_scratch_reg(exprasmlist,scratch_reg);
-            {$endif}
               cg.a_jmp_always(exprasmlist,elselabel);
               cg.a_jmp_always(exprasmlist,elselabel);
            end;
            end;
       end;
       end;
@@ -905,9 +836,6 @@ implementation
               jmp_lt:=OC_B;
               jmp_lt:=OC_B;
               jmp_le:=OC_BE;
               jmp_le:=OC_BE;
            end;
            end;
-        {$ifndef newra}
-         rg.cleartempgen;
-        {$endif}
          { save current truelabel and falselabel }
          { save current truelabel and falselabel }
          isjump:=false;
          isjump:=false;
          if left.location.loc=LOC_JUMP then
          if left.location.loc=LOC_JUMP then
@@ -1034,9 +962,6 @@ implementation
          hp:=tstatementnode(right);
          hp:=tstatementnode(right);
          while assigned(hp) do
          while assigned(hp) do
            begin
            begin
-            {$ifndef newra}
-              rg.cleartempgen;
-            {$endif}
               { relabel when inlining }
               { relabel when inlining }
               if inlining_procedure then
               if inlining_procedure then
                 begin
                 begin
@@ -1055,9 +980,6 @@ implementation
          { ...and the else block }
          { ...and the else block }
          if assigned(elseblock) then
          if assigned(elseblock) then
            begin
            begin
-            {$ifndef newra}
-              rg.cleartempgen;
-            {$endif}
               secondpass(elseblock);
               secondpass(elseblock);
               load_all_regvars(exprasmlist);
               load_all_regvars(exprasmlist);
            end;
            end;
@@ -1081,7 +1003,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.47  2003-08-20 20:29:06  daniel
+  Revision 1.48  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.47.2.1  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.47  2003/08/20 20:29:06  daniel
     * Some more R_NO changes
     * Some more R_NO changes
     * Preventive code to loadref added
     * Preventive code to loadref added
 
 

+ 56 - 344
compiler/ncgutil.pas

@@ -40,23 +40,14 @@ interface
     type
     type
       tloadregvars = (lr_dont_load_regvars, lr_load_regvars);
       tloadregvars = (lr_dont_load_regvars, lr_load_regvars);
 
 
-      tmaybesave = record
-        saved : boolean;
-        ref   : treference;
-      end;
-
     procedure firstcomplex(p : tbinarynode);
     procedure firstcomplex(p : tbinarynode);
     procedure maketojumpbool(list:TAAsmoutput; p : tnode; loadregvars: tloadregvars);
     procedure maketojumpbool(list:TAAsmoutput; p : tnode; loadregvars: tloadregvars);
-    procedure remove_non_regvars_from_loc(const t: tlocation; var regs:Tsupregset);
+    procedure remove_non_regvars_from_loc(const t: tlocation; var regs:Tsuperregisterset);
 
 
     procedure location_force_reg(list: TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
     procedure location_force_reg(list: TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
     procedure location_force_fpureg(list: TAAsmoutput;var l: tlocation;maybeconst:boolean);
     procedure location_force_fpureg(list: TAAsmoutput;var l: tlocation;maybeconst:boolean);
     procedure location_force_mem(list: TAAsmoutput;var l:tlocation);
     procedure location_force_mem(list: TAAsmoutput;var l:tlocation);
 
 
-{$ifndef newra}
-    procedure maybe_save(list:taasmoutput;needed:integer;var l:tlocation;var s:tmaybesave);
-    procedure maybe_restore(list:taasmoutput;var l:tlocation;const s:tmaybesave);
-{$endif}
     function  maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
     function  maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
 
 
     procedure push_value_para(list:taasmoutput;p:tnode;calloption:tproccalloption;
     procedure push_value_para(list:taasmoutput;p:tnode;calloption:tproccalloption;
@@ -235,32 +226,24 @@ implementation
       end;
       end;
 
 
 
 
-    procedure remove_non_regvars_from_loc(const t: tlocation; var regs:Tsupregset);
+    procedure remove_non_regvars_from_loc(const t: tlocation; var regs:Tsuperregisterset);
       begin
       begin
         case t.loc of
         case t.loc of
           LOC_REGISTER:
           LOC_REGISTER:
             begin
             begin
               { can't be a regvar, since it would be LOC_CREGISTER then }
               { can't be a regvar, since it would be LOC_CREGISTER then }
-              if t.register.enum<>R_INTREGISTER then
-                internalerror(200301154);
-              if t.registerhigh.enum<>R_INTREGISTER then
-                internalerror(200301154);
-              exclude(regs,t.register.number shr 8);
-              if t.registerhigh.enum <> R_NO then
-                exclude(regs,t.registerhigh.number shr 8);
+              exclude(regs,getsupreg(t.register));
+              if t.registerhigh<>NR_NO then
+                exclude(regs,getsupreg(t.registerhigh));
             end;
             end;
           LOC_CREFERENCE,LOC_REFERENCE:
           LOC_CREFERENCE,LOC_REFERENCE:
             begin
             begin
-              if t.reference.base.enum<>R_INTREGISTER then
-                internalerror(200301154);
-              if t.reference.index.enum<>R_INTREGISTER then
-                internalerror(200301154);
               if not(cs_regvars in aktglobalswitches) or
               if not(cs_regvars in aktglobalswitches) or
-                 ((t.reference.base.number shr 8) in rg.usableregsint) then
-                exclude(regs,t.reference.base.number shr 8);
+                 (getsupreg(t.reference.base) in rg.usableregsint) then
+                exclude(regs,getsupreg(t.reference.base));
               if not(cs_regvars in aktglobalswitches) or
               if not(cs_regvars in aktglobalswitches) or
-                 ((t.reference.index.number shr 8) in rg.usableregsint) then
-                exclude(regs,t.reference.index.number shr 8);
+                 (getsupreg(t.reference.index) in rg.usableregsint) then
+                exclude(regs,getsupreg(t.reference.index));
             end;
             end;
         end;
         end;
       end;
       end;
@@ -272,8 +255,6 @@ implementation
     procedure new_exception(list : taasmoutput;const jmpbuf,envbuf, href : treference;
     procedure new_exception(list : taasmoutput;const jmpbuf,envbuf, href : treference;
       a : aword; exceptlabel : tasmlabel);
       a : aword; exceptlabel : tasmlabel);
 
 
-    var r:Tregister;
-
      begin
      begin
        cg.a_paramaddr_ref(list,envbuf,paramanager.getintparaloc(list,3));
        cg.a_paramaddr_ref(list,envbuf,paramanager.getintparaloc(list,3));
        cg.a_paramaddr_ref(list,jmpbuf,paramanager.getintparaloc(list,2));
        cg.a_paramaddr_ref(list,jmpbuf,paramanager.getintparaloc(list,2));
@@ -282,51 +263,33 @@ implementation
        paramanager.freeintparaloc(list,3);
        paramanager.freeintparaloc(list,3);
        paramanager.freeintparaloc(list,2);
        paramanager.freeintparaloc(list,2);
        paramanager.freeintparaloc(list,1);
        paramanager.freeintparaloc(list,1);
-{$ifdef newra}
        rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
        rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
        cg.a_call_name(list,'FPC_PUSHEXCEPTADDR');
        cg.a_call_name(list,'FPC_PUSHEXCEPTADDR');
-{$ifdef newra}
        rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
        rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
 
 
-       r.enum:=R_INTREGISTER;
-       r.number:=NR_FUNCTION_RESULT_REG;
-       cg.a_param_reg(list,OS_ADDR,r,paramanager.getintparaloc(list,1));
+       cg.a_param_reg(list,OS_ADDR,NR_FUNCTION_RESULT_REG,paramanager.getintparaloc(list,1));
        paramanager.freeintparaloc(list,1);
        paramanager.freeintparaloc(list,1);
-{$ifdef newra}
        rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
        rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
        cg.a_call_name(list,'FPC_SETJMP');
        cg.a_call_name(list,'FPC_SETJMP');
-{$ifdef newra}
        rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
        rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
 
 
        cg.g_exception_reason_save(list, href);
        cg.g_exception_reason_save(list, href);
-       cg.a_cmp_const_reg_label(list,OS_S32,OC_NE,0,r,exceptlabel);
+       cg.a_cmp_const_reg_label(list,OS_S32,OC_NE,0,NR_FUNCTION_RESULT_REG,exceptlabel);
      end;
      end;
 
 
 
 
     procedure free_exception(list : taasmoutput;const jmpbuf, envbuf, href : treference;
     procedure free_exception(list : taasmoutput;const jmpbuf, envbuf, href : treference;
      a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
      a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
 
 
-    var r:Tregister;
-
      begin
      begin
-{$ifdef newra}
          rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
          rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
          cg.a_call_name(list,'FPC_POPADDRSTACK');
          cg.a_call_name(list,'FPC_POPADDRSTACK');
-{$ifdef newra}
          rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
          rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
 
 
          if not onlyfree then
          if not onlyfree then
           begin
           begin
             cg.g_exception_reason_load(list, href);
             cg.g_exception_reason_load(list, href);
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_FUNCTION_RESULT_REG;
-            cg.a_cmp_const_reg_label(list,OS_S32,OC_EQ,a,r,endexceptlabel);
+            cg.a_cmp_const_reg_label(list,OS_S32,OC_EQ,a,NR_FUNCTION_RESULT_REG,endexceptlabel);
           end;
           end;
      end;
      end;
 
 
@@ -352,8 +315,8 @@ implementation
               { load a smaller size to OS_64 }
               { load a smaller size to OS_64 }
               if l.loc=LOC_REGISTER then
               if l.loc=LOC_REGISTER then
                begin
                begin
-                 hregister.enum:=R_INTREGISTER;
-                 hregister.number:=(l.registerlow.number and not $ff) or R_SUBWHOLE;
+                 hregister:=l.registerlow;
+                 setsubreg(hregister,R_SUBWHOLE);
                  cg.a_load_reg_reg(list,l.size,OS_32,l.registerlow,hregister);
                  cg.a_load_reg_reg(list,l.size,OS_32,l.registerlow,hregister);
                end
                end
               else
               else
@@ -416,7 +379,7 @@ implementation
               hreg64.reglo:=hregister;
               hreg64.reglo:=hregister;
               hreg64.reghi:=hregisterhi;
               hreg64.reghi:=hregisterhi;
               { load value in new register }
               { load value in new register }
-              cg64.a_load64_loc_reg(list,l,hreg64{$ifdef newra},false{$endif});
+              cg64.a_load64_loc_reg(list,l,hreg64,false);
               location_reset(l,LOC_REGISTER,dst_size);
               location_reset(l,LOC_REGISTER,dst_size);
               l.registerlow:=hregister;
               l.registerlow:=hregister;
               l.registerhigh:=hregisterhi;
               l.registerhigh:=hregisterhi;
@@ -424,14 +387,12 @@ implementation
          end
          end
         else
         else
          begin
          begin
-         {$ifdef newra}
            { transformations to 32bit or smaller }
            { transformations to 32bit or smaller }
            if (l.loc=LOC_REGISTER) and (l.size in [OS_64,OS_S64]) then
            if (l.loc=LOC_REGISTER) and (l.size in [OS_64,OS_S64]) then
              { if the previous was 64bit release the high register }
              { if the previous was 64bit release the high register }
              begin
              begin
                rg.ungetregisterint(list,l.registerhigh);
                rg.ungetregisterint(list,l.registerhigh);
-               l.registerhigh.enum:=R_INTREGISTER;
-               l.registerhigh.number:=NR_NO;
+               l.registerhigh:=NR_NO;
              end;
              end;
             if l.loc=LOC_REGISTER then
             if l.loc=LOC_REGISTER then
               rg.ungetregisterint(list,l.register);
               rg.ungetregisterint(list,l.register);
@@ -440,49 +401,6 @@ implementation
             and trying to recycle registers can cause problems because
             and trying to recycle registers can cause problems because
             the registers changes size and may need aditional constraints.}
             the registers changes size and may need aditional constraints.}
            hregister:=rg.getregisterint(list,dst_size);
            hregister:=rg.getregisterint(list,dst_size);
-         {$else}
-           { transformations to 32bit or smaller }
-           if l.loc=LOC_REGISTER then
-            begin
-              { if the previous was 64bit release the high register }
-              if l.size in [OS_64,OS_S64] then
-               begin
-                 rg.ungetregisterint(list,l.registerhigh);
-                 l.registerhigh.enum:=R_INTREGISTER;
-                 l.registerhigh.number:=NR_NO;
-               end;
-              hregister:=l.register;
-            end
-           else
-            begin
-              { get new register }
-              if (l.loc=LOC_CREGISTER) and
-                 maybeconst and
-                 (TCGSize2Size[dst_size]=TCGSize2Size[l.size]) then
-               hregister:=l.register
-              else
-               begin
-                 hregister.enum:=R_INTREGISTER;
-                 hregister.number:=NR_NO;
-               end;
-            end;
-           if hregister.enum<>R_INTREGISTER then
-            internalerror(200302022);
-           { need to load into address register? }
-           if (dst_size=OS_ADDR) then
-             begin
-               if (hregister.number=NR_NO) or
-                  (not rg.isaddressregister(hregister)) then
-                 hregister:=rg.getaddressregister(list);
-             end
-           else
-             begin
-               if (hregister.number=NR_NO) {or
-                  rg.isaddressregister(hregister)} then
-                 hregister:=rg.getregisterint(list,dst_size);
-             end;
-           hregister:=rg.makeregsize(hregister,dst_size);
-        {$endif}
            { load value in new register }
            { load value in new register }
            case l.loc of
            case l.loc of
              LOC_FLAGS :
              LOC_FLAGS :
@@ -522,17 +440,6 @@ implementation
                  if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
                  if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
                    l.size:=dst_size;
                    l.size:=dst_size;
 {$endif not i386}
 {$endif not i386}
-{$ifndef newra}
-                 { Release old register when the superregister is changed }
-                 if (l.loc=LOC_REGISTER) and
-                    (l.register.number shr 8<>hregister.number shr 8) then
-                   begin
-                     if rg.isaddressregister(l.register) then
-                       rg.ungetaddressregister(list,l.register)
-                     else
-                       rg.ungetregisterint(list,l.register);
-                   end;
-{$endif}
                end;
                end;
            end;
            end;
            if (l.loc <> LOC_CREGISTER) or
            if (l.loc <> LOC_CREGISTER) or
@@ -651,7 +558,7 @@ implementation
      end;
      end;
 {$endif cpu64bit}
 {$endif cpu64bit}
 
 
-{$ifdef newra}
+
     procedure location_force_reg(list: TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
     procedure location_force_reg(list: TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
 
 
     var oldloc:Tlocation;
     var oldloc:Tlocation;
@@ -666,18 +573,7 @@ implementation
            location_release(list,oldloc);
            location_release(list,oldloc);
          end;
          end;
       end;
       end;
-{$else}
-    procedure location_force_reg(list: TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
-      begin
-        { release previous location before demanding a new register }
-        if (l.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
-         begin
-           location_freetemp(list,l);
-           location_release(list,l);
-         end;
-        location_force(list, l, dst_size, maybeconst)
-      end;
-{$endif}
+
 
 
     procedure location_force_fpureg(list: TAAsmoutput;var l: tlocation;maybeconst:boolean);
     procedure location_force_fpureg(list: TAAsmoutput;var l: tlocation;maybeconst:boolean);
       var
       var
@@ -736,110 +632,6 @@ implementation
                                   Maybe_Save
                                   Maybe_Save
 *****************************************************************************}
 *****************************************************************************}
 
 
-{$ifndef newra}
-    procedure maybe_save(list:taasmoutput;needed:integer;var l:tlocation;var s:tmaybesave);
-      begin
-        s.saved:=false;
-        if l.loc=LOC_CREGISTER then
-         begin
-           s.saved:=true;
-           exit;
-         end;
-        if needed>rg.countunusedregsint then
-         begin
-           case l.loc of
-             LOC_REGISTER :
-               begin
-{$ifndef cpu64bit}
-                 if l.size in [OS_64,OS_S64] then
-                  begin
-                    tg.GetTemp(list,8,tt_normal,s.ref);
-                    cg64.a_load64_reg_ref(list,joinreg64(l.registerlow,l.registerhigh),s.ref);
-                  end
-                 else
-{$endif cpu64bit}
-                  begin
-                    tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,s.ref);
-                    cg.a_load_reg_ref(list,l.size,l.size,l.register,s.ref);
-                  end;
-                 location_release(list,l);
-                 s.saved:=true;
-               end;
-             LOC_REFERENCE,
-             LOC_CREFERENCE :
-               begin
-                 if l.reference.base.enum<>R_INTREGISTER then
-                   internalerror(200302101);
-                 if l.reference.index.enum<>R_INTREGISTER then
-                   internalerror(200302101);
-                 if ((l.reference.base.number<>NR_NO) or
-                     (l.reference.index.number<>NR_NO)) then
-                  begin
-                    { load address into a single base register }
-                    if l.reference.index.number<>NR_NO then
-                     begin
-                       cg.a_loadaddr_ref_reg(list,l.reference,l.reference.index);
-                       rg.ungetregisterint(list,l.reference.base);
-                       reference_reset_base(l.reference,l.reference.index,0);
-                     end
-                    else
-                     begin
-                       cg.a_loadaddr_ref_reg(list,l.reference,l.reference.base);
-                       rg.ungetregisterint(list,l.reference.index);
-                       reference_reset_base(l.reference,l.reference.base,0);
-                     end;
-                    { save base register }
-                    tg.GetTemp(list,TCGSize2Size[OS_ADDR],tt_normal,s.ref);
-                    cg.a_load_reg_ref(list,OS_ADDR,OS_ADDR,l.reference.base,s.ref);
-                    { release }
-                    location_release(list,l);
-                    s.saved:=true;
-                  end;
-               end;
-           end;
-         end;
-      end;
-
-
-    procedure maybe_restore(list:taasmoutput;var l:tlocation;const s:tmaybesave);
-      begin
-        if not s.saved then
-         exit;
-        if l.loc=LOC_CREGISTER then
-         begin
-           load_regvar_reg(list,l.register);
-           exit;
-         end;
-        case l.loc of
-          LOC_REGISTER :
-            begin
-{$ifndef cpu64bit}
-              if l.size in [OS_64,OS_S64] then
-               begin
-                 l.registerlow:=rg.getregisterint(list,OS_INT);
-                 l.registerhigh:=rg.getregisterint(list,OS_INT);
-                 cg64.a_load64_ref_reg(list,s.ref,joinreg64(l.registerlow,l.registerhigh));
-               end
-              else
-{$endif cpu64bit}
-               begin
-                 l.register:=rg.getregisterint(list,OS_INT);
-                 cg.a_load_ref_reg(list,OS_INT,OS_INT,s.ref,l.register);
-               end;
-            end;
-          LOC_CREFERENCE,
-          LOC_REFERENCE :
-            begin
-              reference_reset(l.reference);
-              l.reference.base:=rg.getaddressregister(list);
-              cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,s.ref,l.reference.base);
-            end;
-        end;
-        tg.ungetiftemp(list,s.ref);
-      end;
-{$endif newra}
-
-
     function maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
     function maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
       begin
       begin
         if (needed>=maxfpuregs) and
         if (needed>=maxfpuregs) and
@@ -864,7 +656,6 @@ implementation
         href : treference;
         href : treference;
 {$ifdef i386}
 {$ifdef i386}
         tempreference : treference;
         tempreference : treference;
-        hreg : tregister;
         sizetopush : longint;
         sizetopush : longint;
 {$endif i386}
 {$endif i386}
         size : longint;
         size : longint;
@@ -907,11 +698,8 @@ implementation
                       size:=align(tfloatdef(p.resulttype.def).size,alignment);
                       size:=align(tfloatdef(p.resulttype.def).size,alignment);
                       inc(pushedparasize,size);
                       inc(pushedparasize,size);
                       cg.g_stackpointer_alloc(list,size);
                       cg.g_stackpointer_alloc(list,size);
-                      hreg.enum:=R_INTREGISTER;
-                      hreg.number:=NR_STACK_POINTER_REG;
-                      reference_reset_base(href,hreg,0);
+                      reference_reset_base(href,NR_STACK_POINTER_REG,0);
                       cg.a_loadfpu_reg_ref(list,def_cgsize(p.resulttype.def),p.location.register,href);
                       cg.a_loadfpu_reg_ref(list,def_cgsize(p.resulttype.def),p.location.register,href);
-
                    end;
                    end;
                  LOC_REFERENCE,
                  LOC_REFERENCE,
                  LOC_CREFERENCE :
                  LOC_CREFERENCE :
@@ -968,9 +756,7 @@ implementation
               size:=align(p.resulttype.def.size,alignment);
               size:=align(p.resulttype.def.size,alignment);
               inc(pushedparasize,size);
               inc(pushedparasize,size);
               cg.g_stackpointer_alloc(list,size);
               cg.g_stackpointer_alloc(list,size);
-              hreg.enum:=R_INTREGISTER;
-              hreg.number:=NR_STACK_POINTER_REG;
-              reference_reset_base(href,hreg,0);
+              reference_reset_base(href,NR_STACK_POINTER_REG,0);
               cg.g_concatcopy(list,p.location.reference,href,size,false,false);
               cg.g_concatcopy(list,p.location.reference,href,size,false,false);
 {$else i386}
 {$else i386}
               cg.a_param_copy_ref(list,p.resulttype.def.size,p.location.reference,locpara);
               cg.a_param_copy_ref(list,p.resulttype.def.size,p.location.reference,locpara);
@@ -1060,7 +846,7 @@ implementation
            (tvarsym(p).varspez=vs_value) and
            (tvarsym(p).varspez=vs_value) and
            (paramanager.push_addr_param(tvarsym(p).vartype.def,current_procinfo.procdef.proccalloption)) then
            (paramanager.push_addr_param(tvarsym(p).vartype.def,current_procinfo.procdef.proccalloption)) then
          begin
          begin
-           loadref := (tvarsym(p).reg.enum=R_NO) or ((Tvarsym(p).reg.enum=R_INTREGISTER) and (Tvarsym(p).reg.number=NR_NO));
+           loadref := (tvarsym(p).reg=NR_NO);
            if (loadref) then
            if (loadref) then
              reference_reset_base(href1,current_procinfo.framepointer,tvarsym(p).adjusted_address)
              reference_reset_base(href1,current_procinfo.framepointer,tvarsym(p).adjusted_address)
            else
            else
@@ -1181,19 +967,11 @@ implementation
              vs_out :
              vs_out :
                begin
                begin
                  reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address);
                  reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address);
-               {$ifdef newra}
                  tmpreg:=rg.getaddressregister(list);
                  tmpreg:=rg.getaddressregister(list);
-               {$else}
-                 tmpreg:=cg.get_scratch_reg_address(list);
-               {$endif}
                  cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,tmpreg);
                  cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,tmpreg);
                  reference_reset_base(href,tmpreg,0);
                  reference_reset_base(href,tmpreg,0);
                  cg.g_initialize(list,tvarsym(p).vartype.def,href,false);
                  cg.g_initialize(list,tvarsym(p).vartype.def,href,false);
-               {$ifdef newra}
                  rg.ungetregisterint(list,tmpreg);
                  rg.ungetregisterint(list,tmpreg);
-               {$else}
-                 cg.free_scratch_reg(list,tmpreg);
-               {$endif newra}
                end;
                end;
            end;
            end;
          end;
          end;
@@ -1261,13 +1039,9 @@ implementation
                  reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
                  reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
                  cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(list,1));
                  cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(list,1));
                  paramanager.freeintparaloc(list,1);
                  paramanager.freeintparaloc(list,1);
-{$ifdef newra}
                  rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
                  rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                  cg.a_call_name(list,'FPC_ANSISTR_DECR_REF');
                  cg.a_call_name(list,'FPC_ANSISTR_DECR_REF');
-{$ifdef newra}
                  rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
                  rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                end;
                end;
              tt_widestring,
              tt_widestring,
              tt_freewidestring :
              tt_freewidestring :
@@ -1275,26 +1049,18 @@ implementation
                  reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
                  reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
                  cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(list,1));
                  cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(list,1));
                  paramanager.freeintparaloc(list,1);
                  paramanager.freeintparaloc(list,1);
-{$ifdef newra}
                  rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
                  rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                  cg.a_call_name(list,'FPC_WIDESTR_DECR_REF');
                  cg.a_call_name(list,'FPC_WIDESTR_DECR_REF');
-{$ifdef newra}
                  rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
                  rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                end;
                end;
              tt_interfacecom :
              tt_interfacecom :
                begin
                begin
                  reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
                  reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
                  cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(list,1));
                  cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(list,1));
                  paramanager.freeintparaloc(list,1);
                  paramanager.freeintparaloc(list,1);
-{$ifdef newra}
                  rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
                  rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                  cg.a_call_name(list,'FPC_INTF_DECR_REF');
                  cg.a_call_name(list,'FPC_INTF_DECR_REF');
-{$ifdef newra}
                  rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
                  rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                end;
                end;
            end;
            end;
            hp:=hp^.next;
            hp:=hp^.next;
@@ -1320,7 +1086,7 @@ implementation
                   reference_reset_base(href,current_procinfo.framepointer,tvarsym(current_procinfo.procdef.funcretsym).adjusted_address);
                   reference_reset_base(href,current_procinfo.framepointer,tvarsym(current_procinfo.procdef.funcretsym).adjusted_address);
                   cg.g_initialize(list,current_procinfo.procdef.rettype.def,href,paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption));
                   cg.g_initialize(list,current_procinfo.procdef.rettype.def,href,paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption));
                   { load the pointer to the initialized retvalue in te register }
                   { load the pointer to the initialized retvalue in te register }
-                  if (tvarsym(current_procinfo.procdef.funcretsym).reg.enum <> R_NO) then
+                  if (tvarsym(current_procinfo.procdef.funcretsym).reg<>NR_NO) then
                     cg.a_load_ref_reg(list,OS_ADDR,def_cgsize(current_procinfo.procdef.rettype.def),href,tvarsym(current_procinfo.procdef.funcretsym).reg);
                     cg.a_load_ref_reg(list,OS_ADDR,def_cgsize(current_procinfo.procdef.rettype.def),href,tvarsym(current_procinfo.procdef.funcretsym).reg);
                end;
                end;
           end;
           end;
@@ -1346,28 +1112,20 @@ implementation
         { Constructors need to return self }
         { Constructors need to return self }
         if (current_procinfo.procdef.proctypeoption=potype_constructor) then
         if (current_procinfo.procdef.proctypeoption=potype_constructor) then
           begin
           begin
-{$ifdef newra}
             r:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN_REG);
             r:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN_REG);
-{$else}
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_FUNCTION_RETURN_REG;
-            cg.a_reg_alloc(list,r);
-{$endif}
             { return the self pointer }
             { return the self pointer }
             ressym:=tvarsym(current_procinfo.procdef.parast.search('self'));
             ressym:=tvarsym(current_procinfo.procdef.parast.search('self'));
             if not assigned(ressym) then
             if not assigned(ressym) then
               internalerror(200305058);
               internalerror(200305058);
             reference_reset_base(href,current_procinfo.framepointer,tvarsym(ressym).adjusted_address);
             reference_reset_base(href,current_procinfo.framepointer,tvarsym(ressym).adjusted_address);
-{$ifdef newra}
             rg.ungetregisterint(list,r);
             rg.ungetregisterint(list,r);
-{$endif newra}
             cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,r);
             cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,r);
             uses_acc:=true;
             uses_acc:=true;
             exit;
             exit;
           end;
           end;
 
 
         ressym := tvarsym(current_procinfo.procdef.funcretsym);
         ressym := tvarsym(current_procinfo.procdef.funcretsym);
-        if ressym.reg.enum <> R_NO then
+        if ressym.reg<>NR_NO then
           begin
           begin
             if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
             if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
               location_reset(resloc,LOC_CREGISTER,OS_ADDR)
               location_reset(resloc,LOC_CREGISTER,OS_ADDR)
@@ -1395,37 +1153,18 @@ implementation
               if resloc.size in [OS_64,OS_S64] then
               if resloc.size in [OS_64,OS_S64] then
                begin
                begin
                  uses_acchi:=true;
                  uses_acchi:=true;
-{$ifdef newra}
                  r:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN64_LOW_REG);
                  r:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN64_LOW_REG);
                  r2:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN64_HIGH_REG);
                  r2:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN64_HIGH_REG);
-{$else}
-                 r.enum:=R_INTREGISTER;
-                 r.number:=NR_FUNCTION_RETURN64_LOW_REG;
-                 cg.a_reg_alloc(list,r);
-                 r2.enum:=R_INTREGISTER;
-                 r2.number:=NR_FUNCTION_RETURN64_HIGH_REG;
-                 cg.a_reg_alloc(list,r2);
-{$endif}
-{$ifdef newra}
                  rg.ungetregisterint(list,r);
                  rg.ungetregisterint(list,r);
                  rg.ungetregisterint(list,r2);
                  rg.ungetregisterint(list,r2);
-{$endif newra}
-                 cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2){$ifdef newra},false{$endif});
+                 cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2),false);
                end
                end
               else
               else
 {$endif cpu64bit}
 {$endif cpu64bit}
                begin
                begin
-{$ifdef newra}
                  hreg:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN_REG);
                  hreg:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN_REG);
-{$else}
-                 hreg.enum:=R_INTREGISTER;
-                 hreg.number:=NR_FUNCTION_RETURN_REG;
-                 cg.a_reg_alloc(list,hreg);
-{$endif}
                  hreg:=rg.makeregsize(hreg,resloc.size);
                  hreg:=rg.makeregsize(hreg,resloc.size);
-{$ifdef newra}
                  rg.ungetregisterint(list,hreg);
                  rg.ungetregisterint(list,hreg);
-{$endif newra}
                  cg.a_load_loc_reg(list,resloc.size,resloc,hreg);
                  cg.a_load_loc_reg(list,resloc.size,resloc,hreg);
                end;
                end;
             end;
             end;
@@ -1433,11 +1172,11 @@ implementation
             begin
             begin
               uses_fpu := true;
               uses_fpu := true;
 {$ifdef cpufpemu}
 {$ifdef cpufpemu}
-               if cs_fp_emulation in aktmoduleswitches then
-                 r.enum := FUNCTION_RETURN_REG
+              if cs_fp_emulation in aktmoduleswitches then
+                r:=NR_FUNCTION_RETURN_REG
               else
               else
 {$endif cpufpemu}
 {$endif cpufpemu}
-               r.enum:=FPU_RESULT_REG;
+                r:=NR_FPU_RESULT_REG;
               cg.a_loadfpu_loc_reg(list,resloc,r);
               cg.a_loadfpu_loc_reg(list,resloc,r);
             end;
             end;
           else
           else
@@ -1450,37 +1189,18 @@ implementation
                  if resloc.size in [OS_64,OS_S64] then
                  if resloc.size in [OS_64,OS_S64] then
                   begin
                   begin
                     uses_acchi:=true;
                     uses_acchi:=true;
-{$ifdef newra}
                     r:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN64_LOW_REG);
                     r:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN64_LOW_REG);
                     r2:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN64_HIGH_REG);
                     r2:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN64_HIGH_REG);
-{$else}
-                    r.enum:=R_INTREGISTER;
-                    r.number:=NR_FUNCTION_RETURN64_LOW_REG;
-                    cg.a_reg_alloc(list,r);
-                    r2.enum:=R_INTREGISTER;
-                    r2.number:=NR_FUNCTION_RETURN64_HIGH_REG;
-                    cg.a_reg_alloc(list,r2);
-{$endif}
-{$ifdef newra}
                     rg.ungetregisterint(list,r);
                     rg.ungetregisterint(list,r);
                     rg.ungetregisterint(list,r2);
                     rg.ungetregisterint(list,r2);
-{$endif newra}
-                    cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2){$ifdef newra},false{$endif});
+                    cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2),false);
                   end
                   end
                  else
                  else
 {$endif cpu64bit}
 {$endif cpu64bit}
                   begin
                   begin
-{$ifdef newra}
                     hreg:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN_REG);
                     hreg:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN_REG);
-{$else}
-                    hreg.enum:=R_INTREGISTER;
-                    hreg.number:=NR_FUNCTION_RETURN_REG;
-                    cg.a_reg_alloc(list,hreg);
-{$endif}
                     hreg:=rg.makeregsize(hreg,resloc.size);
                     hreg:=rg.makeregsize(hreg,resloc.size);
-{$ifdef newra}
                     rg.ungetregisterint(list,hreg);
                     rg.ungetregisterint(list,hreg);
-{$endif newra}
                     cg.a_load_loc_reg(list,resloc.size,resloc,hreg);
                     cg.a_load_loc_reg(list,resloc.size,resloc,hreg);
                   end;
                   end;
                 end
                 end
@@ -1558,23 +1278,15 @@ implementation
                  cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(list,1));
                  cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(list,1));
                  paramanager.freeintparaloc(list,2);
                  paramanager.freeintparaloc(list,2);
                  paramanager.freeintparaloc(list,1);
                  paramanager.freeintparaloc(list,1);
-{$ifdef newra}
                  rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
                  rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                  cg.a_call_name(list,'_monstartup');
                  cg.a_call_name(list,'_monstartup');
-{$ifdef newra}
                  rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
                  rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                end;
                end;
 
 
               { initialize units }
               { initialize units }
-{$ifdef newra}
               rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
               rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(list,'FPC_INITIALIZEUNITS');
               cg.a_call_name(list,'FPC_INITIALIZEUNITS');
-{$ifdef newra}
               rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
               rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             end;
             end;
 
 
 {$ifdef GDB}
 {$ifdef GDB}
@@ -1683,7 +1395,7 @@ implementation
 {$ifndef powerpc}
 {$ifndef powerpc}
         { at least for the ppc this applies always, so this code isn't usable (FK) }
         { at least for the ppc this applies always, so this code isn't usable (FK) }
         { omit stack frame ? }
         { omit stack frame ? }
-        if (current_procinfo.framepointer.number=NR_STACK_POINTER_REG) then
+        if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
           begin
           begin
             CGmessage(cg_d_stackframe_omited);
             CGmessage(cg_d_stackframe_omited);
             if stackframe<>0 then
             if stackframe<>0 then
@@ -1709,10 +1421,7 @@ implementation
       var
       var
         href : treference;
         href : treference;
         hp : tparaitem;
         hp : tparaitem;
-        rsp : tregister;
-{$ifdef newra}
         gotregvarparas: boolean;
         gotregvarparas: boolean;
-{$endif newra}
       begin
       begin
         { the actual stack allocation code, symbol entry point and
         { the actual stack allocation code, symbol entry point and
           gdb stabs information is generated AFTER the rest of this
           gdb stabs information is generated AFTER the rest of this
@@ -1729,45 +1438,37 @@ implementation
             { we do this before init_paras because that one calls routines which may overwrite these  }
             { we do this before init_paras because that one calls routines which may overwrite these  }
             { registers and it also expects the values to be in memory                                }
             { registers and it also expects the values to be in memory                                }
             hp:=tparaitem(current_procinfo.procdef.para.first);
             hp:=tparaitem(current_procinfo.procdef.para.first);
-{$ifdef newra}
             gotregvarparas := false;
             gotregvarparas := false;
-{$endif newra}
             while assigned(hp) do
             while assigned(hp) do
               begin
               begin
-                if Tvarsym(hp.parasym).reg.enum>R_INTREGISTER then
-                  internalerror(200301081);
-                if (tvarsym(hp.parasym).reg.enum<>R_NO) then
+                if (tvarsym(hp.parasym).reg<>NR_NO) then
                   begin
                   begin
-{$ifdef newra}
                     gotregvarparas := true;
                     gotregvarparas := true;
                     { cg.a_load_param_reg will first allocate and then deallocate paraloc }
                     { cg.a_load_param_reg will first allocate and then deallocate paraloc }
                     { register (if the parameter resides in a register) and then allocate }
                     { register (if the parameter resides in a register) and then allocate }
                     { the regvar (which is currently not allocated)                       }
                     { the regvar (which is currently not allocated)                       }
-{$endif newra}
                     cg.a_load_param_reg(list,hp.paraloc[calleeside],tvarsym(hp.parasym).reg);
                     cg.a_load_param_reg(list,hp.paraloc[calleeside],tvarsym(hp.parasym).reg);
                   end
                   end
                 else if (hp.paraloc[calleeside].loc in [LOC_REGISTER,LOC_FPUREGISTER,LOC_MMREGISTER,
                 else if (hp.paraloc[calleeside].loc in [LOC_REGISTER,LOC_FPUREGISTER,LOC_MMREGISTER,
                                             LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMREGISTER]) and
                                             LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMREGISTER]) and
-                        (tvarsym(hp.parasym).reg.enum=R_NO) then
+                        (tvarsym(hp.parasym).reg=NR_NO) then
                   begin
                   begin
                     reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
                     reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
                     cg.a_load_param_ref(list,hp.paraloc[calleeside],href);
                     cg.a_load_param_ref(list,hp.paraloc[calleeside],href);
                   end;
                   end;
                 hp:=tparaitem(hp.next);
                 hp:=tparaitem(hp.next);
               end;
               end;
-{$ifdef newra}
             if gotregvarparas then
             if gotregvarparas then
               begin
               begin
                 { deallocate all register variables again }
                 { deallocate all register variables again }
                 hp:=tparaitem(current_procinfo.procdef.para.first);
                 hp:=tparaitem(current_procinfo.procdef.para.first);
                 while assigned(hp) do
                 while assigned(hp) do
                   begin
                   begin
-                    if (tvarsym(hp.parasym).reg.enum<>R_NO) then
+                    if (tvarsym(hp.parasym).reg<>NR_NO) then
                       rg.ungetregisterint(list,tvarsym(hp.parasym).reg);
                       rg.ungetregisterint(list,tvarsym(hp.parasym).reg);
                     hp:=tparaitem(hp.next);
                     hp:=tparaitem(hp.next);
                   end;
                   end;
               end;
               end;
-{$endif newra}
           end;
           end;
 
 
         { for the save all registers we can simply use a pusha,popa which
         { for the save all registers we can simply use a pusha,popa which
@@ -1781,14 +1482,12 @@ implementation
 
 
         { Save stackpointer value }
         { Save stackpointer value }
         if not inlined and
         if not inlined and
-           (current_procinfo.framepointer.number<>NR_STACK_POINTER_REG) and
+           (current_procinfo.framepointer<>NR_STACK_POINTER_REG) and
            ((po_savestdregs in current_procinfo.procdef.procoptions) or
            ((po_savestdregs in current_procinfo.procdef.procoptions) or
             (po_saveregisters in current_procinfo.procdef.procoptions)) then
             (po_saveregisters in current_procinfo.procdef.procoptions)) then
          begin
          begin
            tg.GetTemp(list,POINTER_SIZE,tt_noreuse,current_procinfo.save_stackptr_ref);
            tg.GetTemp(list,POINTER_SIZE,tt_noreuse,current_procinfo.save_stackptr_ref);
-           rsp.enum:=R_INTREGISTER;
-           rsp.number:=NR_STACK_POINTER_REG;
-           cg.a_load_reg_ref(list,OS_ADDR,OS_ADDR,rsp,current_procinfo.save_stackptr_ref);
+           cg.a_load_reg_ref(list,OS_ADDR,OS_ADDR,NR_STACK_POINTER_REG,current_procinfo.save_stackptr_ref);
          end;
          end;
       end;
       end;
 
 
@@ -1800,7 +1499,6 @@ implementation
         mangled_length : longint;
         mangled_length : longint;
         p : pchar;
         p : pchar;
 {$endif GDB}
 {$endif GDB}
-        rsp : Tregister;
         stacksize,
         stacksize,
         retsize : longint;
         retsize : longint;
       begin
       begin
@@ -1815,13 +1513,11 @@ implementation
 
 
         { Restore stackpointer if it was saved }
         { Restore stackpointer if it was saved }
         if not inlined and
         if not inlined and
-           (current_procinfo.framepointer.number<>NR_STACK_POINTER_REG) and
+           (current_procinfo.framepointer<>NR_STACK_POINTER_REG) and
            ((po_savestdregs in current_procinfo.procdef.procoptions) or
            ((po_savestdregs in current_procinfo.procdef.procoptions) or
             (po_saveregisters in current_procinfo.procdef.procoptions)) then
             (po_saveregisters in current_procinfo.procdef.procoptions)) then
          begin
          begin
-           rsp.enum:=R_INTREGISTER;
-           rsp.number:=NR_STACK_POINTER_REG;
-           cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,current_procinfo.save_stackptr_ref,rsp);
+           cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,current_procinfo.save_stackptr_ref,NR_STACK_POINTER_REG);
            tg.UngetTemp(list,current_procinfo.save_stackptr_ref);
            tg.UngetTemp(list,current_procinfo.save_stackptr_ref);
          end;
          end;
 
 
@@ -1838,7 +1534,7 @@ implementation
         { remove stackframe }
         { remove stackframe }
         if not inlined then
         if not inlined then
          begin
          begin
-           if (current_procinfo.framepointer.number=NR_STACK_POINTER_REG) then
+           if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
             begin
             begin
               stacksize:=current_procinfo.calc_stackframe_size;
               stacksize:=current_procinfo.calc_stackframe_size;
               if (stacksize<>0) then
               if (stacksize<>0) then
@@ -1978,7 +1674,7 @@ implementation
                   begin
                   begin
                     r:=rg.getregisterint(list,OS_INT);
                     r:=rg.getregisterint(list,OS_INT);
                     r2:=rg.getregisterint(list,OS_INT);
                     r2:=rg.getregisterint(list,OS_INT);
-                    cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2){$ifdef newra},false{$endif});
+                    cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2),false);
                   end
                   end
                  else
                  else
 {$endif cpu64bit}
 {$endif cpu64bit}
@@ -2007,7 +1703,7 @@ implementation
                      begin
                      begin
                        r:=rg.getregisterint(list,OS_INT);
                        r:=rg.getregisterint(list,OS_INT);
                        r2:=rg.getregisterint(list,OS_INT);
                        r2:=rg.getregisterint(list,OS_INT);
-                       cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2){$ifdef newra},false{$endif});
+                       cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2),false);
                      end
                      end
                     else
                     else
 {$endif cpu64bit}
 {$endif cpu64bit}
@@ -2083,13 +1779,29 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.138  2003-09-03 11:18:37  florian
+  Revision 1.139  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.138  2003/09/03 11:18:37  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.137.2.4  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.137.2.3  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.137.2.2  2003/08/28 18:35:08  peter
+    * tregister changed to cardinal
+
+  Revision 1.137.2.1  2003/08/27 19:55:54  peter
+    * first tregister patch
+
+>>>>>>> 1.137.2.4
   Revision 1.137  2003/08/20 20:29:06  daniel
   Revision 1.137  2003/08/20 20:29:06  daniel
     * Some more R_NO changes
     * Some more R_NO changes
     * Preventive code to loadref added
     * Preventive code to loadref added

+ 4 - 21
compiler/ncnv.pas

@@ -279,12 +279,6 @@ implementation
         end;
         end;
 
 
         procedure do_set(pos : longint);
         procedure do_set(pos : longint);
-
-  {$ifdef oldset}
-        var
-          mask,l : longint;
-  {$endif}
-
         begin
         begin
           if (pos and not $ff)<>0 then
           if (pos and not $ff)<>0 then
            Message(parser_e_illegal_set_expr);
            Message(parser_e_illegal_set_expr);
@@ -292,19 +286,9 @@ implementation
            constsethi:=pos;
            constsethi:=pos;
           if pos<constsetlo then
           if pos<constsetlo then
            constsetlo:=pos;
            constsetlo:=pos;
-  {$ifdef oldset}
-          { to do this correctly we use the 32bit array }
-          l:=pos shr 5;
-          mask:=1 shl (pos mod 32);
-          { do we allow the same twice }
-          if (pconst32bitset(constset)^[l] and mask)<>0 then
-           Message(parser_e_illegal_set_expr);
-          pconst32bitset(constset)^[l]:=pconst32bitset(constset)^[l] or mask;
-  {$else}
           if pos in constset^ then
           if pos in constset^ then
             Message(parser_e_illegal_set_expr);
             Message(parser_e_illegal_set_expr);
           include(constset^,pos);
           include(constset^,pos);
-  {$endif}
         end;
         end;
 
 
       var
       var
@@ -315,11 +299,7 @@ implementation
         if p.nodetype<>arrayconstructorn then
         if p.nodetype<>arrayconstructorn then
           internalerror(200205105);
           internalerror(200205105);
         new(constset);
         new(constset);
-      {$ifdef oldset}
-        FillChar(constset^,sizeof(constset^),0);
-      {$else}
         constset^:=[];
         constset^:=[];
-      {$endif}
         htype.reset;
         htype.reset;
         constsetlo:=0;
         constsetlo:=0;
         constsethi:=0;
         constsethi:=0;
@@ -2113,7 +2093,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.116  2003-08-10 17:25:23  peter
+  Revision 1.117  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.116  2003/08/10 17:25:23  peter
     * fixed some reported bugs
     * fixed some reported bugs
 
 
   Revision 1.115  2003/06/05 20:05:55  peter
   Revision 1.115  2003/06/05 20:05:55  peter

+ 9 - 42
compiler/ncon.pas

@@ -279,28 +279,11 @@ implementation
          str_length:=tstringconstnode(p).len;
          str_length:=tstringconstnode(p).len;
       end;
       end;
 
 
-{$ifdef oldset}
     function is_emptyset(p : tnode):boolean;
     function is_emptyset(p : tnode):boolean;
-
-      var
-        i : longint;
       begin
       begin
-        i:=0;
-        if p.nodetype=setconstn then
-         begin
-           while (i<32) and (tsetconstnode(p).value_set^[i]=0) do
-            inc(i);
-         end;
-        is_emptyset:=(i=32);
-      end;
-{$else}
-    function is_emptyset(p : tnode):boolean;
-
-    begin
         is_emptyset:=(p.nodetype=setconstn) and
         is_emptyset:=(p.nodetype=setconstn) and
-         (Tsetconstnode(p).value_set^=[]);
-    end;
-{$endif}
+                     (Tsetconstnode(p).value_set^=[]);
+      end;
 
 
 
 
     function genconstsymtree(p : tconstsym) : tnode;
     function genconstsymtree(p : tconstsym) : tnode;
@@ -822,32 +805,13 @@ implementation
           expectloc:=LOC_CREFERENCE;
           expectloc:=LOC_CREFERENCE;
       end;
       end;
 
 
-{$ifdef oldset}
+
     function tsetconstnode.docompare(p: tnode): boolean;
     function tsetconstnode.docompare(p: tnode): boolean;
-      var
-        i: 0..31;
       begin
       begin
-        if inherited docompare(p) then
-          begin
-            for i := 0 to 31 do
-              if (value_set^[i] <> tsetconstnode(p).value_set^[i]) then
-                begin
-                  docompare := false;
-                  exit
-                end;
-            docompare := true;
-          end
-        else
-          docompare := false;
+        docompare:=(inherited docompare(p)) and
+                   (value_set^=Tsetconstnode(p).value_set^);
       end;
       end;
-{$else}
-    function tsetconstnode.docompare(p: tnode): boolean;
 
 
-    begin
-        docompare:=(inherited docompare(p))
-         and (value_set^=Tsetconstnode(p).value_set^);
-    end;
-{$endif}
 
 
 {*****************************************************************************
 {*****************************************************************************
                                TNILNODE
                                TNILNODE
@@ -938,7 +902,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.49  2003-04-25 20:59:33  peter
+  Revision 1.50  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.49  2003/04/25 20:59:33  peter
     * removed funcretn,funcretsym, function result is now in varsym
     * removed funcretn,funcretsym, function result is now in varsym
       and aliases for result and function name are added using absolutesym
       and aliases for result and function name are added using absolutesym
     * vs_hidden parameter for funcret passed in parameter
     * vs_hidden parameter for funcret passed in parameter

+ 4 - 7
compiler/node.pas

@@ -35,13 +35,7 @@ interface
 
 
     type
     type
        pconstset = ^tconstset;
        pconstset = ^tconstset;
-{$ifdef oldset}
-       tconstset = array[0..31] of byte;
-       pconst32bitset = ^tconst32bitset;
-       tconst32bitset = array[0..7] of longint;
-{$else}
        tconstset = set of 0..255;
        tconstset = set of 0..255;
-{$endif}
 
 
        tnodetype = (
        tnodetype = (
           emptynode,        {No node (returns nil when loading from ppu)}
           emptynode,        {No node (returns nil when loading from ppu)}
@@ -981,7 +975,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.64  2003-09-03 11:18:37  florian
+  Revision 1.65  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.64  2003/09/03 11:18:37  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around

+ 7 - 25
compiler/nset.pas

@@ -182,10 +182,6 @@ implementation
 
 
     function tinnode.det_resulttype:tnode;
     function tinnode.det_resulttype:tnode;
 
 
-{$ifdef oldset}
-      type
-        byteset = set of byte;
-{$endif}
       var
       var
         t : tnode;
         t : tnode;
         pst : pconstset;
         pst : pconstset;
@@ -203,22 +199,14 @@ implementation
                 pes:=tenumsym(tenumdef(psd.elementtype.def).firstenum);
                 pes:=tenumsym(tenumdef(psd.elementtype.def).firstenum);
                 while assigned(pes) do
                 while assigned(pes) do
                   begin
                   begin
-                {$ifdef oldset}
-                    pcs^[pes.value div 8]:=pcs^[pes.value div 8] or (1 shl (pes.value mod 8));
-                {$else}
                     include(pcs^,pes.value);
                     include(pcs^,pes.value);
-                {$endif}
                     pes:=pes.nextenum;
                     pes:=pes.nextenum;
                   end;
                   end;
               end;
               end;
             orddef :
             orddef :
               begin
               begin
                 for i:=torddef(psd.elementtype.def).low to torddef(psd.elementtype.def).high do
                 for i:=torddef(psd.elementtype.def).low to torddef(psd.elementtype.def).high do
-                {$ifdef oldset}
-                    pcs^[i div 8]:=pcs^[i div 8] or (1 shl (i mod 8));
-                {$else}
-                    include(pcs^,i);
-                {$endif}
+                  include(pcs^,i);
               end;
               end;
           end;
           end;
           createsetconst:=pcs;
           createsetconst:=pcs;
@@ -285,11 +273,7 @@ implementation
          { empty set then return false }
          { empty set then return false }
          if not assigned(tsetdef(right.resulttype.def).elementtype.def) or
          if not assigned(tsetdef(right.resulttype.def).elementtype.def) or
             ((right.nodetype = setconstn) and
             ((right.nodetype = setconstn) and
-{$ifdef oldset}
-             (byteset(tsetconstnode(right).value_set^) = [])) then
-{$else oldset}
-             (tsetconstnode(right).value_set^ = [])) then
-{$endif oldset}
+             (tnormalset(tsetconstnode(right).value_set^) = [])) then
           begin
           begin
             t:=cordconstnode.create(0,booltype,false);
             t:=cordconstnode.create(0,booltype,false);
             resulttypepass(t);
             resulttypepass(t);
@@ -300,13 +284,8 @@ implementation
          { constant evaluation }
          { constant evaluation }
          if (left.nodetype=ordconstn) and (right.nodetype=setconstn) then
          if (left.nodetype=ordconstn) and (right.nodetype=setconstn) then
           begin
           begin
-        {$ifdef oldset}
-            t:=cordconstnode.create(byte(tordconstnode(left).value in byteset(tsetconstnode(right).value_set^)),
-              booltype,true);
-        {$else}
             t:=cordconstnode.create(byte(tordconstnode(left).value in Tsetconstnode(right).value_set^),
             t:=cordconstnode.create(byte(tordconstnode(left).value in Tsetconstnode(right).value_set^),
-              booltype,true);
-        {$endif}
+               booltype,true);
             resulttypepass(t);
             resulttypepass(t);
             result:=t;
             result:=t;
             exit;
             exit;
@@ -707,7 +686,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.43  2003-06-12 22:09:54  jonas
+  Revision 1.44  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.43  2003/06/12 22:09:54  jonas
     * tcginnode.pass_2 doesn't call a helper anymore in any case
     * tcginnode.pass_2 doesn't call a helper anymore in any case
     * fixed ungetregisterfpu compilation problems
     * fixed ungetregisterfpu compilation problems
 
 

+ 21 - 4
compiler/options.pas

@@ -876,10 +876,8 @@ begin
                      initglobalswitches:=initglobalswitches-[cs_link_on_target]
                      initglobalswitches:=initglobalswitches-[cs_link_on_target]
                    else if more='t' then
                    else if more='t' then
                      initglobalswitches:=initglobalswitches+[cs_link_on_target]
                      initglobalswitches:=initglobalswitches+[cs_link_on_target]
-{$ifdef newra}
                    else if more='r' then
                    else if more='r' then
-                     initglobalswitches:=initglobalswitches+[cs_no_regalloc]
-{$endif newra}
+                     initglobalswitches:=initglobalswitches+[cs_asm_leave,cs_no_regalloc]
                    else if more<>'' then
                    else if more<>'' then
                      IllegalPara(opt);
                      IllegalPara(opt);
                  end;
                  end;
@@ -1716,6 +1714,9 @@ begin
   def_symbol('CPUSPARC');
   def_symbol('CPUSPARC');
   def_symbol('CPUSPARC32');
   def_symbol('CPUSPARC32');
   def_symbol('CPU32');
   def_symbol('CPU32');
+  def_symbol('FPC_HAS_TYPE_DOUBLE');
+  def_symbol('FPC_HAS_TYPE_SINGLE');
+  def_symbol('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
 {$endif}
 {$endif}
 {$ifdef vis}
 {$ifdef vis}
   def_symbol('CPUVIS');
   def_symbol('CPUVIS');
@@ -1952,13 +1953,29 @@ finalization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.100  2003-09-03 11:18:37  florian
+  Revision 1.101  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.100  2003/09/03 11:18:37  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.99.2.4  2003/09/02 17:48:42  peter
+    * sparc need software int64 to double
+
+  Revision 1.99.2.3  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.99.2.2  2003/08/31 16:18:05  peter
+    * more fixes
+
+  Revision 1.99.2.1  2003/08/31 13:50:15  daniel
+    * Remove sorting and use pregenerated indexes
+    * Some work on making things compile
+
   Revision 1.99  2003/05/13 19:14:41  peter
   Revision 1.99  2003/05/13 19:14:41  peter
     * failn removed
     * failn removed
     * inherited result code check moven to pexpr
     * inherited result code check moven to pexpr

+ 11 - 5
compiler/paramgr.pas

@@ -254,15 +254,15 @@ implementation
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
               if (loc.size in [OS_64,OS_S64,OS_F64]) then
               if (loc.size in [OS_64,OS_S64,OS_F64]) then
                 begin
                 begin
-                  rg.getexplicitregisterint(list,loc.registerhigh.number);
-                  rg.getexplicitregisterint(list,loc.registerlow.number);
+                  rg.getexplicitregisterint(list,loc.registerhigh);
+                  rg.getexplicitregisterint(list,loc.registerlow);
                 end
                 end
               else
               else
 {$endif cpu64bit}
 {$endif cpu64bit}
-                rg.getexplicitregisterint(list,loc.register.number);
+                rg.getexplicitregisterint(list,loc.register);
             end;
             end;
           LOC_FPUREGISTER, LOC_CFPUREGISTER:
           LOC_FPUREGISTER, LOC_CFPUREGISTER:
-            rg.getexplicitregisterfpu(list,loc.register.enum);
+            rg.getexplicitregisterfpu(list,loc.register);
           LOC_REFERENCE,LOC_CREFERENCE:
           LOC_REFERENCE,LOC_CREFERENCE:
             { do nothing by default, most of the time it's the framepointer }
             { do nothing by default, most of the time it's the framepointer }
           else
           else
@@ -352,7 +352,13 @@ end.
 
 
 {
 {
    $Log$
    $Log$
-   Revision 1.50  2003-08-11 21:18:20  peter
+   Revision 1.51  2003-09-03 15:55:01  peter
+     * NEWRA branch merged
+
+   Revision 1.50.2.1  2003/08/29 17:28:59  peter
+     * next batch of updates
+
+   Revision 1.50  2003/08/11 21:18:20  peter
      * start of sparc support for newra
      * start of sparc support for newra
 
 
    Revision 1.49  2003/07/08 21:24:59  peter
    Revision 1.49  2003/07/08 21:24:59  peter

+ 18 - 21
compiler/pass_2.pas

@@ -164,9 +164,6 @@ implementation
          prevp : pptree;
          prevp : pptree;
 {$endif TEMPREGDEBUG}
 {$endif TEMPREGDEBUG}
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
-{$ifndef newra}
-         i : longint;
-{$endif newra}
 {$endif EXTDEBUG}
 {$endif EXTDEBUG}
       begin
       begin
          if not assigned(p) then
          if not assigned(p) then
@@ -206,21 +203,11 @@ implementation
                  Comment(V_Warning,'Location is different in secondpass: '+nodetype2str[p.nodetype]);
                  Comment(V_Warning,'Location is different in secondpass: '+nodetype2str[p.nodetype]);
              end;
              end;
 
 
-{$ifdef newra}
-  {$ifdef i386}
-            if rg.unusedregsint*([first_supreg..last_supreg] - [RS_FRAME_POINTER_REG,RS_STACK_POINTER_REG])<>
-                                ([first_supreg..last_supreg] - [RS_FRAME_POINTER_REG,RS_STACK_POINTER_REG]) then
+{$ifdef i386}
+            if rg.unusedregsint*([first_int_supreg..last_int_supreg] - [RS_FRAME_POINTER_REG,RS_STACK_POINTER_REG])<>
+                                ([first_int_supreg..last_int_supreg] - [RS_FRAME_POINTER_REG,RS_STACK_POINTER_REG]) then
               internalerror(200306171);
               internalerror(200306171);
-  {$endif}
-{$else}
-            { check if all scratch registers are freed }
-            for i:=1 to max_scratch_regs do
-              if not(scratch_regs[i] in cg.unusedscratchregisters) then
-                begin
-                   printnode(stdout,p);
-                   internalerror(2003042201);
-                end;
-{$endif newra}
+{$endif i386}
 {$endif EXTDEBUG}
 {$endif EXTDEBUG}
             if codegenerror then
             if codegenerror then
               include(p.flags,nf_error);
               include(p.flags,nf_error);
@@ -262,9 +249,6 @@ implementation
 
 
     procedure generatecode(var p : tnode);
     procedure generatecode(var p : tnode);
       begin
       begin
-       {$ifndef newra}
-         rg.cleartempgen;
-       {$endif}
          flowcontrol:=[];
          flowcontrol:=[];
          { when size optimization only count occurrence }
          { when size optimization only count occurrence }
          if cs_littlesize in aktglobalswitches then
          if cs_littlesize in aktglobalswitches then
@@ -317,7 +301,20 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.63  2003-08-11 21:18:20  peter
+  Revision 1.64  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.63.2.3  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.63.2.2  2003/08/31 13:50:16  daniel
+    * Remove sorting and use pregenerated indexes
+    * Some work on making things compile
+
+  Revision 1.63.2.1  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.63  2003/08/11 21:18:20  peter
     * start of sparc support for newra
     * start of sparc support for newra
 
 
   Revision 1.62  2003/08/10 17:25:23  peter
   Revision 1.62  2003/08/10 17:25:23  peter

+ 7 - 6
compiler/powerpc/aasmcpu.pas

@@ -82,14 +82,12 @@ uses
 
 
          function is_nop: boolean; override;
          function is_nop: boolean; override;
          function is_move:boolean; override;
          function is_move:boolean; override;
-{$ifdef newra}
          function spill_registers(list:Taasmoutput;
          function spill_registers(list:Taasmoutput;
                                   rgget:Trggetproc;
                                   rgget:Trggetproc;
                                   rgunget:Trgungetproc;
                                   rgunget:Trgungetproc;
                                   r:Tsupregset;
                                   r:Tsupregset;
                                   var unusedregsint:Tsupregset;
                                   var unusedregsint:Tsupregset;
                                   const spilltemplist:Tspill_temp_list):boolean; override;
                                   const spilltemplist:Tspill_temp_list):boolean; override;
-{$endif}
 
 
 
 
       end;
       end;
@@ -435,7 +433,6 @@ uses cutils,rgobj;
       end;
       end;
 
 
 
 
-{$ifdef newra}
     function taicpu.spill_registers(list:Taasmoutput;
     function taicpu.spill_registers(list:Taasmoutput;
                              rgget:Trggetproc;
                              rgget:Trggetproc;
                              rgunget:Trgungetproc;
                              rgunget:Trgungetproc;
@@ -707,8 +704,6 @@ uses cutils,rgobj;
                 end;
                 end;
             end;
             end;
       end;
       end;
-{$endif newra}
-
 
 
 
 
     procedure InitAsm;
     procedure InitAsm;
@@ -723,7 +718,13 @@ uses cutils,rgobj;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.15  2003-08-18 21:27:00  jonas
+  Revision 1.16  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.15.2.1  2003/08/31 21:08:16  peter
+    * first batch of sparc fixes
+
+  Revision 1.15  2003/08/18 21:27:00  jonas
     * some newra optimizations (eliminate lots of moves between registers)
     * some newra optimizations (eliminate lots of moves between registers)
 
 
   Revision 1.14  2003/08/17 16:53:19  jonas
   Revision 1.14  2003/08/17 16:53:19  jonas

+ 100 - 327
compiler/powerpc/cgcpu.pas

@@ -193,18 +193,10 @@ const
                reference_reset(ref);
                reference_reset(ref);
                ref.base:=locpara.reference.index;
                ref.base:=locpara.reference.index;
                ref.offset:=locpara.reference.offset;
                ref.offset:=locpara.reference.offset;
-{$ifndef newra}
-               tmpreg := get_scratch_reg_int(list,size);
-{$else newra}
                tmpreg := rg.getregisterint(list,size);
                tmpreg := rg.getregisterint(list,size);
-{$endif newra}
                a_load_ref_reg(list,size,size,r,tmpreg);
                a_load_ref_reg(list,size,size,r,tmpreg);
                a_load_reg_ref(list,size,size,tmpreg,ref);
                a_load_reg_ref(list,size,size,tmpreg,ref);
-{$ifndef newra}
-               free_scratch_reg(list,tmpreg);
-{$else newra}
                rg.ungetregisterint(list,tmpreg);
                rg.ungetregisterint(list,tmpreg);
-{$endif newra}
             end;
             end;
           LOC_FPUREGISTER,LOC_CFPUREGISTER:
           LOC_FPUREGISTER,LOC_CFPUREGISTER:
             case size of
             case size of
@@ -235,18 +227,10 @@ const
                 reference_reset(ref);
                 reference_reset(ref);
                 ref.base := locpara.reference.index;
                 ref.base := locpara.reference.index;
                 ref.offset := locpara.reference.offset;
                 ref.offset := locpara.reference.offset;
-{$ifndef newra}
-                tmpreg := get_scratch_reg_address(list);
-{$else newra}
                 tmpreg := rg.getregisterint(list,OS_ADDR);
                 tmpreg := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
                 a_loadaddr_ref_reg(list,r,tmpreg);
                 a_loadaddr_ref_reg(list,r,tmpreg);
                 a_load_reg_ref(list,OS_ADDR,OS_ADDR,tmpreg,ref);
                 a_load_reg_ref(list,OS_ADDR,OS_ADDR,tmpreg,ref);
-{$ifndef newra}
-                free_scratch_reg(list,tmpreg);
-{$else newra}
                 rg.ungetregisterint(list,tmpreg);
                 rg.ungetregisterint(list,tmpreg);
-{$endif newra}
               end;
               end;
             else
             else
               internalerror(2002080701);
               internalerror(2002080701);
@@ -282,22 +266,14 @@ const
             {Generate instruction to load the procedure address from
             {Generate instruction to load the procedure address from
             the transition vector.}
             the transition vector.}
             //TODO: Support cross-TOC calls.
             //TODO: Support cross-TOC calls.
-{$ifndef newra}
-            tmpreg := get_scratch_reg_int(list,OS_INT);
-{$else newra}
             tmpreg := rg.getregisterint(list,OS_INT);
             tmpreg := rg.getregisterint(list,OS_INT);
-{$endif newra}
             reference_reset(tmpref);
             reference_reset(tmpref);
             tmpref.offset := 0;
             tmpref.offset := 0;
             //tmpref.symaddr := refs_full;
             //tmpref.symaddr := refs_full;
             tmpref.base:= reg;
             tmpref.base:= reg;
             list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
             list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
             list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
             list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
-{$ifndef newra}
-            free_scratch_reg(list,tmpreg);
-{$else newra}
             rg.ungetregisterint(list,tmpreg);
             rg.ungetregisterint(list,tmpreg);
-{$endif newra}
           end
           end
         else
         else
           list.concat(taicpu.op_reg(A_MTCTR,reg));
           list.concat(taicpu.op_reg(A_MTCTR,reg));
@@ -319,11 +295,7 @@ const
         tmpref : treference;
         tmpref : treference;
 
 
       begin
       begin
-{$ifndef newra}
-        tmpreg := get_scratch_reg_int(list,OS_ADDR);
-{$else newra}
         tmpreg := rg.getregisterint(list,OS_ADDR);
         tmpreg := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
         a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,tmpreg);
         a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,tmpreg);
         if target_info.system=system_powerpc_macos then
         if target_info.system=system_powerpc_macos then
           begin
           begin
@@ -337,11 +309,7 @@ const
             list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
             list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
           end;
           end;
         list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
         list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
-{$ifndef newra}
-        free_scratch_reg(list,tmpreg);
-{$else newra}
         rg.ungetregisterint(list,tmpreg);
         rg.ungetregisterint(list,tmpreg);
-{$endif newra}
         list.concat(taicpu.op_none(A_BCTRL));
         list.concat(taicpu.op_none(A_BCTRL));
         //if target_info.system=system_powerpc_macos then
         //if target_info.system=system_powerpc_macos then
         //  //NOP is not needed here.
         //  //NOP is not needed here.
@@ -395,14 +363,10 @@ const
          { 64 bit stuff should be handled separately }
          { 64 bit stuff should be handled separately }
          if tosize in [OS_64,OS_S64] then
          if tosize in [OS_64,OS_S64] then
            internalerror(200109236);
            internalerror(200109236);
-         op := storeinstr[tcgsize2unsigned[tosize],ref2.index.number<>NR_NO,false];
+         op := storeinstr[tcgsize2unsigned[tosize],ref2.index<>NR_NO,false];
          a_load_store(list,op,reg,ref2);
          a_load_store(list,op,reg,ref2);
          if freereg then
          if freereg then
-{$ifndef newra}
-           cg.free_scratch_reg(list,ref2.base);
-{$else newra}
-            rg.ungetregisterint(list,ref2.base);
-{$endif newra}
+           rg.ungetregisterint(list,ref2.base);
        End;
        End;
 
 
 
 
@@ -433,14 +397,10 @@ const
             internalerror(2002090902);
             internalerror(2002090902);
           ref2 := ref;
           ref2 := ref;
           freereg := fixref(list,ref2);
           freereg := fixref(list,ref2);
-          op := loadinstr[fromsize,ref2.index.number<>NR_NO,false];
+          op := loadinstr[fromsize,ref2.index<>NR_NO,false];
           a_load_store(list,op,reg,ref2);
           a_load_store(list,op,reg,ref2);
           if freereg then
           if freereg then
-{$ifndef newra}
-            free_scratch_reg(list,ref2.base);
-{$else newra}
             rg.ungetregisterint(list,ref2.base);
             rg.ungetregisterint(list,ref2.base);
-{$endif newra}
           { sign extend shortint if necessary, since there is no }
           { sign extend shortint if necessary, since there is no }
           { load instruction that does that automatically (JM)   }
           { load instruction that does that automatically (JM)   }
           if fromsize = OS_S8 then
           if fromsize = OS_S8 then
@@ -453,11 +413,7 @@ const
        var
        var
          instr: taicpu;
          instr: taicpu;
        begin
        begin
-         if (reg1.enum<>R_INTREGISTER) or (reg1.number = 0) then
-           internalerror(200303101);
-         if (reg2.enum<>R_INTREGISTER) or (reg2.number = 0) then
-           internalerror(200303102);
-         if (reg1.number<>reg2.number) or
+         if (reg1<>reg2) or
             (tcgsize2size[tosize] < tcgsize2size[fromsize]) or
             (tcgsize2size[tosize] < tcgsize2size[fromsize]) or
             ((tcgsize2size[tosize] = tcgsize2size[fromsize]) and
             ((tcgsize2size[tosize] = tcgsize2size[fromsize]) and
              (tosize <> fromsize) and
              (tosize <> fromsize) and
@@ -479,9 +435,7 @@ const
                else internalerror(2002090901);
                else internalerror(2002090901);
              end;
              end;
              list.concat(instr);
              list.concat(instr);
-{$ifdef newra}
              rg.add_move_instruction(instr);
              rg.add_move_instruction(instr);
-{$endif newra}
            end;
            end;
        end;
        end;
 
 
@@ -518,14 +472,10 @@ const
           end;
           end;
          ref2 := ref;
          ref2 := ref;
          freereg := fixref(list,ref2);
          freereg := fixref(list,ref2);
-         op := fpuloadinstr[size,ref2.index.number <> NR_NO,false];
+         op := fpuloadinstr[size,ref2.index <> NR_NO,false];
          a_load_store(list,op,reg,ref2);
          a_load_store(list,op,reg,ref2);
          if freereg then
          if freereg then
-{$ifndef newra}
-           cg.free_scratch_reg(list,ref2.base);
-{$else newra}
            rg.ungetregisterint(list,ref2.base);
            rg.ungetregisterint(list,ref2.base);
-{$endif newra}
        end;
        end;
 
 
 
 
@@ -546,14 +496,10 @@ const
            internalerror(200201122);
            internalerror(200201122);
          ref2 := ref;
          ref2 := ref;
          freereg := fixref(list,ref2);
          freereg := fixref(list,ref2);
-         op := fpustoreinstr[size,ref2.index.number <> NR_NO,false];
+         op := fpustoreinstr[size,ref2.index <> NR_NO,false];
          a_load_store(list,op,reg,ref2);
          a_load_store(list,op,reg,ref2);
          if freereg then
          if freereg then
-{$ifndef newra}
-           cg.free_scratch_reg(list,ref2.base);
-{$else newra}
            rg.ungetregisterint(list,ref2.base);
            rg.ungetregisterint(list,ref2.base);
-{$endif newra}
        end;
        end;
 
 
 
 
@@ -709,21 +655,13 @@ const
           OP_OR:
           OP_OR:
             { try to use rlwimi }
             { try to use rlwimi }
             if gotrlwi and
             if gotrlwi and
-               (src.number = dst.number) then
+               (src = dst) then
               begin
               begin
-{$ifndef newra}
-                scratchreg := get_scratch_reg_int(list,OS_INT);
-{$else newra}
                 scratchreg := rg.getregisterint(list,OS_INT);
                 scratchreg := rg.getregisterint(list,OS_INT);
-{$endif newra}
                 list.concat(taicpu.op_reg_const(A_LI,scratchreg,-1));
                 list.concat(taicpu.op_reg_const(A_LI,scratchreg,-1));
                 list.concat(taicpu.op_reg_reg_const_const_const(A_RLWIMI,dst,
                 list.concat(taicpu.op_reg_reg_const_const_const(A_RLWIMI,dst,
                   scratchreg,0,l1,l2));
                   scratchreg,0,l1,l2));
-{$ifndef newra}
-                free_scratch_reg(list,scratchreg);
-{$else newra}
                 rg.ungetregisterint(list,scratchreg);
                 rg.ungetregisterint(list,scratchreg);
-{$endif newra}
               end
               end
             else
             else
               do_lo_hi;
               do_lo_hi;
@@ -753,18 +691,10 @@ const
         { perform the operation                                        }
         { perform the operation                                        }
         if useReg then
         if useReg then
           begin
           begin
-{$ifndef newra}
-            scratchreg := get_scratch_reg_int(list,OS_INT);
-{$else newra}
             scratchreg := rg.getregisterint(list,OS_INT);
             scratchreg := rg.getregisterint(list,OS_INT);
-{$endif newra}
             a_load_const_reg(list,OS_32,a,scratchreg);
             a_load_const_reg(list,OS_32,a,scratchreg);
             a_op_reg_reg_reg(list,op,OS_32,scratchreg,src,dst);
             a_op_reg_reg_reg(list,op,OS_32,scratchreg,src,dst);
-{$ifndef newra}
-            free_scratch_reg(list,scratchreg);
-{$else newra}
             rg.ungetregisterint(list,scratchreg);
             rg.ungetregisterint(list,scratchreg);
-{$endif newra}
           end;
           end;
       end;
       end;
 
 
@@ -811,36 +741,20 @@ const
               list.concat(taicpu.op_reg_reg_const(A_CMPWI,r,reg,longint(a)))
               list.concat(taicpu.op_reg_reg_const(A_CMPWI,r,reg,longint(a)))
             else
             else
               begin
               begin
-{$ifndef newra}
-                scratch_register := get_scratch_reg_int(list,OS_INT);
-{$else newra}
                 scratch_register := rg.getregisterint(list,OS_INT);
                 scratch_register := rg.getregisterint(list,OS_INT);
-{$endif newra}
                 a_load_const_reg(list,OS_32,a,scratch_register);
                 a_load_const_reg(list,OS_32,a,scratch_register);
                 list.concat(taicpu.op_reg_reg_reg(A_CMPW,r,reg,scratch_register));
                 list.concat(taicpu.op_reg_reg_reg(A_CMPW,r,reg,scratch_register));
-{$ifndef newra}
-                free_scratch_reg(list,scratch_register);
-{$else newra}
                 rg.ungetregisterint(list,scratch_register);
                 rg.ungetregisterint(list,scratch_register);
-{$endif newra}
               end
               end
           else
           else
             if (a <= $ffff) then
             if (a <= $ffff) then
               list.concat(taicpu.op_reg_reg_const(A_CMPLWI,r,reg,a))
               list.concat(taicpu.op_reg_reg_const(A_CMPLWI,r,reg,a))
             else
             else
               begin
               begin
-{$ifndef newra}
-                scratch_register := get_scratch_reg_int(list,OS_32);
-{$else newra}
                 scratch_register := rg.getregisterint(list,OS_INT);
                 scratch_register := rg.getregisterint(list,OS_INT);
-{$endif newra}
                 a_load_const_reg(list,OS_32,a,scratch_register);
                 a_load_const_reg(list,OS_32,a,scratch_register);
                 list.concat(taicpu.op_reg_reg_reg(A_CMPLW,r,reg,scratch_register));
                 list.concat(taicpu.op_reg_reg_reg(A_CMPLW,r,reg,scratch_register));
-{$ifndef newra}
-                free_scratch_reg(list,scratch_register);
-{$else newra}
                 rg.ungetregisterint(list,scratch_register);
                 rg.ungetregisterint(list,scratch_register);
-{$endif newra}
               end;
               end;
           a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
           a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
         end;
         end;
@@ -1025,20 +939,11 @@ const
         { procedure, but currently this isn't checked, so save them always         }
         { procedure, but currently this isn't checked, so save them always         }
         { following is the entry code as described in "Altivec Programming }
         { following is the entry code as described in "Altivec Programming }
         { Interface Manual", bar the saving of AltiVec registers           }
         { Interface Manual", bar the saving of AltiVec registers           }
-        rsp.enum:=R_INTREGISTER;
-        rsp.number:=NR_STACK_POINTER_REG;
-        a_reg_alloc(list,rsp);
-        r.enum:=R_INTREGISTER;
-        r.number:=NR_R0;
-        a_reg_alloc(list,r);
+        a_reg_alloc(list,NR_STACK_POINTER_REG);
+        a_reg_alloc(list,NR_R0);
 
 
         if current_procinfo.procdef.parast.symtablelevel>1 then
         if current_procinfo.procdef.parast.symtablelevel>1 then
-          begin
-             r.enum:=R_INTREGISTER;
-             r.number:=NR_R11;
-             a_reg_alloc(list,r);
-          end;
-
+          a_reg_alloc(list,NR_R11);
 
 
         usesfpr:=false;
         usesfpr:=false;
         if not (po_assembler in current_procinfo.procdef.procoptions) then
         if not (po_assembler in current_procinfo.procdef.procoptions) then
@@ -1059,8 +964,7 @@ const
               if regcounter2 in rg.used_in_proc_int then
               if regcounter2 in rg.used_in_proc_int then
                 begin
                 begin
                    usesgpr:=true;
                    usesgpr:=true;
-                   firstreggpr.enum := R_INTREGISTER;
-                   firstreggpr.number := regcounter2 shl 8;
+                   firstreggpr:=newreg(R_INTREGISTER,regcounter2,R_SUBNONE);
                    break;
                    break;
                 end;
                 end;
             end;
             end;
@@ -1070,9 +974,7 @@ const
           if (pi_do_call in current_procinfo.flags) then
           if (pi_do_call in current_procinfo.flags) then
             begin
             begin
                { save return address... }
                { save return address... }
-               r.enum:=R_INTREGISTER;
-               r.number:=NR_R0;
-               list.concat(taicpu.op_reg(A_MFLR,r));
+               list.concat(taicpu.op_reg(A_MFLR,NR_R0));
                { ... in caller's frame }
                { ... in caller's frame }
                case target_info.abi of
                case target_info.abi of
                  abi_powerpc_aix:
                  abi_powerpc_aix:
@@ -1081,7 +983,7 @@ const
                    reference_reset_base(href,rsp,LA_LR_SYSV);
                    reference_reset_base(href,rsp,LA_LR_SYSV);
                end;
                end;
                list.concat(taicpu.op_reg_ref(A_STW,r,href));
                list.concat(taicpu.op_reg_ref(A_STW,r,href));
-               a_reg_dealloc(list,r);
+               a_reg_dealloc(list,NR_R0);
             end;
             end;
 
 
         { save the CR if necessary in callers frame. }
         { save the CR if necessary in callers frame. }
@@ -1089,55 +991,46 @@ const
           if target_info.abi = abi_powerpc_aix then
           if target_info.abi = abi_powerpc_aix then
             if false then { Not needed at the moment. }
             if false then { Not needed at the moment. }
               begin
               begin
-                r.enum:=R_INTREGISTER;
-                r.number:=NR_R0;
-                a_reg_alloc(list,r);
-                r2.enum:=R_CR;
-                list.concat(taicpu.op_reg_reg(A_MFSPR,r,r2));
+                a_reg_alloc(list,NR_R0);
+                list.concat(taicpu.op_reg_reg(A_MFSPR,NR_R0,NR_CR));
                 reference_reset_base(href,rsp,LA_CR_AIX);
                 reference_reset_base(href,rsp,LA_CR_AIX);
                 list.concat(taicpu.op_reg_ref(A_STW,r,href));
                 list.concat(taicpu.op_reg_ref(A_STW,r,href));
-                a_reg_dealloc(list,r);
+                a_reg_dealloc(list,NR_R0);
               end;
               end;
 
 
         { !!! always allocate space for all registers for now !!! }
         { !!! always allocate space for all registers for now !!! }
         if not (po_assembler in current_procinfo.procdef.procoptions) then
         if not (po_assembler in current_procinfo.procdef.procoptions) then
 {        if usesfpr or usesgpr then }
 {        if usesfpr or usesgpr then }
           begin
           begin
-             r.enum:=R_INTREGISTER;
-             r.number:=NR_R12;
-             a_reg_alloc(list,r);
+             a_reg_alloc(list,NR_R12);
              { save end of fpr save area }
              { save end of fpr save area }
-             list.concat(taicpu.op_reg_reg(A_MR,r,rsp));
+             list.concat(taicpu.op_reg_reg(A_MR,NR_R12,NR_STACK_POINTER_REG));
           end;
           end;
 
 
 
 
         if (localsize <> 0) then
         if (localsize <> 0) then
           begin
           begin
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_STACK_POINTER_REG;
             if (localsize <= high(smallint)) then
             if (localsize <= high(smallint)) then
               begin
               begin
-                reference_reset_base(href,r,-localsize);
-                a_load_store(list,A_STWU,r,href);
+                reference_reset_base(href,NR_STACK_POINTER_REG,-localsize);
+                a_load_store(list,A_STWU,NR_STACK_POINTER_REG,href);
               end
               end
             else
             else
               begin
               begin
-                reference_reset_base(href,r,0);
+                reference_reset_base(href,NR_STACK_POINTER_REG,0);
                 { can't use getregisterint here, the register colouring }
                 { can't use getregisterint here, the register colouring }
                 { is already done when we get here                      }
                 { is already done when we get here                      }
-                href.index.enum := R_INTREGISTER;
-                href.index.number := NR_R11;
+                href.index := NR_R11;
                 a_reg_alloc(list,href.index);
                 a_reg_alloc(list,href.index);
                 a_load_const_reg(list,OS_S32,-localsize,href.index);
                 a_load_const_reg(list,OS_S32,-localsize,href.index);
-                a_load_store(list,A_STWUX,r,href);
+                a_load_store(list,A_STWUX,NR_STACK_POINTER_REG,href);
                 a_reg_dealloc(list,href.index);
                 a_reg_dealloc(list,href.index);
               end;
               end;
           end;
           end;
 
 
         { no GOT pointer loaded yet }
         { no GOT pointer loaded yet }
         gotgot:=false;
         gotgot:=false;
-        r.enum := R_INTREGISTER;
-        r.NUMBER := NR_R12;
+        r := NR_R12;
         if usesfpr then
         if usesfpr then
           begin
           begin
              { save floating-point registers
              { save floating-point registers
@@ -1179,8 +1072,7 @@ const
                 if regcounter2 in rg.used_in_proc_int then
                 if regcounter2 in rg.used_in_proc_int then
                   begin
                   begin
                      usesgpr:=true;
                      usesgpr:=true;
-                     r.enum := R_INTREGISTER;
-                     r.number := regcounter2 shl 8;
+                     r:=newreg(R_INTREGISTER,regcounter2,R_SUBNONE);
                      a_load_reg_ref(list,OS_INT,OS_INT,r,href);
                      a_load_reg_ref(list,OS_INT,OS_INT,r,href);
                      dec(href.offset,4);
                      dec(href.offset,4);
                   end;
                   end;
@@ -1198,8 +1090,7 @@ const
             if not (po_assembler in current_procinfo.procdef.procoptions) then
             if not (po_assembler in current_procinfo.procdef.procoptions) then
               begin
               begin
                 { copy memory parameters to local parast }
                 { copy memory parameters to local parast }
-                r.enum:=R_INTREGISTER;
-                r.number:=NR_R12;
+                r:=NR_R12;
                 hp:=tparaitem(current_procinfo.procdef.para.first);
                 hp:=tparaitem(current_procinfo.procdef.para.first);
                 while assigned(hp) do
                 while assigned(hp) do
                   begin
                   begin
@@ -1212,7 +1103,7 @@ const
 {$ifdef newra2}
 {$ifdef newra2}
                     else if (hp.calleeparaloc.loc in [LOC_REGISTER,LOC_CREGISTER]) then
                     else if (hp.calleeparaloc.loc in [LOC_REGISTER,LOC_CREGISTER]) then
                       begin
                       begin
-                        rg.getexplicitregisterint(list,hp.calleeparaloc.register.number);
+                        rg.getexplicitregisterint(list,hp.calleeparaloc.register);
                       end
                       end
 {$endif newra}
 {$endif newra}
                       ;
                       ;
@@ -1221,10 +1112,8 @@ const
               end;
               end;
           end;
           end;
 
 
-        r.enum:=R_INTREGISTER;
-        r.number:=NR_R12;
         if usesfpr or usesgpr then
         if usesfpr or usesgpr then
-          a_reg_dealloc(list,r);
+          a_reg_dealloc(list,NR_R12);
 
 
         { PIC code support, }
         { PIC code support, }
         if cs_create_pic in aktmoduleswitches then
         if cs_create_pic in aktmoduleswitches then
@@ -1234,12 +1123,9 @@ const
                begin
                begin
                   {!!!!!!!!!!!!!}
                   {!!!!!!!!!!!!!}
                end;
                end;
-             r.enum:=R_INTREGISTER;
-             r.number:=NR_R31;
-             r2.enum:=R_LR;
-             a_reg_alloc(list,r);
+             a_reg_alloc(list,NR_R31);
              { place GOT ptr in r31 }
              { place GOT ptr in r31 }
-             list.concat(taicpu.op_reg_reg(A_MFSPR,r,r2));
+             list.concat(taicpu.op_reg_reg(A_MFSPR,NR_R31,NR_LR));
           end;
           end;
         { save the CR if necessary ( !!! always done currently ) }
         { save the CR if necessary ( !!! always done currently ) }
         { still need to find out where this has to be done for SystemV
         { still need to find out where this has to be done for SystemV
@@ -1253,10 +1139,8 @@ const
         { if we're in a nested procedure, we've to save R11 }
         { if we're in a nested procedure, we've to save R11 }
         if current_procinfo.procdef.parast.symtablelevel>2 then
         if current_procinfo.procdef.parast.symtablelevel>2 then
           begin
           begin
-             r.enum:=R_INTREGISTER;
-             r.number:=NR_R11;
              reference_reset_base(href,rsp,PARENT_FRAMEPOINTER_OFFSET);
              reference_reset_base(href,rsp,PARENT_FRAMEPOINTER_OFFSET);
-             list.concat(taicpu.op_reg_ref(A_STW,r,href));
+             list.concat(taicpu.op_reg_ref(A_STW,NR_R11,href));
           end;
           end;
 
 
       end;
       end;
@@ -1293,8 +1177,7 @@ const
               if regcounter2 in rg.used_in_proc_int then
               if regcounter2 in rg.used_in_proc_int then
                 begin
                 begin
                   usesgpr:=true;
                   usesgpr:=true;
-                  firstreggpr.enum:=R_INTREGISTER;
-                  firstreggpr.number:=regcounter2 shl 8;
+                  firstreggpr:=newreg(R_INTREGISTER,regcounter2,R_SUBNONE);
                   break;
                   break;
                 end;
                 end;
             end;
             end;
@@ -1306,14 +1189,10 @@ const
         if usesgpr or usesfpr then
         if usesgpr or usesfpr then
           begin
           begin
              { address of gpr save area to r11 }
              { address of gpr save area to r11 }
-             r.enum:=R_INTREGISTER;
-             r.number:=NR_STACK_POINTER_REG;
-             r2.enum:=R_INTREGISTER;
-             r2.number:=NR_R12;
-             a_op_const_reg_reg(list,OP_ADD,OS_ADDR,localsize,r,r2);
+             a_op_const_reg_reg(list,OP_ADD,OS_ADDR,localsize,NR_STACK_POINTER_REG,NR_R12);
              if usesfpr then
              if usesfpr then
                begin
                begin
-                 reference_reset_base(href,r2,-8);
+                 reference_reset_base(href,NR_R12,-8);
                  for regcounter.enum := firstregfpu.enum to R_F31 do
                  for regcounter.enum := firstregfpu.enum to R_F31 do
                    if (regcounter.enum in rg.used_in_proc_other) then
                    if (regcounter.enum in rg.used_in_proc_other) then
                      begin
                      begin
@@ -1323,15 +1202,14 @@ const
                  inc(href.offset,4);
                  inc(href.offset,4);
                end
                end
              else
              else
-               reference_reset_base(href,r2,-4);
+               reference_reset_base(href,NR_R12,-4);
 
 
             for regcounter2:=firstsaveintreg to RS_R31 do
             for regcounter2:=firstsaveintreg to RS_R31 do
               begin
               begin
                 if regcounter2 in rg.used_in_proc_int then
                 if regcounter2 in rg.used_in_proc_int then
                   begin
                   begin
                      usesgpr:=true;
                      usesgpr:=true;
-                     r.enum := R_INTREGISTER;
-                     r.number := regcounter2 shl 8;
+                     r:=newreg(R_INTREGISTER,regcounter2,R_SUBNONE);
                      a_load_ref_reg(list,OS_INT,OS_INT,href,r);
                      a_load_ref_reg(list,OS_INT,OS_INT,href,r);
                      dec(href.offset,4);
                      dec(href.offset,4);
                   end;
                   end;
@@ -1369,41 +1247,30 @@ const
         if genret then
         if genret then
           begin
           begin
              { adjust r1 }
              { adjust r1 }
-             r.enum:=R_INTREGISTER;
-             r.number:=NR_R1;
-             a_op_const_reg(list,OP_ADD,OS_ADDR,localsize,r);
+             a_op_const_reg(list,OP_ADD,OS_ADDR,localsize,NR_R1);
              { load link register? }
              { load link register? }
              if not (po_assembler in current_procinfo.procdef.procoptions) then
              if not (po_assembler in current_procinfo.procdef.procoptions) then
                begin
                begin
                  if (pi_do_call in current_procinfo.flags) then
                  if (pi_do_call in current_procinfo.flags) then
                    begin
                    begin
-                      r.enum:=R_INTREGISTER;
-                      r.number:=NR_STACK_POINTER_REG;
                       case target_info.abi of
                       case target_info.abi of
                         abi_powerpc_aix:
                         abi_powerpc_aix:
-                          reference_reset_base(href,r,LA_LR_AIX);
+                          reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_AIX);
                         abi_powerpc_sysv:
                         abi_powerpc_sysv:
-                          reference_reset_base(href,r,LA_LR_SYSV);
+                          reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_SYSV);
                       end;
                       end;
-                      r.enum:=R_INTREGISTER;
-                      r.number:=NR_R0;
-                      list.concat(taicpu.op_reg_ref(A_LWZ,r,href));
-                      list.concat(taicpu.op_reg(A_MTLR,r));
+                      list.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,href));
+                      list.concat(taicpu.op_reg(A_MTLR,NR_R0));
                    end;
                    end;
 
 
                  { restore the CR if necessary from callers frame}
                  { restore the CR if necessary from callers frame}
                  if target_info.abi = abi_powerpc_aix then
                  if target_info.abi = abi_powerpc_aix then
                    if false then { Not needed at the moment. }
                    if false then { Not needed at the moment. }
                      begin
                      begin
-                      r.enum:=R_INTREGISTER;
-                      r.number:=NR_STACK_POINTER_REG;
-                      reference_reset_base(href,r,LA_CR_AIX);
-                      r.enum:=R_INTREGISTER;
-                      r.number:=NR_R0;
-                      list.concat(taicpu.op_reg_ref(A_LWZ,r,href));
-                      r2.enum:=R_CR;
-                      list.concat(taicpu.op_reg_reg(A_MTSPR,r,r2));
-                      a_reg_dealloc(list,r);
+                      reference_reset_base(href,NR_STACK_POINTER_REG,LA_CR_AIX);
+                      list.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,href));
+                      list.concat(taicpu.op_reg_reg(A_MTSPR,NR_R0,NR_CR));
+                      a_reg_dealloc(list,NR_R0);
                      end;
                      end;
                end;
                end;
 
 
@@ -1441,8 +1308,7 @@ const
             if regcounter2 in rg.used_in_proc_int then
             if regcounter2 in rg.used_in_proc_int then
               begin
               begin
                  usesgpr:=true;
                  usesgpr:=true;
-                 firstreggpr.enum:=R_INTREGISTER;
-                 firstreggpr.number:=regcounter2 shl 8;
+                 firstreggpr:=newreg(R_INTREGISTER,regcounter2,R_SUBNONE);
                  break;
                  break;
               end;
               end;
           end;
           end;
@@ -1465,22 +1331,18 @@ const
         if firstreggpr.enum < R_30 then
         if firstreggpr.enum < R_30 then
           begin
           begin
             offset:= offset - 4 * (ord(R_31) - ord(firstreggpr.enum) + 1);
             offset:= offset - 4 * (ord(R_31) - ord(firstreggpr.enum) + 1);
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_STACK_POINTER_REG;
-            reference_reset_base(href,r,offset);
+            reference_reset_base(href,NR_STACK_POINTER_REG,offset);
             list.concat(taicpu.op_reg_ref(A_STMW,firstreggpr,href));
             list.concat(taicpu.op_reg_ref(A_STMW,firstreggpr,href));
               {STMW stores multiple registers}
               {STMW stores multiple registers}
           end
           end
         else
         else
           begin
           begin
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_STACK_POINTER_REG;
             r2 := firstreggpr;
             r2 := firstreggpr;
             convert_register_to_enum(firstreggpr);
             convert_register_to_enum(firstreggpr);
             for regcounter.enum := firstreggpr.enum to R_31 do
             for regcounter.enum := firstreggpr.enum to R_31 do
               begin
               begin
                 offset:= offset - 4;
                 offset:= offset - 4;
-                reference_reset_base(href, r, offset);
+                reference_reset_base(href, NR_STACK_POINTER_REG, offset);
                 list.concat(taicpu.op_reg_ref(A_STW, r2, href));
                 list.concat(taicpu.op_reg_ref(A_STW, r2, href));
                 inc(r2.number,NR_R1-NR_R0);
                 inc(r2.number,NR_R1-NR_R0);
               end;
               end;
@@ -1796,11 +1658,7 @@ const
                        ref2.base,tmpref));
                        ref2.base,tmpref));
                      if freereg then
                      if freereg then
                        begin
                        begin
-{$ifndef newra}
-                         cg.free_scratch_reg(list,ref2.base);
-{$else newra}
                          rg.ungetregisterint(list,ref2.base);
                          rg.ungetregisterint(list,ref2.base);
-{$endif newra}
                          freereg := false;
                          freereg := false;
                        end;
                        end;
                    end
                    end
@@ -1826,11 +1684,7 @@ const
                  (r.number <> ref2.base.number) then
                  (r.number <> ref2.base.number) then
            list.concat(taicpu.op_reg_reg(A_MR,r,ref2.base));
            list.concat(taicpu.op_reg_reg(A_MR,r,ref2.base));
          if freereg then
          if freereg then
-{$ifndef newra}
-           cg.free_scratch_reg(list,ref2.base);
-{$else newra}
            rg.ungetregisterint(list,ref2.base);
            rg.ungetregisterint(list,ref2.base);
-{$endif newra}
        end;
        end;
 
 
 { ************* concatcopy ************ }
 { ************* concatcopy ************ }
@@ -1898,24 +1752,16 @@ const
         { load the address of source into src.base }
         { load the address of source into src.base }
         if loadref then
         if loadref then
           begin
           begin
-{$ifndef newra}
-            src.base := get_scratch_reg_address(list);
-{$else newra}
-           src.base := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
+            src.base := rg.getregisterint(list,OS_ADDR);
             a_load_ref_reg(list,OS_32,OS_32,source,src.base);
             a_load_ref_reg(list,OS_32,OS_32,source,src.base);
             orgsrc := false;
             orgsrc := false;
           end
           end
         else if (count > 4) or
         else if (count > 4) or
                 not issimpleref(source) or
                 not issimpleref(source) or
-                ((source.index.number <> NR_NO) and
+                ((source.index <> NR_NO) and
                  ((source.offset + longint(len)) > high(smallint))) then
                  ((source.offset + longint(len)) > high(smallint))) then
           begin
           begin
-{$ifndef newra}
-            src.base := get_scratch_reg_address(list);
-{$else newra}
             src.base := rg.getregisterint(list,OS_ADDR);
             src.base := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
             a_loadaddr_ref_reg(list,source,src.base);
             a_loadaddr_ref_reg(list,source,src.base);
             orgsrc := false;
             orgsrc := false;
           end
           end
@@ -1929,14 +1775,10 @@ const
         { load the address of dest into dst.base }
         { load the address of dest into dst.base }
         if (count > 4) or
         if (count > 4) or
            not issimpleref(dest) or
            not issimpleref(dest) or
-           ((dest.index.number <> NR_NO) and
+           ((dest.index <> NR_NO) and
             ((dest.offset + longint(len)) > high(smallint))) then
             ((dest.offset + longint(len)) > high(smallint))) then
           begin
           begin
-{$ifndef newra}
-            dst.base := get_scratch_reg_address(list);
-{$else newra}
             dst.base := rg.getregisterint(list,OS_ADDR);
             dst.base := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
             a_loadaddr_ref_reg(list,dest,dst.base);
             a_loadaddr_ref_reg(list,dest,dst.base);
             orgdst := false;
             orgdst := false;
           end
           end
@@ -1958,11 +1800,7 @@ const
             inc(src.offset,8);
             inc(src.offset,8);
             list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,8));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,8));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,8));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,8));
-{$ifndef newra}
-            countreg := get_scratch_reg_int(list,OS_INT);
-{$else newra}
             countreg := rg.getregisterint(list,OS_INT);
             countreg := rg.getregisterint(list,OS_INT);
-{$endif newra}
             a_load_const_reg(list,OS_32,count,countreg);
             a_load_const_reg(list,OS_32,count,countreg);
             { explicitely allocate R_0 since it can be used safely here }
             { explicitely allocate R_0 since it can be used safely here }
             { (for holding date that's being copied)                    }
             { (for holding date that's being copied)                    }
@@ -1975,11 +1813,7 @@ const
             list.concat(taicpu.op_reg_ref(A_LFDU,r,src));
             list.concat(taicpu.op_reg_ref(A_LFDU,r,src));
             list.concat(taicpu.op_reg_ref(A_STFDU,r,dst));
             list.concat(taicpu.op_reg_ref(A_STFDU,r,dst));
             a_jmp(list,A_BC,C_NE,0,lab);
             a_jmp(list,A_BC,C_NE,0,lab);
-{$ifndef newra}
-            free_scratch_reg(list,countreg);
-{$else newra}
-           rg.ungetregisterint(list,countreg);
-{$endif newra}
+            rg.ungetregisterint(list,countreg);
             a_reg_dealloc(list,r);
             a_reg_dealloc(list,r);
             len := len mod 8;
             len := len mod 8;
           end;
           end;
@@ -2003,14 +1837,12 @@ const
 
 
         if (len and 4) <> 0 then
         if (len and 4) <> 0 then
           begin
           begin
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_R0;
-            a_reg_alloc(list,r);
-            a_load_ref_reg(list,OS_32,OS_32,src,r);
-            a_load_reg_ref(list,OS_32,OS_32,r,dst);
+            a_reg_alloc(list,NR_R0);
+            a_load_ref_reg(list,OS_32,OS_32,src,NR_R0);
+            a_load_reg_ref(list,OS_32,OS_32,NR_R0,dst);
             inc(src.offset,4);
             inc(src.offset,4);
             inc(dst.offset,4);
             inc(dst.offset,4);
-            a_reg_dealloc(list,r);
+            a_reg_dealloc(list,NR_R0);
           end;
           end;
 {$else not ppc603}
 {$else not ppc603}
         if count > 4 then
         if count > 4 then
@@ -2024,29 +1856,19 @@ const
             inc(src.offset,4);
             inc(src.offset,4);
             list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,4));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,4));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,4));
             list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,4));
-{$ifndef newra}
-            countreg := get_scratch_reg_int(list,OS_INT);
-{$else newra}
             countreg := rg.getregisterint(list,OS_INT);
             countreg := rg.getregisterint(list,OS_INT);
-{$endif newra}
             a_load_const_reg(list,OS_32,count,countreg);
             a_load_const_reg(list,OS_32,count,countreg);
             { explicitely allocate R_0 since it can be used safely here }
             { explicitely allocate R_0 since it can be used safely here }
             { (for holding date that's being copied)                    }
             { (for holding date that's being copied)                    }
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_R0;
-            a_reg_alloc(list,r);
+            a_reg_alloc(list,NR_R0);
             objectlibrary.getlabel(lab);
             objectlibrary.getlabel(lab);
             a_label(list, lab);
             a_label(list, lab);
             list.concat(taicpu.op_reg_reg_const(A_SUBIC_,countreg,countreg,1));
             list.concat(taicpu.op_reg_reg_const(A_SUBIC_,countreg,countreg,1));
-            list.concat(taicpu.op_reg_ref(A_LWZU,r,src));
-            list.concat(taicpu.op_reg_ref(A_STWU,r,dst));
+            list.concat(taicpu.op_reg_ref(A_LWZU,NR_R0,src));
+            list.concat(taicpu.op_reg_ref(A_STWU,NR_R0,dst));
             a_jmp(list,A_BC,C_NE,0,lab);
             a_jmp(list,A_BC,C_NE,0,lab);
-{$ifndef newra}
-            free_scratch_reg(list,countreg);
-{$else newra}
-           rg.ungetregisterint(list,countreg);
-{$endif newra}
-            a_reg_dealloc(list,r);
+            rg.ungetregisterint(list,countreg);
+            a_reg_dealloc(list,NR_R0);
             len := len mod 4;
             len := len mod 4;
           end;
           end;
 
 
@@ -2054,13 +1876,11 @@ const
         if count > 0 then
         if count > 0 then
           { unrolled loop }
           { unrolled loop }
           begin
           begin
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_R0;
-            a_reg_alloc(list,r);
+            a_reg_alloc(list,NR_R0);
             for count2 := 1 to count do
             for count2 := 1 to count do
               begin
               begin
-                a_load_ref_reg(list,OS_32,OS_32,src,r);
-                a_load_reg_ref(list,OS_32,OS_32,r,dst);
+                a_load_ref_reg(list,OS_32,OS_32,src,NR_R0);
+                a_load_reg_ref(list,OS_32,OS_32,NR_R0,dst);
                 inc(src.offset,4);
                 inc(src.offset,4);
                 inc(dst.offset,4);
                 inc(dst.offset,4);
               end;
               end;
@@ -2071,23 +1891,19 @@ const
        { copy the leftovers }
        { copy the leftovers }
        if (len and 2) <> 0 then
        if (len and 2) <> 0 then
          begin
          begin
-           r.enum:=R_INTREGISTER;
-           r.number:=NR_R0;
-           a_reg_alloc(list,r);
-           a_load_ref_reg(list,OS_16,OS_16,src,r);
-           a_load_reg_ref(list,OS_16,OS_16,r,dst);
+           a_reg_alloc(list,NR_R0);
+           a_load_ref_reg(list,OS_16,OS_16,src,NR_R0);
+           a_load_reg_ref(list,OS_16,OS_16,NR_R0,dst);
            inc(src.offset,2);
            inc(src.offset,2);
            inc(dst.offset,2);
            inc(dst.offset,2);
-           a_reg_dealloc(list,r);
+           a_reg_dealloc(list,NR_R0);
          end;
          end;
        if (len and 1) <> 0 then
        if (len and 1) <> 0 then
          begin
          begin
-           r.enum:=R_INTREGISTER;
-           r.number:=NR_R0;
-           a_reg_alloc(list,r);
-           a_load_ref_reg(list,OS_8,OS_8,src,r);
-           a_load_reg_ref(list,OS_8,OS_8,r,dst);
-           a_reg_dealloc(list,r);
+           a_reg_alloc(list,NR_R0);
+           a_load_ref_reg(list,OS_8,OS_8,src,NR_R0);
+           a_load_reg_ref(list,OS_8,OS_8,NR_R0,dst);
+           a_reg_dealloc(list,NR_R0);
          end;
          end;
        if orgsrc then
        if orgsrc then
          begin
          begin
@@ -2095,17 +1911,9 @@ const
              reference_release(list,source);
              reference_release(list,source);
          end
          end
        else
        else
-{$ifndef newra}
-         free_scratch_reg(list,src.base);
-{$else newra}
          rg.ungetregisterint(list,src.base);
          rg.ungetregisterint(list,src.base);
-{$endif newra}
        if not orgdst then
        if not orgdst then
-{$ifndef newra}
-         free_scratch_reg(list,dst.base);
-{$else newra}
          rg.ungetregisterint(list,dst.base);
          rg.ungetregisterint(list,dst.base);
-{$endif newra}
        if delsource then
        if delsource then
          tg.ungetiftemp(list,source);
          tg.ungetiftemp(list,source);
       end;
       end;
@@ -2120,7 +1928,7 @@ const
       begin
       begin
          {$warning !!!! FIX ME !!!!}
          {$warning !!!! FIX ME !!!!}
          internalerror(200305231);
          internalerror(200305231);
-{!!!!
+(* !!!!
         lenref:=ref;
         lenref:=ref;
         inc(lenref.offset,4);
         inc(lenref.offset,4);
         { get stack space }
         { get stack space }
@@ -2230,7 +2038,7 @@ const
 
 
         { patch the new address }
         { patch the new address }
         a_load_reg_ref(list,OS_INT,rsp,ref);
         a_load_reg_ref(list,OS_INT,rsp,ref);
-!!!!}
+!!!! *)
       end;
       end;
 
 
     procedure tcgppc.g_overflowcheck(list: taasmoutput; const l: tlocation; def: tdef);
     procedure tcgppc.g_overflowcheck(list: taasmoutput; const l: tlocation; def: tdef);
@@ -2263,15 +2071,15 @@ const
     function tcgppc.issimpleref(const ref: treference): boolean;
     function tcgppc.issimpleref(const ref: treference): boolean;
 
 
       begin
       begin
-        if (ref.base.number = NR_NO) and
-           (ref.index.number <> NR_NO) then
+        if (ref.base = NR_NO) and
+           (ref.index <> NR_NO) then
           internalerror(200208101);
           internalerror(200208101);
         result :=
         result :=
           not(assigned(ref.symbol)) and
           not(assigned(ref.symbol)) and
-          (((ref.index.number = NR_NO) and
+          (((ref.index = NR_NO) and
             (ref.offset >= low(smallint)) and
             (ref.offset >= low(smallint)) and
             (ref.offset <= high(smallint))) or
             (ref.offset <= high(smallint))) or
-           ((ref.index.number <> NR_NO) and
+           ((ref.index <> NR_NO) and
             (ref.offset = 0)));
             (ref.offset = 0)));
       end;
       end;
 
 
@@ -2280,34 +2088,29 @@ const
 
 
        var
        var
          tmpreg: tregister;
          tmpreg: tregister;
-{$ifdef newra}
          orgindex: tregister;
          orgindex: tregister;
          freeindex: boolean;
          freeindex: boolean;
-{$endif newra}
        begin
        begin
          result := false;
          result := false;
-         if (ref.base.number = NR_NO) then
+         if (ref.base = NR_NO) then
            begin
            begin
              ref.base := ref.index;
              ref.base := ref.index;
-             ref.base.number := NR_NO;
+             ref.base := NR_NO;
            end;
            end;
-         if (ref.base.number <> NR_NO) then
+         if (ref.base <> NR_NO) then
            begin
            begin
-             if (ref.index.number <> NR_NO) and
+             if (ref.index <> NR_NO) and
                 ((ref.offset <> 0) or assigned(ref.symbol)) then
                 ((ref.offset <> 0) or assigned(ref.symbol)) then
                begin
                begin
                  result := true;
                  result := true;
-{$ifndef newra}
-                 tmpreg := cg.get_scratch_reg_int(list,OS_INT);
-{$else newra}
                  { references are often freed before they are used. Since we allocate  }
                  { references are often freed before they are used. Since we allocate  }
                  { a register here, we must first reallocate the index register, since }
                  { a register here, we must first reallocate the index register, since }
                  { otherwise it may be overwritten (and it's still used afterwards)    }
                  { otherwise it may be overwritten (and it's still used afterwards)    }
                  freeindex := false;
                  freeindex := false;
-                 if ((ref.index.number shr 8) >= first_supreg) and
-                    ((ref.index.number shr 8) in rg.unusedregsint) then
+                 if (getsupreg(ref.index) >= first_supreg) and
+                    (getsupreg(ref.index) in rg.unusedregsint) then
                    begin
                    begin
-                     rg.getexplicitregisterint(list,ref.index.number);
+                     rg.getexplicitregisterint(list,ref.index);
                      orgindex := ref.index;
                      orgindex := ref.index;
                      freeindex := true;
                      freeindex := true;
                    end;
                    end;
@@ -2325,19 +2128,15 @@ const
                    begin
                    begin
                      list.concat(taicpu.op_reg_reg_reg(
                      list.concat(taicpu.op_reg_reg_reg(
                        A_ADD,tmpreg,ref.base,ref.index));
                        A_ADD,tmpreg,ref.base,ref.index));
-                     ref.index.number := NR_NO;
+                     ref.index := NR_NO;
                    end;
                    end;
                  ref.base := tmpreg;
                  ref.base := tmpreg;
-{$ifdef newra}
                  if freeindex then
                  if freeindex then
-                   begin
-                     rg.ungetregisterint(list,orgindex);
-                   end;
-{$endif newra}
+                   rg.ungetregisterint(list,orgindex);
                end
                end
            end
            end
          else
          else
-           if ref.index.number <> NR_NO then
+           if ref.index <> NR_NO then
              internalerror(200208102);
              internalerror(200208102);
        end;
        end;
 
 
@@ -2420,26 +2219,21 @@ const
         largeOffset: Boolean;
         largeOffset: Boolean;
 
 
       begin
       begin
-        tmpreg.number := NR_NO;
+        tmpreg := NR_NO;
 
 
         if target_info.system = system_powerpc_macos then
         if target_info.system = system_powerpc_macos then
           begin
           begin
             largeOffset:= (cardinal(ref.offset-low(smallint)) >
             largeOffset:= (cardinal(ref.offset-low(smallint)) >
                   high(smallint)-low(smallint));
                   high(smallint)-low(smallint));
 
 
-{$ifndef newra}
-            tmpreg := get_scratch_reg_address(list);
-{$else newra}
             tmpreg := rg.getregisterint(list,OS_ADDR);
             tmpreg := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
             tmpregUsed:= false;
             tmpregUsed:= false;
 
 
             if assigned(ref.symbol) then
             if assigned(ref.symbol) then
               begin //Load symbol's value
               begin //Load symbol's value
                 reference_reset(tmpref);
                 reference_reset(tmpref);
                 tmpref.symbol := ref.symbol;
                 tmpref.symbol := ref.symbol;
-                tmpref.base.enum:= R_INTREGISTER;
-                tmpref.base.number:= NR_RTOC;
+                tmpref.base := NR_RTOC;
                 if macos_direct_globals then
                 if macos_direct_globals then
                   list.concat(taicpu.op_reg_ref(A_LA,tmpreg,tmpref))
                   list.concat(taicpu.op_reg_ref(A_LA,tmpreg,tmpref))
                 else
                 else
@@ -2462,7 +2256,7 @@ const
             if tmpregUsed then
             if tmpregUsed then
               begin
               begin
                 //Add content of base register
                 //Add content of base register
-                if ref.base.number <> NR_NO then
+                if ref.base <> NR_NO then
                   list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg,
                   list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg,
                     ref.base,tmpreg));
                     ref.base,tmpreg));
 
 
@@ -2483,16 +2277,12 @@ const
                (cardinal(ref.offset-low(smallint)) >
                (cardinal(ref.offset-low(smallint)) >
                 high(smallint)-low(smallint)) then
                 high(smallint)-low(smallint)) then
               begin
               begin
-{$ifndef newra}
-                tmpreg := get_scratch_reg_address(list);
-{$else newra}
                 tmpreg := rg.getregisterint(list,OS_ADDR);
                 tmpreg := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
                 reference_reset(tmpref);
                 reference_reset(tmpref);
                 tmpref.symbol := ref.symbol;
                 tmpref.symbol := ref.symbol;
                 tmpref.offset := ref.offset;
                 tmpref.offset := ref.offset;
                 tmpref.symaddr := refs_ha;
                 tmpref.symaddr := refs_ha;
-                if ref.base.number <> NR_NO then
+                if ref.base <> NR_NO then
                   list.concat(taicpu.op_reg_reg_ref(A_ADDIS,tmpreg,
                   list.concat(taicpu.op_reg_reg_ref(A_ADDIS,tmpreg,
                     ref.base,tmpref))
                     ref.base,tmpref))
                 else
                 else
@@ -2505,13 +2295,8 @@ const
               list.concat(taicpu.op_reg_ref(op,reg,ref));
               list.concat(taicpu.op_reg_ref(op,reg,ref));
           end;
           end;
 
 
-
-        if (tmpreg.number <> NR_NO) then
-{$ifndef newra}
-          free_scratch_reg(list,tmpreg);
-{$else newra}
+        if (tmpreg <> NR_NO) then
           rg.ungetregisterint(list,tmpreg);
           rg.ungetregisterint(list,tmpreg);
-{$endif newra}
       end;
       end;
 
 
 
 
@@ -2606,40 +2391,22 @@ const
                     end
                     end
                   else if ((value shr 32) = 0) then
                   else if ((value shr 32) = 0) then
                     begin
                     begin
-{$ifndef newra}
-                      tmpreg := cg.get_scratch_reg_int(list,OS_32);
-{$else newra}
                       tmpreg := rg.getregisterint(list,OS_32);
                       tmpreg := rg.getregisterint(list,OS_32);
-{$endif newra}
                       cg.a_load_const_reg(list,OS_32,cardinal(value),tmpreg);
                       cg.a_load_const_reg(list,OS_32,cardinal(value),tmpreg);
                       list.concat(taicpu.op_reg_reg_reg(ops[issub,2],
                       list.concat(taicpu.op_reg_reg_reg(ops[issub,2],
                         regdst.reglo,regsrc.reglo,tmpreg));
                         regdst.reglo,regsrc.reglo,tmpreg));
-{$ifndef newra}
-                      cg.free_scratch_reg(list,tmpreg);
-{$else newra}
                       rg.ungetregisterint(list,tmpreg);
                       rg.ungetregisterint(list,tmpreg);
-{$endif newra}
                       list.concat(taicpu.op_reg_reg(ops[issub,3],
                       list.concat(taicpu.op_reg_reg(ops[issub,3],
                         regdst.reghi,regsrc.reghi));
                         regdst.reghi,regsrc.reghi));
                     end
                     end
                   else
                   else
                     begin
                     begin
-{$ifndef newra}
-                      tmpreg64.reglo := cg.get_scratch_reg_int(list,OS_32);
-                      tmpreg64.reghi := cg.get_scratch_reg_int(list,OS_32);
-{$else newra}
                       tmpreg64.reglo := rg.getregisterint(list,OS_32);
                       tmpreg64.reglo := rg.getregisterint(list,OS_32);
                       tmpreg64.reghi := rg.getregisterint(list,OS_32);
                       tmpreg64.reghi := rg.getregisterint(list,OS_32);
-{$endif newra}
                       a_load64_const_reg(list,value,tmpreg64);
                       a_load64_const_reg(list,value,tmpreg64);
                       a_op64_reg_reg_reg(list,op,tmpreg64,regsrc,regdst);
                       a_op64_reg_reg_reg(list,op,tmpreg64,regsrc,regdst);
-{$ifndef newra}
-                      cg.free_scratch_reg(list,tmpreg64.reghi);
-                      cg.free_scratch_reg(list,tmpreg64.reglo);
-{$else newra}
                       rg.ungetregisterint(list,tmpreg64.reglo);
                       rg.ungetregisterint(list,tmpreg64.reglo);
                       rg.ungetregisterint(list,tmpreg64.reghi);
                       rg.ungetregisterint(list,tmpreg64.reghi);
-{$endif newra}
                     end
                     end
                 end
                 end
               else
               else
@@ -2661,7 +2428,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.122  2003-08-18 21:27:00  jonas
+  Revision 1.123  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.122.2.1  2003/08/31 21:08:16  peter
+    * first batch of sparc fixes
+
+  Revision 1.122  2003/08/18 21:27:00  jonas
     * some newra optimizations (eliminate lots of moves between registers)
     * some newra optimizations (eliminate lots of moves between registers)
 
 
   Revision 1.121  2003/08/18 11:50:55  olle
   Revision 1.121  2003/08/18 11:50:55  olle

+ 132 - 0
compiler/powerpc/ppcreg.dat

@@ -0,0 +1,132 @@
+;
+; $Id$
+;
+; PowerPC registers
+;
+; layout
+; <name>,<value>,<stdname>,<motname>,<stabidx>
+;
+NR_NO,$00000000,INVALID,INVALID,-1
+
+NR_R0,$01000000,r0,r0,0
+NR_R1,$01000001,r1,r1,1
+NR_R2,$01000002,r2,r2,2
+NR_R3,$01000003,r3,r3,3
+NR_R4,$01000004,r4,r4,4
+NR_R5,$01000005,r5,r5,5
+NR_R6,$01000006,r6,r6,6
+NR_R7,$01000007,r7,r7,7
+NR_R8,$01000008,r8,r8,8
+NR_R9,$01000009,r9,r9,9
+NR_R10,$0100000a,r10,r10,10
+NR_R11,$0100000b,r11,r11,11
+NR_R12,$0100000c,r12,r12,12
+NR_R13,$0100000d,r13,r13,13
+NR_R14,$0100000e,r14,r14,14
+NR_R15,$0100000f,r15,r15,15
+NR_R16,$01000010,r16,r16,16
+NR_R17,$01000011,r17,r17,17
+NR_R18,$01000012,r18,r18,18
+NR_R19,$01000013,r19,r19,19
+NR_R20,$01000014,r20,r20,20
+NR_R21,$01000015,r21,r21,21
+NR_R22,$01000016,r22,r22,22
+NR_R23,$01000017,r23,r23,23
+NR_R24,$01000018,r24,r24,24
+NR_R25,$01000019,r25,r25,25
+NR_R26,$0100001a,r26,r26,26
+NR_R27,$0100001b,r27,r27,27
+NR_R28,$0100001c,r28,r28,28
+NR_R29,$0100001d,r29,r29,29
+NR_R30,$0100001e,r30,r30,30
+NR_R31,$0100001f,r31,r31,31
+
+NR_F0,$02000000,F0,F0,32
+NR_F1,$02000001,F1,F1,33
+NR_F2,$02000002,F2,F2,34
+NR_F3,$02000003,F3,F3,35
+NR_F4,$02000004,F4,F4,36
+NR_F5,$02000005,F5,F5,37
+NR_F6,$02000006,F6,F6,38
+NR_F7,$02000007,F7,F7,39
+NR_F8,$02000008,F8,F8,40
+NR_F9,$02000009,F9,F9,41
+NR_F10,$0200000a,F10,F10,42
+NR_F11,$0200000b,F11,F11,43
+NR_F12,$0200000c,F12,F12,44
+NR_F13,$0200000d,F13,F13,45
+NR_F14,$0200000e,F14,F14,46
+NR_F15,$0200000f,F15,F15,47
+NR_F16,$02000010,F16,F16,48
+NR_F17,$02000011,F17,F17,49
+NR_F18,$02000012,F18,F18,50
+NR_F19,$02000013,F19,F19,51
+NR_F20,$02000014,F20,F20,52
+NR_F21,$02000015,F21,F21,53
+NR_F22,$02000016,F22,F22,54
+NR_F23,$02000017,F23,F23,55
+NR_F24,$02000018,F24,F24,56
+NR_F25,$02000019,F25,F25,57
+NR_F26,$0200001a,F26,F26,58
+NR_F27,$0200001b,F27,F27,59
+NR_F28,$0200001c,F28,F28,60
+NR_F29,$0200001d,F29,F29,61
+NR_F30,$0200001e,F30,F30,62
+NR_F31,$0200001f,F31,F31,63
+
+NR_M0,$03000000,M0,M0,-1
+NR_M1,$03000001,M1,M1,-1
+NR_M2,$03000002,M2,M2,-1
+NR_M3,$03000003,M3,M3,-1
+NR_M4,$03000004,M4,M4,-1
+NR_M5,$03000005,M5,M5,-1
+NR_M6,$03000006,M6,M6,-1
+NR_M7,$03000007,M7,M7,-1
+NR_M8,$03000008,M8,M8,-1
+NR_M9,$03000009,M9,M9,-1
+NR_M10,$0300000a,M10,M10,-1
+NR_M11,$0300000b,M11,M11,-1
+NR_M12,$0300000c,M12,M12,-1
+NR_M13,$0300000d,M13,M13,-1
+NR_M14,$0300000e,M14,M14,-1
+NR_M15,$0300000f,M15,M15,-1
+NR_M16,$03000010,M16,M16,-1
+NR_M17,$03000011,M17,M17,-1
+NR_M18,$03000012,M18,M18,-1
+NR_M19,$03000013,M19,M19,-1
+NR_M20,$03000014,M20,M20,-1
+NR_M21,$03000015,M21,M21,-1
+NR_M22,$03000016,M22,M22,-1
+NR_M23,$03000017,M23,M23,-1
+NR_M24,$03000018,M24,M24,-1
+NR_M25,$03000019,M25,M25,-1
+NR_M26,$0300001a,M26,M26,-1
+NR_M27,$0300001b,M27,M27,-1
+NR_M28,$0300001c,M28,M28,-1
+NR_M29,$0300001d,M29,M29,-1
+NR_M30,$0300001e,M30,M30,-1
+NR_M31,$0300001f,M31,M31,-1
+
+NR_CR,$05000000,CR,CR,-1
+NR_CR0,$05000001,CR0,CR0,68
+NR_CR1,$05000002,CR1,CR1,69
+NR_CR2,$05000003,CR2,CR2,70
+NR_CR3,$05000004,CR3,CR3,71
+NR_CR4,$05000005,CR4,CR4,72
+NR_CR5,$05000006,CR5,CR5,73
+NR_CR6,$05000007,CR6,CR6,74
+NR_CR7,$05000008,CR7,CR7,75
+NR_XER,$05000009,XER,XER,76
+NR_LR,$0500000a,LR,LR,65
+NR_CTR,$0500000b,CTR,CTR,66
+NR_FPSCR,$0500000c,FPSCR,FPSCR,-1
+
+;
+; $Log$
+; Revision 1.2  2003-09-03 15:55:01  peter
+;   * NEWRA branch merged
+;
+; Revision 1.1.2.1  2003/09/02 20:48:22  peter
+;   * powerpc registers
+;
+;

+ 111 - 0
compiler/powerpc/rppccon.inc

@@ -0,0 +1,111 @@
+{ don't edit, this file is generated from ppcreg.dat }
+NR_NO = $00000000;
+NR_R0 = $01000000;
+NR_R1 = $01000001;
+NR_R2 = $01000002;
+NR_R3 = $01000003;
+NR_R4 = $01000004;
+NR_R5 = $01000005;
+NR_R6 = $01000006;
+NR_R7 = $01000007;
+NR_R8 = $01000008;
+NR_R9 = $01000009;
+NR_R10 = $0100000a;
+NR_R11 = $0100000b;
+NR_R12 = $0100000c;
+NR_R13 = $0100000d;
+NR_R14 = $0100000e;
+NR_R15 = $0100000f;
+NR_R16 = $01000010;
+NR_R17 = $01000011;
+NR_R18 = $01000012;
+NR_R19 = $01000013;
+NR_R20 = $01000014;
+NR_R21 = $01000015;
+NR_R22 = $01000016;
+NR_R23 = $01000017;
+NR_R24 = $01000018;
+NR_R25 = $01000019;
+NR_R26 = $0100001a;
+NR_R27 = $0100001b;
+NR_R28 = $0100001c;
+NR_R29 = $0100001d;
+NR_R30 = $0100001e;
+NR_R31 = $0100001f;
+NR_F0 = $02000000;
+NR_F1 = $02000001;
+NR_F2 = $02000002;
+NR_F3 = $02000003;
+NR_F4 = $02000004;
+NR_F5 = $02000005;
+NR_F6 = $02000006;
+NR_F7 = $02000007;
+NR_F8 = $02000008;
+NR_F9 = $02000009;
+NR_F10 = $0200000a;
+NR_F11 = $0200000b;
+NR_F12 = $0200000c;
+NR_F13 = $0200000d;
+NR_F14 = $0200000e;
+NR_F15 = $0200000f;
+NR_F16 = $02000010;
+NR_F17 = $02000011;
+NR_F18 = $02000012;
+NR_F19 = $02000013;
+NR_F20 = $02000014;
+NR_F21 = $02000015;
+NR_F22 = $02000016;
+NR_F23 = $02000017;
+NR_F24 = $02000018;
+NR_F25 = $02000019;
+NR_F26 = $0200001a;
+NR_F27 = $0200001b;
+NR_F28 = $0200001c;
+NR_F29 = $0200001d;
+NR_F30 = $0200001e;
+NR_F31 = $0200001f;
+NR_M0 = $03000000;
+NR_M1 = $03000001;
+NR_M2 = $03000002;
+NR_M3 = $03000003;
+NR_M4 = $03000004;
+NR_M5 = $03000005;
+NR_M6 = $03000006;
+NR_M7 = $03000007;
+NR_M8 = $03000008;
+NR_M9 = $03000009;
+NR_M10 = $0300000a;
+NR_M11 = $0300000b;
+NR_M12 = $0300000c;
+NR_M13 = $0300000d;
+NR_M14 = $0300000e;
+NR_M15 = $0300000f;
+NR_M16 = $03000010;
+NR_M17 = $03000011;
+NR_M18 = $03000012;
+NR_M19 = $03000013;
+NR_M20 = $03000014;
+NR_M21 = $03000015;
+NR_M22 = $03000016;
+NR_M23 = $03000017;
+NR_M24 = $03000018;
+NR_M25 = $03000019;
+NR_M26 = $0300001a;
+NR_M27 = $0300001b;
+NR_M28 = $0300001c;
+NR_M29 = $0300001d;
+NR_M30 = $0300001e;
+NR_M31 = $0300001f;
+NR_CR = $05000000;
+NR_CR0 = $05000001;
+NR_CR1 = $05000002;
+NR_CR2 = $05000003;
+NR_CR3 = $05000004;
+NR_CR4 = $05000005;
+NR_CR5 = $05000006;
+NR_CR6 = $05000007;
+NR_CR7 = $05000008;
+NR_XER = $05000009;
+NR_LR = $0500000a;
+NR_CTR = $0500000b;
+NR_FPSCR = $0500000c;

+ 111 - 0
compiler/powerpc/rppcmot.inc

@@ -0,0 +1,111 @@
+{ don't edit, this file is generated from ppcreg.dat }
+'INVALID',
+'r0',
+'r1',
+'r2',
+'r3',
+'r4',
+'r5',
+'r6',
+'r7',
+'r8',
+'r9',
+'r10',
+'r11',
+'r12',
+'r13',
+'r14',
+'r15',
+'r16',
+'r17',
+'r18',
+'r19',
+'r20',
+'r21',
+'r22',
+'r23',
+'r24',
+'r25',
+'r26',
+'r27',
+'r28',
+'r29',
+'r30',
+'r31',
+'F0',
+'F1',
+'F2',
+'F3',
+'F4',
+'F5',
+'F6',
+'F7',
+'F8',
+'F9',
+'F10',
+'F11',
+'F12',
+'F13',
+'F14',
+'F15',
+'F16',
+'F17',
+'F18',
+'F19',
+'F20',
+'F21',
+'F22',
+'F23',
+'F24',
+'F25',
+'F26',
+'F27',
+'F28',
+'F29',
+'F30',
+'F31',
+'M0',
+'M1',
+'M2',
+'M3',
+'M4',
+'M5',
+'M6',
+'M7',
+'M8',
+'M9',
+'M10',
+'M11',
+'M12',
+'M13',
+'M14',
+'M15',
+'M16',
+'M17',
+'M18',
+'M19',
+'M20',
+'M21',
+'M22',
+'M23',
+'M24',
+'M25',
+'M26',
+'M27',
+'M28',
+'M29',
+'M30',
+'M31',
+'CR',
+'CR0',
+'CR1',
+'CR2',
+'CR3',
+'CR4',
+'CR5',
+'CR6',
+'CR7',
+'XER',
+'LR',
+'CTR',
+'FPSCR'

+ 111 - 0
compiler/powerpc/rppcmri.inc

@@ -0,0 +1,111 @@
+{ don't edit, this file is generated from ppcreg.dat }
+97,
+98,
+99,
+100,
+101,
+102,
+103,
+104,
+105,
+108,
+33,
+34,
+43,
+44,
+45,
+46,
+47,
+48,
+49,
+50,
+51,
+52,
+35,
+53,
+54,
+55,
+56,
+57,
+58,
+59,
+60,
+61,
+62,
+36,
+63,
+64,
+37,
+38,
+39,
+40,
+41,
+42,
+109,
+0,
+107,
+65,
+66,
+75,
+76,
+77,
+78,
+79,
+80,
+81,
+82,
+83,
+84,
+67,
+85,
+86,
+87,
+88,
+89,
+90,
+91,
+92,
+93,
+94,
+68,
+95,
+96,
+69,
+70,
+71,
+72,
+73,
+74,
+106,
+1,
+2,
+11,
+12,
+13,
+14,
+15,
+16,
+17,
+18,
+19,
+20,
+3,
+21,
+22,
+23,
+24,
+25,
+26,
+27,
+28,
+29,
+30,
+4,
+31,
+32,
+5,
+6,
+7,
+8,
+9,
+10

+ 2 - 0
compiler/powerpc/rppcnor.inc

@@ -0,0 +1,2 @@
+{ don't edit, this file is generated from ppcreg.dat }
+110

+ 111 - 0
compiler/powerpc/rppcnum.inc

@@ -0,0 +1,111 @@
+{ don't edit, this file is generated from ppcreg.dat }
+$00000000,
+$01000000,
+$01000001,
+$01000002,
+$01000003,
+$01000004,
+$01000005,
+$01000006,
+$01000007,
+$01000008,
+$01000009,
+$0100000a,
+$0100000b,
+$0100000c,
+$0100000d,
+$0100000e,
+$0100000f,
+$01000010,
+$01000011,
+$01000012,
+$01000013,
+$01000014,
+$01000015,
+$01000016,
+$01000017,
+$01000018,
+$01000019,
+$0100001a,
+$0100001b,
+$0100001c,
+$0100001d,
+$0100001e,
+$0100001f,
+$02000000,
+$02000001,
+$02000002,
+$02000003,
+$02000004,
+$02000005,
+$02000006,
+$02000007,
+$02000008,
+$02000009,
+$0200000a,
+$0200000b,
+$0200000c,
+$0200000d,
+$0200000e,
+$0200000f,
+$02000010,
+$02000011,
+$02000012,
+$02000013,
+$02000014,
+$02000015,
+$02000016,
+$02000017,
+$02000018,
+$02000019,
+$0200001a,
+$0200001b,
+$0200001c,
+$0200001d,
+$0200001e,
+$0200001f,
+$03000000,
+$03000001,
+$03000002,
+$03000003,
+$03000004,
+$03000005,
+$03000006,
+$03000007,
+$03000008,
+$03000009,
+$0300000a,
+$0300000b,
+$0300000c,
+$0300000d,
+$0300000e,
+$0300000f,
+$03000010,
+$03000011,
+$03000012,
+$03000013,
+$03000014,
+$03000015,
+$03000016,
+$03000017,
+$03000018,
+$03000019,
+$0300001a,
+$0300001b,
+$0300001c,
+$0300001d,
+$0300001e,
+$0300001f,
+$05000000,
+$05000001,
+$05000002,
+$05000003,
+$05000004,
+$05000005,
+$05000006,
+$05000007,
+$05000008,
+$05000009,
+$0500000a,
+$0500000b,
+$0500000c

+ 111 - 0
compiler/powerpc/rppcrni.inc

@@ -0,0 +1,111 @@
+{ don't edit, this file is generated from ppcreg.dat }
+0,
+1,
+2,
+3,
+4,
+5,
+6,
+7,
+8,
+9,
+10,
+11,
+12,
+13,
+14,
+15,
+16,
+17,
+18,
+19,
+20,
+21,
+22,
+23,
+24,
+25,
+26,
+27,
+28,
+29,
+30,
+31,
+32,
+33,
+34,
+35,
+36,
+37,
+38,
+39,
+40,
+41,
+42,
+43,
+44,
+45,
+46,
+47,
+48,
+49,
+50,
+51,
+52,
+53,
+54,
+55,
+56,
+57,
+58,
+59,
+60,
+61,
+62,
+63,
+64,
+65,
+66,
+67,
+68,
+69,
+70,
+71,
+72,
+73,
+74,
+75,
+76,
+77,
+78,
+79,
+80,
+81,
+82,
+83,
+84,
+85,
+86,
+87,
+88,
+89,
+90,
+91,
+92,
+93,
+94,
+95,
+96,
+97,
+98,
+99,
+100,
+101,
+102,
+103,
+104,
+105,
+106,
+107,
+108,
+109

+ 111 - 0
compiler/powerpc/rppcsri.inc

@@ -0,0 +1,111 @@
+{ don't edit, this file is generated from ppcreg.dat }
+97,
+98,
+99,
+100,
+101,
+102,
+103,
+104,
+105,
+108,
+33,
+34,
+43,
+44,
+45,
+46,
+47,
+48,
+49,
+50,
+51,
+52,
+35,
+53,
+54,
+55,
+56,
+57,
+58,
+59,
+60,
+61,
+62,
+36,
+63,
+64,
+37,
+38,
+39,
+40,
+41,
+42,
+109,
+0,
+107,
+65,
+66,
+75,
+76,
+77,
+78,
+79,
+80,
+81,
+82,
+83,
+84,
+67,
+85,
+86,
+87,
+88,
+89,
+90,
+91,
+92,
+93,
+94,
+68,
+95,
+96,
+69,
+70,
+71,
+72,
+73,
+74,
+106,
+1,
+2,
+11,
+12,
+13,
+14,
+15,
+16,
+17,
+18,
+19,
+20,
+3,
+21,
+22,
+23,
+24,
+25,
+26,
+27,
+28,
+29,
+30,
+4,
+31,
+32,
+5,
+6,
+7,
+8,
+9,
+10

+ 111 - 0
compiler/powerpc/rppcstab.inc

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

+ 111 - 0
compiler/powerpc/rppcstd.inc

@@ -0,0 +1,111 @@
+{ don't edit, this file is generated from ppcreg.dat }
+'INVALID',
+'r0',
+'r1',
+'r2',
+'r3',
+'r4',
+'r5',
+'r6',
+'r7',
+'r8',
+'r9',
+'r10',
+'r11',
+'r12',
+'r13',
+'r14',
+'r15',
+'r16',
+'r17',
+'r18',
+'r19',
+'r20',
+'r21',
+'r22',
+'r23',
+'r24',
+'r25',
+'r26',
+'r27',
+'r28',
+'r29',
+'r30',
+'r31',
+'F0',
+'F1',
+'F2',
+'F3',
+'F4',
+'F5',
+'F6',
+'F7',
+'F8',
+'F9',
+'F10',
+'F11',
+'F12',
+'F13',
+'F14',
+'F15',
+'F16',
+'F17',
+'F18',
+'F19',
+'F20',
+'F21',
+'F22',
+'F23',
+'F24',
+'F25',
+'F26',
+'F27',
+'F28',
+'F29',
+'F30',
+'F31',
+'M0',
+'M1',
+'M2',
+'M3',
+'M4',
+'M5',
+'M6',
+'M7',
+'M8',
+'M9',
+'M10',
+'M11',
+'M12',
+'M13',
+'M14',
+'M15',
+'M16',
+'M17',
+'M18',
+'M19',
+'M20',
+'M21',
+'M22',
+'M23',
+'M24',
+'M25',
+'M26',
+'M27',
+'M28',
+'M29',
+'M30',
+'M31',
+'CR',
+'CR0',
+'CR1',
+'CR2',
+'CR3',
+'CR4',
+'CR5',
+'CR6',
+'CR7',
+'XER',
+'LR',
+'CTR',
+'FPSCR'

+ 24 - 22
compiler/pstatmnt.pas

@@ -44,7 +44,7 @@ implementation
        globtype,globals,verbose,
        globtype,globals,verbose,
        systems,cpuinfo,
        systems,cpuinfo,
        { aasm }
        { aasm }
-       cpubase,aasmbase,aasmtai,aasmcpu,
+       cginfo,cpubase,aasmbase,aasmtai,aasmcpu,
        { symtable }
        { symtable }
        symconst,symbase,symtype,symdef,symsym,symtable,defutil,defcmp,
        symconst,symbase,symtype,symdef,symsym,symtable,defutil,defcmp,
        paramgr,
        paramgr,
@@ -186,10 +186,7 @@ implementation
       begin
       begin
          consume(_CASE);
          consume(_CASE);
          caseexpr:=comp_expr(true);
          caseexpr:=comp_expr(true);
-       { determines result type }
-       {$ifndef newra}
-         rg.cleartempgen;
-       {$endif}
+         { determines result type }
          do_resulttypepass(caseexpr);
          do_resulttypepass(caseexpr);
          casedeferror:=false;
          casedeferror:=false;
          casedef:=caseexpr.resulttype.def;
          casedef:=caseexpr.resulttype.def;
@@ -776,9 +773,7 @@ implementation
       var
       var
         asmstat : tasmnode;
         asmstat : tasmnode;
         Marker  : tai;
         Marker  : tai;
-        reg     : tsuperregister;
-        found   : boolean;
-        hs      : string;
+        reg     : tregister;
       begin
       begin
          Inside_asm_statement:=true;
          Inside_asm_statement:=true;
          case aktasmmode of
          case aktasmmode of
@@ -824,16 +819,13 @@ implementation
               begin
               begin
                 repeat
                 repeat
                   { it's possible to specify the modified registers }
                   { it's possible to specify the modified registers }
-                  hs:=upper(pattern);
-                  found:=false;
-                  for reg:=first_supreg to last_supreg do
-                   if hs=upper(supreg_name(reg)) then
+                  reg:=std_regnum_search(lower(pattern));
+                  if reg<>NR_NO then
                     begin
                     begin
-                      include(rg.used_in_proc_int,reg);
-                      found:=true;
-                      break;
-                    end;
-                  if not(found) then
+                      if getregtype(reg)=R_INTREGISTER then
+                        include(rg.used_in_proc_int,getsupreg(reg));
+                    end
+                  else
                     Message(asmr_e_invalid_register);
                     Message(asmr_e_invalid_register);
                   consume(_CSTRING);
                   consume(_CSTRING);
                   if not try_to_consume(_COMMA) then
                   if not try_to_consume(_COMMA) then
@@ -1072,8 +1064,7 @@ implementation
         i : longint;
         i : longint;
       begin
       begin
         { replace framepointer with stackpointer }
         { replace framepointer with stackpointer }
-        current_procinfo.framepointer.enum:=R_INTREGISTER;
-        current_procinfo.framepointer.number:=NR_STACK_POINTER_REG;
+        current_procinfo.framepointer:=NR_STACK_POINTER_REG;
         { set the right value for parameters }
         { set the right value for parameters }
         dec(current_procinfo.procdef.parast.address_fixup,pointer_size);
         dec(current_procinfo.procdef.parast.address_fixup,pointer_size);
         { replace all references to parameters in the instructions,
         { replace all references to parameters in the instructions,
@@ -1096,8 +1087,7 @@ implementation
                        ref_parafixup :
                        ref_parafixup :
                          begin
                          begin
                            ref^.offsetfixup:=parafixup;
                            ref^.offsetfixup:=parafixup;
-                           ref^.base.enum:=R_INTREGISTER;
-                           ref^.base.number:=NR_STACK_POINTER_REG;
+                           ref^.base:=NR_STACK_POINTER_REG;
                          end;
                          end;
                      end;
                      end;
                    end;
                    end;
@@ -1191,7 +1181,19 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.106  2003-07-08 21:24:59  peter
+  Revision 1.107  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.106.2.3  2003/08/31 15:46:26  peter
+    * more updates for tregister
+
+  Revision 1.106.2.2  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.106.2.1  2003/08/28 18:35:08  peter
+    * tregister changed to cardinal
+
+  Revision 1.106  2003/07/08 21:24:59  peter
     * sparc fixes
     * sparc fixes
 
 
   Revision 1.105  2003/06/17 16:34:44  jonas
   Revision 1.105  2003/06/17 16:34:44  jonas

+ 10 - 14
compiler/psub.pas

@@ -646,7 +646,6 @@ implementation
         else
         else
           aktproccode.concatlist(templist);
           aktproccode.concatlist(templist);
 
 
-{$ifdef newra}
         { note: this must be done only after as much code as possible has  }
         { note: this must be done only after as much code as possible has  }
         {   been generated. The result is that when you ungetregister() a  }
         {   been generated. The result is that when you ungetregister() a  }
         {   regvar, it will actually free the regvar (and alse free the    }
         {   regvar, it will actually free the regvar (and alse free the    }
@@ -657,7 +656,6 @@ implementation
         {   gen_entry_code (that one has to be able to allocate the        }
         {   gen_entry_code (that one has to be able to allocate the        }
         {   regvars again) (JM)                                            }
         {   regvars again) (JM)                                            }
         free_regvars(aktproccode);
         free_regvars(aktproccode);
-{$endif newra}
 
 
         { add code that will load the return value, this is not done
         { add code that will load the return value, this is not done
           for assembler routines when they didn't reference the result
           for assembler routines when they didn't reference the result
@@ -678,14 +676,11 @@ implementation
 
 
         { The procedure body is finished, we can now
         { The procedure body is finished, we can now
           allocate the registers }
           allocate the registers }
-{$ifdef newra}
 {$ifdef ra_debug2}
 {$ifdef ra_debug2}
         rg.writegraph;
         rg.writegraph;
-{$endif}
 {$endif}
 {$endif}
         if not(cs_no_regalloc in aktglobalswitches) then
         if not(cs_no_regalloc in aktglobalswitches) then
           begin
           begin
-{$ifdef newra}
             {Do register allocation.}
             {Do register allocation.}
             repeat
             repeat
               rg.prepare_colouring;
               rg.prepare_colouring;
@@ -693,19 +688,17 @@ implementation
               rg.epilogue_colouring;
               rg.epilogue_colouring;
             until (rg.spillednodes='') or not rg.spill_registers(aktproccode,rg.spillednodes);
             until (rg.spillednodes='') or not rg.spill_registers(aktproccode,rg.spillednodes);
             aktproccode.translate_registers(rg.colour);
             aktproccode.translate_registers(rg.colour);
-{$else newra}
+(*
 {$ifndef NoOpt}
 {$ifndef NoOpt}
             if (cs_optimize in aktglobalswitches) and
             if (cs_optimize in aktglobalswitches) and
             { do not optimize pure assembler procedures }
             { do not optimize pure assembler procedures }
                not(pi_is_assembler in current_procinfo.flags)  then
                not(pi_is_assembler in current_procinfo.flags)  then
               optimize(aktproccode);
               optimize(aktproccode);
 {$endif NoOpt}
 {$endif NoOpt}
-{$endif newra}
+*)
           end;
           end;
 
 
-{$ifdef newra}
         translate_regvars(aktproccode,rg.colour);
         translate_regvars(aktproccode,rg.colour);
-{$endif newra}
         { Add stack allocation code after header }
         { Add stack allocation code after header }
         gen_stackalloc_code(templist);
         gen_stackalloc_code(templist);
         aktproccode.insertlistafter(headertai,templist);
         aktproccode.insertlistafter(headertai,templist);
@@ -715,11 +708,7 @@ implementation
 
 
         { now all the registers used are known }
         { now all the registers used are known }
         { Remove all imaginary registers from the used list.}
         { Remove all imaginary registers from the used list.}
-{$ifdef newra}
         procdef.usedintregisters:=rg.used_in_proc_int*VOLATILE_INTREGISTERS-rg.savedintbyproc;
         procdef.usedintregisters:=rg.used_in_proc_int*VOLATILE_INTREGISTERS-rg.savedintbyproc;
-{$else}
-        procdef.usedintregisters:=rg.used_in_proc_int;
-{$endif}
         procdef.usedotherregisters:=rg.used_in_proc_other;
         procdef.usedotherregisters:=rg.used_in_proc_other;
 
 
         { save local data (casetable) also in the same file }
         { save local data (casetable) also in the same file }
@@ -1312,13 +1301,20 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.139  2003-09-03 11:18:37  florian
+  Revision 1.140  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.139  2003/09/03 11:18:37  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.138.2.1  2003/08/31 13:50:16  daniel
+    * Remove sorting and use pregenerated indexes
+    * Some work on making things compile
+
   Revision 1.138  2003/08/20 17:48:49  peter
   Revision 1.138  2003/08/20 17:48:49  peter
     * fixed stackalloc to not allocate localst.datasize twice
     * fixed stackalloc to not allocate localst.datasize twice
     * order of stackalloc code fixed for implicit init/final
     * order of stackalloc code fixed for implicit init/final

+ 5 - 13
compiler/ptconst.pas

@@ -451,11 +451,7 @@ implementation
                         if source_info.endian = target_info.endian then
                         if source_info.endian = target_info.endian then
                           begin
                           begin
                             for l:=0 to p.resulttype.def.size-1 do
                             for l:=0 to p.resulttype.def.size-1 do
-                            {$ifdef oldset}
-                               curconstsegment.concat(tai_const.create_8bit(tsetconstnode(p).value_set^[l]));
-                            {$else}
-                               curconstsegment.concat(tai_const.create_8bit(Psetbytes(tsetconstnode(p).value_set)^[l]));
-                            {$endif}
+                              curconstsegment.concat(tai_const.create_8bit(Psetbytes(tsetconstnode(p).value_set)^[l]));
                           end
                           end
                         else
                         else
                           begin
                           begin
@@ -463,17 +459,10 @@ implementation
                             j:=0;
                             j:=0;
                             for l:=0 to ((p.resulttype.def.size-1) div 4) do
                             for l:=0 to ((p.resulttype.def.size-1) div 4) do
                               begin
                               begin
-                        {$ifdef oldset}
-                                curconstsegment.concat(tai_const.create_8bit(tsetconstnode(p).value_set^[j+3]));
-                                curconstsegment.concat(tai_const.create_8bit(tsetconstnode(p).value_set^[j+2]));
-                                curconstsegment.concat(tai_const.create_8bit(tsetconstnode(p).value_set^[j+1]));
-                                curconstsegment.concat(tai_const.create_8bit(tsetconstnode(p).value_set^[j]));
-                        {$else}
                                 curconstsegment.concat(tai_const.create_8bit(Psetbytes(tsetconstnode(p).value_set)^[j+3]));
                                 curconstsegment.concat(tai_const.create_8bit(Psetbytes(tsetconstnode(p).value_set)^[j+3]));
                                 curconstsegment.concat(tai_const.create_8bit(Psetbytes(tsetconstnode(p).value_set)^[j+2]));
                                 curconstsegment.concat(tai_const.create_8bit(Psetbytes(tsetconstnode(p).value_set)^[j+2]));
                                 curconstsegment.concat(tai_const.create_8bit(Psetbytes(tsetconstnode(p).value_set)^[j+1]));
                                 curconstsegment.concat(tai_const.create_8bit(Psetbytes(tsetconstnode(p).value_set)^[j+1]));
                                 curconstsegment.concat(tai_const.create_8bit(Psetbytes(tsetconstnode(p).value_set)^[j]));
                                 curconstsegment.concat(tai_const.create_8bit(Psetbytes(tsetconstnode(p).value_set)^[j]));
-                        {$endif}
                                 Inc(j,4);
                                 Inc(j,4);
                               end;
                               end;
                           end;
                           end;
@@ -1004,7 +993,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.69  2003-05-09 17:47:03  peter
+  Revision 1.70  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.69  2003/05/09 17:47:03  peter
     * self moved to hidden parameter
     * self moved to hidden parameter
     * removed hdisposen,hnewn,selfn
     * removed hdisposen,hnewn,selfn
 
 

+ 7 - 6
compiler/rautils.pas

@@ -1002,11 +1002,6 @@ Begin
   end;
   end;
   opr.typ := OPR_REFERENCE;
   opr.typ := OPR_REFERENCE;
   Fillchar(opr.ref,sizeof(treference),0);
   Fillchar(opr.ref,sizeof(treference),0);
-{$ifdef i386}
-  opr.ref.segment.enum:=R_INTREGISTER;
-{$endif}
-  opr.ref.index.enum:=R_INTREGISTER;
-  opr.ref.base.enum:=R_INTREGISTER;
 end;
 end;
 
 
 
 
@@ -1560,7 +1555,13 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.64  2003-06-13 21:19:31  peter
+  Revision 1.65  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.64.2.1  2003/08/27 19:55:54  peter
+    * first tregister patch
+
+  Revision 1.64  2003/06/13 21:19:31  peter
     * current_procdef removed, use current_procinfo.procdef instead
     * current_procdef removed, use current_procinfo.procdef instead
 
 
   Revision 1.63  2003/06/06 14:43:29  peter
   Revision 1.63  2003/06/06 14:43:29  peter

+ 62 - 133
compiler/regvars.pas

@@ -39,16 +39,14 @@ interface
     procedure load_regvar(asml: TAAsmoutput; vsym: tvarsym);
     procedure load_regvar(asml: TAAsmoutput; vsym: tvarsym);
     procedure load_regvar_reg(asml: TAAsmoutput; reg: tregister);
     procedure load_regvar_reg(asml: TAAsmoutput; reg: tregister);
     procedure load_all_regvars(asml: TAAsmoutput);
     procedure load_all_regvars(asml: TAAsmoutput);
-{$ifdef newra}
    procedure free_regvars(list: taasmoutput);
    procedure free_regvars(list: taasmoutput);
    procedure translate_regvars(list: taasmoutput; const table:Ttranstable);
    procedure translate_regvars(list: taasmoutput; const table:Ttranstable);
-{$endif newra}
 
 
 {$ifdef i386}
 {$ifdef i386}
     procedure sync_regvars_other(list1, list2: taasmoutput; const regvarsloaded1,
     procedure sync_regvars_other(list1, list2: taasmoutput; const regvarsloaded1,
       regvarsloaded2: regvarother_booleanarray);
       regvarsloaded2: regvarother_booleanarray);
     procedure sync_regvars_int(list1, list2: taasmoutput; const regvarsloaded1,
     procedure sync_regvars_int(list1, list2: taasmoutput; const regvarsloaded1,
-      regvarsloaded2: Tsupregset);
+      regvarsloaded2: Tsuperregisterset);
 {$endif i386}
 {$endif i386}
 
 
 implementation
 implementation
@@ -151,7 +149,6 @@ implementation
       regvarinfo: pregvarinfo;
       regvarinfo: pregvarinfo;
       i: longint;
       i: longint;
       parasym : boolean;
       parasym : boolean;
-      r : Tregister;
       siz : tcgsize;
       siz : tcgsize;
     begin
     begin
       { max. optimizations     }
       { max. optimizations     }
@@ -174,69 +171,27 @@ implementation
               symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}searchregvars,@parasym);
               symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}searchregvars,@parasym);
               { copy parameter into a register ? }
               { copy parameter into a register ? }
               parasym:=true;
               parasym:=true;
-{$ifndef newra}
-{$ifndef i386}
-              if (pi_do_call in current_procinfo.flags) then
-{$endif not i386}
-{$endif not newra}
-                begin
-                  symtablestack.next.foreach_static({$ifdef FPCPROCVAR}@{$endif}searchregvars,@parasym);
-                end
-{$ifndef newra}
-{$ifndef i386}
-              else
-                begin
-                  hp:=tparaitem(current_procinfo.procdef.para.first);
-                  while assigned(hp) do
-                    begin
-                      if (hp.paraloc[calleeside].loc in [LOC_REGISTER,LOC_FPUREGISTER,
-                            LOC_CREGISTER,LOC_CFPUREGISTER]) and
-                         (TCGSize2Size[hp.paraloc[calleeside].size] <= sizeof(aword)) then
-                        begin
-                          tvarsym(hp.parasym).reg := hp.paraloc[calleeside].register;
-                          if (hp.paraloc[calleeside].loc in [LOC_REGISTER,LOC_CREGISTER]) then
-                            rg.makeregvarint(hp.paraloc[calleeside].register.number shr 8)
-                          else
-                            rg.makeregvarother(hp.paraloc[calleeside].register);
-                        end
-                      else
-                        begin
-                          searchregvars(hp.parasym,@parasym);
-                          searchfpuregvars(hp.parasym,@parasym);
-                        end;
-                    hp := tparaitem(hp.next);
-                  end;
-                end
-{$endif not i386}
-{$endif not newra}
-              ;
+              symtablestack.next.foreach_static({$ifdef FPCPROCVAR}@{$endif}searchregvars,@parasym);
               { hold needed registers free }
               { hold needed registers free }
-              for i:=maxvarregs downto maxvarregs-p.registers32+1{$ifdef newra}-maxintscratchregs{$endif newra} do
+              for i:=maxvarregs downto maxvarregs-p.registers32+1-maxintscratchregs do
                 begin
                 begin
                   regvarinfo^.regvars[i]:=nil;
                   regvarinfo^.regvars[i]:=nil;
                   regvarinfo^.regvars_para[i] := false;
                   regvarinfo^.regvars_para[i] := false;
                 end;
                 end;
               { now assign register }
               { now assign register }
-              for i:=1 to maxvarregs-p.registers32{$ifdef newra}-maxintscratchregs{$endif newra} do
+              for i:=1 to maxvarregs-p.registers32-maxintscratchregs do
                 begin
                 begin
                   if assigned(regvarinfo^.regvars[i]) and
                   if assigned(regvarinfo^.regvars[i]) and
-{$ifdef newra}
                     { currently we assume we can use volatile registers for all }
                     { currently we assume we can use volatile registers for all }
                     { regvars if procedure does no call                         }
                     { regvars if procedure does no call                         }
                      (not(pi_do_call in current_procinfo.flags) or
                      (not(pi_do_call in current_procinfo.flags) or
                     { otherwise, demand some (arbitrary) minimum usage }
                     { otherwise, demand some (arbitrary) minimum usage }
                       (regvarinfo^.regvars[i].refs > 100)) then
                       (regvarinfo^.regvars[i].refs > 100)) then
-{$else newra}
-                     (rg.reg_pushes_int[varregs[i]] < regvarinfo^.regvars[i].refs) then
-{$endif newra}
                     begin
                     begin
                       { register is no longer available for }
                       { register is no longer available for }
                       { expressions                          }
                       { expressions                          }
                       { search the register which is the most }
                       { search the register which is the most }
                       { unused                                }
                       { unused                                }
-{$ifndef newra}
-                      rg.makeregvarint(varregs[i]);
-{$endif newra}
 
 
                       { call by reference/const ? }
                       { call by reference/const ? }
                       if (regvarinfo^.regvars[i].varspez in [vs_var,vs_out]) or
                       if (regvarinfo^.regvars[i].varspez in [vs_var,vs_out]) or
@@ -254,19 +209,10 @@ implementation
                       else
                       else
                         siz:=OS_32;
                         siz:=OS_32;
 
 
-{$ifdef newra}
                       { allocate a register for this regvar }
                       { allocate a register for this regvar }
                       regvarinfo^.regvars[i].reg:=rg.getregisterint(exprasmlist,siz);
                       regvarinfo^.regvars[i].reg:=rg.getregisterint(exprasmlist,siz);
                       { and make sure it can't be freed }
                       { and make sure it can't be freed }
-                      rg.makeregvarint(regvarinfo^.regvars[i].reg.number shr 8);
-{$else newra}
-                      regvarinfo^.regvars[i].reg.enum:=R_INTREGISTER;
-                      regvarinfo^.regvars[i].reg.number:=(varregs[i] shl 8) or cgsize2subreg(siz);
-{$ifdef i386}
-                      { procedure uses this register }
-                      include(rg.used_in_proc_int,varregs[i]);
-{$endif i386}
-{$endif newra}
+                      rg.makeregvarint(getsupreg(regvarinfo^.regvars[i].reg));
                     end
                     end
                   else
                   else
                     begin
                     begin
@@ -318,10 +264,9 @@ implementation
                      begin
                      begin
 {$ifdef i386}
 {$ifdef i386}
                        { reserve place on the FPU stack }
                        { reserve place on the FPU stack }
-                       r.enum:=R_ST0;
-                       regvarinfo^.fpuregvars[i].reg:=trgcpu(rg).correct_fpuregister(r,i);
+                       regvarinfo^.fpuregvars[i].reg:=trgcpu(rg).correct_fpuregister(NR_ST0,i);
 {$else i386}
 {$else i386}
-                       regvarinfo^.fpuregvars[i].reg.enum:=fpuvarregs[i];
+                       regvarinfo^.fpuregvars[i].reg:=fpuvarregs[i];
                        rg.makeregvarother(regvarinfo^.fpuregvars[i].reg);
                        rg.makeregvarother(regvarinfo^.fpuregvars[i].reg);
 {$endif i386}
 {$endif i386}
                      end;
                      end;
@@ -340,18 +285,21 @@ implementation
       hr: treference;
       hr: treference;
       regvarinfo: pregvarinfo;
       regvarinfo: pregvarinfo;
       vsym: tvarsym;
       vsym: tvarsym;
+      regidx : tregisterindex;
+      supreg : tsuperregister;
     begin
     begin
 {$ifdef i386}
 {$ifdef i386}
       regvarinfo := pregvarinfo(current_procinfo.procdef.regvarinfo);
       regvarinfo := pregvarinfo(current_procinfo.procdef.regvarinfo);
       if not assigned(regvarinfo) then
       if not assigned(regvarinfo) then
         exit;
         exit;
-      if reg.enum=R_INTREGISTER then
+      if getregtype(reg)=R_INTREGISTER then
         begin
         begin
+          supreg:=getsupreg(reg);
           for i := 1 to maxvarregs do
           for i := 1 to maxvarregs do
             if assigned(regvarinfo^.regvars[i]) and
             if assigned(regvarinfo^.regvars[i]) and
-               (regvarinfo^.regvars[i].reg.number shr 8 = reg.number shr 8) then
+               (getsupreg(regvarinfo^.regvars[i].reg)=supreg) then
               begin
               begin
-                if (reg.number shr 8) in rg.regvar_loaded_int then
+                if supreg in rg.regvar_loaded_int then
                   begin
                   begin
                     vsym := tvarsym(regvarinfo^.regvars[i]);
                     vsym := tvarsym(regvarinfo^.regvars[i]);
                     { we only have to store the regvar back to memory if it's }
                     { we only have to store the regvar back to memory if it's }
@@ -363,7 +311,7 @@ implementation
                         cg.a_load_reg_ref(asml,cgsize,cgsize,vsym.reg,hr);
                         cg.a_load_reg_ref(asml,cgsize,cgsize,vsym.reg,hr);
                       end;
                       end;
                     asml.concat(tai_regalloc.dealloc(vsym.reg));
                     asml.concat(tai_regalloc.dealloc(vsym.reg));
-                    exclude(rg.regvar_loaded_int,reg.number shr 8);
+                    exclude(rg.regvar_loaded_int,supreg);
                   end;
                   end;
                 break;
                 break;
               end;
               end;
@@ -374,9 +322,10 @@ implementation
             if assigned(regvarinfo^.regvars[i]) then
             if assigned(regvarinfo^.regvars[i]) then
               begin
               begin
                 r:=rg.makeregsize(regvarinfo^.regvars[i].reg,OS_INT);
                 r:=rg.makeregsize(regvarinfo^.regvars[i].reg,OS_INT);
-                if (r.enum = reg.enum) then
+                if (r = reg) then
                   begin
                   begin
-                    if rg.regvar_loaded_other[r.enum] then
+                    regidx:=findreg_by_number(r);
+                    if rg.regvar_loaded_other[regidx] then
                       begin
                       begin
                         vsym := tvarsym(regvarinfo^.regvars[i]);
                         vsym := tvarsym(regvarinfo^.regvars[i]);
                         { we only have to store the regvar back to memory if it's }
                         { we only have to store the regvar back to memory if it's }
@@ -388,7 +337,7 @@ implementation
                             cg.a_load_reg_ref(asml,cgsize,cgsize,vsym.reg,hr);
                             cg.a_load_reg_ref(asml,cgsize,cgsize,vsym.reg,hr);
                           end;
                           end;
                         asml.concat(tai_regalloc.dealloc(vsym.reg));
                         asml.concat(tai_regalloc.dealloc(vsym.reg));
-                        rg.regvar_loaded_other[r.enum] := false;
+                        rg.regvar_loaded_other[regidx] := false;
                       end;
                       end;
                     break;
                     break;
                   end;
                   end;
@@ -403,14 +352,15 @@ implementation
       opsize: tcgsize;
       opsize: tcgsize;
       r,
       r,
       reg : tregister;
       reg : tregister;
+      regidx : tregisterindex;
     begin
     begin
 {$ifndef i386}
 {$ifndef i386}
       exit;
       exit;
 {$endif i386}
 {$endif i386}
       reg:=vsym.reg;
       reg:=vsym.reg;
-      if reg.enum=R_INTREGISTER then
+      if getregtype(reg)=R_INTREGISTER then
         begin
         begin
-          if not((reg.number shr 8) in rg.regvar_loaded_int) then
+          if not(getsupreg(reg) in rg.regvar_loaded_int) then
             begin
             begin
               asml.concat(tai_regalloc.alloc(reg));
               asml.concat(tai_regalloc.alloc(reg));
               reference_reset_base(hr,current_procinfo.framepointer,vsym.adjusted_address);
               reference_reset_base(hr,current_procinfo.framepointer,vsym.adjusted_address);
@@ -421,13 +371,14 @@ implementation
               else
               else
                 opsize := def_cgsize(vsym.vartype.def);
                 opsize := def_cgsize(vsym.vartype.def);
               cg.a_load_ref_reg(asml,opsize,opsize,hr,reg);
               cg.a_load_ref_reg(asml,opsize,opsize,hr,reg);
-              include(rg.regvar_loaded_int,reg.number shr 8);
+              include(rg.regvar_loaded_int,getsupreg(reg));
             end;
             end;
         end
         end
       else
       else
         begin
         begin
           r:=rg.makeregsize(reg,OS_INT);
           r:=rg.makeregsize(reg,OS_INT);
-          if not rg.regvar_loaded_other[r.enum] then
+          regidx:=findreg_by_number(r);
+          if not rg.regvar_loaded_other[regidx] then
             begin
             begin
               asml.concat(tai_regalloc.alloc(reg));
               asml.concat(tai_regalloc.alloc(reg));
               reference_reset_base(hr,current_procinfo.framepointer,vsym.adjusted_address);
               reference_reset_base(hr,current_procinfo.framepointer,vsym.adjusted_address);
@@ -438,7 +389,7 @@ implementation
               else
               else
                 opsize := def_cgsize(vsym.vartype.def);
                 opsize := def_cgsize(vsym.vartype.def);
               cg.a_load_ref_reg(asml,opsize,opsize,hr,reg);
               cg.a_load_ref_reg(asml,opsize,opsize,hr,reg);
-              rg.regvar_loaded_other[r.enum] := true;
+              rg.regvar_loaded_other[regidx] := true;
             end;
             end;
         end;
         end;
     end;
     end;
@@ -448,25 +399,25 @@ implementation
       i: longint;
       i: longint;
       regvarinfo: pregvarinfo;
       regvarinfo: pregvarinfo;
       reg_spare : tregister;
       reg_spare : tregister;
+      supreg : tsuperregister;
     begin
     begin
       regvarinfo := pregvarinfo(current_procinfo.procdef.regvarinfo);
       regvarinfo := pregvarinfo(current_procinfo.procdef.regvarinfo);
       if not assigned(regvarinfo) then
       if not assigned(regvarinfo) then
         exit;
         exit;
-      if reg.enum=R_INTREGISTER then
+      if getregtype(reg)=R_INTREGISTER then
         begin
         begin
+          supreg:=getsupreg(reg);
           for i := 1 to maxvarregs do
           for i := 1 to maxvarregs do
             if assigned(regvarinfo^.regvars[i]) and
             if assigned(regvarinfo^.regvars[i]) and
-               (regvarinfo^.regvars[i].reg.number shr 8 = reg.number shr 8) then
+               (getsupreg(regvarinfo^.regvars[i].reg) = supreg) then
               load_regvar(asml,tvarsym(regvarinfo^.regvars[i]))
               load_regvar(asml,tvarsym(regvarinfo^.regvars[i]))
         end
         end
       else
       else
         begin
         begin
           reg_spare := rg.makeregsize(reg,OS_INT);
           reg_spare := rg.makeregsize(reg,OS_INT);
-          if reg_spare.enum>lastreg then
-            internalerror(2003010801);
           for i := 1 to maxvarregs do
           for i := 1 to maxvarregs do
             if assigned(regvarinfo^.regvars[i]) and
             if assigned(regvarinfo^.regvars[i]) and
-               (rg.makeregsize(regvarinfo^.regvars[i].reg,OS_INT).enum = reg_spare.enum) then
+               (rg.makeregsize(regvarinfo^.regvars[i].reg,OS_INT) = reg_spare) then
               load_regvar(asml,tvarsym(regvarinfo^.regvars[i]))
               load_regvar(asml,tvarsym(regvarinfo^.regvars[i]))
         end;
         end;
     end;
     end;
@@ -489,7 +440,6 @@ implementation
     var
     var
       i: longint;
       i: longint;
       regvarinfo: pregvarinfo;
       regvarinfo: pregvarinfo;
-      r:Tregister;
     begin
     begin
       if (cs_regvars in aktglobalswitches) and
       if (cs_regvars in aktglobalswitches) and
          not(pi_uses_asm in current_procinfo.flags) and
          not(pi_uses_asm in current_procinfo.flags) and
@@ -499,30 +449,13 @@ implementation
           { can happen when inlining assembler procedures (JM) }
           { can happen when inlining assembler procedures (JM) }
           if not assigned(regvarinfo) then
           if not assigned(regvarinfo) then
             exit;
             exit;
-{$ifndef newra}
-          for i:=1 to maxvarregs do
-            begin
-             if assigned(regvarinfo^.regvars[i]) then
-               begin
-                r:=regvarinfo^.regvars[i].reg;
-                convert_register_to_enum(r);
-                if cs_asm_source in aktglobalswitches then
-                 asml.insert(tai_comment.Create(strpnew(regvarinfo^.regvars[i].name+
-                  ' with weight '+tostr(regvarinfo^.regvars[i].refs)+' assigned to register '+
-                  std_reg2str[r.enum])));
-                Message3(cg_d_register_weight,std_reg2str[r.enum],
-                  tostr(regvarinfo^.regvars[i].refs),regvarinfo^.regvars[i].name);
-               end;
-            end;
-{$endif newra}
           for i:=1 to maxfpuvarregs do
           for i:=1 to maxfpuvarregs do
             begin
             begin
               if assigned(regvarinfo^.fpuregvars[i]) then
               if assigned(regvarinfo^.fpuregvars[i]) then
                 begin
                 begin
 {$ifdef i386}
 {$ifdef i386}
-                  r.enum:=R_ST0;
                   { reserve place on the FPU stack }
                   { reserve place on the FPU stack }
-                  regvarinfo^.fpuregvars[i].reg:=trgcpu(rg).correct_fpuregister(r,i-1);
+                  regvarinfo^.fpuregvars[i].reg:=trgcpu(rg).correct_fpuregister(NR_ST0,i-1);
                   asml.concat(Taicpu.op_none(A_FLDZ,S_NO));
                   asml.concat(Taicpu.op_none(A_FLDZ,S_NO));
 {$endif i386}
 {$endif i386}
                 end;
                 end;
@@ -540,9 +473,9 @@ implementation
                     if cs_asm_source in aktglobalswitches then
                     if cs_asm_source in aktglobalswitches then
                       asml.insert(tai_comment.Create(strpnew(regvarinfo^.fpuregvars[i].name+
                       asml.insert(tai_comment.Create(strpnew(regvarinfo^.fpuregvars[i].name+
                         ' with weight '+tostr(regvarinfo^.fpuregvars[i].refs)+' assigned to register '+
                         ' with weight '+tostr(regvarinfo^.fpuregvars[i].refs)+' assigned to register '+
-                        std_reg2str[regvarinfo^.fpuregvars[i].reg.enum])));
+                        std_regname(regvarinfo^.fpuregvars[i].reg))));
                     if (status.verbosity and v_debug)=v_debug then
                     if (status.verbosity and v_debug)=v_debug then
-                      Message3(cg_d_register_weight,std_reg2str[regvarinfo^.fpuregvars[i].reg.enum],
+                      Message3(cg_d_register_weight,std_regname(regvarinfo^.fpuregvars[i].reg),
                         tostr(regvarinfo^.fpuregvars[i].refs),regvarinfo^.fpuregvars[i].name);
                         tostr(regvarinfo^.fpuregvars[i].refs),regvarinfo^.fpuregvars[i].name);
                  end;
                  end;
             end;
             end;
@@ -555,14 +488,14 @@ implementation
     procedure sync_regvars_other(list1, list2: taasmoutput; const regvarsloaded1,
     procedure sync_regvars_other(list1, list2: taasmoutput; const regvarsloaded1,
       regvarsloaded2: regvarother_booleanarray);
       regvarsloaded2: regvarother_booleanarray);
     var
     var
-      counter: tregister;
+      counter: tregisterindex;
     begin
     begin
-      for counter.enum := low(rg.regvar_loaded_other) to high(rg.regvar_loaded_other) do
+      for counter := low(rg.regvar_loaded_other) to high(rg.regvar_loaded_other) do
         begin
         begin
-           rg.regvar_loaded_other[counter.enum] := regvarsloaded1[counter.enum] and
-             regvarsloaded2[counter.enum];
-           if regvarsloaded1[counter.enum] xor regvarsloaded2[counter.enum] then
-             if regvarsloaded1[counter.enum] then
+           rg.regvar_loaded_other[counter] := regvarsloaded1[counter] and
+             regvarsloaded2[counter];
+           if regvarsloaded1[counter] xor regvarsloaded2[counter] then
+             if regvarsloaded1[counter] then
                load_regvar_reg(list2,counter)
                load_regvar_reg(list2,counter)
              else
              else
                load_regvar_reg(list1,counter);
                load_regvar_reg(list1,counter);
@@ -571,15 +504,14 @@ implementation
 
 
 
 
     procedure sync_regvars_int(list1, list2: taasmoutput; const regvarsloaded1,
     procedure sync_regvars_int(list1, list2: taasmoutput; const regvarsloaded1,
-      regvarsloaded2: Tsupregset);
+      regvarsloaded2: Tsuperregisterset);
     var
     var
       i : longint;
       i : longint;
       r : tregister;
       r : tregister;
     begin
     begin
       for i:=1 to maxvarregs do
       for i:=1 to maxvarregs do
         begin
         begin
-          r.enum:=R_INTREGISTER;
-          r.number:=varregs[i] shl 8;
+          r:=newreg(R_INTREGISTER,varregs[i],R_SUBWHOLE);
           if (varregs[i] in regvarsloaded1) and
           if (varregs[i] in regvarsloaded1) and
              not(varregs[i] in regvarsloaded2) then
              not(varregs[i] in regvarsloaded2) then
             load_regvar_reg(list2,r)
             load_regvar_reg(list2,r)
@@ -595,7 +527,8 @@ implementation
     procedure cleanup_regvars(asml: TAAsmoutput);
     procedure cleanup_regvars(asml: TAAsmoutput);
     var
     var
       i: longint;
       i: longint;
-      r,reg : tregister;
+      reg : tregister;
+      regidx : tregisterindex;
     begin
     begin
       { can happen when inlining assembler procedures (JM) }
       { can happen when inlining assembler procedures (JM) }
       if not assigned(current_procinfo.procdef.regvarinfo) then
       if not assigned(current_procinfo.procdef.regvarinfo) then
@@ -606,32 +539,24 @@ implementation
         with pregvarinfo(current_procinfo.procdef.regvarinfo)^ do
         with pregvarinfo(current_procinfo.procdef.regvarinfo)^ do
           begin
           begin
 {$ifdef i386}
 {$ifdef i386}
-            r.enum:=R_ST0;
             for i:=1 to maxfpuvarregs do
             for i:=1 to maxfpuvarregs do
               if assigned(fpuregvars[i]) then
               if assigned(fpuregvars[i]) then
                 { ... and clean it up }
                 { ... and clean it up }
-                asml.concat(Taicpu.op_reg(A_FSTP,S_NO,r));
+                asml.concat(Taicpu.op_reg(A_FSTP,S_NO,NR_ST0));
 {$endif i386}
 {$endif i386}
             for i := 1 to maxvarregs do
             for i := 1 to maxvarregs do
              begin
              begin
                if assigned(regvars[i]) then
                if assigned(regvars[i]) then
                 begin
                 begin
                   reg:=regvars[i].reg;
                   reg:=regvars[i].reg;
-                  if reg.enum=R_INTREGISTER then
+                  if getregtype(reg)=R_INTREGISTER then
                     begin
                     begin
-{$ifndef newra}
-                      if (reg.number shr 8 in rg.regvar_loaded_int) then
-                       asml.concat(tai_regalloc.dealloc(reg));
-{$endif newra}
                     end
                     end
                   else
                   else
                     begin
                     begin
-                      reg.number:=(reg.number and not $ff) or cgsize2subreg(OS_INT);
-                      r:=reg;
-                      convert_register_to_enum(r);
-                      if r.enum>lastreg then
-                        internalerror(200201081);
-                      if (rg.regvar_loaded_other[r.enum]) then
+                      setsubreg(reg,cgsize2subreg(OS_INT));
+                      regidx:=findreg_by_number(reg);
+                      if (rg.regvar_loaded_other[regidx]) then
                        asml.concat(tai_regalloc.dealloc(reg));
                        asml.concat(tai_regalloc.dealloc(reg));
                     end;
                     end;
                 end;
                 end;
@@ -640,7 +565,6 @@ implementation
     end;
     end;
 
 
 
 
-{$ifdef newra}
     procedure free_regvars(list: taasmoutput);
     procedure free_regvars(list: taasmoutput);
       var
       var
         i: longint;
         i: longint;
@@ -653,7 +577,7 @@ implementation
               (regvars[i] <> tvarsym(current_procinfo.procdef.funcretsym))} then
               (regvars[i] <> tvarsym(current_procinfo.procdef.funcretsym))} then
               begin
               begin
                 { make sure the unget isn't just a nop }
                 { make sure the unget isn't just a nop }
-                exclude(rg.is_reg_var_int,regvars[i].reg.number shr 8);
+                exclude(rg.is_reg_var_int,getsupreg(regvars[i].reg));
                 rg.ungetregisterint(list,regvars[i].reg);
                 rg.ungetregisterint(list,regvars[i].reg);
               end;
               end;
       end;
       end;
@@ -671,26 +595,31 @@ implementation
             if assigned(regvars[i]) { and
             if assigned(regvars[i]) { and
               (regvars[i] <> tvarsym(current_procinfo.procdef.funcretsym))} then
               (regvars[i] <> tvarsym(current_procinfo.procdef.funcretsym))} then
               begin
               begin
-                regvars[i].reg.number :=
-                  (regvars[i].reg.number and $ff) or
-                  (table[regvars[i].reg.number shr 8] shl 8);
+                setsupreg(regvars[i].reg,getsupreg(table[getsupreg(regvars[i].reg)]));
                 r:=regvars[i].reg;
                 r:=regvars[i].reg;
-                convert_register_to_enum(r);
                 if cs_asm_source in aktglobalswitches then
                 if cs_asm_source in aktglobalswitches then
                  list.insert(tai_comment.Create(strpnew(regvars[i].name+
                  list.insert(tai_comment.Create(strpnew(regvars[i].name+
                   ' with weight '+tostr(regvars[i].refs)+' assigned to register '+
                   ' with weight '+tostr(regvars[i].refs)+' assigned to register '+
-                  std_reg2str[r.enum])));
-                Message3(cg_d_register_weight,std_reg2str[r.enum],
+                  std_regname(r))));
+                Message3(cg_d_register_weight,std_regname(r),
                   tostr(regvars[i].refs),regvars[i].name);
                   tostr(regvars[i].refs),regvars[i].name);
               end;
               end;
       end;
       end;
-{$endif newra}
 
 
 end.
 end.
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.62  2003-08-17 20:47:47  daniel
+  Revision 1.63  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.62.2.2  2003/08/29 17:28:59  peter
+    * next batch of updates
+
+  Revision 1.62.2.1  2003/08/28 18:35:08  peter
+    * tregister changed to cardinal
+
+  Revision 1.62  2003/08/17 20:47:47  daniel
     * Notranslation changed into -sr functionality
     * Notranslation changed into -sr functionality
 
 
   Revision 1.61  2003/08/17 16:59:20  jonas
   Revision 1.61  2003/08/17 16:59:20  jonas

File diff suppressed because it is too large
+ 138 - 435
compiler/rgobj.pas


+ 59 - 268
compiler/sparc/aasmcpu.pas

@@ -29,7 +29,7 @@ interface
 uses
 uses
   cclasses,aasmtai,
   cclasses,aasmtai,
   aasmbase,globals,verbose,
   aasmbase,globals,verbose,
-  cpubase,cpuinfo;
+  cginfo,cpubase,cpuinfo;
 
 
     const
     const
       { "mov reg,reg" source operand number }
       { "mov reg,reg" source operand number }
@@ -63,12 +63,12 @@ uses
          { register allocation }
          { register allocation }
          function is_nop:boolean;override;
          function is_nop:boolean;override;
          function is_move:boolean;override;
          function is_move:boolean;override;
-         function spill_registers(list:Taasmoutput;
-                                  rgget:Trggetproc;
-                                  rgunget:Trgungetproc;
-                                  r:Tsupregset;
-                                  var unusedregsint:Tsupregset;
-                                  const spilltemplist:Tspill_temp_list):boolean; override;
+
+         { register spilling code }
+         function spilling_decode_loadstore(op: tasmop; var counterpart: tasmop; var wasload: boolean): boolean;override;
+         function spilling_create_loadstore(op: tasmop; r:tregister; const ref:treference): tai;override;
+         function spilling_create_load(const ref:treference;r:tregister): tai;override;
+         function spilling_create_store(r:tregister; const ref:treference): tai;override;
       end;
       end;
 
 
       tai_align = class(tai_align_abstract)
       tai_align = class(tai_align_abstract)
@@ -94,8 +94,6 @@ implementation
     constructor taicpu.op_reg(op : tasmop;_op1 : tregister);
     constructor taicpu.op_reg(op : tasmop;_op1 : tregister);
       begin
       begin
          inherited create(op);
          inherited create(op);
-         if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
-           internalerror(2003031207);
          ops:=1;
          ops:=1;
          loadreg(0,_op1);
          loadreg(0,_op1);
       end;
       end;
@@ -120,10 +118,6 @@ implementation
     constructor taicpu.op_reg_reg(op : tasmop;_op1,_op2 : tregister);
     constructor taicpu.op_reg_reg(op : tasmop;_op1,_op2 : tregister);
       begin
       begin
          inherited create(op);
          inherited create(op);
-         if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
-           internalerror(2003031205);
-         if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
-           internalerror(2003031206);
          ops:=2;
          ops:=2;
          loadreg(0,_op1);
          loadreg(0,_op1);
          loadreg(1,_op2);
          loadreg(1,_op2);
@@ -132,8 +126,6 @@ implementation
     constructor taicpu.op_reg_const(op:tasmop; _op1: tregister; _op2: aword);
     constructor taicpu.op_reg_const(op:tasmop; _op1: tregister; _op2: aword);
       begin
       begin
          inherited create(op);
          inherited create(op);
-         if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
-           internalerror(2003031208);
          ops:=2;
          ops:=2;
          loadreg(0,_op1);
          loadreg(0,_op1);
          loadconst(1,_op2);
          loadconst(1,_op2);
@@ -142,8 +134,6 @@ implementation
      constructor taicpu.op_const_reg(op:tasmop; _op1: aword; _op2: tregister);
      constructor taicpu.op_const_reg(op:tasmop; _op1: aword; _op2: tregister);
       begin
       begin
          inherited create(op);
          inherited create(op);
-         if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
-           internalerror(2003031209);
          ops:=2;
          ops:=2;
          loadconst(0,_op1);
          loadconst(0,_op1);
          loadreg(1,_op2);
          loadreg(1,_op2);
@@ -153,8 +143,6 @@ implementation
     constructor taicpu.op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
     constructor taicpu.op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
       begin
       begin
          inherited create(op);
          inherited create(op);
-         if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
-           internalerror(2003031210);
          ops:=2;
          ops:=2;
          loadreg(0,_op1);
          loadreg(0,_op1);
          loadref(1,_op2);
          loadref(1,_op2);
@@ -164,8 +152,6 @@ implementation
     constructor taicpu.op_ref_reg(op : tasmop;const _op1 : treference;_op2 : tregister);
     constructor taicpu.op_ref_reg(op : tasmop;const _op1 : treference;_op2 : tregister);
       begin
       begin
          inherited create(op);
          inherited create(op);
-         if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
-           internalerror(2003031210);
          ops:=2;
          ops:=2;
          loadref(0,_op1);
          loadref(0,_op1);
          loadreg(1,_op2);
          loadreg(1,_op2);
@@ -175,12 +161,6 @@ implementation
     constructor taicpu.op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
     constructor taicpu.op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
       begin
       begin
          inherited create(op);
          inherited create(op);
-         if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
-           internalerror(2003031211);
-         if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
-           internalerror(2003031212);
-         if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
-           internalerror(2003031213);
          ops:=3;
          ops:=3;
          loadreg(0,_op1);
          loadreg(0,_op1);
          loadreg(1,_op2);
          loadreg(1,_op2);
@@ -191,10 +171,6 @@ implementation
     constructor taicpu.op_reg_ref_reg(op:tasmop;_op1:TRegister;_op2:TReference;_op3:tregister);
     constructor taicpu.op_reg_ref_reg(op:tasmop;_op1:TRegister;_op2:TReference;_op3:tregister);
       begin
       begin
          inherited create(op);
          inherited create(op);
-         if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
-           internalerror(2003031214);
-         if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
-           internalerror(2003031215);
          { only allowed to load the address }
          { only allowed to load the address }
          if not(_op2.symaddr in [refs_lo,refs_hi]) then
          if not(_op2.symaddr in [refs_lo,refs_hi]) then
            internalerror(200305311);
            internalerror(200305311);
@@ -208,10 +184,6 @@ implementation
     constructor taicpu.op_reg_const_reg(op:tasmop;_op1:TRegister;_op2:aword;_op3:tregister);
     constructor taicpu.op_reg_const_reg(op:tasmop;_op1:TRegister;_op2:aword;_op3:tregister);
       begin
       begin
          inherited create(op);
          inherited create(op);
-         if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
-           internalerror(2003031216);
-         if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
-           internalerror(2003031217);
          ops:=3;
          ops:=3;
          loadreg(0,_op1);
          loadreg(0,_op1);
          loadconst(1,_op2);
          loadconst(1,_op2);
@@ -258,242 +230,55 @@ implementation
       end;
       end;
 
 
 
 
-    function taicpu.spill_registers(list:Taasmoutput;
-                             rgget:Trggetproc;
-                             rgunget:Trgungetproc;
-                             r:Tsupregset;
-                             var unusedregsint:Tsupregset;
-                              const spilltemplist:Tspill_temp_list): boolean;
-
-      function decode_loadstore(op: tasmop; var counterpart: tasmop; var wasload: boolean): boolean;
-
-        begin
-          result := true;
-          wasload := true;
-          case op of
-            A_LDSB,
-            A_LDUB :
-              begin
-                counterpart := A_STB;
-              end;
-            A_LDSH,
-            A_LDUH:
-              begin
-                counterpart := A_STH;
-              end;
-            A_LD :
-              begin
-                counterpart := A_ST;
-                wasload := false;
-              end;
-            A_LDD:
-              begin
-                counterpart := A_STD;
-                wasload := false;
-              end;
-            else
-              result := false;
-          end;
-       end;
-
-
-    var i:byte;
-        supreg, reg1, reg2, reg3: Tsuperregister;
-        helpreg:Tregister;
-        helpins:Taicpu;
-        op:Tasmop;
-        pos:Tai;
-        wasload: boolean;
+    function taicpu.spilling_decode_loadstore(op: tasmop; var counterpart: tasmop; var wasload: boolean): boolean;
+      begin
+         result := true;
+         wasload := true;
+         case op of
+           A_LDSB,
+           A_LDUB :
+             begin
+               counterpart := A_STB;
+             end;
+           A_LDSH,
+           A_LDUH:
+             begin
+               counterpart := A_STH;
+             end;
+           A_LD :
+             begin
+               counterpart := A_ST;
+               wasload := false;
+             end;
+           A_LDD:
+             begin
+               counterpart := A_STD;
+               wasload := false;
+             end;
+           else
+             result := false;
+         end;
+      end;
+
 
 
+    function taicpu.spilling_create_loadstore(op: tasmop; r:tregister; const ref:treference): tai;
       begin
       begin
-        spill_registers:=false;
-        if (ops = 2) and
-           (oper[1].typ=top_ref) and
-           { oper[1] can also be ref in case of "lis r3,symbol@ha" or so }
-           decode_loadstore(opcode,op,wasload) then
-          begin
-            { the register that's being stored/loaded }
-            supreg:=oper[0].reg.number shr 8;
-            if supreg in r then
-              begin
-                // Example:
-                //   l?? r20d, 8(r1)   ; r20d must be spilled into -60(r1)
-                //
-                //   Change into:
-                //
-                //   l?? r21d, 8(r1)
-                //   st? r21d, -60(r1)
-                //
-                // And:
-                //
-                //   st? r20d, 8(r1)   ; r20d must be spilled into -60(r1)
-                //
-                //   Change into:
-                //
-                //   l?? r21d, -60(r1)
-                //   st? r21d, 8(r1)
-
-                pos := get_insert_pos(Tai(previous),oper[0].reg.number shr 8,
-                                      oper[1].ref^.base.number shr 8,
-                                      oper[1].ref^.index.number shr 8,
-                                      unusedregsint);
-                rgget(list,pos,0,helpreg);
-                spill_registers := true;
-                if wasload then
-                  begin
-                    helpins := taicpu.op_reg_ref(opcode,helpreg,oper[1].ref^);
-                    loadref(1,spilltemplist[supreg]);
-                    opcode := op;
-                  end
-                else
-                  helpins := taicpu.op_reg_ref(op,helpreg,spilltemplist[supreg]);
-                if pos=nil then
-                  list.insertafter(helpins,list.first)
-                else
-                  list.insertafter(helpins,pos.next);
-                loadreg(0,helpreg);
-                rgunget(list,helpins,helpreg);
-                forward_allocation(tai(helpins.next),unusedregsint);
-{
-                writeln('spilling!');
-                list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
-}
-              end;
-
-            { now the registers used in the reference }
-            { a) base                                 }
-            supreg := oper[1].ref^.base.number shr 8;
-            if supreg in r then
-              begin
-                if wasload then
-                  pos:=get_insert_pos(Tai(previous),oper[1].ref^.index.number shr 8,oper[0].reg.number shr 8,0,unusedregsint)
-                else
-                  pos:=get_insert_pos(Tai(previous),oper[1].ref^.index.number shr 8,0,0,unusedregsint);
-                rgget(list,pos,0,helpreg);
-                spill_registers:=true;
-                helpins:=Taicpu.op_reg_ref(A_LD,helpreg,spilltemplist[supreg]);
-                if pos=nil then
-                  list.insertafter(helpins,list.first)
-                else
-                  list.insertafter(helpins,pos.next);
-                oper[1].ref^.base:=helpreg;
-                rgunget(list,helpins,helpreg);
-                forward_allocation(Tai(helpins.next),unusedregsint);
-{
-                writeln('spilling!');
-                list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
-}
-              end;
-
-            { b) index }
-            supreg := oper[1].ref^.index.number shr 8;
-            if supreg in r then
-              begin
-                if wasload then
-                  pos:=get_insert_pos(Tai(previous),oper[1].ref^.base.number shr 8,oper[0].reg.number shr 8,0,unusedregsint)
-                else
-                  pos:=get_insert_pos(Tai(previous),oper[1].ref^.base.number shr 8,0,0,unusedregsint);
-                rgget(list,pos,0,helpreg);
-                spill_registers:=true;
-                helpins:=Taicpu.op_reg_ref(A_LD,helpreg,spilltemplist[supreg]);
-                if pos=nil then
-                  list.insertafter(helpins,list.first)
-                else
-                  list.insertafter(helpins,pos.next);
-                oper[1].ref^.index:=helpreg;
-                rgunget(list,helpins,helpreg);
-                forward_allocation(Tai(helpins.next),unusedregsint);
-{
-                writeln('spilling!');
-                list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
-}
-              end;
-            { load/store is done }
-            exit;
-          end;
-
-        { all other instructions the compiler generates are the same (I hope):   }
-        { operand 0 is a register and is the destination, the others are sources }
-        { and can be either registers or constants                               }
-        { exception: branches (is_jmp isn't always set for them)                 }
-        if oper[0].typ <> top_reg then
-          exit;
-        reg1 := oper[0].reg.number shr 8;
-        if oper[1].typ = top_reg then
-          reg2 := oper[1].reg.number shr 8
-        else
-          reg2 := 0;
-        if (ops >= 3) and
-           (oper[2].typ = top_reg) then
-          reg3 := oper[2].reg.number shr 8
-        else
-          reg3 := 0;
-
-        supreg:=reg1;
-        if supreg in r then
-          begin
-            // Example:
-            //   add r20d, r21d, r22d   ; r20d must be spilled into -60(r1)
-            //
-            //   Change into:
-            //
-            //   lwz r23d, -60(r1)
-            //   add r23d, r21d, r22d
-            //   stw r23d, -60(r1)
-
-            pos := get_insert_pos(Tai(previous),reg1,reg2,reg3,unusedregsint);
-            rgget(list,pos,0,helpreg);
-            spill_registers := true;
-            helpins := taicpu.op_reg_ref(A_ST,helpreg,spilltemplist[supreg]);
-            list.insertafter(helpins,self);
-            helpins := taicpu.op_reg_ref(A_LD,helpreg,spilltemplist[supreg]);
-            if pos=nil then
-              list.insertafter(helpins,list.first)
-            else
-              list.insertafter(helpins,pos.next);
-            loadreg(0,helpreg);
-            rgunget(list,helpins,helpreg);
-            forward_allocation(tai(helpins.next),unusedregsint);
-{
-            writeln('spilling!');
-            list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
-}
-          end;
-
-        for i := 1 to 2 do
-          if (oper[i].typ = top_reg) then
-            begin
-              supreg:=oper[i].reg.number shr 8;
-              if supreg in r then
-                begin
-                  // Example:
-                  //   add r20d, r21d, r22d   ; r20d must be spilled into -60(r1)
-                  //
-                  //   Change into:
-                  //
-                  //   lwz r23d, -60(r1)
-                  //   add r23d, r21d, r22d
-                  //   stw r23d, -60(r1)
-
-                  pos := get_insert_pos(Tai(previous),reg1,reg2,reg3,unusedregsint);
-                  rgget(list,pos,0,helpreg);
-                  spill_registers := true;
-                  helpins := taicpu.op_reg_ref(A_LD,helpreg,spilltemplist[supreg]);
-                  if pos=nil then
-                    list.insertafter(helpins,list.first)
-                  else
-                    list.insertafter(helpins,pos.next);
-                  loadreg(i,helpreg);
-                  rgunget(list,helpins,helpreg);
-                  forward_allocation(tai(helpins.next),unusedregsint);
-{
-                  writeln('spilling!');
-                  list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
-}
-                end;
-            end;
+        result:=taicpu.op_reg_ref(opcode,r,ref);
+      end;
+
+
+    function taicpu.spilling_create_load(const ref:treference;r:tregister): tai;
+      begin
+        result:=taicpu.op_ref_reg(A_LD,ref,r);
+      end;
+
+
+    function taicpu.spilling_create_store(r:tregister; const ref:treference): tai;
+      begin
+        result:=taicpu.op_reg_ref(A_ST,r,ref);
       end;
       end;
 
 
+
     procedure InitAsm;
     procedure InitAsm;
       begin
       begin
       end;
       end;
@@ -506,7 +291,13 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.31  2003-08-11 21:18:20  peter
+  Revision 1.32  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.31.2.1  2003/08/31 21:08:16  peter
+    * first batch of sparc fixes
+
+  Revision 1.31  2003/08/11 21:18:20  peter
     * start of sparc support for newra
     * start of sparc support for newra
 
 
   Revision 1.30  2003/06/14 14:53:50  jonas
   Revision 1.30  2003/06/14 14:53:50  jonas

+ 90 - 251
compiler/sparc/cgcpu.pas

@@ -78,10 +78,10 @@ interface
         procedure g_stackframe_entry(list:TAasmOutput;localsize:LongInt);override;
         procedure g_stackframe_entry(list:TAasmOutput;localsize:LongInt);override;
         procedure g_restore_all_registers(list:TAasmOutput;accused,acchiused:boolean);override;
         procedure g_restore_all_registers(list:TAasmOutput;accused,acchiused:boolean);override;
         procedure g_restore_frame_pointer(list:TAasmOutput);override;
         procedure g_restore_frame_pointer(list:TAasmOutput);override;
-        procedure g_restore_standard_registers(list:taasmoutput;usedinproc:Tsupregset);override;
+        procedure g_restore_standard_registers(list:taasmoutput;usedinproc:Tsuperregisterset);override;
         procedure g_return_from_proc(list:TAasmOutput;parasize:aword);override;
         procedure g_return_from_proc(list:TAasmOutput;parasize:aword);override;
         procedure g_save_all_registers(list : taasmoutput);override;
         procedure g_save_all_registers(list : taasmoutput);override;
-        procedure g_save_standard_registers(list : taasmoutput; usedinproc : Tsupregset);override;
+        procedure g_save_standard_registers(list : taasmoutput; usedinproc : Tsuperregisterset);override;
         procedure g_concatcopy(list:TAasmOutput;const source,dest:TReference;len:aword;delsource,loadref:boolean);override;
         procedure g_concatcopy(list:TAasmOutput;const source,dest:TReference;len:aword;delsource,loadref:boolean);override;
         class function reg_cgsize(const reg:tregister):tcgsize;override;
         class function reg_cgsize(const reg:tregister):tcgsize;override;
       end;
       end;
@@ -115,13 +115,13 @@ implementation
 
 
     function TCgSparc.IsSimpleRef(const ref:treference):boolean;
     function TCgSparc.IsSimpleRef(const ref:treference):boolean;
       begin
       begin
-        if (ref.base.number=NR_NO) and (ref.index.number<>NR_NO) then
+        if (ref.base=NR_NO) and (ref.index<>NR_NO) then
           InternalError(2002100804);
           InternalError(2002100804);
         result :=not(assigned(ref.symbol))and
         result :=not(assigned(ref.symbol))and
-                  (((ref.index.number = NR_NO) and
+                  (((ref.index = NR_NO) and
                    (ref.offset >= simm13lo) and
                    (ref.offset >= simm13lo) and
                     (ref.offset <= simm13hi)) or
                     (ref.offset <= simm13hi)) or
-                  ((ref.index.number <> NR_NO) and
+                  ((ref.index <> NR_NO) and
                   (ref.offset = 0)));
                   (ref.offset = 0)));
       end;
       end;
 
 
@@ -131,24 +131,19 @@ implementation
         tmpreg : tregister;
         tmpreg : tregister;
         tmpref : treference;
         tmpref : treference;
       begin
       begin
-        tmpreg.enum:=R_INTREGISTER;
-        tmpreg.number:=NR_NO;
+        tmpreg:=NR_NO;
         { Be sure to have a base register }
         { Be sure to have a base register }
-        if (ref.base.number=NR_NO) then
+        if (ref.base=NR_NO) then
           begin
           begin
             ref.base:=ref.index;
             ref.base:=ref.index;
-            ref.index.number:=NR_NO;
+            ref.index:=NR_NO;
           end;
           end;
         { When need to use SETHI, do it first }
         { When need to use SETHI, do it first }
         if assigned(ref.symbol) or
         if assigned(ref.symbol) or
            (ref.offset<simm13lo) or
            (ref.offset<simm13lo) or
            (ref.offset>simm13hi) then
            (ref.offset>simm13hi) then
           begin
           begin
-{$ifdef newra}
             tmpreg:=rg.getregisterint(list,OS_INT);
             tmpreg:=rg.getregisterint(list,OS_INT);
-{$else}
-            tmpreg:=get_scratch_reg_int(list,OS_INT);
-{$endif}
             reference_reset(tmpref);
             reference_reset(tmpref);
             tmpref.symbol:=ref.symbol;
             tmpref.symbol:=ref.symbol;
             tmpref.offset:=ref.offset;
             tmpref.offset:=ref.offset;
@@ -162,39 +157,33 @@ implementation
             ref.offset:=0;
             ref.offset:=0;
             ref.symbol:=nil;
             ref.symbol:=nil;
             { Only an index register or offset is allowed }
             { Only an index register or offset is allowed }
-            if tmpreg.number<>NR_NO then
+            if tmpreg<>NR_NO then
               begin
               begin
-                if (ref.index.number<>NR_NO) then
+                if (ref.index<>NR_NO) then
                   begin
                   begin
                     list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg,ref.index,tmpreg));
                     list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg,ref.index,tmpreg));
                     ref.index:=tmpreg;
                     ref.index:=tmpreg;
                   end
                   end
                 else
                 else
                   begin
                   begin
-                    if ref.base.number<>NR_NO then
+                    if ref.base<>NR_NO then
                       ref.index:=tmpreg
                       ref.index:=tmpreg
                     else
                     else
                       ref.base:=tmpreg;
                       ref.base:=tmpreg;
                   end;
                   end;
               end;
               end;
           end;
           end;
-        if (ref.base.number<>NR_NO) then
+        if (ref.base<>NR_NO) then
           begin
           begin
-            if (ref.index.number<>NR_NO) and
+            if (ref.index<>NR_NO) and
                ((ref.offset<>0) or assigned(ref.symbol)) then
                ((ref.offset<>0) or assigned(ref.symbol)) then
               begin
               begin
-                if tmpreg.number=NR_NO then
-                  begin
-{$ifdef newra}
-                    tmpreg:=rg.getregisterint(list,OS_INT);
-{$else}
-                    tmpreg:=get_scratch_reg_int(list,OS_INT);
-{$endif}
-                  end;
-                if (ref.index.number<>NR_NO) then
+                if tmpreg=NR_NO then
+                  tmpreg:=rg.getregisterint(list,OS_INT);
+                if (ref.index<>NR_NO) then
                   begin
                   begin
                     list.concat(taicpu.op_reg_reg_reg(A_ADD,ref.base,ref.index,tmpreg));
                     list.concat(taicpu.op_reg_reg_reg(A_ADD,ref.base,ref.index,tmpreg));
-                    ref.index.number:=NR_NO;
+                    ref.index:=NR_NO;
                   end;
                   end;
               end;
               end;
           end;
           end;
@@ -202,14 +191,8 @@ implementation
           list.concat(taicpu.op_reg_ref(op,reg,ref))
           list.concat(taicpu.op_reg_ref(op,reg,ref))
         else
         else
           list.concat(taicpu.op_ref_reg(op,ref,reg));
           list.concat(taicpu.op_ref_reg(op,ref,reg));
-        if (tmpreg.number<>NR_NO) then
-          begin
-{$ifdef newra}
-            rg.ungetregisterint(list,tmpreg);
-{$else}
-            free_scratch_reg(list,tmpreg);
-{$endif}
-          end;
+        if (tmpreg<>NR_NO) then
+          rg.ungetregisterint(list,tmpreg);
       end;
       end;
 
 
 
 
@@ -220,19 +203,11 @@ implementation
         if (longint(a)<simm13lo) or
         if (longint(a)<simm13lo) or
            (longint(a)>simm13hi) then
            (longint(a)>simm13hi) then
           begin
           begin
-{$ifdef newra}
             tmpreg:=rg.getregisterint(list,OS_INT);
             tmpreg:=rg.getregisterint(list,OS_INT);
-{$else}
-            tmpreg:=get_scratch_reg_int(list,OS_INT);
-{$endif}
             list.concat(taicpu.op_const_reg(A_SETHI,a shr 10,tmpreg));
             list.concat(taicpu.op_const_reg(A_SETHI,a shr 10,tmpreg));
             list.concat(taicpu.op_reg_const_reg(A_OR,tmpreg,a and aword($3ff),tmpreg));
             list.concat(taicpu.op_reg_const_reg(A_OR,tmpreg,a and aword($3ff),tmpreg));
             list.concat(taicpu.op_reg_reg_reg(op,src,tmpreg,dst));
             list.concat(taicpu.op_reg_reg_reg(op,src,tmpreg,dst));
-{$ifdef newra}
             rg.ungetregisterint(list,tmpreg);
             rg.ungetregisterint(list,tmpreg);
-{$else}
-            free_scratch_reg(list,tmpreg);
-{$endif}
           end
           end
         else
         else
           list.concat(taicpu.op_reg_const_reg(op,src,a,dst));
           list.concat(taicpu.op_reg_const_reg(op,src,a,dst));
@@ -285,18 +260,10 @@ implementation
                 if locpara.reference.offset<92 then
                 if locpara.reference.offset<92 then
                   InternalError(2002081104);
                   InternalError(2002081104);
                 reference_reset_base(ref,locpara.reference.index,locpara.reference.offset);
                 reference_reset_base(ref,locpara.reference.index,locpara.reference.offset);
-{$ifdef newra}
                 tmpreg:=rg.getregisterint(list,OS_INT);
                 tmpreg:=rg.getregisterint(list,OS_INT);
-{$else}
-                tmpreg := get_scratch_reg_int(list,sz);
-{$endif}
                 a_load_ref_reg(list,sz,sz,r,tmpreg);
                 a_load_ref_reg(list,sz,sz,r,tmpreg);
                 a_load_reg_ref(list,sz,sz,tmpreg,ref);
                 a_load_reg_ref(list,sz,sz,tmpreg,ref);
-{$ifdef newra}
                 rg.ungetregisterint(list,tmpreg);
                 rg.ungetregisterint(list,tmpreg);
-{$else}
-                free_scratch_reg(list,tmpreg);
-{$endif}
               end;
               end;
             else
             else
               internalerror(2002081103);
               internalerror(2002081103);
@@ -317,18 +284,10 @@ implementation
               reference_reset(ref);
               reference_reset(ref);
               ref.base := locpara.reference.index;
               ref.base := locpara.reference.index;
               ref.offset := locpara.reference.offset;
               ref.offset := locpara.reference.offset;
-{$ifdef newra}
               tmpreg:=rg.getaddressregister(list);
               tmpreg:=rg.getaddressregister(list);
-{$else}
-              tmpreg := get_scratch_reg_address(list);
-{$endif}
               a_loadaddr_ref_reg(list,r,tmpreg);
               a_loadaddr_ref_reg(list,r,tmpreg);
               a_load_reg_ref(list,OS_ADDR,OS_ADDR,tmpreg,ref);
               a_load_reg_ref(list,OS_ADDR,OS_ADDR,tmpreg,ref);
-{$ifdef newra}
               rg.ungetregisterint(list,tmpreg);
               rg.ungetregisterint(list,tmpreg);
-{$else}
-              free_scratch_reg(list,tmpreg);
-{$endif}
             end;
             end;
           else
           else
             internalerror(2002080701);
             internalerror(2002080701);
@@ -438,18 +397,14 @@ implementation
     {********************** load instructions ********************}
     {********************** load instructions ********************}
 
 
     procedure TCgSparc.a_load_const_reg(list : TAasmOutput;size : TCGSize;a : aword;reg : TRegister);
     procedure TCgSparc.a_load_const_reg(list : TAasmOutput;size : TCGSize;a : aword;reg : TRegister);
-      var
-        zeroreg : tregister;
       begin
       begin
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
         { we don't use the set instruction here because it could be evalutated to two
         { we don't use the set instruction here because it could be evalutated to two
           instructions which would cause problems with the delay slot (FK) }
           instructions which would cause problems with the delay slot (FK) }
         { sethi allows to set the upper 22 bit, so we'll take full advantage of it }
         { sethi allows to set the upper 22 bit, so we'll take full advantage of it }
         if (a and aword($1fff))=0 then
         if (a and aword($1fff))=0 then
           list.concat(taicpu.op_const_reg(A_SETHI,a shr 10,reg))
           list.concat(taicpu.op_const_reg(A_SETHI,a shr 10,reg))
         else if (longint(a)>=simm13lo) and (longint(a)<=simm13hi) then
         else if (longint(a)>=simm13lo) and (longint(a)<=simm13hi) then
-          list.concat(taicpu.op_reg_const_reg(A_OR,zeroreg,a,reg))
+          list.concat(taicpu.op_reg_const_reg(A_OR,NR_G0,a,reg))
         else
         else
           begin
           begin
             list.concat(taicpu.op_const_reg(A_SETHI,a shr 10,reg));
             list.concat(taicpu.op_const_reg(A_SETHI,a shr 10,reg));
@@ -459,15 +414,9 @@ implementation
 
 
 
 
     procedure TCgSparc.a_load_const_ref(list : TAasmOutput;size : tcgsize;a : aword;const ref : TReference);
     procedure TCgSparc.a_load_const_ref(list : TAasmOutput;size : tcgsize;a : aword;const ref : TReference);
-      var
-        zeroreg : Tregister;
       begin
       begin
         if a=0 then
         if a=0 then
-          begin
-            zeroreg.enum:=R_INTREGISTER;
-            zeroreg.number:=NR_G0;
-            a_load_reg_ref(list,size,size,zeroreg,ref);
-          end
+          a_load_reg_ref(list,size,size,NR_G0,ref)
         else
         else
           inherited a_load_const_ref(list,size,a,ref);
           inherited a_load_const_ref(list,size,a,ref);
       end;
       end;
@@ -521,11 +470,7 @@ implementation
 
 
     procedure TCgSparc.a_load_reg_reg(list:TAasmOutput;fromsize,tosize:tcgsize;reg1,reg2:tregister);
     procedure TCgSparc.a_load_reg_reg(list:TAasmOutput;fromsize,tosize:tcgsize;reg1,reg2:tregister);
       begin
       begin
-        if(reg1.enum<>R_INTREGISTER)or(reg1.number=NR_NO) then
-          InternalError(200303101);
-        if(reg2.enum<>R_INTREGISTER)or(reg2.number=NR_NO) then
-          InternalError(200303102);
-        if (reg1.Number<>reg2.Number) or
+        if (reg1<>reg2) or
            (tcgsize2size[tosize]<tcgsize2size[fromsize]) or
            (tcgsize2size[tosize]<tcgsize2size[fromsize]) or
            (
            (
             (tcgsize2size[tosize] = tcgsize2size[fromsize]) and
             (tcgsize2size[tosize] = tcgsize2size[fromsize]) and
@@ -541,7 +486,7 @@ implementation
                 a_op_const_reg_reg(list,OP_AND,tosize,$ffff,reg1,reg2);
                 a_op_const_reg_reg(list,OP_AND,tosize,$ffff,reg1,reg2);
               OS_32,OS_S32:
               OS_32,OS_S32:
                 begin
                 begin
-                  if reg1.number<>reg2.number then
+                  if reg1<>reg2 then
                     list.Concat(taicpu.op_reg_reg(A_MOV,reg1,reg2));
                     list.Concat(taicpu.op_reg_reg(A_MOV,reg1,reg2));
                 end;
                 end;
               else
               else
@@ -554,28 +499,19 @@ implementation
     procedure TCgSparc.a_loadaddr_ref_reg(list : TAasmOutput;const ref : TReference;r : tregister);
     procedure TCgSparc.a_loadaddr_ref_reg(list : TAasmOutput;const ref : TReference;r : tregister);
       var
       var
          tmpref : treference;
          tmpref : treference;
-         zeroreg,
          hreg : tregister;
          hreg : tregister;
       begin
       begin
-        if (ref.base.number=NR_NO) and (ref.index.number<>NR_NO) then
+        if (ref.base=NR_NO) and (ref.index<>NR_NO) then
           internalerror(200306171);
           internalerror(200306171);
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
         { At least big offset (need SETHI), maybe base and maybe index }
         { At least big offset (need SETHI), maybe base and maybe index }
         if assigned(ref.symbol) or
         if assigned(ref.symbol) or
            (ref.offset<simm13lo) or
            (ref.offset<simm13lo) or
            (ref.offset>simm13hi) then
            (ref.offset>simm13hi) then
           begin
           begin
-            if (ref.base.number<>r.number) and (ref.index.number<>r.number) then
+            if (ref.base<>r) and (ref.index<>r) then
               hreg:=r
               hreg:=r
             else
             else
-              begin
-              {$ifdef newra}
-                hreg:=rg.getaddressregister(list);
-              {$else}
-                hreg:=get_scratch_reg_address(list);
-              {$endif}
-              end;
+              hreg:=rg.getaddressregister(list);
             reference_reset(tmpref);
             reference_reset(tmpref);
             tmpref.symbol := ref.symbol;
             tmpref.symbol := ref.symbol;
             tmpref.offset := ref.offset;
             tmpref.offset := ref.offset;
@@ -584,9 +520,9 @@ implementation
             { Only the low part is left }
             { Only the low part is left }
             tmpref.symaddr:=refs_lo;
             tmpref.symaddr:=refs_lo;
             list.concat(taicpu.op_reg_ref_reg(A_OR,hreg,tmpref,hreg));
             list.concat(taicpu.op_reg_ref_reg(A_OR,hreg,tmpref,hreg));
-            if ref.base.number<>NR_NO then
+            if ref.base<>NR_NO then
               begin
               begin
-                if ref.index.number<>NR_NO then
+                if ref.index<>NR_NO then
                   begin
                   begin
                     list.concat(taicpu.op_reg_reg_reg(A_ADD,hreg,ref.base,hreg));
                     list.concat(taicpu.op_reg_reg_reg(A_ADD,hreg,ref.base,hreg));
                     list.concat(taicpu.op_reg_reg_reg(A_ADD,hreg,ref.index,r));
                     list.concat(taicpu.op_reg_reg_reg(A_ADD,hreg,ref.index,r));
@@ -596,60 +532,42 @@ implementation
               end
               end
             else
             else
               begin
               begin
-                if hreg.number<>r.number then
+                if hreg<>r then
                   list.Concat(taicpu.op_reg_reg(A_MOV,hreg,r));
                   list.Concat(taicpu.op_reg_reg(A_MOV,hreg,r));
               end;
               end;
-            if hreg.number<>r.number then
-              begin
-              {$ifdef newra}
-                rg.ungetaddressregister(list,hreg);
-              {$else}
-                free_scratch_reg(list,hreg);
-              {$endif}
-              end;
+            if hreg<>r then
+              rg.ungetaddressregister(list,hreg);
           end
           end
         else
         else
         { At least small offset, maybe base and maybe index }
         { At least small offset, maybe base and maybe index }
           if ref.offset<>0 then
           if ref.offset<>0 then
             begin
             begin
-              if ref.base.number<>NR_NO then
+              if ref.base<>NR_NO then
                 begin
                 begin
-                  if ref.index.number<>NR_NO then
+                  if ref.index<>NR_NO then
                     begin
                     begin
-                      if (ref.base.number<>r.number) and (ref.index.number<>r.number) then
+                      if (ref.base<>r) and (ref.index<>r) then
                         hreg:=r
                         hreg:=r
                       else
                       else
-                        begin
-                        {$ifdef newra}
-                          hreg:=rg.getaddressregister(list);
-                        {$else}
-                          hreg:=get_scratch_reg_address(list);
-                        {$endif}
-                        end;
+                        hreg:=rg.getaddressregister(list);
                       list.concat(taicpu.op_reg_const_reg(A_ADD,ref.base,aword(ref.offset),hreg));
                       list.concat(taicpu.op_reg_const_reg(A_ADD,ref.base,aword(ref.offset),hreg));
                       list.concat(taicpu.op_reg_reg_reg(A_ADD,hreg,ref.index,r));
                       list.concat(taicpu.op_reg_reg_reg(A_ADD,hreg,ref.index,r));
-                      if hreg.number<>r.number then
-                        begin
-                        {$ifdef newra}
-                          rg.ungetaddressregister(list,hreg);
-                        {$else}
-                          free_scratch_reg(list,hreg);
-                        {$endif}
-                        end;
+                      if hreg<>r then
+                        rg.ungetaddressregister(list,hreg);
                     end
                     end
                   else
                   else
                     list.concat(taicpu.op_reg_const_reg(A_ADD,ref.base,aword(ref.offset),r));
                     list.concat(taicpu.op_reg_const_reg(A_ADD,ref.base,aword(ref.offset),r));
                 end
                 end
               else
               else
-                list.concat(taicpu.op_reg_const_reg(A_ADD,zeroreg,aword(ref.offset),r));
+                list.concat(taicpu.op_reg_const_reg(A_ADD,NR_G0,aword(ref.offset),r));
             end
             end
         else
         else
         { Both base and index }
         { Both base and index }
-          if ref.index.number<>NR_NO then
+          if ref.index<>NR_NO then
             list.concat(taicpu.op_reg_reg_reg(A_ADD,ref.base,ref.index,r))
             list.concat(taicpu.op_reg_reg_reg(A_ADD,ref.base,ref.index,r))
         else
         else
         { Only base }
         { Only base }
-          if ref.base.number<>NR_NO then
+          if ref.base<>NR_NO then
             a_load_reg_reg(list,OS_INT,OS_INT,ref.base,r)
             a_load_reg_reg(list,OS_INT,OS_INT,ref.base,r)
         else
         else
           internalerror(200306172);
           internalerror(200306172);
@@ -658,13 +576,13 @@ implementation
 
 
     procedure TCgSparc.a_loadfpu_reg_reg(list:TAasmOutput;size:tcgsize;reg1, reg2:tregister);
     procedure TCgSparc.a_loadfpu_reg_reg(list:TAasmOutput;size:tcgsize;reg1, reg2:tregister);
       begin
       begin
-        if reg1.enum<>reg2.enum then
+        if reg1<>reg2 then
           begin
           begin
             list.concat(taicpu.op_reg_reg(A_FMOVs,reg1,reg2));
             list.concat(taicpu.op_reg_reg(A_FMOVs,reg1,reg2));
             if size=OS_F64 then
             if size=OS_F64 then
               begin
               begin
-                reg1.enum:=succ(reg1.enum);
-                reg2.enum:=succ(reg2.enum);
+                setsupreg(reg1,getsupreg(reg1)+1);
+                setsupreg(reg2,getsupreg(reg2)+1);
                 list.concat(taicpu.op_reg_reg(A_FMOVs,reg1,reg2));
                 list.concat(taicpu.op_reg_reg(A_FMOVs,reg1,reg2));
               end;
               end;
           end;
           end;
@@ -710,15 +628,11 @@ implementation
 
 
 
 
     procedure TCgSparc.a_op_const_reg(list:TAasmOutput;Op:TOpCG;size:tcgsize;a:AWord;reg:TRegister);
     procedure TCgSparc.a_op_const_reg(list:TAasmOutput;Op:TOpCG;size:tcgsize;a:AWord;reg:TRegister);
-      var
-        zeroreg : tregister;
       begin
       begin
         if Op in [OP_NEG,OP_NOT] then
         if Op in [OP_NEG,OP_NOT] then
           internalerror(200306011);
           internalerror(200306011);
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
         if (a=0) then
         if (a=0) then
-          list.concat(taicpu.op_reg_reg_reg(TOpCG2AsmOp[op],reg,zeroreg,reg))
+          list.concat(taicpu.op_reg_reg_reg(TOpCG2AsmOp[op],reg,NR_G0,reg))
         else
         else
           handle_reg_const_reg(list,TOpCG2AsmOp[op],reg,a,reg);
           handle_reg_const_reg(list,TOpCG2AsmOp[op],reg,a,reg);
       end;
       end;
@@ -774,26 +688,18 @@ implementation
   {*************** compare instructructions ****************}
   {*************** compare instructructions ****************}
 
 
     procedure TCgSparc.a_cmp_const_reg_label(list:TAasmOutput;size:tcgsize;cmp_op:topcmp;a:aword;reg:tregister;l:tasmlabel);
     procedure TCgSparc.a_cmp_const_reg_label(list:TAasmOutput;size:tcgsize;cmp_op:topcmp;a:aword;reg:tregister;l:tasmlabel);
-      var
-        zeroreg : tregister;
       begin
       begin
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
         if (a=0) then
         if (a=0) then
-          list.concat(taicpu.op_reg_reg_reg(A_SUBcc,reg,zeroreg,zeroreg))
+          list.concat(taicpu.op_reg_reg_reg(A_SUBcc,reg,NR_G0,NR_G0))
         else
         else
-          handle_reg_const_reg(list,A_SUBcc,reg,a,zeroreg);
+          handle_reg_const_reg(list,A_SUBcc,reg,a,NR_G0);
         a_jmp_cond(list,cmp_op,l);
         a_jmp_cond(list,cmp_op,l);
       end;
       end;
 
 
 
 
     procedure TCgSparc.a_cmp_reg_reg_label(list:TAasmOutput;size:tcgsize;cmp_op:topcmp;reg1,reg2:tregister;l:tasmlabel);
     procedure TCgSparc.a_cmp_reg_reg_label(list:TAasmOutput;size:tcgsize;cmp_op:topcmp;reg1,reg2:tregister;l:tasmlabel);
-      var
-        zeroreg : tregister;
       begin
       begin
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
-        list.concat(taicpu.op_reg_reg_reg(A_SUBcc,reg2,reg1,zeroreg));
+        list.concat(taicpu.op_reg_reg_reg(A_SUBcc,reg2,reg1,NR_G0));
         a_jmp_cond(list,cmp_op,l);
         a_jmp_cond(list,cmp_op,l);
       end;
       end;
 
 
@@ -833,10 +739,8 @@ implementation
     procedure TCgSparc.g_flags2reg(list:TAasmOutput;Size:TCgSize;const f:tresflags;reg:TRegister);
     procedure TCgSparc.g_flags2reg(list:TAasmOutput;Size:TCgSize;const f:tresflags;reg:TRegister);
       var
       var
         ai : taicpu;
         ai : taicpu;
-        r : tregister;
       begin
       begin
-        r.enum:=R_PSR;
-        ai:=Taicpu.Op_reg_reg(A_RDPSR,r,reg);
+        ai:=Taicpu.Op_reg_reg(A_RDPSR,NR_PSR,reg);
 {$warning Need to retrieve the correct flag setting in reg}
 {$warning Need to retrieve the correct flag setting in reg}
 //        ai.SetCondition(flags_to_cond(f));
 //        ai.SetCondition(flags_to_cond(f));
         list.Concat(ai);
         list.Concat(ai);
@@ -871,20 +775,15 @@ implementation
 
 
     procedure tcgsparc.g_save_parent_framepointer_param(list:taasmoutput);
     procedure tcgsparc.g_save_parent_framepointer_param(list:taasmoutput);
       var
       var
-        hreg : tregister;
         href : treference;
         href : treference;
       begin
       begin
         reference_reset_base(href,current_procinfo.framepointer,PARENT_FRAMEPOINTER_OFFSET);
         reference_reset_base(href,current_procinfo.framepointer,PARENT_FRAMEPOINTER_OFFSET);
         { Parent framepointer is always pushed the first parameter (%i0) }
         { Parent framepointer is always pushed the first parameter (%i0) }
-        hreg.enum:=R_INTREGISTER;
-        hreg.number:=NR_I0;
-        a_load_reg_ref(list,OS_ADDR,OS_ADDR,hreg,href);
+        a_load_reg_ref(list,OS_ADDR,OS_ADDR,NR_I0,href);
       end;
       end;
 
 
 
 
     procedure TCgSparc.g_stackframe_entry(list:TAasmOutput;LocalSize:LongInt);
     procedure TCgSparc.g_stackframe_entry(list:TAasmOutput;LocalSize:LongInt);
-      var
-        r : tregister;
       begin
       begin
         { Althogh the SPARC architecture require only word alignment, software
         { Althogh the SPARC architecture require only word alignment, software
           convention and the operating system require every stack frame to be double word
           convention and the operating system require every stack frame to be double word
@@ -894,9 +793,7 @@ implementation
           stack frame. In the "SAVE %i6,size,%i6" the first %i6 is related to the state
           stack frame. In the "SAVE %i6,size,%i6" the first %i6 is related to the state
           before execution of the SAVE instrucion so it is the caller %i6, when the %i6
           before execution of the SAVE instrucion so it is the caller %i6, when the %i6
           after execution of that instruction is the called function stack pointer}
           after execution of that instruction is the called function stack pointer}
-        r.enum:=R_INTREGISTER;
-        r.number:=NR_STACK_POINTER_REG;
-        list.concat(Taicpu.Op_reg_const_reg(A_SAVE,r,aword(-LocalSize),r));
+        list.concat(Taicpu.Op_reg_const_reg(A_SAVE,NR_STACK_POINTER_REG,aword(-LocalSize),NR_STACK_POINTER_REG));
       end;
       end;
 
 
 
 
@@ -913,7 +810,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure TCgSparc.g_restore_standard_registers(list:taasmoutput;usedinproc:Tsupregset);
+    procedure TCgSparc.g_restore_standard_registers(list:taasmoutput;usedinproc:Tsuperregisterset);
       begin
       begin
         { The sparc port uses the sparc standard calling convetions so this function has no used }
         { The sparc port uses the sparc standard calling convetions so this function has no used }
       end;
       end;
@@ -945,7 +842,7 @@ implementation
       end;
       end;
 
 
 
 
-    procedure TCgSparc.g_save_standard_registers(list : taasmoutput; usedinproc:Tsupregset);
+    procedure TCgSparc.g_save_standard_registers(list : taasmoutput; usedinproc:Tsuperregisterset);
       begin
       begin
         { The sparc port uses the sparc standard calling convetions so this function has no used }
         { The sparc port uses the sparc standard calling convetions so this function has no used }
       end;
       end;
@@ -955,12 +852,12 @@ implementation
 
 
     procedure TCgSparc.g_concatcopy(list:taasmoutput;const source,dest:treference;len:aword;delsource,loadref:boolean);
     procedure TCgSparc.g_concatcopy(list:taasmoutput;const source,dest:treference;len:aword;delsource,loadref:boolean);
       var
       var
+        hreg,
         countreg: TRegister;
         countreg: TRegister;
         src, dst: TReference;
         src, dst: TReference;
         lab: tasmlabel;
         lab: tasmlabel;
         count, count2: aword;
         count, count2: aword;
         orgsrc, orgdst: boolean;
         orgsrc, orgdst: boolean;
-        r:Tregister;
       begin
       begin
         if len > high(longint) then
         if len > high(longint) then
           internalerror(2002072704);
           internalerror(2002072704);
@@ -977,13 +874,12 @@ implementation
                 end
                 end
               else
               else
                 begin
                 begin
-                  r.enum:=R_F0;
-                  a_reg_alloc(list,r);
-                  a_loadfpu_ref_reg(list,OS_F64,source,r);
+                  a_reg_alloc(list,NR_F0);
+                  a_loadfpu_ref_reg(list,OS_F64,source,NR_F0);
                   if delsource then
                   if delsource then
                     reference_release(list,source);
                     reference_release(list,source);
-                  a_loadfpu_reg_ref(list,OS_F64,r,dest);
-                  a_reg_dealloc(list,r);
+                  a_loadfpu_reg_ref(list,OS_F64,NR_F0,dest);
+                  a_reg_dealloc(list,NR_F0);
                 end;
                 end;
               exit;
               exit;
             end;
             end;
@@ -993,27 +889,19 @@ implementation
         { load the address of source into src.base }
         { load the address of source into src.base }
         if loadref then
         if loadref then
           begin
           begin
-{$ifdef newra}
             src.base:=rg.getaddressregister(list);
             src.base:=rg.getaddressregister(list);
-{$else}
-            src.base := get_scratch_reg_address(list);
-{$endif}
             a_load_ref_reg(list,OS_32,OS_32,source,src.base);
             a_load_ref_reg(list,OS_32,OS_32,source,src.base);
             orgsrc := false;
             orgsrc := false;
           end
           end
         else
         else
          if not issimpleref(source) or
          if not issimpleref(source) or
             (
             (
-              (source.index.number<>NR_NO) and
+              (source.index<>NR_NO) and
               (((source.offset+longint(len))>simm13hi) or
               (((source.offset+longint(len))>simm13hi) or
                ((source.offset+longint(len))<simm13lo))
                ((source.offset+longint(len))<simm13lo))
             ) then
             ) then
            begin
            begin
-{$ifdef newra}
              src.base:=rg.getaddressregister(list);
              src.base:=rg.getaddressregister(list);
-{$else}
-             src.base := get_scratch_reg_address(list);
-{$endif}
              a_loadaddr_ref_reg(list,source,src.base);
              a_loadaddr_ref_reg(list,source,src.base);
              orgsrc := false;
              orgsrc := false;
            end
            end
@@ -1027,16 +915,12 @@ implementation
           { load the address of dest into dst.base }
           { load the address of dest into dst.base }
         if not issimpleref(dest) or
         if not issimpleref(dest) or
            (
            (
-            (dest.index.number<>NR_NO) and
+            (dest.index<>NR_NO) and
             (((dest.offset + longint(len)) > simm13hi) or
             (((dest.offset + longint(len)) > simm13hi) or
              ((dest.offset + longint(len)) < simm13lo))
              ((dest.offset + longint(len)) < simm13lo))
            ) then
            ) then
           begin
           begin
-{$ifdef newra}
             dst.base:=rg.getaddressregister(list);
             dst.base:=rg.getaddressregister(list);
-{$else}
-            dst.base := get_scratch_reg_address(list);
-{$endif}
             a_loadaddr_ref_reg(list,dest,dst.base);
             a_loadaddr_ref_reg(list,dest,dst.base);
             orgdst := false;
             orgdst := false;
           end
           end
@@ -1057,101 +941,61 @@ implementation
             inc(src.offset,8);
             inc(src.offset,8);
             list.concat(taicpu.op_reg_const_reg(A_SUB,src.base,8,src.base));
             list.concat(taicpu.op_reg_const_reg(A_SUB,src.base,8,src.base));
             list.concat(taicpu.op_reg_const_reg(A_SUB,dst.base,8,dst.base));
             list.concat(taicpu.op_reg_const_reg(A_SUB,dst.base,8,dst.base));
-{$ifdef newra}
             countreg:=rg.getregisterint(list,OS_INT);
             countreg:=rg.getregisterint(list,OS_INT);
-{$else}
-            countreg := get_scratch_reg_int(list,OS_INT);
-{$endif}
             a_load_const_reg(list,OS_INT,count,countreg);
             a_load_const_reg(list,OS_INT,count,countreg);
             { explicitely allocate R_O0 since it can be used safely here }
             { explicitely allocate R_O0 since it can be used safely here }
             { (for holding date that's being copied)                    }
             { (for holding date that's being copied)                    }
-            r.enum:=R_F0;
-            a_reg_alloc(list,r);
+            a_reg_alloc(list,NR_F0);
             objectlibrary.getlabel(lab);
             objectlibrary.getlabel(lab);
             a_label(list, lab);
             a_label(list, lab);
             list.concat(taicpu.op_reg_const_reg(A_SUB,countreg,1,countreg));
             list.concat(taicpu.op_reg_const_reg(A_SUB,countreg,1,countreg));
-            list.concat(taicpu.op_ref_reg(A_LDF,src,r));
-            list.concat(taicpu.op_reg_ref(A_STD,r,dst));
+            list.concat(taicpu.op_ref_reg(A_LDF,src,NR_F0));
+            list.concat(taicpu.op_reg_ref(A_STD,NR_F0,dst));
             //a_jmp(list,A_BC,C_NE,0,lab);
             //a_jmp(list,A_BC,C_NE,0,lab);
-{$ifdef newra}
             rg.ungetregisterint(list,countreg);
             rg.ungetregisterint(list,countreg);
-{$else}
-            free_scratch_reg(list,countreg);
-{$endif}
-            a_reg_dealloc(list,r);
+            a_reg_dealloc(list,NR_F0);
             len := len mod 8;
             len := len mod 8;
           end;
           end;
         { unrolled loop }
         { unrolled loop }
         count:=len and 7;
         count:=len and 7;
         if count>0 then
         if count>0 then
           begin
           begin
-            r.enum:=R_F0;
-            a_reg_alloc(list,r);
+            a_reg_alloc(list,NR_F0);
             for count2 := 1 to count do
             for count2 := 1 to count do
               begin
               begin
-                a_loadfpu_ref_reg(list,OS_F64,src,r);
-                a_loadfpu_reg_ref(list,OS_F64,r,dst);
+                a_loadfpu_ref_reg(list,OS_F64,src,NR_F0);
+                a_loadfpu_reg_ref(list,OS_F64,NR_F0,dst);
                 inc(src.offset,8);
                 inc(src.offset,8);
                 inc(dst.offset,8);
                 inc(dst.offset,8);
               end;
               end;
-            a_reg_dealloc(list,r);
+            a_reg_dealloc(list,NR_F0);
             len := len mod 8;
             len := len mod 8;
           end;
           end;
         if (len and 4) <> 0 then
         if (len and 4) <> 0 then
           begin
           begin
-{$ifdef newra}
-            r:=rg.getregisterint(list,OS_INT);
-{$else}
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_O0;
-            a_reg_alloc(list,r);
-{$endif}
-            a_load_ref_reg(list,OS_32,OS_32,src,r);
-            a_load_reg_ref(list,OS_32,OS_32,r,dst);
+            hreg:=rg.getregisterint(list,OS_INT);
+            a_load_ref_reg(list,OS_32,OS_32,src,hreg);
+            a_load_reg_ref(list,OS_32,OS_32,hreg,dst);
             inc(src.offset,4);
             inc(src.offset,4);
             inc(dst.offset,4);
             inc(dst.offset,4);
-{$ifdef newra}
-            rg.ungetregisterint(list,r);
-{$else}
-            a_reg_dealloc(list,r);
-{$endif}
+            rg.ungetregisterint(list,hreg);
           end;
           end;
         { copy the leftovers }
         { copy the leftovers }
         if (len and 2) <> 0 then
         if (len and 2) <> 0 then
           begin
           begin
-{$ifdef newra}
-            r:=rg.getregisterint(list,OS_INT);
-{$else}
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_O0;
-            a_reg_alloc(list,r);
-{$endif}
-            a_load_ref_reg(list,OS_16,OS_16,src,r);
-            a_load_reg_ref(list,OS_16,OS_16,r,dst);
+            hreg:=rg.getregisterint(list,OS_INT);
+            a_load_ref_reg(list,OS_16,OS_16,src,hreg);
+            a_load_reg_ref(list,OS_16,OS_16,hreg,dst);
             inc(src.offset,2);
             inc(src.offset,2);
             inc(dst.offset,2);
             inc(dst.offset,2);
-{$ifdef newra}
-            rg.ungetregisterint(list,r);
-{$else}
-            a_reg_dealloc(list,r);
-{$endif}
+            rg.ungetregisterint(list,hreg);
           end;
           end;
         if (len and 1) <> 0 then
         if (len and 1) <> 0 then
           begin
           begin
-{$ifdef newra}
-            r:=rg.getregisterint(list,OS_INT);
-{$else}
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_O0;
-            a_reg_alloc(list,r);
-{$endif}
-            a_load_ref_reg(list,OS_8,OS_8,src,r);
-            a_load_reg_ref(list,OS_8,OS_8,r,dst);
-{$ifdef newra}
-            rg.ungetregisterint(list,r);
-{$else}
-            a_reg_dealloc(list,r);
-{$endif}
+            hreg:=rg.getregisterint(list,OS_INT);
+            a_load_ref_reg(list,OS_8,OS_8,src,hreg);
+            a_load_reg_ref(list,OS_8,OS_8,hreg,dst);
+            rg.ungetregisterint(list,hreg);
           end;
           end;
         if orgsrc then
         if orgsrc then
           begin
           begin
@@ -1159,17 +1003,9 @@ implementation
               reference_release(list,source);
               reference_release(list,source);
           end
           end
         else
         else
-{$ifdef newra}
-            rg.ungetregisterint(list,src.base);
-{$else}
-          free_scratch_reg(list,src.base);
-{$endif}
+          rg.ungetregisterint(list,src.base);
         if not orgdst then
         if not orgdst then
-{$ifdef newra}
-            rg.ungetregisterint(list,dst.base);
-{$else}
-          free_scratch_reg(list,dst.base);
-{$endif}
+          rg.ungetregisterint(list,dst.base);
       end;
       end;
 
 
 {****************************************************************************
 {****************************************************************************
@@ -1217,16 +1053,13 @@ implementation
 
 
     procedure TCg64Sparc.a_op64_reg_reg(list:TAasmOutput;op:TOpCG;regsrc,regdst:TRegister64);
     procedure TCg64Sparc.a_op64_reg_reg(list:TAasmOutput;op:TOpCG;regsrc,regdst:TRegister64);
       var
       var
-        zeroreg : tregister;
         op1,op2 : TAsmOp;
         op1,op2 : TAsmOp;
       begin
       begin
         case op of
         case op of
           OP_NEG :
           OP_NEG :
             begin
             begin
-              zeroreg.enum:=R_INTREGISTER;
-              zeroreg.number:=NR_G0;
-              list.concat(taicpu.op_reg_reg_reg(A_XNOR,zeroreg,regsrc.reghi,regdst.reghi));
-              list.concat(taicpu.op_reg_reg_reg(A_SUBcc,zeroreg,regsrc.reglo,regdst.reglo));
+              list.concat(taicpu.op_reg_reg_reg(A_XNOR,NR_G0,regsrc.reghi,regdst.reghi));
+              list.concat(taicpu.op_reg_reg_reg(A_SUBcc,NR_G0,regsrc.reglo,regdst.reglo));
               list.concat(taicpu.op_reg_const_reg(A_ADDX,regdst.reglo,aword(-1),regdst.reglo));
               list.concat(taicpu.op_reg_const_reg(A_ADDX,regdst.reglo,aword(-1),regdst.reglo));
               exit;
               exit;
             end;
             end;
@@ -1257,7 +1090,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.65  2003-07-08 21:24:59  peter
+  Revision 1.66  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.65.2.1  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.65  2003/07/08 21:24:59  peter
     * sparc fixes
     * sparc fixes
 
 
   Revision 1.64  2003/07/06 22:10:13  peter
   Revision 1.64  2003/07/06 22:10:13  peter

+ 210 - 572
compiler/sparc/cpubase.pas

@@ -56,467 +56,128 @@ uses
                                   Registers
                                   Registers
 *****************************************************************************}
 *****************************************************************************}
 
 
-    type
-      TCpuRegister=(
-        R_NO
-        {General purpose global registers}
-        ,R_G0{This register is usually set to zero and used as a scratch register}
-        ,R_G1,R_G2,R_G3,R_G4,R_G5,R_G6,R_G7
-        {General purpose out registers}
-        ,R_O0,R_O1,R_O2,R_O3,R_O4,R_O5,R_O6
-        ,R_O7{This register is used to save the address of the last CALL instruction}
-        {General purpose local registers}
-        ,R_L0
-        ,R_L1{This register is used to save the Program Counter (PC) after a Trap}
-        ,R_L2{This register is used to save the Program Counter (nPC) after a Trap}
-        ,R_L3,R_L4,R_L5,R_L6,R_L7
-        {General purpose in registers}
-        ,R_I0,R_I1,R_I2,R_I3,R_I4,R_I5,R_I6,R_I7
-        {Floating point registers}
-        ,R_F0,R_F1,R_F2,R_F3,R_F4,R_F5,R_F6,R_F7
-        ,R_F8,R_F9,R_F10,R_F11,R_F12,R_F13,R_F14,R_F15
-        ,R_F16,R_F17,R_F18,R_F19,R_F20,R_F21,R_F22,R_F23
-        ,R_F24,R_F25,R_F26,R_F27,R_F28,R_F29,R_F30,R_F31
-        {Floating point status/"front of queue" registers}
-        ,R_FSR,R_FQ
-        {Coprocessor registers}
-        ,R_C0,R_C1,R_C2,R_C3,R_C4,R_C5,R_C6,R_C7
-        ,R_C8,R_C9,R_C10,R_C11,R_C12,R_C13,R_C14,R_C15
-        ,R_C16,R_C17,R_C18,R_C19,R_C20,R_C21,R_C22,R_C23
-        ,R_C24,R_C25,R_C26,R_C27,R_C28,R_C29,R_C30,R_C31
-        {Coprocessor status/queue registers}
-        ,R_CSR
-        ,R_CQ
-        {Integer Unit control & status registers}
-        ,R_PSR{Processor Status Register : informs upon the program status}
-        ,R_TBR{Trap Base Register : saves the Trap vactor base address}
-        ,R_WIM{Window Invalid Mask : }
-        ,R_Y{Multiply/Devide Register : }
-        {Ancillary State Registers : these are implementation dependent registers and
-        thus, are not specified by the SPARC Reference Manual. I did choose the SUN's
-        implementation according to the Assembler Refernce Manual.(MN)}
-        ,R_ASR0,R_ASR1,R_ASR2,R_ASR3,R_ASR4,R_ASR5,R_ASR6,R_ASR7
-        ,R_ASR8,R_ASR9,R_ASR10,R_ASR11,R_ASR12,R_ASR13,R_ASR14,R_ASR15
-        ,R_ASR16,R_ASR17,R_ASR18,R_ASR19,R_ASR20,R_ASR21,R_ASR22,R_ASR23
-        ,R_ASR24,R_ASR25,R_ASR26,R_ASR27,R_ASR28,R_ASR29,R_ASR30,R_ASR31
-        {The following registers are just used with the new register allocator}
-        ,R_INTREGISTER,R_FLOATREGISTER,R_MMXREGISTER,R_KNIREGISTER
-      );
-
-      TOldRegister=TCpuRegister;
-
-      Tnewregister=word;
-      Tsuperregister=byte;
-      Tsubregister=byte;
-
-      Tregister=record
-        enum:TCpuRegister;
-        number:Tnewregister;
-      end;
-
-      {# Set type definition for registers }
-      tregisterset = set of TCpuRegister;
-      Tsupregset=set of Tsuperregister;
-
-      { A type to store register locations for 64 Bit values. }
-      tregister64 = packed record
-        reglo,reghi : tregister;
-      end;
-
-      { alias for compact code }
-      treg64 = tregister64;
-
+    const
+      { Invalid register number }
+      RS_INVALID    = $ff;
+
+      { Integer Super registers }
+      RS_G0=$00;
+      RS_G1=$01;
+      RS_G2=$02;
+      RS_G3=$03;
+      RS_G4=$04;
+      RS_G5=$05;
+      RS_G6=$06;
+      RS_G7=$07;
+      RS_O0=$08;
+      RS_O1=$09;
+      RS_O2=$0a;
+      RS_O3=$0b;
+      RS_O4=$0c;
+      RS_O5=$0d;
+      RS_O6=$0e;
+      RS_O7=$0f;
+      RS_L0=$10;
+      RS_L1=$11;
+      RS_L2=$12;
+      RS_L3=$13;
+      RS_L4=$14;
+      RS_L5=$15;
+      RS_L6=$16;
+      RS_L7=$17;
+      RS_I0=$18;
+      RS_I1=$19;
+      RS_I2=$1a;
+      RS_I3=$1b;
+      RS_I4=$1c;
+      RS_I5=$1d;
+      RS_I6=$1e;
+      RS_I7=$1f;
+
+{$warning Supreg shall be $00-$1f}
+      first_int_supreg = $08;
+      last_int_supreg = $17;
+
+      first_int_imreg = $20;
+      last_int_imreg = $fe;
+
+      { Float Super registers }
+      RS_F0=$00;
+      RS_F1=$01;
+      RS_F2=$02;
+      RS_F3=$03;
+      RS_F4=$04;
+      RS_F5=$05;
+      RS_F6=$06;
+      RS_F7=$07;
+      RS_F8=$08;
+      RS_F9=$09;
+      RS_F10=$0a;
+      RS_F11=$0b;
+      RS_F12=$0c;
+      RS_F13=$0d;
+      RS_F14=$0e;
+      RS_F15=$0f;
+      RS_F16=$10;
+      RS_F17=$11;
+      RS_F18=$12;
+      RS_F19=$13;
+      RS_F20=$14;
+      RS_F21=$15;
+      RS_F22=$16;
+      RS_F23=$17;
+      RS_F24=$18;
+      RS_F25=$19;
+      RS_F26=$1a;
+      RS_F27=$1b;
+      RS_F28=$1c;
+      RS_F29=$1d;
+      RS_F30=$1e;
+      RS_F31=$1f;
+
+      { Float Super register first and last }
+      first_fpu_supreg    = $00;
+      last_fpu_supreg     = $1f;
+
+      first_fpu_imreg     = $20;
+      last_fpu_imreg      = $fe;
+
+      { MM Super register first and last }
+      first_mmx_supreg    = RS_INVALID;
+      last_mmx_supreg     = RS_INVALID;
+      first_mmx_imreg     = RS_INVALID;
+      last_mmx_imreg      = RS_INVALID;
+
+      { No Subregisters }
+      R_SUBWHOLE=R_SUBNONE;
+
+      { Available Registers }
+      {$i rspcon.inc}
 
 
-    Const
-      {# First register in the tregister enumeration }
-      firstreg = low(TCpuRegister);
-      {# Last register in the tregister enumeration }
-      lastreg  = R_ASR31;
     type
     type
-      {# Type definition for the array of string of register nnames }
-      treg2strtable = array[firstreg..lastreg] of string[7];
+      { Number of registers used for indexing in tables }
+      tregisterindex=0..{$i rspnor.inc}-1;
 
 
     const
     const
-      std_reg2str:treg2strtable=(
-        '',
-          {general purpose global registers}
-        '%g0','%g1','%g2','%g3','%g4','%g5','%g6','%g7',
-          {general purpose out registers}
-        '%o0','%o1','%o2','%o3','%o4','%o5','%o6','%o7',
-          {general purpose local registers}
-        '%l0','%l1','%l2','%l3','%l4','%l5','%l6','%l7',
-          {general purpose in registers}
-        '%i0','%i1','%i2','%i3','%i4','%i5','%i6','%i7',
-          {floating point registers}
-        '%f0','%f1','%f2','%f3','%f4','%f5','%f6','%f7',
-        '%f8','%f9','%f10','%f11','%f12','%f13','%f14','%f15',
-        '%f16','%f17','%f18','%f19','%f20','%f21','%f22','%f23',
-        '%f24','%f25','%f26','%f27','%f28','%f29','%f30','%f31',
-          {floating point status/"front of queue" registers}
-        '%fSR','%fQ',
-          {coprocessor registers}
-        '%c0','%c1','%c2','%c3','%c4','%c5','%c6','%c7',
-        '%c8','%c9','%c10','%c11','%c12','%c13','%c14','%c15',
-        '%c16','%c17','%c18','%c19','%c20','%c21','%c22','%c23',
-        '%c24','%c25','%c26','%c27','%c28','%c29','%c30','%c31',
-          {coprocessor status/queue registers}
-        '%csr','%cq',
-          {"Program status"/"Trap vactor base address register"/"Window invalid mask"/Y registers}
-        '%psr','%tbr','%wim','%y',
-          {Ancillary state registers}
-        '%asr0','%asr1','%asr2','%asr3','%asr4','%asr5','%asr6','%asr7',
-        '%asr8','%asr9','%asr10','%asr11','%asr12','%asr13','%asr14','%asr15',
-        '%asr16','%asr17','%asr18','%asr19','%asr20','%asr21','%asr22','%asr23',
-        '%asr24','%asr25','%asr26','%asr27','%asr28','%asr29','%asr30','%asr31'
-      );
-
-    {New register coding:}
+{$warning TODO Calculate bsstart}
+      regnumber_count_bsstart = 128;
 
 
-    {Special registers:}
-    const
-      NR_NO=$0000;  {Invalid register}
-
-    {Normal registers:}
-
-    {General purpose registers:}
-      NR_G0=$0100;
-      NR_G1=$0200;
-      NR_G2=$0300;
-      NR_G3=$0400;
-      NR_G4=$0500;
-      NR_G5=$0600;
-      NR_G6=$0700;
-      NR_G7=$0800;
-      NR_O0=$0900;
-      NR_O1=$0a00;
-      NR_O2=$0b00;
-      NR_O3=$0c00;
-      NR_O4=$0d00;
-      NR_O5=$0e00;
-      NR_O6=$0f00;
-      NR_O7=$1000;
-      NR_L0=$1100;
-      NR_L1=$1200;
-      NR_L2=$1300;
-      NR_L3=$1400;
-      NR_L4=$1500;
-      NR_L5=$1600;
-      NR_L6=$1700;
-      NR_L7=$1800;
-      NR_I0=$1900;
-      NR_I1=$1A00;
-      NR_I2=$1B00;
-      NR_I3=$1C00;
-      NR_I4=$1D00;
-      NR_I5=$1E00;
-      NR_I6=$1F00;
-      NR_I7=$2000;
-{$ifdef dummy}
-    { Floating point }
-      NR_F0=$2000;
-      NR_F1=$2000;
-      NR_F2=$2000;
-      NR_F3=$2000;
-      NR_F4=$2000;
-      NR_F5=$2000;
-      NR_F6=$2000;
-      NR_F7=$2000;
-      NR_F8=$2000;
-      NR_F9=$2000;
-      NR_F10=$2000;
-      NR_F11=$2000;
-      NR_F12=$2000;
-      NR_F13=$2000;
-      NR_F14=$2000;
-      NR_F15=$2000;
-      NR_F16=$2000;
-      NR_F17=$2000;
-      NR_F18=$2000;
-      NR_F19=$2000;
-      NR_F20=$2000;
-      NR_F21=$2000;
-      NR_F22=$2000;
-      NR_F23=$2000;
-      NR_F24=$2000;
-      NR_F25=$2000;
-      NR_F26=$2000;
-      NR_F27=$2000;
-      NR_F28=$2000;
-      NR_F29=$2000;
-      NR_F30=$2000;
-      NR_F31=$2000;
-    { Coprocessor point }
-      NR_C0=$3000;
-      NR_C1=$3000;
-      NR_C2=$3000;
-      NR_C3=$3000;
-      NR_C4=$3000;
-      NR_C5=$3000;
-      NR_C6=$3000;
-      NR_C7=$3000;
-      NR_C8=$3000;
-      NR_C9=$3000;
-      NR_C10=$3000;
-      NR_C11=$3000;
-      NR_C12=$3000;
-      NR_C13=$3000;
-      NR_C14=$3000;
-      NR_C15=$3000;
-      NR_C16=$3000;
-      NR_C17=$3000;
-      NR_C18=$3000;
-      NR_C19=$3000;
-      NR_C20=$3000;
-      NR_C21=$3000;
-      NR_C22=$3000;
-      NR_C23=$3000;
-      NR_C24=$3000;
-      NR_C25=$3000;
-      NR_C26=$3000;
-      NR_C27=$3000;
-      NR_C28=$3000;
-      NR_C29=$3000;
-      NR_C30=$3000;
-      NR_C31=$3000;
-    { ASR }
-      NR_ASR0=$4000;
-      NR_ASR1=$4000;
-      NR_ASR2=$4000;
-      NR_ASR3=$4000;
-      NR_ASR4=$4000;
-      NR_ASR5=$4000;
-      NR_ASR6=$4000;
-      NR_ASR7=$4000;
-      NR_ASR8=$4000;
-      NR_ASR9=$4000;
-      NR_ASR10=$4000;
-      NR_ASR11=$4000;
-      NR_ASR12=$4000;
-      NR_ASR13=$4000;
-      NR_ASR14=$4000;
-      NR_ASR15=$4000;
-      NR_ASR16=$4000;
-      NR_ASR17=$4000;
-      NR_ASR18=$4000;
-      NR_ASR19=$4000;
-      NR_ASR20=$4000;
-      NR_ASR21=$4000;
-      NR_ASR22=$4000;
-      NR_ASR23=$4000;
-      NR_ASR24=$4000;
-      NR_ASR25=$4000;
-      NR_ASR26=$4000;
-      NR_ASR27=$4000;
-      NR_ASR28=$4000;
-      NR_ASR29=$4000;
-      NR_ASR30=$4000;
-      NR_ASR31=$4000;
-    { Floating point status/"front of queue" registers }
-      NR_FSR=$5000;
-      NR_FQ=$5000;
-      NR_CSR=$5000;
-      NR_CQ=$5000;
-      NR_PSR=$5000;
-      NR_TBR=$5000;
-      NR_WIM=$5000;
-      NR_Y=$5000;
-{$endif dummy}
+      regnumber_table : array[tregisterindex] of tregister = (
+        {$i rspnum.inc}
+      );
 
 
-    {Super registers:}
-      RS_NO=$00;
-      RS_G0=$01;
-      RS_G1=$02;
-      RS_G2=$03;
-      RS_G3=$04;
-      RS_G4=$05;
-      RS_G5=$06;
-      RS_G6=$07;
-      RS_G7=$08;
-      RS_O0=$09;
-      RS_O1=$0a;
-      RS_O2=$0b;
-      RS_O3=$0c;
-      RS_O4=$0d;
-      RS_O5=$0e;
-      RS_O6=$0f;
-      RS_O7=$10;
-      RS_L0=$11;
-      RS_L1=$12;
-      RS_L2=$13;
-      RS_L3=$14;
-      RS_L4=$15;
-      RS_L5=$16;
-      RS_L6=$17;
-      RS_L7=$18;
-      RS_I0=$19;
-      RS_I1=$1a;
-      RS_I2=$1b;
-      RS_I3=$1c;
-      RS_I4=$1d;
-      RS_I5=$1e;
-      RS_I6=$1f;
-      RS_I7=$20;
-
-      first_supreg = $01;
-      last_supreg = $20;
+      regstabs_table : array[tregisterindex] of tregister = (
+        {$i rspstab.inc}
+      );
 
 
-{$warning FIXME!!}
       { registers which may be destroyed by calls }
       { registers which may be destroyed by calls }
-      VOLATILE_INTREGISTERS = [first_supreg..last_supreg];
+      VOLATILE_INTREGISTERS = [RS_G1];
 {$warning FIXME!!}
 {$warning FIXME!!}
       VOLATILE_FPUREGISTERS = [];
       VOLATILE_FPUREGISTERS = [];
 
 
-      first_imreg = $21;
-      last_imreg = $ff;
-
-    { Subregisters, situation unknown!! }
-      R_SUBWHOLE=$00;
-      R_SUBL=$00;
-
-{Conversion between TCpuRegister and NewRegisters}
-  RegEnum2Number:array[TCpuRegister]of cardinal=(
-    NR_NO,
-    NR_G0,
-    NR_G1,
-    NR_G2,
-    NR_G3,
-    NR_G4,
-    NR_G5,
-    NR_G6,
-    NR_G7,
-    NR_O0,
-    NR_O1,
-    NR_O2,
-    NR_O3,
-    NR_O4,
-    NR_O5,
-    NR_O6,
-    NR_O7,
-    NR_L0,
-    NR_L1,
-    NR_L2,
-    NR_L3,
-    NR_L4,
-    NR_L5,
-    NR_L6,
-    NR_L7,
-    NR_I0,
-    NR_I1,
-    NR_I2,
-    NR_I3,
-    NR_I4,
-    NR_I5,
-    NR_I6,
-    NR_I7,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO,
-    NR_NO
-  );
+   type
+      totherregisterset = set of tregisterindex;
+
 
 
 {*****************************************************************************
 {*****************************************************************************
                                 Conditions
                                 Conditions
@@ -739,21 +400,10 @@ type
       max_operands = 3;
       max_operands = 3;
 
 
       {# Constant defining possibly all registers which might require saving }
       {# Constant defining possibly all registers which might require saving }
-      ALL_REGISTERS = [R_G0..R_I7];
+      ALL_OTHERREGISTERS = [];
 
 
-      general_registers = [R_G0..R_I7];
       general_superregisters = [RS_O0..RS_I7];
       general_superregisters = [RS_O0..RS_I7];
 
 
-      {# low and high of the available maximum width integer general purpose }
-      { registers                                                            }
-      LoGPReg = R_G0;
-      HiGPReg = R_I7;
-
-      {# low and high of every possible width general purpose register (same as }
-      { above on most architctures apart from the 80x86)                        }
-      LoReg = R_G0;
-      HiReg = R_I7;
-
       {# Table of registers which can be allocated by the code generator
       {# Table of registers which can be allocated by the code generator
          internally, when generating the code.
          internally, when generating the code.
       }
       }
@@ -768,14 +418,12 @@ type
 
 
       maxintregs = 8;
       maxintregs = 8;
       { to determine how many registers to use for regvars }
       { to determine how many registers to use for regvars }
-      maxintscratchregs = 3;      
-      intregs = [R_G0..R_I7];
+      maxintscratchregs = 3;
       usableregsint = [RS_L0..RS_L7];
       usableregsint = [RS_L0..RS_L7];
       c_countusableregsint = 8;
       c_countusableregsint = 8;
 
 
       maxfpuregs = 8;
       maxfpuregs = 8;
-      fpuregs=[R_F0..R_F31];
-      usableregsfpu=[R_F0..R_F31];
+      usableregsfpu=[RS_F0..RS_F31];
       c_countusableregsfpu=32;
       c_countusableregsfpu=32;
 
 
       mmregs     = [];
       mmregs     = [];
@@ -791,18 +439,18 @@ type
 {$warning firstsaveintreg shall be RS_NO}
 {$warning firstsaveintreg shall be RS_NO}
       firstsaveintreg = RS_L0; { Temporary, having RS_NO is broken }
       firstsaveintreg = RS_L0; { Temporary, having RS_NO is broken }
       lastsaveintreg = RS_L0; { L0..L7 are already saved, I0..O7 are parameter }
       lastsaveintreg = RS_L0; { L0..L7 are already saved, I0..O7 are parameter }
-      firstsavefpureg = R_F2; { F0..F1 is used for return value }
-      lastsavefpureg = R_F31;
-      firstsavemmreg = R_NO;
-      lastsavemmreg = R_NO;
+      firstsavefpureg = RS_F2; { F0..F1 is used for return value }
+      lastsavefpureg = RS_F31;
+      firstsavemmreg = RS_INVALID;
+      lastsavemmreg = RS_INVALID;
 
 
       maxvarregs = 8;
       maxvarregs = 8;
-      varregs : Array [1..maxvarregs] of Tnewregister =
+      varregs : Array [1..maxvarregs] of Tsuperregister =
                 (RS_L0,RS_L1,RS_L2,RS_L3,RS_L4,RS_L5,RS_L6,RS_L7);
                 (RS_L0,RS_L1,RS_L2,RS_L3,RS_L4,RS_L5,RS_L6,RS_L7);
 
 
       maxfpuvarregs = 1;
       maxfpuvarregs = 1;
-      fpuvarregs : Array [1..maxfpuvarregs] of TCpuRegister =
-                (R_F2);
+      fpuvarregs : Array [1..maxfpuvarregs] of TsuperRegister =
+                (RS_F2);
 
 
       {
       {
       max_param_regs_int = 6;
       max_param_regs_int = 6;
@@ -818,11 +466,6 @@ type
         (R_M1,R_M2,R_M3,R_M4,R_M5,R_M6,R_M7,R_M8,R_M9,R_M10,R_M11,R_M12,R_M13);
         (R_M1,R_M2,R_M3,R_M4,R_M5,R_M6,R_M7,R_M8,R_M9,R_M10,R_M11,R_M12,R_M13);
       }
       }
 
 
-      {# Registers which are defined as scratch and no need to save across
-         routine calls or in assembler blocks.
-      }
-      max_scratch_regs = 3;
-      scratch_regs: Array[1..max_scratch_regs] of Tsuperregister = (RS_O7,RS_G2,RS_G3);
 
 
 {*****************************************************************************
 {*****************************************************************************
                           Default generic sizes
                           Default generic sizes
@@ -837,63 +480,6 @@ type
       {# the size of a vector register for a processor     }
       {# the size of a vector register for a processor     }
       OS_VECTOR = OS_M64;
       OS_VECTOR = OS_M64;
 
 
-{*****************************************************************************
-                               GDB Information
-*****************************************************************************}
-
-      {# Register indexes for stabs information, when some
-         parameters or variables are stored in registers.
-
-         Taken from rs6000.h (DBX_REGISTER_NUMBER)
-         from GCC 3.x source code.
-      }
-
-      stab_regindex : array[firstreg..lastreg] of shortint =
-      (
-        0{R_NO}
-        {General purpose global registers}
-        ,1{R_G0}{This register is usually set to zero and used as a scratch register}
-        ,2{R_G1},3{R_G2},4{R_G3},5{R_G4},6{R_G5},7{R_G6},8{R_G7}
-        {General purpose out registers}
-        ,9{R_O0},10{R_O1},11{R_O2},12{R_O3},13{R_O4},14{R_O5},15{R_O6}
-        ,16{R_O7}{This register is used to save the address of the last CALL instruction}
-        {General purpose local registers}
-        ,16{R_L0}
-        ,17{R_L1}{This register is used to save the Program Counter (PC) after a Trap}
-        ,18{R_L2}{This register is used to save the Program Counter (nPC) after a Trap}
-        ,19{R_L3},20{R_L4},21{R_L5},22{R_L6},23{R_L7}
-        {General purpose in registers}
-        ,24{R_I0},25{R_I1},26{R_I2},27{R_I3},28{R_I4},29{R_I5},30{R_I6},31{R_I7}
-        {Floating point registers}
-        ,32{R_F0},33{R_F1},34{R_F2},35{R_F3},36{R_F4},37{R_F5},38{R_F6},39{R_F7}
-        ,40{R_F8},41{R_F9},42{R_F10},43{R_F11},44{R_F12},45{R_F13},46{R_F14},47{R_F15}
-        ,48{R_F16},49{R_F17},50{R_F18},51{R_F19},52{R_F20},53{R_F21},54{R_F22},55{R_F23}
-        ,56{R_F24},57{R_F25},58{R_F26},59{R_F27},60{R_F28},61{R_F29},62{R_F30},63{R_F31}
-        {Floating point status/"front of queue" registers}
-        ,64{R_FSR},65{R_FQ}
-        {Coprocessor registers}
-        ,66{R_C0},67{R_C1},68{R_C2},69{R_C3},70{R_C4},71{R_C5},72{R_C6},73{R_C7}
-        ,74{R_C8},75{R_C9},76{R_C10},77{R_C11},78{R_C12},79{R_C13},80{R_C14},81{R_C15}
-        ,82{R_C16},83{R_C17},84{R_C18},85{R_C19},86{R_C20},87{R_C21},88{R_C22},89{R_C23}
-        ,90{R_C24},91{R_C25},92{R_C26},93{R_C27},94{R_C28},95{R_C29},96{R_C30},98{R_C31}
-        {Coprocessor status/queue registers}
-        ,99{R_CSR}
-        ,100{R_CQ}
-        {Integer Unit control & status registers}
-        ,101{R_PSR}{Processor Status Register : informs upon the program status}
-        ,102{R_TBR}{Trap Base Register : saves the Trap vactor base address}
-        ,103{R_WIM}{Window Invalid Mask : }
-        ,104{R_Y}{Multiply/Devide Register : }
-        {Ancillary State Registers : these are implementation dependent registers and
-        thus, are not specified by the SPARC Reference Manual. I did choose the SUN's
-        implementation according to the Assembler Refernce Manual.(MN)}
-        ,105{R_ASR0},106{R_ASR1},107{R_ASR2},108{R_ASR3},109{R_ASR4},110{R_ASR5},111{R_ASR6},112{R_ASR7}
-        ,113{R_ASR8},114{R_ASR9},115{R_ASR10},116{R_ASR11},117{R_ASR12},118{R_ASR13},119{R_ASR14},120{R_ASR15}
-        ,121{R_ASR16},122{R_ASR17},123{R_ASR18},124{R_ASR19},125{R_ASR20},126{R_ASR21},127{R_ASR22},127{R_ASR23}
-        ,127{R_ASR24},127{R_ASR25},127{R_ASR26},127{R_ASR27},127{R_ASR28},127{R_ASR29},127{R_ASR30},127{R_ASR31}
-      );
-
-
 {*****************************************************************************
 {*****************************************************************************
                           Generic Register names
                           Generic Register names
 *****************************************************************************}
 *****************************************************************************}
@@ -934,11 +520,12 @@ type
       NR_FUNCTION_RESULT64_HIGH_REG = NR_O0;
       NR_FUNCTION_RESULT64_HIGH_REG = NR_O0;
       RS_FUNCTION_RESULT64_HIGH_REG = RS_O0;
       RS_FUNCTION_RESULT64_HIGH_REG = RS_O0;
 
 
-      FPU_RESULT_REG = R_F0;
-      mmresultreg = R_NO;
+      NR_FPU_RESULT_REG = NR_F0;
+      NR_MM_RESULT_REG  = NR_NO;
 
 
       PARENT_FRAMEPOINTER_OFFSET = 68; { o0 }
       PARENT_FRAMEPOINTER_OFFSET = 68; { o0 }
 
 
+
 {*****************************************************************************
 {*****************************************************************************
                        GCC /ABI linking information
                        GCC /ABI linking information
 *****************************************************************************}
 *****************************************************************************}
@@ -977,11 +564,11 @@ type
 
 
     procedure inverse_flags(var f: TResFlags);
     procedure inverse_flags(var f: TResFlags);
     function  flags_to_cond(const f: TResFlags) : TAsmCond;
     function  flags_to_cond(const f: TResFlags) : TAsmCond;
-    procedure convert_register_to_enum(var r:Tregister);
     function cgsize2subreg(s:Tcgsize):Tsubregister;
     function cgsize2subreg(s:Tcgsize):Tsubregister;
-    function supreg_name(r:Tsuperregister):string;
-
-    function gas_regname(const r:TNewRegister):string;
+    function findreg_by_number(r:Tregister):tregisterindex;
+    function std_regnum_search(const s:string):Tregister;
+    function std_regname(r:Tregister):string;
+    function gas_regname(r:Tregister):string;
 
 
 
 
 implementation
 implementation
@@ -989,6 +576,20 @@ implementation
     uses
     uses
       verbose;
       verbose;
 
 
+    const
+      std_regname_table : array[tregisterindex] of string[7] = (
+        {$i rspstd.inc}
+      );
+
+      regnumber_index : array[tregisterindex] of tregisterindex = (
+        {$i rsprni.inc}
+      );
+
+      std_regname_index : array[tregisterindex] of tregisterindex = (
+        {$i rspsri.inc}
+      );
+
+
 {*****************************************************************************
 {*****************************************************************************
                                   Helpers
                                   Helpers
 *****************************************************************************}
 *****************************************************************************}
@@ -1019,58 +620,95 @@ implementation
       end;
       end;
 
 
 
 
-    procedure convert_register_to_enum(var r:Tregister);
+    function cgsize2subreg(s:Tcgsize):Tsubregister;
       begin
       begin
-        if (r.enum=R_INTREGISTER) then
-          begin
-            if r.number>NR_I7 then
-              internalerror(200301082);
-            r.enum:=TCpuRegister(r.number shr 8);
-          end;
+        cgsize2subreg:=R_SUBWHOLE;
       end;
       end;
 
 
 
 
-    function cgsize2subreg(s:Tcgsize):Tsubregister;
+    function findreg_by_stdname(const s:string):byte;
+      var
+        i,p : tregisterindex;
       begin
       begin
-        cgsize2subreg:=R_SUBWHOLE;
+        {Binary search.}
+        p:=0;
+        i:=regnumber_count_bsstart;
+        repeat
+          if (p+i<=high(tregisterindex)) and (std_regname_table[std_regname_index[p+i]]<=s) then
+            p:=p+i;
+          i:=i shr 1;
+        until i=0;
+        if std_regname_table[std_regname_index[p]]=s then
+          result:=std_regname_index[p]
+        else
+          result:=0;
       end;
       end;
 
 
 
 
-    function supreg_name(r:Tsuperregister):string;
-      const
-        supreg_names:array[0..last_supreg] of string[4]=
-          ('INV',
-           'g0','g1','g2','g3','g4','g5','g6','g7',
-           'o0','o1','o2','o3','o4','o5','o6','o7',
-           'l0','l1','l2','l3','l4','l5','l6','l7',
-           'i0','i1','i2','i3','i4','i5','i6','i7');
+    function findreg_by_number(r:Tregister):tregisterindex;
+      var
+        i,p : tregisterindex;
+      begin
+        {Binary search.}
+        p:=0;
+        i:=regnumber_count_bsstart;
+        repeat
+          if (p+i<=high(tregisterindex)) and (regnumber_table[regnumber_index[p+i]]<=r) then
+            p:=p+i;
+          i:=i shr 1;
+        until i=0;
+        if regnumber_table[regnumber_index[p]]=r then
+          result:=regnumber_index[p]
+        else
+          result:=0;
+      end;
+
+
+    function std_regnum_search(const s:string):Tregister;
+      begin
+        result:=regnumber_table[findreg_by_stdname(s)];
+      end;
+
+
+    function std_regname(r:Tregister):string;
       var
       var
-        s : string[4];
+        p : tregisterindex;
       begin
       begin
-        if r in [0..last_supreg] then
-          supreg_name:=supreg_names[r]
+        p:=findreg_by_number(r);
+        if p<>0 then
+          result:=std_regname_table[p]
         else
         else
-          begin
-            str(r,s);
-            supreg_name:='reg'+s;
-          end;
+          result:=generic_regname(r);
       end;
       end;
 
 
 
 
-    function gas_regname(const r:TNewRegister):string;
+    function gas_regname(r:Tregister):string;
       var
       var
-        Reg:TRegister;
+        p : tregisterindex;
       begin
       begin
-        Reg.Number:=r;
-        Reg.enum:=R_INTREGISTER;
-        convert_register_to_enum(Reg);
-        gas_regname:=std_Reg2str[Reg.Enum];
+        p:=findreg_by_number(r);
+        if p<>0 then
+          result:=std_regname_table[p]
+        else
+          result:=generic_regname(r);
       end;
       end;
 
 
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.47  2003-08-19 13:22:51  mazen
+  Revision 1.48  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.47.2.3  2003/09/02 17:49:17  peter
+    * newra updates
+
+  Revision 1.47.2.2  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.47.2.1  2003/08/31 21:08:16  peter
+    * first batch of sparc fixes
+
+  Revision 1.47  2003/08/19 13:22:51  mazen
   + implemented gas_regname based on convert_register_to_enum std_Reg2str
   + implemented gas_regname based on convert_register_to_enum std_Reg2str
 
 
   Revision 1.46  2003/08/17 16:59:20  jonas
   Revision 1.46  2003/08/17 16:59:20  jonas

+ 14 - 8
compiler/sparc/cpugas.pas

@@ -48,7 +48,7 @@ unit cpugas;
           begin
           begin
             inc(offset,offsetfixup);
             inc(offset,offsetfixup);
             offsetfixup:=0;
             offsetfixup:=0;
-            if (base.number=NR_NO) and (index.number=NR_NO) then
+            if (base=NR_NO) and (index=NR_NO) then
               begin
               begin
                  if assigned(symbol) then
                  if assigned(symbol) then
                    GetReferenceString:=symbol.name;
                    GetReferenceString:=symbol.name;
@@ -68,9 +68,9 @@ unit cpugas;
                 if assigned(symbol) then
                 if assigned(symbol) then
                   internalerror(2003052601);
                   internalerror(2003052601);
                 GetReferenceString:='[';
                 GetReferenceString:='[';
-                if base.number<>NR_NO then
-                  GetReferenceString:=GetReferenceString+std_reg2str[base.enum];
-                if index.number=NR_NO then
+                if base<>NR_NO then
+                  GetReferenceString:=GetReferenceString+gas_regname(base);
+                if index=NR_NO then
                   begin
                   begin
                     if (Offset<simm13lo) or (Offset>simm13hi) then
                     if (Offset<simm13lo) or (Offset>simm13hi) then
                       internalerror(2003053008);
                       internalerror(2003053008);
@@ -83,7 +83,7 @@ unit cpugas;
                   begin
                   begin
                     if Offset<>0 then
                     if Offset<>0 then
                       internalerror(2003052603);
                       internalerror(2003052603);
-                    GetReferenceString:=GetReferenceString+'+'+std_reg2str[index.enum];
+                    GetReferenceString:=GetReferenceString+'+'+gas_regname(index);
                   end;
                   end;
                 GetReferenceString:=GetReferenceString+']';
                 GetReferenceString:=GetReferenceString+']';
               end;
               end;
@@ -93,12 +93,12 @@ unit cpugas;
 
 
     function getopstr(const Oper:TOper):string;
     function getopstr(const Oper:TOper):string;
       var
       var
-        hs:string;
+        hs : string;
       begin
       begin
         with Oper do
         with Oper do
           case typ of
           case typ of
             top_reg:
             top_reg:
-              getopstr:=std_reg2str[reg.enum];
+              getopstr:=gas_regname(reg);
             top_ref:
             top_ref:
               getopstr:=getreferencestring(ref^);
               getopstr:=getreferencestring(ref^);
             top_const:
             top_const:
@@ -205,7 +205,13 @@ begin
 end.
 end.
 {
 {
     $Log$
     $Log$
-    Revision 1.21  2003-07-08 21:25:00  peter
+    Revision 1.22  2003-09-03 15:55:01  peter
+      * NEWRA branch merged
+
+    Revision 1.21.2.1  2003/09/01 21:02:55  peter
+      * sparc updates for new tregister
+
+    Revision 1.21  2003/07/08 21:25:00  peter
       * sparc fixes
       * sparc fixes
 
 
     Revision 1.20  2003/07/02 22:18:04  peter
     Revision 1.20  2003/07/02 22:18:04  peter

+ 7 - 1
compiler/sparc/cpuinfo.pas

@@ -42,6 +42,9 @@ TYPE
   { possible supported processors for this target }
   { possible supported processors for this target }
   tprocessors=(no_processor,SPARC_V8,SPARC_V9);
   tprocessors=(no_processor,SPARC_V8,SPARC_V9);
 
 
+  tfputype =(fpu_soft,fpu_hard);
+
+
 const
 const
 {# Size of native extended floating point type }
 {# Size of native extended floating point type }
 {SPARC architecture uses IEEE double floating point numbers}
 {SPARC architecture uses IEEE double floating point numbers}
@@ -63,7 +66,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.8  2003-06-17 16:35:42  peter
+  Revision 1.9  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.8  2003/06/17 16:35:42  peter
     * JMP_BUF_SIZE changed to 4 to remove Alloctemp warnings
     * JMP_BUF_SIZE changed to 4 to remove Alloctemp warnings
 
 
   Revision 1.7  2003/05/23 22:33:48  florian
   Revision 1.7  2003/05/23 22:33:48  florian

+ 29 - 33
compiler/sparc/cpupara.pas

@@ -93,16 +93,14 @@ implementation
            if nr<6 then
            if nr<6 then
             begin
             begin
               loc:=LOC_REGISTER;
               loc:=LOC_REGISTER;
-              register.enum:=R_INTREGISTER;
-              register.number:=(RS_O0+nr) shl 8;
-              rg.getexplicitregisterint(list,register.number);
+              register:=newreg(R_INTREGISTER,(RS_O0+nr),R_SUBWHOLE);
+              rg.getexplicitregisterint(list,register);
             end
             end
            else
            else
            { The other parameters are passed on the stack }
            { The other parameters are passed on the stack }
             begin
             begin
               loc:=LOC_REFERENCE;
               loc:=LOC_REFERENCE;
-              reference.index.enum:=R_INTREGISTER;
-              reference.index.number:=NR_STACK_POINTER_REG;
+              reference.index:=NR_STACK_POINTER_REG;
               reference.offset:=92+(nr-6)*4;
               reference.offset:=92+(nr-6)*4;
             end;
             end;
            size:=OS_INT;
            size:=OS_INT;
@@ -113,7 +111,7 @@ implementation
     procedure tsparcparamanager.freeintparaloc(list: taasmoutput; nr : longint);
     procedure tsparcparamanager.freeintparaloc(list: taasmoutput; nr : longint);
 
 
       var
       var
-        r: tregister;
+        hreg : tregister;
 
 
       begin
       begin
         if nr<1 then
         if nr<1 then
@@ -121,9 +119,8 @@ implementation
         Dec(nr);
         Dec(nr);
         if nr<6 then
         if nr<6 then
           begin
           begin
-            r.enum:=R_INTREGISTER;
-            r.number:=(RS_O0+nr) shl 8;
-            rg.ungetregisterint(list,r);
+            hreg:=newreg(R_INTREGISTER,RS_O0+nr,R_SUBWHOLE);
+            rg.ungetregisterint(list,hreg);
           end;
           end;
       end;
       end;
 
 
@@ -132,7 +129,7 @@ implementation
       begin
       begin
         if (loc.loc=LOC_REFERENCE) and
         if (loc.loc=LOC_REFERENCE) and
            (loc.low_in_reg) then
            (loc.low_in_reg) then
-          rg.getexplicitregisterint(list,loc.lowreg.number);
+          rg.getexplicitregisterint(list,loc.lowreg);
         inherited allocparaloc(list,loc);
         inherited allocparaloc(list,loc);
       end;
       end;
 
 
@@ -178,12 +175,10 @@ implementation
                 { big endian }
                 { big endian }
                 if is_64bit then
                 if is_64bit then
                   begin
                   begin
-                    paraloc.registerhigh.enum:=R_INTREGISTER;
-                    paraloc.registerhigh.number:=nextintreg shl 8;
+                    paraloc.registerhigh:=newreg(R_INTREGISTER,nextintreg,R_SUBWHOLE);
                     inc(nextintreg);
                     inc(nextintreg);
                   end;
                   end;
-                paraloc.registerlow.enum:=R_INTREGISTER;
-                paraloc.registerlow.number:=NextIntReg shl 8;
+                paraloc.registerlow:=newreg(R_INTREGISTER,nextintreg,R_SUBWHOLE);
                 inc(NextIntReg);
                 inc(NextIntReg);
               end
               end
             else
             else
@@ -193,12 +188,10 @@ implementation
                 if NextIntReg<=RS_O5 then
                 if NextIntReg<=RS_O5 then
                   begin
                   begin
                     paraloc.low_in_reg:=true;
                     paraloc.low_in_reg:=true;
-                    paraloc.lowreg.enum:=R_INTREGISTER;
-                    paraloc.lowreg.number:=nextintreg shl 8;
+                    paraloc.lowreg:=newreg(R_INTREGISTER,nextintreg,R_SUBWHOLE);
                   end;
                   end;
                 nextintreg:=RS_O6;
                 nextintreg:=RS_O6;
-                paraloc.reference.index.enum:=R_INTREGISTER;
-                paraloc.reference.index.number:=NR_STACK_POINTER_REG;
+                paraloc.reference.index:=NR_STACK_POINTER_REG;
                 paraloc.reference.offset:=stack_offset;
                 paraloc.reference.offset:=stack_offset;
                 if is_64bit and
                 if is_64bit and
                    (not paraloc.low_in_reg) then
                    (not paraloc.low_in_reg) then
@@ -215,14 +208,14 @@ implementation
                   begin
                   begin
                     { big endian }
                     { big endian }
                     if is_64bit then
                     if is_64bit then
-                      inc(hp.paraloc[calleeside].registerhigh.number,(RS_I0-RS_O0) shl 8);
-                    inc(hp.paraloc[calleeside].registerlow.number,(RS_I0-RS_O0) shl 8);
+                      setsupreg(hp.paraloc[calleeside].registerhigh,getsupreg(hp.paraloc[calleeside].registerhigh)+(RS_I0-RS_O0));
+                    setsupreg(hp.paraloc[calleeside].registerlow,getsupreg(hp.paraloc[calleeside].registerlow)+(RS_I0-RS_O0));
                   end
                   end
                 else
                 else
                   begin
                   begin
                     if hp.paraloc[calleeside].low_in_reg then
                     if hp.paraloc[calleeside].low_in_reg then
-                      inc(hp.paraloc[calleeside].lowreg.number,(RS_I0-RS_O0) shl 8);
-                    inc(hp.paraloc[calleeside].reference.index.number,(RS_I0-RS_O0) shl 8);
+                      setsupreg(hp.paraloc[calleeside].lowreg,getsupreg(hp.paraloc[calleeside].lowreg)+(RS_I0-RS_O0));
+                    setsupreg(hp.paraloc[calleeside].reference.index,getsupreg(hp.paraloc[calleeside].reference.index)+(RS_I0-RS_O0));
                   end;
                   end;
               end;
               end;
             hp:=TParaItem(hp.Next);
             hp:=TParaItem(hp.Next);
@@ -235,7 +228,7 @@ implementation
         if p.rettype.def.deftype=floatdef then
         if p.rettype.def.deftype=floatdef then
           begin
           begin
             paraloc.loc:=LOC_FPUREGISTER;
             paraloc.loc:=LOC_FPUREGISTER;
-            paraloc.register.enum:=FPU_RESULT_REG;
+            paraloc.register:=NR_FPU_RESULT_REG;
           end
           end
         else
         else
          { Return in register? }
          { Return in register? }
@@ -245,25 +238,22 @@ implementation
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
             if paraloc.size in [OS_64,OS_S64] then
             if paraloc.size in [OS_64,OS_S64] then
              begin
              begin
-               paraloc.register64.reglo.enum:=R_INTREGISTER;
                if side=callerside then
                if side=callerside then
-                 paraloc.register64.reglo.number:=NR_FUNCTION_RESULT64_LOW_REG
+                 paraloc.register64.reglo:=NR_FUNCTION_RESULT64_LOW_REG
                else
                else
-                 paraloc.register64.reglo.number:=NR_FUNCTION_RETURN64_LOW_REG;
-               paraloc.register64.reghi.enum:=R_INTREGISTER;
+                 paraloc.register64.reglo:=NR_FUNCTION_RETURN64_LOW_REG;
                if side=callerside then
                if side=callerside then
-                 paraloc.register64.reghi.number:=NR_FUNCTION_RESULT64_HIGH_REG
+                 paraloc.register64.reghi:=NR_FUNCTION_RESULT64_HIGH_REG
                else
                else
-                 paraloc.register64.reghi.number:=NR_FUNCTION_RETURN64_HIGH_REG;
+                 paraloc.register64.reghi:=NR_FUNCTION_RETURN64_HIGH_REG;
              end
              end
             else
             else
 {$endif cpu64bit}
 {$endif cpu64bit}
              begin
              begin
-               paraloc.register.enum:=R_INTREGISTER;
                if side=callerside then
                if side=callerside then
-                 paraloc.register.number:=NR_FUNCTION_RESULT_REG
+                 paraloc.register:=NR_FUNCTION_RESULT_REG
                else
                else
-                 paraloc.register.number:=NR_FUNCTION_RETURN_REG;
+                 paraloc.register:=NR_FUNCTION_RETURN_REG;
              end;
              end;
           end
           end
         else
         else
@@ -301,7 +291,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.27  2003-08-11 21:18:20  peter
+  Revision 1.28  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.27.2.1  2003/08/31 21:08:16  peter
+    * first batch of sparc fixes
+
+  Revision 1.27  2003/08/11 21:18:20  peter
     * start of sparc support for newra
     * start of sparc support for newra
 
 
   Revision 1.26  2003/07/08 21:25:00  peter
   Revision 1.26  2003/07/08 21:25:00  peter

+ 8 - 2
compiler/sparc/cpupi.pas

@@ -77,7 +77,7 @@ implementation
             <register window save area for calling>
             <register window save area for calling>
           %sp
           %sp
         }
         }
-        result:=Align(lasttemp+savearea,4);
+        result:=Align(tg.lasttemp+savearea,4);
       end;
       end;
 
 
 
 
@@ -86,7 +86,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.19  2003-08-20 17:48:49  peter
+  Revision 1.20  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.19.2.1  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.19  2003/08/20 17:48:49  peter
     * fixed stackalloc to not allocate localst.datasize twice
     * fixed stackalloc to not allocate localst.datasize twice
     * order of stackalloc code fixed for implicit init/final
     * order of stackalloc code fixed for implicit init/final
 
 

+ 0 - 63
compiler/sparc/cpuregs.inc

@@ -1,63 +0,0 @@
-{******************************************************************************
-  $Id$
-  Author                 : Mazen NEIFER                                       
-  Project                : Free Pascal Compiler (FPC)                         
-  Creation date          : 2002\05\08                                         
-  Licence                : GPL                                                
-  Bug report             : [email protected]                        
-******************************************************************************}
-R_NONE
-{General purpose global registers}
-,R_G0{This register is usually set to zero and used as a scratch register}
-,R_G1,R_G2,R_G3,R_G4,R_G5,R_G6,R_G7
-{General purpose out registers}
-,R_O0,R_O1,R_O2,R_O3,R_O4,R_O5,R_O6
-,R_O7{This register is used to save the address of the last CALL instruction}
-{General purpose local registers}
-,R_L0
-,R_L1{This register is used to save the Program Counter (PC) after a Trap}
-,R_L2{This register is used to save the Program Counter (nPC) after a Trap}
-,R_L3,R_L4,R_L5,R_L6,R_L7
-{General purpose in registers}
-,R_I0,R_I1,R_I2,R_I3,R_I4,R_I5,R_I6,R_I7
-{Floating point registers}
-,R_F0,R_F1,R_F2,R_F3,R_F4,R_F5,R_F6,R_F7
-,R_F8,R_F9,R_F10,R_F11,R_F12,R_F13,R_F14,R_F15
-,R_F16,R_F17,R_F18,R_F19,R_F20,R_F21,R_F22,R_F23
-,R_F24,R_F25,R_F26,R_F27,R_F28,R_F29,R_F30,R_F31
-{Floating point status/"front of queue" registers}
-,R_FSR,R_FQ
-{Coprocessor registers}
-,R_C0,R_C1,R_C2,R_C3,R_C4,R_C5,R_C6,R_C7
-,R_C8,R_C9,R_C10,R_C11,R_C12,R_C13,R_C14,R_C15
-,R_C16,R_C17,R_C18,R_C19,R_C20,R_C21,R_C22,R_C23
-,R_C24,R_C25,R_C26,R_C27,R_C28,R_C29,R_C30,R_C31
-{Coprocessor status/queue registers}
-,R_CSR
-,R_CQ
-{Integer Unit control & status registers}
-,R_PSR{Processor Status Register : informs upon the program status}
-,R_TBR{Trap Base Register : saves the Trap vactor base address}
-,R_WIM{Window Invalid Mask : }
-,R_Y{Multiply/Devide Register : }
-{Ancillary State Registers : these are implementation dependent registers and
-thus, are not specified by the SPARC Reference Manual. I did choose the SUN's
-implementation according to the Assembler Refernce Manual.(MN)}
-,R_ASR0,R_ASR1,R_ASR2,R_ASR3,R_ASR4,R_ASR5,R_ASR6,R_ASR7
-,R_ASR8,R_ASR9,R_ASR10,R_ASR11,R_ASR12,R_ASR13,R_ASR14,R_ASR15
-,R_ASR16,R_ASR17,R_ASR18,R_ASR19,R_ASR20,R_ASR21,R_ASR22,R_ASR23
-,R_ASR24,R_ASR25,R_ASR26,R_ASR27,R_ASR28,R_ASR29,R_ASR30,R_ASR31
-{The following registers are just used with the new register allocator}
-,R_INTREGISTER,R_FLOATREGISTER,R_MMXREGISTER,R_KNIREGISTER
-{
-  $Log$
-  Revision 1.1  2003-04-29 11:53:38  mazen
-  + This file is used to define all cpu registers physically available
-
-  Revision 1.3  2003/01/20 22:21:36  mazen
-  * many stuff related to RTL fixed
-
-  Revision 1.2  2002/10/02 22:20:28  mazen
-  + out registers allocator for the first 6 scalar parameters which must be passed into %o0..%o5
-
-}

+ 13 - 21
compiler/sparc/ncpuadd.pas

@@ -183,19 +183,14 @@ interface
 
 
 
 
     procedure tsparcaddnode.second_cmpboolean;
     procedure tsparcaddnode.second_cmpboolean;
-      var
-        zeroreg : tregister;
       begin
       begin
         pass_left_right;
         pass_left_right;
         force_reg_left_right(true,true);
         force_reg_left_right(true,true);
 
 
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
-
         if right.location.loc = LOC_CONSTANT then
         if right.location.loc = LOC_CONSTANT then
-          tcgsparc(cg).handle_reg_const_reg(exprasmlist,A_SUBcc,left.location.register,right.location.value,zeroreg)
+          tcgsparc(cg).handle_reg_const_reg(exprasmlist,A_SUBcc,left.location.register,right.location.value,NR_G0)
         else
         else
-          exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUBcc,left.location.register,right.location.register,zeroreg));
+          exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUBcc,left.location.register,right.location.register,NR_G0));
 
 
         location_reset(location,LOC_FLAGS,OS_NO);
         location_reset(location,LOC_FLAGS,OS_NO);
         location.resflags:=getresflags(true);
         location.resflags:=getresflags(true);
@@ -205,19 +200,14 @@ interface
 
 
 
 
     procedure tsparcaddnode.second_cmpsmallset;
     procedure tsparcaddnode.second_cmpsmallset;
-      var
-        zeroreg : tregister;
       begin
       begin
         pass_left_right;
         pass_left_right;
         force_reg_left_right(true,true);
         force_reg_left_right(true,true);
 
 
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
-
         if right.location.loc = LOC_CONSTANT then
         if right.location.loc = LOC_CONSTANT then
-          tcgsparc(cg).handle_reg_const_reg(exprasmlist,A_SUBcc,left.location.register,right.location.value,zeroreg)
+          tcgsparc(cg).handle_reg_const_reg(exprasmlist,A_SUBcc,left.location.register,right.location.value,NR_G0)
         else
         else
-          exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUBcc,left.location.register,right.location.register,zeroreg));
+          exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUBcc,left.location.register,right.location.register,NR_G0));
 
 
         location_reset(location,LOC_FLAGS,OS_NO);
         location_reset(location,LOC_FLAGS,OS_NO);
         location.resflags:=getresflags(true);
         location.resflags:=getresflags(true);
@@ -243,7 +233,6 @@ interface
 
 
     procedure tsparcaddnode.second_cmpordinal;
     procedure tsparcaddnode.second_cmpordinal;
       var
       var
-        zeroreg : tregister;
         unsigned : boolean;
         unsigned : boolean;
       begin
       begin
         pass_left_right;
         pass_left_right;
@@ -252,13 +241,10 @@ interface
         unsigned:=not(is_signed(left.resulttype.def)) or
         unsigned:=not(is_signed(left.resulttype.def)) or
                   not(is_signed(right.resulttype.def));
                   not(is_signed(right.resulttype.def));
 
 
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
-
         if right.location.loc = LOC_CONSTANT then
         if right.location.loc = LOC_CONSTANT then
-          tcgsparc(cg).handle_reg_const_reg(exprasmlist,A_SUBcc,left.location.register,right.location.value,zeroreg)
+          tcgsparc(cg).handle_reg_const_reg(exprasmlist,A_SUBcc,left.location.register,right.location.value,NR_G0)
         else
         else
-          exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUBcc,left.location.register,right.location.register,zeroreg));
+          exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUBcc,left.location.register,right.location.register,NR_G0));
 
 
         location_reset(location,LOC_FLAGS,OS_NO);
         location_reset(location,LOC_FLAGS,OS_NO);
         location.resflags:=getresflags(unsigned);
         location.resflags:=getresflags(unsigned);
@@ -271,7 +257,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.18  2003-07-08 21:25:00  peter
+  Revision 1.19  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.18.2.1  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.18  2003/07/08 21:25:00  peter
     * sparc fixes
     * sparc fixes
 
 
   Revision 1.17  2003/07/06 22:09:50  peter
   Revision 1.17  2003/07/06 22:09:50  peter

+ 10 - 39
compiler/sparc/ncpumat.pas

@@ -74,17 +74,10 @@ implementation
          numerator,
          numerator,
          divider,
          divider,
          resultreg  : tregister;
          resultreg  : tregister;
-         saved      : tmaybesave;
 
 
       begin
       begin
          secondpass(left);
          secondpass(left);
-{$ifndef newra}
-         maybe_save(exprasmlist,right.registers32,left.location,saved);
-{$endif}
          secondpass(right);
          secondpass(right);
-{$ifndef newra}
-         maybe_restore(exprasmlist,left.location,saved);
-{$endif}
          location_copy(location,left.location);
          location_copy(location,left.location);
 
 
          { put numerator in register }
          { put numerator in register }
@@ -99,33 +92,19 @@ implementation
              resultreg := location.register;
              resultreg := location.register;
            end;
            end;
          if (nodetype = modn) then
          if (nodetype = modn) then
-           begin
-{$ifdef newra}
-             resultreg := rg.getregisterint(exprasmlist,OS_INT);
-{$else}
-             resultreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
-{$endif}
-           end;
+           resultreg := rg.getregisterint(exprasmlist,OS_INT);
 
 
          if (nodetype = divn) and
          if (nodetype = divn) and
             (right.nodetype = ordconstn) and
             (right.nodetype = ordconstn) and
             ispowerof2(tordconstnode(right).value,power) then
             ispowerof2(tordconstnode(right).value,power) then
            begin
            begin
-{$ifdef newra}
              tmpreg:=rg.getregisterint(exprasmlist,OS_INT);
              tmpreg:=rg.getregisterint(exprasmlist,OS_INT);
-{$else}
-             tmpreg:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
-{$endif}
              cg.a_op_const_reg_reg(exprasmlist,OP_SAR,OS_INT,31,numerator,tmpreg);
              cg.a_op_const_reg_reg(exprasmlist,OP_SAR,OS_INT,31,numerator,tmpreg);
              { if signed, tmpreg=right value-1, otherwise 0 }
              { if signed, tmpreg=right value-1, otherwise 0 }
              cg.a_op_const_reg(exprasmlist,OP_AND,OS_INT,tordconstnode(right).value-1,tmpreg);
              cg.a_op_const_reg(exprasmlist,OP_AND,OS_INT,tordconstnode(right).value-1,tmpreg);
              { add to the left value }
              { add to the left value }
              cg.a_op_reg_reg(exprasmlist,OP_ADD,OS_INT,tmpreg,numerator);
              cg.a_op_reg_reg(exprasmlist,OP_ADD,OS_INT,tmpreg,numerator);
-{$ifdef newra}
              rg.ungetregisterint(exprasmlist,tmpreg);
              rg.ungetregisterint(exprasmlist,tmpreg);
-{$else}
-             cg.free_scratch_reg(exprasmlist,tmpreg);
-{$endif}
              cg.a_op_const_reg_reg(exprasmlist,OP_SAR,OS_INT,aword(power),numerator,resultreg);
              cg.a_op_const_reg_reg(exprasmlist,OP_SAR,OS_INT,aword(power),numerator,resultreg);
            end
            end
          else
          else
@@ -147,18 +126,14 @@ implementation
                  exprasmlist.concat(taicpu.op_reg_reg_reg(A_SMUL,resultreg,divider,resultreg));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(A_SMUL,resultreg,divider,resultreg));
                  rg.UnGetRegisterInt(exprasmlist,divider);
                  rg.UnGetRegisterInt(exprasmlist,divider);
                  exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUB,location.register,numerator,resultreg));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUB,location.register,numerator,resultreg));
-  {$ifdef newra}
                  rg.ungetregisterint(exprasmlist,resultreg);
                  rg.ungetregisterint(exprasmlist,resultreg);
-  {$else}
-                 cg.free_scratch_reg(exprasmlist,resultreg);
-  {$endif}
                  resultreg := location.register;
                  resultreg := location.register;
                end
                end
              else
              else
                rg.UnGetRegisterInt(exprasmlist,divider);
                rg.UnGetRegisterInt(exprasmlist,divider);
            end;
            end;
         { free used registers }
         { free used registers }
-        if numerator.number <> resultreg.number then
+        if numerator<>resultreg then
           rg.ungetregisterint(exprasmlist,numerator);
           rg.ungetregisterint(exprasmlist,numerator);
         { set result location }
         { set result location }
         location.loc:=LOC_REGISTER;
         location.loc:=LOC_REGISTER;
@@ -183,17 +158,10 @@ procedure tSparcshlshrnode.pass_2;
     op : topcg;
     op : topcg;
     asmop1, asmop2: tasmop;
     asmop1, asmop2: tasmop;
     shiftval: aword;
     shiftval: aword;
-    saved : tmaybesave;
     r:Tregister;
     r:Tregister;
   begin
   begin
     secondpass(left);
     secondpass(left);
-{$ifndef newra}
-    maybe_save(exprasmlist,right.registers32,left.location,saved);
-{$endif}
     secondpass(right);
     secondpass(right);
-{$ifndef newra}
-    maybe_restore(exprasmlist,left.location,saved);
-{$endif}
     if is_64bitint(left.resulttype.def)
     if is_64bitint(left.resulttype.def)
     then
     then
       begin
       begin
@@ -303,7 +271,6 @@ procedure tSparcshlshrnode.pass_2;
     procedure tsparcnotnode.second_boolean;
     procedure tsparcnotnode.second_boolean;
       var
       var
         hl : tasmlabel;
         hl : tasmlabel;
-        zeroreg : tregister;
       begin
       begin
         { if the location is LOC_JUMP, we do the secondpass after the
         { if the location is LOC_JUMP, we do the secondpass after the
           labels are allocated
           labels are allocated
@@ -332,9 +299,7 @@ procedure tSparcshlshrnode.pass_2;
               LOC_REGISTER, LOC_CREGISTER, LOC_REFERENCE, LOC_CREFERENCE :
               LOC_REGISTER, LOC_CREGISTER, LOC_REFERENCE, LOC_CREFERENCE :
                 begin
                 begin
                   location_force_reg(exprasmlist,left.location,def_cgsize(left.resulttype.def),true);
                   location_force_reg(exprasmlist,left.location,def_cgsize(left.resulttype.def),true);
-                  zeroreg.enum:=R_INTREGISTER;
-                  zeroreg.number:=NR_G0;
-                  exprasmlist.concat(taicpu.op_reg_const_reg(A_SUBcc,left.location.register,0,zeroreg));
+                  exprasmlist.concat(taicpu.op_reg_const_reg(A_SUBcc,left.location.register,0,NR_G0));
                   location_release(exprasmlist,left.location);
                   location_release(exprasmlist,left.location);
                   location_reset(location,LOC_FLAGS,OS_NO);
                   location_reset(location,LOC_FLAGS,OS_NO);
                   location.resflags:=F_E;
                   location.resflags:=F_E;
@@ -353,13 +318,19 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2003-09-03 11:18:37  florian
+  Revision 1.14  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.13  2003/09/03 11:18:37  florian
     * fixed arm concatcopy
     * fixed arm concatcopy
     + arm support in the common compiler sources added
     + arm support in the common compiler sources added
     * moved some generic cg code around
     * moved some generic cg code around
     + tfputype added
     + tfputype added
     * ...
     * ...
 
 
+  Revision 1.12.2.1  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
   Revision 1.12  2003/07/06 22:09:32  peter
   Revision 1.12  2003/07/06 22:09:32  peter
     * shr and div fixed
     * shr and div fixed
 
 

+ 12 - 7
compiler/sparc/radirect.pas

@@ -46,7 +46,7 @@ interface
        scanner,
        scanner,
        rautils,
        rautils,
        { codegen }
        { codegen }
-       cgbase,
+       cginfo,cgbase,
        { constants }
        { constants }
        aggas,cpubase,globtype
        aggas,cpubase,globtype
        ;
        ;
@@ -88,9 +88,8 @@ interface
           is_fpu(current_procinfo.procdef.rettype.def) then
           is_fpu(current_procinfo.procdef.rettype.def) then
          tvarsym(current_procinfo.procdef.funcretsym).varstate:=vs_assigned;
          tvarsym(current_procinfo.procdef.funcretsym).varstate:=vs_assigned;
        framereg:=current_procinfo.framepointer;
        framereg:=current_procinfo.framepointer;
-       convert_register_to_enum(framereg);
        if (not is_void(current_procinfo.procdef.rettype.def)) then
        if (not is_void(current_procinfo.procdef.rettype.def)) then
-         retstr:=upper(tostr(tvarsym(current_procinfo.procdef.funcretsym).adjusted_address)+'('+std_reg2str[framereg.enum]+')')
+         retstr:=upper(tostr(tvarsym(current_procinfo.procdef.funcretsym).adjusted_address)+'('+std_regname(framereg)+')')
        else
        else
          retstr:='';
          retstr:='';
 
 
@@ -172,7 +171,7 @@ interface
                                             hs:=tvarsym(sym).mangledname
                                             hs:=tvarsym(sym).mangledname
                                           else
                                           else
                                             hs:='-'+tostr(tvarsym(sym).address)+
                                             hs:='-'+tostr(tvarsym(sym).address)+
-                                                '('+std_reg2str[current_procinfo.framepointer.enum]+')';
+                                                '('+std_regname(current_procinfo.framepointer)+')';
                                           end
                                           end
                                         else
                                         else
                                         { call to local function }
                                         { call to local function }
@@ -195,7 +194,7 @@ interface
                                                   l:=tvarsym(sym).address;
                                                   l:=tvarsym(sym).address;
                                                   { set offset }
                                                   { set offset }
                                                   inc(l,current_procinfo.procdef.parast.address_fixup);
                                                   inc(l,current_procinfo.procdef.parast.address_fixup);
-                                                  hs:=tostr(l)+'('+std_reg2str[current_procinfo.framepointer.enum]+')';
+                                                  hs:=tostr(l)+'('+std_regname(current_procinfo.framepointer)+')';
                                                   if pos(',',s) > 0 then
                                                   if pos(',',s) > 0 then
                                                     tvarsym(sym).varstate:=vs_used;
                                                     tvarsym(sym).varstate:=vs_used;
                                                end;
                                                end;
@@ -283,7 +282,7 @@ interface
                                                 varsym :
                                                 varsym :
                                                   begin
                                                   begin
                                                     hs:=tostr(tvarsym(sym).adjusted_address)+
                                                     hs:=tostr(tvarsym(sym).adjusted_address)+
-                                                        '('+std_reg2str[framereg.enum]+')';
+                                                        '('+std_regname(framereg)+')';
                                                     inc(tvarsym(sym).refs);
                                                     inc(tvarsym(sym).refs);
                                                   end;
                                                   end;
                                                 typedconstsym :
                                                 typedconstsym :
@@ -340,7 +339,13 @@ initialization
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2003-08-11 09:15:53  mazen
+  Revision 1.14  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.13.2.1  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.13  2003/08/11 09:15:53  mazen
   - removed uncommon file header!
   - removed uncommon file header!
 
 
   Revision 1.12  2003/06/13 21:19:32  peter
   Revision 1.12  2003/06/13 21:19:32  peter

+ 8 - 1
compiler/sparc/rasm.pas

@@ -58,13 +58,20 @@ Implementation
 
 
     function assemble : tnode;
     function assemble : tnode;
      begin
      begin
+       result:=nil;
      end;
      end;
 
 
 Begin
 Begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2002-08-23 10:08:28  mazen
+  Revision 1.2  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.1.2.1  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.1  2002/08/23 10:08:28  mazen
   *** empty log message ***
   *** empty log message ***
 
 
   Revision 1.2  2002/08/11 06:14:41  florian
   Revision 1.2  2002/08/11 06:14:41  florian

+ 23 - 58
compiler/sparc/rgcpu.pas

@@ -36,13 +36,6 @@ interface
 
 
     type
     type
       trgcpu=class(trgobj)
       trgcpu=class(trgobj)
-{$ifndef NEWRA}
-      private
-        UsedParaRegs: TSupRegSet;
-      public
-        function GetExplicitRegisterInt(list:taasmoutput;Reg:Tnewregister):tregister;override;
-        procedure UngetregisterInt(list:taasmoutput;Reg:tregister);override;
-{$endif NEWRA}
         function GetRegisterFpu(list:TAasmOutput;size:Tcgsize):TRegister;override;
         function GetRegisterFpu(list:TAasmOutput;size:Tcgsize):TRegister;override;
         procedure UngetRegisterFpu(list:taasmoutput;reg:tregister;size:TCGsize);override;
         procedure UngetRegisterFpu(list:taasmoutput;reg:tregister;size:TCGsize);override;
         procedure ClearTempGen;override;
         procedure ClearTempGen;override;
@@ -55,45 +48,9 @@ implementation
       cgobj,verbose;
       cgobj,verbose;
 
 
 
 
-{$ifndef NEWRA}
-    function TRgCpu.GetExplicitRegisterInt(list:TAasmOutput;reg:TNewRegister):TRegister;
-      begin
-        if ((reg shr 8) in [RS_O0..RS_O7,RS_I0..RS_I7]) then
-          begin
-            if (reg shr 8) in UsedParaRegs then
-              InternalError(2003060701)
-              ;
-            include(UsedParaRegs,reg shr 8);
-            result.enum:=R_INTREGISTER;
-            result.number:=reg;
-            cg.a_reg_alloc(list,result);
-          end
-        else
-          result:=inherited GetExplicitRegisterInt(list,reg);
-      end;
-
-
-    procedure trgcpu.UngetRegisterInt(list:taasmoutput;reg:tregister);
-      begin
-        if reg.enum<>R_INTREGISTER then
-          internalerror(200302191);
-        if ((reg.number shr 8) in [RS_O0..RS_O7,RS_I0..RS_I7]) then
-          begin
-            if not((reg.number shr 8) in usedpararegs) then
-              internalerror(2003060702)
-              ;
-            exclude(usedpararegs,reg.number shr 8);
-            cg.a_reg_dealloc(list,reg);
-          end
-        else
-          inherited ungetregisterint(list,reg);
-      end;
-{$endif NEWRA}
-
-
     function TRgCpu.GetRegisterFpu(list:TAasmOutput;size:Tcgsize):TRegister;
     function TRgCpu.GetRegisterFpu(list:TAasmOutput;size:Tcgsize):TRegister;
       var
       var
-        i: Toldregister;
+        i: Tsuperregister;
         r: Tregister;
         r: Tregister;
       begin
       begin
         for i:=firstsavefpureg to lastsavefpureg do
         for i:=firstsavefpureg to lastsavefpureg do
@@ -101,19 +58,19 @@ implementation
             if (i in unusedregsfpu) and
             if (i in unusedregsfpu) and
                (
                (
                 (size=OS_F32) or
                 (size=OS_F32) or
-                (not odd(ord(i)-ord(R_F0)))
+                (not odd(i-RS_F0))
                ) then
                ) then
               begin
               begin
                  exclude(unusedregsfpu,i);
                  exclude(unusedregsfpu,i);
                  dec(countunusedregsfpu);
                  dec(countunusedregsfpu);
-                 r.enum:=i;
+                 r:=newreg(R_FPUREGISTER,i,R_SUBNONE);
                  list.concat(tai_regalloc.alloc(r));
                  list.concat(tai_regalloc.alloc(r));
                  result := r;
                  result := r;
                  { double need 2 FPU registers }
                  { double need 2 FPU registers }
                  if size=OS_F64 then
                  if size=OS_F64 then
                    begin
                    begin
-                     r.enum:=succ(i);
-                     exclude(unusedregsfpu,r.enum);
+                     r:=newreg(R_FPUREGISTER,i+1,R_SUBNONE);
+                     exclude(unusedregsfpu,i+1);
                      dec(countunusedregsfpu);
                      dec(countunusedregsfpu);
                      list.concat(tai_regalloc.alloc(r));
                      list.concat(tai_regalloc.alloc(r));
                    end;
                    end;
@@ -127,21 +84,22 @@ implementation
     procedure trgcpu.UngetRegisterFpu(list:taasmoutput;reg:tregister;size:TCGsize);
     procedure trgcpu.UngetRegisterFpu(list:taasmoutput;reg:tregister;size:TCGsize);
       var
       var
         r : tregister;
         r : tregister;
+        supreg : tsuperregister;
       begin
       begin
+        supreg:=getsupreg(reg);
         { double need 2 FPU registers }
         { double need 2 FPU registers }
         if (size=OS_F64) then
         if (size=OS_F64) then
           begin
           begin
             { Only even FP registers are allowed }
             { Only even FP registers are allowed }
-            if (odd(ord(reg.enum)-ord(R_F0))) then
+            if odd(supreg-RS_F0) then
               internalerror(200306101);
               internalerror(200306101);
-            r:=reg;
-            r.enum:=succ(r.enum);
+            r:=newreg(R_FPUREGISTER,supreg+1,R_SUBNONE);
             inc(countunusedregsfpu);
             inc(countunusedregsfpu);
-            include(unusedregsfpu,r.enum);
+            include(unusedregsfpu,getsupreg(r));
             list.concat(tai_regalloc.dealloc(r));
             list.concat(tai_regalloc.dealloc(r));
           end;
           end;
         inc(countunusedregsfpu);
         inc(countunusedregsfpu);
-        include(unusedregsfpu,reg.enum);
+        include(unusedregsfpu,supreg);
         list.concat(tai_regalloc.dealloc(reg));
         list.concat(tai_regalloc.dealloc(reg));
       end;
       end;
 
 
@@ -149,17 +107,24 @@ implementation
     procedure trgcpu.cleartempgen;
     procedure trgcpu.cleartempgen;
       begin
       begin
         inherited cleartempgen;
         inherited cleartempgen;
-{$ifndef NEWRA}
-        usedpararegs:=[];
-{$endif NEWRA}
       end;
       end;
 
 
 begin
 begin
-  rg := trgcpu.create(24); {24 registers.}
+  { Only use %o and %l }
+  rg := trgcpu.create(16);
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.16  2003-08-11 21:18:20  peter
+  Revision 1.17  2003-09-03 15:55:01  peter
+    * NEWRA branch merged
+
+  Revision 1.16.2.2  2003/09/02 17:49:17  peter
+    * newra updates
+
+  Revision 1.16.2.1  2003/09/01 21:02:55  peter
+    * sparc updates for new tregister
+
+  Revision 1.16  2003/08/11 21:18:20  peter
     * start of sparc support for newra
     * start of sparc support for newra
 
 
   Revision 1.15  2003/07/02 22:18:04  peter
   Revision 1.15  2003/07/02 22:18:04  peter

+ 138 - 0
compiler/sparc/rspcon.inc

@@ -0,0 +1,138 @@
+{ don't edit, this file is generated from spreg.dat }
+NR_NO = $00000000;
+NR_G0 = $01000000;
+NR_G1 = $01000001;
+NR_G2 = $01000002;
+NR_G3 = $01000003;
+NR_G4 = $01000004;
+NR_G5 = $01000005;
+NR_G6 = $01000006;
+NR_G7 = $01000007;
+NR_O0 = $01000008;
+NR_O1 = $01000009;
+NR_O2 = $0100000a;
+NR_O3 = $0100000b;
+NR_O4 = $0100000c;
+NR_O5 = $0100000d;
+NR_O6 = $0100000e;
+NR_O7 = $0100000f;
+NR_L0 = $01000010;
+NR_L1 = $01000011;
+NR_L2 = $01000012;
+NR_L3 = $01000013;
+NR_L4 = $01000014;
+NR_L5 = $01000015;
+NR_L6 = $01000016;
+NR_L7 = $01000017;
+NR_I0 = $01000018;
+NR_I1 = $01000019;
+NR_I2 = $0100001a;
+NR_I3 = $0100001b;
+NR_I4 = $0100001c;
+NR_I5 = $0100001d;
+NR_I6 = $0100001e;
+NR_I7 = $0100001f;
+NR_F0 = $02000000;
+NR_F1 = $02000001;
+NR_F2 = $02000002;
+NR_F3 = $02000003;
+NR_F4 = $02000004;
+NR_F5 = $02000005;
+NR_F6 = $02000006;
+NR_F7 = $02000007;
+NR_F8 = $02000008;
+NR_F9 = $02000009;
+NR_F10 = $0200000a;
+NR_F11 = $0200000b;
+NR_F12 = $0200000c;
+NR_F13 = $0200000d;
+NR_F14 = $0200000e;
+NR_F15 = $0200000f;
+NR_F16 = $02000010;
+NR_F17 = $02000011;
+NR_F18 = $02000012;
+NR_F19 = $02000013;
+NR_F20 = $02000014;
+NR_F21 = $02000015;
+NR_F22 = $02000016;
+NR_F23 = $02000017;
+NR_F24 = $02000018;
+NR_F25 = $02000019;
+NR_F26 = $0200001a;
+NR_F27 = $0200001b;
+NR_F28 = $0200001c;
+NR_F29 = $0200001d;
+NR_F30 = $0200001e;
+NR_F31 = $0200001f;
+NR_C0 = $03000000;
+NR_C1 = $03000001;
+NR_C2 = $03000002;
+NR_C3 = $03000003;
+NR_C4 = $03000004;
+NR_C5 = $03000005;
+NR_C6 = $03000006;
+NR_C7 = $03000007;
+NR_C8 = $03000008;
+NR_C9 = $03000009;
+NR_C10 = $0300000a;
+NR_C11 = $0300000b;
+NR_C12 = $0300000c;
+NR_C13 = $0300000d;
+NR_C14 = $0300000e;
+NR_C15 = $0300000f;
+NR_C16 = $03000010;
+NR_C17 = $03000011;
+NR_C18 = $03000012;
+NR_C19 = $03000013;
+NR_C20 = $03000014;
+NR_C21 = $03000015;
+NR_C22 = $03000016;
+NR_C23 = $03000017;
+NR_C24 = $03000018;
+NR_C25 = $03000019;
+NR_C26 = $0300001a;
+NR_C27 = $0300001b;
+NR_C28 = $0300001c;
+NR_C29 = $0300001d;
+NR_C30 = $0300001e;
+NR_C31 = $0300001f;
+NR_FSR = $05000000;
+NR_FQ = $05000001;
+NR_CSR = $05000002;
+NR_CQ = $05000003;
+NR_PSR = $05000004;
+NR_TBR = $05000005;
+NR_WIM = $05000006;
+NR_Y = $05000007;
+NR_ASR0 = $04000000;
+NR_ASR1 = $04000001;
+NR_ASR2 = $04000002;
+NR_ASR3 = $04000003;
+NR_ASR4 = $04000004;
+NR_ASR5 = $04000005;
+NR_ASR6 = $04000006;
+NR_ASR7 = $04000007;
+NR_ASR8 = $04000008;
+NR_ASR9 = $04000009;
+NR_ASR10 = $0400000a;
+NR_ASR11 = $0400000b;
+NR_ASR12 = $0400000c;
+NR_ASR13 = $0400000d;
+NR_ASR14 = $0400000e;
+NR_ASR15 = $0400000f;
+NR_ASR16 = $04000010;
+NR_ASR17 = $04000011;
+NR_ASR18 = $04000012;
+NR_ASR19 = $04000013;
+NR_ASR20 = $04000014;
+NR_ASR21 = $04000015;
+NR_ASR22 = $04000016;
+NR_ASR23 = $04000017;
+NR_ASR24 = $04000018;
+NR_ASR25 = $04000019;
+NR_ASR26 = $0400001a;
+NR_ASR27 = $0400001b;
+NR_ASR28 = $0400001c;
+NR_ASR29 = $0400001d;
+NR_ASR30 = $0400001e;
+NR_ASR31 = $0400001f;

+ 2 - 0
compiler/sparc/rspnor.inc

@@ -0,0 +1,2 @@
+{ don't edit, this file is generated from spreg.dat }
+137

+ 138 - 0
compiler/sparc/rspnum.inc

@@ -0,0 +1,138 @@
+{ don't edit, this file is generated from spreg.dat }
+$00000000,
+$01000000,
+$01000001,
+$01000002,
+$01000003,
+$01000004,
+$01000005,
+$01000006,
+$01000007,
+$01000008,
+$01000009,
+$0100000a,
+$0100000b,
+$0100000c,
+$0100000d,
+$0100000e,
+$0100000f,
+$01000010,
+$01000011,
+$01000012,
+$01000013,
+$01000014,
+$01000015,
+$01000016,
+$01000017,
+$01000018,
+$01000019,
+$0100001a,
+$0100001b,
+$0100001c,
+$0100001d,
+$0100001e,
+$0100001f,
+$02000000,
+$02000001,
+$02000002,
+$02000003,
+$02000004,
+$02000005,
+$02000006,
+$02000007,
+$02000008,
+$02000009,
+$0200000a,
+$0200000b,
+$0200000c,
+$0200000d,
+$0200000e,
+$0200000f,
+$02000010,
+$02000011,
+$02000012,
+$02000013,
+$02000014,
+$02000015,
+$02000016,
+$02000017,
+$02000018,
+$02000019,
+$0200001a,
+$0200001b,
+$0200001c,
+$0200001d,
+$0200001e,
+$0200001f,
+$03000000,
+$03000001,
+$03000002,
+$03000003,
+$03000004,
+$03000005,
+$03000006,
+$03000007,
+$03000008,
+$03000009,
+$0300000a,
+$0300000b,
+$0300000c,
+$0300000d,
+$0300000e,
+$0300000f,
+$03000010,
+$03000011,
+$03000012,
+$03000013,
+$03000014,
+$03000015,
+$03000016,
+$03000017,
+$03000018,
+$03000019,
+$0300001a,
+$0300001b,
+$0300001c,
+$0300001d,
+$0300001e,
+$0300001f,
+$05000000,
+$05000001,
+$05000002,
+$05000003,
+$05000004,
+$05000005,
+$05000006,
+$05000007,
+$04000000,
+$04000001,
+$04000002,
+$04000003,
+$04000004,
+$04000005,
+$04000006,
+$04000007,
+$04000008,
+$04000009,
+$0400000a,
+$0400000b,
+$0400000c,
+$0400000d,
+$0400000e,
+$0400000f,
+$04000010,
+$04000011,
+$04000012,
+$04000013,
+$04000014,
+$04000015,
+$04000016,
+$04000017,
+$04000018,
+$04000019,
+$0400001a,
+$0400001b,
+$0400001c,
+$0400001d,
+$0400001e,
+$0400001f

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