浏览代码

* NEWRA branch merged

peter 22 年之前
父节点
当前提交
6a8d5eb25d
共有 100 个文件被更改,包括 4659 次插入6946 次删除
  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
        cutils,cclasses,
        globtype,globals,systems,
-       cpuinfo,cpubase,
+       cginfo,cpuinfo,cpubase,
        symppu,
        aasmbase;
 
@@ -407,7 +407,7 @@ interface
       Taasmoutput=class;
 
       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
        }
@@ -445,15 +445,19 @@ interface
           procedure clearop(opidx:longint);
           function is_nop:boolean;virtual;abstract;
           function is_move:boolean;virtual;abstract;
-{$ifdef NEWRA}
           { 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;
                                    rgget:Trggetproc;
                                    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;
 
        { alignment for operator }
@@ -1536,8 +1540,6 @@ implementation
 
     procedure taicpu_abstract.loadref(opidx:longint;const r:treference);
       begin
-        if (r.base.enum=R_NO) or (r.index.enum=R_NO) then
-          internalerror(200308192);
         if opidx>=ops then
          ops:=opidx+1;
         with oper[opidx] do
@@ -1552,14 +1554,8 @@ implementation
 {$ifdef i386}
             { We allow this exception for i386, since overloading this would be
               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}
             typ:=top_ref;
             { mark symbol as used }
@@ -1621,6 +1617,269 @@ implementation
       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.
   ---------------------------------------------------------------------}
@@ -1802,24 +2061,20 @@ implementation
         begin
           case p.typ of
             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:
               begin
                 for i:=0 to Taicpu_abstract(p).ops-1 do
                   case Taicpu_abstract(p).oper[i].typ of
                     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:
                       begin
                         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;
 {$ifdef arm}
                     Top_shifterop:
@@ -1831,13 +2086,16 @@ implementation
                       end;
 {$endif arm}
                   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;
           p:=Tai(p.next);
@@ -1847,13 +2105,31 @@ implementation
 end.
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around
     + 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
     * remove convert_registers
 

+ 15 - 13
compiler/aggas.pas

@@ -71,7 +71,7 @@ implementation
       dos,
 {$endif Delphi}
       cutils,globtype,systems,
-      fmodule,finput,verbose,cpubase
+      fmodule,finput,verbose,cpubase,cginfo
 {$ifdef GDB}
   {$ifdef delphi}
       ,sysutils
@@ -314,11 +314,10 @@ var
       co       : comp;
       sin      : single;
       d        : double;
+{$ifdef cpuextended}
       e        : extended;
+{$endif cpuextended}
       do_line  : boolean;
-{$ifdef delphi}
-      _64bitarray : t64bitarray;
-{$endif}
     begin
       if not assigned(p) then
        exit;
@@ -399,14 +398,8 @@ var
            ait_regalloc :
              begin
                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;
 
            ait_tempalloc :
@@ -835,13 +828,22 @@ var
 end.
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around
     + 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
     * Fixed PowerPC compilation
 

+ 13 - 2
compiler/assemble.pas

@@ -1018,7 +1018,12 @@ Implementation
     function TInternalAssembler.TreePass1(hp:Tai):Tai;
       var
         InlineLevel,
-        i,l : longint;
+        l : longint;
+{$ifdef i386}
+{$ifndef NOAG386BIN}
+        i : longint;
+{$endif NOAG386BIN}
+{$endif i386}
       begin
         inlinelevel:=0;
         while assigned(hp) do
@@ -1635,7 +1640,13 @@ Implementation
 end.
 {
   $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
 
   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_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_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_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_const_loc(list : taasmoutput;value : qword;const l : tlocation);override;
         procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);override;
@@ -158,7 +158,7 @@ unit cg64f32;
       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
         tmpreg: tregister;
         tmpref: treference;
@@ -172,13 +172,9 @@ unit cg64f32;
           end;
         got_scratch:=false;
         tmpref := ref;
-        if (tmpref.base.number=reg.reglo.number) then
+        if (tmpref.base=reg.reglo) then
          begin
-         {$ifdef newra}
            tmpreg:=rg.getaddressregister(list);
-         {$else}
-           tmpreg := cg.get_scratch_reg_address(list);
-         {$endif}
            got_scratch:=true;
            cg.a_load_reg_reg(list,OS_ADDR,OS_ADDR,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 method and this method must be replaced by a more generic }
          { implementation FK                                              }
-         if (tmpref.index.number=reg.reglo.number) then
+         if (tmpref.index=reg.reglo) then
           begin
-          {$ifdef newra}
             tmpreg:=rg.getaddressregister(list);
-          {$else}
-            tmpreg:=cg.get_scratch_reg_address(list);
-          {$endif}
             got_scratch:=true;
             cg.a_load_reg_reg(list,OS_ADDR,OS_ADDR,tmpref.index,tmpreg);
             tmpref.index:=tmpreg;
           end;
         cg.a_load_ref_reg(list,OS_32,OS_32,tmpref,reg.reglo);
         inc(tmpref.offset,4);
-{$ifdef newra}
         if delete then
           begin
             tg.ungetiftemp(list,tmpref);
             reference_release(list,tmpref);
           end;
-{$endif}
         cg.a_load_ref_reg(list,OS_32,OS_32,tmpref,reg.reghi);
-{$ifdef newra}
         if got_scratch then
           rg.ungetregisterint(list,tmpreg);
-{$else}
-        if got_scratch then
-          cg.free_scratch_reg(list,tmpreg);
-{$endif}
       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
-      {$ifdef newra}
         if delete then
           rg.ungetregisterint(list,regsrc.reglo);
-      {$endif}
         cg.a_load_reg_reg(list,OS_32,OS_32,regsrc.reglo,regdst.reglo);
-      {$ifdef newra}
         if delete then
           rg.ungetregisterint(list,regsrc.reghi);
-      {$endif}
         cg.a_load_reg_reg(list,OS_32,OS_32,regsrc.reghi,regdst.reghi);
       end;
 
@@ -242,14 +223,14 @@ unit cg64f32;
       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
         case l.loc of
           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:
-            a_load64_reg_reg(list,l.register64,reg{$ifdef newra},delete{$endif});
+            a_load64_reg_reg(list,l.register64,reg,delete);
           LOC_CONSTANT :
             a_load64_const_reg(list,l.valueqword,reg);
           else
@@ -292,7 +273,7 @@ unit cg64f32;
           LOC_REFERENCE, LOC_CREFERENCE:
             a_load64_reg_ref(list,reg,l.reference);
           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
             internalerror(200112293);
         end;
@@ -435,22 +416,12 @@ unit cg64f32;
       var
         tempreg: tregister64;
       begin
-      {$ifdef newra}
         tempreg.reghi:=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);
-      {$ifdef newra}
         rg.ungetregisterint(list,tempreg.reglo);
         rg.ungetregisterint(list,tempreg.reghi);
-      {$else}
-        cg.free_scratch_reg(list,tempreg.reglo);
-        cg.free_scratch_reg(list,tempreg.reghi);
-      {$endif}
       end;
 
 
@@ -458,23 +429,13 @@ unit cg64f32;
       var
         tempreg: tregister64;
       begin
-      {$ifdef newra}
         tempreg.reghi:=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_load64_reg_ref(list,tempreg,ref);
-      {$ifdef newra}
         rg.ungetregisterint(list,tempreg.reglo);
         rg.ungetregisterint(list,tempreg.reghi);
-      {$else}
-        cg.free_scratch_reg(list,tempreg.reglo);
-        cg.free_scratch_reg(list,tempreg.reghi);
-      {$endif}
       end;
 
 
@@ -482,23 +443,13 @@ unit cg64f32;
       var
         tempreg: tregister64;
       begin
-      {$ifdef newra}
         tempreg.reghi:=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_load64_reg_ref(list,tempreg,ref);
-      {$ifdef newra}
         rg.ungetregisterint(list,tempreg.reglo);
         rg.ungetregisterint(list,tempreg.reghi);
-      {$else}
-        cg.free_scratch_reg(list,tempreg.reglo);
-        cg.free_scratch_reg(list,tempreg.reghi);
-      {$endif}
       end;
 
 
@@ -587,11 +538,7 @@ unit cg64f32;
                end
              else
                begin
-               {$ifdef newra}
                  hreg:=rg.getregisterint(list,OS_INT);
-               {$else}
-                 hreg := cg.get_scratch_reg_int(list,OS_INT);
-               {$endif}
                  got_scratch := true;
                  a_load64high_ref_reg(list,l.reference,hreg);
                end;
@@ -607,13 +554,8 @@ unit cg64f32;
                  cg.a_cmp_const_reg_label(list,OS_32,OC_EQ,aword(-1),hreg,neglabel);
                end;
              { !!! freeing of register should happen directly after compare! (JM) }
-           {$ifdef newra}
              if got_scratch then
                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 }
              cg.a_call_name(list,'FPC_RANGEERROR');
 
@@ -642,11 +584,7 @@ unit cg64f32;
                    end
                  else
                    begin
-                   {$ifdef newra}
                      hreg:=rg.getregisterint(list,OS_INT);
-                   {$else}
-                     hreg := cg.get_scratch_reg_int(list,OS_INT);
-                   {$endif}
                      got_scratch := true;
                      a_load64low_ref_reg(list,l.reference,hreg);
                    end;
@@ -654,13 +592,8 @@ unit cg64f32;
                  objectlibrary.getlabel(neglabel);
                  cg.a_cmp_const_reg_label(list,OS_32,OC_LT,0,hreg,neglabel);
                  { !!! freeing of register should happen directly after compare! (JM) }
-               {$ifdef newra}
                  if got_scratch then
                    rg.ungetregisterint(list,hreg);
-               {$else}
-                 if got_scratch then
-                   cg.free_scratch_reg(list,hreg);
-               {$endif}
 
                  cg.a_call_name(list,'FPC_RANGEERROR');
 
@@ -704,11 +637,7 @@ unit cg64f32;
                  end
                else
                  begin
-                 {$ifdef newra}
                    hreg:=rg.getregisterint(list,OS_INT);
-                 {$else}
-                   hreg := cg.get_scratch_reg_int(list,OS_INT);
-                 {$endif}
                    got_scratch := true;
 
                    opsize := def_cgsize(fromdef);
@@ -721,13 +650,8 @@ unit cg64f32;
                cg.a_cmp_const_reg_label(list,opsize,OC_GTE,0,hreg,poslabel);
 
                { !!! freeing of register should happen directly after compare! (JM) }
-             {$ifdef newra}
                if got_scratch then
                  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_label(list,poslabel);
              end;
@@ -838,7 +762,16 @@ begin
 end.
 {
   $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
     * sparc calling convention updates
 

+ 14 - 7
compiler/cgbase.pas

@@ -320,8 +320,7 @@ implementation
         parent_framepointer_offset:=0;
         firsttemp_offset:=0;
         flags:=[];
-        framepointer.enum:=R_INTREGISTER;
-        framepointer.number:=NR_FRAME_POINTER_REG;
+        framepointer:=NR_FRAME_POINTER_REG;
         { asmlists }
         aktproccode:=Taasmoutput.Create;
         aktlocaldata:=Taasmoutput.Create;
@@ -376,6 +375,7 @@ implementation
     procedure tprocinfo.handle_body_start;
       var
         paramloc : tparalocation;
+        regidx : tregisterindex;
       begin
          { generate callee paraloc register info }
          paramanager.create_paraloc_info(current_procinfo.procdef,calleeside);
@@ -396,18 +396,19 @@ implementation
                LOC_MMREGISTER,
                LOC_CMMREGISTER :
                  begin
-                   include(rg.used_in_proc_other,paramloc.register.enum);
+                   regidx:=findreg_by_number(paramloc.register);
+                   include(rg.used_in_proc_other,regidx);
                  end;
                LOC_REGISTER,LOC_CREGISTER :
                  begin
                    if ((paramloc.size in [OS_S64,OS_64]) and
                       (sizeof(aword) < 8)) then
                      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
                    else
-                     include(rg.used_in_proc_int,paramloc.register.number shr 8);
+                     include(rg.used_in_proc_int,getsupreg(paramloc.register));
                  end;
              end;
            end;
@@ -581,7 +582,13 @@ implementation
 end.
 {
   $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
 
   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_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
        tcgsize2size : Array[tcgsize] of integer =
          { integer values }
@@ -145,12 +203,118 @@ interface
             'LOC_MMREG',
             '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
 
+    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.
 {
   $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
       and aliases for result and function name are added using absolutesym
     * 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).
        }
        tcg = class
-{$ifndef newra}
-          {# List of currently unused scratch registers }
-          unusedscratchregisters:Tsupregset;
-{$endif}
-
           alignment : talignment;
           {************************************************}
           {                 basic routines                 }
@@ -80,31 +75,6 @@ unit cgobj;
           {# Deallocates register r by inserting a pa_regdealloc record}
           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.
 
              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_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
              a routine declared as @var(interrupt). The default
              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)
           }
-          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
              of a routine. It should restore all registers which were previously
              saved in @var(g_save_standard_registers).
 
              @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_restore_all_registers(list : taasmoutput;accused,acchiused:boolean);virtual;abstract;
        end;
@@ -445,10 +414,10 @@ unit cgobj;
         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_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_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_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;
@@ -509,10 +478,6 @@ unit cgobj;
        rgobj,cutils;
 
     const
-{$ifndef newra}
-      max_scratch_regs = high(scratch_regs) - low(scratch_regs) + 1;
-{$endif}
-
       { Please leave this here, this module should NOT use
         exprasmlist, the lists are always passed as arguments.
         Declaring it as string here results in an error when compiling (PFV) }
@@ -524,14 +489,7 @@ unit cgobj;
 
     constructor tcg.create;
 
-      var
-         i : longint;
-
       begin
-{$ifndef newra}
-         for i:=low(scratch_regs) to high(scratch_regs) do
-           include(unusedscratchregisters,scratch_regs[i]);
-{$endif}
       end;
 
     procedure tcg.a_reg_alloc(list : taasmoutput;r : tregister);
@@ -552,57 +510,14 @@ unit cgobj;
          list.concat(tai_label.create(l));
       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
 ******************************************************************************}
 
     procedure tcg.a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;const locpara : tparalocation);
-
       var
          ref : treference;
-         t : Tregister;
-
       begin
          case locpara.loc of
             LOC_REGISTER,LOC_CREGISTER:
@@ -610,11 +525,7 @@ unit cgobj;
             LOC_REFERENCE,LOC_CREFERENCE:
               begin
                  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);
                  ref.base:=locpara.reference.index;
                  ref.offset:=locpara.reference.offset;
@@ -631,36 +542,20 @@ unit cgobj;
          hr : tregister;
 
       begin
-      {$ifdef newra}
          hr:=rg.getregisterint(list,size);
-      {$else}
-         hr:=get_scratch_reg_int(list,size);
-      {$endif}
          a_load_const_reg(list,size,a,hr);
          a_param_reg(list,size,hr,locpara);
-      {$ifdef newra}
          rg.ungetregisterint(list,hr);
-      {$else}
-         free_scratch_reg(list,hr);
-      {$endif}
       end;
 
     procedure tcg.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);
       var
          hr : tregister;
       begin
-      {$ifdef newra}
          hr:=rg.getregisterint(list,size);
-      {$else}
-         hr:=get_scratch_reg_int(list,size);
-      {$endif}
          a_load_ref_reg(list,size,size,r,hr);
          a_param_reg(list,size,hr,locpara);
-      {$ifdef newra}
          rg.ungetregisterint(list,hr);
-      {$else}
-         free_scratch_reg(list,hr);
-      {$endif}
       end;
 
 
@@ -685,18 +580,10 @@ unit cgobj;
       var
          hr : tregister;
       begin
-      {$ifdef newra}
          hr:=rg.getaddressregister(list);
-      {$else newra}
-         hr:=get_scratch_reg_address(list);
-      {$endif}
          a_loadaddr_ref_reg(list,r,hr);
          a_param_reg(list,OS_ADDR,hr,locpara);
-      {$ifdef newra}
          rg.ungetregisterint(list,hr);
-      {$else}
-         free_scratch_reg(list,hr);
-      {$endif}
       end;
 
 
@@ -721,24 +608,20 @@ unit cgobj;
             begin
               if (locpara.size in [OS_S64,OS_64]) then
                 begin
-{$ifdef newra}
-{$ifdef cpu64bit} 
+{$ifdef cpu64bit}
                   rg.ungetregisterint(list,locpara.register64);
 {$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.registerhigh);
 {$endif cpu64bit}
-{$endif newra}
                   cg64.a_load64_reg_ref(list,locpara.register64,ref)
                 end
               else
                 begin
-{$ifdef newra}
-                  rg.getexplicitregisterint(list,locpara.register.number);
+                  rg.getexplicitregisterint(list,locpara.register);
                   rg.ungetregisterint(list,locpara.register);
-{$endif newra}
                   cg.a_load_reg_ref(list,locpara.size,locpara.size,locpara.register,ref);
                 end;
             end;
@@ -761,11 +644,9 @@ unit cgobj;
             begin
               if not(locpara.size in [OS_S64,OS_64]) then
                 begin
-{$ifdef newra}
-                  rg.getexplicitregisterint(list,locpara.register.number);
+                  rg.getexplicitregisterint(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)
                 end
               else
@@ -778,9 +659,7 @@ unit cgobj;
           LOC_CREFERENCE:
             begin
               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);
             end;
           else
@@ -794,94 +673,27 @@ unit cgobj;
 ****************************************************************************}
 
     procedure tcg.a_load_ref_ref(list : taasmoutput;fromsize,tosize : tcgsize;const sref : treference;const dref : treference);
-
       var
         tmpreg: tregister;
-{$ifdef i386}
-        pushed_reg: tregister;
-{$endif i386}
-
       begin
         { verify if we have the same reference }
         if references_equal(sref,dref) then
           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);
-{$else}
-        tmpreg := get_scratch_reg_int(list,tosize);
-{$endif}
         a_load_ref_reg(list,fromsize,tosize,sref,tmpreg);
         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);
-{$else}
-        free_scratch_reg(list,tmpreg);
-{$endif}
       end;
 
 
     procedure tcg.a_load_const_ref(list : taasmoutput;size : tcgsize;a : aword;const ref : treference);
-
       var
         tmpreg: tregister;
-
       begin
-{$ifdef newra}
         tmpreg:=rg.getregisterint(list,size);
-{$else}
-        tmpreg := get_scratch_reg_int(list,size);
-{$endif}
         a_load_const_reg(list,size,a,tmpreg);
         a_load_reg_ref(list,size,size,tmpreg,ref);
-{$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
-{$else}
-        free_scratch_reg(list,tmpreg);
-{$endif}
       end;
 
 
@@ -912,7 +724,6 @@ unit cgobj;
 
 
     procedure tcg.a_load_loc_reg(list : taasmoutput; tosize: tcgsize; const loc: tlocation; reg : tregister);
-
       begin
         case loc.loc of
           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);
-
       begin
         case loc.loc of
           LOC_REFERENCE,LOC_CREFERENCE:
@@ -947,18 +757,10 @@ unit cgobj;
       var
         tmpreg: tregister;
       begin
-{$ifdef newra}
         tmpreg:=rg.getaddressregister(list);
-{$else}
-        tmpreg := get_scratch_reg_address(list);
-{$endif}
         a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,tmpreg);
         a_call_reg(list,tmpreg);
-{$ifdef newra}
         rg.ungetaddressregister(list,tmpreg);
-{$else}
-        free_scratch_reg(list,tmpreg);
-{$endif}
       end;
 
 
@@ -1028,8 +830,8 @@ unit cgobj;
         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
         case loc.loc of
           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);
-
       begin
         case loc.loc of
           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);
-
       var
          ref : treference;
-         t : Tregister;
-
       begin
          case locpara.loc of
             LOC_FPUREGISTER,LOC_CFPUREGISTER:
@@ -1069,11 +867,7 @@ unit cgobj;
             LOC_REFERENCE,LOC_CREFERENCE:
               begin
                  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);
                  ref.base:=locpara.reference.index;
                  ref.offset:=locpara.reference.offset;
@@ -1102,19 +896,11 @@ unit cgobj;
         tmpreg: tregister;
 
       begin
-      {$ifdef newra}
         tmpreg:=rg.getregisterint(list,size);
-      {$else}
-        tmpreg := get_scratch_reg_int(list,size);
-      {$endif}
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_op_const_reg(list,op,size,a,tmpreg);
         a_load_reg_ref(list,size,size,tmpreg,ref);
-      {$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
-      {$else}
-        free_scratch_reg(list,tmpreg);
-      {$endif}
       end;
 
 
@@ -1138,19 +924,11 @@ unit cgobj;
         tmpreg: tregister;
 
       begin
-      {$ifdef newra}
         tmpreg:=rg.getregisterint(list,size);
-      {$else}
-        tmpreg := get_scratch_reg_int(list,size);
-      {$endif}
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_op_reg_reg(list,op,size,reg,tmpreg);
         a_load_reg_ref(list,size,size,tmpreg,ref);
-      {$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
-      {$else}
-        free_scratch_reg(list,tmpreg);
-      {$endif}
       end;
 
 
@@ -1169,18 +947,10 @@ unit cgobj;
             end;
           else
             begin
-            {$ifdef newra}
               tmpreg:=rg.getregisterint(list,size);
-            {$else}
-              tmpreg := get_scratch_reg_int(list,size);
-            {$endif}
               a_load_ref_reg(list,size,size,ref,tmpreg);
               a_op_reg_reg(list,op,size,tmpreg,reg);
-            {$ifdef newra}
               rg.ungetregisterint(list,tmpreg);
-            {$else}
-              free_scratch_reg(list,tmpreg);
-            {$endif}
             end;
         end;
       end;
@@ -1211,18 +981,10 @@ unit cgobj;
             a_op_ref_reg(list,op,loc.size,ref,loc.register);
           LOC_REFERENCE,LOC_CREFERENCE:
             begin
-            {$ifdef newra}
               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_op_reg_ref(list,op,loc.size,tmpreg,loc.reference);
-            {$ifdef newra}
               rg.ungetregisterint(list,tmpreg);
-            {$else}
-              free_scratch_reg(list,tmpreg);
-            {$endif}
             end;
           else
             internalerror(200109061);
@@ -1238,27 +1000,21 @@ unit cgobj;
 
     procedure tcg.a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
         size: tcgsize; src1, src2, dst: tregister);
-{$ifdef newra}
       var
         tmpreg: tregister;
-{$endif newra}
       begin
-        if (dst.number <> src1.number) then
+        if (dst<>src1) then
           begin
             a_load_reg_reg(list,size,size,src2,dst);
             a_op_reg_reg(list,op,size,src1,dst);
           end
         else
           begin
-{$ifdef newra}
             tmpreg := rg.getregisterint(list,size);
             a_load_reg_reg(list,size,size,src2,tmpreg);
             a_op_reg_reg(list,op,size,src1,tmpreg);
             a_load_reg_reg(list,size,size,tmpreg,dst);
             rg.ungetregisterint(list,tmpreg);
-{$else newra}
-            internalerror(200305011);
-{$endif newra}
           end;
       end;
 
@@ -1271,18 +1027,10 @@ unit cgobj;
         tmpreg: tregister;
 
       begin
-      {$ifdef newra}
         tmpreg:=rg.getregisterint(list,size);
-      {$else}
-        tmpreg := get_scratch_reg_int(list,size);
-      {$endif}
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_cmp_const_reg_label(list,size,cmp_op,a,tmpreg,l);
-      {$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
-      {$else}
-        free_scratch_reg(list,tmpreg);
-      {$endif}
       end;
 
     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;
 
       begin
-      {$ifdef newra}
         tmpreg:=rg.getregisterint(list,size);
-      {$else}
-        tmpreg := get_scratch_reg_int(list,size);
-      {$endif}
         a_load_ref_reg(list,size,size,ref,tmpreg);
         a_cmp_reg_reg_label(list,size,cmp_op,tmpreg,reg,l);
-      {$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
-      {$else}
-        free_scratch_reg(list,tmpreg);
-      {$endif}
       end;
 
     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);
           LOC_REFERENCE,LOC_CREFERENCE:
             begin
-{$ifdef newra}
               tmpreg := rg.getregisterint(list,size);
               a_load_ref_reg(list,size,size,loc.reference,tmpreg);
               a_cmp_ref_reg_label(list,size,cmp_op,ref,tmpreg,l);
               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
           else
             internalerror(200109061);
@@ -1426,13 +1146,9 @@ unit cgobj;
         paramanager.freeintparaloc(list,3);
         paramanager.freeintparaloc(list,2);
         paramanager.freeintparaloc(list,1);
-{$ifdef newra}
         rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
         a_call_name(list,'FPC_SHORTSTR_ASSIGN');
-{$ifdef newra}
         rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
       end;
 
 
@@ -1459,13 +1175,9 @@ unit cgobj;
             { these functions get the pointer by value }
             a_param_ref(list,OS_ADDR,ref,paramanager.getintparaloc(list,1));
             paramanager.freeintparaloc(list,1);
-{$ifdef newra}
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             a_call_name(list,incrfunc);
-{$ifdef newra}
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
           end
          else
           begin
@@ -1477,13 +1189,9 @@ unit cgobj;
               a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
             paramanager.freeintparaloc(list,1);
             paramanager.freeintparaloc(list,2);
-{$ifdef newra}
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             a_call_name(list,'FPC_ADDREF');
-{$ifdef newra}
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
          end;
       end;
 
@@ -1521,13 +1229,9 @@ unit cgobj;
             else
               a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
             paramanager.freeintparaloc(list,1);
-{$ifdef newra}
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             a_call_name(list,decrfunc);
-{$ifdef newra}
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             if needrtti then
               paramanager.freeintparaloc(list,2);
           end
@@ -1541,13 +1245,9 @@ unit cgobj;
               a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
             paramanager.freeintparaloc(list,1);
             paramanager.freeintparaloc(list,2);
-{$ifdef newra}
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             a_call_name(list,'FPC_DECREF');
-{$ifdef newra}
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
          end;
       end;
 
@@ -1570,13 +1270,9 @@ unit cgobj;
                 a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
               paramanager.freeintparaloc(list,1);
               paramanager.freeintparaloc(list,2);
-{$ifdef newra}
               rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
               a_call_name(list,'FPC_INITIALIZE');
-{$ifdef newra}
               rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
            end;
       end;
 
@@ -1599,13 +1295,9 @@ unit cgobj;
                 a_paramaddr_ref(list,ref,paramanager.getintparaloc(list,1));
               paramanager.freeintparaloc(list,1);
               paramanager.freeintparaloc(list,2);
-{$ifdef newra}
               rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
               a_call_name(list,'FPC_FINALIZE');
-{$ifdef newra}
               rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
            end;
       end;
 
@@ -1708,21 +1400,13 @@ unit cgobj;
               if lto < 0 then
                 lto := 0;
             end;
-{$ifdef newra}
         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_op_const_reg(list,OP_SUB,OS_INT,aword(lto),hreg);
         objectlibrary.getlabel(neglabel);
         a_cmp_const_reg_label(list,OS_INT,OC_BE,aword(hto-lto),hreg,neglabel);
         { !!! should happen right after the compare (JM) }
-{$ifdef newra}
         rg.ungetregisterint(list,hreg);
-{$else}
-        free_scratch_reg(list,hreg);
-{$endif}
         a_call_name(list,'FPC_RANGEERROR');
         a_label(list,neglabel);
       end;
@@ -1742,18 +1426,10 @@ unit cgobj;
       var
         tmpreg : tregister;
       begin
-      {$ifdef newra}
         tmpreg:=rg.getregisterint(list,size);
-      {$else}
-        tmpreg := get_scratch_reg_int(list,size);
-      {$endif}
         g_flags2reg(list,size,f,tmpreg);
         a_load_reg_ref(list,size,size,tmpreg,ref);
-      {$ifdef newra}
         rg.ungetregisterint(list,tmpreg);
-      {$else}
-        free_scratch_reg(list,tmpreg);
-      {$endif}
       end;
 
 
@@ -1785,26 +1461,18 @@ unit cgobj;
            a_param_reg(list,OS_ADDR,reg,paramanager.getintparaloc(list,1));
            paramanager.freeintparaloc(list,2);
            paramanager.freeintparaloc(list,1);
-{$ifdef newra}
            rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
            a_call_name(list,'FPC_CHECK_OBJECT_EXT');
-{$ifdef newra}
            rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
          end
         else
          if (cs_check_range in aktlocalswitches) then
           begin
             a_param_reg(list,OS_ADDR,reg,paramanager.getintparaloc(list,1));
             paramanager.freeintparaloc(list,1);
-{$ifdef newra}
             rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             a_call_name(list,'FPC_CHECK_OBJECT');
-{$ifdef newra}
             rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
           end;
       end;
 
@@ -1813,91 +1481,6 @@ unit cgobj;
                             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);
       begin
       end;
@@ -1914,49 +1497,37 @@ unit cgobj;
 
 
     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);
-     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);
-
-    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
-        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);
       end;
 
 
     procedure tcg64.a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);
       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);
       end;
 
 
-
 initialization
     ;
 finalization
@@ -1965,13 +1536,28 @@ finalization
 end.
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around
     + 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
     * fixed regvars so they work with newra (at least for ppc)
     * fixed some volatile register bugs

+ 22 - 16
compiler/cutils.pas

@@ -363,12 +363,18 @@ uses
     {
       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;
@@ -495,15 +501,6 @@ uses
       end;
 
 
-   function tostr(i : longint) : string;
-   {
-     return string of value i
-   }
-     begin
-        str(i,result);
-     end;
-
-
    function realtostr(e:extended):string;
      begin
         str(e,result);
@@ -866,7 +863,16 @@ initialization
 end.
 {
   $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
     * slightly optimized the swap*() functions
 

+ 22 - 16
compiler/fpcdefs.inc

@@ -38,60 +38,66 @@
 
 {$ifdef i386}
   {$ifdef delphi}
-  {$define oldset}
+    {$define oldset}
   {$endif}
   {$define x86}
   {$define cpuextended}
-{$else}
-  {$define oldset}
 {$endif i386}
 
 {$ifdef x86_64}
   {$define x86}
   {$define cpu64bit}
   {$define cpuextended}
-  {$define callparatemp}
 {$endif x86_64}
 
 {$ifdef alpha}
   {$define cpu64bit}
   {$undef cpuflags}
-  {$define callparatemp}
+  {$define noopt}
+  {$define oldset}
 {$endif alpha}
 
 {$ifdef sparc}
-  {$define usetempparaloc}
-  { define callparatemp}
+  {$define noopt}
+  {$define oldset}
 {$endif sparc}
 
 {$ifdef powerpc}
-  {$define callparatemp}
+  {$define noopt}
+  {$define oldset}
 {$endif powerpc}
 
 {$ifdef arm}
-  {$define callparatemp}
   {$define cpuneedsdiv32helper}
+  {$define noopt}
+  {$define oldset}
 {$endif arm}
 
-{ FPU Emulator support }
 {$ifdef m68k}
   {$define cpufpemu}
-{$endif m68k}
-
-{ Optimizer is x86 only }
-{$ifndef i386}
   {$define noopt}
-{$endif i386}
+  {$define oldset}
+{$endif m68k}
 
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around
     + 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
     * start of sparc support for newra
 

+ 4 - 3
compiler/globtype.pas

@@ -165,8 +165,6 @@ interface
        tnormalset = set of byte; { 256 elements set }
        pnormalset = ^tnormalset;
 
-
-
        pboolean   = ^boolean;
        pdouble    = ^double;
        pbyte      = ^byte;
@@ -208,7 +206,10 @@ implementation
 end.
 {
   $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
       allocator
     * Some preventive changes to i386 spillinh code

+ 40 - 145
compiler/i386/ag386int.pas

@@ -46,70 +46,16 @@ interface
         procedure WriteExternals;
       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
 {$ifdef delphi}
       sysutils,
 {$endif}
       cutils,globtype,globals,systems,cclasses,
-      verbose,finput,fmodule,script,cpuinfo
+      verbose,finput,fmodule,script,cpuinfo,
+      itx86int
       ;
 
     const
@@ -211,17 +157,11 @@ interface
       begin
         with ref do
          begin
-           if segment.enum>lastreg then
-             internalerror(200301081);
-           if base.enum>lastreg then
-             internalerror(200301081);
-           if index.enum>lastreg then
-             internalerror(200301081);
            first:=true;
            inc(offset,offsetfixup);
            offsetfixup:=0;
-           if segment.enum<>R_NO then
-            AsmWrite(std_reg2str[segment.enum]+':[')
+           if segment<>NR_NO then
+            AsmWrite(masm_regname(segment)+':[')
            else
             AsmWrite('[');
            if assigned(symbol) then
@@ -231,21 +171,21 @@ interface
               AsmWrite(symbol.name);
               first:=false;
             end;
-           if (base.enum<>R_NO) then
+           if (base<>NR_NO) then
             begin
               if not(first) then
                AsmWrite('+')
               else
                first:=false;
-               AsmWrite(std_reg2str[base.enum]);
+               AsmWrite(masm_regname(base));
             end;
-           if (index.enum<>R_NO) then
+           if (index<>NR_NO) then
             begin
               if not(first) then
                AsmWrite('+')
               else
                first:=false;
-              AsmWrite(std_reg2str[index.enum]);
+              AsmWrite(masm_regname(index));
               if scalefactor<>0 then
                AsmWrite('*'+tostr(scalefactor));
             end;
@@ -270,11 +210,7 @@ interface
       begin
         case o.typ of
           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 :
             AsmWrite(tostr(longint(o.val)));
           top_symbol :
@@ -333,11 +269,7 @@ interface
     begin
       case o.typ of
         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 :
           AsmWrite(tostr(longint(o.val)));
         top_symbol :
@@ -481,7 +413,7 @@ interface
            ait_regalloc :
              begin
                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]);
              end;
 
@@ -669,15 +601,21 @@ interface
                          word prefix to get selectors
                          to be pushed in 2 bytes  PM }
                        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');
-                       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 }
                        if (taicpu(hp).ops = 0) and
@@ -866,61 +804,6 @@ ait_stab_function_name : ;
 {$endif EXTDEBUG}
    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
@@ -971,7 +854,19 @@ initialization
 end.
 {
   $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
 
   Revision 1.35  2003/08/09 18:56:54  daniel

+ 37 - 58
compiler/i386/ag386nsm.pas

@@ -52,30 +52,34 @@ interface
       sysutils,
 {$endif}
       cutils,globtype,globals,systems,cclasses,
-      fmodule,finput,verbose,cpuinfo,ag386int
+      fmodule,finput,verbose,cpuinfo,cginfo
       ;
 
     const
       line_length = 64;
 
-    int_nasmreg2str : reg2strtable = ('',
-     'eax','ecx','edx','ebx','esp','ebp','esi','edi',
-     'ax','cx','dx','bx','sp','bp','si','di',
-     'al','cl','dl','bl','ah','ch','bh','dh',
-     'cs','ds','es','ss','fs','gs',
-     'st0','st0','st1','st2','st3','st4','st5','st6','st7',
-     'dr0','dr1','dr2','dr3','dr6','dr7',
-     'cr0','cr2','cr3','cr4',
-     'tr3','tr4','tr5','tr6','tr7',
-     'mm0','mm1','mm2','mm3','mm4','mm5','mm6','mm7',
-     'xmm0','xmm1','xmm2','xmm3','xmm4','xmm5','xmm6','xmm7'
-   );
+      nasm_regname_table : array[tregisterindex] of string[7] = (
+        {r386nasm.inc contains the Nasm name of each register.}
+        {$i r386nasm.inc}
+      );
 
     var
       lastfileinfo : tfileposinfo;
       infile,
       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;
    {
      return s with all leading and ending spaces and tabs removed
@@ -217,48 +221,36 @@ interface
 
     procedure T386NasmAssembler.WriteReference(var ref : treference);
       var
-        first,no_s,no_b,no_i : boolean;
+        first : boolean;
       begin
         with ref do
          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('[');
            first:=true;
            inc(offset,offsetfixup);
            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
             begin
               AsmWrite(symbol.name);
               first:=false;
             end;
-           if not no_b then
+           if (base<>NR_NO) then
             begin
               if not(first) then
                AsmWrite('+')
               else
                first:=false;
-            if base.enum=R_INTREGISTER then
-              asmwrite(intel_regname(base.number))
-            else
-              asmwrite(int_nasmreg2str[base.enum]);
+              AsmWrite(nasm_regname(base))
             end;
-           if not no_i then
+           if (index<>NR_NO) then
              begin
                if not(first) then
                  AsmWrite('+')
                else
                  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
                  AsmWrite('*'+tostr(scalefactor));
              end;
@@ -283,16 +275,7 @@ interface
       begin
         case o.typ of
           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 :
             begin
               if (ops=1) and (opcode<>A_RET) then
@@ -333,12 +316,7 @@ interface
       begin
         case o.typ of
           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 :
             WriteReference(o.ref^);
           top_const :
@@ -387,7 +365,6 @@ interface
       found,
       do_line,
       quoted   : boolean;
-      regstr:string[6];
     begin
       if not assigned(p) then
        exit;
@@ -458,12 +435,8 @@ interface
 
            ait_regalloc :
              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
-                 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]);
              end;
 
@@ -678,9 +651,9 @@ interface
                  begin
                    taicpu(hp).ops:=2;
                    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].reg.enum:=R_ST;
+                   taicpu(hp).oper[1].reg:=NR_ST;
                  end;
                if taicpu(hp).opcode=A_FWAIT then
                 AsmWriteln(#9#9'DB'#9'09bh')
@@ -693,7 +666,7 @@ interface
                      ((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
+                      (is_segment_reg(taicpu(hp).oper[0].reg)) then
                     AsmWriteln(#9#9'DB'#9'066h');
                   AsmWrite(#9#9+std_op2str[taicpu(hp).opcode]+cond2str[taicpu(hp).condition]);
                   if taicpu(hp).ops<>0 then
@@ -929,7 +902,13 @@ initialization
 end.
 {
   $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
       allocator
     * Some preventive changes to i386 spillinh code

+ 11 - 5
compiler/i386/cgcpu.pas

@@ -115,8 +115,8 @@ unit cgcpu;
         case op of
           OP_NEG :
             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_NEG,S_L,regdst.reglo));
               list.concat(taicpu.op_const_reg(A_SBB,S_L,aword(-1),regdst.reghi));
@@ -124,8 +124,8 @@ unit cgcpu;
             end;
           OP_NOT :
             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.reglo));
               exit;
@@ -193,7 +193,13 @@ begin
 end.
 {
   $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
 
   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}
 
-      {# 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
 *****************************************************************************}
 
       firstsaveintreg = RS_EAX;
       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];
 
-{$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;
 
       maxaddrregs = 1;
-      addrregs    = [R_ESI];
       usableregsaddr = [RS_ESI];
       c_countusableregsaddr = 1;
 
       maxvarregs = 4;
-      varregs : array[1..maxvarregs] of tnewregister =
+      varregs : array[1..maxvarregs] of tsuperregister =
          (RS_EBX,RS_EDX,RS_ECX,RS_EAX);
 
       maxfpuvarregs = 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
@@ -116,20 +86,11 @@
           (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
 *****************************************************************************}
@@ -151,7 +112,6 @@
       NR_STACK_POINTER_REG = NR_ESP;
       RS_STACK_POINTER_REG = RS_ESP;
       {# Frame pointer register }
-      frame_pointer_reg = R_EBP;
       RS_FRAME_POINTER_REG = RS_EBP;
       NR_FRAME_POINTER_REG = NR_EBP;
       {# 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 }
       { 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 }
       PARENT_FRAMEPOINTER_OFFSET = 8;
@@ -198,7 +158,7 @@
          This value can be deduced from the CALLED_USED_REGISTERS array in the
          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
          stdcall and cdecl. The alignment value should be the one defined
          by GCC or the target ABI.
@@ -210,13 +170,25 @@
 
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around
     + 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
     * framepointer fixes for sparc
     * 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;
       begin
          getintparaloc.loc:=LOC_REFERENCE;
-         getintparaloc.reference.index.enum:=R_EBP;
+         getintparaloc.reference.index:=NR_EBP;
          getintparaloc.reference.offset:=4*nr;
       end;
 
@@ -148,10 +148,7 @@ unit cpupara;
             if assigned(current_procinfo) then
               paraloc.reference.index:=current_procinfo.framepointer
             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;
             hp.paraloc[side]:=paraloc;
 {$warning callerparaloc shall not be the same as calleeparaloc}
@@ -165,7 +162,7 @@ unit cpupara;
         if p.rettype.def.deftype=floatdef then
           begin
             paraloc.loc:=LOC_FPUREGISTER;
-            paraloc.register.enum:=FPU_RESULT_REG;
+            paraloc.register:=NR_FPU_RESULT_REG;
           end
         else
          { Return in register? }
@@ -175,16 +172,13 @@ unit cpupara;
 {$ifndef cpu64bit}
             if paraloc.size in [OS_64,OS_S64] then
              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
             else
 {$endif cpu64bit}
              begin
-               paraloc.register.enum:=R_INTREGISTER;
-               paraloc.register.number:=NR_FUNCTION_RETURN_REG;
+               paraloc.register:=NR_FUNCTION_RETURN_REG;
              end;
           end
         else
@@ -204,8 +198,7 @@ unit cpupara;
            internalerror(200305251);
          getselflocation.loc:=LOC_REFERENCE;
          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;
       end;
 
@@ -214,7 +207,16 @@ begin
 end.
 {
   $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
 
   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;
       begin
-        if framepointer.number=NR_EBP then
+        if framepointer=NR_EBP then
           begin
             { Make sure the register allocator won't allocate registers
               into ebp }
@@ -69,7 +69,13 @@ begin
 end.
 {
   $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
     * 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);
 
     procedure ti386addnode.pass_left_and_right(var pushedfpu:boolean);
-      var
-        pushedregs : tmaybesave;
       begin
         { calculate the operator which is more difficult }
         firstcomplex(self);
@@ -83,17 +81,11 @@ interface
         secondpass(left);
 
         { are too few registers free? }
-      {$ifndef newra}
-        maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-      {$endif newra}
         if location.loc=LOC_FPUREGISTER then
           pushedfpu:=maybe_pushfpu(exprasmlist,right.registersfpu,left.location)
         else
           pushedfpu:=false;
         secondpass(right);
-      {$ifndef newra}
-        maybe_restore(exprasmlist,left.location,pushedregs);
-      {$endif}
       end;
 
 
@@ -230,13 +222,7 @@ interface
             begin
               if extra_not then
                 emit_reg(A_NOT,opsize,left.location.register);
-            {$ifdef newra}
               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);
               emit_reg_reg(op,opsize,left.location.register,r);
               emit_reg_reg(A_MOV,opsize,r,left.location.register);
@@ -280,13 +266,7 @@ interface
                  begin
                    if extra_not then
                      begin
-                     {$ifdef newra}
                         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);
                         emit_reg(A_NOT,S_L,r);
                         emit_reg_reg(A_AND,S_L,r,left.location.register);
@@ -350,14 +330,6 @@ interface
 
     procedure ti386addnode.second_addstring;
 
-      var
-      {$ifdef newra}
-        r          : Tregister;
-        i          : Tsuperregister;
-      {$else}
-        pushed     : Tpushedsavedint;
-      {$endif}
-        regstopush : Tsupregset;
       begin
         { string operations are not commutative }
         if nf_swaped in flags then
@@ -368,28 +340,17 @@ interface
                 case nodetype of
                    ltn,lten,gtn,gten,equaln,unequaln :
                      begin
-                     {$ifndef newra}
-                       rg.saveusedintregisters(exprasmlist,pushed,VOLATILE_INTREGISTERS);
-                     {$endif newra}
                        secondpass(left);
                        location_release(exprasmlist,left.location);
                        cg.a_paramaddr_ref(exprasmlist,left.location.reference,paramanager.getintparaloc(exprasmlist,2));
                        secondpass(right);
                        location_release(exprasmlist,right.location);
                        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');
                        paramanager.freeintparaloc(exprasmlist,2);
                        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,right.location);
                      end;
@@ -413,7 +374,6 @@ interface
         cmpop,
         isjump  : boolean;
         otl,ofl : tasmlabel;
-        pushedregs : tmaybesave;
       begin
         { calculate the operator which is more difficult }
         firstcomplex(self);
@@ -452,9 +412,6 @@ interface
                falselabel:=ofl;
              end;
 
-          {$ifndef newra}
-            maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-          {$endif}
             isjump:=(right.location.loc=LOC_JUMP);
             if isjump then
               begin
@@ -464,9 +421,6 @@ interface
                  objectlibrary.getlabel(falselabel);
               end;
             secondpass(right);
-          {$ifndef newra}
-            maybe_restore(exprasmlist,left.location,pushedregs);
-          {$endif newra}
             if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
              location_force_reg(exprasmlist,right.location,opsize_2_cgsize[opsize],false);
             if isjump then
@@ -553,7 +507,7 @@ interface
         resflags   : tresflags;
         pushedfpu,
         cmpop      : boolean;
-        r,r2:Tregister;
+        r : Tregister;
       begin
         pass_left_and_right(pushedfpu);
 
@@ -579,14 +533,13 @@ interface
 
         if (right.location.loc<>LOC_FPUREGISTER) then
          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
               pushedfpu then
              location_freetemp(exprasmlist,left.location);
            if (left.location.loc<>LOC_FPUREGISTER) then
             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
                  pushedfpu then
                 location_freetemp(exprasmlist,left.location);
@@ -603,8 +556,7 @@ interface
         { the nominator in st0 }
         else if (left.location.loc<>LOC_FPUREGISTER) then
          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
               pushedfpu then
              location_freetemp(exprasmlist,left.location);
@@ -635,9 +587,7 @@ interface
         { the Intel assemblers want operands }
         if op<>A_FCOMPP then
           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);
           end
         else
@@ -649,36 +599,10 @@ interface
         { on comparison load flags }
         if cmpop then
          begin
-         {$ifdef newra}
            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_none(A_SAHF,S_NO);
-         {$ifdef newra}
            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
             begin
               case nodetype of
@@ -707,7 +631,7 @@ interface
         else
          begin
            location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-           location.register.enum:=R_ST;
+           location.register:=NR_ST;
          end;
       end;
 
@@ -962,22 +886,10 @@ interface
               { we can reuse a CREGISTER for comparison }
               if not((left.location.loc=LOC_CREGISTER) and cmpop) then
                begin
-               {$ifdef newra}
                  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);
                  hregister2:=rg.getregisterint(exprasmlist,OS_INT);
-               {$ifdef newra}
                  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);
                  left.location.registerlow:=hregister;
                  left.location.registerhigh:=hregister2;
@@ -1022,13 +934,7 @@ interface
            { right.location<>LOC_REGISTER }
            if (nodetype=subn) and (nf_swaped in flags) then
             begin
-{$ifdef newra}
               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);
               emit_reg_reg(op1,opsize,left.location.registerlow,r);
               emit_reg_reg(A_MOV,opsize,r,left.location.registerlow);
@@ -1251,29 +1157,26 @@ interface
          begin
            if (nodetype=subn) and (nf_swaped in flags) then
             begin
-              r.enum:=R_MM7;
               if right.location.loc=LOC_CMMXREGISTER then
                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
               else
                begin
                  if not(left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
                   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);
                end;
             end
            else
             begin
               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
                begin
                  if not(right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
@@ -1313,10 +1216,9 @@ interface
                                 MUL
 *****************************************************************************}
 
-{$ifdef newra}
     procedure ti386addnode.second_mul;
 
-    var r,r_eax:Tregister;
+    var r:Tregister;
 
     begin
       {The location.register will be filled in later (JM)}
@@ -1328,10 +1230,8 @@ interface
       location_release(exprasmlist,left.location);
       {Allocate EAX.}
       rg.getexplicitregisterint(exprasmlist,NR_EAX);
-      r_eax.enum:=R_INTREGISTER;
-      r_eax.number:=NR_EAX;
       {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);
       {The mul instruction frees register r.}
       rg.ungetregisterint(exprasmlist,r);
@@ -1339,103 +1239,16 @@ interface
       rg.getexplicitregisterint(exprasmlist,NR_EDX);
       emit_reg(A_MUL,S_L,r);
       {Free EDX}
-      r.enum:=R_INTREGISTER;
-      r.number:=NR_EDX;
-      rg.ungetregisterint(exprasmlist,r);
+      rg.ungetregisterint(exprasmlist,NR_EDX);
       {Free EAX}
-      rg.ungetregisterint(exprasmlist,r_eax);
+      rg.ungetregisterint(exprasmlist,NR_EAX);
       {Allocate a new register and store the result in EAX in it.}
       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,right.location);
     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
@@ -1633,7 +1446,17 @@ begin
 end.
 {
   $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
       possible to reduce the slowdown of spills.
 

+ 12 - 33
compiler/i386/n386cal.pas

@@ -67,12 +67,9 @@ implementation
 
 
     procedure ti386callnode.extra_interrupt_code;
-      var
-        r : Tregister;
       begin
         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;
 
 
@@ -84,7 +81,6 @@ implementation
          push_size : longint;
 {$endif OPTALIGN}
          i : integer;
-         rsp : tregister;
       begin
         pop_size:=0;
         { This parasize aligned on 4 ? }
@@ -97,9 +93,7 @@ implementation
         if pop_size>0 then
          begin
            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}
            if (cs_debuginfo in aktmoduleswitches) and
               (exprasmList.first=exprasmList.last) then
@@ -142,52 +136,31 @@ implementation
         { better than an add on all processors }
         if pop_size=4 then
           begin
-          {$ifdef newra}
             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));
-          {$ifdef newra}
             rg.ungetregisterint(exprasmlist,hreg);
-          {$else}
-            cg.free_scratch_reg(exprasmlist,hreg);
-          {$endif newra}
           end
         { the pentium has two pipes and pop reg is pairable }
         { but the registers must be different!        }
         else
           if (pop_size=8) and
              not(cs_littlesize in aktglobalswitches) and
-             (aktoptprocessor=ClassP5)
-             {$ifndef newra} and (rg.countunusedregsint>0){$endif} then
+             (aktoptprocessor=ClassP5) then
             begin
-            {$ifdef newra}
                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));
-            {$ifdef newra}
                rg.ungetregisterint(exprasmlist,hreg);
-            {$else}
-               cg.free_scratch_reg(exprasmlist,hreg);
-            {$endif}
                hreg:=rg.getregisterint(exprasmlist,OS_INT);
                exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));
                rg.ungetregisterint(exprasmlist,hreg);
             end
         else
           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}
         if pop_esp then
-          emit_reg(A_POP,S_L,rsp);
+          emit_reg(A_POP,S_L,NR_ESP);
 {$endif OPTALIGN}
       end;
 
@@ -197,7 +170,13 @@ begin
 end.
 {
   $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
     * accumulator removed, splitted in function_return_reg (called) and
       function_result_reg (caller)

+ 25 - 42
compiler/i386/n386cnv.pas

@@ -87,11 +87,10 @@ implementation
          hregister : tregister;
          l1,l2 : tasmlabel;
          freereg : boolean;
-         r:Tregister;
 
       begin
          location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-         hregister.enum:=R_NO;
+         hregister:=NR_NO;
          freereg:=false;
 
          { for u32bit a solution is to push $0 and to load a comp }
@@ -113,11 +112,7 @@ implementation
                    hregister:=left.location.register;
                  else
                    begin
-                    {$ifdef newra}
                      hregister:=rg.getregisterint(exprasmlist,OS_32);
-                    {$else}
-                     hregister:=cg.get_scratch_reg_int(exprasmlist,OS_32);
-                    {$endif}
                      freereg:=true;
                      cg.a_load_reg_reg(exprasmlist,left.location.size,OS_32,left.location.register,hregister);
                    end;
@@ -126,11 +121,7 @@ implementation
            LOC_REFERENCE,
            LOC_CREFERENCE :
              begin
-              {$ifdef newra}
                hregister:=rg.getregisterint(exprasmlist,OS_INT);
-              {$else}
-               hregister:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
-              {$endif newra}
                freereg:=true;
                if left.location.size in [OS_64,OS_S64] then
                 begin
@@ -151,27 +142,20 @@ implementation
 
          { for 64 bit integers, the high dword is already pushed }
          exprasmlist.concat(taicpu.op_reg(A_PUSH,S_L,hregister));
-        {$ifdef newra}
          if freereg then
            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
            u32bit:
              begin
                 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;
            scurrency,
            s64bit:
              begin
                 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;
            u64bit:
              begin
@@ -179,22 +163,14 @@ implementation
                 { we load bits 0..62 and then check bit 63:  }
                 { if it is 1 then we add $80000000 000000000 }
                 { as double                                  }
-                r.enum:=R_INTREGISTER;
-                r.number:=NR_EDI;
                 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);
-                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);
                 objectlibrary.getdatalabel(l1);
                 objectlibrary.getlabel(l2);
@@ -206,20 +182,18 @@ implementation
                 reference_reset_symbol(href,l1,0);
                 emit_ref(A_FADD,S_FL,href);
                 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
            else
              begin
                 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;
          inc(trgcpu(rg).fpuvaroffset);
-         location.register.enum:=R_ST;
+         location.register:=NR_ST;
       end;
 
 
@@ -358,7 +332,16 @@ begin
 end.
 {
   $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
     * makeregsize only accepts newregister
     * i386 uses generic tcgnotnode,tcgunaryminus

+ 9 - 3
compiler/i386/n386con.pas

@@ -65,14 +65,14 @@ implementation
            begin
               emit_none(A_FLD1,S_NO);
               location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-              location.register.enum:=R_ST;
+              location.register:=NR_ST;
               inc(trgcpu(rg).fpuvaroffset);
            end
          else if (value_real=0.0) then
            begin
               emit_none(A_FLDZ,S_NO);
               location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-              location.register.enum:=R_ST;
+              location.register:=NR_ST;
               inc(trgcpu(rg).fpuvaroffset);
            end
          else
@@ -85,7 +85,13 @@ begin
 end.
 {
   $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
     * checks if there are differences between the expectloc and
       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));
          emit_none(A_FLDPI,S_NO);
          inc(trgcpu(rg).fpuvaroffset);
-         location.register.enum:=FPU_RESULT_REG;
-
+         location.register:=NR_FPU_RESULT_REG;
        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;
+
 
      procedure ti386inlinenode.second_arctan_real;
        begin
@@ -207,14 +207,12 @@ implementation
          emit_none(A_FABS,S_NO);
        end;
 
-     procedure ti386inlinenode.second_sqr_real;
 
-     var r:Tregister;
+     procedure ti386inlinenode.second_sqr_real;
 
        begin
          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;
 
      procedure ti386inlinenode.second_sqrt_real;
@@ -249,11 +247,9 @@ implementation
 
       procedure ti386inlinenode.second_IncludeExclude;
         var
-         scratch_reg : boolean;
          hregister : tregister;
          asmop : tasmop;
          L : cardinal;
-         pushedregs : TMaybesave;
          cgop : topcg;
         begin
           secondpass(tcallparanode(left).left);
@@ -287,14 +283,7 @@ implementation
           else
             begin
               { 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);
-            {$ifndef newra}
-              maybe_restore(exprasmlist,tcallparanode(left).left.location,pushedregs);
-            {$endif}
               { determine asm operator }
               if inlinenumber=in_include_x_y then
                  asmop:=A_BTS
@@ -311,33 +300,20 @@ implementation
                 { need a cmp and jmp, but this should be done by the         }
                 { type cast code which does range checking if necessary (FK) }
                 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
               else
                 begin
-                  scratch_reg := TRUE;
-                {$ifdef newra}
                   hregister:=rg.getregisterint(exprasmlist,OS_INT);
-                {$else}
-                  hregister:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
-                {$endif newra}
                 end;
               cg.a_load_loc_reg(exprasmlist,OS_INT,tcallparanode(tcallparanode(left).right).left.location,hregister);
               if (tcallparanode(left).left.location.loc=LOC_REFERENCE) then
                 emit_reg_ref(asmop,S_L,hregister,tcallparanode(left).left.location.reference)
               else
                 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);
-            {$else}
-              if scratch_reg then
-                cg.free_scratch_reg(exprasmlist,hregister);
-            {$endif newra}
             end;
         end;
 
@@ -347,7 +323,16 @@ begin
 end.
 {
   $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
     * sparc calling convention updates
 

+ 69 - 584
compiler/i386/n386mat.pas

@@ -71,14 +71,12 @@ implementation
                              TI386MODDIVNODE
 *****************************************************************************}
 
-{$ifdef newra}
     procedure ti386moddivnode.pass_2;
 
-    var  r,r2,hreg1,hreg2:Tregister;
+    var  hreg1,hreg2:Tregister;
          power:longint;
          hl:Tasmlabel;
          op:Tasmop;
-         pushedregs:Tmaybesave;
 
     begin
       secondpass(left);
@@ -146,15 +144,11 @@ implementation
           {Bring denominator to a register.}
           rg.ungetregisterint(exprasmlist,hreg1);
           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);
           {Sign extension depends on the left type.}
           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
             emit_none(A_CDQ,S_NO);
 
@@ -180,239 +174,20 @@ implementation
           {Copy the result into a new register. Release EAX & EDX.}
           if nodetype=divn then
             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);
-              emit_reg_reg(A_MOV,S_L,r,location.register);
+              emit_reg_reg(A_MOV,S_L,NR_EAX,location.register);
             end
           else
             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);
-              emit_reg_reg(A_MOV,S_L,r2,location.register);
+              emit_reg_reg(A_MOV,S_L,NR_EDX,location.register);
             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;
     end;
 
-{$ifdef newra}
     procedure ti386shlshrnode.pass_2;
 
     var hregister2,hregisterhigh,hregisterlow:Tregister;
-        r,r2:Tregister;
         op:Tasmop;
         l1,l2,l3:Tasmlabel;
-        pushedregs:Tmaybesave;
 
     begin
       secondpass(left);
@@ -508,10 +280,6 @@ implementation
               { 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;
 
               { the damned shift instructions work only til a count of 32 }
               { so we've to do some tricks here                           }
@@ -529,23 +297,23 @@ implementation
               emit_const_reg(A_SUB,S_L,32,hregister2);
               if nodetype=shln then
                 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_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);
+                  emit_reg_reg_reg(A_SHLD,S_L,NR_CL,hregisterlow,hregisterhigh);
+                  emit_reg_reg(A_SHL,S_L,NR_CL,hregisterlow);
                 end
               else
                 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_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);
+                  emit_reg_reg_reg(A_SHRD,S_L,NR_CL,hregisterhigh,hregisterlow);
+                  emit_reg_reg(A_SHR,S_L,NR_CL,hregisterhigh);
                 end;
               cg.a_label(exprasmlist,l3);
 
@@ -560,9 +328,6 @@ implementation
           location_copy(location,left.location);
           location_force_reg(exprasmlist,location,OS_INT,false);
 
-          r2.enum:=R_INTREGISTER;
-          r2.number:=NR_CL;
-
           { shifting by a constant directly coded: }
           if (right.nodetype=ordconstn) then
             { 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);
 
               { 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);
             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}
     procedure ti386unaryminusnode.second_mmx;
       var
-        r : Tregister;
         op : tasmop;
       begin
         secondpass(left);
@@ -909,23 +394,20 @@ implementation
           LOC_MMXREGISTER:
             begin
                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;
           LOC_CMMXREGISTER:
             begin
                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);
             end;
           LOC_REFERENCE,
           LOC_CREFERENCE:
             begin
                reference_release(exprasmlist,left.location.reference);
-               r.enum:=R_MM7;
                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);
             end;
           else
@@ -951,16 +433,13 @@ implementation
              mmxs32bit,mmxu32bit:
                op:=A_PSUBD;
           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;
 {$endif SUPPORT_MMX}
 
 
     procedure ti386unaryminusnode.second_float;
-      var
-        r : tregister;
       begin
         secondpass(left);
         location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
@@ -969,7 +448,7 @@ implementation
           LOC_CREFERENCE:
             begin
               reference_release(exprasmlist,left.location.reference);
-              location.register.enum:=R_ST;
+              location.register:=NR_ST;
               cg.a_loadfpu_ref_reg(exprasmlist,
                  def_cgsize(left.resulttype.def),
                  left.location.reference,location.register);
@@ -979,9 +458,8 @@ implementation
           LOC_CFPUREGISTER:
             begin
                { "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);
             end;
         end;
@@ -1046,44 +524,41 @@ implementation
 
 {$ifdef SUPPORT_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;
+      { 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}
 
 begin
@@ -1094,7 +569,17 @@ begin
 end.
 {
   $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
     * sparc calling convention updates
 

+ 16 - 19
compiler/i386/n386mem.pas

@@ -27,7 +27,7 @@ unit n386mem;
 interface
 
     uses
-      cpuinfo,cpubase,
+      cginfo,cpuinfo,cpubase,
       node,nmem,ncgmem;
 
     type
@@ -54,7 +54,6 @@ implementation
       cutils,verbose,
       symdef,paramgr,
       aasmtai,
-      cginfo,
       nld,ncon,nadd,
       cgobj,tgobj,rgobj;
 
@@ -67,7 +66,7 @@ implementation
       begin
         inherited pass_2;
         { 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;
       end;
 
@@ -80,10 +79,7 @@ implementation
       begin
          inherited pass_2;
          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;
 
 
@@ -95,16 +91,12 @@ implementation
        var
          l2 : integer;
        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 }
-         if location.reference.index.number=NR_NO then
+         if location.reference.index=NR_NO then
           begin
             { no preparations needed }
           end
-         else if location.reference.base.number=NR_NO then
+         else if location.reference.base=NR_NO then
           begin
             case location.reference.scalefactor of
              2 : cg.a_op_const_reg(exprasmlist,OP_SHL,OS_ADDR,1,location.reference.index);
@@ -138,12 +130,8 @@ implementation
     procedure ti386vecnode.pass_2;
       begin
         inherited pass_2;
-
         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;
 
 
@@ -154,7 +142,16 @@ begin
 end.
 {
   $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
     * op_const_reg size parameter added
     * sparc updates

+ 20 - 33
compiler/i386/n386obj.pas

@@ -36,7 +36,7 @@ uses
   symconst,symtype,symdef,symsym,
   fmodule,
   nobj,
-  cpubase,
+  cpubase,cginfo,
   cga,tgobj,rgobj,cgobj;
 
    type
@@ -110,51 +110,38 @@ procedure ti386classheader.cgintfwrapper(asmlist: TAAsmoutput; procdef: tprocdef
   procedure getselftoeax(offs: longint);
   var
     href : treference;
-    r:Tregister;
   begin
     { 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;
 
   procedure loadvmttoeax;
   var
     href : treference;
-    r:Tregister;
   begin
     checkvirtual;
     { 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;
 
   procedure op_oneaxmethodaddr(op: TAsmOp);
   var
     href : treference;
-    r:Tregister;
   begin
     { 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);
   end;
 
   procedure loadmethodoffstoeax;
   var
     href : treference;
-    r:Tregister;
   begin
     { 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;
 
 var
@@ -162,7 +149,6 @@ var
   lab : tasmsymbol;
   make_global : boolean;
   href : treference;
-  r:Tregister;
 begin
   if procdef.proctypeoption<>potype_none then
     Internalerror(200006137);
@@ -207,21 +193,16 @@ begin
   { case 3 }
   else if [po_virtualmethod,po_saveregisters]*procdef.procoptions=[po_virtualmethod,po_saveregisters] then
     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);
       loadvmttoeax;
       loadmethodoffstoeax;
       { 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 }
-      emit_reg(A_POP,S_L,r);
+      emit_reg(A_POP,S_L,NR_EAX);
       { ret  ; jump to the address }
       emit_none(A_RET,S_L);
     end
@@ -247,7 +228,13 @@ initialization
 end.
 {
   $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
     * makeregsize only accepts newregister
     * i386 uses generic tcgnotnode,tcgunaryminus

+ 18 - 53
compiler/i386/n386set.pas

@@ -100,7 +100,6 @@ implementation
          setparts   : array[1..8] of Tsetpart;
          i,numparts : byte;
          adjustment : longint;
-         pushedregs : tmaybesave;
          l,l2       : tasmlabel;
          r          : Tregister;
 {$ifdef CORRECT_SET_IN_FPC}
@@ -108,8 +107,6 @@ implementation
 {$endif CORRECT_SET_IN_FPC}
 
          function analizeset(Aset:pconstset;is_small:boolean):boolean;
-           type
-             byteset=set of byte;
            var
              compares,maxcompares:word;
              i:byte;
@@ -194,13 +191,7 @@ implementation
          { Only process the right if we are not generating jumps }
          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 newra}
           end;
          if codegenerror then
           exit;
@@ -221,10 +212,10 @@ implementation
              begin
                { for ranges we always need a 32bit register, because then we }
                { use the register as base in a reference (JM)                }
-               pleftreg.enum:=R_INTREGISTER;
                if ranges then
                  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);
                    if opsize <> S_L then
                      emit_const_reg(A_AND,S_L,255,pleftreg);
@@ -234,18 +225,15 @@ implementation
                  { otherwise simply use the lower 8 bits (no "and" }
                  { necessary this way) (JM)                        }
                  begin
-                   pleftreg.number:=(left.location.register.number and not $ff) or R_SUBL;
+                   pleftreg:=left.location.register;
+                   setsubreg(pleftreg,R_SUBL);
                    opsize := S_B;
                  end;
              end
             else
              begin
                { load the value in a register }
-             {$ifdef newra}
                pleftreg:=rg.getregisterint(exprasmlist,OS_INT);
-             {$else}
-               pleftreg := rg.getexplicitregisterint(exprasmlist,NR_EDI);
-             {$endif}
                opsize := S_L;
                emit_ref_reg(A_MOVZX,S_BL,left.location.reference,pleftreg);
                location_release(exprasmlist,left.location);
@@ -267,7 +255,7 @@ implementation
             { "x in [y..z]" expression                               }
             adjustment := 0;
 
-            r.enum:=R_NO;
+            r:=NR_NO;
             for i:=1 to numparts do
              if setparts[i].range then
               { 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 }
                       { to edi (not done before because now we can do the  }
                       { 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
                           rg.ungetregister(exprasmlist,pleftreg);
-                        {$ifdef newra}
                           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);
                           emit_ref_reg(A_LEA,S_L,href,r);
                           { only now change pleftreg since previous value is }
@@ -352,24 +333,9 @@ implementation
              right.location.reference.symbol:=nil;
              { Now place the end label }
              cg.a_label(exprasmlist,l);
-          {$ifdef newra}
              rg.ungetregisterint(exprasmlist,pleftreg);
-             if r.enum=R_INTREGISTER then
+             if r<>NR_NO then
               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
          else
           begin
@@ -414,11 +380,8 @@ implementation
                       { the set element isn't never samller than a byte  }
                       { and because it's a small set we need only 5 bits }
                       { 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);
                     end;
                   end;
@@ -532,15 +495,11 @@ implementation
                 begin
                   if (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
                     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
                   else
-                  {$ifdef newra}
                     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);
                   location_freetemp(exprasmlist,left.location);
                   location_release(exprasmlist,left.location);
@@ -730,7 +689,13 @@ begin
 end.
 {
   $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
       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;
   actcondition   : tasmcond;
   iasmops        : tdictionary;
-  iasmregs       : ^reg2strtable;
 
 
 Procedure SetupTables;
 { creates uppercased symbol tables for speed access }
 var
   i : tasmop;
-  j : Toldregister;
   str2opentry: tstr2opentry;
 Begin
   { opcodes }
@@ -120,10 +118,6 @@ Begin
       str2opentry.op:=i;
       iasmops.insert(str2opentry);
     end;
-  { registers }
-  new(iasmregs);
-  for j:=firstreg to lastreg do
-   iasmregs^[j] := upper(gas_reg2str[j]);
 end;
 
 
@@ -236,25 +230,10 @@ end;
 
 
 function is_register(const s:string):boolean;
-
-var i:Toldregister;
-
 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
       is_register:=true;
       actasmtoken:=AS_REGISTER;
@@ -1180,8 +1159,7 @@ Begin
       Begin
         { Check if there is already a base (mostly ebp,esp) than this is
           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);
         opr.ref.base:=actasmregister;
         Consume(AS_REGISTER);
@@ -2131,13 +2109,20 @@ initialization
 finalization
   if assigned(iasmops) then
     iasmops.Free;
-  if assigned(iasmregs) then
-    dispose(iasmregs);
 
 end.
 {
   $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
     * accumulator removed, splitted in function_return_reg (called) and
       function_result_reg (caller)

+ 22 - 37
compiler/i386/ra386int.pas

@@ -50,7 +50,7 @@ Implementation
        rgobj,
        { register allocator }
        scanner,
-       rautils,rax86,ag386int,
+       rautils,rax86,itx86int,
        { codegen }
        cginfo,cgbase,cgobj
        ;
@@ -117,14 +117,12 @@ var
   actopsize      : topsize;
   actcondition   : tasmcond;
   iasmops        : tdictionary;
-  iasmregs       : ^reg2strtable;
 
 
 Procedure SetupTables;
 { creates uppercased symbol tables for speed access }
 var
   i : tasmop;
-  j : Toldregister;
   str2opentry: tstr2opentry;
 Begin
   { opcodes }
@@ -136,10 +134,6 @@ Begin
       str2opentry.op:=i;
       iasmops.insert(str2opentry);
     end;
-  { registers }
-  new(iasmregs);
-  for j:=firstreg to lastreg do
-   iasmregs^[j] := upper(std_reg2str[j]);
 end;
 
 
@@ -223,26 +217,12 @@ Begin
   is_asmdirective:=false;
 end;
 
-function is_register(const s:string):boolean;
-
-var i:Toldregister;
 
+function is_register(const s:string):boolean;
 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
       is_register:=true;
       actasmtoken:=AS_REGISTER;
@@ -1082,8 +1062,7 @@ Begin
              if negative then
                Message(asmr_e_only_add_relocatable_symbol);
              oldbase:=opr.ref.base;
-             opr.ref.base.enum:=R_INTREGISTER;
-             opr.ref.base.number:=NR_NO;
+             opr.ref.base:=NR_NO;
              tempstr:=actasmpattern;
              Consume(AS_ID);
              { typecasting? }
@@ -1109,10 +1088,9 @@ Begin
               end;
              if GotOffset then
               begin
-                if hasvar and (opr.ref.base.number=current_procinfo.framepointer.number) then
+                if hasvar and (opr.ref.base=current_procinfo.framepointer) then
                  begin
-                   opr.ref.base.enum:=R_INTREGISTER;
-                   opr.ref.base.number:=NR_NO;
+                   opr.ref.base:=NR_NO;
                    hasvar:=hadvar;
                  end
                 else
@@ -1123,10 +1101,10 @@ Begin
                  end;
               end;
              { is the base register loaded by the var ? }
-             if (opr.ref.base.number<>NR_NO) then
+             if (opr.ref.base<>NR_NO) then
               begin
                 { 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)
                 else
                  opr.ref.index:=oldbase;
@@ -1214,9 +1192,9 @@ Begin
              3. base register is already used }
           if (GotStar) or
              (actasmtoken=AS_STAR) or
-             (opr.ref.base.number<>NR_NO) then
+             (opr.ref.base<>NR_NO) then
            begin
-             if (opr.ref.index.number<>NR_NO) then
+             if (opr.ref.index<>NR_NO) then
               Message(asmr_e_multiple_index);
              opr.ref.index:=hreg;
              if scale<>0 then
@@ -1941,13 +1919,20 @@ initialization
 finalization
   if assigned(iasmops) then
     iasmops.Free;
-  if assigned(iasmregs) then
-    dispose(iasmregs);
 
 end.
 {
   $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
 
   Revision 1.48  2003/05/30 23:57:08  peter

+ 41 - 291
compiler/i386/rgcpu.pas

@@ -39,14 +39,7 @@ unit rgcpu;
           fpuvaroffset : byte;
 
           { 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;
           procedure ungetregisterfpu(list: taasmoutput; r : tregister;size:TCGSize); override;
@@ -59,37 +52,19 @@ unit rgcpu;
           function makeregsize(reg: tregister; size: tcgsize): tregister; override;
 
           { pushes and restores registers }
-{$ifndef newra}
-          procedure pushusedintregisters(list:Taasmoutput;
-                                         var pushed:Tpushedsavedint;
-                                         const s:Tsupregset);
-{$endif}
 {$ifdef SUPPORT_MMX}
           procedure pushusedotherregisters(list:Taasmoutput;
                                            var pushed:Tpushedsavedother;
-                                           const s:Tregisterset);
+                                           const s:Totherregisterset);
 {$endif SUPPORT_MMX}
-{$ifndef newra}
-          procedure popusedintregisters(list:Taasmoutput;
-                                        const pushed:Tpushedsavedint);
-{$endif}
 {$ifdef SUPPORT_MMX}
           procedure popusedotherregisters(list:Taasmoutput;
                                           const pushed:Tpushedsavedother);
 {$endif SUPPORT_MMX}
 
-{$ifndef newra}
-          procedure saveusedintregisters(list:Taasmoutput;
-                                         var saved:Tpushedsavedint;
-                                         const s:Tsupregset);override;
-{$endif}
           procedure saveusedotherregisters(list:Taasmoutput;
                                            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;
                                               const saved:Tpushedsavedother);override;
 
@@ -112,160 +87,19 @@ unit rgcpu;
 {                               trgcpu                                   }
 {************************************************************************}
 
-{$ifdef newra}
-    procedure Trgcpu.add_constraints(reg:Tnewregister);
-
+    procedure Trgcpu.add_constraints(reg:Tregister);
+    var
+      supreg : tsuperregister;
     begin
-      if reg and $ff in [R_SUBL,R_SUBH] then
+      if getsubreg(reg) in [R_SUBL,R_SUBH] then
         begin
+          supreg:=getsupreg(reg);
           {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;
-{$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;
@@ -273,7 +107,7 @@ unit rgcpu;
       begin
         { note: don't return R_ST0, see comments above implementation of }
         { a_loadfpu_* methods in cgcpu (JM)                              }
-        result.enum := R_ST;
+        result:=NR_ST;
       end;
 
 
@@ -285,52 +119,17 @@ unit rgcpu;
       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}
     procedure trgcpu.pushusedotherregisters(list:Taasmoutput;
                                             var pushed:Tpushedsavedother;
-                                            const s:Tregisterset);
+                                            const s:Totherregisterset);
 
-    var r:Toldregister;
+{    var r:Toldregister;
         r2:Tregister;
-        hr:Treference;
+        hr:Treference;}
 
     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
         begin
           pushed[r].pushed:=false;
@@ -347,58 +146,27 @@ unit rgcpu;
               r2.enum:=r;
               list.concat(Taicpu.Op_reg_ref(A_MOVQ,S_NO,r2,hr));
               include(unusedregsmm,r);
-            {$ifndef newra}
-              inc(countunusedregsmm);
-            {$endif}
               pushed[r].pushed:=true;
             end;
-        end;
+        end;*)
 {$ifdef TEMPREGDEBUG}
       testregisters;
 {$endif TEMPREGDEBUG}
     end;
 {$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}
     procedure trgcpu.popusedotherregisters(list:Taasmoutput;
                                            const pushed:Tpushedsavedother);
 
-    var r:Toldregister;
+{    var r:Toldregister;
         r2,r3:Tregister;
-        hr:Treference;
+        hr:Treference;}
 
     begin
       { 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
           begin
             r2.enum:=R_INTREGISTER;
@@ -407,38 +175,18 @@ unit rgcpu;
             r3.enum:=r;
             list.concat(Taicpu.op_ref_reg(A_MOVQ,S_NO,hr,r3));
             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);
-          end;
+          end;}
 {$ifdef TEMPREGDEBUG}
       testregisters;
 {$endif TEMPREGDEBUG}
     end;
 {$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;
-                                            const s:tregisterset);
+                                            const s:totherregisterset);
 
     begin
 {$ifdef SUPPORT_MMX}
@@ -450,18 +198,6 @@ unit rgcpu;
         inherited saveusedotherregisters(list,saved,s);
     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;
                                                const saved:tpushedsavedother);
@@ -488,16 +224,17 @@ unit rgcpu;
    function trgcpu.correct_fpuregister(r : tregister;ofs : byte) : tregister;
 
      begin
-        correct_fpuregister.enum:=Toldregister(longint(r.enum)+ofs);
+        correct_fpuregister:=r;
+        setsupreg(correct_fpuregister,ofs);
      end;
 
 
     function trgcpu.makeregsize(reg: tregister; size: tcgsize): tregister;
       begin
-        if reg.enum<>R_INTREGISTER then
+        if getregtype(reg)<>R_INTREGISTER then
           internalerror(200306032);
-        result.enum:=R_INTREGISTER;
-        result.number:=(reg.number and (not $ff)) or cgsize2subreg(size);
+        result:=reg;
+        setsubreg(result,cgsize2subreg(size));
       end;
 
 
@@ -508,7 +245,20 @@ end.
 
 {
   $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
       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}
 
-{$ifdef callparatemp}
-  {$undef addstringopt}
-{$endif}
-
 interface
 
     uses
@@ -547,124 +543,48 @@ implementation
                  left:=nil;
                  exit;
                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
-                    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;
-
-{$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;
               exit;
            end;
@@ -1953,7 +1873,13 @@ begin
 end.
 {
   $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
       of the setdef forever and can result in a different between
       original interface and current implementation definition

+ 7 - 5
compiler/nbas.pas

@@ -332,10 +332,6 @@ implementation
 
       begin
          inherited create(blockn,l);
-    {$ifndef newra}
-         if releasetemp then
-           include(flags,nf_releasetemps);
-    {$endif newra}
       end;
 
     function tblocknode.det_resulttype:tnode;
@@ -852,7 +848,13 @@ begin
 end.
 {
   $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
       allocator
     * Some preventive changes to i386 spillinh code

+ 14 - 138
compiler/ncal.pas

@@ -130,9 +130,6 @@ interface
           procedure printnodedata(var t:text);override;
           function  para_count:longint;
        private
-{$ifdef callparatemp}
-          function extract_functioncall_paras: tblocknode;
-{$endif callparatemp}
           AbstractMethodsList : TStringList;
        end;
        tcallnodeclass = class of tcallnode;
@@ -2242,104 +2239,11 @@ type
       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;
 {$ifdef m68k}
       var
          regi : tregister;
 {$endif}
-{$ifdef callparatemp}
-      var
-         callparatemps, newblock: tblocknode;
-         statement: tstatementnode;
-         paras, oldright, newcall: tnode;
-{$endif callparatemp}
       label
         errorexit;
       begin
@@ -2349,10 +2253,6 @@ type
          if assigned(left) then
            tcallparanode(left).det_registers;
 
-{$ifdef callparatemp}
-         callparatemps := extract_functioncall_paras;
-{$endif callparatemp}
-
          { function result node }
          if assigned(_funcretnode) then
            firstpass(_funcretnode);
@@ -2365,10 +2265,7 @@ type
               { procedure does a call }
               if not (block_type in [bt_const,bt_type]) then
                 include(current_procinfo.flags,pi_do_call);
-            {$ifndef newra}
-              rg.incrementintregisterpushed(VOLATILE_INTREGISTERS);
-            {$endif}
-              rg.incrementotherregisterpushed(all_registers);
+              rg.incrementotherregisterpushed(all_otherregisters);
            end
          else
          { not a procedure variable }
@@ -2402,9 +2299,6 @@ type
                 end;
 
              { It doesn't hurt to calculate it already though :) (JM) }
-          {$ifndef newra}
-             rg.incrementintregisterpushed(tprocdef(procdefinition).usedintregisters);
-          {$endif}
              rg.incrementotherregisterpushed(tprocdef(procdefinition).usedotherregisters);
            end;
 
@@ -2532,39 +2426,9 @@ type
               registersmmx:=max(left.registersmmx,registersmmx);
 {$endif SUPPORT_MMX}
            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:
          if assigned(inlinecode) then
            procdefinition.proccalloption:=pocall_inline;
-{$ifdef callparatemp}
-         if assigned(callparatemps) then
-           callparatemps.free;
-{$endif callparatemp}
       end;
 
 {$ifdef state_tracking}
@@ -2650,7 +2514,19 @@ begin
 end.
 {
   $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
 
   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;
       var
-        pushedregs : tmaybesave;
         tmpreg     : tregister;
         isjump,
         pushedfpu  : boolean;
@@ -115,9 +114,6 @@ interface
           end;
 
         { are too few registers free? }
-{$ifndef newra}
-        maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-{$endif}
         if left.location.loc=LOC_FPUREGISTER then
           pushedfpu:=maybe_pushfpu(exprasmlist,right.registersfpu,left.location)
         else
@@ -138,9 +134,6 @@ interface
             truelabel:=otl;
             falselabel:=ofl;
           end;
-{$ifndef newra}
-        maybe_restore(exprasmlist,left.location,pushedregs);
-{$endif}
         if pushedfpu then
           begin
             tmpreg := rg.getregisterfpu(exprasmlist,left.location.size);
@@ -230,15 +223,13 @@ interface
         if (right.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
            not(
                (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
           location_release(exprasmlist,right.location);
         if (left.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
            not(
                (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
           location_release(exprasmlist,left.location);
       end;
@@ -295,11 +286,7 @@ interface
                       left.location.register,location.register)
                   else
                     begin
-{$ifdef newra}
                       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_op_reg_reg(exprasmlist,OP_SHL,location.size,
                         right.location.register,tmpreg);
@@ -309,11 +296,7 @@ interface
                       else
                         cg.a_op_const_reg_reg(exprasmlist,OP_OR,location.size,
                             aword(left.location.value),tmpreg,location.register);
-{$ifdef newra}
                       rg.ungetregisterint(exprasmlist,tmpreg);
-{$else}
-                      cg.free_scratch_reg(exprasmlist,tmpreg);
-{$endif}
                     end;
                   opdone := true;
                 end
@@ -343,21 +326,13 @@ interface
                 begin
                   if left.location.loc = LOC_CONSTANT then
                     begin
-{$ifdef newra}
                       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,
                         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_AND,location.size,right.location.register,tmpreg);
                       cg.a_load_reg_reg(exprasmlist,OS_INT,location.size,tmpreg,location.register);
-{$ifdef newra}
                       rg.ungetregisterint(exprasmlist,tmpreg);
-{$else}
-                      cg.free_scratch_reg(exprasmlist,tmpreg);
-{$endif}
                     end
                   else
                     begin
@@ -677,20 +652,12 @@ interface
             end
           else
             begin
-{$ifdef newra}
               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,
                 aword(left.location.value),tmpreg);
               cg.a_op_reg_reg_reg(exprasmlist,OP_SUB,location.size,
                 right.location.register,tmpreg,location.register);
-{$ifdef newra}
               rg.ungetregisterint(exprasmlist,tmpreg);
-{$else}
-              cg.free_scratch_reg(exprasmlist,tmpreg);
-{$endif}
             end;
         end;
 
@@ -760,13 +727,22 @@ begin
 end.
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around
     + 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
     * sparc fixes
 

+ 7 - 8
compiler/ncgbas.pas

@@ -96,9 +96,6 @@ interface
           begin
             if assigned(hp.left) then
              begin
-             {$ifndef newra}
-               rg.cleartempgen;
-             {$endif newra}
                secondpass(hp.left);
                { Compiler inserted blocks can return values }
                location_copy(hp.location,hp.left.location);
@@ -244,10 +241,6 @@ interface
             begin
               if assigned(hp.left) then
                begin
-               {$ifndef newra}
-                 if nf_releasetemps in flags then
-                   rg.cleartempgen;
-               {$endif newra}
                  secondpass(hp.left);
                  location_copy(hp.location,hp.left.location);
                end;
@@ -316,7 +309,13 @@ begin
 end.
 {
   $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
 
   Revision 1.36  2003/06/09 18:26:46  peter

+ 59 - 284
compiler/ncgcal.pas

@@ -169,19 +169,11 @@ implementation
                   inc(pushedparasize,POINTER_SIZE);
                   if calloption=pocall_inline then
                     begin
-                    {$ifdef newra}
                        tmpreg:=rg.getaddressregister(exprasmlist);
-                    {$else}
-                       tmpreg:=cg.get_scratch_reg_address(exprasmlist);
-                    {$endif}
                        cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                        reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
                        cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
-                    {$ifdef newra}
                        rg.ungetregisterint(exprasmlist,tmpreg);
-                    {$else}
-                       cg.free_scratch_reg(exprasmlist,tmpreg);
-                    {$endif}
                     end
                   else
                     cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
@@ -228,19 +220,11 @@ implementation
 
                    if calloption=pocall_inline then
                      begin
-                     {$ifdef newra}
                        tmpreg:=rg.getaddressregister(exprasmlist);
-                     {$else}
-                       tmpreg:=cg.get_scratch_reg_address(exprasmlist);
-                     {$endif newra}
                        cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                        reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
                        cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
-                     {$ifdef newra}
                        rg.ungetregisterint(exprasmlist,tmpreg);
-                     {$else}
-                       cg.free_scratch_reg(exprasmlist,tmpreg);
-                     {$endif}
                      end
                    else
                      cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
@@ -266,19 +250,11 @@ implementation
               inc(pushedparasize,POINTER_SIZE);
               if calloption=pocall_inline then
                 begin
-                {$ifdef newra}
                    tmpreg:=rg.getaddressregister(exprasmlist);
-                {$else}
-                   tmpreg:=cg.get_scratch_reg_address(exprasmlist);
-                {$endif}
                    cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                    reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
                    cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
-                {$ifdef newra}
                    rg.ungetregisterint(exprasmlist,tmpreg);
-                {$else}
-                   cg.free_scratch_reg(exprasmlist,tmpreg);
-                {$endif}
                 end
               else
                 cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
@@ -316,19 +292,11 @@ implementation
                    inc(pushedparasize,POINTER_SIZE);
                    if calloption=pocall_inline then
                      begin
-                     {$ifdef newra}
                         tmpreg:=rg.getaddressregister(exprasmlist);
-                     {$else}
-                        tmpreg:=cg.get_scratch_reg_address(exprasmlist);
-                     {$endif}
                         cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,tmpreg);
                         reference_reset_base(href,current_procinfo.framepointer,para_offset-pushedparasize);
                         cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
-                     {$ifdef newra}
                         rg.ungetregisterint(exprasmlist,tmpreg);
-                     {$else}
-                        cg.free_scratch_reg(exprasmlist,tmpreg);
-                     {$endif}
                      end
                    else
                      cg.a_paramaddr_ref(exprasmlist,left.location.reference,tempparaloc);
@@ -415,10 +383,7 @@ implementation
     procedure tcgcallnode.handle_return_value;
       var
         cgsize : tcgsize;
-        r,hregister : tregister;
-{$ifndef NEWRA}
-        href: treference;
-{$endif}
+        hregister : tregister;
         tempnode: tnode;
       begin
         { structured results are easy to handle.... }
@@ -434,33 +399,18 @@ implementation
          if is_ansistring(resulttype.def) or
             is_widestring(resulttype.def) then
           begin
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_FUNCTION_RESULT_REG;
-{$ifdef newra}
             { 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
               begin
                 location_reset(location,LOC_CREFERENCE,OS_ADDR);
                 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
             else
               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);
-                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 }
                 { original funcretnode isn't touched -> make sure it's    }
                 { the same here (not sure if it's necessary)              }
@@ -469,15 +419,8 @@ implementation
                 location := tempnode.location;
                 tempnode.free;
                 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
         else
@@ -489,10 +432,10 @@ implementation
                 location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
 {$ifdef cpufpemu}
                 if cs_fp_emulation in aktmoduleswitches then
-                  location.register.enum := FUNCTION_RESULT_REG
+                  location.register:=NR_FUNCTION_RESULT_REG
                 else
 {$endif cpufpemu}
-                  location.register.enum:=FPU_RESULT_REG;
+                  location.register:=NR_FPU_RESULT_REG;
 {$ifdef x86}
                 inc(trgcpu(rg).fpuvaroffset);
 {$else x86}
@@ -517,64 +460,26 @@ implementation
                     begin
                       { Move the function result to free registers, preferably the
                         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
                         are already allocated }
-                      rg.ungetregisterint(exprasmlist,r);
+                      rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT64_LOW_REG);
                       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);
-                      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
                    else
 {$endif cpu64bit}
                     begin
                       {Move the function result to a free register, preferably the
                        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 }
-                      rg.ungetregisterint(exprasmlist,r);
+                      rg.ungetregisterint(exprasmlist,NR_FUNCTION_RESULT_REG);
                       { change register size after the unget because the
                       getregister was done for the full register }
-                      r:=rg.makeregsize(r,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
                 else
@@ -586,7 +491,6 @@ implementation
           end
         else
           begin
-{$ifdef newra}
             cgsize:=def_cgsize(resulttype.def);
 
             { an object constructor is a function with pointer result }
@@ -597,21 +501,12 @@ implementation
 {$ifndef cpu64bit}
               if cgsize in [OS_64,OS_S64] then
                 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
               else
 {$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);
           end;
       end;
@@ -630,17 +525,7 @@ implementation
                begin
                  { don't release the funcret temp }
                  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 }
                  if ppn.left.nodetype=arrayconstructorn then
                    begin
@@ -662,15 +547,9 @@ implementation
 
     procedure tcgcallnode.normal_pass_2;
       var
-         regs_to_push_other : tregisterset;
+         regs_to_push_other : totherregisterset;
          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;
          oldpushedparasize : longint;
          { adress returned from an I/O-error }
@@ -679,9 +558,6 @@ implementation
          href,helpref : treference;
          para_alignment,
          pop_size : longint;
-{$ifdef x86}
-         accreg,
-{$endif x86}
          vmtreg,vmtreg2 : tregister;
          oldaktcallnode : tcallnode;
 
@@ -714,7 +590,7 @@ implementation
                      end
                    else
 {$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);
                  end;
                ppn:=tcgcallparanode(ppn.right);
@@ -795,13 +671,7 @@ implementation
               else
                 iolabel:=nil;
 
-{$ifdef newra}
               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}
               regs_to_push_other := tprocdef(procdefinition).usedotherregisters;
@@ -818,19 +688,15 @@ implementation
            end
          else
            begin
-{$ifdef newra}
               regs_to_alloc:=VOLATILE_INTREGISTERS;
-{$else}
-              regs_to_push_int := VOLATILE_INTREGISTERS;
-{$endif}
 {$ifdef i386}
-              regs_to_push_other := all_registers;
+              regs_to_push_other := all_otherregisters;
 {$else i386}
               regs_to_push_other := VOLATILE_FPUREGISTERS;
 {$endif i386}
 {$ifdef i386}
               rg.used_in_proc_int:=VOLATILE_INTREGISTERS;
-              rg.used_in_proc_other:=all_registers;
+              rg.used_in_proc_other:=all_otherregisters;
 {$endif i386}
 
               { no IO check for methods and procedure variables }
@@ -840,43 +706,23 @@ implementation
         { Include Function result registers }
         if (not is_void(resulttype.def)) then
           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
               LOC_REGISTER,LOC_CREGISTER:
                 begin
 {$ifndef cpu64bit}
                   if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
                     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
                  else
 {$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;
-{$endif NEWRA}
           end;
 
          { 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);
 
          { Initialize for pushing the parameters }
@@ -908,7 +754,7 @@ implementation
              if tprocdef(procdefinition).extnumber=-1 then
                internalerror(200304021);
              { 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);
 
              { test validity of VMT }
@@ -921,24 +767,9 @@ implementation
          { Process parameters }
          if assigned(left) then
            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(
                 (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
                  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}
              pushparas;
@@ -955,9 +786,6 @@ implementation
                  ((tprocdef(procdefinition).parast.symtablelevel)>normal_function_level) then
                 push_framepointer;
 
-{$ifndef newra}
-              rg.saveintregvars(exprasmlist,regs_to_push_int);
-{$endif}
               rg.saveotherregvars(exprasmlist,regs_to_push_other);
 
               if (po_virtualmethod in procdefinition.procoptions) and
@@ -972,7 +800,7 @@ implementation
                    if tprocdef(procdefinition).extnumber=-1 then
                      internalerror(200304021);
                    { VMT should already be loaded in a register }
-                   if vmtreg.number=NR_NO then
+                   if vmtreg=NR_NO then
                      internalerror(200304022);
 
                    { test validity of VMT }
@@ -982,36 +810,26 @@ implementation
 {$else}
                    vmtreg:=methodpointer.location.register;
 {$endif}
-{$ifdef newra}
                    { release self }
                    rg.ungetaddressregister(exprasmlist,vmtreg);
                    vmtreg2:=rg.getabtregisterint(exprasmlist,OS_ADDR);
                    rg.ungetregisterint(exprasmlist,vmtreg2);
                    cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,vmtreg,vmtreg2);
-{$endif newra}
                    { free the resources allocated for the parameters }
                    freeparas;
 
-{$ifdef newra}
                    rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
-{$endif}
                    { call method }
-                   reference_reset_base(href,{$ifdef newra}vmtreg2{$else}vmtreg{$endif},
+                   reference_reset_base(href,vmtreg2,
                       tprocdef(procdefinition)._class.vmtmethodoffset(tprocdef(procdefinition).extnumber));
                    cg.a_call_ref(exprasmlist,href);
-{$ifndef newra}
-                   { release self }
-                   rg.ungetaddressregister(exprasmlist,vmtreg);
-{$endif}
                 end
               else
                 begin
                   { free the resources allocated for the parameters }
                   freeparas;
 
-{$ifdef newra}
                   rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
-{$endif}
                   { Calling interrupt from the same code requires some
                     extra code }
                   if (po_interrupt in procdefinition.procoptions) then
@@ -1025,18 +843,17 @@ implementation
 {$ifdef i386}
               secondpass(right);
 {$endif i386}
-{$ifdef newra}
               if right.location.loc in  [LOC_REFERENCE,LOC_CREFERENCE] then
                 begin
                   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
                       rg.ungetregisterint(exprasmlist,helpref.index);
                       helpref.index:=rg.getabtregisterint(exprasmlist,OS_ADDR);
                       cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,
                                         right.location.reference.index,helpref.index);
                     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
                       rg.ungetregisterint(exprasmlist,helpref.base);
                       helpref.base:=rg.getabtregisterint(exprasmlist,OS_ADDR);
@@ -1049,24 +866,17 @@ implementation
                 rg.ungetregisterint(exprasmlist,right.location.register);
 
               location_freetemp(exprasmlist,right.location);
-{$endif newra}
 
               { free the resources allocated for the parameters }
               freeparas;
 
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,regs_to_alloc);
-{$endif}
               { Calling interrupt from the same code requires some
                 extra code }
               if (po_interrupt in procdefinition.procoptions) then
                 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
                  cg.a_call_ref(exprasmlist,helpref)
                else
@@ -1101,7 +911,6 @@ implementation
          testregisters32;
 {$endif TEMPREGDEBUG}
 
-{$ifdef newra}
          { Release registers, but not the registers that contain the
            function result }
          regs_to_free:=regs_to_alloc;
@@ -1113,17 +922,17 @@ implementation
 {$ifndef cpu64bit}
                    if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
                      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
                    else
 {$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;
          rg.deallocexplicitregistersint(exprasmlist,regs_to_free);
-{$endif}
+
          { handle function results }
          if (not is_void(resulttype.def)) then
            handle_return_value
@@ -1136,20 +945,13 @@ implementation
               //reference_reset_symbol(href,iolabel,0);
               //cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(exprasmlist,1));
               //paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_IOCHECK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
            end;
 
          { restore registers }
          rg.restoreusedotherregisters(exprasmlist,pushedother);
-       {$ifndef newra}
-         rg.restoreusedintregisters(exprasmlist,pushedint);
-       {$endif}
 
          { release temps of paras }
          release_para_temps;
@@ -1169,8 +971,7 @@ implementation
                 begin
 {$ifdef x86}
                   { 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);
                     do NOT decrement as the increment before
@@ -1184,22 +985,13 @@ implementation
 
     procedure tcgcallnode.inlined_pass_2;
       var
-         regs_to_push_int : Tsupregset;
-         regs_to_push_other : tregisterset;
+         regs_to_push_int : Tsuperregisterset;
+         regs_to_push_other : totherregisterset;
          unusedstate: pointer;
          pushedother : tpushedsavedother;
-      {$ifndef newra}
-         pushedint : tpushedsavedint;
-         pushedregs : tmaybesave;
-      {$endif}
          oldpushedparasize : longint;
          { adress returned from an I/O-error }
          iolabel : tasmlabel;
-         { help reference pointer }
-         href : treference;
-{$ifdef x86}
-         accreg : tregister;
-{$endif x86}
          oldaktcallnode : tcallnode;
          oldprocdef : tprocdef;
          i : longint;
@@ -1246,9 +1038,6 @@ implementation
              { inlined code block are (JM)                                    }
              rg.resetusableregisters;
              rg.clearregistercount;
-           {$ifndef newra}
-             rg.cleartempgen;
-           {$endif}
              if assigned(tprocdef(procdefinition).regvarinfo) then
                with pregvarinfo(tprocdef(procdefinition).regvarinfo)^ do
                  for i := 1 to maxvarregs do
@@ -1366,19 +1155,16 @@ implementation
 {$ifndef cpu64bit}
                    if procdefinition.funcret_paraloc[callerside].size in [OS_S64,OS_64] then
                      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
                    else
 {$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;
 
-      {$ifndef newra}
-         rg.saveusedintregisters(exprasmlist,pushedint,regs_to_push_int);
-      {$endif}
          rg.saveusedotherregisters(exprasmlist,pushedother,regs_to_push_other);
 
 {$ifdef i386}
@@ -1397,32 +1183,14 @@ implementation
 
          if assigned(left) then
            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
                 the parameter block }
               tcallparanode(left).secondcallparan(
                   (po_leftright in procdefinition.procoptions),procdefinition.proccalloption,
                   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;
          aktcallnode:=oldaktcallnode;
 
-      {$ifndef newra}
-         rg.saveintregvars(exprasmlist,regs_to_push_int);
-      {$endif}
          rg.saveotherregvars(exprasmlist,regs_to_push_other);
 
          { takes care of local data initialization }
@@ -1493,20 +1261,13 @@ implementation
               //reference_reset_symbol(href,iolabel,0);
               //cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(exprasmlist,1));
               //paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_IOCHECK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
            end;
 
          { restore registers }
          rg.restoreusedotherregisters(exprasmlist,pushedother);
-      {$ifndef newra}
-         rg.restoreusedintregisters(exprasmlist,pushedint);
-      {$endif}
 
          { release temps of paras }
          release_para_temps;
@@ -1527,8 +1288,7 @@ implementation
                 begin
 {$ifdef x86}
                   { 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);
                     do NOT decrement as the increment before
@@ -1583,7 +1343,22 @@ begin
 end.
 {
   $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
 
   Revision 1.107  2003/08/17 16:59:20  jonas

+ 5 - 6
compiler/ncgcon.pas

@@ -442,12 +442,8 @@ implementation
                              i:=0;
                              while assigned(hp1) and (i<32) do
                               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
-                            {$endif}
-                                 break;
+                                  break;
                                 inc(i);
                                 hp1:=tai(hp1.next);
                               end;
@@ -549,7 +545,10 @@ begin
 end.
 {
   $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
 
   Revision 1.27  2003/04/24 22:29:57  florian

+ 47 - 166
compiler/ncgflw.pas

@@ -135,9 +135,6 @@ implementation
 
          aktcontinuelabel:=lcont;
          aktbreaklabel:=lbreak;
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
          if assigned(right) then
            secondpass(right);
 
@@ -156,9 +153,6 @@ implementation
             truelabel:=lloop;
             falselabel:=lbreak;
           end;
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
          secondpass(left);
 
          maketojumpbool(exprasmlist,left,lr_load_regvars);
@@ -187,7 +181,7 @@ implementation
          else_regvar_loaded_other : regvarother_booleanarray;
          org_regvar_loaded_int,
          then_regvar_loaded_int,
-         else_regvar_loaded_int : Tsupregset;
+         else_regvar_loaded_int : Tsuperregisterset;
          org_list,
          then_list,
          else_list : taasmoutput;
@@ -200,9 +194,6 @@ implementation
          oflabel:=falselabel;
          objectlibrary.getlabel(truelabel);
          objectlibrary.getlabel(falselabel);
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
          secondpass(left);
 
 {$ifdef i386}
@@ -227,9 +218,6 @@ implementation
          if assigned(right) then
            begin
               cg.a_label(exprasmlist,truelabel);
-           {$ifndef newra}
-              rg.cleartempgen;
-           {$endif}
               secondpass(right);
            end;
 
@@ -265,9 +253,6 @@ implementation
                    cg.a_jmp_always(exprasmlist,hl);
                 end;
               cg.a_label(exprasmlist,falselabel);
-            {$ifndef newra}
-              rg.cleartempgen;
-            {$endif}
               secondpass(t1);
 {$ifdef i386}
               { save current asmlist (previous instructions + else-block) }
@@ -367,19 +352,12 @@ implementation
          objectlibrary.getlabel(l3);
 
          { only calculate reference }
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
          secondpass(t2);
          hs := t2.resulttype.def.size;
          opsize := def_cgsize(t2.resulttype.def);
 
          { first set the to value
            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;
 
          secondpass(right);
@@ -404,9 +382,6 @@ implementation
            temptovalue:=false;
 
          { produce start assignment }
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
          secondpass(left);
          count_var_is_signed:=is_signed(t2.resulttype.def);
 
@@ -468,9 +443,6 @@ implementation
             end;
 
          { help register must not be in instruction block }
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
          if assigned(t1) then
            begin
              secondpass(t1);
@@ -491,11 +463,6 @@ implementation
 
          cg.a_label(exprasmlist,aktcontinuelabel);
 
-         { makes no problems there }
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif}
-
          if do_loopvar_at_end then
            if lnf_backward in loopflags then
              if count_var_is_signed then
@@ -787,9 +754,6 @@ implementation
 
          load_all_regvars(exprasmlist);
          cg.a_label(exprasmlist,labelnr);
-      {$ifndef newra}
-         rg.cleartempgen;
-      {$endif newra}
          secondpass(left);
       end;
 
@@ -803,43 +767,34 @@ implementation
       var
          a : tasmlabel;
          href2: treference;
-         r:Tregister;
       begin
          location_reset(location,LOC_VOID,OS_NO);
 
          if assigned(left) then
            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);
               if codegenerror then
                 exit;
-{$endif callparatemp}
-              { multiple parameters? }
+
+              { Push parameters }
               if assigned(right) then
                 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
                     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
                   else
                     cg.a_param_const(exprasmlist,OS_INT,0,paramanager.getintparaloc(exprasmlist,3));
-{$ifndef callparatemp}
                   { 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));
                 end
               else
@@ -849,43 +804,28 @@ implementation
                    cg.a_label(exprasmlist,a);
                    reference_reset_symbol(href2,a,0);
                    { 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 }
                    if target_info.system <> system_powerpc_macos then
                      cg.a_paramaddr_ref(exprasmlist,href2,paramanager.getintparaloc(exprasmlist,2))
                    else
                      cg.a_param_const(exprasmlist,OS_INT,0,paramanager.getintparaloc(exprasmlist,2));
                 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));
               paramanager.freeintparaloc(exprasmlist,3);
               paramanager.freeintparaloc(exprasmlist,2);
               paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_RAISEEXCEPTION');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
            end
          else
            begin
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
               cg.a_call_name(exprasmlist,'FPC_RERAISE');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
            end;
        end;
 
@@ -922,27 +862,15 @@ implementation
     { in the except block                                    }
     procedure cleanupobjectstack;
 
-    var r:Tregister;
-
       begin
-{$ifdef newra}
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
          cg.a_call_name(exprasmlist,'FPC_POPOBJECTSTACK');
-{$ifdef newra}
          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);
-{$ifdef newra}
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
          cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
-{$ifdef newra}
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
       end;
 
 
@@ -966,7 +894,6 @@ implementation
          exceptflowcontrol : tflowcontrol;
          tempbuf,tempaddr : treference;
          href : treference;
-         r:Tregister;
 
       label
          errorexit;
@@ -1048,13 +975,9 @@ implementation
               }
               cg.a_param_const(exprasmlist,OS_ADDR,aword(-1),paramanager.getintparaloc(exprasmlist,1));
               paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_CATCHES');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
 
               { the destruction of the exception object must be also }
               { guarded by an exception frame                        }
@@ -1072,25 +995,15 @@ implementation
 
               try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
 
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
-{$ifdef newra}
               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);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               { we don't need to restore esi here because reraise never }
               { returns                                                 }
               cg.a_call_name(exprasmlist,'FPC_RERAISE');
@@ -1111,13 +1024,9 @@ implementation
               cg.a_label(exprasmlist,exitexceptlabel);
               { we must also destroy the address frame which guards }
               { exception object                                    }
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.g_exception_reason_load(exprasmlist,href);
               cleanupobjectstack;
               cg.a_jmp_always(exprasmlist,oldaktexitlabel);
@@ -1128,13 +1037,9 @@ implementation
               cg.a_label(exprasmlist,breakexceptlabel);
               { we must also destroy the address frame which guards }
               { exception object                                    }
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.g_exception_reason_load(exprasmlist,href);
               cleanupobjectstack;
               cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
@@ -1145,13 +1050,9 @@ implementation
               cg.a_label(exprasmlist,continueexceptlabel);
               { we must also destroy the address frame which guards }
               { exception object                                    }
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.g_exception_reason_load(exprasmlist,href);
               cleanupobjectstack;
               cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
@@ -1161,13 +1062,9 @@ implementation
            begin
               { do some magic for exit in the try block }
               cg.a_label(exprasmlist,exittrylabel);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.g_exception_reason_load(exprasmlist,href);
               cg.a_jmp_always(exprasmlist,oldaktexitlabel);
            end;
@@ -1175,13 +1072,9 @@ implementation
          if fc_break in tryflowcontrol then
            begin
               cg.a_label(exprasmlist,breaktrylabel);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.g_exception_reason_load(exprasmlist,href);
               cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
            end;
@@ -1189,13 +1082,9 @@ implementation
          if fc_continue in tryflowcontrol then
            begin
               cg.a_label(exprasmlist,continuetrylabel);
-{$ifdef newra}
               rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
-{$ifdef newra}
               rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.g_exception_reason_load(exprasmlist,href);
               cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
            end;
@@ -1235,7 +1124,6 @@ implementation
          tempbuf,tempaddr : treference;
          href : treference;
          href2: treference;
-         r:Tregister;
 
       begin
          location_reset(location,LOC_VOID,OS_NO);
@@ -1248,25 +1136,19 @@ implementation
          reference_reset_symbol(href2,objectlibrary.newasmsymboldata(excepttype.vmt_mangledname),0);
          cg.a_paramaddr_ref(exprasmlist,href2,paramanager.getintparaloc(exprasmlist,1));
          paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
          cg.a_call_name(exprasmlist,'FPC_CATCHES');
-{$ifdef newra}
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
 
          { 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;
          tg.GetTemp(exprasmlist,pointer_size,tt_normal,ref);
 
          { what a hack ! }
          if assigned(exceptsymtable) then
            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 }
          { we've to destroy the old one                }
@@ -1297,22 +1179,14 @@ implementation
 
          try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
 
-{$ifdef newra}
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
          cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
-{$ifdef newra}
          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);
-{$ifdef newra}
          rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
          cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
-{$ifdef newra}
          rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
          { we don't need to restore esi here because reraise never }
          { returns                                                 }
          cg.a_call_name(exprasmlist,'FPC_RERAISE');
@@ -1359,12 +1233,7 @@ implementation
          flowcontrol:=oldflowcontrol+flowcontrol;
          { next on node }
          if assigned(left) then
-           begin
-            {$ifndef newra}
-              rg.cleartempgen;
-            {$endif newra}
-              secondpass(left);
-           end;
+           secondpass(left);
       end;
 
 {*****************************************************************************
@@ -1386,7 +1255,6 @@ implementation
          decconst : longint;
          tempbuf,tempaddr : treference;
          href : treference;
-         r:Tregister;
 
       begin
          location_reset(location,LOC_VOID,OS_NO);
@@ -1450,11 +1318,9 @@ implementation
 
          { the value should now be in the exception handler }
          cg.g_exception_reason_load(exprasmlist,href);
-         r.enum:=R_INTREGISTER;
-         r.number:=NR_FUNCTION_RESULT_REG;
          if implicitframe then
            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 }
              flowcontrol:=[];
              secondpass(t1);
@@ -1466,29 +1332,29 @@ implementation
            end
          else
            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
                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;
                end
              else
                decconst:=2;
              if fc_break in tryflowcontrol then
                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;
                end
              else
                inc(decconst);
              if fc_continue in tryflowcontrol then
                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;
              cg.a_label(exprasmlist,reraiselabel);
              cg.a_call_name(exprasmlist,'FPC_RERAISE');
@@ -1543,13 +1409,28 @@ begin
 end.
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around
     + 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
     * made FPC_RAISEEXCEPTION compatible with MacOS
 

+ 8 - 41
compiler/ncginl.pas

@@ -177,7 +177,6 @@ implementation
      var
          hp2 : tstringconstnode;
          otlabel,oflabel{,l1}   : tasmlabel;
-         r: Tregister;
      begin
        { the node should be removed in the firstpass }
        if not (cs_do_assertion in aktlocalswitches) then
@@ -190,9 +189,7 @@ implementation
        maketojumpbool(exprasmlist,tcallparanode(left).left,lr_load_regvars);
        cg.a_label(exprasmlist,falselabel);
        { 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 }
        cg.a_param_const(exprasmlist,OS_INT,aktfilepos.line,paramanager.getintparaloc(exprasmlist,3));
        { filename string }
@@ -211,13 +208,9 @@ implementation
        paramanager.freeintparaloc(exprasmlist,3);
        paramanager.freeintparaloc(exprasmlist,2);
        paramanager.freeintparaloc(exprasmlist,1);
-{$ifdef newra}
        rg.allocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
        cg.a_call_name(exprasmlist,'FPC_ASSERT');
-{$ifdef newra}
        rg.deallocexplicitregistersint(exprasmlist,VOLATILE_INTREGISTERS);
-{$endif newra}
        cg.a_label(exprasmlist,truelabel);
        truelabel:=otlabel;
        falselabel:=oflabel;
@@ -375,7 +368,6 @@ implementation
          hregisterhi,
          hregister : tregister;
          cgsize : tcgsize;
-         pushedregs : tmaybesave;
         begin
           { set defaults }
           addconstant:=true;
@@ -400,14 +392,7 @@ implementation
           { second_ argument specified?, must be a s32bit in register }
           if assigned(tcallparanode(left).right) then
             begin
-            {$ifndef newra}
-              maybe_save(exprasmlist,tcallparanode(tcallparanode(left).right).left.registers32,
-                 tcallparanode(left).left.location,pushedregs);
-            {$endif}
               secondpass(tcallparanode(tcallparanode(left).right).left);
-            {$ifndef newra}
-              maybe_restore(exprasmlist,tcallparanode(left).left.location,pushedregs);
-            {$endif}
               { when constant, just multiply the addvalue }
               if is_constintnode(tcallparanode(tcallparanode(left).right).left) then
                  addvalue:=addvalue*get_ordinal_value(tcallparanode(tcallparanode(left).right).left)
@@ -472,7 +457,6 @@ implementation
         var
          hregister : tregister;
          L : longint;
-         pushedregs : TMaybesave;
          cgop : topcg;
          addrreg, hregister2: tregister;
          use_small : boolean;
@@ -519,21 +503,10 @@ implementation
                    (tenumdef(tcallparanode(tcallparanode(left).right).left.resulttype.def).max<=32));
 
               { 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);
-            {$ifndef newra}
-              maybe_restore(exprasmlist,tcallparanode(left).left.location,pushedregs);
-            {$endif newra}
 
               { bitnumber - which must be loaded into register }
-            {$ifdef newra}
               hregister:=rg.getregisterint(exprasmlist,OS_INT);
-            {$else}
-              hregister := cg.get_scratch_reg_int(exprasmlist,OS_INT);
-            {$endif}
               hregister2 := rg.getregisterint(exprasmlist,OS_INT);
 
               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(exprasmlist, OP_SHL, OS_32, 2, hregister2);
-              {$ifdef newra}
                   addrreg:=rg.getaddressregister(exprasmlist);
-              {$else}
-                  addrreg := cg.get_scratch_reg_address(exprasmlist);
-              {$endif}
                   { calculate the correct address of the operand }
                   cg.a_loadaddr_ref_reg(exprasmlist, tcallparanode(left).left.location.reference,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_ref(exprasmlist, OP_AND, OS_32, hregister2, href);
                        end;
-                {$ifdef newra}
                   rg.ungetregisterint(exprasmlist,addrreg);
-                {$else}
-                  cg.free_scratch_reg(exprasmlist, addrreg);
-                {$endif}
                 end;
-              {$ifdef newra}
                 rg.ungetregisterint(exprasmlist,hregister);
-              {$else}
-                cg.free_scratch_reg(exprasmlist,hregister);
-              {$endif}
                 rg.ungetregisterint(exprasmlist,hregister2);
             end;
         end;
@@ -692,7 +653,13 @@ end.
 
 {
   $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
       pairs round calls to helpers
 

+ 35 - 83
compiler/ncgld.pas

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

+ 16 - 32
compiler/ncgmat.pas

@@ -266,18 +266,11 @@ implementation
          hdenom : tregister;
          power : longint;
          hl : tasmlabel;
-         pushedregs : tmaybesave;
       begin
          secondpass(left);
          if codegenerror then
           exit;
-        {$ifndef newra}
-         maybe_save(exprasmlist,right.registers32,left.location,pushedregs);
-        {$endif}
          secondpass(right);
-        {$ifndef newra}
-         maybe_restore(exprasmlist,left.location,pushedregs);
-        {$endif newra}
          if codegenerror then
           exit;
          location_copy(location,left.location);
@@ -362,6 +355,9 @@ implementation
          op : topcg;
       begin
 {$ifdef cpu64bit}
+         freescratch:=false;
+         secondpass(left);
+         secondpass(right);
          { determine operator }
          case nodetype of
            shln: op:=OP_SHL;
@@ -383,21 +379,6 @@ implementation
            begin
              { this should be handled in pass_1 }
              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;
 {$else cpu64bit}
          { already hanled in 1st pass }
@@ -405,6 +386,7 @@ implementation
 {$endif cpu64bit}
       end;
 
+
     procedure tcgshlshrnode.second_integer;
       var
          freescratch : boolean;
@@ -445,27 +427,19 @@ implementation
                 begin
                   if right.location.loc<>LOC_CREGISTER then
                    location_release(exprasmlist,right.location);
-                {$ifdef newra}
                   hcountreg:=rg.getregisterint(exprasmlist,OS_INT);
-                {$else}
-                  hcountreg:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
-                {$endif}
                   freescratch := true;
                   cg.a_load_loc_reg(exprasmlist,right.location.size,right.location,hcountreg);
                 end
               else
                 hcountreg:=right.location.register;
               cg.a_op_reg_reg(exprasmlist,op,OS_INT,hcountreg,location.register);
-            {$ifdef newra}
               if freescratch then
                 rg.ungetregisterint(exprasmlist,hcountreg);
-            {$else}
-              if freescratch then
-                cg.free_scratch_reg(exprasmlist,hcountreg);
-            {$endif}
            end;
       end;
 
+
     procedure tcgshlshrnode.pass_2;
       begin
          secondpass(left);
@@ -524,13 +498,23 @@ begin
 end.
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around
     + 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
     * paraloc splitted in callerparaloc,calleeparaloc
     * sparc calling convention updates

+ 11 - 86
compiler/ncgmem.pas

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

+ 12 - 7
compiler/ncgopt.pas

@@ -107,8 +107,7 @@ begin
     end;
   secondpass(right);
   { 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 }
   { may need registers from the reference                           }
@@ -154,8 +153,8 @@ begin
   { we need a new reference to store the character }
   { at the end of the string. Check if the base or }
   { 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
       { they're not free, so add the base reg to       }
       { the string length (since the index can         }
@@ -165,7 +164,7 @@ begin
     end
   else
     { 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
     else
       begin
@@ -186,7 +185,7 @@ begin
     end
   else
     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 }
   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);
@@ -202,7 +201,13 @@ end.
 
 {
   $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
     * makeregsize only accepts newregister
     * i386 uses generic tcgnotnode,tcgunaryminus

+ 14 - 86
compiler/ncgset.pas

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

+ 56 - 344
compiler/ncgutil.pas

@@ -40,23 +40,14 @@ interface
     type
       tloadregvars = (lr_dont_load_regvars, lr_load_regvars);
 
-      tmaybesave = record
-        saved : boolean;
-        ref   : treference;
-      end;
-
     procedure firstcomplex(p : tbinarynode);
     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_fpureg(list: TAAsmoutput;var l: tlocation;maybeconst:boolean);
     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;
 
     procedure push_value_para(list:taasmoutput;p:tnode;calloption:tproccalloption;
@@ -235,32 +226,24 @@ implementation
       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
         case t.loc of
           LOC_REGISTER:
             begin
               { 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;
           LOC_CREFERENCE,LOC_REFERENCE:
             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
-                 ((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
-                 ((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;
@@ -272,8 +255,6 @@ implementation
     procedure new_exception(list : taasmoutput;const jmpbuf,envbuf, href : treference;
       a : aword; exceptlabel : tasmlabel);
 
-    var r:Tregister;
-
      begin
        cg.a_paramaddr_ref(list,envbuf,paramanager.getintparaloc(list,3));
        cg.a_paramaddr_ref(list,jmpbuf,paramanager.getintparaloc(list,2));
@@ -282,51 +263,33 @@ implementation
        paramanager.freeintparaloc(list,3);
        paramanager.freeintparaloc(list,2);
        paramanager.freeintparaloc(list,1);
-{$ifdef newra}
        rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
        cg.a_call_name(list,'FPC_PUSHEXCEPTADDR');
-{$ifdef newra}
        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);
-{$ifdef newra}
        rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
        cg.a_call_name(list,'FPC_SETJMP');
-{$ifdef newra}
        rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
 
        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;
 
 
     procedure free_exception(list : taasmoutput;const jmpbuf, envbuf, href : treference;
      a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
 
-    var r:Tregister;
-
      begin
-{$ifdef newra}
          rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
          cg.a_call_name(list,'FPC_POPADDRSTACK');
-{$ifdef newra}
          rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
 
          if not onlyfree then
           begin
             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;
 
@@ -352,8 +315,8 @@ implementation
               { load a smaller size to OS_64 }
               if l.loc=LOC_REGISTER then
                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);
                end
               else
@@ -416,7 +379,7 @@ implementation
               hreg64.reglo:=hregister;
               hreg64.reghi:=hregisterhi;
               { 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);
               l.registerlow:=hregister;
               l.registerhigh:=hregisterhi;
@@ -424,14 +387,12 @@ implementation
          end
         else
          begin
-         {$ifdef newra}
            { transformations to 32bit or smaller }
            if (l.loc=LOC_REGISTER) and (l.size in [OS_64,OS_S64]) then
              { if the previous was 64bit release the high register }
              begin
                rg.ungetregisterint(list,l.registerhigh);
-               l.registerhigh.enum:=R_INTREGISTER;
-               l.registerhigh.number:=NR_NO;
+               l.registerhigh:=NR_NO;
              end;
             if l.loc=LOC_REGISTER then
               rg.ungetregisterint(list,l.register);
@@ -440,49 +401,6 @@ implementation
             and trying to recycle registers can cause problems because
             the registers changes size and may need aditional constraints.}
            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 }
            case l.loc of
              LOC_FLAGS :
@@ -522,17 +440,6 @@ implementation
                  if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
                    l.size:=dst_size;
 {$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;
            if (l.loc <> LOC_CREGISTER) or
@@ -651,7 +558,7 @@ implementation
      end;
 {$endif cpu64bit}
 
-{$ifdef newra}
+
     procedure location_force_reg(list: TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
 
     var oldloc:Tlocation;
@@ -666,18 +573,7 @@ implementation
            location_release(list,oldloc);
          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);
       var
@@ -736,110 +632,6 @@ implementation
                                   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;
       begin
         if (needed>=maxfpuregs) and
@@ -864,7 +656,6 @@ implementation
         href : treference;
 {$ifdef i386}
         tempreference : treference;
-        hreg : tregister;
         sizetopush : longint;
 {$endif i386}
         size : longint;
@@ -907,11 +698,8 @@ implementation
                       size:=align(tfloatdef(p.resulttype.def).size,alignment);
                       inc(pushedparasize,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);
-
                    end;
                  LOC_REFERENCE,
                  LOC_CREFERENCE :
@@ -968,9 +756,7 @@ implementation
               size:=align(p.resulttype.def.size,alignment);
               inc(pushedparasize,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);
 {$else i386}
               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
            (paramanager.push_addr_param(tvarsym(p).vartype.def,current_procinfo.procdef.proccalloption)) then
          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
              reference_reset_base(href1,current_procinfo.framepointer,tvarsym(p).adjusted_address)
            else
@@ -1181,19 +967,11 @@ implementation
              vs_out :
                begin
                  reference_reset_base(href,current_procinfo.framepointer,tvarsym(p).adjusted_address);
-               {$ifdef newra}
                  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);
                  reference_reset_base(href,tmpreg,0);
                  cg.g_initialize(list,tvarsym(p).vartype.def,href,false);
-               {$ifdef newra}
                  rg.ungetregisterint(list,tmpreg);
-               {$else}
-                 cg.free_scratch_reg(list,tmpreg);
-               {$endif newra}
                end;
            end;
          end;
@@ -1261,13 +1039,9 @@ implementation
                  reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
                  cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(list,1));
                  paramanager.freeintparaloc(list,1);
-{$ifdef newra}
                  rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                  cg.a_call_name(list,'FPC_ANSISTR_DECR_REF');
-{$ifdef newra}
                  rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                end;
              tt_widestring,
              tt_freewidestring :
@@ -1275,26 +1049,18 @@ implementation
                  reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
                  cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(list,1));
                  paramanager.freeintparaloc(list,1);
-{$ifdef newra}
                  rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                  cg.a_call_name(list,'FPC_WIDESTR_DECR_REF');
-{$ifdef newra}
                  rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                end;
              tt_interfacecom :
                begin
                  reference_reset_base(href,current_procinfo.framepointer,hp^.pos);
                  cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(list,1));
                  paramanager.freeintparaloc(list,1);
-{$ifdef newra}
                  rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                  cg.a_call_name(list,'FPC_INTF_DECR_REF');
-{$ifdef newra}
                  rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                end;
            end;
            hp:=hp^.next;
@@ -1320,7 +1086,7 @@ implementation
                   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));
                   { 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);
                end;
           end;
@@ -1346,28 +1112,20 @@ implementation
         { Constructors need to return self }
         if (current_procinfo.procdef.proctypeoption=potype_constructor) then
           begin
-{$ifdef newra}
             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 }
             ressym:=tvarsym(current_procinfo.procdef.parast.search('self'));
             if not assigned(ressym) then
               internalerror(200305058);
             reference_reset_base(href,current_procinfo.framepointer,tvarsym(ressym).adjusted_address);
-{$ifdef newra}
             rg.ungetregisterint(list,r);
-{$endif newra}
             cg.a_load_ref_reg(list,OS_ADDR,OS_ADDR,href,r);
             uses_acc:=true;
             exit;
           end;
 
         ressym := tvarsym(current_procinfo.procdef.funcretsym);
-        if ressym.reg.enum <> R_NO then
+        if ressym.reg<>NR_NO then
           begin
             if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
               location_reset(resloc,LOC_CREGISTER,OS_ADDR)
@@ -1395,37 +1153,18 @@ implementation
               if resloc.size in [OS_64,OS_S64] then
                begin
                  uses_acchi:=true;
-{$ifdef newra}
                  r:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN64_LOW_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,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
               else
 {$endif cpu64bit}
                begin
-{$ifdef newra}
                  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);
-{$ifdef newra}
                  rg.ungetregisterint(list,hreg);
-{$endif newra}
                  cg.a_load_loc_reg(list,resloc.size,resloc,hreg);
                end;
             end;
@@ -1433,11 +1172,11 @@ implementation
             begin
               uses_fpu := true;
 {$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
 {$endif cpufpemu}
-               r.enum:=FPU_RESULT_REG;
+                r:=NR_FPU_RESULT_REG;
               cg.a_loadfpu_loc_reg(list,resloc,r);
             end;
           else
@@ -1450,37 +1189,18 @@ implementation
                  if resloc.size in [OS_64,OS_S64] then
                   begin
                     uses_acchi:=true;
-{$ifdef newra}
                     r:=rg.getexplicitregisterint(list,NR_FUNCTION_RETURN64_LOW_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,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
                  else
 {$endif cpu64bit}
                   begin
-{$ifdef newra}
                     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);
-{$ifdef newra}
                     rg.ungetregisterint(list,hreg);
-{$endif newra}
                     cg.a_load_loc_reg(list,resloc.size,resloc,hreg);
                   end;
                 end
@@ -1558,23 +1278,15 @@ implementation
                  cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(list,1));
                  paramanager.freeintparaloc(list,2);
                  paramanager.freeintparaloc(list,1);
-{$ifdef newra}
                  rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                  cg.a_call_name(list,'_monstartup');
-{$ifdef newra}
                  rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
                end;
 
               { initialize units }
-{$ifdef newra}
               rg.allocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
               cg.a_call_name(list,'FPC_INITIALIZEUNITS');
-{$ifdef newra}
               rg.deallocexplicitregistersint(list,VOLATILE_INTREGISTERS);
-{$endif newra}
             end;
 
 {$ifdef GDB}
@@ -1683,7 +1395,7 @@ implementation
 {$ifndef powerpc}
         { at least for the ppc this applies always, so this code isn't usable (FK) }
         { omit stack frame ? }
-        if (current_procinfo.framepointer.number=NR_STACK_POINTER_REG) then
+        if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
           begin
             CGmessage(cg_d_stackframe_omited);
             if stackframe<>0 then
@@ -1709,10 +1421,7 @@ implementation
       var
         href : treference;
         hp : tparaitem;
-        rsp : tregister;
-{$ifdef newra}
         gotregvarparas: boolean;
-{$endif newra}
       begin
         { the actual stack allocation code, symbol entry point and
           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  }
             { registers and it also expects the values to be in memory                                }
             hp:=tparaitem(current_procinfo.procdef.para.first);
-{$ifdef newra}
             gotregvarparas := false;
-{$endif newra}
             while assigned(hp) do
               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
-{$ifdef newra}
                     gotregvarparas := true;
                     { cg.a_load_param_reg will first allocate and then deallocate paraloc }
                     { register (if the parameter resides in a register) and then allocate }
                     { the regvar (which is currently not allocated)                       }
-{$endif newra}
                     cg.a_load_param_reg(list,hp.paraloc[calleeside],tvarsym(hp.parasym).reg);
                   end
                 else if (hp.paraloc[calleeside].loc in [LOC_REGISTER,LOC_FPUREGISTER,LOC_MMREGISTER,
                                             LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMREGISTER]) and
-                        (tvarsym(hp.parasym).reg.enum=R_NO) then
+                        (tvarsym(hp.parasym).reg=NR_NO) then
                   begin
                     reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
                     cg.a_load_param_ref(list,hp.paraloc[calleeside],href);
                   end;
                 hp:=tparaitem(hp.next);
               end;
-{$ifdef newra}
             if gotregvarparas then
               begin
                 { deallocate all register variables again }
                 hp:=tparaitem(current_procinfo.procdef.para.first);
                 while assigned(hp) do
                   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);
                     hp:=tparaitem(hp.next);
                   end;
               end;
-{$endif newra}
           end;
 
         { for the save all registers we can simply use a pusha,popa which
@@ -1781,14 +1482,12 @@ implementation
 
         { Save stackpointer value }
         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_saveregisters in current_procinfo.procdef.procoptions)) then
          begin
            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;
 
@@ -1800,7 +1499,6 @@ implementation
         mangled_length : longint;
         p : pchar;
 {$endif GDB}
-        rsp : Tregister;
         stacksize,
         retsize : longint;
       begin
@@ -1815,13 +1513,11 @@ implementation
 
         { Restore stackpointer if it was saved }
         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_saveregisters in current_procinfo.procdef.procoptions)) then
          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);
          end;
 
@@ -1838,7 +1534,7 @@ implementation
         { remove stackframe }
         if not inlined then
          begin
-           if (current_procinfo.framepointer.number=NR_STACK_POINTER_REG) then
+           if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
             begin
               stacksize:=current_procinfo.calc_stackframe_size;
               if (stacksize<>0) then
@@ -1978,7 +1674,7 @@ implementation
                   begin
                     r:=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
                  else
 {$endif cpu64bit}
@@ -2007,7 +1703,7 @@ implementation
                      begin
                        r:=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
                     else
 {$endif cpu64bit}
@@ -2083,13 +1779,29 @@ implementation
 end.
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around
     + 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
     * Some more R_NO changes
     * Preventive code to loadref added

+ 4 - 21
compiler/ncnv.pas

@@ -279,12 +279,6 @@ implementation
         end;
 
         procedure do_set(pos : longint);
-
-  {$ifdef oldset}
-        var
-          mask,l : longint;
-  {$endif}
-
         begin
           if (pos and not $ff)<>0 then
            Message(parser_e_illegal_set_expr);
@@ -292,19 +286,9 @@ implementation
            constsethi:=pos;
           if pos<constsetlo then
            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
             Message(parser_e_illegal_set_expr);
           include(constset^,pos);
-  {$endif}
         end;
 
       var
@@ -315,11 +299,7 @@ implementation
         if p.nodetype<>arrayconstructorn then
           internalerror(200205105);
         new(constset);
-      {$ifdef oldset}
-        FillChar(constset^,sizeof(constset^),0);
-      {$else}
         constset^:=[];
-      {$endif}
         htype.reset;
         constsetlo:=0;
         constsethi:=0;
@@ -2113,7 +2093,10 @@ begin
 end.
 {
   $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
 
   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;
       end;
 
-{$ifdef oldset}
     function is_emptyset(p : tnode):boolean;
-
-      var
-        i : longint;
       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
-         (Tsetconstnode(p).value_set^=[]);
-    end;
-{$endif}
+                     (Tsetconstnode(p).value_set^=[]);
+      end;
 
 
     function genconstsymtree(p : tconstsym) : tnode;
@@ -822,32 +805,13 @@ implementation
           expectloc:=LOC_CREFERENCE;
       end;
 
-{$ifdef oldset}
+
     function tsetconstnode.docompare(p: tnode): boolean;
-      var
-        i: 0..31;
       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;
-{$else}
-    function tsetconstnode.docompare(p: tnode): boolean;
 
-    begin
-        docompare:=(inherited docompare(p))
-         and (value_set^=Tsetconstnode(p).value_set^);
-    end;
-{$endif}
 
 {*****************************************************************************
                                TNILNODE
@@ -938,7 +902,10 @@ begin
 end.
 {
   $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
       and aliases for result and function name are added using absolutesym
     * vs_hidden parameter for funcret passed in parameter

+ 4 - 7
compiler/node.pas

@@ -35,13 +35,7 @@ interface
 
     type
        pconstset = ^tconstset;
-{$ifdef oldset}
-       tconstset = array[0..31] of byte;
-       pconst32bitset = ^tconst32bitset;
-       tconst32bitset = array[0..7] of longint;
-{$else}
        tconstset = set of 0..255;
-{$endif}
 
        tnodetype = (
           emptynode,        {No node (returns nil when loading from ppu)}
@@ -981,7 +975,10 @@ implementation
 end.
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around

+ 7 - 25
compiler/nset.pas

@@ -182,10 +182,6 @@ implementation
 
     function tinnode.det_resulttype:tnode;
 
-{$ifdef oldset}
-      type
-        byteset = set of byte;
-{$endif}
       var
         t : tnode;
         pst : pconstset;
@@ -203,22 +199,14 @@ implementation
                 pes:=tenumsym(tenumdef(psd.elementtype.def).firstenum);
                 while assigned(pes) do
                   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);
-                {$endif}
                     pes:=pes.nextenum;
                   end;
               end;
             orddef :
               begin
                 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;
           createsetconst:=pcs;
@@ -285,11 +273,7 @@ implementation
          { empty set then return false }
          if not assigned(tsetdef(right.resulttype.def).elementtype.def) or
             ((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
             t:=cordconstnode.create(0,booltype,false);
             resulttypepass(t);
@@ -300,13 +284,8 @@ implementation
          { constant evaluation }
          if (left.nodetype=ordconstn) and (right.nodetype=setconstn) then
           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^),
-              booltype,true);
-        {$endif}
+               booltype,true);
             resulttypepass(t);
             result:=t;
             exit;
@@ -707,7 +686,10 @@ begin
 end.
 {
   $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
     * fixed ungetregisterfpu compilation problems
 

+ 21 - 4
compiler/options.pas

@@ -876,10 +876,8 @@ begin
                      initglobalswitches:=initglobalswitches-[cs_link_on_target]
                    else if more='t' then
                      initglobalswitches:=initglobalswitches+[cs_link_on_target]
-{$ifdef newra}
                    else if more='r' then
-                     initglobalswitches:=initglobalswitches+[cs_no_regalloc]
-{$endif newra}
+                     initglobalswitches:=initglobalswitches+[cs_asm_leave,cs_no_regalloc]
                    else if more<>'' then
                      IllegalPara(opt);
                  end;
@@ -1716,6 +1714,9 @@ begin
   def_symbol('CPUSPARC');
   def_symbol('CPUSPARC32');
   def_symbol('CPU32');
+  def_symbol('FPC_HAS_TYPE_DOUBLE');
+  def_symbol('FPC_HAS_TYPE_SINGLE');
+  def_symbol('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
 {$endif}
 {$ifdef vis}
   def_symbol('CPUVIS');
@@ -1952,13 +1953,29 @@ finalization
 end.
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around
     + 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
     * failn removed
     * inherited result code check moven to pexpr

+ 11 - 5
compiler/paramgr.pas

@@ -254,15 +254,15 @@ implementation
 {$ifndef cpu64bit}
               if (loc.size in [OS_64,OS_S64,OS_F64]) then
                 begin
-                  rg.getexplicitregisterint(list,loc.registerhigh.number);
-                  rg.getexplicitregisterint(list,loc.registerlow.number);
+                  rg.getexplicitregisterint(list,loc.registerhigh);
+                  rg.getexplicitregisterint(list,loc.registerlow);
                 end
               else
 {$endif cpu64bit}
-                rg.getexplicitregisterint(list,loc.register.number);
+                rg.getexplicitregisterint(list,loc.register);
             end;
           LOC_FPUREGISTER, LOC_CFPUREGISTER:
-            rg.getexplicitregisterfpu(list,loc.register.enum);
+            rg.getexplicitregisterfpu(list,loc.register);
           LOC_REFERENCE,LOC_CREFERENCE:
             { do nothing by default, most of the time it's the framepointer }
           else
@@ -352,7 +352,13 @@ end.
 
 {
    $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
 
    Revision 1.49  2003/07/08 21:24:59  peter

+ 18 - 21
compiler/pass_2.pas

@@ -164,9 +164,6 @@ implementation
          prevp : pptree;
 {$endif TEMPREGDEBUG}
 {$ifdef EXTDEBUG}
-{$ifndef newra}
-         i : longint;
-{$endif newra}
 {$endif EXTDEBUG}
       begin
          if not assigned(p) then
@@ -206,21 +203,11 @@ implementation
                  Comment(V_Warning,'Location is different in secondpass: '+nodetype2str[p.nodetype]);
              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);
-  {$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}
             if codegenerror then
               include(p.flags,nf_error);
@@ -262,9 +249,6 @@ implementation
 
     procedure generatecode(var p : tnode);
       begin
-       {$ifndef newra}
-         rg.cleartempgen;
-       {$endif}
          flowcontrol:=[];
          { when size optimization only count occurrence }
          if cs_littlesize in aktglobalswitches then
@@ -317,7 +301,20 @@ implementation
 end.
 {
   $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
 
   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_move:boolean; override;
-{$ifdef newra}
          function spill_registers(list:Taasmoutput;
                                   rgget:Trggetproc;
                                   rgunget:Trgungetproc;
                                   r:Tsupregset;
                                   var unusedregsint:Tsupregset;
                                   const spilltemplist:Tspill_temp_list):boolean; override;
-{$endif}
 
 
       end;
@@ -435,7 +433,6 @@ uses cutils,rgobj;
       end;
 
 
-{$ifdef newra}
     function taicpu.spill_registers(list:Taasmoutput;
                              rgget:Trggetproc;
                              rgunget:Trgungetproc;
@@ -707,8 +704,6 @@ uses cutils,rgobj;
                 end;
             end;
       end;
-{$endif newra}
-
 
 
     procedure InitAsm;
@@ -723,7 +718,13 @@ uses cutils,rgobj;
 end.
 {
   $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)
 
   Revision 1.14  2003/08/17 16:53:19  jonas

+ 100 - 327
compiler/powerpc/cgcpu.pas

@@ -193,18 +193,10 @@ const
                reference_reset(ref);
                ref.base:=locpara.reference.index;
                ref.offset:=locpara.reference.offset;
-{$ifndef newra}
-               tmpreg := get_scratch_reg_int(list,size);
-{$else newra}
                tmpreg := rg.getregisterint(list,size);
-{$endif newra}
                a_load_ref_reg(list,size,size,r,tmpreg);
                a_load_reg_ref(list,size,size,tmpreg,ref);
-{$ifndef newra}
-               free_scratch_reg(list,tmpreg);
-{$else newra}
                rg.ungetregisterint(list,tmpreg);
-{$endif newra}
             end;
           LOC_FPUREGISTER,LOC_CFPUREGISTER:
             case size of
@@ -235,18 +227,10 @@ const
                 reference_reset(ref);
                 ref.base := locpara.reference.index;
                 ref.offset := locpara.reference.offset;
-{$ifndef newra}
-                tmpreg := get_scratch_reg_address(list);
-{$else newra}
                 tmpreg := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
                 a_loadaddr_ref_reg(list,r,tmpreg);
                 a_load_reg_ref(list,OS_ADDR,OS_ADDR,tmpreg,ref);
-{$ifndef newra}
-                free_scratch_reg(list,tmpreg);
-{$else newra}
                 rg.ungetregisterint(list,tmpreg);
-{$endif newra}
               end;
             else
               internalerror(2002080701);
@@ -282,22 +266,14 @@ const
             {Generate instruction to load the procedure address from
             the transition vector.}
             //TODO: Support cross-TOC calls.
-{$ifndef newra}
-            tmpreg := get_scratch_reg_int(list,OS_INT);
-{$else newra}
             tmpreg := rg.getregisterint(list,OS_INT);
-{$endif newra}
             reference_reset(tmpref);
             tmpref.offset := 0;
             //tmpref.symaddr := refs_full;
             tmpref.base:= reg;
             list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
             list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
-{$ifndef newra}
-            free_scratch_reg(list,tmpreg);
-{$else newra}
             rg.ungetregisterint(list,tmpreg);
-{$endif newra}
           end
         else
           list.concat(taicpu.op_reg(A_MTCTR,reg));
@@ -319,11 +295,7 @@ const
         tmpref : treference;
 
       begin
-{$ifndef newra}
-        tmpreg := get_scratch_reg_int(list,OS_ADDR);
-{$else newra}
         tmpreg := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
         a_load_ref_reg(list,OS_ADDR,OS_ADDR,ref,tmpreg);
         if target_info.system=system_powerpc_macos then
           begin
@@ -337,11 +309,7 @@ const
             list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
           end;
         list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
-{$ifndef newra}
-        free_scratch_reg(list,tmpreg);
-{$else newra}
         rg.ungetregisterint(list,tmpreg);
-{$endif newra}
         list.concat(taicpu.op_none(A_BCTRL));
         //if target_info.system=system_powerpc_macos then
         //  //NOP is not needed here.
@@ -395,14 +363,10 @@ const
          { 64 bit stuff should be handled separately }
          if tosize in [OS_64,OS_S64] then
            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);
          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;
 
 
@@ -433,14 +397,10 @@ const
             internalerror(2002090902);
           ref2 := ref;
           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);
           if freereg then
-{$ifndef newra}
-            free_scratch_reg(list,ref2.base);
-{$else newra}
             rg.ungetregisterint(list,ref2.base);
-{$endif newra}
           { sign extend shortint if necessary, since there is no }
           { load instruction that does that automatically (JM)   }
           if fromsize = OS_S8 then
@@ -453,11 +413,7 @@ const
        var
          instr: taicpu;
        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]) and
              (tosize <> fromsize) and
@@ -479,9 +435,7 @@ const
                else internalerror(2002090901);
              end;
              list.concat(instr);
-{$ifdef newra}
              rg.add_move_instruction(instr);
-{$endif newra}
            end;
        end;
 
@@ -518,14 +472,10 @@ const
           end;
          ref2 := ref;
          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);
          if freereg then
-{$ifndef newra}
-           cg.free_scratch_reg(list,ref2.base);
-{$else newra}
            rg.ungetregisterint(list,ref2.base);
-{$endif newra}
        end;
 
 
@@ -546,14 +496,10 @@ const
            internalerror(200201122);
          ref2 := ref;
          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);
          if freereg then
-{$ifndef newra}
-           cg.free_scratch_reg(list,ref2.base);
-{$else newra}
            rg.ungetregisterint(list,ref2.base);
-{$endif newra}
        end;
 
 
@@ -709,21 +655,13 @@ const
           OP_OR:
             { try to use rlwimi }
             if gotrlwi and
-               (src.number = dst.number) then
+               (src = dst) then
               begin
-{$ifndef newra}
-                scratchreg := get_scratch_reg_int(list,OS_INT);
-{$else newra}
                 scratchreg := rg.getregisterint(list,OS_INT);
-{$endif newra}
                 list.concat(taicpu.op_reg_const(A_LI,scratchreg,-1));
                 list.concat(taicpu.op_reg_reg_const_const_const(A_RLWIMI,dst,
                   scratchreg,0,l1,l2));
-{$ifndef newra}
-                free_scratch_reg(list,scratchreg);
-{$else newra}
                 rg.ungetregisterint(list,scratchreg);
-{$endif newra}
               end
             else
               do_lo_hi;
@@ -753,18 +691,10 @@ const
         { perform the operation                                        }
         if useReg then
           begin
-{$ifndef newra}
-            scratchreg := get_scratch_reg_int(list,OS_INT);
-{$else newra}
             scratchreg := rg.getregisterint(list,OS_INT);
-{$endif newra}
             a_load_const_reg(list,OS_32,a,scratchreg);
             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);
-{$endif newra}
           end;
       end;
 
@@ -811,36 +741,20 @@ const
               list.concat(taicpu.op_reg_reg_const(A_CMPWI,r,reg,longint(a)))
             else
               begin
-{$ifndef newra}
-                scratch_register := get_scratch_reg_int(list,OS_INT);
-{$else newra}
                 scratch_register := rg.getregisterint(list,OS_INT);
-{$endif newra}
                 a_load_const_reg(list,OS_32,a,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);
-{$endif newra}
               end
           else
             if (a <= $ffff) then
               list.concat(taicpu.op_reg_reg_const(A_CMPLWI,r,reg,a))
             else
               begin
-{$ifndef newra}
-                scratch_register := get_scratch_reg_int(list,OS_32);
-{$else newra}
                 scratch_register := rg.getregisterint(list,OS_INT);
-{$endif newra}
                 a_load_const_reg(list,OS_32,a,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);
-{$endif newra}
               end;
           a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
         end;
@@ -1025,20 +939,11 @@ const
         { procedure, but currently this isn't checked, so save them always         }
         { following is the entry code as described in "Altivec Programming }
         { 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
-          begin
-             r.enum:=R_INTREGISTER;
-             r.number:=NR_R11;
-             a_reg_alloc(list,r);
-          end;
-
+          a_reg_alloc(list,NR_R11);
 
         usesfpr:=false;
         if not (po_assembler in current_procinfo.procdef.procoptions) then
@@ -1059,8 +964,7 @@ const
               if regcounter2 in rg.used_in_proc_int then
                 begin
                    usesgpr:=true;
-                   firstreggpr.enum := R_INTREGISTER;
-                   firstreggpr.number := regcounter2 shl 8;
+                   firstreggpr:=newreg(R_INTREGISTER,regcounter2,R_SUBNONE);
                    break;
                 end;
             end;
@@ -1070,9 +974,7 @@ const
           if (pi_do_call in current_procinfo.flags) then
             begin
                { 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 }
                case target_info.abi of
                  abi_powerpc_aix:
@@ -1081,7 +983,7 @@ const
                    reference_reset_base(href,rsp,LA_LR_SYSV);
                end;
                list.concat(taicpu.op_reg_ref(A_STW,r,href));
-               a_reg_dealloc(list,r);
+               a_reg_dealloc(list,NR_R0);
             end;
 
         { save the CR if necessary in callers frame. }
@@ -1089,55 +991,46 @@ const
           if target_info.abi = abi_powerpc_aix then
             if false then { Not needed at the moment. }
               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);
                 list.concat(taicpu.op_reg_ref(A_STW,r,href));
-                a_reg_dealloc(list,r);
+                a_reg_dealloc(list,NR_R0);
               end;
 
         { !!! always allocate space for all registers for now !!! }
         if not (po_assembler in current_procinfo.procdef.procoptions) then
 {        if usesfpr or usesgpr then }
           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 }
-             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;
 
 
         if (localsize <> 0) then
           begin
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_STACK_POINTER_REG;
             if (localsize <= high(smallint)) then
               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
             else
               begin
-                reference_reset_base(href,r,0);
+                reference_reset_base(href,NR_STACK_POINTER_REG,0);
                 { can't use getregisterint here, the register colouring }
                 { 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_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);
               end;
           end;
 
         { no GOT pointer loaded yet }
         gotgot:=false;
-        r.enum := R_INTREGISTER;
-        r.NUMBER := NR_R12;
+        r := NR_R12;
         if usesfpr then
           begin
              { save floating-point registers
@@ -1179,8 +1072,7 @@ const
                 if regcounter2 in rg.used_in_proc_int then
                   begin
                      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);
                      dec(href.offset,4);
                   end;
@@ -1198,8 +1090,7 @@ const
             if not (po_assembler in current_procinfo.procdef.procoptions) then
               begin
                 { copy memory parameters to local parast }
-                r.enum:=R_INTREGISTER;
-                r.number:=NR_R12;
+                r:=NR_R12;
                 hp:=tparaitem(current_procinfo.procdef.para.first);
                 while assigned(hp) do
                   begin
@@ -1212,7 +1103,7 @@ const
 {$ifdef newra2}
                     else if (hp.calleeparaloc.loc in [LOC_REGISTER,LOC_CREGISTER]) then
                       begin
-                        rg.getexplicitregisterint(list,hp.calleeparaloc.register.number);
+                        rg.getexplicitregisterint(list,hp.calleeparaloc.register);
                       end
 {$endif newra}
                       ;
@@ -1221,10 +1112,8 @@ const
               end;
           end;
 
-        r.enum:=R_INTREGISTER;
-        r.number:=NR_R12;
         if usesfpr or usesgpr then
-          a_reg_dealloc(list,r);
+          a_reg_dealloc(list,NR_R12);
 
         { PIC code support, }
         if cs_create_pic in aktmoduleswitches then
@@ -1234,12 +1123,9 @@ const
                begin
                   {!!!!!!!!!!!!!}
                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 }
-             list.concat(taicpu.op_reg_reg(A_MFSPR,r,r2));
+             list.concat(taicpu.op_reg_reg(A_MFSPR,NR_R31,NR_LR));
           end;
         { save the CR if necessary ( !!! always done currently ) }
         { 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 current_procinfo.procdef.parast.symtablelevel>2 then
           begin
-             r.enum:=R_INTREGISTER;
-             r.number:=NR_R11;
              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;
@@ -1293,8 +1177,7 @@ const
               if regcounter2 in rg.used_in_proc_int then
                 begin
                   usesgpr:=true;
-                  firstreggpr.enum:=R_INTREGISTER;
-                  firstreggpr.number:=regcounter2 shl 8;
+                  firstreggpr:=newreg(R_INTREGISTER,regcounter2,R_SUBNONE);
                   break;
                 end;
             end;
@@ -1306,14 +1189,10 @@ const
         if usesgpr or usesfpr then
           begin
              { 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
                begin
-                 reference_reset_base(href,r2,-8);
+                 reference_reset_base(href,NR_R12,-8);
                  for regcounter.enum := firstregfpu.enum to R_F31 do
                    if (regcounter.enum in rg.used_in_proc_other) then
                      begin
@@ -1323,15 +1202,14 @@ const
                  inc(href.offset,4);
                end
              else
-               reference_reset_base(href,r2,-4);
+               reference_reset_base(href,NR_R12,-4);
 
             for regcounter2:=firstsaveintreg to RS_R31 do
               begin
                 if regcounter2 in rg.used_in_proc_int then
                   begin
                      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);
                      dec(href.offset,4);
                   end;
@@ -1369,41 +1247,30 @@ const
         if genret then
           begin
              { 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? }
              if not (po_assembler in current_procinfo.procdef.procoptions) then
                begin
                  if (pi_do_call in current_procinfo.flags) then
                    begin
-                      r.enum:=R_INTREGISTER;
-                      r.number:=NR_STACK_POINTER_REG;
                       case target_info.abi of
                         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:
-                          reference_reset_base(href,r,LA_LR_SYSV);
+                          reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_SYSV);
                       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;
 
                  { restore the CR if necessary from callers frame}
                  if target_info.abi = abi_powerpc_aix then
                    if false then { Not needed at the moment. }
                      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;
 
@@ -1441,8 +1308,7 @@ const
             if regcounter2 in rg.used_in_proc_int then
               begin
                  usesgpr:=true;
-                 firstreggpr.enum:=R_INTREGISTER;
-                 firstreggpr.number:=regcounter2 shl 8;
+                 firstreggpr:=newreg(R_INTREGISTER,regcounter2,R_SUBNONE);
                  break;
               end;
           end;
@@ -1465,22 +1331,18 @@ const
         if firstreggpr.enum < R_30 then
           begin
             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));
               {STMW stores multiple registers}
           end
         else
           begin
-            r.enum:=R_INTREGISTER;
-            r.number:=NR_STACK_POINTER_REG;
             r2 := firstreggpr;
             convert_register_to_enum(firstreggpr);
             for regcounter.enum := firstreggpr.enum to R_31 do
               begin
                 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));
                 inc(r2.number,NR_R1-NR_R0);
               end;
@@ -1796,11 +1658,7 @@ const
                        ref2.base,tmpref));
                      if freereg then
                        begin
-{$ifndef newra}
-                         cg.free_scratch_reg(list,ref2.base);
-{$else newra}
                          rg.ungetregisterint(list,ref2.base);
-{$endif newra}
                          freereg := false;
                        end;
                    end
@@ -1826,11 +1684,7 @@ const
                  (r.number <> ref2.base.number) then
            list.concat(taicpu.op_reg_reg(A_MR,r,ref2.base));
          if freereg then
-{$ifndef newra}
-           cg.free_scratch_reg(list,ref2.base);
-{$else newra}
            rg.ungetregisterint(list,ref2.base);
-{$endif newra}
        end;
 
 { ************* concatcopy ************ }
@@ -1898,24 +1752,16 @@ const
         { load the address of source into src.base }
         if loadref then
           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);
             orgsrc := false;
           end
         else if (count > 4) or
                 not issimpleref(source) or
-                ((source.index.number <> NR_NO) and
+                ((source.index <> NR_NO) and
                  ((source.offset + longint(len)) > high(smallint))) then
           begin
-{$ifndef newra}
-            src.base := get_scratch_reg_address(list);
-{$else newra}
             src.base := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
             a_loadaddr_ref_reg(list,source,src.base);
             orgsrc := false;
           end
@@ -1929,14 +1775,10 @@ const
         { load the address of dest into dst.base }
         if (count > 4) or
            not issimpleref(dest) or
-           ((dest.index.number <> NR_NO) and
+           ((dest.index <> NR_NO) and
             ((dest.offset + longint(len)) > high(smallint))) then
           begin
-{$ifndef newra}
-            dst.base := get_scratch_reg_address(list);
-{$else newra}
             dst.base := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
             a_loadaddr_ref_reg(list,dest,dst.base);
             orgdst := false;
           end
@@ -1958,11 +1800,7 @@ const
             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,dst.base,dst.base,8));
-{$ifndef newra}
-            countreg := get_scratch_reg_int(list,OS_INT);
-{$else newra}
             countreg := rg.getregisterint(list,OS_INT);
-{$endif newra}
             a_load_const_reg(list,OS_32,count,countreg);
             { explicitely allocate R_0 since it can be used safely here }
             { (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_STFDU,r,dst));
             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);
             len := len mod 8;
           end;
@@ -2003,14 +1837,12 @@ const
 
         if (len and 4) <> 0 then
           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(dst.offset,4);
-            a_reg_dealloc(list,r);
+            a_reg_dealloc(list,NR_R0);
           end;
 {$else not ppc603}
         if count > 4 then
@@ -2024,29 +1856,19 @@ const
             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,dst.base,dst.base,4));
-{$ifndef newra}
-            countreg := get_scratch_reg_int(list,OS_INT);
-{$else newra}
             countreg := rg.getregisterint(list,OS_INT);
-{$endif newra}
             a_load_const_reg(list,OS_32,count,countreg);
             { explicitely allocate R_0 since it can be used safely here }
             { (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);
             a_label(list, lab);
             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);
-{$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;
           end;
 
@@ -2054,13 +1876,11 @@ const
         if count > 0 then
           { unrolled loop }
           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
               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(dst.offset,4);
               end;
@@ -2071,23 +1891,19 @@ const
        { copy the leftovers }
        if (len and 2) <> 0 then
          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(dst.offset,2);
-           a_reg_dealloc(list,r);
+           a_reg_dealloc(list,NR_R0);
          end;
        if (len and 1) <> 0 then
          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;
        if orgsrc then
          begin
@@ -2095,17 +1911,9 @@ const
              reference_release(list,source);
          end
        else
-{$ifndef newra}
-         free_scratch_reg(list,src.base);
-{$else newra}
          rg.ungetregisterint(list,src.base);
-{$endif newra}
        if not orgdst then
-{$ifndef newra}
-         free_scratch_reg(list,dst.base);
-{$else newra}
          rg.ungetregisterint(list,dst.base);
-{$endif newra}
        if delsource then
          tg.ungetiftemp(list,source);
       end;
@@ -2120,7 +1928,7 @@ const
       begin
          {$warning !!!! FIX ME !!!!}
          internalerror(200305231);
-{!!!!
+(* !!!!
         lenref:=ref;
         inc(lenref.offset,4);
         { get stack space }
@@ -2230,7 +2038,7 @@ const
 
         { patch the new address }
         a_load_reg_ref(list,OS_INT,rsp,ref);
-!!!!}
+!!!! *)
       end;
 
     procedure tcgppc.g_overflowcheck(list: taasmoutput; const l: tlocation; def: tdef);
@@ -2263,15 +2071,15 @@ const
     function tcgppc.issimpleref(const ref: treference): boolean;
 
       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);
         result :=
           not(assigned(ref.symbol)) and
-          (((ref.index.number = NR_NO) and
+          (((ref.index = NR_NO) and
             (ref.offset >= low(smallint)) and
             (ref.offset <= high(smallint))) or
-           ((ref.index.number <> NR_NO) and
+           ((ref.index <> NR_NO) and
             (ref.offset = 0)));
       end;
 
@@ -2280,34 +2088,29 @@ const
 
        var
          tmpreg: tregister;
-{$ifdef newra}
          orgindex: tregister;
          freeindex: boolean;
-{$endif newra}
        begin
          result := false;
-         if (ref.base.number = NR_NO) then
+         if (ref.base = NR_NO) then
            begin
              ref.base := ref.index;
-             ref.base.number := NR_NO;
+             ref.base := NR_NO;
            end;
-         if (ref.base.number <> NR_NO) then
+         if (ref.base <> NR_NO) then
            begin
-             if (ref.index.number <> NR_NO) and
+             if (ref.index <> NR_NO) and
                 ((ref.offset <> 0) or assigned(ref.symbol)) then
                begin
                  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  }
                  { a register here, we must first reallocate the index register, since }
                  { otherwise it may be overwritten (and it's still used afterwards)    }
                  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
-                     rg.getexplicitregisterint(list,ref.index.number);
+                     rg.getexplicitregisterint(list,ref.index);
                      orgindex := ref.index;
                      freeindex := true;
                    end;
@@ -2325,19 +2128,15 @@ const
                    begin
                      list.concat(taicpu.op_reg_reg_reg(
                        A_ADD,tmpreg,ref.base,ref.index));
-                     ref.index.number := NR_NO;
+                     ref.index := NR_NO;
                    end;
                  ref.base := tmpreg;
-{$ifdef newra}
                  if freeindex then
-                   begin
-                     rg.ungetregisterint(list,orgindex);
-                   end;
-{$endif newra}
+                   rg.ungetregisterint(list,orgindex);
                end
            end
          else
-           if ref.index.number <> NR_NO then
+           if ref.index <> NR_NO then
              internalerror(200208102);
        end;
 
@@ -2420,26 +2219,21 @@ const
         largeOffset: Boolean;
 
       begin
-        tmpreg.number := NR_NO;
+        tmpreg := NR_NO;
 
         if target_info.system = system_powerpc_macos then
           begin
             largeOffset:= (cardinal(ref.offset-low(smallint)) >
                   high(smallint)-low(smallint));
 
-{$ifndef newra}
-            tmpreg := get_scratch_reg_address(list);
-{$else newra}
             tmpreg := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
             tmpregUsed:= false;
 
             if assigned(ref.symbol) then
               begin //Load symbol's value
                 reference_reset(tmpref);
                 tmpref.symbol := ref.symbol;
-                tmpref.base.enum:= R_INTREGISTER;
-                tmpref.base.number:= NR_RTOC;
+                tmpref.base := NR_RTOC;
                 if macos_direct_globals then
                   list.concat(taicpu.op_reg_ref(A_LA,tmpreg,tmpref))
                 else
@@ -2462,7 +2256,7 @@ const
             if tmpregUsed then
               begin
                 //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,
                     ref.base,tmpreg));
 
@@ -2483,16 +2277,12 @@ const
                (cardinal(ref.offset-low(smallint)) >
                 high(smallint)-low(smallint)) then
               begin
-{$ifndef newra}
-                tmpreg := get_scratch_reg_address(list);
-{$else newra}
                 tmpreg := rg.getregisterint(list,OS_ADDR);
-{$endif newra}
                 reference_reset(tmpref);
                 tmpref.symbol := ref.symbol;
                 tmpref.offset := ref.offset;
                 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,
                     ref.base,tmpref))
                 else
@@ -2505,13 +2295,8 @@ const
               list.concat(taicpu.op_reg_ref(op,reg,ref));
           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);
-{$endif newra}
       end;
 
 
@@ -2606,40 +2391,22 @@ const
                     end
                   else if ((value shr 32) = 0) then
                     begin
-{$ifndef newra}
-                      tmpreg := cg.get_scratch_reg_int(list,OS_32);
-{$else newra}
                       tmpreg := rg.getregisterint(list,OS_32);
-{$endif newra}
                       cg.a_load_const_reg(list,OS_32,cardinal(value),tmpreg);
                       list.concat(taicpu.op_reg_reg_reg(ops[issub,2],
                         regdst.reglo,regsrc.reglo,tmpreg));
-{$ifndef newra}
-                      cg.free_scratch_reg(list,tmpreg);
-{$else newra}
                       rg.ungetregisterint(list,tmpreg);
-{$endif newra}
                       list.concat(taicpu.op_reg_reg(ops[issub,3],
                         regdst.reghi,regsrc.reghi));
                     end
                   else
                     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.reghi := rg.getregisterint(list,OS_32);
-{$endif newra}
                       a_load64_const_reg(list,value,tmpreg64);
                       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.reghi);
-{$endif newra}
                     end
                 end
               else
@@ -2661,7 +2428,13 @@ begin
 end.
 {
   $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)
 
   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,
        systems,cpuinfo,
        { aasm }
-       cpubase,aasmbase,aasmtai,aasmcpu,
+       cginfo,cpubase,aasmbase,aasmtai,aasmcpu,
        { symtable }
        symconst,symbase,symtype,symdef,symsym,symtable,defutil,defcmp,
        paramgr,
@@ -186,10 +186,7 @@ implementation
       begin
          consume(_CASE);
          caseexpr:=comp_expr(true);
-       { determines result type }
-       {$ifndef newra}
-         rg.cleartempgen;
-       {$endif}
+         { determines result type }
          do_resulttypepass(caseexpr);
          casedeferror:=false;
          casedef:=caseexpr.resulttype.def;
@@ -776,9 +773,7 @@ implementation
       var
         asmstat : tasmnode;
         Marker  : tai;
-        reg     : tsuperregister;
-        found   : boolean;
-        hs      : string;
+        reg     : tregister;
       begin
          Inside_asm_statement:=true;
          case aktasmmode of
@@ -824,16 +819,13 @@ implementation
               begin
                 repeat
                   { 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
-                      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);
                   consume(_CSTRING);
                   if not try_to_consume(_COMMA) then
@@ -1072,8 +1064,7 @@ implementation
         i : longint;
       begin
         { 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 }
         dec(current_procinfo.procdef.parast.address_fixup,pointer_size);
         { replace all references to parameters in the instructions,
@@ -1096,8 +1087,7 @@ implementation
                        ref_parafixup :
                          begin
                            ref^.offsetfixup:=parafixup;
-                           ref^.base.enum:=R_INTREGISTER;
-                           ref^.base.number:=NR_STACK_POINTER_REG;
+                           ref^.base:=NR_STACK_POINTER_REG;
                          end;
                      end;
                    end;
@@ -1191,7 +1181,19 @@ implementation
 end.
 {
   $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
 
   Revision 1.105  2003/06/17 16:34:44  jonas

+ 10 - 14
compiler/psub.pas

@@ -646,7 +646,6 @@ implementation
         else
           aktproccode.concatlist(templist);
 
-{$ifdef newra}
         { note: this must be done only after as much code as possible has  }
         {   been generated. The result is that when you ungetregister() a  }
         {   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        }
         {   regvars again) (JM)                                            }
         free_regvars(aktproccode);
-{$endif newra}
 
         { add code that will load the return value, this is not done
           for assembler routines when they didn't reference the result
@@ -678,14 +676,11 @@ implementation
 
         { The procedure body is finished, we can now
           allocate the registers }
-{$ifdef newra}
 {$ifdef ra_debug2}
         rg.writegraph;
-{$endif}
 {$endif}
         if not(cs_no_regalloc in aktglobalswitches) then
           begin
-{$ifdef newra}
             {Do register allocation.}
             repeat
               rg.prepare_colouring;
@@ -693,19 +688,17 @@ implementation
               rg.epilogue_colouring;
             until (rg.spillednodes='') or not rg.spill_registers(aktproccode,rg.spillednodes);
             aktproccode.translate_registers(rg.colour);
-{$else newra}
+(*
 {$ifndef NoOpt}
             if (cs_optimize in aktglobalswitches) and
             { do not optimize pure assembler procedures }
                not(pi_is_assembler in current_procinfo.flags)  then
               optimize(aktproccode);
 {$endif NoOpt}
-{$endif newra}
+*)
           end;
 
-{$ifdef newra}
         translate_regvars(aktproccode,rg.colour);
-{$endif newra}
         { Add stack allocation code after header }
         gen_stackalloc_code(templist);
         aktproccode.insertlistafter(headertai,templist);
@@ -715,11 +708,7 @@ implementation
 
         { now all the registers used are known }
         { Remove all imaginary registers from the used list.}
-{$ifdef newra}
         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;
 
         { save local data (casetable) also in the same file }
@@ -1312,13 +1301,20 @@ begin
 end.
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around
     + 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
     * fixed stackalloc to not allocate localst.datasize twice
     * 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
                           begin
                             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
                         else
                           begin
@@ -463,17 +459,10 @@ implementation
                             j:=0;
                             for l:=0 to ((p.resulttype.def.size-1) div 4) do
                               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+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]));
-                        {$endif}
                                 Inc(j,4);
                               end;
                           end;
@@ -1004,7 +993,10 @@ implementation
 end.
 {
   $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
     * removed hdisposen,hnewn,selfn
 

+ 7 - 6
compiler/rautils.pas

@@ -1002,11 +1002,6 @@ Begin
   end;
   opr.typ := OPR_REFERENCE;
   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;
 
 
@@ -1560,7 +1555,13 @@ end;
 end.
 {
   $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
 
   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_reg(asml: TAAsmoutput; reg: tregister);
     procedure load_all_regvars(asml: TAAsmoutput);
-{$ifdef newra}
    procedure free_regvars(list: taasmoutput);
    procedure translate_regvars(list: taasmoutput; const table:Ttranstable);
-{$endif newra}
 
 {$ifdef i386}
     procedure sync_regvars_other(list1, list2: taasmoutput; const regvarsloaded1,
       regvarsloaded2: regvarother_booleanarray);
     procedure sync_regvars_int(list1, list2: taasmoutput; const regvarsloaded1,
-      regvarsloaded2: Tsupregset);
+      regvarsloaded2: Tsuperregisterset);
 {$endif i386}
 
 implementation
@@ -151,7 +149,6 @@ implementation
       regvarinfo: pregvarinfo;
       i: longint;
       parasym : boolean;
-      r : Tregister;
       siz : tcgsize;
     begin
       { max. optimizations     }
@@ -174,69 +171,27 @@ implementation
               symtablestack.foreach_static({$ifdef FPCPROCVAR}@{$endif}searchregvars,@parasym);
               { copy parameter into a register ? }
               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 }
-              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
                   regvarinfo^.regvars[i]:=nil;
                   regvarinfo^.regvars_para[i] := false;
                 end;
               { 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
                   if assigned(regvarinfo^.regvars[i]) and
-{$ifdef newra}
                     { currently we assume we can use volatile registers for all }
                     { regvars if procedure does no call                         }
                      (not(pi_do_call in current_procinfo.flags) or
                     { otherwise, demand some (arbitrary) minimum usage }
                       (regvarinfo^.regvars[i].refs > 100)) then
-{$else newra}
-                     (rg.reg_pushes_int[varregs[i]] < regvarinfo^.regvars[i].refs) then
-{$endif newra}
                     begin
                       { register is no longer available for }
                       { expressions                          }
                       { search the register which is the most }
                       { unused                                }
-{$ifndef newra}
-                      rg.makeregvarint(varregs[i]);
-{$endif newra}
 
                       { call by reference/const ? }
                       if (regvarinfo^.regvars[i].varspez in [vs_var,vs_out]) or
@@ -254,19 +209,10 @@ implementation
                       else
                         siz:=OS_32;
 
-{$ifdef newra}
                       { allocate a register for this regvar }
                       regvarinfo^.regvars[i].reg:=rg.getregisterint(exprasmlist,siz);
                       { 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
                   else
                     begin
@@ -318,10 +264,9 @@ implementation
                      begin
 {$ifdef i386}
                        { 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}
-                       regvarinfo^.fpuregvars[i].reg.enum:=fpuvarregs[i];
+                       regvarinfo^.fpuregvars[i].reg:=fpuvarregs[i];
                        rg.makeregvarother(regvarinfo^.fpuregvars[i].reg);
 {$endif i386}
                      end;
@@ -340,18 +285,21 @@ implementation
       hr: treference;
       regvarinfo: pregvarinfo;
       vsym: tvarsym;
+      regidx : tregisterindex;
+      supreg : tsuperregister;
     begin
 {$ifdef i386}
       regvarinfo := pregvarinfo(current_procinfo.procdef.regvarinfo);
       if not assigned(regvarinfo) then
         exit;
-      if reg.enum=R_INTREGISTER then
+      if getregtype(reg)=R_INTREGISTER then
         begin
+          supreg:=getsupreg(reg);
           for i := 1 to maxvarregs do
             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
-                if (reg.number shr 8) in rg.regvar_loaded_int then
+                if supreg in rg.regvar_loaded_int then
                   begin
                     vsym := tvarsym(regvarinfo^.regvars[i]);
                     { 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);
                       end;
                     asml.concat(tai_regalloc.dealloc(vsym.reg));
-                    exclude(rg.regvar_loaded_int,reg.number shr 8);
+                    exclude(rg.regvar_loaded_int,supreg);
                   end;
                 break;
               end;
@@ -374,9 +322,10 @@ implementation
             if assigned(regvarinfo^.regvars[i]) then
               begin
                 r:=rg.makeregsize(regvarinfo^.regvars[i].reg,OS_INT);
-                if (r.enum = reg.enum) then
+                if (r = reg) then
                   begin
-                    if rg.regvar_loaded_other[r.enum] then
+                    regidx:=findreg_by_number(r);
+                    if rg.regvar_loaded_other[regidx] then
                       begin
                         vsym := tvarsym(regvarinfo^.regvars[i]);
                         { 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);
                           end;
                         asml.concat(tai_regalloc.dealloc(vsym.reg));
-                        rg.regvar_loaded_other[r.enum] := false;
+                        rg.regvar_loaded_other[regidx] := false;
                       end;
                     break;
                   end;
@@ -403,14 +352,15 @@ implementation
       opsize: tcgsize;
       r,
       reg : tregister;
+      regidx : tregisterindex;
     begin
 {$ifndef i386}
       exit;
 {$endif i386}
       reg:=vsym.reg;
-      if reg.enum=R_INTREGISTER then
+      if getregtype(reg)=R_INTREGISTER then
         begin
-          if not((reg.number shr 8) in rg.regvar_loaded_int) then
+          if not(getsupreg(reg) in rg.regvar_loaded_int) then
             begin
               asml.concat(tai_regalloc.alloc(reg));
               reference_reset_base(hr,current_procinfo.framepointer,vsym.adjusted_address);
@@ -421,13 +371,14 @@ implementation
               else
                 opsize := def_cgsize(vsym.vartype.def);
               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
       else
         begin
           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
               asml.concat(tai_regalloc.alloc(reg));
               reference_reset_base(hr,current_procinfo.framepointer,vsym.adjusted_address);
@@ -438,7 +389,7 @@ implementation
               else
                 opsize := def_cgsize(vsym.vartype.def);
               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;
@@ -448,25 +399,25 @@ implementation
       i: longint;
       regvarinfo: pregvarinfo;
       reg_spare : tregister;
+      supreg : tsuperregister;
     begin
       regvarinfo := pregvarinfo(current_procinfo.procdef.regvarinfo);
       if not assigned(regvarinfo) then
         exit;
-      if reg.enum=R_INTREGISTER then
+      if getregtype(reg)=R_INTREGISTER then
         begin
+          supreg:=getsupreg(reg);
           for i := 1 to maxvarregs do
             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]))
         end
       else
         begin
           reg_spare := rg.makeregsize(reg,OS_INT);
-          if reg_spare.enum>lastreg then
-            internalerror(2003010801);
           for i := 1 to maxvarregs do
             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]))
         end;
     end;
@@ -489,7 +440,6 @@ implementation
     var
       i: longint;
       regvarinfo: pregvarinfo;
-      r:Tregister;
     begin
       if (cs_regvars in aktglobalswitches) and
          not(pi_uses_asm in current_procinfo.flags) and
@@ -499,30 +449,13 @@ implementation
           { can happen when inlining assembler procedures (JM) }
           if not assigned(regvarinfo) then
             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
             begin
               if assigned(regvarinfo^.fpuregvars[i]) then
                 begin
 {$ifdef i386}
-                  r.enum:=R_ST0;
                   { 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));
 {$endif i386}
                 end;
@@ -540,9 +473,9 @@ implementation
                     if cs_asm_source in aktglobalswitches then
                       asml.insert(tai_comment.Create(strpnew(regvarinfo^.fpuregvars[i].name+
                         ' 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
-                      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);
                  end;
             end;
@@ -555,14 +488,14 @@ implementation
     procedure sync_regvars_other(list1, list2: taasmoutput; const regvarsloaded1,
       regvarsloaded2: regvarother_booleanarray);
     var
-      counter: tregister;
+      counter: tregisterindex;
     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
-           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)
              else
                load_regvar_reg(list1,counter);
@@ -571,15 +504,14 @@ implementation
 
 
     procedure sync_regvars_int(list1, list2: taasmoutput; const regvarsloaded1,
-      regvarsloaded2: Tsupregset);
+      regvarsloaded2: Tsuperregisterset);
     var
       i : longint;
       r : tregister;
     begin
       for i:=1 to maxvarregs do
         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
              not(varregs[i] in regvarsloaded2) then
             load_regvar_reg(list2,r)
@@ -595,7 +527,8 @@ implementation
     procedure cleanup_regvars(asml: TAAsmoutput);
     var
       i: longint;
-      r,reg : tregister;
+      reg : tregister;
+      regidx : tregisterindex;
     begin
       { can happen when inlining assembler procedures (JM) }
       if not assigned(current_procinfo.procdef.regvarinfo) then
@@ -606,32 +539,24 @@ implementation
         with pregvarinfo(current_procinfo.procdef.regvarinfo)^ do
           begin
 {$ifdef i386}
-            r.enum:=R_ST0;
             for i:=1 to maxfpuvarregs do
               if assigned(fpuregvars[i]) then
                 { ... 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}
             for i := 1 to maxvarregs do
              begin
                if assigned(regvars[i]) then
                 begin
                   reg:=regvars[i].reg;
-                  if reg.enum=R_INTREGISTER then
+                  if getregtype(reg)=R_INTREGISTER then
                     begin
-{$ifndef newra}
-                      if (reg.number shr 8 in rg.regvar_loaded_int) then
-                       asml.concat(tai_regalloc.dealloc(reg));
-{$endif newra}
                     end
                   else
                     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));
                     end;
                 end;
@@ -640,7 +565,6 @@ implementation
     end;
 
 
-{$ifdef newra}
     procedure free_regvars(list: taasmoutput);
       var
         i: longint;
@@ -653,7 +577,7 @@ implementation
               (regvars[i] <> tvarsym(current_procinfo.procdef.funcretsym))} then
               begin
                 { 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);
               end;
       end;
@@ -671,26 +595,31 @@ implementation
             if assigned(regvars[i]) { and
               (regvars[i] <> tvarsym(current_procinfo.procdef.funcretsym))} then
               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;
-                convert_register_to_enum(r);
                 if cs_asm_source in aktglobalswitches then
                  list.insert(tai_comment.Create(strpnew(regvars[i].name+
                   ' 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);
               end;
       end;
-{$endif newra}
 
 end.
 
 {
   $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
 
   Revision 1.61  2003/08/17 16:59:20  jonas

文件差异内容过多而无法显示
+ 138 - 435
compiler/rgobj.pas


+ 59 - 268
compiler/sparc/aasmcpu.pas

@@ -29,7 +29,7 @@ interface
 uses
   cclasses,aasmtai,
   aasmbase,globals,verbose,
-  cpubase,cpuinfo;
+  cginfo,cpubase,cpuinfo;
 
     const
       { "mov reg,reg" source operand number }
@@ -63,12 +63,12 @@ uses
          { register allocation }
          function is_nop: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;
 
       tai_align = class(tai_align_abstract)
@@ -94,8 +94,6 @@ implementation
     constructor taicpu.op_reg(op : tasmop;_op1 : tregister);
       begin
          inherited create(op);
-         if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
-           internalerror(2003031207);
          ops:=1;
          loadreg(0,_op1);
       end;
@@ -120,10 +118,6 @@ implementation
     constructor taicpu.op_reg_reg(op : tasmop;_op1,_op2 : tregister);
       begin
          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;
          loadreg(0,_op1);
          loadreg(1,_op2);
@@ -132,8 +126,6 @@ implementation
     constructor taicpu.op_reg_const(op:tasmop; _op1: tregister; _op2: aword);
       begin
          inherited create(op);
-         if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
-           internalerror(2003031208);
          ops:=2;
          loadreg(0,_op1);
          loadconst(1,_op2);
@@ -142,8 +134,6 @@ implementation
      constructor taicpu.op_const_reg(op:tasmop; _op1: aword; _op2: tregister);
       begin
          inherited create(op);
-         if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
-           internalerror(2003031209);
          ops:=2;
          loadconst(0,_op1);
          loadreg(1,_op2);
@@ -153,8 +143,6 @@ implementation
     constructor taicpu.op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
       begin
          inherited create(op);
-         if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
-           internalerror(2003031210);
          ops:=2;
          loadreg(0,_op1);
          loadref(1,_op2);
@@ -164,8 +152,6 @@ implementation
     constructor taicpu.op_ref_reg(op : tasmop;const _op1 : treference;_op2 : tregister);
       begin
          inherited create(op);
-         if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
-           internalerror(2003031210);
          ops:=2;
          loadref(0,_op1);
          loadreg(1,_op2);
@@ -175,12 +161,6 @@ implementation
     constructor taicpu.op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
       begin
          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;
          loadreg(0,_op1);
          loadreg(1,_op2);
@@ -191,10 +171,6 @@ implementation
     constructor taicpu.op_reg_ref_reg(op:tasmop;_op1:TRegister;_op2:TReference;_op3:tregister);
       begin
          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 }
          if not(_op2.symaddr in [refs_lo,refs_hi]) then
            internalerror(200305311);
@@ -208,10 +184,6 @@ implementation
     constructor taicpu.op_reg_const_reg(op:tasmop;_op1:TRegister;_op2:aword;_op3:tregister);
       begin
          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;
          loadreg(0,_op1);
          loadconst(1,_op2);
@@ -258,242 +230,55 @@ implementation
       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
-        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;
 
+
     procedure InitAsm;
       begin
       end;
@@ -506,7 +291,13 @@ implementation
 end.
 {
   $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
 
   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_restore_all_registers(list:TAasmOutput;accused,acchiused:boolean);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_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;
         class function reg_cgsize(const reg:tregister):tcgsize;override;
       end;
@@ -115,13 +115,13 @@ implementation
 
     function TCgSparc.IsSimpleRef(const ref:treference):boolean;
       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);
         result :=not(assigned(ref.symbol))and
-                  (((ref.index.number = NR_NO) and
+                  (((ref.index = NR_NO) and
                    (ref.offset >= simm13lo) and
                     (ref.offset <= simm13hi)) or
-                  ((ref.index.number <> NR_NO) and
+                  ((ref.index <> NR_NO) and
                   (ref.offset = 0)));
       end;
 
@@ -131,24 +131,19 @@ implementation
         tmpreg : tregister;
         tmpref : treference;
       begin
-        tmpreg.enum:=R_INTREGISTER;
-        tmpreg.number:=NR_NO;
+        tmpreg:=NR_NO;
         { Be sure to have a base register }
-        if (ref.base.number=NR_NO) then
+        if (ref.base=NR_NO) then
           begin
             ref.base:=ref.index;
-            ref.index.number:=NR_NO;
+            ref.index:=NR_NO;
           end;
         { When need to use SETHI, do it first }
         if assigned(ref.symbol) or
            (ref.offset<simm13lo) or
            (ref.offset>simm13hi) then
           begin
-{$ifdef newra}
             tmpreg:=rg.getregisterint(list,OS_INT);
-{$else}
-            tmpreg:=get_scratch_reg_int(list,OS_INT);
-{$endif}
             reference_reset(tmpref);
             tmpref.symbol:=ref.symbol;
             tmpref.offset:=ref.offset;
@@ -162,39 +157,33 @@ implementation
             ref.offset:=0;
             ref.symbol:=nil;
             { Only an index register or offset is allowed }
-            if tmpreg.number<>NR_NO then
+            if tmpreg<>NR_NO then
               begin
-                if (ref.index.number<>NR_NO) then
+                if (ref.index<>NR_NO) then
                   begin
                     list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg,ref.index,tmpreg));
                     ref.index:=tmpreg;
                   end
                 else
                   begin
-                    if ref.base.number<>NR_NO then
+                    if ref.base<>NR_NO then
                       ref.index:=tmpreg
                     else
                       ref.base:=tmpreg;
                   end;
               end;
           end;
-        if (ref.base.number<>NR_NO) then
+        if (ref.base<>NR_NO) then
           begin
-            if (ref.index.number<>NR_NO) and
+            if (ref.index<>NR_NO) and
                ((ref.offset<>0) or assigned(ref.symbol)) then
               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
                     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;
@@ -202,14 +191,8 @@ implementation
           list.concat(taicpu.op_reg_ref(op,reg,ref))
         else
           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;
 
 
@@ -220,19 +203,11 @@ implementation
         if (longint(a)<simm13lo) or
            (longint(a)>simm13hi) then
           begin
-{$ifdef newra}
             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_reg_const_reg(A_OR,tmpreg,a and aword($3ff),tmpreg));
             list.concat(taicpu.op_reg_reg_reg(op,src,tmpreg,dst));
-{$ifdef newra}
             rg.ungetregisterint(list,tmpreg);
-{$else}
-            free_scratch_reg(list,tmpreg);
-{$endif}
           end
         else
           list.concat(taicpu.op_reg_const_reg(op,src,a,dst));
@@ -285,18 +260,10 @@ implementation
                 if locpara.reference.offset<92 then
                   InternalError(2002081104);
                 reference_reset_base(ref,locpara.reference.index,locpara.reference.offset);
-{$ifdef newra}
                 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_reg_ref(list,sz,sz,tmpreg,ref);
-{$ifdef newra}
                 rg.ungetregisterint(list,tmpreg);
-{$else}
-                free_scratch_reg(list,tmpreg);
-{$endif}
               end;
             else
               internalerror(2002081103);
@@ -317,18 +284,10 @@ implementation
               reference_reset(ref);
               ref.base := locpara.reference.index;
               ref.offset := locpara.reference.offset;
-{$ifdef newra}
               tmpreg:=rg.getaddressregister(list);
-{$else}
-              tmpreg := get_scratch_reg_address(list);
-{$endif}
               a_loadaddr_ref_reg(list,r,tmpreg);
               a_load_reg_ref(list,OS_ADDR,OS_ADDR,tmpreg,ref);
-{$ifdef newra}
               rg.ungetregisterint(list,tmpreg);
-{$else}
-              free_scratch_reg(list,tmpreg);
-{$endif}
             end;
           else
             internalerror(2002080701);
@@ -438,18 +397,14 @@ implementation
     {********************** load instructions ********************}
 
     procedure TCgSparc.a_load_const_reg(list : TAasmOutput;size : TCGSize;a : aword;reg : TRegister);
-      var
-        zeroreg : tregister;
       begin
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
         { 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) }
         { sethi allows to set the upper 22 bit, so we'll take full advantage of it }
         if (a and aword($1fff))=0 then
           list.concat(taicpu.op_const_reg(A_SETHI,a shr 10,reg))
         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
           begin
             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);
-      var
-        zeroreg : Tregister;
       begin
         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
           inherited a_load_const_ref(list,size,a,ref);
       end;
@@ -521,11 +470,7 @@ implementation
 
     procedure TCgSparc.a_load_reg_reg(list:TAasmOutput;fromsize,tosize:tcgsize;reg1,reg2:tregister);
       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]) and
@@ -541,7 +486,7 @@ implementation
                 a_op_const_reg_reg(list,OP_AND,tosize,$ffff,reg1,reg2);
               OS_32,OS_S32:
                 begin
-                  if reg1.number<>reg2.number then
+                  if reg1<>reg2 then
                     list.Concat(taicpu.op_reg_reg(A_MOV,reg1,reg2));
                 end;
               else
@@ -554,28 +499,19 @@ implementation
     procedure TCgSparc.a_loadaddr_ref_reg(list : TAasmOutput;const ref : TReference;r : tregister);
       var
          tmpref : treference;
-         zeroreg,
          hreg : tregister;
       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);
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
         { At least big offset (need SETHI), maybe base and maybe index }
         if assigned(ref.symbol) or
            (ref.offset<simm13lo) or
            (ref.offset>simm13hi) then
           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
             else
-              begin
-              {$ifdef newra}
-                hreg:=rg.getaddressregister(list);
-              {$else}
-                hreg:=get_scratch_reg_address(list);
-              {$endif}
-              end;
+              hreg:=rg.getaddressregister(list);
             reference_reset(tmpref);
             tmpref.symbol := ref.symbol;
             tmpref.offset := ref.offset;
@@ -584,9 +520,9 @@ implementation
             { Only the low part is left }
             tmpref.symaddr:=refs_lo;
             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
-                if ref.index.number<>NR_NO then
+                if ref.index<>NR_NO then
                   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.index,r));
@@ -596,60 +532,42 @@ implementation
               end
             else
               begin
-                if hreg.number<>r.number then
+                if hreg<>r then
                   list.Concat(taicpu.op_reg_reg(A_MOV,hreg,r));
               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
         else
         { At least small offset, maybe base and maybe index }
           if ref.offset<>0 then
             begin
-              if ref.base.number<>NR_NO then
+              if ref.base<>NR_NO then
                 begin
-                  if ref.index.number<>NR_NO then
+                  if ref.index<>NR_NO then
                     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
                       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_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
                   else
                     list.concat(taicpu.op_reg_const_reg(A_ADD,ref.base,aword(ref.offset),r));
                 end
               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
         else
         { 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))
         else
         { 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)
         else
           internalerror(200306172);
@@ -658,13 +576,13 @@ implementation
 
     procedure TCgSparc.a_loadfpu_reg_reg(list:TAasmOutput;size:tcgsize;reg1, reg2:tregister);
       begin
-        if reg1.enum<>reg2.enum then
+        if reg1<>reg2 then
           begin
             list.concat(taicpu.op_reg_reg(A_FMOVs,reg1,reg2));
             if size=OS_F64 then
               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));
               end;
           end;
@@ -710,15 +628,11 @@ implementation
 
 
     procedure TCgSparc.a_op_const_reg(list:TAasmOutput;Op:TOpCG;size:tcgsize;a:AWord;reg:TRegister);
-      var
-        zeroreg : tregister;
       begin
         if Op in [OP_NEG,OP_NOT] then
           internalerror(200306011);
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
         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
           handle_reg_const_reg(list,TOpCG2AsmOp[op],reg,a,reg);
       end;
@@ -774,26 +688,18 @@ implementation
   {*************** compare instructructions ****************}
 
     procedure TCgSparc.a_cmp_const_reg_label(list:TAasmOutput;size:tcgsize;cmp_op:topcmp;a:aword;reg:tregister;l:tasmlabel);
-      var
-        zeroreg : tregister;
       begin
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
         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
-          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);
       end;
 
 
     procedure TCgSparc.a_cmp_reg_reg_label(list:TAasmOutput;size:tcgsize;cmp_op:topcmp;reg1,reg2:tregister;l:tasmlabel);
-      var
-        zeroreg : tregister;
       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);
       end;
 
@@ -833,10 +739,8 @@ implementation
     procedure TCgSparc.g_flags2reg(list:TAasmOutput;Size:TCgSize;const f:tresflags;reg:TRegister);
       var
         ai : taicpu;
-        r : tregister;
       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}
 //        ai.SetCondition(flags_to_cond(f));
         list.Concat(ai);
@@ -871,20 +775,15 @@ implementation
 
     procedure tcgsparc.g_save_parent_framepointer_param(list:taasmoutput);
       var
-        hreg : tregister;
         href : treference;
       begin
         reference_reset_base(href,current_procinfo.framepointer,PARENT_FRAMEPOINTER_OFFSET);
         { 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;
 
 
     procedure TCgSparc.g_stackframe_entry(list:TAasmOutput;LocalSize:LongInt);
-      var
-        r : tregister;
       begin
         { Althogh the SPARC architecture require only word alignment, software
           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
           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}
-        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;
 
 
@@ -913,7 +810,7 @@ implementation
       end;
 
 
-    procedure TCgSparc.g_restore_standard_registers(list:taasmoutput;usedinproc:Tsupregset);
+    procedure TCgSparc.g_restore_standard_registers(list:taasmoutput;usedinproc:Tsuperregisterset);
       begin
         { The sparc port uses the sparc standard calling convetions so this function has no used }
       end;
@@ -945,7 +842,7 @@ implementation
       end;
 
 
-    procedure TCgSparc.g_save_standard_registers(list : taasmoutput; usedinproc:Tsupregset);
+    procedure TCgSparc.g_save_standard_registers(list : taasmoutput; usedinproc:Tsuperregisterset);
       begin
         { The sparc port uses the sparc standard calling convetions so this function has no used }
       end;
@@ -955,12 +852,12 @@ implementation
 
     procedure TCgSparc.g_concatcopy(list:taasmoutput;const source,dest:treference;len:aword;delsource,loadref:boolean);
       var
+        hreg,
         countreg: TRegister;
         src, dst: TReference;
         lab: tasmlabel;
         count, count2: aword;
         orgsrc, orgdst: boolean;
-        r:Tregister;
       begin
         if len > high(longint) then
           internalerror(2002072704);
@@ -977,13 +874,12 @@ implementation
                 end
               else
                 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
                     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;
               exit;
             end;
@@ -993,27 +889,19 @@ implementation
         { load the address of source into src.base }
         if loadref then
           begin
-{$ifdef newra}
             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);
             orgsrc := false;
           end
         else
          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))<simm13lo))
             ) then
            begin
-{$ifdef newra}
              src.base:=rg.getaddressregister(list);
-{$else}
-             src.base := get_scratch_reg_address(list);
-{$endif}
              a_loadaddr_ref_reg(list,source,src.base);
              orgsrc := false;
            end
@@ -1027,16 +915,12 @@ implementation
           { load the address of dest into dst.base }
         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)) < simm13lo))
            ) then
           begin
-{$ifdef newra}
             dst.base:=rg.getaddressregister(list);
-{$else}
-            dst.base := get_scratch_reg_address(list);
-{$endif}
             a_loadaddr_ref_reg(list,dest,dst.base);
             orgdst := false;
           end
@@ -1057,101 +941,61 @@ implementation
             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,dst.base,8,dst.base));
-{$ifdef newra}
             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);
             { explicitely allocate R_O0 since it can be used safely here }
             { (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);
             a_label(list, lab);
             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);
-{$ifdef newra}
             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;
           end;
         { unrolled loop }
         count:=len and 7;
         if count>0 then
           begin
-            r.enum:=R_F0;
-            a_reg_alloc(list,r);
+            a_reg_alloc(list,NR_F0);
             for count2 := 1 to count do
               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(dst.offset,8);
               end;
-            a_reg_dealloc(list,r);
+            a_reg_dealloc(list,NR_F0);
             len := len mod 8;
           end;
         if (len and 4) <> 0 then
           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(dst.offset,4);
-{$ifdef newra}
-            rg.ungetregisterint(list,r);
-{$else}
-            a_reg_dealloc(list,r);
-{$endif}
+            rg.ungetregisterint(list,hreg);
           end;
         { copy the leftovers }
         if (len and 2) <> 0 then
           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(dst.offset,2);
-{$ifdef newra}
-            rg.ungetregisterint(list,r);
-{$else}
-            a_reg_dealloc(list,r);
-{$endif}
+            rg.ungetregisterint(list,hreg);
           end;
         if (len and 1) <> 0 then
           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;
         if orgsrc then
           begin
@@ -1159,17 +1003,9 @@ implementation
               reference_release(list,source);
           end
         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
-{$ifdef newra}
-            rg.ungetregisterint(list,dst.base);
-{$else}
-          free_scratch_reg(list,dst.base);
-{$endif}
+          rg.ungetregisterint(list,dst.base);
       end;
 
 {****************************************************************************
@@ -1217,16 +1053,13 @@ implementation
 
     procedure TCg64Sparc.a_op64_reg_reg(list:TAasmOutput;op:TOpCG;regsrc,regdst:TRegister64);
       var
-        zeroreg : tregister;
         op1,op2 : TAsmOp;
       begin
         case op of
           OP_NEG :
             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));
               exit;
             end;
@@ -1257,7 +1090,13 @@ begin
 end.
 {
   $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
 
   Revision 1.64  2003/07/06 22:10:13  peter

+ 210 - 572
compiler/sparc/cpubase.pas

@@ -56,467 +56,128 @@ uses
                                   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 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
-      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 }
-      VOLATILE_INTREGISTERS = [first_supreg..last_supreg];
+      VOLATILE_INTREGISTERS = [RS_G1];
 {$warning FIXME!!}
       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
@@ -739,21 +400,10 @@ type
       max_operands = 3;
 
       {# 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];
 
-      {# 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
          internally, when generating the code.
       }
@@ -768,14 +418,12 @@ type
 
       maxintregs = 8;
       { to determine how many registers to use for regvars }
-      maxintscratchregs = 3;      
-      intregs = [R_G0..R_I7];
+      maxintscratchregs = 3;
       usableregsint = [RS_L0..RS_L7];
       c_countusableregsint = 8;
 
       maxfpuregs = 8;
-      fpuregs=[R_F0..R_F31];
-      usableregsfpu=[R_F0..R_F31];
+      usableregsfpu=[RS_F0..RS_F31];
       c_countusableregsfpu=32;
 
       mmregs     = [];
@@ -791,18 +439,18 @@ type
 {$warning firstsaveintreg shall be RS_NO}
       firstsaveintreg = RS_L0; { Temporary, having RS_NO is broken }
       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;
-      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);
 
       maxfpuvarregs = 1;
-      fpuvarregs : Array [1..maxfpuvarregs] of TCpuRegister =
-                (R_F2);
+      fpuvarregs : Array [1..maxfpuvarregs] of TsuperRegister =
+                (RS_F2);
 
       {
       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);
       }
 
-      {# 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
@@ -837,63 +480,6 @@ type
       {# the size of a vector register for a processor     }
       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
 *****************************************************************************}
@@ -934,11 +520,12 @@ type
       NR_FUNCTION_RESULT64_HIGH_REG = NR_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 }
 
+
 {*****************************************************************************
                        GCC /ABI linking information
 *****************************************************************************}
@@ -977,11 +564,11 @@ type
 
     procedure inverse_flags(var f: TResFlags);
     function  flags_to_cond(const f: TResFlags) : TAsmCond;
-    procedure convert_register_to_enum(var r:Tregister);
     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
@@ -989,6 +576,20 @@ implementation
     uses
       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
 *****************************************************************************}
@@ -1019,58 +620,95 @@ implementation
       end;
 
 
-    procedure convert_register_to_enum(var r:Tregister);
+    function cgsize2subreg(s:Tcgsize):Tsubregister;
       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;
 
 
-    function cgsize2subreg(s:Tcgsize):Tsubregister;
+    function findreg_by_stdname(const s:string):byte;
+      var
+        i,p : tregisterindex;
       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;
 
 
-    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
-        s : string[4];
+        p : tregisterindex;
       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
-          begin
-            str(r,s);
-            supreg_name:='reg'+s;
-          end;
+          result:=generic_regname(r);
       end;
 
 
-    function gas_regname(const r:TNewRegister):string;
+    function gas_regname(r:Tregister):string;
       var
-        Reg:TRegister;
+        p : tregisterindex;
       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.
 {
   $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
 
   Revision 1.46  2003/08/17 16:59:20  jonas

+ 14 - 8
compiler/sparc/cpugas.pas

@@ -48,7 +48,7 @@ unit cpugas;
           begin
             inc(offset,offsetfixup);
             offsetfixup:=0;
-            if (base.number=NR_NO) and (index.number=NR_NO) then
+            if (base=NR_NO) and (index=NR_NO) then
               begin
                  if assigned(symbol) then
                    GetReferenceString:=symbol.name;
@@ -68,9 +68,9 @@ unit cpugas;
                 if assigned(symbol) then
                   internalerror(2003052601);
                 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
                     if (Offset<simm13lo) or (Offset>simm13hi) then
                       internalerror(2003053008);
@@ -83,7 +83,7 @@ unit cpugas;
                   begin
                     if Offset<>0 then
                       internalerror(2003052603);
-                    GetReferenceString:=GetReferenceString+'+'+std_reg2str[index.enum];
+                    GetReferenceString:=GetReferenceString+'+'+gas_regname(index);
                   end;
                 GetReferenceString:=GetReferenceString+']';
               end;
@@ -93,12 +93,12 @@ unit cpugas;
 
     function getopstr(const Oper:TOper):string;
       var
-        hs:string;
+        hs : string;
       begin
         with Oper do
           case typ of
             top_reg:
-              getopstr:=std_reg2str[reg.enum];
+              getopstr:=gas_regname(reg);
             top_ref:
               getopstr:=getreferencestring(ref^);
             top_const:
@@ -205,7 +205,13 @@ begin
 end.
 {
     $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
 
     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 }
   tprocessors=(no_processor,SPARC_V8,SPARC_V9);
 
+  tfputype =(fpu_soft,fpu_hard);
+
+
 const
 {# Size of native extended floating point type }
 {SPARC architecture uses IEEE double floating point numbers}
@@ -63,7 +66,10 @@ implementation
 end.
 {
   $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
 
   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
             begin
               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
            else
            { The other parameters are passed on the stack }
             begin
               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;
             end;
            size:=OS_INT;
@@ -113,7 +111,7 @@ implementation
     procedure tsparcparamanager.freeintparaloc(list: taasmoutput; nr : longint);
 
       var
-        r: tregister;
+        hreg : tregister;
 
       begin
         if nr<1 then
@@ -121,9 +119,8 @@ implementation
         Dec(nr);
         if nr<6 then
           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;
 
@@ -132,7 +129,7 @@ implementation
       begin
         if (loc.loc=LOC_REFERENCE) and
            (loc.low_in_reg) then
-          rg.getexplicitregisterint(list,loc.lowreg.number);
+          rg.getexplicitregisterint(list,loc.lowreg);
         inherited allocparaloc(list,loc);
       end;
 
@@ -178,12 +175,10 @@ implementation
                 { big endian }
                 if is_64bit then
                   begin
-                    paraloc.registerhigh.enum:=R_INTREGISTER;
-                    paraloc.registerhigh.number:=nextintreg shl 8;
+                    paraloc.registerhigh:=newreg(R_INTREGISTER,nextintreg,R_SUBWHOLE);
                     inc(nextintreg);
                   end;
-                paraloc.registerlow.enum:=R_INTREGISTER;
-                paraloc.registerlow.number:=NextIntReg shl 8;
+                paraloc.registerlow:=newreg(R_INTREGISTER,nextintreg,R_SUBWHOLE);
                 inc(NextIntReg);
               end
             else
@@ -193,12 +188,10 @@ implementation
                 if NextIntReg<=RS_O5 then
                   begin
                     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;
                 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;
                 if is_64bit and
                    (not paraloc.low_in_reg) then
@@ -215,14 +208,14 @@ implementation
                   begin
                     { big endian }
                     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
                 else
                   begin
                     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;
             hp:=TParaItem(hp.Next);
@@ -235,7 +228,7 @@ implementation
         if p.rettype.def.deftype=floatdef then
           begin
             paraloc.loc:=LOC_FPUREGISTER;
-            paraloc.register.enum:=FPU_RESULT_REG;
+            paraloc.register:=NR_FPU_RESULT_REG;
           end
         else
          { Return in register? }
@@ -245,25 +238,22 @@ implementation
 {$ifndef cpu64bit}
             if paraloc.size in [OS_64,OS_S64] then
              begin
-               paraloc.register64.reglo.enum:=R_INTREGISTER;
                if side=callerside then
-                 paraloc.register64.reglo.number:=NR_FUNCTION_RESULT64_LOW_REG
+                 paraloc.register64.reglo:=NR_FUNCTION_RESULT64_LOW_REG
                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
-                 paraloc.register64.reghi.number:=NR_FUNCTION_RESULT64_HIGH_REG
+                 paraloc.register64.reghi:=NR_FUNCTION_RESULT64_HIGH_REG
                else
-                 paraloc.register64.reghi.number:=NR_FUNCTION_RETURN64_HIGH_REG;
+                 paraloc.register64.reghi:=NR_FUNCTION_RETURN64_HIGH_REG;
              end
             else
 {$endif cpu64bit}
              begin
-               paraloc.register.enum:=R_INTREGISTER;
                if side=callerside then
-                 paraloc.register.number:=NR_FUNCTION_RESULT_REG
+                 paraloc.register:=NR_FUNCTION_RESULT_REG
                else
-                 paraloc.register.number:=NR_FUNCTION_RETURN_REG;
+                 paraloc.register:=NR_FUNCTION_RETURN_REG;
              end;
           end
         else
@@ -301,7 +291,13 @@ begin
 end.
 {
   $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
 
   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>
           %sp
         }
-        result:=Align(lasttemp+savearea,4);
+        result:=Align(tg.lasttemp+savearea,4);
       end;
 
 
@@ -86,7 +86,13 @@ begin
 end.
 {
   $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
     * 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;
-      var
-        zeroreg : tregister;
       begin
         pass_left_right;
         force_reg_left_right(true,true);
 
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
-
         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
-          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.resflags:=getresflags(true);
@@ -205,19 +200,14 @@ interface
 
 
     procedure tsparcaddnode.second_cmpsmallset;
-      var
-        zeroreg : tregister;
       begin
         pass_left_right;
         force_reg_left_right(true,true);
 
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
-
         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
-          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.resflags:=getresflags(true);
@@ -243,7 +233,6 @@ interface
 
     procedure tsparcaddnode.second_cmpordinal;
       var
-        zeroreg : tregister;
         unsigned : boolean;
       begin
         pass_left_right;
@@ -252,13 +241,10 @@ interface
         unsigned:=not(is_signed(left.resulttype.def)) or
                   not(is_signed(right.resulttype.def));
 
-        zeroreg.enum:=R_INTREGISTER;
-        zeroreg.number:=NR_G0;
-
         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
-          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.resflags:=getresflags(unsigned);
@@ -271,7 +257,13 @@ begin
 end.
 {
   $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
 
   Revision 1.17  2003/07/06 22:09:50  peter

+ 10 - 39
compiler/sparc/ncpumat.pas

@@ -74,17 +74,10 @@ implementation
          numerator,
          divider,
          resultreg  : tregister;
-         saved      : tmaybesave;
 
       begin
          secondpass(left);
-{$ifndef newra}
-         maybe_save(exprasmlist,right.registers32,left.location,saved);
-{$endif}
          secondpass(right);
-{$ifndef newra}
-         maybe_restore(exprasmlist,left.location,saved);
-{$endif}
          location_copy(location,left.location);
 
          { put numerator in register }
@@ -99,33 +92,19 @@ implementation
              resultreg := location.register;
            end;
          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
             (right.nodetype = ordconstn) and
             ispowerof2(tordconstnode(right).value,power) then
            begin
-{$ifdef newra}
              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);
              { if signed, tmpreg=right value-1, otherwise 0 }
              cg.a_op_const_reg(exprasmlist,OP_AND,OS_INT,tordconstnode(right).value-1,tmpreg);
              { add to the left value }
              cg.a_op_reg_reg(exprasmlist,OP_ADD,OS_INT,tmpreg,numerator);
-{$ifdef newra}
              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);
            end
          else
@@ -147,18 +126,14 @@ implementation
                  exprasmlist.concat(taicpu.op_reg_reg_reg(A_SMUL,resultreg,divider,resultreg));
                  rg.UnGetRegisterInt(exprasmlist,divider);
                  exprasmlist.concat(taicpu.op_reg_reg_reg(A_SUB,location.register,numerator,resultreg));
-  {$ifdef newra}
                  rg.ungetregisterint(exprasmlist,resultreg);
-  {$else}
-                 cg.free_scratch_reg(exprasmlist,resultreg);
-  {$endif}
                  resultreg := location.register;
                end
              else
                rg.UnGetRegisterInt(exprasmlist,divider);
            end;
         { free used registers }
-        if numerator.number <> resultreg.number then
+        if numerator<>resultreg then
           rg.ungetregisterint(exprasmlist,numerator);
         { set result location }
         location.loc:=LOC_REGISTER;
@@ -183,17 +158,10 @@ procedure tSparcshlshrnode.pass_2;
     op : topcg;
     asmop1, asmop2: tasmop;
     shiftval: aword;
-    saved : tmaybesave;
     r:Tregister;
   begin
     secondpass(left);
-{$ifndef newra}
-    maybe_save(exprasmlist,right.registers32,left.location,saved);
-{$endif}
     secondpass(right);
-{$ifndef newra}
-    maybe_restore(exprasmlist,left.location,saved);
-{$endif}
     if is_64bitint(left.resulttype.def)
     then
       begin
@@ -303,7 +271,6 @@ procedure tSparcshlshrnode.pass_2;
     procedure tsparcnotnode.second_boolean;
       var
         hl : tasmlabel;
-        zeroreg : tregister;
       begin
         { if the location is LOC_JUMP, we do the secondpass after the
           labels are allocated
@@ -332,9 +299,7 @@ procedure tSparcshlshrnode.pass_2;
               LOC_REGISTER, LOC_CREGISTER, LOC_REFERENCE, LOC_CREFERENCE :
                 begin
                   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_reset(location,LOC_FLAGS,OS_NO);
                   location.resflags:=F_E;
@@ -353,13 +318,19 @@ begin
 end.
 {
   $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
     + arm support in the common compiler sources added
     * moved some generic cg code around
     + 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
     * shr and div fixed
 

+ 12 - 7
compiler/sparc/radirect.pas

@@ -46,7 +46,7 @@ interface
        scanner,
        rautils,
        { codegen }
-       cgbase,
+       cginfo,cgbase,
        { constants }
        aggas,cpubase,globtype
        ;
@@ -88,9 +88,8 @@ interface
           is_fpu(current_procinfo.procdef.rettype.def) then
          tvarsym(current_procinfo.procdef.funcretsym).varstate:=vs_assigned;
        framereg:=current_procinfo.framepointer;
-       convert_register_to_enum(framereg);
        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
          retstr:='';
 
@@ -172,7 +171,7 @@ interface
                                             hs:=tvarsym(sym).mangledname
                                           else
                                             hs:='-'+tostr(tvarsym(sym).address)+
-                                                '('+std_reg2str[current_procinfo.framepointer.enum]+')';
+                                                '('+std_regname(current_procinfo.framepointer)+')';
                                           end
                                         else
                                         { call to local function }
@@ -195,7 +194,7 @@ interface
                                                   l:=tvarsym(sym).address;
                                                   { set offset }
                                                   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
                                                     tvarsym(sym).varstate:=vs_used;
                                                end;
@@ -283,7 +282,7 @@ interface
                                                 varsym :
                                                   begin
                                                     hs:=tostr(tvarsym(sym).adjusted_address)+
-                                                        '('+std_reg2str[framereg.enum]+')';
+                                                        '('+std_regname(framereg)+')';
                                                     inc(tvarsym(sym).refs);
                                                   end;
                                                 typedconstsym :
@@ -340,7 +339,13 @@ initialization
 end.
 {
   $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!
 
   Revision 1.12  2003/06/13 21:19:32  peter

+ 8 - 1
compiler/sparc/rasm.pas

@@ -58,13 +58,20 @@ Implementation
 
     function assemble : tnode;
      begin
+       result:=nil;
      end;
 
 Begin
 end.
 {
   $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 ***
 
   Revision 1.2  2002/08/11 06:14:41  florian

+ 23 - 58
compiler/sparc/rgcpu.pas

@@ -36,13 +36,6 @@ interface
 
     type
       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;
         procedure UngetRegisterFpu(list:taasmoutput;reg:tregister;size:TCGsize);override;
         procedure ClearTempGen;override;
@@ -55,45 +48,9 @@ implementation
       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;
       var
-        i: Toldregister;
+        i: Tsuperregister;
         r: Tregister;
       begin
         for i:=firstsavefpureg to lastsavefpureg do
@@ -101,19 +58,19 @@ implementation
             if (i in unusedregsfpu) and
                (
                 (size=OS_F32) or
-                (not odd(ord(i)-ord(R_F0)))
+                (not odd(i-RS_F0))
                ) then
               begin
                  exclude(unusedregsfpu,i);
                  dec(countunusedregsfpu);
-                 r.enum:=i;
+                 r:=newreg(R_FPUREGISTER,i,R_SUBNONE);
                  list.concat(tai_regalloc.alloc(r));
                  result := r;
                  { double need 2 FPU registers }
                  if size=OS_F64 then
                    begin
-                     r.enum:=succ(i);
-                     exclude(unusedregsfpu,r.enum);
+                     r:=newreg(R_FPUREGISTER,i+1,R_SUBNONE);
+                     exclude(unusedregsfpu,i+1);
                      dec(countunusedregsfpu);
                      list.concat(tai_regalloc.alloc(r));
                    end;
@@ -127,21 +84,22 @@ implementation
     procedure trgcpu.UngetRegisterFpu(list:taasmoutput;reg:tregister;size:TCGsize);
       var
         r : tregister;
+        supreg : tsuperregister;
       begin
+        supreg:=getsupreg(reg);
         { double need 2 FPU registers }
         if (size=OS_F64) then
           begin
             { Only even FP registers are allowed }
-            if (odd(ord(reg.enum)-ord(R_F0))) then
+            if odd(supreg-RS_F0) then
               internalerror(200306101);
-            r:=reg;
-            r.enum:=succ(r.enum);
+            r:=newreg(R_FPUREGISTER,supreg+1,R_SUBNONE);
             inc(countunusedregsfpu);
-            include(unusedregsfpu,r.enum);
+            include(unusedregsfpu,getsupreg(r));
             list.concat(tai_regalloc.dealloc(r));
           end;
         inc(countunusedregsfpu);
-        include(unusedregsfpu,reg.enum);
+        include(unusedregsfpu,supreg);
         list.concat(tai_regalloc.dealloc(reg));
       end;
 
@@ -149,17 +107,24 @@ implementation
     procedure trgcpu.cleartempgen;
       begin
         inherited cleartempgen;
-{$ifndef NEWRA}
-        usedpararegs:=[];
-{$endif NEWRA}
       end;
 
 begin
-  rg := trgcpu.create(24); {24 registers.}
+  { Only use %o and %l }
+  rg := trgcpu.create(16);
 end.
 {
   $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
 
   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

部分文件因为文件数量过多而无法显示