Преглед изворни кода

* Tregister changed into a record

daniel пре 22 година
родитељ
комит
55a161bbbf
75 измењених фајлова са 3032 додато и 1866 уклоњено
  1. 11 6
      compiler/aasmtai.pas
  2. 10 3
      compiler/aggas.pas
  3. 10 3
      compiler/cg64f32.pas
  4. 5 2
      compiler/cgbase.pas
  5. 64 34
      compiler/cgobj.pas
  6. 89 31
      compiler/i386/aasmcpu.pas
  7. 34 13
      compiler/i386/ag386att.pas
  8. 28 12
      compiler/i386/ag386int.pas
  9. 30 14
      compiler/i386/ag386nsm.pas
  10. 5 2
      compiler/i386/cga.pas
  11. 159 11
      compiler/i386/cpubase.pas
  12. 5 2
      compiler/i386/cpupara.pas
  13. 230 225
      compiler/i386/csopt386.pas
  14. 226 179
      compiler/i386/daopt386.pas
  15. 77 47
      compiler/i386/n386add.pas
  16. 87 58
      compiler/i386/n386cal.pas
  17. 26 14
      compiler/i386/n386cnv.pas
  18. 6 3
      compiler/i386/n386con.pas
  19. 11 4
      compiler/i386/n386inl.pas
  20. 99 72
      compiler/i386/n386mat.pas
  21. 9 6
      compiler/i386/n386mem.pas
  22. 30 13
      compiler/i386/n386obj.pas
  23. 8 5
      compiler/i386/n386opt.pas
  24. 14 7
      compiler/i386/n386set.pas
  25. 93 84
      compiler/i386/popt386.pas
  26. 27 16
      compiler/i386/ra386.pas
  27. 15 8
      compiler/i386/ra386att.pas
  28. 26 15
      compiler/i386/ra386int.pas
  29. 13 7
      compiler/i386/radirect.pas
  30. 54 36
      compiler/i386/rgcpu.pas
  31. 28 19
      compiler/i386/rropt386.pas
  32. 17 14
      compiler/m68k/agcpugas.pas
  33. 81 52
      compiler/m68k/cgcpu.pas
  34. 23 12
      compiler/m68k/cpubase.pas
  35. 5 2
      compiler/m68k/cpupara.pas
  36. 21 18
      compiler/m68k/rasm.pas
  37. 19 15
      compiler/m68k/rgcpu.pas
  38. 11 8
      compiler/ncgadd.pas
  39. 42 25
      compiler/ncgcal.pas
  40. 55 32
      compiler/ncgflw.pas
  41. 7 2
      compiler/ncginl.pas
  42. 17 13
      compiler/ncgld.pas
  43. 9 6
      compiler/ncgmem.pas
  44. 9 4
      compiler/ncgset.pas
  45. 97 43
      compiler/ncgutil.pas
  46. 14 11
      compiler/paramgr.pas
  47. 5 2
      compiler/pmodules.pas
  48. 11 8
      compiler/powerpc/agppcgas.pas
  49. 13 10
      compiler/powerpc/agppcmpw.pas
  50. 217 149
      compiler/powerpc/cgcpu.pas
  51. 26 15
      compiler/powerpc/cpubase.pas
  52. 26 23
      compiler/powerpc/cpupara.pas
  53. 25 18
      compiler/powerpc/nppcadd.pas
  54. 14 9
      compiler/powerpc/nppcmat.pas
  55. 8 2
      compiler/powerpc/nppcset.pas
  56. 8 5
      compiler/powerpc/radirect.pas
  57. 12 6
      compiler/powerpc/rgcpu.pas
  58. 5 2
      compiler/ppu.pas
  59. 11 8
      compiler/pstatmnt.pas
  60. 5 2
      compiler/psub.pas
  61. 5 2
      compiler/rautils.pas
  62. 47 26
      compiler/regvars.pas
  63. 101 80
      compiler/rgobj.pas
  64. 8 5
      compiler/sparc/aasmcpu.pas
  65. 88 53
      compiler/sparc/cgcpu.pas
  66. 20 9
      compiler/sparc/cpubase.pas
  67. 11 8
      compiler/sparc/cpugas.pas
  68. 24 21
      compiler/sparc/cpupara.pas
  69. 5 2
      compiler/sparc/ncpuadd.pas
  70. 8 3
      compiler/sparc/ncpumat.pas
  71. 9 6
      compiler/sparc/radirect.pas
  72. 13 6
      compiler/sparc/rgcpu.pas
  73. 14 7
      compiler/symsym.pas
  74. 14 5
      compiler/tgobj.pas
  75. 323 166
      compiler/x86/cgx86.pas

+ 11 - 6
compiler/aasmtai.pas

@@ -1417,7 +1417,7 @@ uses
     constructor tai_regalloc.ppuload(t:taitype;ppufile:tcompilerppufile);
       begin
         inherited ppuload(t,ppufile);
-        reg:=tregister(ppufile.getbyte);
+        ppufile.getdata(reg,sizeof(Tregister));
         allocation:=boolean(ppufile.getbyte);
       end;
 
@@ -1425,7 +1425,7 @@ uses
     procedure tai_regalloc.ppuwrite(ppufile:tcompilerppufile);
       begin
         inherited ppuwrite(ppufile);
-        ppufile.putbyte(byte(reg));
+        ppufile.putdata(reg,sizeof(Tregister));
         ppufile.putbyte(byte(allocation));
       end;
 
@@ -1507,9 +1507,11 @@ uses
             new(ref);
            ref^:=r;
 {$ifdef i386}
+           if ref^.segment.enum>lastreg then
+              internalerror(200301081);
            { We allow this exception for i386, since overloading this would be
              too much of a a speed penalty}
-           if not(ref^.segment in [R_DS,R_NO]) then
+           if not(ref^.segment.enum in [R_DS,R_NO]) then
             segprefix:=ref^.segment;
 {$endif}
            typ:=top_ref;
@@ -1589,7 +1591,7 @@ uses
           ppuloadoper(ppufile,oper[i-1]);
         opcode:=tasmop(ppufile.getword);
 {$ifdef i386}
-        segprefix:=tregister(ppufile.getbyte);
+        ppufile.getdata(segprefix,sizeof(Tregister));
 {$endif i386}
         is_jmp:=boolean(ppufile.getbyte);
       end;
@@ -1606,7 +1608,7 @@ uses
           ppuwriteoper(ppufile,oper[i-1]);
         ppufile.putword(word(opcode));
 {$ifdef i386}
-        ppufile.putbyte(byte(segprefix));
+        ppufile.putdata(segprefix,sizeof(Tregister));
 {$endif i386}
         ppufile.putbyte(byte(is_jmp));
       end;
@@ -1711,7 +1713,10 @@ uses
 end.
 {
   $Log$
-  Revision 1.15  2003-01-05 13:36:53  florian
+  Revision 1.16  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.15  2003/01/05 13:36:53  florian
     * x86-64 compiles
     + very basic support for float128 type (x86-64 only)
 

+ 10 - 3
compiler/aggas.pas

@@ -392,8 +392,12 @@ var
            ait_regalloc :
              begin
                if (cs_asm_regalloc in aktglobalswitches) then
-                 AsmWriteLn(target_asm.comment+'Register '+std_reg2str[tai_regalloc(hp).reg]+
-                   allocstr[tai_regalloc(hp).allocation]);
+                 begin
+                   if Tai_Regalloc(hp).reg.enum>lastreg then
+                     internalerror(200201081);
+                   AsmWriteLn(target_asm.comment+'Register '+std_reg2str[tai_regalloc(hp).reg.enum]+
+                     allocstr[tai_regalloc(hp).allocation]);
+                 end;
              end;
 
            ait_tempalloc :
@@ -814,7 +818,10 @@ var
 end.
 {
   $Log$
-  Revision 1.18  2002-12-07 14:03:25  carl
+  Revision 1.19  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.18  2002/12/07 14:03:25  carl
     - remove some duplicates and unused vars
 
   Revision 1.17  2002/12/06 17:50:39  peter

+ 10 - 3
compiler/cg64f32.pas

@@ -164,7 +164,11 @@ unit cg64f32;
           end;
         got_scratch:=false;
         tmpref := ref;
-        if (tmpref.base=reg.reglo) then
+        if tmpref.base.enum>lastreg then
+          internalerror(200301081);
+        if reg.reglo.enum>lastreg then
+          internalerror(200301081);
+        if (tmpref.base.enum=reg.reglo.enum) then
          begin
            tmpreg := cg.get_scratch_reg_int(list);
            got_scratch:=true;
@@ -175,7 +179,7 @@ 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=reg.reglo) then
+         if (tmpref.index.enum=reg.reglo.enum) then
           begin
             tmpreg:=cg.get_scratch_reg_int(list);
             got_scratch:=true;
@@ -748,7 +752,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.33  2003-01-05 13:36:53  florian
+  Revision 1.34  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.33  2003/01/05 13:36:53  florian
     * x86-64 compiles
     + very basic support for float128 type (x86-64 only)
 

+ 5 - 2
compiler/cgbase.pas

@@ -377,7 +377,7 @@ implementation
         firsttemp_offset:=0;
         para_offset:=0;
         flags:=0;
-        framepointer:=R_NO;
+        framepointer.enum:=R_NO;
         globalsymbol:=false;
         exported:=false;
         no_fast_exit:=false;
@@ -646,7 +646,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.35  2003-01-01 21:04:48  peter
+  Revision 1.36  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.35  2003/01/01 21:04:48  peter
     * removed unused method
 
   Revision 1.34  2002/11/25 17:43:16  peter

+ 64 - 34
compiler/cgobj.pas

@@ -549,10 +549,10 @@ unit cgobj;
                 (scratch_register_array_pointer+max_scratch_regs-1) do
            if scratch_regs[(i mod max_scratch_regs)+1] in unusedscratchregisters then
              begin
-                r:=scratch_regs[(i mod max_scratch_regs)+1];
+                r.enum:=scratch_regs[(i mod max_scratch_regs)+1];
                 break;
              end;
-         exclude(unusedscratchregisters,r);
+         exclude(unusedscratchregisters,r.enum);
          inc(scratch_register_array_pointer);
          if scratch_register_array_pointer>max_scratch_regs then
            scratch_register_array_pointer:=1;
@@ -570,7 +570,7 @@ unit cgobj;
     procedure tcg.free_scratch_reg(list : taasmoutput;r : tregister);
 
       begin
-         include(unusedscratchregisters,rg.makeregsize(r,OS_INT));
+         include(unusedscratchregisters,rg.makeregsize(r,OS_INT).enum);
          a_reg_dealloc(list,r);
       end;
 
@@ -582,6 +582,7 @@ unit cgobj;
 
       var
          ref : treference;
+         t : Tregister;
 
       begin
          case locpara.loc of
@@ -590,7 +591,10 @@ unit cgobj;
             LOC_REFERENCE,LOC_CREFERENCE:
               begin
                  if locpara.sp_fixup<>0 then
-                   a_op_const_reg(list,OP_ADD,locpara.sp_fixup,stack_pointer_reg);
+                   begin
+                      t.enum:=stack_pointer_reg;
+                      a_op_const_reg(list,OP_ADD,locpara.sp_fixup,t);
+                   end;
                  reference_reset(ref);
                  ref.base:=locpara.reference.index;
                  ref.offset:=locpara.reference.offset;
@@ -677,17 +681,21 @@ unit cgobj;
         { 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 := R_NO;
+        pushed_reg.enum := R_NO;
         if size in [OS_8,OS_S8] then
           if (rg.countunusedregsint = 0) then
             begin
-              if (dref.base <> R_EBX) and
-                 (dref.index <> R_EBX) then
-                pushed_reg := R_EBX
-              else if (dref.base <> R_EAX) and
-                      (dref.index <> R_EAX) then
-                pushed_reg := R_EAX
-              else pushed_reg := R_ECX;
+              if dref.base.enum>lastreg then
+                internalerror(200301081);
+              if dref.index.enum>lastreg then
+                internalerror(200301081);
+              if (dref.base.enum <> R_EBX) and
+                 (dref.index.enum <> R_EBX) then
+                pushed_reg.enum := R_EBX
+              else if (dref.base.enum <> R_EAX) and
+                      (dref.index.enum <> R_EAX) then
+                pushed_reg.enum := R_EAX
+              else pushed_reg.enum := R_ECX;
               tmpreg := rg.makeregsize(pushed_reg,OS_8);
               list.concat(taicpu.op_reg(A_PUSH,S_L,pushed_reg));
             end
@@ -702,7 +710,7 @@ unit cgobj;
 {$ifdef i386}
         if size in [OS_8,OS_S8] then
           begin
-            if (pushed_reg <> R_NO) then
+            if (pushed_reg.enum <> R_NO) then
               list.concat(taicpu.op_reg(A_POP,S_L,pushed_reg))
             else
               rg.ungetregister(list,tmpreg)
@@ -1374,28 +1382,30 @@ unit cgobj;
          hp : treference;
          p : tprocinfo;
          i : longint;
+         spr : Tregister;
       begin
+         spr.enum:=SELF_POINTER_REG;
          if assigned(procinfo._class) then
            begin
-              list.concat(tai_regalloc.Alloc(SELF_POINTER_REG));
+              list.concat(tai_regalloc.Alloc(spr));
               if lexlevel>normal_function_level then
                 begin
                    reference_reset_base(hp,procinfo.framepointer,procinfo.framepointer_offset);
-                   a_load_ref_reg(list,OS_ADDR,hp,SELF_POINTER_REG);
+                   a_load_ref_reg(list,OS_ADDR,hp,spr);
                    p:=procinfo.parent;
                    for i:=3 to lexlevel-1 do
                      begin
-                        reference_reset_base(hp,SELF_POINTER_REG,p.framepointer_offset);
-                        a_load_ref_reg(list,OS_ADDR,hp,SELF_POINTER_REG);
+                        reference_reset_base(hp,spr,p.framepointer_offset);
+                        a_load_ref_reg(list,OS_ADDR,hp,spr);
                         p:=p.parent;
                      end;
-                   reference_reset_base(hp,SELF_POINTER_REG,p.selfpointer_offset);
-                   a_load_ref_reg(list,OS_ADDR,hp,SELF_POINTER_REG);
+                   reference_reset_base(hp,spr,p.selfpointer_offset);
+                   a_load_ref_reg(list,OS_ADDR,hp,spr);
                 end
               else
                 begin
                    reference_reset_base(hp,procinfo.framepointer,procinfo.selfpointer_offset);
-                   a_load_ref_reg(list,OS_ADDR,hp,SELF_POINTER_REG);
+                   a_load_ref_reg(list,OS_ADDR,hp,spr);
                 end;
            end;
       end;
@@ -1405,12 +1415,14 @@ unit cgobj;
       var
         OKLabel : tasmlabel;
         dummyloc : tparalocation;
+        spr : Tregister;
       begin
         if (cs_check_object in aktlocalswitches) or
            (cs_check_range in aktlocalswitches) then
          begin
+           spr.enum:=SELF_POINTER_REG;
            objectlibrary.getlabel(oklabel);
-           a_cmp_const_reg_label(list,OS_ADDR,OC_NE,0,SELF_POINTER_REG,oklabel);
+           a_cmp_const_reg_label(list,OS_ADDR,OC_NE,0,spr,oklabel);
            a_param_const(list,OS_INT,210,dummyloc);
            a_call_name(list,'FPC_HANDLEERROR');
            a_label(list,oklabel);
@@ -1426,7 +1438,10 @@ unit cgobj;
      var
       href : treference;
       hregister : tregister;
+      spr,acc : Tregister;
      begin
+        acc.enum:=accumulator;
+        spr.enum:=SELF_POINTER_REG;
         if is_class(procinfo._class) then
           begin
             if (cs_implicit_exceptions in aktmoduleswitches) then
@@ -1435,16 +1450,16 @@ unit cgobj;
             {!! this is a terrible hack, normally the helper should get three params : }
             {    one with self register, one with flag and one with VMT pointer        }
             {reference_reset_base(href, procinfo.framepointer,procinfo.selfpointer_offset+POINTER_SIZE);}
-            a_param_reg(list, OS_ADDR, SELF_POINTER_REG, paramanager.getintparaloc(2));
+            a_param_reg(list, OS_ADDR, spr, paramanager.getintparaloc(2));
 
             { parameter 1 : vmt pointer (stored at the selfpointer address on stack)  }
             reference_reset_base(href, procinfo.framepointer,procinfo.selfpointer_offset);
             a_param_ref(list, OS_ADDR,href,paramanager.getintparaloc(1));
             a_call_name(list,'FPC_NEW_CLASS');
-            a_load_reg_reg(list,OS_ADDR,OS_ADDR,accumulator,SELF_POINTER_REG);
+            a_load_reg_reg(list,OS_ADDR,OS_ADDR,acc,spr);
             { save the self pointer result }
-            a_load_reg_ref(list,OS_ADDR,SELF_POINTER_REG,href);
-            a_cmp_const_reg_label(list,OS_ADDR,OC_EQ,0,accumulator,faillabel);
+            a_load_reg_ref(list,OS_ADDR,spr,href);
+            a_cmp_const_reg_label(list,OS_ADDR,OC_EQ,0,acc,faillabel);
           end
         else if is_object(procinfo._class) then
           begin
@@ -1464,8 +1479,8 @@ unit cgobj;
             a_param_reg(list, OS_ADDR,hregister,paramanager.getintparaloc(1));
             free_scratch_reg(list, hregister);
             a_call_name(list,'FPC_HELP_CONSTRUCTOR');
-            a_load_reg_reg(list,OS_ADDR,OS_ADDR,accumulator,SELF_POINTER_REG);
-            a_cmp_const_reg_label(list,OS_ADDR,OC_EQ,0,accumulator,faillabel);
+            a_load_reg_reg(list,OS_ADDR,OS_ADDR,acc,spr);
+            a_cmp_const_reg_label(list,OS_ADDR,OC_EQ,0,acc,faillabel);
           end
         else
           internalerror(200006161);
@@ -1477,7 +1492,9 @@ unit cgobj;
         nofinal : tasmlabel;
         href : treference;
       hregister : tregister;
+        spr : Tregister;
       begin
+        spr.enum:=SELF_POINTER_REG;
         if is_class(procinfo._class) then
          begin
            { 2nd parameter  : flag }
@@ -1496,7 +1513,7 @@ unit cgobj;
               objectlibrary.getlabel(nofinal);
               reference_reset_base(href,procinfo.framepointer,target_info.first_parm_offset);
               a_cmp_const_ref_label(list,OS_ADDR,OC_EQ,0,href,nofinal);
-              reference_reset_base(href,SELF_POINTER_REG,0);
+              reference_reset_base(href,spr,0);
               g_finalize(list,procinfo._class,href,false);
               a_label(list,nofinal);
             end;
@@ -1524,7 +1541,9 @@ unit cgobj;
       var
         href : treference;
         hregister : tregister;
+        spr : Tregister;
       begin
+        spr.enum:=SELF_POINTER_REG;
         if is_class(procinfo._class) then
           begin
             {
@@ -1538,9 +1557,9 @@ unit cgobj;
             a_param_ref(list, OS_ADDR,href,paramanager.getintparaloc(1));
             a_call_name(list,'FPC_DISPOSE_CLASS');
             { SET SELF TO NIL }
-            a_load_const_reg(list,OS_ADDR,0,SELF_POINTER_REG);
+            a_load_const_reg(list,OS_ADDR,0,spr);
             { set the self pointer in the stack to nil }
-            a_load_reg_ref(list,OS_ADDR,SELF_POINTER_REG,href);
+            a_load_reg_ref(list,OS_ADDR,spr,href);
           end
         else if is_object(procinfo._class) then
           begin
@@ -1561,7 +1580,7 @@ unit cgobj;
             free_scratch_reg(list, hregister);
             a_call_name(list,'FPC_HELP_FAIL');
             { SET SELF TO NIL }
-            a_load_const_reg(list,OS_ADDR,0,SELF_POINTER_REG);
+            a_load_const_reg(list,OS_ADDR,0,spr);
           end
         else
           internalerror(200006163);
@@ -1584,8 +1603,12 @@ unit cgobj;
 
 
     procedure tcg.g_exception_reason_save(list : taasmoutput; const href : treference);
+
+    var r:Tregister;
+
      begin
-       a_load_reg_ref(list, OS_S32, accumulator, href);
+       r.enum:=accumulator;
+       a_load_reg_ref(list, OS_S32, r, href);
      end;
 
 
@@ -1596,8 +1619,12 @@ unit cgobj;
 
 
     procedure tcg.g_exception_reason_load(list : taasmoutput; const href : treference);
+
+    var r:Tregister;
+
      begin
-       a_load_ref_reg(list, OS_S32, href, accumulator);
+       r.enum:=accumulator;
+       a_load_ref_reg(list, OS_S32, href, r);
      end;
 
 
@@ -1625,7 +1652,10 @@ finalization
 end.
 {
   $Log$
-  Revision 1.69  2002-12-24 15:56:50  peter
+  Revision 1.70  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.69  2002/12/24 15:56:50  peter
     * stackpointer_alloc added for adjusting ESP. Win32 needs
       this for the pageprotection
 

+ 89 - 31
compiler/i386/aasmcpu.pas

@@ -315,14 +315,14 @@ implementation
     constructor tai_align.create(b: byte);
       begin
         inherited create(b);
-        reg := R_ECX;
+        reg.enum := R_ECX;
       end;
 
 
     constructor tai_align.create_op(b: byte; _op: byte);
       begin
         inherited create_op(b,_op);
-        reg := R_NO;
+        reg.enum := R_NO;
       end;
 
 
@@ -372,7 +372,7 @@ implementation
       begin
          { default order is att }
          FOperandOrder:=op_att;
-         segprefix:=R_NO;
+         segprefix.enum:=R_NO;
          opsize:=_size;
 {$ifndef NOAG386BIN}
          insentry:=nil;
@@ -395,6 +395,8 @@ implementation
          inherited create(op);
          init(_size);
          ops:=1;
+         if _op1.enum>lastreg then
+           internalerror(200301081);
          loadreg(0,_op1);
       end;
 
@@ -422,6 +424,10 @@ implementation
          inherited create(op);
          init(_size);
          ops:=2;
+         if _op1.enum>lastreg then
+           internalerror(200301081);
+         if _op2.enum>lastreg then
+           internalerror(200301081);
          loadreg(0,_op1);
          loadreg(1,_op2);
       end;
@@ -432,6 +438,8 @@ implementation
          inherited create(op);
          init(_size);
          ops:=2;
+         if _op1.enum>lastreg then
+           internalerror(200301081);
          loadreg(0,_op1);
          loadconst(1,_op2);
       end;
@@ -442,6 +450,8 @@ implementation
          inherited create(op);
          init(_size);
          ops:=2;
+         if _op1.enum>lastreg then
+           internalerror(200301081);
          loadreg(0,_op1);
          loadref(1,_op2);
       end;
@@ -452,6 +462,8 @@ implementation
          inherited create(op);
          init(_size);
          ops:=2;
+         if _op2.enum>lastreg then
+           internalerror(200301081);
          loadconst(0,_op1);
          loadreg(1,_op2);
       end;
@@ -482,6 +494,8 @@ implementation
          inherited create(op);
          init(_size);
          ops:=2;
+         if _op2.enum>lastreg then
+           internalerror(200301081);
          loadref(0,_op1);
          loadreg(1,_op2);
       end;
@@ -492,6 +506,12 @@ implementation
          inherited create(op);
          init(_size);
          ops:=3;
+         if _op1.enum>lastreg then
+           internalerror(200301081);
+         if _op2.enum>lastreg then
+           internalerror(200301081);
+         if _op3.enum>lastreg then
+           internalerror(200301081);
          loadreg(0,_op1);
          loadreg(1,_op2);
          loadreg(2,_op3);
@@ -503,6 +523,10 @@ implementation
          inherited create(op);
          init(_size);
          ops:=3;
+         if _op2.enum>lastreg then
+           internalerror(200301081);
+         if _op3.enum>lastreg then
+           internalerror(200301081);
          loadconst(0,_op1);
          loadreg(1,_op2);
          loadreg(2,_op3);
@@ -514,6 +538,10 @@ implementation
          inherited create(op);
          init(_size);
          ops:=3;
+         if _op1.enum>lastreg then
+           internalerror(200301081);
+         if _op2.enum>lastreg then
+           internalerror(200301081);
          loadreg(0,_op1);
          loadreg(1,_op2);
          loadref(2,_op3);
@@ -527,6 +555,8 @@ implementation
          ops:=3;
          loadconst(0,_op1);
          loadref(1,_op2);
+         if _op3.enum>lastreg then
+           internalerror(200301081);
          loadreg(2,_op3);
       end;
 
@@ -537,6 +567,8 @@ implementation
          init(_size);
          ops:=3;
          loadconst(0,_op1);
+         if _op2.enum>lastreg then
+           internalerror(200301081);
          loadreg(1,_op2);
          loadref(2,_op3);
       end;
@@ -576,6 +608,8 @@ implementation
          init(_size);
          ops:=2;
          loadsymbol(0,_op1,_op1ofs);
+         if _op2.enum>lastreg then
+           internalerror(200301081);
          loadreg(1,_op2);
       end;
 
@@ -693,13 +727,13 @@ implementation
         o.ot:=ppufile.getlongint;
         case o.typ of
           top_reg :
-            o.reg:=tregister(ppufile.getbyte);
+              ppufile.getdata(o.reg,sizeof(Tregister));
           top_ref :
             begin
               new(o.ref);
-              o.ref^.segment:=tregister(ppufile.getbyte);
-              o.ref^.base:=tregister(ppufile.getbyte);
-              o.ref^.index:=tregister(ppufile.getbyte);
+              ppufile.getdata(o.ref^.segment,sizeof(Tregister));
+              ppufile.getdata(o.ref^.base,sizeof(Tregister));
+              ppufile.getdata(o.ref^.index,sizeof(Tregister));
               o.ref^.scalefactor:=ppufile.getbyte;
               o.ref^.offset:=ppufile.getlongint;
               o.ref^.symbol:=ppufile.getasmsymbol;
@@ -723,12 +757,12 @@ implementation
         ppufile.putlongint(o.ot);
         case o.typ of
           top_reg :
-            ppufile.putbyte(byte(o.reg));
+            ppufile.putdata(o.reg,sizeof(Tregister));
           top_ref :
             begin
-              ppufile.putbyte(byte(o.ref^.segment));
-              ppufile.putbyte(byte(o.ref^.base));
-              ppufile.putbyte(byte(o.ref^.index));
+              ppufile.putdata(o.ref^.segment,sizeof(Tregister));
+              ppufile.putdata(o.ref^.base,sizeof(Tregister));
+              ppufile.putdata(o.ref^.index,sizeof(Tregister));
               ppufile.putbyte(o.ref^.scalefactor);
               ppufile.putlongint(o.ref^.offset);
               ppufile.putasmsymbol(o.ref^.symbol);
@@ -765,12 +799,17 @@ implementation
         { we need ATT order }
         SetOperandOrder(op_att);
 
+        if (oper[0].typ=top_reg) and (oper[0].reg.enum>lastreg) then
+          internalerror(200301081);
+        if (oper[1].typ=top_reg) and (oper[1].reg.enum>lastreg) then
+          internalerror(200301081);
+
         if ((ops=2) and
            (oper[0].typ=top_reg) and
            (oper[1].typ=top_reg) and
            { if the first is ST and the second is also a register
              it is necessarily ST1 .. ST7 }
-           (oper[0].reg in [R_ST..R_ST0])) or
+           (oper[0].reg.enum in [R_ST..R_ST0])) or
            { ((ops=1) and
             (oper[0].typ=top_reg) and
             (oper[0].reg in [R_ST1..R_ST7]))  or}
@@ -793,7 +832,7 @@ implementation
               opcode:=A_FDIVRP;
          if  ((ops=1) and
             (oper[0].typ=top_reg) and
-            (oper[0].reg in [R_ST1..R_ST7])) then
+            (oper[0].reg.enum in [R_ST1..R_ST7])) then
             if opcode=A_FSUBRP then
               opcode:=A_FSUBP
             else if opcode=A_FSUBP then
@@ -835,18 +874,26 @@ implementation
           begin
             case typ of
               top_reg :
-                ot:=reg2type[reg];
+                begin
+                  if reg.enum>lastreg then
+                    internalerror(200301081);
+                  ot:=reg2type[reg.enum];
+                end;
               top_ref :
                 begin
+                  if ref^.base.enum>lastreg then
+                    internalerror(200301081);
+                  if ref^.index.enum>lastreg then
+                    internalerror(200301081);
                 { create ot field }
                   if (ot and OT_SIZE_MASK)=0 then
                     ot:=OT_MEMORY or opsize_2_type[i,opsize]
                   else
                     ot:=OT_MEMORY or (ot and OT_SIZE_MASK);
-                  if (ref^.base=R_NO) and (ref^.index=R_NO) then
+                  if (ref^.base.enum=R_NO) and (ref^.index.enum=R_NO) then
                     ot:=ot or OT_MEM_OFFS;
                 { fix scalefactor }
-                  if (ref^.index=R_NO) then
+                  if (ref^.index.enum=R_NO) then
                    ref^.scalefactor:=0
                   else
                    if (ref^.scalefactor=0) then
@@ -1074,7 +1121,9 @@ implementation
            if m=100 then
             begin
               InsSize:=calcsize(insentry);
-              if (segprefix<>R_NO) then
+              if segprefix.enum>lastreg then
+                internalerror(200301081);
+              if (segprefix.enum<>R_NO) then
                inc(InsSize);
               { For opsize if size if forced }
               if (insentry^.flags and (IF_SB or IF_SW or IF_SD))<>0 then
@@ -1161,9 +1210,11 @@ implementation
          exit;
         aktfilepos:=fileinfo;
         { Segment override }
-        if (segprefix<>R_NO) then
+        if segprefix.enum>lastreg then
+          internalerror(200201081);
+        if (segprefix.enum<>R_NO) then
          begin
-           case segprefix of
+           case segprefix.enum of
              R_CS : c:=$2e;
              R_DS : c:=$3e;
              R_ES : c:=$26;
@@ -1182,12 +1233,14 @@ implementation
 
     function taicpu.NeedAddrPrefix(opidx:byte):boolean;
       var
-        i,b : tregister;
+        i,b : Toldregister;
       begin
         if (OT_MEMORY and (not oper[opidx].ot))=0 then
          begin
-           i:=oper[opidx].ref^.index;
-           b:=oper[opidx].ref^.base;
+           i:=oper[opidx].ref^.index.enum;
+           b:=oper[opidx].ref^.base.enum;
+           if (i>lastreg) or (b>lastreg) then
+              internalerror(200201081);
            if not(i in [R_NO,R_EAX,R_EBX,R_ECX,R_EDX,R_EBP,R_ESP,R_ESI,R_EDI]) or
               not(b in [R_NO,R_EAX,R_EBX,R_ECX,R_EDX,R_EBP,R_ESP,R_ESI,R_EDI]) then
             begin
@@ -1201,7 +1254,7 @@ implementation
 
     function regval(r:tregister):byte;
       begin
-        case r of
+        case r.enum of
           R_EAX,R_AX,R_AL,R_ES,R_CR0,R_DR0,R_ST,R_ST0,R_MM0,R_XMM0 :
             regval:=0;
           R_ECX,R_CX,R_CL,R_CS,R_DR1,R_ST1,R_MM1,R_XMM1 :
@@ -1229,7 +1282,7 @@ implementation
 
     function process_ea(const input:toper;var output:ea;rfield:longint):boolean;
       const
-        regs : array[0..63] of tregister=(
+        regs : array[0..63] of Toldregister=(
           R_MM0, R_EAX, R_AX, R_AL, R_XMM0, R_NO, R_NO, R_NO,
           R_MM1, R_ECX, R_CX, R_CL, R_XMM1, R_NO, R_NO, R_NO,
           R_MM2, R_EDX, R_DX, R_DL, R_XMM2, R_NO, R_NO, R_NO,
@@ -1241,7 +1294,7 @@ implementation
         );
       var
         j     : longint;
-        i,b   : tregister;
+        i,b   : Toldregister;
         sym   : tasmsymbol;
         md,s  : byte;
         base,index,scalefactor,
@@ -1254,7 +1307,7 @@ implementation
            j:=0;
            while (j<=high(regs)) do
             begin
-              if input.reg=regs[j] then
+              if input.reg.enum=regs[j] then
                break;
               inc(j);
             end;
@@ -1269,8 +1322,10 @@ implementation
            exit;
          end;
       { memory reference }
-        i:=input.ref^.index;
-        b:=input.ref^.base;
+        i:=input.ref^.index.enum;
+        b:=input.ref^.base.enum;
+        if (i>lastreg) or (b>lastreg) then
+          internalerror(200301081);
         s:=input.ref^.scalefactor;
         o:=input.ref^.offset+input.ref^.offsetfixup;
         sym:=input.ref^.symbol;
@@ -1582,7 +1637,7 @@ implementation
               end;
             4,6 :
               begin
-                case oper[0].reg of
+                case oper[0].reg.enum of
                   R_CS :
                     begin
                       if c=4 then
@@ -1619,7 +1674,7 @@ implementation
               end;
             5,7 :
               begin
-                case oper[0].reg of
+                case oper[0].reg.enum of
                   R_FS :
                     begin
                       if c=5 then
@@ -1875,7 +1930,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.9  2003-01-05 13:36:53  florian
+  Revision 1.10  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.9  2003/01/05 13:36:53  florian
     * x86-64 compiles
     + very basic support for float128 type (x86-64 only)
 

+ 34 - 13
compiler/i386/ag386att.pas

@@ -90,8 +90,14 @@ interface
          { These are probably not correctly handled under GAS }
          { should be replaced by coding the segment override  }
          { directly! - DJGPP FAQ                              }
-           if segment<>R_NO then
-            AsmWrite(gas_reg2str[segment]+':');
+           if segment.enum>lastreg then
+             internalerror(200301081);
+           if base.enum>lastreg then
+             internalerror(200301081);
+           if index.enum>lastreg then
+             internalerror(200301081);
+           if segment.enum<>R_NO then
+            AsmWrite(gas_reg2str[segment.enum]+':');
            if assigned(symbol) then
              AsmWrite(symbol.name);
            if offset<0 then
@@ -104,23 +110,23 @@ interface
                else
                 AsmWrite(tostr(offset));
              end
-           else if (index=R_NO) and (base=R_NO) and not assigned(symbol) then
+           else if (index.enum=R_NO) and (base.enum=R_NO) and not assigned(symbol) then
              AsmWrite('0');
-           if (index<>R_NO) and (base=R_NO) then
+           if (index.enum<>R_NO) and (base.enum=R_NO) then
             begin
-              AsmWrite('(,'+gas_reg2str[index]);
+              AsmWrite('(,'+gas_reg2str[index.enum]);
               if scalefactor<>0 then
                AsmWrite(','+tostr(scalefactor)+')')
               else
                AsmWrite(')');
             end
            else
-            if (index=R_NO) and (base<>R_NO) then
-             AsmWrite('('+gas_reg2str[base]+')')
+            if (index.enum=R_NO) and (base.enum<>R_NO) then
+             AsmWrite('('+gas_reg2str[base.enum]+')')
             else
-             if (index<>R_NO) and (base<>R_NO) then
+             if (index.enum<>R_NO) and (base.enum<>R_NO) then
               begin
-                AsmWrite('('+gas_reg2str[base]+','+gas_reg2str[index]);
+                AsmWrite('('+gas_reg2str[base.enum]+','+gas_reg2str[index.enum]);
                 if scalefactor<>0 then
                  AsmWrite(','+tostr(scalefactor));
                 AsmWrite(')');
@@ -133,7 +139,11 @@ interface
       begin
         case o.typ of
           top_reg :
-            AsmWrite(gas_reg2str[o.reg]);
+            begin
+              if o.reg.enum>lastreg then
+                internalerror(200301081);
+              AsmWrite(gas_reg2str[o.reg.enum]);
+            end;
           top_ref :
             WriteReference(o.ref^);
           top_const :
@@ -162,7 +172,11 @@ interface
       begin
         case o.typ of
           top_reg :
-            AsmWrite('*'+gas_reg2str[o.reg]);
+            begin
+              if o.reg.enum>lastreg then
+                internalerror(200301081);
+              AsmWrite('*'+gas_reg2str[o.reg.enum]);
+            end;
           top_ref :
             begin
               AsmWrite('*');
@@ -200,13 +214,17 @@ interface
         AsmWrite(#9+gas_op2str[op]+cond2str[taicpu(hp).condition]);
         { suffix needed ?  fnstsw,fldcw don't support suffixes
           with binutils 2.9.5 under linux }
+        if (Taicpu(hp).oper[0].typ=top_reg) and
+            (Taicpu(hp).oper[0].reg.enum>lastreg) then
+          internalerror(200301081);
+          
         if (not calljmp) and
             (gas_needsuffix[op]<>AttSufNONE) and
             (op<>A_FNSTSW) and (op<>A_FSTSW) and
             (op<>A_FNSTCW) and (op<>A_FSTCW) and
             (op<>A_FLDCW) and not(
             (taicpu(hp).oper[0].typ=top_reg) and
-            (taicpu(hp).oper[0].reg in [R_ST..R_ST7])
+            (taicpu(hp).oper[0].reg.enum in [R_ST..R_ST7])
            ) then
           AsmWrite(gas_opsize2str[taicpu(hp).opsize]);
         { process operands }
@@ -303,7 +321,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.28  2003-01-05 13:36:53  florian
+  Revision 1.29  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.28  2003/01/05 13:36:53  florian
     * x86-64 compiles
     + very basic support for float128 type (x86-64 only)
 

+ 28 - 12
compiler/i386/ag386int.pas

@@ -158,11 +158,17 @@ 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 ref.segment<>R_NO then
-            AsmWrite(std_reg2str[segment]+':[')
+           if segment.enum<>R_NO then
+            AsmWrite(std_reg2str[segment.enum]+':[')
            else
             AsmWrite('[');
            if assigned(symbol) then
@@ -172,21 +178,21 @@ interface
               AsmWrite(symbol.name);
               first:=false;
             end;
-           if (base<>R_NO) then
+           if (base.enum<>R_NO) then
             begin
               if not(first) then
                AsmWrite('+')
               else
                first:=false;
-               AsmWrite(std_reg2str[base]);
+               AsmWrite(std_reg2str[base.enum]);
             end;
-           if (index<>R_NO) then
+           if (index.enum<>R_NO) then
             begin
               if not(first) then
                AsmWrite('+')
               else
                first:=false;
-              AsmWrite(std_reg2str[index]);
+              AsmWrite(std_reg2str[index.enum]);
               if scalefactor<>0 then
                AsmWrite('*'+tostr(scalefactor));
             end;
@@ -211,7 +217,11 @@ interface
       begin
         case o.typ of
           top_reg :
-            AsmWrite(std_reg2str[o.reg]);
+            begin
+              if o.reg.enum>lastreg then
+                internalerror(200301081);
+              AsmWrite(std_reg2str[o.reg.enum]);
+            end;
           top_const :
             AsmWrite(tostr(longint(o.val)));
           top_symbol :
@@ -270,7 +280,11 @@ interface
     begin
       case o.typ of
         top_reg :
-          AsmWrite(std_reg2str[o.reg]);
+          begin
+            if o.reg.enum>lastreg then
+              internalerror(200301081);
+            AsmWrite(std_reg2str[o.reg.enum]);
+          end;
         top_const :
           AsmWrite(tostr(longint(o.val)));
         top_symbol :
@@ -414,7 +428,7 @@ interface
            ait_regalloc :
              begin
                if (cs_asm_regalloc in aktglobalswitches) then
-                 AsmWriteLn(target_asm.comment+'Register '+std_reg2str[tai_regalloc(hp).reg]+
+                 AsmWriteLn(target_asm.comment+'Register '+std_reg2str[tai_regalloc(hp).reg.enum]+
                    allocstr[tai_regalloc(hp).allocation]);
              end;
 
@@ -605,8 +619,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>=firstsreg) and
-                            (taicpu(hp).oper[0].reg<=lastsreg)) then
+                           ((taicpu(hp).oper[0].reg.enum in [firstsreg..lastsreg])) then
                          AsmWriteln(#9#9'DB'#9'066h');
                        { added prefix instructions, must be on same line as opcode }
                        if (taicpu(hp).ops = 0) and
@@ -844,7 +857,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.31  2002-12-24 18:10:34  peter
+  Revision 1.32  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.31  2002/12/24 18:10:34  peter
     * Long symbol names support
 
   Revision 1.30  2002/11/17 16:31:58  carl

+ 30 - 14
compiler/i386/ag386nsm.pas

@@ -221,32 +221,38 @@ 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);
            AsmWrite('[');
            first:=true;
            inc(offset,offsetfixup);
            offsetfixup:=0;
-           if ref.segment<>R_NO then
-            AsmWrite(std_reg2str[segment]+':');
+           if segment.enum<>R_NO then
+            AsmWrite(std_reg2str[segment.enum]+':');
            if assigned(symbol) then
             begin
               AsmWrite(symbol.name);
               first:=false;
             end;
-           if (base<>R_NO) then
+           if (base.enum<>R_NO) then
             begin
               if not(first) then
                AsmWrite('+')
               else
                first:=false;
-              AsmWrite(int_nasmreg2str[base]);
+              AsmWrite(int_nasmreg2str[base.enum]);
             end;
-           if (index<>R_NO) then
+           if (index.enum<>R_NO) then
              begin
                if not(first) then
                  AsmWrite('+')
                else
                  first:=false;
-               AsmWrite(int_nasmreg2str[index]);
+               AsmWrite(int_nasmreg2str[index.enum]);
                if scalefactor<>0 then
                  AsmWrite('*'+tostr(scalefactor));
              end;
@@ -271,7 +277,11 @@ interface
       begin
         case o.typ of
           top_reg :
-            AsmWrite(int_nasmreg2str[o.reg]);
+            begin
+              if o.reg.enum>lastreg then
+                internalerror(200301081);
+              AsmWrite(int_nasmreg2str[o.reg.enum]);
+            end;
           top_const :
             begin
               if (ops=1) and (opcode<>A_RET) then
@@ -313,7 +323,11 @@ interface
       begin
         case o.typ of
           top_reg :
-            AsmWrite(int_nasmreg2str[o.reg]);
+            begin
+              if o.reg.enum>lastreg then
+                internalerror(200301081);
+              AsmWrite(int_nasmreg2str[o.reg.enum]);
+            end;
           top_ref :
             WriteReference(o.ref^);
           top_const :
@@ -433,7 +447,7 @@ interface
            ait_regalloc :
              begin
                if (cs_asm_regalloc in aktglobalswitches) then
-                 AsmWriteLn(target_asm.comment+'Register '+std_reg2str[tai_regalloc(hp).reg]+
+                 AsmWriteLn(target_asm.comment+'Register '+std_reg2str[tai_regalloc(hp).reg.enum]+
                    allocstr[tai_regalloc(hp).allocation]);
              end;
 
@@ -643,9 +657,9 @@ interface
                  begin
                    taicpu(hp).ops:=2;
                    taicpu(hp).oper[0].typ:=top_reg;
-                   taicpu(hp).oper[0].reg:=R_ST1;
+                   taicpu(hp).oper[0].reg.enum:=R_ST1;
                    taicpu(hp).oper[1].typ:=top_reg;
-                   taicpu(hp).oper[1].reg:=R_ST;
+                   taicpu(hp).oper[1].reg.enum:=R_ST;
                  end;
                if taicpu(hp).opcode=A_FWAIT then
                 AsmWriteln(#9#9'DB'#9'09bh')
@@ -658,8 +672,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>=firstsreg) and
-                       (taicpu(hp).oper[0].reg<=lastsreg)) then
+                      ((taicpu(hp).oper[0].reg.enum in [firstsreg..lastsreg])) 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
@@ -895,7 +908,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.29  2002-12-24 18:10:34  peter
+  Revision 1.30  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.29  2002/12/24 18:10:34  peter
     * Long symbol names support
 
   Revision 1.28  2002/11/17 16:31:59  carl

+ 5 - 2
compiler/i386/cga.pas

@@ -152,7 +152,7 @@ implementation
 
     procedure emit_reg_reg(i : tasmop;s : topsize;reg1,reg2 : tregister);
       begin
-         if (reg1<>reg2) or (i<>A_MOV) then
+         if (reg1.enum<>reg2.enum) or (i<>A_MOV) then
            exprasmList.concat(Taicpu.Op_reg_reg(i,s,reg1,reg2));
       end;
 
@@ -174,7 +174,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.33  2002-07-01 18:46:29  peter
+  Revision 1.34  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.33  2002/07/01 18:46:29  peter
     * internal linker
     * reorganized aasm layer
 

+ 159 - 11
compiler/i386/cpubase.pas

@@ -78,6 +78,131 @@ uses
                                   Registers
 *****************************************************************************}
 
+      {The new register coding:
+
+       For now we'll use this, when the old register coding is away, we
+       can change this into a cardinal or something so the amount of
+       possible registers increases.
+
+       High byte: Register number
+       Low byte:  Subregister
+
+       Example:
+
+       $0100      AL
+       $0101      AH
+       $0102      AX
+       $0103      EAX
+       $0104      RAX
+       $0201      BL
+       $0203      EBX
+
+       Register numbers:
+
+       $00        Special register
+       $01        EAX
+       $02        EBX
+       $03        ECX
+       $04        EDX
+       $05        ESI
+       $06        EDI
+       $07        EBP
+       $08        ESP
+       $09        R08
+       $0a        R09
+       $0b        R10
+       $0c        R11
+       $0d        R12
+       $0e        R13
+       $0f        R14
+       $10        R15}
+
+     {Special registers:}
+     const        NR_NO    = $0000;      {Invalid register}
+                  NR_CS    = $0001;      {CS}
+                  NR_DS    = $0002;      {DS}
+                  NR_ES    = $0003;      {ES}
+                  NR_SS    = $0004;      {SS}
+                  NR_FS    = $0005;      {FS}
+                  NR_GS    = $0006;      {GS}
+                  NR_RIP   = $000F;      {RIP}
+                  NR_DR0   = $0010;      {DR0}
+                  NR_DR1   = $0011;      {DR1}
+                  NR_DR2   = $0012;      {DR2}
+                  NR_DR3   = $0013;      {DR3}
+                  NR_DR6   = $0016;      {DR6}
+                  NR_DR7   = $0017;      {DR7}
+                  NR_CR0   = $0020;      {CR0}
+                  NR_CR1   = $0021;      {CR1}
+                  NR_CR2   = $0022;      {CR2}
+                  NR_CR3   = $0023;      {CR3}
+                  NR_TR3   = $0030;      {R_TR3}
+                  NR_TR4   = $0031;      {R_TR4}
+                  NR_TR5   = $0032;      {R_TR5}
+                  NR_TR6   = $0033;      {R_TR6}
+                  NR_TR7   = $0034;      {R_TR7}
+      {Normal registers.}
+      const       NR_AL    = $0100;      {AL}
+                  NR_AH    = $0101;      {AH}
+                  NR_AX    = $0102;      {AX}
+                  NR_EAX   = $0103;      {EAX}
+                  NR_RAX   = $0104;      {RAX}
+                  NR_BL    = $0200;      {BL}
+                  NR_BH    = $0201;      {BH}
+                  NR_BX    = $0202;      {BX}
+                  NR_EBX   = $0203;      {EBX}
+                  NR_RBX   = $0204;      {RBX}
+                  NR_CL    = $0300;      {CL}
+                  NR_CH    = $0301;      {CH}
+                  NR_CX    = $0302;      {CX}
+                  NR_ECX   = $0303;      {ECX}
+                  NR_RCX   = $0304;      {RCX}
+                  NR_DL    = $0400;      {DL}
+                  NR_DH    = $0401;      {DH}
+                  NR_DX    = $0402;      {DX}
+                  NR_EDX   = $0403;      {EDX}
+                  NR_RDX   = $0404;      {RDX}
+                  NR_SIL   = $0500;      {SIL}
+                  NR_SI    = $0502;      {SI}
+                  NR_ESI   = $0503;      {ESI}
+                  NR_RSI   = $0504;      {RSI}
+                  NR_DIL   = $0600;      {DIL}
+                  NR_DI    = $0602;      {DI}
+                  NR_EDI   = $0603;      {EDI}
+                  NR_RDI   = $0604;      {RDI}
+                  NR_BPL   = $0700;      {BPL}
+                  NR_BP    = $0702;      {BP}
+                  NR_EBP   = $0703;      {EBP}
+                  NR_RBP   = $0704;      {RBP}
+                  NR_SPL   = $0800;      {SPL}
+                  NR_SP    = $0802;      {SP}
+                  NR_ESP   = $0803;      {ESP}
+                  NR_RSP   = $0804;      {RSP}
+                  NR_R8L   = $0900;      {R8L}
+                  NR_R8W   = $0902;      {R8W}
+                  NR_R8D   = $0903;      {R8D}
+                  NR_R9L   = $0a00;      {R9D}
+                  NR_R9W   = $0a02;      {R9W}
+                  NR_R9D   = $0a03;      {R9D}
+                  NR_R10L  = $0b00;      {R10L}
+                  NR_R10W  = $0b02;      {R10W}
+                  NR_R10D  = $0b03;      {R10D}
+                  NR_R11L  = $0c00;      {R11L}
+                  NR_R11W  = $0c02;      {R11W}
+                  NR_R11D  = $0c03;      {R11D}
+                  NR_R12L  = $0d00;      {R12L}
+                  NR_R12W  = $0d02;      {R12W}
+                  NR_R12D  = $0d03;      {R12D}
+                  NR_R13L  = $0e00;      {R13L}
+                  NR_R13W  = $0e02;      {R13W}
+                  NR_R13D  = $0e03;      {R13D}
+                  NR_R14L  = $0f00;      {R14L}
+                  NR_R14W  = $0f02;      {R14W}
+                  NR_R14D  = $0f03;      {R14D}
+                  NR_R15L  = $1000;      {R15L}
+                  NR_R15W  = $1002;      {R15W}
+                  NR_R15D  = $1003;      {R15D}
+
     type
       {# Enumeration for all possible registers for cpu. It
         is to note that all registers of the same type
@@ -86,7 +211,8 @@ uses
       }
       { don't change the order }
       { it's used by the register size conversions        }
-      tregister = (R_NO,
+      {$packenum 1}
+      Toldregister = (R_NO,
         R_EAX,R_ECX,R_EDX,R_EBX,R_ESP,R_EBP,R_ESI,R_EDI,
         R_AX,R_CX,R_DX,R_BX,R_SP,R_BP,R_SI,R_DI,
         R_AL,R_CL,R_DL,R_BL,R_AH,R_CH,R_BH,R_DH,
@@ -96,8 +222,24 @@ uses
         R_CR0,R_CR2,R_CR3,R_CR4,
         R_TR3,R_TR4,R_TR5,R_TR6,R_TR7,
         R_MM0,R_MM1,R_MM2,R_MM3,R_MM4,R_MM5,R_MM6,R_MM7,
-        R_XMM0,R_XMM1,R_XMM2,R_XMM3,R_XMM4,R_XMM5,R_XMM6,R_XMM7
+        R_XMM0,R_XMM1,R_XMM2,R_XMM3,R_XMM4,R_XMM5,R_XMM6,R_XMM7,
+        R_INTREGISTER,R_FLOATREGISTER,R_MMXREGISTER,R_KNIREGISTER
       );
+      
+
+      {Constants for subregisters.}
+      const   RS_L8   = 0;    {Like AL}
+              RS_H8   = 1;    {Like AH}
+              RS_16   = 2;    {Like AX}
+              RS_32   = 3;    {Like EAX}
+              RS_64   = 4;    {Like RAX}
+
+      type  Tregister = packed record
+              enum:Toldregister;
+              number:word;        {This is a word for now, change to cardinal when
+                                   the old register coding is away.}
+            end;
+      {$packenum normal}
 
       { A type to store register locations for 64 Bit values. }
       tregister64 = packed record
@@ -108,16 +250,14 @@ uses
       treg64 = tregister64;
 
       {# Set type definition for registers }
-      tregisterset = set of tregister;
+      tregisterset = set of Toldregister;
 
-      {# Type definition for the array of string of register names }
-      reg2strtable = array[tregister] of string[6];
 
     const
       {# First register in the tregister enumeration }
-      firstreg = low(tregister);
+      firstreg = low(Toldregister);
       {# Last register in the tregister enumeration }
-      lastreg  = high(tregister);
+      lastreg  = R_XMM7;
 
       firstsreg = R_CS;
       lastsreg  = R_GS;
@@ -146,6 +286,11 @@ uses
       }
       std_op2str:op2strtable={$i i386int.inc}
 
+    type
+      {# Type definition for the array of string of register names }
+         reg2strtable = array[firstreg..lastreg] of string[6];
+
+    const
       {# Standard register table (for each tregister enumeration). The
          register strings should conform to the the names as defined
          by the processor manufacturer
@@ -377,7 +522,7 @@ uses
       lastsavemmreg   = R_MM7;
 
       maxvarregs = 4;
-      varregs : array[1..maxvarregs] of tregister =
+      varregs : array[1..maxvarregs] of Toldregister =
          (R_EBX,R_EDX,R_ECX,R_EAX);
 
       maxfpuvarregs = 8;
@@ -386,7 +531,7 @@ uses
          routine calls or in assembler blocks.
       }
       max_scratch_regs = 1;
-      scratch_regs : array[1..max_scratch_regs] of tregister = (R_EDI);
+      scratch_regs : array[1..max_scratch_regs] of Toldregister = (R_EDI);
 
 
 {*****************************************************************************
@@ -400,7 +545,7 @@ uses
           (FIXED_REGISTERS) from GCC 3.x source code
 
       }
-          stab_regindex : array[tregister] of shortint =
+          stab_regindex : array[firstreg..lastreg] of shortint =
           (-1,
           0,1,2,3,4,5,6,7,
           0,1,2,3,4,5,6,7,
@@ -533,7 +678,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.35  2003-01-05 13:36:53  florian
+  Revision 1.36  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.35  2003/01/05 13:36:53  florian
     * x86-64 compiles
     + very basic support for float128 type (x86-64 only)
 

+ 5 - 2
compiler/i386/cpupara.pas

@@ -121,7 +121,7 @@ unit cpupara;
     function ti386paramanager.getselflocation(p : tabstractprocdef) : tparalocation;
       begin
          getselflocation.loc:=LOC_REFERENCE;
-         getselflocation.reference.index:=R_ESP;
+         getselflocation.reference.index.enum:=R_ESP;
          getselflocation.reference.offset:=4;
       end;
 
@@ -130,7 +130,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.7  2002-12-24 15:56:50  peter
+  Revision 1.8  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.7  2002/12/24 15:56:50  peter
     * stackpointer_alloc added for adjusting ESP. Win32 needs
       this for the pageprotection
 

Разлика између датотеке није приказан због своје велике величине
+ 230 - 225
compiler/i386/csopt386.pas


Разлика између датотеке није приказан због своје велике величине
+ 226 - 179
compiler/i386/daopt386.pas


+ 77 - 47
compiler/i386/n386add.pas

@@ -194,6 +194,7 @@ interface
       var
         power : longint;
         hl4   : tasmlabel;
+        r:Tregister;
       begin
         { at this point, left.location.loc should be LOC_REGISTER }
         if right.location.loc=LOC_REGISTER then
@@ -223,11 +224,12 @@ interface
             begin
               if extra_not then
                 emit_reg(A_NOT,opsize,left.location.register);
+              r.enum:=R_EDI;
               rg.getexplicitregisterint(exprasmlist,R_EDI);
-              cg.a_load_loc_reg(exprasmlist,right.location,R_EDI);
-              emit_reg_reg(op,opsize,left.location.register,R_EDI);
-              emit_reg_reg(A_MOV,opsize,R_EDI,left.location.register);
-              rg.ungetregisterint(exprasmlist,R_EDI);
+              cg.a_load_loc_reg(exprasmlist,right.location,r);
+              emit_reg_reg(op,opsize,left.location.register,r);
+              emit_reg_reg(A_MOV,opsize,r,left.location.register);
+              rg.ungetregisterint(exprasmlist,r);
             end
            else
             begin
@@ -267,11 +269,12 @@ interface
                  begin
                    if extra_not then
                      begin
+                        r.enum:=R_EDI;
                         rg.getexplicitregisterint(exprasmlist,R_EDI);
-                        cg.a_load_loc_reg(exprasmlist,right.location,R_EDI);
-                        emit_reg(A_NOT,S_L,R_EDI);
-                        emit_reg_reg(A_AND,S_L,R_EDI,left.location.register);
-                        rg.ungetregisterint(exprasmlist,R_EDI);
+                        cg.a_load_loc_reg(exprasmlist,right.location,r);
+                        emit_reg(A_NOT,S_L,r);
+                        emit_reg_reg(A_AND,S_L,r,left.location.register);
+                        rg.ungetregisterint(exprasmlist,r);
                      end
                    else
                      begin
@@ -569,6 +572,7 @@ interface
         resflags   : tresflags;
         pushedfpu,
         cmpop      : boolean;
+        r,r2:Tregister;
       begin
         pass_left_and_right(pushedfpu);
 
@@ -594,14 +598,14 @@ interface
 
         if (right.location.loc<>LOC_FPUREGISTER) then
          begin
-           cg.a_loadfpu_loc_reg(exprasmlist,
-               right.location,R_ST);
+           r.enum:=R_ST;
+           cg.a_loadfpu_loc_reg(exprasmlist,right.location,r);
            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_ST);
+              cg.a_loadfpu_loc_reg(exprasmlist,left.location,r);
               if (left.location.loc <> LOC_CFPUREGISTER) and
                  pushedfpu then
                 location_freetemp(exprasmlist,left.location);
@@ -618,7 +622,8 @@ interface
         { the nominator in st0 }
         else if (left.location.loc<>LOC_FPUREGISTER) then
          begin
-           cg.a_loadfpu_loc_reg(exprasmlist,left.location,R_ST);
+           r.enum:=R_ST;
+           cg.a_loadfpu_loc_reg(exprasmlist,left.location,r);
            if (left.location.loc <> LOC_CFPUREGISTER) and
               pushedfpu then
              location_freetemp(exprasmlist,left.location);
@@ -649,7 +654,9 @@ interface
         { the Intel assemblers want operands }
         if op<>A_FCOMPP then
           begin
-             emit_reg_reg(op,S_NO,R_ST,R_ST1);
+             r.enum:=R_ST;
+             r2.enum:=R_ST1;
+             emit_reg_reg(op,S_NO,r,r2);
              dec(trgcpu(rg).fpuvaroffset);
           end
         else
@@ -664,14 +671,19 @@ interface
            if not(R_EAX in rg.unusedregsint) then
              begin
                rg.getexplicitregisterint(exprasmlist,R_EDI);
-               emit_reg_reg(A_MOV,S_L,R_EAX,R_EDI);
+               r.enum:=R_EAX;
+               r2.enum:=R_EDI;
+               emit_reg_reg(A_MOV,S_L,r,r2);
              end;
-           emit_reg(A_FNSTSW,S_NO,R_AX);
+           r.enum:=R_AX;
+           emit_reg(A_FNSTSW,S_NO,r);
            emit_none(A_SAHF,S_NO);
            if not(R_EAX in rg.unusedregsint) then
              begin
-               emit_reg_reg(A_MOV,S_L,R_EDI,R_EAX);
-               rg.ungetregisterint(exprasmlist,R_EDI);
+               r.enum:=R_EAX;
+               r2.enum:=R_EDI;
+               emit_reg_reg(A_MOV,S_L,r2,r);
+               rg.ungetregisterint(exprasmlist,r2);
              end;
            if nf_swaped in flags then
             begin
@@ -701,7 +713,7 @@ interface
         else
          begin
            location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-           location.register:=R_ST;
+           location.register.enum:=R_ST;
          end;
       end;
 
@@ -836,6 +848,7 @@ interface
         mboverflow,
         cmpop,
         unsigned   : boolean;
+        r:Tregister;
 
       procedure firstjmp64bitcmp;
 
@@ -1012,15 +1025,16 @@ interface
            { right.location<>LOC_REGISTER }
            if (nodetype=subn) and (nf_swaped in flags) then
             begin
+              r.enum:=R_EDI;
               rg.getexplicitregisterint(exprasmlist,R_EDI);
-              cg64.a_load64low_loc_reg(exprasmlist,right.location,R_EDI);
-              emit_reg_reg(op1,opsize,left.location.registerlow,R_EDI);
-              emit_reg_reg(A_MOV,opsize,R_EDI,left.location.registerlow);
-              cg64.a_load64high_loc_reg(exprasmlist,right.location,R_EDI);
+              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);
+              cg64.a_load64high_loc_reg(exprasmlist,right.location,r);
               { the carry flag is still ok }
-              emit_reg_reg(op2,opsize,left.location.registerhigh,R_EDI);
-              emit_reg_reg(A_MOV,opsize,R_EDI,left.location.registerhigh);
-              rg.ungetregisterint(exprasmlist,R_EDI);
+              emit_reg_reg(op2,opsize,left.location.registerhigh,r);
+              emit_reg_reg(A_MOV,opsize,r,left.location.registerhigh);
+              rg.ungetregisterint(exprasmlist,r);
               if right.location.loc<>LOC_CREGISTER then
                begin
                  location_freetemp(exprasmlist,right.location);
@@ -1117,7 +1131,7 @@ interface
         pushedfpu,
         cmpop      : boolean;
         mmxbase    : tmmxtype;
-        hregister  : tregister;
+        r,hregister  : tregister;
       begin
         pass_left_and_right(pushedfpu);
 
@@ -1235,19 +1249,20 @@ 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_MM7);
-                 emit_reg_reg(op,S_NO,left.location.register,R_MM7);
-                 emit_reg_reg(A_MOVQ,S_NO,R_MM7,left.location.register);
+                 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);
                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_MM7);
-                 emit_reg_reg(op,S_NO,left.location.register,R_MM7);
-                 emit_reg_reg(A_MOVQ,S_NO,R_MM7,left.location.register);
+                 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);
                  location_release(exprasmlist,right.location);
                end;
             end
@@ -1317,6 +1332,7 @@ interface
          extra_not : boolean;
 
          regstopush: tregisterset;
+         r:Tregister;
 
       begin
          { to make it more readable, string and set (not smallset!) have their
@@ -1455,45 +1471,56 @@ interface
                if not(R_EAX in rg.unusedregsint) and
                   (R_EAX in regstopush) then
                  begin
-                   emit_reg(A_PUSH,S_L,R_EAX);
+                   r.enum:=R_EAX;
+                   emit_reg(A_PUSH,S_L,r);
                    popeax:=true;
                  end;
                if not(R_EDX in rg.unusedregsint) and
                    (R_EDX in regstopush) then
                  begin
-                   emit_reg(A_PUSH,S_L,R_EDX);
+                   r.enum:=R_EDX;
+                   emit_reg(A_PUSH,S_L,r);
                    popedx:=true;
                  end;
                { left.location can be R_EAX !!! }
+               r.enum:=R_EDI;
                rg.getexplicitregisterint(exprasmlist,R_EDI);
                { load the left value }
-               cg.a_load_loc_reg(exprasmlist,left.location,R_EDI);
+               cg.a_load_loc_reg(exprasmlist,left.location,r);
                location_release(exprasmlist,left.location);
                { allocate EAX }
+               r.enum:=R_EAX;
                if R_EAX in rg.unusedregsint then
-                 exprasmList.concat(tai_regalloc.Alloc(R_EAX));
+                 exprasmList.concat(tai_regalloc.Alloc(r));
                { load he right value }
-               cg.a_load_loc_reg(exprasmlist,right.location,R_EAX);
+               cg.a_load_loc_reg(exprasmlist,right.location,r);
                location_release(exprasmlist,right.location);
                { allocate EAX if it isn't yet allocated (JM) }
                if (R_EAX in rg.unusedregsint) then
-                 exprasmList.concat(tai_regalloc.Alloc(R_EAX));
+                 exprasmList.concat(tai_regalloc.Alloc(r));
                { also allocate EDX, since it is also modified by }
                { a mul (JM)                                      }
+               r.enum:=R_EDX;
                if R_EDX in rg.unusedregsint then
-                 exprasmList.concat(tai_regalloc.Alloc(R_EDX));
-               emit_reg(A_MUL,S_L,R_EDI);
-               rg.ungetregisterint(exprasmlist,R_EDI);
+                 exprasmList.concat(tai_regalloc.Alloc(r));
+               r.enum:=R_EDI;
+               emit_reg(A_MUL,S_L,r);
+               rg.ungetregisterint(exprasmlist,r);
+               r.enum:=R_EDX;
                if R_EDX in rg.unusedregsint then
-                 exprasmList.concat(tai_regalloc.DeAlloc(R_EDX));
+                 exprasmList.concat(tai_regalloc.DeAlloc(r));
+               r.enum:=R_EAX;
                if R_EAX in rg.unusedregsint then
-                 exprasmList.concat(tai_regalloc.DeAlloc(R_EAX));
+                 exprasmList.concat(tai_regalloc.DeAlloc(r));
                location.register:=rg.getregisterint(exprasmlist);
-               emit_reg_reg(A_MOV,S_L,R_EAX,location.register);
+               r.enum:=R_EAX;
+               emit_reg_reg(A_MOV,S_L,r,location.register);
+               r.enum:=R_EDX;
                if popedx then
-                 emit_reg(A_POP,S_L,R_EDX);
+                 emit_reg(A_POP,S_L,r);
+               r.enum:=R_EAX;
                if popeax then
-                 emit_reg(A_POP,S_L,R_EAX);
+                 emit_reg(A_POP,S_L,r);
                location_freetemp(exprasmlist,left.location);
                location_freetemp(exprasmlist,right.location);
                exit;
@@ -1553,7 +1580,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.52  2002-11-25 17:43:26  peter
+  Revision 1.53  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.52  2002/11/25 17:43:26  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 87 - 58
compiler/i386/n386cal.pas

@@ -332,11 +332,13 @@ implementation
          constructorfailed : tasmlabel;
          returnref,
          pararef : treference;
+         r,r2,rsp:Tregister;
 
       label
          dont_call;
 
       begin
+         rsp.enum:=R_ESP;
          extended_new:=false;
          iolabel:=nil;
          inlinecode:=nil;
@@ -469,7 +471,7 @@ implementation
             if pop_size>0 then
              begin
                inc(pushedparasize,pop_size);
-               emit_const_reg(A_SUB,S_L,pop_size,R_ESP);
+               emit_const_reg(A_SUB,S_L,pop_size,rsp);
 {$ifdef GDB}
                if (cs_debuginfo in aktmoduleswitches) and
                   (exprasmList.first=exprasmList.last) then
@@ -486,16 +488,17 @@ implementation
                 and nested procedures
               }
               inc(push_size,12);
-              emit_reg_reg(A_MOV,S_L,R_ESP,R_EDI);
+              emit_reg_reg(A_MOV,S_L,rsp,R_EDI);
               if (push_size mod 8)=0 then
-                emit_const_reg(A_AND,S_L,$fffffff8,R_ESP)
+                emit_const_reg(A_AND,S_L,$fffffff8,rsp)
               else
                 begin
-                   emit_const_reg(A_SUB,S_L,push_size,R_ESP);
-                   emit_const_reg(A_AND,S_L,$fffffff8,R_ESP);
-                   emit_const_reg(A_SUB,S_L,push_size,R_ESP);
+                   emit_const_reg(A_SUB,S_L,push_size,rsp);
+                   emit_const_reg(A_AND,S_L,$fffffff8,rsp);
+                   emit_const_reg(A_SUB,S_L,push_size,rsp);
                 end;
-              emit_reg(A_PUSH,S_L,R_EDI);
+              r.enum:=R_EDI;
+              emit_reg(A_PUSH,S_L,r);
            end
          else
            pop_esp:=false;
@@ -593,7 +596,7 @@ implementation
                    methodpointer:=ccallparanode.create(nil,nil);
                    location_reset(methodpointer.location,LOC_REGISTER,OS_ADDR);
                    rg.getexplicitregisterint(exprasmlist,R_ESI);
-                   methodpointer.location.register:=R_ESI;
+                   methodpointer.location.register.enum:=R_ESI;
                    { ARGHHH this is wrong !!!
                      if we can init from base class for a child
                      class that the wrong VMT will be
@@ -602,12 +605,13 @@ implementation
                      twithnode(twithsymtable(symtableproc).withnode).left.resulttype;
                    { make a reference }
                    href:=twithnode(twithsymtable(symtableproc).withnode).withreference;
+                   r.enum:=self_pointer_reg;
                    if ((not(nf_islocal in twithnode(twithsymtable(symtableproc).withnode).flags)) and
                        (not twithsymtable(symtableproc).direct_with)) or
                       is_class_or_interface(methodpointer.resulttype.def) then
-                     cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,self_pointer_reg)
+                     cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,r)
                    else
-                     cg.a_loadaddr_ref_reg(exprasmlist,href,self_pointer_reg);
+                     cg.a_loadaddr_ref_reg(exprasmlist,href,r);
                 end;
 
               { push self }
@@ -647,12 +651,13 @@ implementation
                                          loadesi:=true;
                                          { if no VMT just use $0 bug0214 PM }
                                          rg.getexplicitregisterint(exprasmlist,R_ESI);
+                                         r.enum:=self_pointer_reg;
                                          if not(oo_has_vmt in tobjectdef(methodpointer.resulttype.def).objectoptions) then
-                                           cg.a_load_const_reg(exprasmlist,OS_ADDR,0,self_pointer_reg)
+                                           cg.a_load_const_reg(exprasmlist,OS_ADDR,0,r)
                                          else
                                            begin
                                              reference_reset_symbol(href,objectlibrary.newasmsymbol(tobjectdef(methodpointer.resulttype.def).vmt_mangledname),0);
-                                             cg.a_loadaddr_ref_reg(exprasmlist,href,self_pointer_reg);
+                                             cg.a_loadaddr_ref_reg(exprasmlist,href,r);
                                            end;
                                          { emit_reg(A_PUSH,S_L,R_ESI);
                                            this is done below !! }
@@ -662,18 +667,20 @@ implementation
                                       loadesi:=false;
 
                                     { a class destructor needs a flag }
+                                    r.enum:=self_pointer_reg;
                                     if is_class(tobjectdef(methodpointer.resulttype.def)) and
                                        (procdefinition.proctypeoption=potype_destructor) then
                                       begin
                                         cg.a_param_const(exprasmlist,OS_ADDR,0,paramanager.getintparaloc(2));
-                                        cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,paramanager.getintparaloc(1));
+                                        cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(1));
                                       end;
 
+                                    r.enum:=self_pointer_reg;
                                     if not(is_con_or_destructor and
                                            is_class(methodpointer.resulttype.def) and
                                            (procdefinition.proctypeoption in [potype_constructor,potype_destructor])
                                           ) then
-                                      cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,paramanager.getintparaloc(1));
+                                      cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(1));
                                     { if an inherited con- or destructor should be  }
                                     { called in a con- or destructor then a warning }
                                     { will be made                                  }
@@ -704,9 +711,10 @@ implementation
                                  begin
                                     { extended syntax of new }
                                     { ESI must be zero }
+                                    r.enum:=self_pointer_reg;
                                     rg.getexplicitregisterint(exprasmlist,R_ESI);
-                                    cg.a_load_const_reg(exprasmlist,OS_ADDR,0,self_pointer_reg);
-                                    cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,paramanager.getintparaloc(2));
+                                    cg.a_load_const_reg(exprasmlist,OS_ADDR,0,r);
+                                    cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(2));
                                     { insert the vmt }
                                     reference_reset_symbol(href,objectlibrary.newasmsymbol(tobjectdef(methodpointer.resulttype.def).vmt_mangledname),0);
                                     cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(1));
@@ -718,10 +726,11 @@ implementation
 
                                     { destructor with extended syntax called from dispose }
                                     { hdisposen always deliver LOC_REFERENCE          }
+                                    r.enum:=R_ESI;
                                     rg.getexplicitregisterint(exprasmlist,R_ESI);
-                                    emit_ref_reg(A_LEA,S_L,methodpointer.location.reference,R_ESI);
+                                    emit_ref_reg(A_LEA,S_L,methodpointer.location.reference,r);
                                     reference_release(exprasmlist,methodpointer.location.reference);
-                                    cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,paramanager.getintparaloc(2));
+                                    cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(2));
                                     reference_reset_symbol(href,objectlibrary.newasmsymbol(tobjectdef(methodpointer.resulttype.def).vmt_mangledname),0);
                                     cg.a_paramaddr_ref(exprasmlist,href,paramanager.getintparaloc(1));
                                  end;
@@ -730,22 +739,23 @@ implementation
                                     { call to an instance member }
                                     if (symtableproc.symtabletype<>withsymtable) then
                                       begin
+                                         r.enum:=R_ESI;
                                          secondpass(methodpointer);
                                          rg.getexplicitregisterint(exprasmlist,R_ESI);
                                          case methodpointer.location.loc of
                                             LOC_CREGISTER,
                                             LOC_REGISTER:
                                               begin
-                                                 cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,methodpointer.location.register,R_ESI);
+                                                 cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,methodpointer.location.register,r);
                                                  rg.ungetregisterint(exprasmlist,methodpointer.location.register);
                                               end;
                                             else
                                               begin
                                                  if (methodpointer.resulttype.def.deftype=classrefdef) or
                                                     is_class_or_interface(methodpointer.resulttype.def) then
-                                                   cg.a_load_ref_reg(exprasmlist,OS_ADDR,methodpointer.location.reference,R_ESI)
+                                                   cg.a_load_ref_reg(exprasmlist,OS_ADDR,methodpointer.location.reference,r)
                                                  else
-                                                   cg.a_loadaddr_ref_reg(exprasmlist,methodpointer.location.reference,R_ESI);
+                                                   cg.a_loadaddr_ref_reg(exprasmlist,methodpointer.location.reference,r);
                                                  reference_release(exprasmlist,methodpointer.location.reference);
                                               end;
                                          end;
@@ -758,10 +768,11 @@ implementation
                                            not(methodpointer.resulttype.def.deftype=classrefdef) then
                                           begin
                                              { class method needs current VMT }
+                                             r.enum:=self_pointer_reg;
                                              rg.getexplicitregisterint(exprasmlist,R_ESI);
-                                             reference_reset_base(href,R_ESI,tprocdef(procdefinition)._class.vmt_offset);
+                                             reference_reset_base(href,r,tprocdef(procdefinition)._class.vmt_offset);
                                              cg.g_maybe_testself(exprasmlist);
-                                             cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,self_pointer_reg);
+                                             cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,r);
                                           end;
 
                                         { direct call to destructor: remove data }
@@ -783,7 +794,8 @@ implementation
                                                 (methodpointer.resulttype.def.deftype=classrefdef) and
                                                 is_class(tclassrefdef(methodpointer.resulttype.def).pointertype.def) then
                                                cg.a_param_const(exprasmlist,OS_INT,1,paramanager.getintparaloc(1));
-                                             cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,paramanager.getintparaloc(1));
+                                             r.enum:=self_pointer_reg;
+                                             cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(1));
                                           end;
                                       end;
 
@@ -819,9 +831,10 @@ implementation
                           begin
                              { class method needs current VMT }
                              rg.getexplicitregisterint(exprasmlist,R_ESI);
-                             reference_reset_base(href,R_ESI,tprocdef(procdefinition)._class.vmt_offset);
+                             r.enum:=R_ESI;
+                             reference_reset_base(href,r,tprocdef(procdefinition)._class.vmt_offset);
                              cg.g_maybe_testself(exprasmlist);
-                             cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,R_ESI);
+                             cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,r);
                           end
                         else
                           begin
@@ -831,10 +844,11 @@ implementation
                         { direct call to destructor: don't remove data! }
                         if is_class(procinfo._class) then
                           begin
+                             r.enum:=R_ESI;
                              if (procdefinition.proctypeoption=potype_destructor) then
                                begin
                                   cg.a_param_const(exprasmlist,OS_INT,0,paramanager.getintparaloc(2));
-                                  cg.a_param_reg(exprasmlist,OS_ADDR,R_ESI,paramanager.getintparaloc(1));
+                                  cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(1));
                                end
                              else if (procdefinition.proctypeoption=potype_constructor) then
                                begin
@@ -842,11 +856,12 @@ implementation
                                   cg.a_param_const(exprasmlist,OS_INT,0,paramanager.getintparaloc(1));
                                end
                              else
-                               cg.a_param_reg(exprasmlist,OS_ADDR,R_ESI,paramanager.getintparaloc(1));
+                               cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(1));
                           end
                         else if is_object(procinfo._class) then
                           begin
-                             cg.a_param_reg(exprasmlist,OS_ADDR,R_ESI,paramanager.getintparaloc(1));
+                             r.enum:=R_ESI;
+                             cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(1));
                              if is_con_or_destructor then
                                begin
                                   (*
@@ -878,8 +893,9 @@ implementation
                    (inlined or
                    (right=nil)) then
                   begin
-                     cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,paramanager.getintparaloc(1));
-                     reference_reset_base(href,self_pointer_reg,0);
+                     r.enum:=self_pointer_reg;
+                     cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(1));
+                     reference_reset_base(href,r,0);
                      tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                      cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,tmpreg);
                      reference_reset_base(href,tmpreg,72);
@@ -946,6 +962,7 @@ implementation
                    { on the methodpointer                        PM }
                    release_tmpreg:=false;
                    rg.getexplicitregisterint(exprasmlist,R_ESI);
+                   r.enum:=R_ESI;
                    if assigned(aktprocdef) then
                      begin
                        if (((sp_static in aktprocdef.procsym.symoptions) or
@@ -962,12 +979,12 @@ implementation
                         { ESI is loaded earlier }
                         (po_classmethod in procdefinition.procoptions) then
                          begin
-                            reference_reset_base(href,R_ESI,0);
+                            reference_reset_base(href,r,0);
                          end
                        else
                          begin
                             { this is one point where we need vmt_offset (PM) }
-                            reference_reset_base(href,R_ESI,tprocdef(procdefinition)._class.vmt_offset);
+                            reference_reset_base(href,r,tprocdef(procdefinition)._class.vmt_offset);
                             cg.g_maybe_testself(exprasmlist);
                             tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                             cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,tmpreg);
@@ -1010,7 +1027,8 @@ implementation
                   if (po_interrupt in procdefinition.procoptions) then
                     begin
                         emit_none(A_PUSHF,S_L);
-                        emit_reg(A_PUSH,S_L,R_CS);
+                        r.enum:=R_CS;
+                        emit_reg(A_PUSH,S_L,r);
                     end;
                   cg.a_call_name(exprasmlist,tprocdef(procdefinition).mangledname);
                 end
@@ -1031,19 +1049,20 @@ implementation
               if (po_interrupt in procdefinition.procoptions) then
                 begin
                     emit_none(A_PUSHF,S_L);
-                    emit_reg(A_PUSH,S_L,R_CS);
+                    r.enum:=R_CS;
+                    emit_reg(A_PUSH,S_L,r);
                 end;
               { procedure of object? }
               if (po_methodpointer in procdefinition.procoptions) then
                 begin
                    { method pointer can't be in a register }
-                   hregister:=R_NO;
+                   hregister.enum:=R_NO;
 
                    { do some hacking if we call a method pointer }
                    { which is a class member                 }
                    { else ESI is overwritten !             }
-                   if (right.location.reference.base=R_ESI) or
-                      (right.location.reference.index=R_ESI) then
+                   if (right.location.reference.base.enum=R_ESI) or
+                      (right.location.reference.index.enum=R_ESI) then
                      begin
                         reference_release(exprasmlist,right.location.reference);
                         hregister:=cg.get_scratch_reg_address(exprasmlist);
@@ -1056,19 +1075,20 @@ implementation
                        { load ESI }
                        href:=right.location.reference;
                        inc(href.offset,4);
+                       r.enum:=self_pointer_reg;
                        rg.getexplicitregisterint(exprasmlist,R_ESI);
-                       cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,self_pointer_reg);
+                       cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,r);
                        { push self pointer }
-                       cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,paralocdummy);
+                       cg.a_param_reg(exprasmlist,OS_ADDR,r,paralocdummy);
                      end;
 
                    rg.saveregvars(exprasmlist,ALL_REGISTERS);
-                   if hregister<>R_NO then
+                   if hregister.enum<>R_NO then
                      cg.a_call_reg(exprasmlist,hregister)
                    else
                      cg.a_call_ref(exprasmlist,right.location.reference);
 
-                   if hregister<>R_NO then
+                   if hregister.enum<>R_NO then
                      cg.free_scratch_reg(exprasmlist,hregister);
                    reference_release(exprasmlist,right.location.reference);
                    tg.Ungetiftemp(exprasmlist,right.location.reference);
@@ -1092,9 +1112,10 @@ implementation
                 { better than an add on all processors }
                 if pushedparasize=4 then
                   begin
+                    r.enum:=R_EDI;
                     rg.getexplicitregisterint(exprasmlist,R_EDI);
-                    emit_reg(A_POP,S_L,R_EDI);
-                    rg.ungetregisterint(exprasmlist,R_EDI);
+                    emit_reg(A_POP,S_L,r);
+                    rg.ungetregisterint(exprasmlist,r);
                   end
                 { the pentium has two pipes and pop reg is pairable }
                 { but the registers must be different!        }
@@ -1103,19 +1124,21 @@ implementation
                   (aktoptprocessor=ClassP5) and
                   (procinfo._class=nil) then
                     begin
+                       r.enum:=R_EDI;
                        rg.getexplicitregisterint(exprasmlist,R_EDI);
-                       emit_reg(A_POP,S_L,R_EDI);
-                       rg.ungetregisterint(exprasmlist,R_EDI);
-                       exprasmList.concat(tai_regalloc.Alloc(R_ESI));
-                       emit_reg(A_POP,S_L,R_ESI);
-                       exprasmList.concat(tai_regalloc.DeAlloc(R_ESI));
+                       emit_reg(A_POP,S_L,r);
+                       rg.ungetregisterint(exprasmlist,r);
+                       r.enum:=R_ESI;
+                       exprasmList.concat(tai_regalloc.Alloc(r));
+                       emit_reg(A_POP,S_L,r);
+                       exprasmList.concat(tai_regalloc.DeAlloc(r));
                     end
                 else if pushedparasize<>0 then
-                  emit_const_reg(A_ADD,S_L,pushedparasize,R_ESP);
+                  emit_const_reg(A_ADD,S_L,pushedparasize,rsp);
              end;
 {$ifdef OPTALIGN}
          if pop_esp then
-           emit_reg(A_POP,S_L,R_ESP);
+           emit_reg(A_POP,S_L,rsp);
 {$endif OPTALIGN}
       dont_call:
          pushedparasize:=oldpushedparasize;
@@ -1151,18 +1174,20 @@ implementation
            assigned(methodpointer) and
            (methodpointer.nodetype<>typen) then
            begin
+              r.enum:=accumulator;
+              r2.enum:=self_pointer_reg;
               objectlibrary.getlabel(constructorfailed);
               emitjmp(C_Z,constructorfailed);
-              cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,paramanager.getintparaloc(1));
-              reference_reset_base(href,self_pointer_reg,0);
+              cg.a_param_reg(exprasmlist,OS_ADDR,r2,paramanager.getintparaloc(1));
+              reference_reset_base(href,r2,0);
               tmpreg:=cg.get_scratch_reg_address(exprasmlist);
               cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,tmpreg);
               reference_reset_base(href,tmpreg,68);
               cg.a_call_ref(exprasmlist,href);
               cg.free_scratch_reg(exprasmlist,tmpreg);
-              exprasmList.concat(tai_regalloc.Alloc(accumulator));
+              exprasmList.concat(tai_regalloc.Alloc(r));
               cg.a_label(exprasmlist,constructorfailed);
-              cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,self_pointer_reg,accumulator);
+              cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,r2,r);
            end;
 
          { handle function results }
@@ -1177,7 +1202,7 @@ implementation
               cg.a_call_name(exprasmlist,'FPC_IOCHECK');
            end;
          if pop_size>0 then
-           emit_const_reg(A_ADD,S_L,pop_size,R_ESP);
+           emit_const_reg(A_ADD,S_L,pop_size,rsp);
 
          { restore registers }
          rg.restoreusedregisters(exprasmlist,pushed);
@@ -1235,7 +1260,8 @@ implementation
               else if location.loc=LOC_FPUREGISTER then
                 begin
                   { release FPU stack }
-                  emit_reg(A_FSTP,S_NO,R_ST);
+                  r.enum:=R_ST;
+                  emit_reg(A_FSTP,S_NO,r);
                   {
                     dec(trgcpu(rg).fpuvaroffset);
                     do NOT decrement as the increment before
@@ -1250,7 +1276,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.78  2002-12-15 21:30:12  florian
+  Revision 1.79  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.78  2002/12/15 21:30:12  florian
     * tcallnode.paraitem introduced, all references to defcoll removed
 
   Revision 1.77  2002/11/27 20:05:06  peter

+ 26 - 14
compiler/i386/n386cnv.pas

@@ -91,10 +91,11 @@ implementation
          hregister : tregister;
          l1,l2 : tasmlabel;
          freereg : boolean;
+         r:Tregister;
 
       begin
          location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-         hregister:=R_NO;
+         hregister.enum:=R_NO;
          freereg:=false;
 
          { for u32bit a solution is to push $0 and to load a comp }
@@ -148,17 +149,20 @@ implementation
          exprasmlist.concat(taicpu.op_reg(A_PUSH,S_L,hregister));
          if freereg then
            cg.free_scratch_reg(exprasmlist,hregister);
-         reference_reset_base(href,R_ESP,0);
+         r.enum:=R_ESP;
+         reference_reset_base(href,r,0);
          case torddef(left.resulttype.def).typ of
            u32bit:
              begin
+                r.enum:=R_ESP;
                 emit_ref(A_FILD,S_IQ,href);
-                emit_const_reg(A_ADD,S_L,8,R_ESP);
+                emit_const_reg(A_ADD,S_L,8,r);
              end;
            s64bit:
              begin
+                r.enum:=R_ESP;
                 emit_ref(A_FILD,S_IQ,href);
-                emit_const_reg(A_ADD,S_L,8,R_ESP);
+                emit_const_reg(A_ADD,S_L,8,r);
              end;
            u64bit:
              begin
@@ -166,14 +170,18 @@ 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_EDI;
                 inc(href.offset,4);
                 rg.getexplicitregisterint(exprasmlist,R_EDI);
-                emit_ref_reg(A_MOV,S_L,href,R_EDI);
-                reference_reset_base(href,R_ESP,4);
+                emit_ref_reg(A_MOV,S_L,href,r);
+                r.enum:=R_ESP;
+                reference_reset_base(href,r,4);
                 emit_const_ref(A_AND,S_L,$7fffffff,href);
-                emit_const_reg(A_TEST,S_L,longint($80000000),R_EDI);
-                rg.ungetregisterint(exprasmlist,R_EDI);
-                reference_reset_base(href,R_ESP,0);
+                r.enum:=R_EDI;
+                emit_const_reg(A_TEST,S_L,longint($80000000),r);
+                rg.ungetregisterint(exprasmlist,r);
+                r.enum:=R_ESP;
+                reference_reset_base(href,r,0);
                 emit_ref(A_FILD,S_IQ,href);
                 objectlibrary.getdatalabel(l1);
                 objectlibrary.getlabel(l2);
@@ -185,18 +193,19 @@ 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_ESP);
+                emit_const_reg(A_ADD,S_L,8,r);
              end
            else
              begin
                 emit_ref(A_FILD,S_IL,href);
                 rg.getexplicitregisterint(exprasmlist,R_EDI);
-                emit_reg(A_POP,S_L,R_EDI);
-                rg.ungetregisterint(exprasmlist,R_EDI);
+                r.enum:=R_EDI;
+                emit_reg(A_POP,S_L,r);
+                rg.ungetregisterint(exprasmlist,r);
              end;
          end;
          inc(trgcpu(rg).fpuvaroffset);
-         location.register:=R_ST;
+         location.register.enum:=R_ST;
       end;
 
 
@@ -419,7 +428,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.53  2002-12-05 14:27:42  florian
+  Revision 1.54  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.53  2002/12/05 14:27:42  florian
     * some variant <-> dyn. array stuff
 
   Revision 1.52  2002/11/25 17:43:26  peter

+ 6 - 3
compiler/i386/n386con.pas

@@ -65,14 +65,14 @@ implementation
            begin
               emit_none(A_FLD1,S_NO);
               location.loc:=LOC_FPUREGISTER;
-              location.register:=R_ST;
+              location.register.enum:=R_ST;
               inc(trgcpu(rg).fpuvaroffset);
            end
          else if (value_real=0.0) then
            begin
               emit_none(A_FLDZ,S_NO);
               location.loc:=LOC_FPUREGISTER;
-              location.register:=R_ST;
+              location.register.enum:=R_ST;
               inc(trgcpu(rg).fpuvaroffset);
            end
          else
@@ -85,7 +85,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.16  2002-05-18 13:34:25  peter
+  Revision 1.17  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.16  2002/05/18 13:34:25  peter
     * readded missing revisions
 
   Revision 1.15  2002/05/16 19:46:51  carl

+ 11 - 4
compiler/i386/n386inl.pas

@@ -165,7 +165,7 @@ implementation
          location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
          emit_none(A_FLDPI,S_NO);
          inc(trgcpu(rg).fpuvaroffset);
-         location.register:=FPU_RESULT_REG;
+         location.register.enum:=FPU_RESULT_REG;
 
        end;
 
@@ -173,7 +173,7 @@ implementation
        procedure ti386inlinenode.load_fpu_location;
          begin
            location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-           location.register:=FPU_RESULT_REG;
+           location.register.enum:=FPU_RESULT_REG;
            secondpass(left);
            case left.location.loc of
              LOC_FPUREGISTER:
@@ -209,9 +209,13 @@ implementation
        end;
 
      procedure ti386inlinenode.second_sqr_real;
+     
+     var r:Tregister;
+     
        begin
          load_fpu_location;
-         emit_reg_reg(A_FMUL,S_NO,R_ST0,R_ST0);
+         r.enum:=R_ST0;
+         emit_reg_reg(A_FMUL,S_NO,r,r);
        end;
 
      procedure ti386inlinenode.second_sqrt_real;
@@ -328,7 +332,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.54  2002-11-25 17:43:26  peter
+  Revision 1.55  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.54  2002/11/25 17:43:26  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 99 - 72
compiler/i386/n386mat.pas

@@ -68,6 +68,7 @@ implementation
       var
          hreg1 : tregister;
          hreg2 : tregister;
+         r,r2  : Tregister;
          shrdiv,popeax,popedx : boolean;
          power : longint;
          hl : tasmlabel;
@@ -111,7 +112,7 @@ implementation
                            comp.compilers (JM) }
                         begin
                           { no jumps, but more operations }
-                          if (hreg1 = R_EAX) and
+                          if (hreg1.enum = R_EAX) and
                              (R_EDX in rg.unusedregsint) then
                             begin
                               hreg2 := rg.getexplicitregisterint(exprasmlist,R_EDX);
@@ -120,11 +121,11 @@ implementation
                           else
                             begin
                               rg.getexplicitregisterint(exprasmlist,R_EDI);
-                              hreg2 := R_EDI;
-                              emit_reg_reg(A_MOV,S_L,hreg1,R_EDI);
+                              hreg2.enum := R_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,R_EDI);
+                              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);
@@ -162,93 +163,99 @@ implementation
                   rg.getexplicitregisterint(exprasmlist,R_EDI);
                   if right.location.loc<>LOC_CREGISTER then
                    location_release(exprasmlist,right.location);
-                  cg.a_load_loc_reg(exprasmlist,right.location,R_EDI);
+                  r.enum:=R_EDI;
+                  cg.a_load_loc_reg(exprasmlist,right.location,r);
                   popedx:=false;
                   popeax:=false;
-                  if hreg1=R_EDX then
+                  r.enum:=R_EAX;
+                  r2.enum:=R_EDX;
+                  if hreg1.enum=R_EDX then
                     begin
                       if not(R_EAX in rg.unusedregsint) then
                          begin
-                            emit_reg(A_PUSH,S_L,R_EAX);
+                            emit_reg(A_PUSH,S_L,r);
                             popeax:=true;
                          end
                        else
                          rg.getexplicitregisterint(exprasmlist,R_EAX);
-                      emit_reg_reg(A_MOV,S_L,R_EDX,R_EAX);
+                      emit_reg_reg(A_MOV,S_L,r2,r);
                     end
                   else
                     begin
                        if not(R_EDX in rg.unusedregsint) then
                          begin
-                            emit_reg(A_PUSH,S_L,R_EDX);
+                            emit_reg(A_PUSH,S_L,r2);
                             popedx:=true;
                          end
                        else
                          rg.getexplicitregisterint(exprasmlist,R_EDX);
-                       if hreg1<>R_EAX then
+                       if hreg1.enum<>R_EAX then
                          begin
                             if not(R_EAX in rg.unusedregsint) then
                               begin
-                                 emit_reg(A_PUSH,S_L,R_EAX);
+                                 emit_reg(A_PUSH,S_L,r);
                                  popeax:=true;
                               end
                             else
                               rg.getexplicitregisterint(exprasmlist,R_EAX);
-                            emit_reg_reg(A_MOV,S_L,hreg1,R_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,R_EDX,R_EDX)
+                     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_EDI;
                   if torddef(right.resulttype.def).typ=u32bit then
-                    emit_reg(A_DIV,S_L,R_EDI)
+                    emit_reg(A_DIV,S_L,r)
                   else
-                    emit_reg(A_IDIV,S_L,R_EDI);
-                  rg.ungetregisterint(exprasmlist,R_EDI);
+                    emit_reg(A_IDIV,S_L,r);
+                  r.enum:=R_EDI;
+                  rg.ungetregisterint(exprasmlist,r);
+                  r.enum:=R_EAX;
                   if nodetype=divn then
                     begin
-                       if not popedx and (hreg1 <> R_EDX) then
-                         rg.ungetregister(exprasmlist,R_EDX);
+                       if not popedx and (hreg1.enum <> R_EDX) then
+                         rg.ungetregister(exprasmlist,r2);
                        { if result register is busy then copy }
                        if popeax then
                          begin
-                            if hreg1=R_EAX then
+                            if hreg1.enum=R_EAX then
                               internalerror(112);
-                            emit_reg_reg(A_MOV,S_L,R_EAX,hreg1)
+                            emit_reg_reg(A_MOV,S_L,r,hreg1)
                          end
                        else
-                         if hreg1<>R_EAX then
+                         if hreg1.enum<>R_EAX then
                            Begin
                              rg.ungetregisterint(exprasmlist,hreg1);
                              { no need to allocate eax, that's already done before }
                              { the div (JM)                                        }
-                             hreg1 := R_EAX;
+                             hreg1.enum := R_EAX;
                            end;
                     end
                   else
                     begin
-                      if not popeax and (hreg1 <> R_EAX)then
-                        rg.ungetregister(exprasmlist,R_EAX);
+                      if not popeax and (hreg1.enum <> R_EAX)then
+                        rg.ungetregister(exprasmlist,r);
                       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,R_EDX,hreg1)
+                        emit_reg_reg(A_MOV,S_L,r2,hreg1)
                       else
                         Begin
-                          if hreg1 <> R_EDX then
+                          if hreg1.enum <> R_EDX then
                             rg.ungetregisterint(exprasmlist,hreg1);
-                          hreg1 := R_EDX
+                          hreg1.enum := R_EDX
                         End;
                     end;
                   if popeax then
-                    emit_reg(A_POP,S_L,R_EAX);
+                    emit_reg(A_POP,S_L,r);
                   if popedx then
-                    emit_reg(A_POP,S_L,R_EDX);
+                    emit_reg(A_POP,S_L,r2);
                 end;
               If not(shrdiv) then
                { shrdiv only use hreg1 (which is already in usedinproc,   }
@@ -282,6 +289,7 @@ implementation
          op : tasmop;
          l1,l2,l3 : tasmlabel;
          pushedregs : tmaybesave;
+         r,r2:Tregister;
       begin
          popecx:=false;
 
@@ -366,7 +374,9 @@ implementation
                    { left operator is already in a register }
                    { hence are both in a register }
                    { is it in the case ECX ? }
-                   if (hregisterlow=R_ECX) then
+                   r.enum:=R_ECX;
+                   r2.enum:=R_CL;
+                   if (hregisterlow.enum=R_ECX) then
                      begin
                         { then only swap }
                         emit_reg_reg(A_XCHG,S_L,hregisterlow,hregister2);
@@ -374,7 +384,7 @@ implementation
                         hregisterlow:=hregister2;
                         hregister2:=hregister3;
                      end
-                   else if (hregisterhigh=R_ECX) then
+                   else if (hregisterhigh.enum=R_ECX) then
                      begin
                         { then only swap }
                         emit_reg_reg(A_XCHG,S_L,hregisterhigh,hregister2);
@@ -384,20 +394,20 @@ implementation
                      end
 
                    { if second operator not in ECX ? }
-                   else if (hregister2<>R_ECX) then
+                   else if (hregister2.enum<>R_ECX) then
                      begin
                         { ECX occupied then push it }
                         if not (R_ECX in rg.unusedregsint) then
                          begin
                            popecx:=true;
-                           emit_reg(A_PUSH,S_L,R_ECX);
+                           emit_reg(A_PUSH,S_L,r);
                          end
                         else
                           rg.getexplicitregisterint(exprasmlist,R_ECX);
-                        emit_reg_reg(A_MOV,S_L,hregister2,R_ECX);
+                        emit_reg_reg(A_MOV,S_L,hregister2,r);
                      end;
 
-                   if hregister2 <> R_ECX then
+                   if hregister2.enum <> R_ECX then
                      rg.ungetregisterint(exprasmlist,hregister2);
 
                    { the damned shift instructions work only til a count of 32 }
@@ -407,24 +417,24 @@ implementation
                         objectlibrary.getlabel(l1);
                         objectlibrary.getlabel(l2);
                         objectlibrary.getlabel(l3);
-                        emit_const_reg(A_CMP,S_L,64,R_ECX);
+                        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_ECX);
+                        emit_const_reg(A_CMP,S_L,32,r);
                         emitjmp(C_L,l2);
-                        emit_const_reg(A_SUB,S_L,32,R_ECX);
-                        emit_reg_reg(A_SHL,S_L,R_CL,
+                        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,R_CL,
+                        emit_reg_reg_reg(A_SHLD,S_L,r2,
                           hregisterlow,hregisterhigh);
-                        emit_reg_reg(A_SHL,S_L,R_CL,
+                        emit_reg_reg(A_SHL,S_L,r2,
                           hregisterlow);
                         cg.a_label(exprasmlist,l3);
                      end
@@ -433,24 +443,24 @@ implementation
                         objectlibrary.getlabel(l1);
                         objectlibrary.getlabel(l2);
                         objectlibrary.getlabel(l3);
-                        emit_const_reg(A_CMP,S_L,64,R_ECX);
+                        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_ECX);
+                        emit_const_reg(A_CMP,S_L,32,r);
                         emitjmp(C_L,l2);
-                        emit_const_reg(A_SUB,S_L,32,R_ECX);
-                        emit_reg_reg(A_SHR,S_L,R_CL,
+                        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,R_CL,
+                        emit_reg_reg_reg(A_SHRD,S_L,r2,
                           hregisterhigh,hregisterlow);
-                        emit_reg_reg(A_SHR,S_L,R_CL,
+                        emit_reg_reg(A_SHR,S_L,r2,
                           hregisterhigh);
                         cg.a_label(exprasmlist,l3);
 
@@ -458,9 +468,9 @@ implementation
 
                    { maybe put ECX back }
                    if popecx then
-                     emit_reg(A_POP,S_L,R_ECX)
+                     emit_reg(A_POP,S_L,r)
                    else
-                     rg.ungetregisterint(exprasmlist,R_ECX);
+                     rg.ungetregisterint(exprasmlist,r);
 
                    location.registerlow:=hregisterlow;
                    location.registerhigh:=hregisterhigh;
@@ -471,6 +481,9 @@ implementation
               { load left operators in a register }
               location_copy(location,left.location);
               location_force_reg(exprasmlist,location,OS_INT,false);
+              
+              r.enum:=R_ECX;
+              r2.enum:=R_CL;
 
               { shifting by a constant directly coded: }
               if (right.nodetype=ordconstn) then
@@ -502,7 +515,7 @@ implementation
                    { left operator is already in a register }
                    { hence are both in a register }
                    { is it in the case ECX ? }
-                   if (location.register=R_ECX) then
+                   if (location.register.enum=R_ECX) then
                      begin
                         { then only swap }
                         emit_reg_reg(A_XCHG,S_L,location.register,hregister2);
@@ -511,26 +524,26 @@ implementation
                         hregister2:=hregister3;
                      end
                    { if second operator not in ECX ? }
-                   else if (hregister2<>R_ECX) then
+                   else if (hregister2.enum<>R_ECX) then
                      begin
                         { ECX occupied then push it }
                         if not (R_ECX in rg.unusedregsint) then
                          begin
                            popecx:=true;
-                           emit_reg(A_PUSH,S_L,R_ECX);
+                           emit_reg(A_PUSH,S_L,r);
                          end
                         else
                           rg.getexplicitregisterint(exprasmlist,R_ECX);
-                        emit_reg_reg(A_MOV,S_L,hregister2,R_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,R_CL,location.register);
+                   emit_reg_reg(op,S_L,r2,location.register);
                    { maybe ECX back }
                    if popecx then
-                     emit_reg(A_POP,S_L,R_ECX)
+                     emit_reg(A_POP,S_L,r)
                    else
-                     rg.ungetregisterint(exprasmlist,R_ECX);
+                     rg.ungetregisterint(exprasmlist,r);
                 end;
            end;
       end;
@@ -586,11 +599,14 @@ implementation
 
 
     procedure ti386unaryminusnode.pass_2;
+    
+    var r:Tregister;
 
 {$ifdef SUPPORT_MMX}
       procedure do_mmx_neg;
         var
            op : tasmop;
+           r: Tregister;
         begin
            location_reset(location,LOC_MMXREGISTER,OS_NO);
            if cs_mmx_saturation in aktlocalswitches then
@@ -613,8 +629,9 @@ implementation
                 mmxs32bit,mmxu32bit:
                   op:=A_PSUBD;
              end;
-           emit_reg_reg(op,S_NO,location.register,R_MM7);
-           emit_reg_reg(A_MOVQ,S_NO,R_MM7,location.register);
+           r.enum:=R_MM7;
+           emit_reg_reg(op,S_NO,location.register,r);
+           emit_reg_reg(A_MOVQ,S_NO,r,location.register);
         end;
 {$endif}
 
@@ -652,13 +669,15 @@ implementation
                  LOC_MMXREGISTER:
                    begin
                       location_copy(location,left.location);
-                      emit_reg_reg(A_PXOR,S_NO,R_MM7,R_MM7);
+                      r.enum:=R_MM7;
+                      emit_reg_reg(A_PXOR,S_NO,r,r);
                       do_mmx_neg;
                    end;
                  LOC_CMMXREGISTER:
                    begin
                       location.register:=rg.getregistermm(exprasmlist);
-                      emit_reg_reg(A_PXOR,S_NO,R_MM7,R_MM7);
+                      r.enum:=R_MM7;
+                      emit_reg_reg(A_PXOR,S_NO,r,r);
                       emit_reg_reg(A_MOVQ,S_NO,left.location.register,
                         location.register);
                       do_mmx_neg;
@@ -671,17 +690,18 @@ implementation
                       if (left.resulttype.def.deftype=floatdef) then
                         begin
                            location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-                           location.register:=R_ST;
+                           location.register.enum:=R_ST;
                            cg.a_loadfpu_ref_reg(exprasmlist,
                               def_cgsize(left.resulttype.def),
-                              left.location.reference,R_ST);
+                              left.location.reference,location.register);
                            emit_none(A_FCHS,S_NO);
                         end
 {$ifdef SUPPORT_MMX}
                       else if (cs_mmx in aktlocalswitches) and is_mmx_able_array(left.resulttype.def) then
                         begin
+                           r.enum:=R_MM7;
                            location.register:=rg.getregistermm(exprasmlist);
-                           emit_reg_reg(A_PXOR,S_NO,R_MM7,R_MM7);
+                           emit_reg_reg(A_PXOR,S_NO,r,r);
                            emit_ref_reg(A_MOVQ,S_NO,left.location.reference,location.register);
                            do_mmx_neg;
                         end
@@ -696,9 +716,10 @@ implementation
                  LOC_FPUREGISTER,LOC_CFPUREGISTER:
                    begin
                       { "load st,st" is ignored by the code generator }
-                      cg.a_loadfpu_reg_reg(exprasmlist,left.location.register,R_ST);
+                      r.enum:=R_ST;
+                      cg.a_loadfpu_reg_reg(exprasmlist,left.location.register,r);
                       location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-                      location.register:=R_ST;
+                      location.register.enum:=R_ST;
                       emit_none(A_FCHS,S_NO);
                    end;
                  else
@@ -727,6 +748,7 @@ implementation
       var
          hl : tasmlabel;
          opsize : topsize;
+         r,r2:Tregister;
       begin
          if is_boolean(resulttype.def) then
           begin
@@ -779,8 +801,10 @@ implementation
              secondpass(left);
              location_reset(location,LOC_MMXREGISTER,OS_NO);
              { prepare EDI }
+             r.enum:=R_EDI;
+             r2.enum:=R_MM7;
              rg.getexplicitregisterint(exprasmlist,R_EDI);
-             emit_const_reg(A_MOV,S_L,longint($ffffffff),R_EDI);
+             emit_const_reg(A_MOV,S_L,longint($ffffffff),r);
              { load operand }
              case left.location.loc of
                LOC_MMXREGISTER:
@@ -799,14 +823,14 @@ implementation
                  end;
              end;
              { load mask }
-             emit_reg_reg(A_MOVD,S_NO,R_EDI,R_MM7);
-             rg.ungetregisterint(exprasmlist,R_EDI);
+             emit_reg_reg(A_MOVD,S_NO,r,r2);
+             rg.ungetregisterint(exprasmlist,r);
              { lower 32 bit }
-             emit_reg_reg(A_PXOR,S_D,R_MM7,location.register);
+             emit_reg_reg(A_PXOR,S_D,r2,location.register);
              { shift mask }
-             emit_const_reg(A_PSLLQ,S_NO,32,R_MM7);
+             emit_const_reg(A_PSLLQ,S_NO,32,r2);
              { higher 32 bit }
-             emit_reg_reg(A_PXOR,S_D,R_MM7,location.register);
+             emit_reg_reg(A_PXOR,S_D,r2,location.register);
            end
 {$endif SUPPORT_MMX}
          else if is_64bitint(left.resulttype.def) then
@@ -838,7 +862,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.41  2002-11-25 17:43:26  peter
+  Revision 1.42  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.41  2002/11/25 17:43:26  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 9 - 6
compiler/i386/n386mem.pas

@@ -67,7 +67,7 @@ implementation
       begin
         inherited pass_2;
         { for use of other segments }
-        if left.location.reference.segment<>R_NO then
+        if left.location.reference.segment.enum<>R_NO then
           location.segment:=left.location.reference.segment;
       end;
 
@@ -82,7 +82,7 @@ implementation
       begin
          inherited pass_2;
          if tpointerdef(left.resulttype.def).is_far then
-          location.reference.segment:=R_FS;
+          location.reference.segment.enum:=R_FS;
       end;
 
 
@@ -95,11 +95,11 @@ implementation
          l2 : integer;
        begin
          { Optimized for x86 to use the index register and scalefactor }
-         if location.reference.index=R_NO then
+         if location.reference.index.enum=R_NO then
           begin
             { no preparations needed }
           end
-         else if location.reference.base=R_NO then
+         else if location.reference.base.enum=R_NO then
           begin
             case location.reference.scalefactor of
              2 : cg.a_op_const_reg(exprasmlist,OP_SHL,1,location.reference.index);
@@ -135,7 +135,7 @@ implementation
         inherited pass_2;
 
         if nf_memseg in flags then
-          location.reference.segment:=R_FS;
+          location.reference.segment.enum:=R_FS;
       end;
 
 
@@ -146,7 +146,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.47  2002-12-03 22:14:12  carl
+  Revision 1.48  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.47  2002/12/03 22:14:12  carl
      + use FPC_CHECKPOINTER once again
 
   Revision 1.46  2002/11/25 17:43:27  peter

+ 30 - 13
compiler/i386/n386obj.pas

@@ -110,38 +110,47 @@ procedure ti386classheader.cgintfwrapper(asmlist: TAAsmoutput; procdef: tprocdef
   procedure getselftoeax(offs: longint);
   var
     href : treference;
+    r:Tregister;
   begin
     { mov offset(%esp),%eax }
-    reference_reset_base(href,R_ESP,getselfoffsetfromsp(procdef));
-    cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,R_EAX);
+    r.enum:=R_ESP;
+    reference_reset_base(href,r,getselfoffsetfromsp(procdef));
+    r.enum:=R_EAX;
+    cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,r);
   end;
 
   procedure loadvmttoeax;
   var
     href : treference;
+    r:Tregister;
   begin
     checkvirtual;
     { mov  0(%eax),%eax ; load vmt}
-    reference_reset_base(href,R_EAX,0);
-    emit_ref_reg(A_MOV,S_L,href,R_EAX);
+    r.enum:=R_EAX;
+    reference_reset_base(href,r,0);
+    emit_ref_reg(A_MOV,S_L,href,r);
   end;
 
   procedure op_oneaxmethodaddr(op: TAsmOp);
   var
     href : treference;
+    r:Tregister;
   begin
     { call/jmp  vmtoffs(%eax) ; method offs }
-    reference_reset_base(href,R_EAX,procdef._class.vmtmethodoffset(procdef.extnumber));
+    r.enum:=R_EAX;
+    reference_reset_base(href,r,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 }
-    reference_reset_base(href,R_EAX,procdef._class.vmtmethodoffset(procdef.extnumber));
-    emit_ref_reg(A_MOV,S_L,href,R_EAX);
+    r.enum:=R_EAX;
+    reference_reset_base(href,r,procdef._class.vmtmethodoffset(procdef.extnumber));
+    emit_ref_reg(A_MOV,S_L,href,r);
   end;
 
 var
@@ -149,6 +158,7 @@ var
   lab : tasmsymbol;
   make_global : boolean;
   href : treference;
+  r:Tregister;
 begin
   if procdef.proctypeoption<>potype_none then
     Internalerror(200006137);
@@ -193,16 +203,20 @@ begin
   { case 3 }
   else if [po_virtualmethod,po_saveregisters]*procdef.procoptions=[po_virtualmethod,po_saveregisters] then
     begin
-      emit_reg(A_PUSH,S_L,R_EBX); { allocate space for address}
-      emit_reg(A_PUSH,S_L,R_EAX);
+      r.enum:=R_EBX;
+      emit_reg(A_PUSH,S_L,r); { allocate space for address}
+      r.enum:=R_EAX;
+      emit_reg(A_PUSH,S_L,r);
       getselftoeax(8);
       loadvmttoeax;
       loadmethodoffstoeax;
       { mov %eax,4(%esp) }
-      reference_reset_base(href,R_ESP,4);
-      emit_reg_ref(A_MOV,S_L,R_EAX,href);
+      r.enum:=R_ESP;
+      reference_reset_base(href,r,4);
+      r.enum:=R_EAX;
+      emit_reg_ref(A_MOV,S_L,r,href);
       { pop  %eax }
-      emit_reg(A_POP,S_L,R_EAX);
+      emit_reg(A_POP,S_L,r);
       { ret  ; jump to the address }
       emit_none(A_RET,S_L);
     end
@@ -228,7 +242,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.15  2002-08-11 14:32:30  peter
+  Revision 1.16  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.15  2002/08/11 14:32:30  peter
     * renamed current_library to objectlibrary
 
   Revision 1.14  2002/08/11 13:24:17  peter

+ 8 - 5
compiler/i386/n386opt.pas

@@ -110,7 +110,7 @@ begin
     end;
   secondpass(right);
   { special case for string := string + char (JM) }
-  hreg := R_NO;
+  hreg.enum := R_NO;
 
   { we have to load the char before checking the length, because we }
   { may need registers from the reference                           }
@@ -156,8 +156,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 <> R_NO) and
-     (href2.index <> R_NO) then
+  if (href2.base.enum <> R_NO) and
+     (href2.index.enum <> R_NO) then
     begin
       { they're not free, so add the base reg to       }
       { the string length (since the index can         }
@@ -167,7 +167,7 @@ begin
     end
   else
     { at least one is still free, so put EDI there }
-    if href2.base = R_NO then
+    if href2.base.enum = R_NO then
       href2.base := lengthreg
     else
       begin
@@ -248,7 +248,10 @@ end.
 
 {
   $Log$
-  Revision 1.26  2002-11-25 17:43:27  peter
+  Revision 1.27  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.26  2002/11/25 17:43:27  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 14 - 7
compiler/i386/n386set.pas

@@ -108,6 +108,7 @@ implementation
          adjustment : longint;
          pushedregs : tmaybesave;
          l,l2       : tasmlabel;
+         r          : Tregister;
 {$ifdef CORRECT_SET_IN_FPC}
          AM         : tasmop;
 {$endif CORRECT_SET_IN_FPC}
@@ -275,16 +276,17 @@ 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 (pleftreg <> R_EDI) and
+                      if (pleftreg.enum <> R_EDI) and
                          (left.location.loc = LOC_CREGISTER) then
                         begin
+                          r.enum:=R_EDI;
                           rg.ungetregister(exprasmlist,pleftreg);
                           rg.getexplicitregisterint(exprasmlist,R_EDI);
                           reference_reset_base(href,pleftreg,-setparts[i].start);
-                          emit_ref_reg(A_LEA,S_L,href,R_EDI);
+                          emit_ref_reg(A_LEA,S_L,href,r);
                           { only now change pleftreg since previous value is }
                           { still used in previous instruction               }
-                          pleftreg := R_EDI;
+                          pleftreg := r;
                           opsize := S_L;
                         end
                       else
@@ -347,7 +349,8 @@ implementation
                else
                  begin
                    reference_release(exprasmlist,left.location.reference);
-                   rg.ungetregister(exprasmlist,R_EDI);
+                   r.enum:=R_EDI;
+                   rg.ungetregister(exprasmlist,r);
                  end;
              end;
           end
@@ -394,9 +397,10 @@ 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_EDI;
                       rg.getexplicitregisterint(exprasmlist,R_EDI);
-                      emit_ref_reg(A_MOVZX,S_BL,left.location.reference,R_EDI);
-                      hr:=R_EDI;
+                      emit_ref_reg(A_MOVZX,S_BL,left.location.reference,r);
+                      hr:=r;
                       location_release(exprasmlist,left.location);
                     end;
                   end;
@@ -706,7 +710,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.45  2002-11-25 17:43:27  peter
+  Revision 1.46  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.45  2002/11/25 17:43:27  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 93 - 84
compiler/i386/popt386.pas

@@ -26,7 +26,7 @@ Unit POpt386;
 
 Interface
 
-Uses Aasmbase,aasmtai,aasmcpu;
+Uses Aasmbase,aasmtai,aasmcpu,verbose;
 
 Procedure PrePeepHoleOpts(AsmL: TAAsmOutput; BlockStart, BlockEnd: Tai);
 Procedure PeepHoleOptPass1(AsmL: TAAsmOutput; BlockStart, BlockEnd: Tai);
@@ -43,12 +43,14 @@ Uses
 {$endif finaldestdebug}
   cpuinfo,cpubase,DAOpt386,cginfo,rgobj;
 
-Function RegUsedAfterInstruction(Reg: TRegister; p: Tai; Var UsedRegs: TRegSet): Boolean;
+Function RegUsedAfterInstruction(Reg: Tregister; p: Tai; Var UsedRegs: TRegSet): Boolean;
 Begin
+  if reg.enum>lastreg then
+    internalerror(200301081);
   reg := reg32(reg);
   UpdateUsedRegs(UsedRegs, Tai(p.Next));
   RegUsedAfterInstruction :=
-    (Reg in UsedRegs) and
+    (Reg.enum in UsedRegs) and
     (not(getNextInstruction(p,p)) or
      not(regLoadedWithNewValue(reg,false,p)));
 End;
@@ -73,9 +75,9 @@ begin
          (hp2.typ = ait_instruction) and
          ((Taicpu(hp2).opcode = A_LEAVE) or
           (Taicpu(hp2).opcode = A_RET)) and
-         (Taicpu(p).oper[0].ref^.Base = procinfo.FramePointer) and
+         (Taicpu(p).oper[0].ref^.Base.enum = procinfo.FramePointer.enum) and
          (Taicpu(p).oper[0].ref^.Offset >= procinfo.Return_Offset) and
-         (Taicpu(p).oper[0].ref^.Index = R_NO) then
+         (Taicpu(p).oper[0].ref^.Index.enum = R_NO) then
         begin
           asml.remove(p);
           asml.remove(hp1);
@@ -213,7 +215,7 @@ Begin
                                     If (Taicpu(p).oper[2].typ = Top_Reg)
                                       Then
                                         Begin
-                                          TmpRef.base := R_NO;
+                                          TmpRef.base.enum := R_NO;
                                           hp1 :=  Taicpu.op_ref_reg(A_LEA, S_L, TmpRef,
                                             Taicpu(p).oper[2].reg);
                                         End
@@ -291,7 +293,7 @@ Begin
                                        End
                                      Else
                                        Begin
-                                         TmpRef.base := R_NO;
+                                         TmpRef.base.enum := R_NO;
                                          TmpRef.ScaleFactor := 4;
                                          hp1 :=  Taicpu.op_ref_reg(A_LEA, S_L, TmpRef, Taicpu(p).oper[1].reg);
                                        End;
@@ -300,7 +302,7 @@ Begin
                                      TmpRef.Index := Taicpu(p).oper[1].reg;
                                      If (Taicpu(p).oper[2].typ = Top_Reg) Then
                                        Begin
-                                         TmpRef.base := R_NO;
+                                         TmpRef.base.enum := R_NO;
                                          TmpRef.ScaleFactor := 4;
                                          hp1 :=  Taicpu.op_ref_reg(A_LEA, S_L, TmpRef, Taicpu(p).oper[2].reg);
                                        End
@@ -386,7 +388,7 @@ Begin
               A_XOR:
                 If (Taicpu(p).oper[0].typ = top_reg) And
                    (Taicpu(p).oper[1].typ = top_reg) And
-                   (Taicpu(p).oper[0].reg = Taicpu(p).oper[1].reg) then
+                   (Taicpu(p).oper[0].reg.enum = Taicpu(p).oper[1].reg.enum) then
                  { temporarily change this to 'mov reg,0' to make it easier }
                  { for the CSE. Will be changed back in pass 2              }
                   begin
@@ -415,6 +417,7 @@ Var
   UsedRegs, TmpUsedRegs: TRegSet;
 
   TmpBool1, TmpBool2: Boolean;
+  r:Tregister;
 
   Function SkipLabels(hp: Tai; var hp2: Tai): boolean;
   {skips all labels and returns the next "real" instruction}
@@ -543,7 +546,7 @@ Var
       Case Taicpu(hp1).opcode Of
         A_DEC:
           If (Taicpu(hp1).oper[0].typ = top_reg) And
-             (Taicpu(hp1).oper[0].reg = Taicpu(p).oper[1].reg) Then
+             (Taicpu(hp1).oper[0].reg.enum = Taicpu(p).oper[1].reg.enum) Then
             Begin
               Taicpu(p).LoadConst(0,Taicpu(p).oper[0].val+1);
               asml.Remove(hp1);
@@ -552,7 +555,7 @@ Var
          A_SUB:
            If (Taicpu(hp1).oper[0].typ = top_const) And
               (Taicpu(hp1).oper[1].typ = top_reg) And
-              (Taicpu(hp1).oper[1].reg = Taicpu(p).oper[1].reg) Then
+              (Taicpu(hp1).oper[1].reg.enum = Taicpu(p).oper[1].reg.enum) Then
              Begin
                Taicpu(p).LoadConst(0,Taicpu(p).oper[0].val+Taicpu(hp1).oper[0].val);
                asml.Remove(hp1);
@@ -561,7 +564,7 @@ Var
          A_ADD:
            If (Taicpu(hp1).oper[0].typ = top_const) And
               (Taicpu(hp1).oper[1].typ = top_reg) And
-              (Taicpu(hp1).oper[1].reg = Taicpu(p).oper[1].reg) Then
+              (Taicpu(hp1).oper[1].reg.enum = Taicpu(p).oper[1].reg.enum) Then
              Begin
                Taicpu(p).LoadConst(0,AWord(int64(Taicpu(p).oper[0].val)-int64(Taicpu(hp1).oper[0].val)));
                asml.Remove(hp1);
@@ -655,13 +658,13 @@ Begin
               If (Taicpu(p).oper[l].typ = top_ref) Then
                 With Taicpu(p).oper[l].ref^ Do
                   Begin
-                    If (base = R_NO) And
-                       (index <> R_NO) And
+                    If (base.enum = R_NO) And
+                       (index.enum <> R_NO) And
                        (scalefactor in [0,1])
                       Then
                         Begin
                           base := index;
-                          index := R_NO
+                          index.enum := R_NO
                         End
                    End;
             Case Taicpu(p).opcode Of
@@ -674,7 +677,7 @@ Begin
                      (Taicpu(hp1).opcode = A_AND) And
                      (Taicpu(hp1).oper[0].typ = top_const) And
                      (Taicpu(hp1).oper[1].typ = top_reg) And
-                     (Taicpu(p).oper[1].reg = Taicpu(hp1).oper[1].reg)
+                     (Taicpu(p).oper[1].reg.enum = Taicpu(hp1).oper[1].reg.enum)
                     Then
 {change "and const1, reg; and const2, reg" to "and (const1 and const2), reg"}
                       Begin
@@ -690,7 +693,7 @@ Begin
                          (hp1.typ = ait_instruction) And
                          (Taicpu(hp1).is_jmp) and
                          (Taicpu(hp1).opcode<>A_JMP) and
-                         Not(Taicpu(p).oper[1].reg in UsedRegs) Then
+                         Not(Taicpu(p).oper[1].reg.enum in UsedRegs) Then
                         Taicpu(p).opcode := A_TEST;
                 End;
               A_CMP:
@@ -738,8 +741,8 @@ Begin
                      (hp1.typ = Ait_Instruction) And
                      (Taicpu(hp1).oper[0].typ = top_reg) And
                      (Taicpu(hp1).oper[1].typ = top_reg) And
-                     (Taicpu(hp1).oper[0].reg = R_ST) And
-                     (Taicpu(hp1).oper[1].reg = R_ST1) Then
+                     (Taicpu(hp1).oper[0].reg.enum = R_ST) And
+                     (Taicpu(hp1).oper[1].reg.enum = R_ST1) Then
                      { change                        to
                          fld      reg               fxxx reg,st
                          fxxxp    st, st1 (hp1)
@@ -759,7 +762,7 @@ Begin
                                  A_FDIVRP: Taicpu(hp1).opcode := A_FDIV;
                                End;
                                Taicpu(hp1).oper[0].reg := Taicpu(p).oper[0].reg;
-                               Taicpu(hp1).oper[1].reg := R_ST;
+                               Taicpu(hp1).oper[1].reg.enum := R_ST;
                                asml.Remove(p);
                                p.free;
                                p := hp1;
@@ -774,8 +777,8 @@ Begin
                      (Taicpu(hp2).oper[0].typ = top_reg) And
                      (Taicpu(hp2).oper[1].typ = top_reg) And
                      (Taicpu(p).opsize in [S_FS, S_FL]) And
-                     (Taicpu(hp2).oper[0].reg = R_ST) And
-                     (Taicpu(hp2).oper[1].reg = R_ST1) Then
+                     (Taicpu(hp2).oper[0].reg.enum = R_ST) And
+                     (Taicpu(hp2).oper[1].reg.enum = R_ST1) Then
                     If GetLastInstruction(p, hp1) And
                        (hp1.typ = Ait_Instruction) And
                        ((Taicpu(hp1).opcode = A_FLD) Or
@@ -799,7 +802,7 @@ Begin
                             Taicpu(hp2).opcode := A_FADD
                           Else
                             Taicpu(hp2).opcode := A_FMUL;
-                          Taicpu(hp2).oper[1].reg := R_ST;
+                          Taicpu(hp2).oper[1].reg.enum := R_ST;
                         End
                       Else
                       { change              to
@@ -807,7 +810,8 @@ Begin
                           fld     mem1 (p)     fld      st}
                         Begin
                           Taicpu(p).changeopsize(S_FL);
-                          Taicpu(p).loadreg(0,R_ST);
+                          r.enum:=R_ST;
+                          Taicpu(p).loadreg(0,r);
                         End
                     Else
                       Begin
@@ -840,12 +844,12 @@ Begin
                 Begin
                 {removes seg register prefixes from LEA operations, as they
                  don't do anything}
-                 Taicpu(p).oper[0].ref^.Segment := R_NO;
+                 Taicpu(p).oper[0].ref^.Segment.enum := R_NO;
                 {changes "lea (%reg1), %reg2" into "mov %reg1, %reg2"}
-                  If (Taicpu(p).oper[0].ref^.Base In [R_EAX..R_EDI]) And
-                     (Taicpu(p).oper[0].ref^.Index = R_NO) And
+                  If (Taicpu(p).oper[0].ref^.Base.enum In [R_EAX..R_EDI]) And
+                     (Taicpu(p).oper[0].ref^.Index.enum = R_NO) And
                      (Not(Assigned(Taicpu(p).oper[0].ref^.Symbol))) Then
-                    If (Taicpu(p).oper[0].ref^.Base <> Taicpu(p).oper[1].reg)
+                    If (Taicpu(p).oper[0].ref^.Base.enum <> Taicpu(p).oper[1].reg.enum)
                        and (Taicpu(p).oper[0].ref^.Offset = 0)
                        Then
                         Begin
@@ -867,7 +871,7 @@ Begin
                        End
                       else
                         with Taicpu(p).oper[0].ref^ do
-                          if (Base = Taicpu(p).oper[1].reg) then
+                          if (Base.enum = Taicpu(p).oper[1].reg.enum) then
                             begin
                               l := offset+offsetfixup;
                               if (l=1) then
@@ -894,12 +898,12 @@ Begin
                 Begin
                   TmpUsedRegs := UsedRegs;
                   If (Taicpu(p).oper[1].typ = top_reg) And
-                     (Taicpu(p).oper[1].reg In [R_EAX, R_EBX, R_EDX, R_EDI]) And
+                     (Taicpu(p).oper[1].reg.enum In [R_EAX, R_EBX, R_EDX, R_EDI]) And
                      GetNextInstruction(p, hp1) And
                      (Tai(hp1).typ = ait_instruction) And
                      (Taicpu(hp1).opcode = A_MOV) And
                      (Taicpu(hp1).oper[0].typ = top_reg) And
-                     (Taicpu(hp1).oper[0].reg = Taicpu(p).oper[1].reg)
+                     (Taicpu(hp1).oper[0].reg.enum = Taicpu(p).oper[1].reg.enum)
                     Then
                 {we have "mov x, %treg; mov %treg, y}
                       If not(RegUsedAfterInstruction(Taicpu(p).oper[1].reg, hp1, TmpUsedRegs)) then
@@ -935,14 +939,14 @@ Begin
                          GetNextInstruction(p,hp1) And
                          (Tai(hp1).typ = ait_instruction) And
                          (Taicpu(hp1).oper[0].typ = top_reg) And
-                         (Taicpu(hp1).oper[0].reg = Taicpu(p).oper[1].reg)
+                         (Taicpu(hp1).oper[0].reg.enum = Taicpu(p).oper[1].reg.enum)
                         Then
                   {we have "mov %reg1, %reg2; XXX %reg2, ???"}
                           Begin
                             If ((Taicpu(hp1).opcode = A_OR) Or
                                 (Taicpu(hp1).opcode = A_TEST)) And
                                (Taicpu(hp1).oper[1].typ = top_reg) And
-                               (Taicpu(hp1).oper[0].reg = Taicpu(hp1).oper[1].reg)
+                               (Taicpu(hp1).oper[0].reg.enum = Taicpu(hp1).oper[1].reg.enum)
                               Then
                    {we have "mov %reg1, %reg2; test/or %reg2, %reg2"}
                                 Begin
@@ -990,9 +994,9 @@ Begin
                               If ((Taicpu(hp1).opcode = A_LEAVE) Or
                                   (Taicpu(hp1).opcode = A_RET)) And
                                  (Taicpu(p).oper[1].typ = top_ref) And
-                                 (Taicpu(p).oper[1].ref^.base = procinfo.FramePointer) And
+                                 (Taicpu(p).oper[1].ref^.base.enum = procinfo.FramePointer.enum) And
                                  (Taicpu(p).oper[1].ref^.offset >= procinfo.Return_Offset) And
-                                 (Taicpu(p).oper[1].ref^.index = R_NO) And
+                                 (Taicpu(p).oper[1].ref^.index.enum = R_NO) And
                                  (Taicpu(p).oper[0].typ = top_reg)
                                 Then
                                   Begin
@@ -1054,7 +1058,7 @@ Begin
                                          (Taicpu(hp2).oper[0].typ = TOp_Ref) And
                                          (Taicpu(hp2).oper[1].typ = TOp_Reg) And
                                          RefsEqual(Taicpu(hp2).oper[0].ref^, Taicpu(p).oper[1].ref^) And
-                                         (Taicpu(hp2).oper[1].reg = Taicpu(p).oper[0].reg) And
+                                         (Taicpu(hp2).oper[1].reg .enum= Taicpu(p).oper[0].reg.enum) And
                                          Not(RegUsedAfterInstruction(Taicpu(p).oper[0].reg, hp2, TmpUsedRegs)) Then
                            { change                   to
                               mov reg1, mem1           mov reg1, mem1
@@ -1072,11 +1076,12 @@ Begin
                               Else
                                 Begin
                                   tmpUsedRegs := UsedRegs;
+                                  r.enum:=R_EDI;
                                   If GetNextInstruction(hp1, hp2) And
                                      (Taicpu(p).oper[0].typ = top_ref) And
                                      (Taicpu(p).oper[1].typ = top_reg) And
                                      (Taicpu(hp1).oper[0].typ = top_reg) And
-                                     (Taicpu(hp1).oper[0].reg = Taicpu(p).oper[1].reg) And
+                                     (Taicpu(hp1).oper[0].reg.enum = Taicpu(p).oper[1].reg.enum) And
                                      (Taicpu(hp1).oper[1].typ = top_ref) And
                                      (Tai(hp2).typ = ait_instruction) And
                                      (Taicpu(hp2).opcode = A_MOV) And
@@ -1085,8 +1090,8 @@ Begin
                                      (Taicpu(hp2).oper[0].typ = top_ref) And
                                      RefsEqual(Taicpu(hp2).oper[0].ref^, Taicpu(hp1).oper[1].ref^)  Then
                                     If not regInRef(Taicpu(hp2).oper[1].reg,Taicpu(hp2).oper[0].ref^) and
-                                       (Taicpu(p).oper[1].reg in [R_DI,R_EDI]) and
-                                       not(RegUsedAfterInstruction(R_EDI,hp1,tmpUsedRegs)) Then
+                                       (Taicpu(p).oper[1].reg.enum in [R_DI,R_EDI]) and
+                                       not(RegUsedAfterInstruction(r,hp1,tmpUsedRegs)) Then
                              {   mov mem1, %edi
                                  mov %edi, mem2
                                  mov mem2, reg2
@@ -1101,7 +1106,7 @@ Begin
                                         hp2.free;
                                       End
                                     Else
-                                      If (Taicpu(p).oper[1].reg <> Taicpu(hp2).oper[1].reg) And
+                                      If (Taicpu(p).oper[1].reg.enum <> Taicpu(hp2).oper[1].reg.enum) And
                                          not(RegInRef(Taicpu(p).oper[1].reg,Taicpu(p).oper[0].ref^)) And
                                          not(RegInRef(Taicpu(hp2).oper[1].reg,Taicpu(hp2).oper[0].ref^))
                                         Then
@@ -1126,13 +1131,13 @@ Begin
                                           Taicpu(hp2).LoadRef(1,Taicpu(hp2).oper[0].ref^);
                                           Taicpu(hp2).LoadReg(0,Taicpu(p).oper[1].reg);
                                           allocRegBetween(asmL,Taicpu(p).oper[1].reg,p,hp2);
-                                          if (Taicpu(p).oper[0].ref^.base in (rg.usableregsint+[R_EDI])) then
+                                          if (Taicpu(p).oper[0].ref^.base.enum in (rg.usableregsint+[R_EDI])) then
                                             allocRegBetween(asmL,Taicpu(p).oper[0].ref^.base,p,hp2);
-                                          if (Taicpu(p).oper[0].ref^.index in (rg.usableregsint+[R_EDI])) then
+                                          if (Taicpu(p).oper[0].ref^.index.enum in (rg.usableregsint+[R_EDI])) then
                                             allocRegBetween(asmL,Taicpu(p).oper[0].ref^.index,p,hp2);
                                         End
                                       Else
-                                        If (Taicpu(hp1).Oper[0].reg <> Taicpu(hp2).Oper[1].reg) Then
+                                        If (Taicpu(hp1).Oper[0].reg.enum <> Taicpu(hp2).Oper[1].reg.enum) Then
                                           begin
                                             Taicpu(hp2).LoadReg(0,Taicpu(hp1).Oper[0].reg);
                                             allocRegBetween(asmL,Taicpu(p).oper[1].reg,p,hp2);
@@ -1193,7 +1198,7 @@ Begin
                      (Taicpu(hp1).opcode = A_AND) And
                      (Taicpu(hp1).oper[0].typ = top_const) And
                      (Taicpu(hp1).oper[1].typ = top_reg) And
-                     (Taicpu(hp1).oper[1].reg = Taicpu(p).oper[1].reg)
+                     (Taicpu(hp1).oper[1].reg.enum = Taicpu(p).oper[1].reg.enum)
                     Then
                       Case Taicpu(p).opsize Of
                         S_BL, S_BW:
@@ -1216,7 +1221,7 @@ Begin
                       Case Taicpu(p).opsize of
                         S_BW:
                           Begin
-                            If (rg.makeregsize(Taicpu(p).oper[0].reg,OS_16)=Taicpu(p).oper[1].reg) And
+                            If (rg.makeregsize(Taicpu(p).oper[0].reg,OS_16).enum=Taicpu(p).oper[1].reg.enum) And
                                Not(CS_LittleSize In aktglobalswitches)
                               Then
                                 {Change "movzbw %al, %ax" to "andw $0x0ffh, %ax"}
@@ -1231,7 +1236,7 @@ Begin
                                    (Taicpu(hp1).opcode = A_AND) And
                                    (Taicpu(hp1).oper[0].typ = top_const) And
                                    (Taicpu(hp1).oper[1].typ = top_reg) And
-                                   (Taicpu(hp1).oper[1].reg = Taicpu(p).oper[1].reg)
+                                   (Taicpu(hp1).oper[1].reg.enum = Taicpu(p).oper[1].reg.enum)
                                   Then
                                     {Change "movzbw %reg1, %reg2; andw $const, %reg2"
                                      to "movw %reg1, reg2; andw $(const1 and $ff), %reg2"}
@@ -1244,7 +1249,7 @@ Begin
                           End;
                         S_BL:
                           Begin
-                            If (rg.makeregsize(Taicpu(p).oper[0].reg,OS_32)=Taicpu(p).oper[1].reg) And
+                            If (rg.makeregsize(Taicpu(p).oper[0].reg,OS_32).enum=Taicpu(p).oper[1].reg.enum) And
                                Not(CS_LittleSize in aktglobalswitches)
                               Then
                                 {Change "movzbl %al, %eax" to "andl $0x0ffh, %eax"}
@@ -1259,7 +1264,7 @@ Begin
                                    (Taicpu(hp1).opcode = A_AND) And
                                    (Taicpu(hp1).oper[0].typ = top_const) And
                                    (Taicpu(hp1).oper[1].typ = top_reg) And
-                                   (Taicpu(hp1).oper[1].reg = Taicpu(p).oper[1].reg)
+                                   (Taicpu(hp1).oper[1].reg.enum = Taicpu(p).oper[1].reg.enum)
                                   Then
                                    {Change "movzbl %reg1, %reg2; andl $const, %reg2"
                                     to "movl %reg1, reg2; andl $(const1 and $ff), %reg2"}
@@ -1272,7 +1277,7 @@ Begin
                           End;
                         S_WL:
                           Begin
-                            If (rg.makeregsize(Taicpu(p).oper[0].reg,OS_32)=Taicpu(p).oper[1].reg) And
+                            If (rg.makeregsize(Taicpu(p).oper[0].reg,OS_32).enum=Taicpu(p).oper[1].reg.enum) And
                                Not(CS_LittleSize In aktglobalswitches)
                               Then
                                {Change "movzwl %ax, %eax" to "andl $0x0ffffh, %eax"}
@@ -1287,7 +1292,7 @@ Begin
                                    (Taicpu(hp1).opcode = A_AND) And
                                    (Taicpu(hp1).oper[0].typ = top_const) And
                                    (Taicpu(hp1).oper[1].typ = top_reg) And
-                                   (Taicpu(hp1).oper[1].reg = Taicpu(p).oper[1].reg)
+                                   (Taicpu(hp1).oper[1].reg.enum = Taicpu(p).oper[1].reg.enum)
                                   Then
                                     {Change "movzwl %reg1, %reg2; andl $const, %reg2"
                                      to "movl %reg1, reg2; andl $(const1 and $ffff), %reg2"}
@@ -1307,7 +1312,7 @@ Begin
                                (Taicpu(hp1).opcode = A_AND) And
                                (Taicpu(hp1).oper[0].typ = Top_Const) And
                                (Taicpu(hp1).oper[1].typ = Top_Reg) And
-                               (Taicpu(hp1).oper[1].reg = Taicpu(p).oper[1].reg) Then
+                               (Taicpu(hp1).oper[1].reg.enum = Taicpu(p).oper[1].reg.enum) Then
                               Begin
                                 Taicpu(p).opcode := A_MOV;
                                 Case Taicpu(p).opsize Of
@@ -1359,7 +1364,7 @@ Begin
                                (hp1.typ = ait_instruction) and
                                (Taicpu(hp1).opcode = A_PUSH) and
                                (Taicpu(hp1).oper[0].typ = top_reg) and
-                               (Taicpu(hp1).oper[0].reg = Taicpu(hp2).oper[0].reg) do
+                               (Taicpu(hp1).oper[0].reg.enum = Taicpu(hp2).oper[0].reg.enum) do
                            begin
                              { change it to a two op operation }
                              Taicpu(hp2).oper[1].typ:=top_none;
@@ -1367,7 +1372,7 @@ Begin
                              Taicpu(hp2).opcode := A_MOV;
                              Taicpu(hp2).Loadoper(1,Taicpu(hp1).oper[0]);
                              reference_reset(tmpref);
-                             tmpRef.base := STACK_POINTER_REG;
+                             tmpRef.base .enum:= STACK_POINTER_REG;
                              tmpRef.offset := l;
                              Taicpu(hp2).loadRef(0,tmpRef);
                              hp4 := hp1;
@@ -1396,7 +1401,7 @@ Begin
                          (Tai(hp1).typ=ait_instruction) and
                          (Taicpu(hp1).opcode=A_PUSH) and
                          (Taicpu(hp1).oper[0].typ = top_reg) And
-                         (Taicpu(hp1).oper[0].reg=Taicpu(p).oper[0].reg) then
+                         (Taicpu(hp1).oper[0].reg.enum=Taicpu(p).oper[0].reg.enum) then
                         Begin
                           { change it to a two op operation }
                           Taicpu(p).oper[1].typ:=top_none;
@@ -1404,7 +1409,7 @@ Begin
                           Taicpu(p).opcode := A_MOV;
                           Taicpu(p).Loadoper(1,Taicpu(p).oper[0]);
                           reference_reset(tmpref);
-                          TmpRef.base := R_ESP;
+                          TmpRef.base.enum := R_ESP;
                           Taicpu(p).LoadRef(0,TmpRef);
                           asml.Remove(hp1);
                           hp1.free;
@@ -1448,11 +1453,11 @@ Begin
                               ((((Taicpu(hp1).opcode = A_ADD) Or
                                  (Taicpu(hp1).opcode = A_SUB)) And
                                 (Taicpu(hp1).oper[1].typ = Top_Reg) And
-                                (Taicpu(hp1).oper[1].reg = Taicpu(p).oper[1].reg)) or
+                                (Taicpu(hp1).oper[1].reg.enum = Taicpu(p).oper[1].reg.enum)) or
                                (((Taicpu(hp1).opcode = A_INC) or
                                  (Taicpu(hp1).opcode = A_DEC)) and
                                 (Taicpu(hp1).oper[0].typ = Top_Reg) and
-                                (Taicpu(hp1).oper[0].reg = Taicpu(p).oper[1].reg))) Do
+                                (Taicpu(hp1).oper[0].reg.enum = Taicpu(p).oper[1].reg.enum))) Do
                           Begin
                             TmpBool1 := False;
                             If (Taicpu(hp1).oper[0].typ = Top_Const)
@@ -1472,7 +1477,7 @@ Begin
                             Else
                               If (Taicpu(hp1).oper[0].typ = Top_Reg) And
                                  (((Taicpu(hp1).opcode = A_ADD) And
-                                   (TmpRef.base = R_NO)) or
+                                   (TmpRef.base.enum = R_NO)) or
                                   (Taicpu(hp1).opcode = A_INC) or
                                   (Taicpu(hp1).opcode = A_DEC)) Then
                                 Begin
@@ -1552,8 +1557,8 @@ Begin
                      (hp2.typ = ait_instruction) And
                      ((Taicpu(hp2).opcode = A_LEAVE) or
                       (Taicpu(hp2).opcode = A_RET)) And
-                     (Taicpu(p).oper[0].ref^.Base = procinfo.FramePointer) And
-                     (Taicpu(p).oper[0].ref^.Index = R_NO) And
+                     (Taicpu(p).oper[0].ref^.Base.enum = procinfo.FramePointer.enum) And
+                     (Taicpu(p).oper[0].ref^.Index.enum = R_NO) And
                      (Taicpu(p).oper[0].ref^.Offset >= procinfo.Return_Offset) And
                      (hp1.typ = ait_instruction) And
                      (Taicpu(hp1).opcode = A_MOV) And
@@ -1574,22 +1579,23 @@ Begin
                   If (Taicpu(p).oper[0].typ = top_const) And
                      (Taicpu(p).oper[1].typ = top_reg) Then
                     If (Taicpu(p).oper[0].val = 2) And
-                       (Taicpu(p).oper[1].reg = R_ESP) and
+                       (Taicpu(p).oper[1].reg.enum = R_ESP) and
                        { Don't do the sub/push optimization if the sub }
                        { comes from setting up the stack frame (JM)    }
                        (not getLastInstruction(p,hp1) or
                         (hp1.typ <> ait_instruction) or
                         (Taicpu(hp1).opcode <> A_MOV) or
                         (Taicpu(hp1).oper[0].typ <> top_reg) or
-                        (Taicpu(hp1).oper[0].reg <> R_ESP) or
+                        (Taicpu(hp1).oper[0].reg.enum <> R_ESP) or
                         (Taicpu(hp1).oper[1].typ <> top_reg) or
-                        (Taicpu(hp1).oper[1].reg <> R_EBP)) then
+                        (Taicpu(hp1).oper[1].reg.enum <> R_EBP)) then
                       Begin
                         hp1 := Tai(p.next);
+                        r.enum:=R_ESP;
                         While Assigned(hp1) And
                               (Tai(hp1).typ In [ait_instruction]+SkipInstr) And
-                               not regReadByInstruction(R_ESP,hp1) and
-                               not regModifiedByInstruction(R_ESP,hp1) do
+                               not regReadByInstruction(r,hp1) and
+                               not regModifiedByInstruction(r,hp1) do
                           hp1 := Tai(hp1.next);
                         If Assigned(hp1) And
                            (Tai(hp1).typ = ait_instruction) And
@@ -1613,7 +1619,7 @@ Begin
                A_XOR:
                  If (Taicpu(p).oper[0].typ = top_reg) And
                     (Taicpu(p).oper[1].typ = top_reg) And
-                    (Taicpu(p).oper[0].reg = Taicpu(p).oper[1].reg) then
+                    (Taicpu(p).oper[0].reg.enum = Taicpu(p).oper[1].reg.enum) then
                   { temporarily change this to 'mov reg,0' to make it easier }
                   { for the CSE. Will be changed back in pass 2              }
                    begin
@@ -1641,7 +1647,7 @@ Begin
     end;
 end;
 
-function isFoldableArithOp(hp1: Taicpu; reg: tregister): boolean;
+function isFoldableArithOp(hp1: Taicpu; reg: Toldregister): boolean;
 begin
   IsFoldableArithOp := False;
   case hp1.opcode of
@@ -1649,13 +1655,13 @@ begin
       isFoldableArithOp :=
         ((Taicpu(hp1).oper[0].typ = top_const) or
          ((Taicpu(hp1).oper[0].typ = top_reg) and
-          (Taicpu(hp1).oper[0].reg <> reg))) and
+          (Taicpu(hp1).oper[0].reg.enum <> reg))) and
         (Taicpu(hp1).oper[1].typ = top_reg) and
-        (Taicpu(hp1).oper[1].reg = reg);
+        (Taicpu(hp1).oper[1].reg.enum = reg);
     A_INC,A_DEC:
       isFoldableArithOp :=
         (Taicpu(hp1).oper[0].typ = top_reg) and
-        (Taicpu(hp1).oper[0].reg = reg);
+        (Taicpu(hp1).oper[0].reg.enum = reg);
   end;
 end;
 
@@ -1801,13 +1807,13 @@ Begin
                      (Taicpu(p).oper[1].typ = top_reg) and
                      ((Taicpu(p).oper[2].typ = top_none) or
                       ((Taicpu(p).oper[2].typ = top_reg) and
-                       (Taicpu(p).oper[2].reg = Taicpu(p).oper[1].reg))) and
+                       (Taicpu(p).oper[2].reg.enum = Taicpu(p).oper[1].reg.enum))) and
                      getLastInstruction(p,hp1) and
                      (hp1.typ = ait_instruction) and
                      (Taicpu(hp1).opcode = A_MOV) and
                      (Taicpu(hp1).oper[0].typ = top_reg) and
                      (Taicpu(hp1).oper[1].typ = top_reg) and
-                     (Taicpu(hp1).oper[1].reg = Taicpu(p).oper[1].reg) then
+                     (Taicpu(hp1).oper[1].reg.enum = Taicpu(p).oper[1].reg.enum) then
               { change "mov reg1,reg2; imul y,reg2" to "imul y,reg1,reg2" }
                     begin
                       Taicpu(p).ops := 3;
@@ -1828,16 +1834,16 @@ Begin
                       (Taicpu(hp1).opcode = A_MOVSX)) And
                      (Taicpu(hp1).oper[0].typ = top_ref) And
                      (Taicpu(hp1).oper[1].typ = top_reg) And
-                     ((Taicpu(hp1).oper[0].ref^.Base = Taicpu(p).oper[1].reg) Or
-                      (Taicpu(hp1).oper[0].ref^.Index = Taicpu(p).oper[1].reg)) And
-                     (Reg32(Taicpu(hp1).oper[1].reg) = Taicpu(p).oper[1].reg) Then
+                     ((Taicpu(hp1).oper[0].ref^.Base.enum = Taicpu(p).oper[1].reg.enum) Or
+                      (Taicpu(hp1).oper[0].ref^.Index.enum = Taicpu(p).oper[1].reg.enum)) And
+                     (Reg32(Taicpu(hp1).oper[1].reg).enum = Taicpu(p).oper[1].reg.enum) Then
               {mov reg1, reg2
                mov/zx/sx (reg2, ..), reg2      to   mov/zx/sx (reg1, ..), reg2}
                     Begin
-                      If (Taicpu(hp1).oper[0].ref^.Base = Taicpu(p).oper[1].reg) Then
-                        Taicpu(hp1).oper[0].ref^.Base := Taicpu(p).oper[0].reg;
-                      If (Taicpu(hp1).oper[0].ref^.Index = Taicpu(p).oper[1].reg) Then
-                        Taicpu(hp1).oper[0].ref^.Index := Taicpu(p).oper[0].reg;
+                      If (Taicpu(hp1).oper[0].ref^.Base.enum = Taicpu(p).oper[1].reg.enum) Then
+                        Taicpu(hp1).oper[0].ref^.Base.enum := Taicpu(p).oper[0].reg.enum;
+                      If (Taicpu(hp1).oper[0].ref^.Index.enum = Taicpu(p).oper[1].reg.enum) Then
+                        Taicpu(hp1).oper[0].ref^.Index.enum := Taicpu(p).oper[0].reg.enum;
                       asml.Remove(p);
                       p.free;
                       p := hp1;
@@ -1846,12 +1852,12 @@ Begin
                   Else If (Taicpu(p).oper[0].typ = top_ref) And
                     GetNextInstruction(p,hp1) And
                     (hp1.typ = ait_instruction) And
-                    IsFoldableArithOp(Taicpu(hp1),Taicpu(p).oper[1].reg) And
+                    IsFoldableArithOp(Taicpu(hp1),Taicpu(p).oper[1].reg.enum) And
                     GetNextInstruction(hp1,hp2) And
                     (hp2.typ = ait_instruction) And
                     (Taicpu(hp2).opcode = A_MOV) And
                     (Taicpu(hp2).oper[0].typ = top_reg) And
-                    (Taicpu(hp2).oper[0].reg = Taicpu(p).oper[1].reg) And
+                    (Taicpu(hp2).oper[0].reg.enum = Taicpu(p).oper[1].reg.enum) And
                     (Taicpu(hp2).oper[1].typ = top_ref) Then
                    Begin
                      TmpUsedRegs := UsedRegs;
@@ -1965,8 +1971,8 @@ Begin
                         End
                       Else
                         If (Taicpu(p).oper[0].typ = top_ref) And
-                           (Taicpu(p).oper[0].ref^.base <> Taicpu(p).oper[1].reg) And
-                           (Taicpu(p).oper[0].ref^.index <> Taicpu(p).oper[1].reg) And
+                           (Taicpu(p).oper[0].ref^.base.enum <> Taicpu(p).oper[1].reg.enum) And
+                           (Taicpu(p).oper[0].ref^.index.enum <> Taicpu(p).oper[1].reg.enum) And
                            Not(CS_LittleSize in aktglobalswitches) And
                            IsGP32Reg(Taicpu(p).oper[1].reg) And
                            (aktoptprocessor = ClassP5) And
@@ -2044,7 +2050,10 @@ End.
 
 {
   $Log$
-  Revision 1.35  2002-11-15 16:30:54  peter
+  Revision 1.36  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.35  2002/11/15 16:30:54  peter
     * made tasmsymbol.refs private (merged)
 
   Revision 1.34  2002/08/18 20:06:30  peter

+ 27 - 16
compiler/i386/ra386.pas

@@ -316,6 +316,9 @@ begin
    exit;
   if (OpOrder=op_intel) then
     SwapOperands;
+  if (operands[1].opr.typ=OPR_REGISTER) and
+      (operands[1].opr.reg.enum>lastreg) then
+    internalerror(200301081);
   case ops of
     0 : ;
     1 :
@@ -323,8 +326,7 @@ begin
       if ((opcode=A_PUSH) or
           (opcode=A_POP)) and
          (operands[1].opr.typ=OPR_REGISTER) and
-         ((operands[1].opr.reg>=firstsreg) and
-          (operands[1].opr.reg<=lastsreg)) then
+         (operands[1].opr.reg.enum in [firstsreg..lastsreg]) then
         opsize:=S_L
       else
         opsize:=operands[1].size;
@@ -380,12 +382,14 @@ begin
   end;
   { Handle the BW,BL,WL separatly }
   sizeerr:=false;
+  if (operands[1].opr.typ=OPR_REGISTER) and
+      (operands[1].opr.reg.enum>lastreg) then
+    internalerror(200301081);
   { special push/pop selector case }
   if ((opcode=A_PUSH) or
       (opcode=A_POP)) and
      (operands[1].opr.typ=OPR_REGISTER) and
-     ((operands[1].opr.reg>=firstsreg) and
-      (operands[1].opr.reg<=lastsreg)) then
+     (operands[1].opr.reg.enum in [firstsreg..lastsreg]) then
      exit;
   if opsize in [S_BW,S_BL,S_WL] then
    begin
@@ -432,12 +436,18 @@ procedure T386Instruction.CheckNonCommutativeOpcodes;
 begin
   if (OpOrder=op_intel) then
     SwapOperands;
+  if (operands[1].opr.typ=OPR_REGISTER) and
+      (operands[1].opr.reg.enum>lastreg) then
+    internalerror(200301081);
+  if (operands[2].opr.typ=OPR_REGISTER) and
+      (operands[2].opr.reg.enum>lastreg) then
+    internalerror(200301081);
   if ((ops=2) and
      (operands[1].opr.typ=OPR_REGISTER) and
      (operands[2].opr.typ=OPR_REGISTER) and
      { if the first is ST and the second is also a register
        it is necessarily ST1 .. ST7 }
-     (operands[1].opr.reg in [R_ST..R_ST0])) or
+     (operands[1].opr.reg.enum in [R_ST..R_ST0])) or
       (ops=0)  then
       if opcode=A_FSUBR then
         opcode:=A_FSUB
@@ -457,7 +467,7 @@ begin
         opcode:=A_FDIVRP;
   if  ((ops=1) and
       (operands[1].opr.typ=OPR_REGISTER) and
-      (operands[1].opr.reg in [R_ST1..R_ST7])) then
+      (operands[1].opr.reg.enum in [R_ST1..R_ST7])) then
       if opcode=A_FSUBRP then
         opcode:=A_FSUBP
       else if opcode=A_FSUBP then
@@ -561,12 +571,12 @@ begin
        ops:=2;
        operands[1].opr.typ:=OPR_REGISTER;
        operands[2].opr.typ:=OPR_REGISTER;
-       operands[1].opr.reg:=R_ST;
-       operands[2].opr.reg:=R_ST1;
+       operands[1].opr.reg.enum:=R_ST;
+       operands[2].opr.reg.enum:=R_ST1;
      end;
   if (ops=1) and
       ((operands[1].opr.typ=OPR_REGISTER) and
-      (operands[1].opr.reg in [R_ST1..R_ST7])) and
+      (operands[1].opr.reg.enum in [R_ST1..R_ST7])) and
       ((opcode=A_FSUBP) or
       (opcode=A_FSUBRP) or
       (opcode=A_FDIVP) or
@@ -586,12 +596,12 @@ begin
        ops:=2;
        operands[2].opr.typ:=OPR_REGISTER;
        operands[2].opr.reg:=operands[1].opr.reg;
-       operands[1].opr.reg:=R_ST;
+       operands[1].opr.reg.enum:=R_ST;
      end;
 
   if (ops=1) and
       ((operands[1].opr.typ=OPR_REGISTER) and
-      (operands[1].opr.reg in [R_ST1..R_ST7])) and
+      (operands[1].opr.reg.enum in [R_ST1..R_ST7])) and
       ((opcode=A_FSUB) or
       (opcode=A_FSUBR) or
       (opcode=A_FDIV) or
@@ -610,10 +620,10 @@ begin
 {$endif ATTOP}
        ops:=2;
        operands[2].opr.typ:=OPR_REGISTER;
-       operands[2].opr.reg:=R_ST;
+       operands[2].opr.reg.enum:=R_ST;
      end;
 
-   { I tried to convince Linus Torwald to add
+   { I tried to convince Linus Torvalds to add
      code to support ENTER instruction
      (when raising a stack page fault)
      but he replied that ENTER is a bad instruction and
@@ -623,9 +633,7 @@ begin
      FPC itself does not use it at all PM }
    if (opcode=A_ENTER) and ((target_info.system=system_i386_linux) or
         (target_info.system=system_i386_FreeBSD)) then
-     begin
        message(asmr_w_enter_not_supported_by_linux);
-     end;
 
   ai:=taicpu.op_none(opcode,siz);
   ai.SetOperandOrder(OpOrder);
@@ -690,7 +698,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.26  2002-11-15 01:58:58  peter
+  Revision 1.27  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.26  2002/11/15 01:58:58  peter
     * merged changes from 1.0.7 up to 04-11
       - -V option for generating bug report tracing
       - more tracing for option parsing

+ 15 - 8
compiler/i386/ra386att.pas

@@ -106,7 +106,7 @@ Procedure SetupTables;
 { creates uppercased symbol tables for speed access }
 var
   i : tasmop;
-  j : tregister;
+  j : Toldregister;
   str2opentry: tstr2opentry;
 Begin
   { opcodes }
@@ -235,14 +235,14 @@ end;
 
 Function is_register(const s: string):boolean;
 Var
-  i : tregister;
+  i : Toldregister;
 Begin
-  actasmregister:=R_NO;
+  actasmregister.enum:=R_NO;
   for i:=firstreg to lastreg do
    if s=iasmregs^[i] then
     begin
       actasmtoken:=AS_REGISTER;
-      actasmregister:=i;
+      actasmregister.enum:=i;
       is_register:=true;
       exit;
     end;
@@ -1168,7 +1168,9 @@ Begin
       Begin
         { Check if there is already a base (mostly ebp,esp) than this is
           not allowed,becuase it will give crashing code }
-        if opr.ref.base<>R_NO then
+        if opr.ref.base.enum>lastreg then
+          internalerror(200301081);
+        if opr.ref.base.enum<>R_NO then
          Message(asmr_e_cannot_index_relative_var);
         opr.ref.base:=actasmregister;
         Consume(AS_REGISTER);
@@ -1429,7 +1431,9 @@ Begin
          begin
            opr.typ:=OPR_REGISTER;
            opr.reg:=actasmregister;
-           size:=reg_2_opsize[actasmregister];
+           if opr.reg.enum>lastreg then
+             internalerror(200301081);
+           size:=reg_2_opsize[actasmregister.enum];
            Consume(AS_REGISTER);
          end
         else
@@ -1582,7 +1586,7 @@ Begin
              Message(asmr_e_invalid_operand_type);
            opr.typ:=OPR_REGISTER;
            opr.reg:=tempreg;
-           size:=reg_2_opsize[tempreg];
+           size:=reg_2_opsize[tempreg.enum];
          end
         else
          Message(asmr_e_syn_operand);
@@ -2122,7 +2126,10 @@ finalization
 end.
 {
   $Log$
-  Revision 1.35  2002-12-14 15:02:03  carl
+  Revision 1.36  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.35  2002/12/14 15:02:03  carl
     * maxoperands -> max_operands (for portability in rautils.pas)
     * fix some range-check errors with loadconst
     + add ncgadd unit to m68k

+ 26 - 15
compiler/i386/ra386int.pas

@@ -122,7 +122,7 @@ Procedure SetupTables;
 { creates uppercased symbol tables for speed access }
 var
   i : tasmop;
-  j : tregister;
+  j : Toldregister;
   str2opentry: tstr2opentry;
 Begin
   { opcodes }
@@ -226,9 +226,9 @@ Function is_register(const s: string):boolean;
 Var
   i : tregister;
 Begin
-  actasmregister:=R_NO;
-  for i:=firstreg to lastreg do
-   if s=iasmregs^[i] then
+  actasmregister.enum:=R_NO;
+  for i.enum:=firstreg to lastreg do
+   if s=iasmregs^[i.enum] then
     begin
       actasmtoken:=AS_REGISTER;
       actasmregister:=i;
@@ -1071,7 +1071,7 @@ Begin
              if negative then
                Message(asmr_e_only_add_relocatable_symbol);
              oldbase:=opr.ref.base;
-             opr.ref.base:=R_NO;
+             opr.ref.base.enum:=R_NO;
              tempstr:=actasmpattern;
              Consume(AS_ID);
              { typecasting? }
@@ -1097,9 +1097,11 @@ Begin
               end;
              if GotOffset then
               begin
-                if hasvar and (opr.ref.base=procinfo.framepointer) then
+                if procinfo.framepointer.enum>lastreg then
+                  internalerror(200301081);
+                if hasvar and (opr.ref.base.enum=procinfo.framepointer.enum) then
                  begin
-                   opr.ref.base:=R_NO;
+                   opr.ref.base.enum:=R_NO;
                    hasvar:=hadvar;
                  end
                 else
@@ -1109,15 +1111,19 @@ Begin
                    { should we allow ?? }
                  end;
               end;
+             if opr.ref.base.enum>lastreg then
+               internalerror(200301081);
+             if opr.ref.index.enum>lastreg then
+               internalerror(200301081);
              { is the base register loaded by the var ? }
-             if (opr.ref.base<>R_NO) then
+             if (opr.ref.base.enum<>R_NO) then
               begin
                 { check if we can move the old base to the index register }
-                if (opr.ref.index<>R_NO) then
+                if (opr.ref.index.enum<>R_NO) then
                  Message(asmr_e_wrong_base_index)
                 else if assigned(procinfo._class) and
-                  (oldbase=SELF_POINTER_REG) and
-                  (opr.ref.base=SELF_POINTER_REG) then
+                  (oldbase.enum=SELF_POINTER_REG) and
+                  (opr.ref.base.enum=SELF_POINTER_REG) then
                   begin
                     Message(asmr_w_possible_object_field_bug);
                     { warn but accept... who knows what people
@@ -1210,9 +1216,9 @@ Begin
              3. base register is already used }
           if (GotStar) or
              (actasmtoken=AS_STAR) or
-             (opr.ref.base<>R_NO) then
+             (opr.ref.base.enum<>R_NO) then
            begin
-             if (opr.ref.index<>R_NO) then
+             if (opr.ref.index.enum<>R_NO) then
               Message(asmr_e_multiple_index);
              opr.ref.index:=hreg;
              if scale<>0 then
@@ -1560,7 +1566,9 @@ Begin
             Message(asmr_e_invalid_operand_type);
            opr.typ:=OPR_REGISTER;
            opr.reg:=tempreg;
-           size:=reg2opsize[opr.reg];
+           if opr.reg.enum>lastreg then
+             internalerror(200301081);
+           size:=reg2opsize[opr.reg.enum];
          end;
       end;
 
@@ -1956,7 +1964,10 @@ finalization
 end.
 {
   $Log$
-  Revision 1.38  2002-12-14 15:02:03  carl
+  Revision 1.39  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.38  2002/12/14 15:02:03  carl
     * maxoperands -> max_operands (for portability in rautils.pas)
     * fix some range-check errors with loadconst
     + add ncgadd unit to m68k

+ 13 - 7
compiler/i386/radirect.pas

@@ -51,7 +51,8 @@ interface
        { codegen }
        cgbase,
        { constants }
-       ag386att
+       ag386att,
+       cpubase
        ;
 
     function assemble : tnode;
@@ -88,8 +89,10 @@ interface
        if assigned(aktprocdef.funcretsym) and
           is_fpu(aktprocdef.rettype.def) then
          tfuncretsym(aktprocdef.funcretsym).funcretstate:=vs_assigned;
+       if procinfo.framepointer.enum>lastreg then
+         internalerror(200301081);
        if (not is_void(aktprocdef.rettype.def)) then
-         retstr:=upper(tostr(procinfo.return_offset)+'('+gas_reg2str[procinfo.framepointer]+')')
+         retstr:=upper(tostr(procinfo.return_offset)+'('+gas_reg2str[procinfo.framepointer.enum]+')')
        else
          retstr:='';
          c:=current_scanner.asmgetchar;
@@ -170,7 +173,7 @@ interface
                                                hs:=tvarsym(sym).mangledname
                                              else
                                                hs:='-'+tostr(tvarsym(sym).address)+
-                                                   '('+gas_reg2str[procinfo.framepointer]+')';
+                                                   '('+gas_reg2str[procinfo.framepointer.enum]+')';
                                              end
                                            else
                                            { call to local function }
@@ -193,7 +196,7 @@ interface
                                                      l:=tvarsym(sym).address;
                                                      { set offset }
                                                      inc(l,aktprocdef.parast.address_fixup);
-                                                     hs:=tostr(l)+'('+gas_reg2str[procinfo.framepointer]+')';
+                                                     hs:=tostr(l)+'('+gas_reg2str[procinfo.framepointer.enum]+')';
                                                      if pos(',',s) > 0 then
                                                        tvarsym(sym).varstate:=vs_used;
                                                   end;
@@ -239,7 +242,7 @@ interface
                                              begin
                                                 if assigned(procinfo._class) then
                                                   hs:=tostr(procinfo.selfpointer_offset)+
-                                                      '('+gas_reg2str[procinfo.framepointer]+')'
+                                                      '('+gas_reg2str[procinfo.framepointer.enum]+')'
                                                 else
                                                  Message(asmr_e_cannot_use_SELF_outside_a_method);
                                              end
@@ -256,7 +259,7 @@ interface
                                                 { we do it: }
                                                 if lexlevel>normal_function_level then
                                                   hs:=tostr(procinfo.framepointer_offset)+
-                                                    '('+gas_reg2str[procinfo.framepointer]+')'
+                                                    '('+gas_reg2str[procinfo.framepointer.enum]+')'
                                                 else
                                                   Message(asmr_e_cannot_use_OLDEBP_outside_nested_procedure);
                                              end;
@@ -304,7 +307,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.5  2002-11-25 17:43:27  peter
+  Revision 1.6  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.5  2002/11/25 17:43:27  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 54 - 36
compiler/i386/rgcpu.pas

@@ -41,7 +41,7 @@ unit rgcpu;
           { to keep the same allocation order as with the old routines }
           function getregisterint(list: taasmoutput): tregister; override;
           procedure ungetregisterint(list: taasmoutput; r : tregister); override;
-          function getexplicitregisterint(list: taasmoutput; r : tregister) : tregister; override;
+          function getexplicitregisterint(list: taasmoutput; r : Toldregister) : tregister; override;
 
           function getregisterfpu(list: taasmoutput) : tregister; override;
           procedure ungetregisterfpu(list: taasmoutput; r : tregister); override;
@@ -85,7 +85,7 @@ unit rgcpu;
 {                         routine helpers                                }
 {************************************************************************}
   const
-    reg2reg32 : array[tregister] of tregister = (R_NO,
+    reg2reg32 : array[firstreg..lastreg] of Toldregister = (R_NO,
       R_EAX,R_ECX,R_EDX,R_EBX,R_ESP,R_EBP,R_ESI,R_EDI,
       R_EAX,R_ECX,R_EDX,R_EBX,R_ESP,R_EBP,R_ESI,R_EDI,
       R_EAX,R_ECX,R_EDX,R_EBX,R_NO,R_NO,R_NO,R_NO,
@@ -97,7 +97,7 @@ unit rgcpu;
       R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
       R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO
     );
-    reg2reg16 : array[tregister] of tregister = (R_NO,
+    reg2reg16 : array[firstreg..lastreg] of Toldregister = (R_NO,
       R_AX,R_CX,R_DX,R_BX,R_SP,R_BP,R_SI,R_DI,
       R_AX,R_CX,R_DX,R_BX,R_SP,R_BP,R_SI,R_DI,
       R_AX,R_CX,R_DX,R_BX,R_NO,R_NO,R_NO,R_NO,
@@ -109,7 +109,7 @@ unit rgcpu;
       R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,
       R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO,R_NO
     );
-    reg2reg8 : array[tregister] of tregister = (R_NO,
+    reg2reg8 : array[firstreg..lastreg] of Toldregister = (R_NO,
       R_AL,R_CL,R_DL,R_BL,R_NO,R_NO,R_NO,R_NO,
       R_AL,R_CL,R_DL,R_BL,R_NO,R_NO,R_NO,R_NO,
       R_AL,R_CL,R_DL,R_BL,R_NO,R_NO,R_NO,R_NO,
@@ -129,15 +129,15 @@ unit rgcpu;
       begin
         case size of
           S_B :
-            reg:=reg2reg8[r];
+            reg.enum:=reg2reg8[r.enum];
           S_W :
-            reg:=reg2reg16[r];
+            reg.enum:=reg2reg16[r.enum];
           S_L :
-            reg:=reg2reg32[r];
+            reg.enum:=reg2reg32[r.enum];
           else
             internalerror(200204101);
         end;
-        if reg=R_NO then
+        if reg.enum=R_NO then
          internalerror(200204102);
         changeregsize:=reg;
       end;
@@ -148,6 +148,7 @@ unit rgcpu;
 {************************************************************************}
 
     function trgcpu.getregisterint(list: taasmoutput): tregister;
+
       begin
          if countunusedregsint=0 then
            internalerror(10);
@@ -164,41 +165,41 @@ unit rgcpu;
            begin
               exclude(unusedregsint,R_EAX);
               include(usedinproc,R_EAX);
-              getregisterint:=R_EAX;
+              getregisterint.enum:=R_EAX;
 {$ifdef TEMPREGDEBUG}
               reg_user[R_EAX]:=curptree^;
 {$endif TEMPREGDEBUG}
-              exprasmlist.concat(tai_regalloc.alloc(R_EAX));
+              exprasmlist.concat(tai_regalloc.alloc(getregisterint));
            end
          else if R_EDX in unusedregsint then
            begin
               exclude(unusedregsint,R_EDX);
               include(usedinproc,R_EDX);
-              getregisterint:=R_EDX;
+              getregisterint.enum:=R_EDX;
 {$ifdef TEMPREGDEBUG}
               reg_user[R_EDX]:=curptree^;
 {$endif TEMPREGDEBUG}
-              exprasmlist.concat(tai_regalloc.alloc(R_EDX));
+              exprasmlist.concat(tai_regalloc.alloc(getregisterint));
            end
          else if R_EBX in unusedregsint then
            begin
               exclude(unusedregsint,R_EBX);
               include(usedinproc,R_EBX);
-              getregisterint:=R_EBX;
+              getregisterint.enum:=R_EBX;
 {$ifdef TEMPREGDEBUG}
               reg_user[R_EBX]:=curptree^;
 {$endif TEMPREGDEBUG}
-              exprasmlist.concat(tai_regalloc.alloc(R_EBX));
+              exprasmlist.concat(tai_regalloc.alloc(getregisterint));
            end
          else if R_ECX in unusedregsint then
            begin
               exclude(unusedregsint,R_ECX);
               include(usedinproc,R_ECX);
-              getregisterint:=R_ECX;
+              getregisterint.enum:=R_ECX;
 {$ifdef TEMPREGDEBUG}
               reg_user[R_ECX]:=curptree^;
 {$endif TEMPREGDEBUG}
-              exprasmlist.concat(tai_regalloc.alloc(R_ECX));
+              exprasmlist.concat(tai_regalloc.alloc(getregisterint));
            end
          else internalerror(10);
 {$ifdef TEMPREGDEBUG}
@@ -208,27 +209,33 @@ unit rgcpu;
 
     procedure trgcpu.ungetregisterint(list: taasmoutput; r : tregister);
       begin
-         if r=R_NO then
+         if r.enum=R_NO then
           exit;
          r := makeregsize(r,OS_INT);
-         if (r = R_EDI) or
-            ((not assigned(procinfo._class)) and (r = R_ESI)) then
+         if r.enum>lastreg then
+            internalerror(200301081);
+         if (r.enum = R_EDI) or
+            ((not assigned(procinfo._class)) and (r.enum = R_ESI)) then
            begin
              list.concat(tai_regalloc.DeAlloc(r));
              exit;
            end;
-         if not(r in [R_EAX,R_EBX,R_ECX,R_EDX]) then
+         if not(r.enum in [R_EAX,R_EBX,R_ECX,R_EDX]) then
            exit;
          inherited ungetregisterint(list,r);
       end;
 
 
-   function trgcpu.getexplicitregisterint(list: taasmoutput; r : tregister) : tregister;
+   function trgcpu.getexplicitregisterint(list: taasmoutput; r : Toldregister) : tregister;
+
+   var r2:Tregister;
+
      begin
        if r in [R_ESI,R_EDI] then
          begin
-           list.concat(tai_regalloc.Alloc(r));
-           getexplicitregisterint := r;
+           r2.enum:=r;
+           list.concat(tai_regalloc.Alloc(r2));
+           getexplicitregisterint := r2;
            exit;
          end;
        result := inherited getexplicitregisterint(list,r);
@@ -240,7 +247,7 @@ unit rgcpu;
       begin
         { note: don't return R_ST0, see comments above implementation of }
         { a_loadfpu_* methods in cgcpu (JM)                              }
-        result := R_ST;
+        result.enum := R_ST;
       end;
 
 
@@ -264,7 +271,8 @@ unit rgcpu;
         var pushed : tpushedsaved; const s: tregisterset);
 
       var
-        r: tregister;
+        r: Toldregister;
+        r2: Tregister;
 {$ifdef SUPPORT_MMX}
         hr : treference;
 {$endif SUPPORT_MMX}
@@ -272,6 +280,7 @@ unit rgcpu;
         usedinproc:=usedinproc + s;
         for r:=R_EAX to R_EBX do
           begin
+            r2.enum:=r;
             pushed[r].pushed:=false;
             { if the register is used by the calling subroutine    }
             if not is_reg_var[r] and
@@ -280,7 +289,7 @@ unit rgcpu;
                not(r in unusedregsint) then
               begin
                 { then save it }
-                list.concat(Taicpu.Op_reg(A_PUSH,S_L,r));
+                list.concat(Taicpu.Op_reg(A_PUSH,S_L,r2));
                 include(unusedregsint,r);
                 inc(countunusedregsint);
                 pushed[r].pushed:=true;
@@ -296,9 +305,11 @@ unit rgcpu;
                { and is present in use }
                not(r in unusedregsmm) then
               begin
-                list.concat(Taicpu.Op_const_reg(A_SUB,S_L,8,R_ESP));
-                reference_reset_base(hr,R_ESP,0);
-                list.concat(Taicpu.Op_reg_ref(A_MOVQ,S_NO,r,hr));
+                r2.enum:=R_ESP;
+                list.concat(Taicpu.Op_const_reg(A_SUB,S_L,8,r2));
+                reference_reset_base(hr,r2,0);
+                r2.enum:=r;
+                list.concat(Taicpu.Op_reg_ref(A_MOVQ,S_NO,r2,hr));
                 include(unusedregsmm,r);
                 inc(countunusedregsmm);
                 pushed[r].pushed:=true;
@@ -315,7 +326,8 @@ unit rgcpu;
         const pushed : tpushedsaved);
 
       var
-        r : tregister;
+        r : Toldregister;
+        r2,r3 : Tregister;
 {$ifdef SUPPORT_MMX}
         hr : treference;
 {$endif SUPPORT_MMX}
@@ -325,11 +337,13 @@ unit rgcpu;
         for r:=R_MM6 downto R_MM0 do
           if pushed[r].pushed then
             begin
-              reference_reset_base(hr,R_ESP,0);
+              r2.enum:=R_ESP;
+              reference_reset_base(hr,r2,0);
+              r3.enum:=r;
               list.concat(Taicpu.Op_ref_reg(
-                A_MOVQ,S_NO,hr,r));
+                A_MOVQ,S_NO,hr,r3));
               list.concat(Taicpu.Op_const_reg(
-                A_ADD,S_L,8,R_ESP));
+                A_ADD,S_L,8,r2));
               if not (r in unusedregsmm) then
                 { internalerror(10)
                   in cg386cal we always restore regs
@@ -343,7 +357,8 @@ unit rgcpu;
         for r:=R_EBX downto R_EAX do
           if pushed[r].pushed then
             begin
-              list.concat(Taicpu.Op_reg(A_POP,S_L,r));
+              r2.enum:=r;
+              list.concat(Taicpu.Op_reg(A_POP,S_L,r2));
               if not (r in unusedregsint) then
                 { internalerror(10)
                   in cg386cal we always restore regs
@@ -393,7 +408,7 @@ unit rgcpu;
    function trgcpu.correct_fpuregister(r : tregister;ofs : byte) : tregister;
 
      begin
-        correct_fpuregister:=tregister(longint(r)+ofs);
+        correct_fpuregister.enum:=Toldregister(longint(r.enum)+ofs);
      end;
 
 
@@ -429,7 +444,10 @@ end.
 
 {
   $Log$
-  Revision 1.10  2002-10-05 12:43:29  carl
+  Revision 1.11  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.10  2002/10/05 12:43:29  carl
     * fixes for Delphi 6 compilation
      (warning : Some features do not work under Delphi)
 

+ 28 - 19
compiler/i386/rropt386.pas

@@ -46,18 +46,18 @@ begin
     A_MOV,A_MOVZX,A_MOVSX,A_LEA:
       canBeFirstSwitch :=
         (p.oper[1].typ = top_reg) and
-        (reg32(p.oper[1].reg) = reg);
+        (reg32(p.oper[1].reg).enum = reg.enum);
     A_IMUL:
       canBeFirstSwitch :=
         (p.ops >= 2) and
-        (reg32(p.oper[p.ops-1].reg) = reg) and
+        (reg32(p.oper[p.ops-1].reg).enum = reg.enum) and
         (p.oper[0].typ <> top_ref) and
         (not pTaiprop(p.optinfo)^.FlagsUsed);
     A_INC,A_DEC,A_SUB,A_ADD:
       canBeFirstSwitch :=
         (p.oper[1].typ = top_reg) and
         (p.opsize = S_L) and
-        (reg32(p.oper[1].reg) = reg) and
+        (reg32(p.oper[1].reg).enum = reg.enum) and
         (p.oper[0].typ <> top_ref) and
         ((p.opcode <> A_SUB) or
          (p.oper[0].typ = top_const)) and
@@ -66,7 +66,7 @@ begin
       canBeFirstSwitch :=
         (p.opsize = S_L) and
         (p.oper[1].typ = top_reg) and
-        (p.oper[1].reg = reg) and
+        (p.oper[1].reg.enum = reg.enum) and
         (p.oper[0].typ = top_const) and
         (p.oper[0].val in [1,2,3]) and
         (not pTaiprop(p.optinfo)^.FlagsUsed);
@@ -75,22 +75,28 @@ end;
 
 procedure switchReg(var reg: tregister; reg1, reg2: tregister);
 begin
-  if reg = reg1 then
+  if reg1.enum>lastreg then
+    internalerror(2003010801);
+  if reg2.enum>lastreg then
+    internalerror(2003010801);
+  if reg.enum>lastreg then
+    internalerror(2003010801);
+  if reg.enum = reg1.enum then
     reg := reg2
-  else if reg = reg2 then
+  else if reg.enum = reg2.enum then
     reg := reg1
-  else if (reg in regset8bit) then
+  else if (reg.enum in regset8bit) then
     begin
-      if (reg = rg.makeregsize(reg1,OS_8)) then
+      if (reg.enum = rg.makeregsize(reg1,OS_8).enum) then
         reg := rg.makeregsize(reg2,OS_8)
-      else if reg = rg.makeregsize(reg2,OS_8) then
+      else if reg.enum = rg.makeregsize(reg2,OS_8).enum then
         reg := rg.makeregsize(reg1,OS_8);
     end
-  else if (reg in regset16bit) then
+  else if (reg.enum in regset16bit) then
     begin
-      if reg = rg.makeregsize(reg1,OS_16) then
+      if reg.enum = rg.makeregsize(reg1,OS_16).enum then
         reg := rg.makeregsize(reg2,OS_16)
-      else if reg = rg.makeregsize(reg2,OS_16) then
+      else if reg.enum = rg.makeregsize(reg2,OS_16).enum then
         reg := rg.makeregsize(reg1,OS_16);
     end;
 end;
@@ -211,8 +217,8 @@ begin
           { "mov %oldReg,%newReg; <operations on %newReg>; mov %newReg, }
           { %oldReg" to "<operations on %oldReg>"                       }
           switchLast := storeBack(endP,reg1,reg2);
-          reg1StillUsed := reg1 in pTaiprop(endp.optinfo)^.usedregs;
-          reg2StillUsed := reg2 in pTaiprop(endp.optinfo)^.usedregs;
+          reg1StillUsed := reg1.enum in pTaiprop(endp.optinfo)^.usedregs;
+          reg2StillUsed := reg2.enum in pTaiprop(endp.optinfo)^.usedregs;
           isInstruction := endp.typ = ait_instruction;
           sequenceEnd :=
             switchLast or
@@ -293,9 +299,9 @@ begin
                 else
                   doReplaceReg(Taicpu(hp),reg2,reg1);
             end;
-          if regininstruction(reg1,hp) then
+          if regininstruction(reg1.enum,hp) then
              lastreg1 := hp;
-          if regininstruction(reg2,hp) then
+          if regininstruction(reg2.enum,hp) then
              lastreg2 := hp;
           getNextInstruction(hp,hp);
         end;
@@ -325,8 +331,8 @@ begin
                      (Taicpu(p).oper[0].typ = top_reg) and
                      (Taicpu(p).oper[1].typ = top_reg) and
                      (Taicpu(p).opsize = S_L) and
-                     (Taicpu(p).oper[0].reg in (rg.usableregsint+[R_EDI])) and
-                     (Taicpu(p).oper[1].reg in (rg.usableregsint+[R_EDI])) then
+                     (Taicpu(p).oper[0].reg.enum in (rg.usableregsint+[R_EDI])) and
+                     (Taicpu(p).oper[1].reg.enum in (rg.usableregsint+[R_EDI])) then
                     if switchRegs(asml,Taicpu(p).oper[0].reg,
                          Taicpu(p).oper[1].reg,p) then
                       begin
@@ -350,7 +356,10 @@ End.
 
 {
   $Log$
-  Revision 1.18  2002-07-01 18:46:34  peter
+  Revision 1.19  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.18  2002/07/01 18:46:34  peter
     * internal linker
     * reorganized aasm layer
 

+ 17 - 14
compiler/m68k/agcpugas.pas

@@ -124,8 +124,8 @@ interface
            begin
              inc(offset,offsetfixup);
              offsetfixup:=0;
-             basestr:=gas_reg2str[base];
-             indexstr:=gas_reg2str[index];
+             basestr:=gas_reg2str[base.enum];
+             indexstr:=gas_reg2str[index.enum];
              if assigned(symbol) then
                s:=s+symbol.name;
 
@@ -135,35 +135,35 @@ interface
                   if (symbol=nil) then s:=tostr(offset)
                        else s:=s+'+'+tostr(offset);
                     end
-                  else if (index=R_NO) and (base=R_NO) and not assigned(symbol) then
+                  else if (index.enum=R_NO) and (base.enum=R_NO) and not assigned(symbol) then
                     s:=s+'0';
 
-               if (index<>R_NO) and (base=R_NO) and (direction=dir_none) then
+               if (index.enum<>R_NO) and (base.enum=R_NO) and (direction=dir_none) then
                 begin
                   if (scalefactor = 1) or (scalefactor = 0) then
                     s:=s+'(,'+indexstr+'.l)'
                   else
                     s:=s+'(,'+indexstr+'.l*'+tostr(scalefactor)+')'
                 end
-                else if (index=R_NO) and (base<>R_NO) and (direction=dir_inc) then
+                else if (index.enum=R_NO) and (base.enum<>R_NO) and (direction=dir_inc) then
                 begin
                   if (scalefactor = 1) or (scalefactor = 0) then
                       s:=s+'('+basestr+')+'
                   else
                    InternalError(10002);
                 end
-                else if (index=R_NO) and (base<>R_NO) and (direction=dir_dec) then
+                else if (index.enum=R_NO) and (base.enum<>R_NO) and (direction=dir_dec) then
                 begin
                   if (scalefactor = 1) or (scalefactor = 0) then
                       s:=s+'-('+basestr+')'
                   else
                    InternalError(10003);
                 end
-                  else if (index=R_NO) and (base<>R_NO) and (direction=dir_none) then
+                  else if (index.enum=R_NO) and (base.enum<>R_NO) and (direction=dir_none) then
                 begin
                   s:=s+'('+basestr+')'
                 end
-                  else if (index<>R_NO) and (base<>R_NO) and (direction=dir_none) then
+                  else if (index.enum<>R_NO) and (base.enum<>R_NO) and (direction=dir_none) then
                 begin
                   if (scalefactor = 1) or (scalefactor = 0) then
                     s:=s+'('+basestr+','+indexstr+'.l)'
@@ -181,14 +181,14 @@ interface
       i : tregister;
     begin
       case o.typ of
-            top_reg : getopstr:=gas_reg2str[o.reg];
+            top_reg : getopstr:=gas_reg2str[o.reg.enum];
             top_ref : getopstr:=getreferencestring(o.ref^);
         top_reglist : begin
                       hs:='';
-                      for i:=R_NO to R_FPSR do
+                      for i.enum:=R_NO to R_FPSR do
                       begin
-                        if i in o.registerlist then
-                         hs:=hs+gas_reg2str[i]+'/';
+                        if i.enum in o.registerlist then
+                         hs:=hs+gas_reg2str[i.enum]+'/';
                       end;
                       delete(hs,length(hs),1);
                       getopstr := hs;
@@ -221,7 +221,7 @@ interface
       hs : string;
     begin
       case o.typ of
-            top_reg : getopstr_jmp:=gas_reg2str[o.reg];
+            top_reg : getopstr_jmp:=gas_reg2str[o.reg.enum];
             top_ref : getopstr_jmp:=getreferencestring(o.ref^);
             top_const : getopstr_jmp:=tostr(o.val);
             top_symbol : begin
@@ -417,7 +417,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.4  2002-11-30 23:33:02  carl
+  Revision 1.5  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.4  2002/11/30 23:33:02  carl
     * merges from Pierre's fixes in m68k fixes branch
 
   Revision 1.3  2002/09/07 15:25:11  peter

+ 81 - 52
compiler/m68k/cgcpu.pas

@@ -153,9 +153,9 @@ Implementation
      function isvalidrefoffset(const ref: treference): boolean;
       begin
          isvalidrefoffset := true;
-         if ref.index <> R_NO then
+         if ref.index.enum <> R_NO then
            begin
-             if ref.base <> R_NO then
+             if ref.base.enum <> R_NO then
                 internalerror(20020814);
              if (ref.offset < low(shortint)) or (ref.offset > high(shortint)) then
                 isvalidrefoffset := false
@@ -182,12 +182,12 @@ Implementation
          }
          if (aktoptprocessor <> MC68000) then
            exit;
-         if (ref.base <> R_NO) then
+         if (ref.base.enum <> R_NO) then
            begin
-             if (ref.index <> R_NO) and assigned(ref.symbol) then
+             if (ref.index.enum <> R_NO) and assigned(ref.symbol) then
                 internalerror(20020814);
              { base + reg }
-             if ref.index <> R_NO then
+             if ref.index.enum <> R_NO then
                 begin
                    { base + reg + offset }
                    if (ref.offset < low(shortint)) or (ref.offset > high(shortint)) then
@@ -367,6 +367,7 @@ Implementation
        scratch_reg : tregister;
        scratch_reg2: tregister;
        opcode : tasmop;
+       r,r2 : Tregister;
       begin
         { need to emit opcode? }
         if optimize_op_const_reg(list, op, a, reg) then
@@ -400,14 +401,16 @@ Implementation
               Begin
              if aktoptprocessor = MC68000 then
                    begin
+                     r.enum:=R_D0;
+                     r2.enum:=R_D1;
                      rg.getexplicitregisterint(list,R_D0);
                      rg.getexplicitregisterint(list,R_D1);
-                     list.concat(taicpu.op_const_reg(A_MOVE,S_L,a, R_D0));
-                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg, R_D1));
+                     list.concat(taicpu.op_const_reg(A_MOVE,S_L,a, r));
+                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg, r2));
                      cg.a_call_name(list,'FPC_MUL_LONGINT');
-                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,R_D0, reg));
-                     rg.ungetregisterint(list,R_D0);
-                     rg.ungetregisterint(list,R_D1);
+                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,r, reg));
+                     rg.ungetregisterint(list,r);
+                     rg.ungetregisterint(list,r2);
                    end
                   else
                     begin
@@ -427,14 +430,16 @@ Implementation
               Begin
                  if aktoptprocessor = MC68000 then
                    begin
+                     r.enum:=R_D0;
+                     r2.enum:=R_D1;
                      rg.getexplicitregisterint(list,R_D0);
                      rg.getexplicitregisterint(list,R_D1);
-                     list.concat(taicpu.op_const_reg(A_MOVE,S_L,a, R_D0));
-                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg, R_D1));
+                     list.concat(taicpu.op_const_reg(A_MOVE,S_L,a, r));
+                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg, r2));
                      cg.a_call_name(list,'FPC_MUL_LONGWORD');
-                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,R_D0, reg));
-                     rg.ungetregisterint(list,R_D0);
-                     rg.ungetregisterint(list,R_D1);
+                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,r, reg));
+                     rg.ungetregisterint(list,r);
+                     rg.ungetregisterint(list,r2);
                    end
                   else
                     begin
@@ -508,7 +513,7 @@ Implementation
 
     procedure tcg68k.a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; reg1, reg2: TRegister);
       var
-       hreg1,hreg2: tregister;
+       hreg1,hreg2,r,r2: tregister;
       begin
         case op of
           OP_ADD :
@@ -565,10 +570,10 @@ Implementation
                     list.concat(taicpu.op_reg_reg(topcg2tasmop[op],TCGSize2OpSize[size],hreg1, hreg2));
                   end;
 
-                 if reg1 <> hreg1 then
+                 if reg1.enum <> hreg1.enum then
                     cg.free_scratch_reg(list,hreg1);
                  { move back result into destination register }
-                 if reg2 <> hreg2 then
+                 if reg2.enum <> hreg2.enum then
                    begin
                       list.concat(taicpu.op_reg_reg(A_MOVE,S_L,hreg2,reg2));
                       cg.free_scratch_reg(list,hreg2);
@@ -588,14 +593,16 @@ Implementation
                  sign_extend(list, size,reg2);
                  if aktoptprocessor = MC68000 then
                    begin
+                     r.enum:=R_D0;
+                     r2.enum:=R_D1;
                      rg.getexplicitregisterint(list,R_D0);
                      rg.getexplicitregisterint(list,R_D1);
-                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg1, R_D0));
-                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg2, R_D1));
+                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg1, r));
+                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg2, r2));
                      cg.a_call_name(list,'FPC_MUL_LONGINT');
-                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,R_D0, reg2));
-                     rg.ungetregisterint(list,R_D0);
-                     rg.ungetregisterint(list,R_D1);
+                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,r, reg2));
+                     rg.ungetregisterint(list,r);
+                     rg.ungetregisterint(list,r2);
                    end
                   else
                     begin
@@ -608,17 +615,17 @@ Implementation
                      else
                        hreg2 := reg2;
 
-                     if reg1 <> hreg1 then
+                     if reg1.enum <> hreg1.enum then
                           list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg1,hreg1));
-                     if reg2 <> hreg2 then
+                     if reg2.enum <> hreg2.enum then
                           list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg2,hreg2));
 
                      list.concat(taicpu.op_reg_reg(A_MULS,S_L,reg1,reg2));
 
-                     if reg1 <> hreg1 then
+                     if reg1.enum <> hreg1.enum then
                        cg.free_scratch_reg(list,hreg1);
                      { move back result into destination register }
-                     if reg2 <> hreg2 then
+                     if reg2.enum <> hreg2.enum then
                        begin
                           list.concat(taicpu.op_reg_reg(A_MOVE,S_L,hreg2,reg2));
                           cg.free_scratch_reg(list,hreg2);
@@ -631,14 +638,16 @@ Implementation
                  sign_extend(list, size,reg2);
                  if aktoptprocessor = MC68000 then
                    begin
+                     r.enum:=R_D0;
+                     r2.enum:=R_D1;
                      rg.getexplicitregisterint(list,R_D0);
                      rg.getexplicitregisterint(list,R_D1);
-                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg1, R_D0));
-                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg2, R_D1));
+                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg1, r));
+                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,reg2, r2));
                      cg.a_call_name(list,'FPC_MUL_LONGWORD');
-                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,R_D0, reg2));
-                     rg.ungetregisterint(list,R_D0);
-                     rg.ungetregisterint(list,R_D1);
+                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,r, reg2));
+                     rg.ungetregisterint(list,r);
+                     rg.ungetregisterint(list,r2);
                    end
                   else
                     begin
@@ -661,10 +670,10 @@ Implementation
 
                      list.concat(taicpu.op_reg_reg(A_MULU,S_L,reg1,reg2));
 
-                     if reg1 <> hreg1 then
+                     if reg1.enum <> hreg1.enum then
                        cg.free_scratch_reg(list,hreg1);
                      { move back result into destination register }
-                     if reg2 <> hreg2 then
+                     if reg2.enum <> hreg2.enum then
                        begin
                           list.concat(taicpu.op_reg_reg(A_MOVE,S_L,hreg2,reg2));
                           cg.free_scratch_reg(list,hreg2);
@@ -674,7 +683,7 @@ Implementation
           OP_NEG,
           OP_NOT :
               Begin
-                if reg1 <> R_NO then
+                if reg1.enum <> R_NO then
                   internalerror(200112291);
 
                 if (rg.isaddressregister(reg2)) then
@@ -696,7 +705,7 @@ Implementation
                     list.concat(taicpu.op_reg(topcg2tasmop[op],TCGSize2OpSize[size],hreg2));
                   end;
 
-                if reg2 <> hreg2 then
+                if reg2.enum <> hreg2.enum then
                   begin
                     list.concat(taicpu.op_reg_reg(A_MOVE,S_L,hreg2,reg2));
                     cg.free_scratch_reg(list,hreg2);
@@ -943,10 +952,10 @@ Implementation
                 end;
 
        { restore the registers that we have just used olny if they are used! }
-              if jregister = R_A1 then
-                hp2.base := R_NO;
-              if iregister = R_A0 then
-                hp1.base := R_NO;
+              if jregister.enum = R_A1 then
+                hp2.base.enum := R_NO;
+              if iregister.enum = R_A0 then
+                hp1.base.enum := R_NO;
               reference_release(list,hp1);
               reference_release(list,hp2);
            end;
@@ -969,7 +978,12 @@ Implementation
       end;
 
     procedure tcg68k.g_stackframe_entry(list : taasmoutput;localsize : longint);
+    
+    var r,r2,rsp:Tregister;
+    
       begin
+        r.enum:=frame_pointer_reg;
+        rsp.enum:=stack_pointer_reg;
         if localsize<>0 then
            begin
              { Not to complicate the code generator too much, and since some  }
@@ -977,23 +991,28 @@ Implementation
              { exceed 32K in size.                                            }
              if (localsize < low(smallint)) or (localsize > high(smallint)) then
                 CGMessage(cg_e_localsize_too_big);
-             list.concat(taicpu.op_reg_const(A_LINK,S_W,frame_pointer_reg,-localsize));
+             list.concat(taicpu.op_reg_const(A_LINK,S_W,r,-localsize));
            end { endif localsize <> 0 }
           else
            begin
-             list.concat(taicpu.op_reg_reg(A_MOVE,S_L,frame_pointer_reg,R_SPPUSH));
-             list.concat(taicpu.op_reg_reg(A_MOVE,S_L,stack_pointer_reg,frame_pointer_reg));
+             r2.enum:=R_SPPUSH;
+             list.concat(taicpu.op_reg_reg(A_MOVE,S_L,r,r2));
+             list.concat(taicpu.op_reg_reg(A_MOVE,S_L,rsp,r));
            end;
       end;
 
     procedure tcg68k.g_restore_frame_pointer(list : taasmoutput);
+    
+    var r:Tregister;
+    
       begin
-        list.concat(taicpu.op_reg(A_UNLK,S_NO,frame_pointer_reg));
+        r.enum:=frame_pointer_reg;
+        list.concat(taicpu.op_reg(A_UNLK,S_NO,r));
       end;
 
     procedure tcg68k.g_return_from_proc(list : taasmoutput;parasize : aword);
       var
-       hregister : tregister;
+       r,hregister : tregister;
       begin
        {Routines with the poclearstack flag set use only a ret.}
        { also routines with parasize=0     }
@@ -1025,15 +1044,18 @@ Implementation
 
                 { save the PC counter (pop it from the stack)         }
                 hregister := get_scratch_reg_address(list);
-                list.concat(taicpu.op_reg_reg(A_MOVE,S_L,R_SPPULL,hregister));
+                r.enum:=R_SPPULL;
+                list.concat(taicpu.op_reg_reg(A_MOVE,S_L,r,hregister));
                 { can we do a quick addition ... }
+                r.enum:=R_SP;
                 if (parasize > 0) and (parasize < 9) then
-                   list.concat(taicpu.op_const_reg(A_ADDQ,S_L,parasize,R_SP))
+                   list.concat(taicpu.op_const_reg(A_ADDQ,S_L,parasize,r))
                 else { nope ... }
-                   list.concat(taicpu.op_const_reg(A_ADD,S_L,parasize,R_SP));
+                   list.concat(taicpu.op_const_reg(A_ADD,S_L,parasize,r));
 
                 { restore the PC counter (push it on the stack)       }
-                list.concat(taicpu.op_reg_reg(A_MOVE,S_L,hregister,R_SPPUSH));
+                r.enum:=R_SPPUSH;
+                list.concat(taicpu.op_reg_reg(A_MOVE,S_L,hregister,r));
                 list.concat(taicpu.op_none(A_RTS,S_NO));
                 free_scratch_reg(list,hregister);
                end;
@@ -1044,23 +1066,27 @@ Implementation
     procedure tcg68k.g_save_standard_registers(list : taasmoutput; usedinproc : tregisterset);
       var
         tosave : tregisterlist;
+        r:Tregister;
       begin
          tosave:=std_saved_registers;
          { only save the registers which are not used and must be saved }
          tosave:=tosave*usedinproc;
+         r.enum:=R_SPPUSH;
          if tosave<>[] then
-           list.concat(taicpu.op_reglist_reg(A_MOVEM,S_L,tosave,R_SPPUSH));
+           list.concat(taicpu.op_reglist_reg(A_MOVEM,S_L,tosave,r));
       end;
 
     procedure tcg68k.g_restore_standard_registers(list : taasmoutput; usedinproc : tregisterset);
       var
        torestore : tregisterset;
+        r:Tregister;
       begin
          torestore:=std_saved_registers;
          { should be intersected with used regs, no ? }
          torestore:=torestore*usedinproc;
+         r.enum:=R_SPPULL;
          if torestore<>[] then
-           list.concat(taicpu.op_reg_reglist(A_MOVEM,S_L,R_SPPULL,torestore));
+           list.concat(taicpu.op_reg_reglist(A_MOVEM,S_L,r,torestore));
       end;
 
     procedure tcg68k.g_save_all_registers(list : taasmoutput);
@@ -1250,7 +1276,10 @@ end.
 
 {
   $Log$
-  Revision 1.14  2003-01-05 13:36:53  florian
+  Revision 1.15  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.14  2003/01/05 13:36:53  florian
     * x86-64 compiles
     + very basic support for float128 type (x86-64 only)
 

+ 23 - 12
compiler/m68k/cpubase.pas

@@ -102,7 +102,7 @@ uses
 *****************************************************************************}
 
     type
-       tregister = (
+       Toldregister = (
          R_NO,R_D0,R_D1,R_D2,R_D3,R_D4,R_D5,R_D6,R_D7,
          R_A0,R_A1,R_A2,R_A3,R_A4,R_A5,R_A6,R_SP,
          { PUSH/PULL- quick and dirty hack }
@@ -112,7 +112,12 @@ uses
          R_FP7,R_FPCR,R_SR,R_SSP,R_DFC,R_SFC,R_VBR,R_FPSR);
 
       {# Set type definition for registers }
-      tregisterset = set of tregister;
+      tregisterset = set of Toldregister;
+      
+      Tregister=record
+        enum:Toldregister;
+        number:word;
+      end;
 
       { A type to store register locations for 64 Bit values. }
       tregister64 = packed record
@@ -122,15 +127,18 @@ uses
       { alias for compact code }
       treg64 = tregister64;
 
-      {# Type definition for the array of string of register nnames }
-      reg2strtable = array[tregister] of string[7];
 
     Const
       {# First register in the tregister enumeration }
-      firstreg = low(tregister);
+      firstreg = low(Toldregister);
       {# Last register in the tregister enumeration }
-      lastreg  = high(tregister);
+      lastreg  = R_FPSR;
 
+    type
+      {# Type definition for the array of string of register nnames }
+      reg2strtable = array[firstreg..lastreg] of string[7];
+
+    const
      std_reg2str : reg2strtable =
       ('', 'd0','d1','d2','d3','d4','d5','d6','d7',
        'a0','a1','a2','a3','a4','a5','a6','sp',
@@ -212,7 +220,7 @@ uses
       { Types of operand }
       toptype=(top_none,top_reg,top_ref,top_const,top_symbol,top_reglist);
 
-      tregisterlist = set of tregister;
+      tregisterlist = set of Toldregister;
 
       toper=record
         ot  : longint;
@@ -396,7 +404,7 @@ uses
       }
       maxvarregs = 6;
       { Array of integer registers which can be used as variable registers }
-      varregs : Array [1..maxvarregs] of Tregister =
+      varregs : Array [1..maxvarregs] of Toldregister =
                 (R_D2,R_D3,R_D4,R_D5,R_D6,R_D7);
 
       {
@@ -404,7 +412,7 @@ uses
       }
       maxfpuvarregs = 6;
       { Array of float registers which can be used as variable registers }
-      fpuvarregs : Array [1..maxfpuvarregs] of Tregister =
+      fpuvarregs : Array [1..maxfpuvarregs] of Toldregister =
                 (R_FP2,R_FP3,R_FP4,R_FP5,R_FP6,R_FP7);
 
       {
@@ -435,7 +443,7 @@ uses
          routine calls or in assembler blocks.
       }
       max_scratch_regs = 2;
-      scratch_regs: Array[1..max_scratch_regs] of TRegister = (R_D0,R_D1);
+      scratch_regs: Array[1..max_scratch_regs] of Toldregister = (R_D0,R_D1);
 
 {*****************************************************************************
                           Default generic sizes
@@ -464,7 +472,7 @@ uses
          This is not compatible with the m68k-sun
          implementation.
       }
-          stab_regindex : array[tregister] of shortint =
+          stab_regindex : array[firstreg..lastreg] of shortint =
         (-1,                 { R_NO }
           0,1,2,3,4,5,6,7,   { R_D0..R_D7 }
           8,9,10,11,12,13,14,15,  { R_A0..R_A7 }
@@ -592,7 +600,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.14  2002-11-30 23:33:03  carl
+  Revision 1.15  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.14  2002/11/30 23:33:03  carl
     * merges from Pierre's fixes in m68k fixes branch
 
   Revision 1.13  2002/11/17 18:26:16  mazen

+ 5 - 2
compiler/m68k/cpupara.pas

@@ -65,7 +65,7 @@ unit cpupara;
     function tm68kparamanager.getselflocation(p : tabstractprocdef) : tparalocation;
       begin
          getselflocation.loc:=LOC_REFERENCE;
-         getselflocation.reference.index:=R_SP;
+         getselflocation.reference.index.enum:=R_SP;
          getselflocation.reference.offset:=4;
       end;
 
@@ -75,7 +75,10 @@ end.
 
 {
   $Log$
-  Revision 1.2  2002-12-14 15:02:03  carl
+  Revision 1.3  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.2  2002/12/14 15:02:03  carl
     * maxoperands -> max_operands (for portability in rautils.pas)
     * fix some range-check errors with loadconst
     + add ncgadd unit to m68k

+ 21 - 18
compiler/m68k/rasm.pas

@@ -148,8 +148,8 @@ var
      for i:=firstop to lastop do
       iasmops^[i] := upper(gas_op2str[i]);
      { opcodes }
-     for j:=firstasmreg to lastasmreg do
-      iasmregs[j] := upper(std_reg2str[j]);
+     for j.enum:=firstasmreg to lastasmreg do
+      iasmregs[j.enum] := upper(std_reg2str[j.enum]);
    end;
 
 
@@ -216,9 +216,9 @@ var
    Var
     i: tregister;
    Begin
-     for i:=firstasmreg to lastasmreg do
+     for i.enum:=firstasmreg to lastasmreg do
      begin
-      if s=iasmregs[i] then
+      if s=iasmregs[i.enum] then
       begin
         token := AS_REGISTER;
         exit;
@@ -580,16 +580,16 @@ var
    var
     i: tregister;
    begin
-     findregister := R_NO;
-     for i:=firstasmreg to lastasmreg do
-       if s = iasmregs[i] then
+     findregister.enum := R_NO;
+     for i.enum:=firstasmreg to lastasmreg do
+       if s = iasmregs[i.enum] then
        Begin
          findregister := i;
          exit;
        end;
     if s = 'A7' then
     Begin
-      findregister := R_SP;
+      findregister.enum := R_SP;
       exit;
     end;
    end;
@@ -1076,7 +1076,7 @@ type
         Message(asmr_e_wrong_scale_factor);
         opr.ref.scalefactor := 0;
      end;
-     if opr.ref.index = R_NO then
+     if opr.ref.index.enum = R_NO then
      Begin
         Message(asmr_e_wrong_base_index);
         opr.ref.scalefactor := 0;
@@ -1366,7 +1366,7 @@ type
     i: tregister;
     hl: tasmlabel;
     reg_one, reg_two: tregister;
-    reglist: set of tregister;
+    reglist: Tregisterset;
   Begin
    reglist := [];
    tempstr := '';
@@ -1527,7 +1527,7 @@ type
                    { // Individual register listing // }
                    if (actasmtoken = AS_SLASH) then
                    Begin
-                     reglist := [findregister(tempstr)];
+                     reglist := [findregister(tempstr).enum];
                      Consume(AS_SLASH);
                      if actasmtoken = AS_REGISTER then
                      Begin
@@ -1535,7 +1535,7 @@ type
                        Begin
                          case actasmtoken of
                           AS_REGISTER: Begin
-                                        reglist := reglist + [findregister(actasmpattern)];
+                                        reglist := reglist + [findregister(actasmpattern).enum];
                                         Consume(AS_REGISTER);
                                        end;
                           AS_SLASH: Consume(AS_SLASH);
@@ -1574,15 +1574,15 @@ type
                      Begin
                       { determine the register range ... }
                       reg_two:=findregister(actasmpattern);
-                      if reg_one > reg_two then
+                      if reg_one.enum > reg_two.enum then
                       begin
-                       for i:=reg_two to reg_one do
-                         reglist := reglist + [i];
+                       for i.enum:=reg_two.enum to reg_one.enum do
+                         reglist := reglist + [i.enum];
                       end
                       else
                       Begin
-                       for i:=reg_one to reg_two do
-                         reglist := reglist + [i];
+                       for i.enum:=reg_one.enum to reg_two.enum do
+                         reglist := reglist + [i.enum];
                       end;
                       Consume(AS_REGISTER);
                       if not (actasmtoken in [AS_SEPARATOR,AS_COMMA]) then
@@ -2197,7 +2197,10 @@ Begin
 end.
 {
   $Log$
-  Revision 1.10  2002-12-14 15:02:03  carl
+  Revision 1.11  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.10  2002/12/14 15:02:03  carl
     * maxoperands -> max_operands (for portability in rautils.pas)
     * fix some range-check errors with loadconst
     + add ncgadd unit to m68k

+ 19 - 15
compiler/m68k/rgcpu.pas

@@ -70,7 +70,7 @@ unit rgcpu;
 
      function trgcpu.isaddressregister(reg: tregister): boolean;
        begin
-         isaddressregister := reg in addrregs;
+         isaddressregister := reg.enum in addrregs;
        end;
 
 
@@ -87,19 +87,20 @@ unit rgcpu;
     procedure trgcpu.restoreusedregisters(list : taasmoutput;
         const saved : tpushedsaved);
       var
-         r : tregister;
+         r,r2 : tregister;
          hr : treference;
      begin
         inherited restoreusedregisters(list, saved);
 
-        for r:=lastsaveaddrreg downto firstsaveaddrreg do
+        for r.enum:=lastsaveaddrreg downto firstsaveaddrreg do
           begin
-            if saved[r].ofs <> reg_not_saved then
+            if saved[r.enum].ofs <> reg_not_saved then
               begin
-                reference_reset_base(hr,FRAME_POINTER_REG,saved[r].ofs);
+                r2.enum:=frame_pointer_reg;
+                reference_reset_base(hr,r2,saved[r.enum].ofs);
                 cg.a_reg_alloc(list,r);
                 cg.a_load_ref_reg(list,OS_ADDR,hr,r);
-                if not (r in unusedregsaddr) then
+                if not (r.enum in unusedregsaddr) then
                   { internalerror(10)
                     in n386cal we always save/restore the reg *state*
                     using save/restoreunusedstate -> the current state
@@ -107,7 +108,7 @@ unit rgcpu;
                 else
                   begin
                     dec(countunusedregsint);
-                    exclude(unusedregsint,r);
+                    exclude(unusedregsint,r.enum);
                   end;
                 tg.ungettemp(list,hr);
               end;
@@ -122,22 +123,22 @@ unit rgcpu;
          hr : treference;
       begin
         inherited saveusedregisters(list, saved, s);
-        for r:=firstsaveaddrreg to lastsaveaddrreg do
+        for r.enum:=firstsaveaddrreg to lastsaveaddrreg do
           begin
-            saved[r].ofs:=reg_not_saved;
+            saved[r.enum].ofs:=reg_not_saved;
             { if the register is used by the calling subroutine and if }
             { it's not a regvar (those are handled separately)         }
-            if not is_reg_var[r] and
-               (r in s) and
+            if not is_reg_var[r.enum] and
+               (r.enum in s) and
                { and is present in use }
-               not(r in unusedregsaddr) then
+               not(r.enum in unusedregsaddr) then
               begin
                 { then save it }
                 tg.gettemp(list,pointer_size,tt_persistant,hr);
-                saved[r].ofs:=hr.offset;
+                saved[r.enum].ofs:=hr.offset;
                 cg.a_load_reg_ref(list,OS_ADDR,r,hr);
                 cg.a_reg_dealloc(list,r);
-                include(unusedregsint,r);
+                include(unusedregsint,r.enum);
                 inc(countunusedregsint);
               end;
           end;
@@ -151,7 +152,10 @@ end.
 
 {
   $Log$
-  Revision 1.4  2002-09-07 15:25:14  peter
+  Revision 1.5  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.4  2002/09/07 15:25:14  peter
     * old logs removed and tabs fixed
 
   Revision 1.3  2002/08/23 16:14:50  peter

+ 11 - 8
compiler/ncgadd.pas

@@ -199,7 +199,7 @@ interface
       begin
         if (right.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
            (cmpop or
-            (location.register <> right.location.register)) then
+            (location.register.enum <> right.location.register.enum)) then
           begin
             rg.ungetregister(exprasmlist,right.location.register);
             if is_64bitint(right.resulttype.def) then
@@ -207,7 +207,7 @@ interface
           end;
         if (left.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
            (cmpop or
-            (location.register <> left.location.register)) then
+            (location.register.enum <> left.location.register.enum)) then
           begin
             rg.ungetregister(exprasmlist,left.location.register);
             if is_64bitint(left.resulttype.def) then
@@ -316,7 +316,7 @@ interface
         
         location_reset(location,LOC_REGISTER,def_cgsize(resulttype.def));
 
-        if  (location.register = R_NO) then
+        if  (location.register.enum = R_NO) then
           location.register := rg.getregisterint(exprasmlist);
 
         case nodetype of
@@ -765,7 +765,7 @@ interface
         case nodetype of
               xorn,orn,andn,addn:
                 begin
-                  if (location.registerlow = R_NO) then
+                  if (location.registerlow.enum = R_NO) then
                     begin
                       location.registerlow := rg.getregisterint(exprasmlist);
                       location.registerhigh := rg.getregisterint(exprasmlist);
@@ -787,7 +787,7 @@ interface
 
                   if left.location.loc <> LOC_CONSTANT then
                     begin
-                      if (location.registerlow = R_NO) then
+                      if (location.registerlow.enum = R_NO) then
                         begin
                          location.registerlow := rg.getregisterint(exprasmlist);
                          location.registerhigh := rg.getregisterint(exprasmlist);
@@ -810,7 +810,7 @@ interface
                         def_cgsize(left.resulttype.def),true);
                       if (left.location.loc = LOC_REGISTER) then
                         location.register64 := left.location.register64
-                      else if (location.registerlow = R_NO) then
+                      else if (location.registerlow.enum = R_NO) then
                         begin
                          location.registerlow := rg.getregisterint(exprasmlist);
                          location.registerhigh := rg.getregisterint(exprasmlist);
@@ -876,7 +876,7 @@ interface
        load_left_right(false, (cs_check_overflow in aktlocalswitches) and
           (nodetype in [addn,subn,muln]));
 
-       if (location.register = R_NO) then
+       if (location.register.enum = R_NO) then
          location.register := rg.getregisterint(exprasmlist);
 
        { assume no overflow checking is require }
@@ -1052,7 +1052,10 @@ interface
 end.
 {
   $Log$
-  Revision 1.3  2002-12-14 15:02:03  carl
+  Revision 1.4  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.3  2002/12/14 15:02:03  carl
     * maxoperands -> max_operands (for portability in rautils.pas)
     * fix some range-check errors with loadconst
     + add ncgadd unit to m68k

+ 42 - 25
compiler/ncgcal.pas

@@ -312,11 +312,14 @@ implementation
 
     procedure tcgcallnode.extra_interrupt_code;
 
+    var r:Tregister;
+
       begin
 {$ifdef i386}
          { if the i386 ever uses tcgcal, we've to move this into an overriden method }
          emit_none(A_PUSHF,S_L);
-         emit_reg(A_PUSH,S_L,R_CS);
+         r.enum:=R_CS;
+         emit_reg(A_PUSH,S_L,r);
 {$endif i386}
       end;
 
@@ -325,7 +328,7 @@ implementation
     procedure tcgcallnode.handle_return_value(inlined,extended_new:boolean);
       var
         cgsize : tcgsize;
-        hregister : tregister;
+        r,hregister : tregister;
       begin
         { structured results are easy to handle.... }
         { needed also when result_no_used !! }
@@ -342,9 +345,10 @@ implementation
           begin
             location_reset(location,LOC_CREFERENCE,OS_ADDR);
             location.reference:=refcountedtemp;
-            cg.a_reg_alloc(exprasmlist,accumulator);
-            cg.a_load_reg_ref(exprasmlist,OS_ADDR,accumulator,location.reference);
-            cg.a_reg_dealloc(exprasmlist,accumulator);
+            r.enum:=accumulator;
+            cg.a_reg_alloc(exprasmlist,r);
+            cg.a_load_reg_ref(exprasmlist,OS_ADDR,r,location.reference);
+            cg.a_reg_dealloc(exprasmlist,r);
           end
         else
         { we have only to handle the result if it is used }
@@ -377,21 +381,23 @@ implementation
                   if cgsize<>OS_NO then
                    begin
                      location_reset(location,LOC_REGISTER,cgsize);
-                     cg.a_reg_alloc(exprasmlist,accumulator);
+                     r.enum:=accumulator;
+                     hregister.enum:=accumulatorhigh;
+                     cg.a_reg_alloc(exprasmlist,r);
 {$ifndef cpu64bit}
                      if cgsize in [OS_64,OS_S64] then
                       begin
-                        cg.a_reg_alloc(exprasmlist,accumulatorhigh);
-                        location.registerhigh:=rg.getexplicitregisterint(exprasmlist,accumulatorhigh);
-                        location.registerlow:=rg.getexplicitregisterint(exprasmlist,accumulator);
-                        cg64.a_load64_reg_reg(exprasmlist,joinreg64(accumulator,accumulatorhigh),
+                        cg.a_reg_alloc(exprasmlist,hregister);
+                        location.registerhigh:=rg.getexplicitregisterint(exprasmlist,hregister.enum);
+                        location.registerlow:=rg.getexplicitregisterint(exprasmlist,r.enum);
+                        cg64.a_load64_reg_reg(exprasmlist,joinreg64(r,hregister),
                             location.register64);
                       end
                      else
 {$endif cpu64bit}
                       begin
-                        location.register:=rg.getexplicitregisterint(exprasmlist,accumulator);
-                        hregister:=rg.makeregsize(accumulator,cgsize);
+                        location.register:=rg.getexplicitregisterint(exprasmlist,r.enum);
+                        hregister:=rg.makeregsize(r,cgsize);
                         location.register:=rg.makeregsize(location.register,cgsize);
                         cg.a_load_reg_reg(exprasmlist,cgsize,cgsize,hregister,location.register);
                       end;
@@ -400,7 +406,7 @@ implementation
               floatdef :
                 begin
                   location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
-                  location.register:=fpu_result_reg;
+                  location.register.enum:=fpu_result_reg;
 {$ifdef x86}
                   inc(trgcpu(rg).fpuvaroffset);
 {$endif x86}
@@ -427,7 +433,8 @@ implementation
                 begin
                   location_reset(location,LOC_REGISTER,OS_INT);
                   location.register:=rg.getexplicitregisterint(exprasmlist,accumulator);
-                  cg.a_load_reg_reg(exprasmlist,OS_INT,OS_INT,accumulator,location.register);
+                  r.enum:=accumulator;
+                  cg.a_load_reg_reg(exprasmlist,OS_INT,OS_INT,r,location.register);
                 end;
             end;
          end;
@@ -482,6 +489,7 @@ implementation
          resultloc : tparalocation;
          returnref,
          pararef : treference;
+         r,r2:Tregister;
       label
          dont_call;
 
@@ -1033,8 +1041,9 @@ implementation
                    (inlined or
                    (right=nil)) then
                   begin
-                     cg.a_param_reg(exprasmlist,OS_ADDR,self_pointer_reg,paramanager.getintparaloc(1));
-                     reference_reset_base(href,self_pointer_reg,0);
+                     r.enum:=self_pointer_reg;
+                     cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(1));
+                     reference_reset_base(href,r,0);
                      tmpreg:=cg.get_scratch_reg_address(exprasmlist);
                      cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,tmpreg);
                      reference_reset_base(href,tmpreg,72);
@@ -1260,7 +1269,8 @@ implementation
             (methodpointer.nodetype=typen) and
             (aktprocdef.proctypeoption=potype_constructor) then
            begin
-              cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,accumulator,faillabel);
+              r.enum:=accumulator;
+              cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,r,faillabel);
            end;
 
          { call to AfterConstruction? }
@@ -1272,17 +1282,19 @@ implementation
            (methodpointer.nodetype<>typen) then
            begin
               objectlibrary.getlabel(constructorfailed);
-              cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,self_pointer_reg,constructorfailed);
-              cg.a_param_reg(exprasmlist,OS_ADDR,accumulator,paramanager.getintparaloc(1));
-              reference_reset_base(href,self_pointer_reg,0);
+              r.enum:=self_pointer_reg;
+              r2.enum:=accumulator;
+              cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,r,constructorfailed);
+              cg.a_param_reg(exprasmlist,OS_ADDR,r2,paramanager.getintparaloc(1));
+              reference_reset_base(href,r,0);
               tmpreg:=cg.get_scratch_reg_address(exprasmlist);
               cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,tmpreg);
               reference_reset_base(href,tmpreg,17*pointer_size);
               cg.a_call_ref(exprasmlist,href);
               cg.free_scratch_reg(exprasmlist,tmpreg);
-              exprasmList.concat(tai_regalloc.Alloc(accumulator));
+              exprasmList.concat(tai_regalloc.Alloc(r2));
               cg.a_label(exprasmlist,constructorfailed);
-              cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,self_pointer_reg,accumulator);
+              cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,r,r2);
            end;
 
          { handle function results }
@@ -1298,8 +1310,9 @@ implementation
            end;
 
 {$ifdef i386}
+         r.enum:=R_ESP;
          if pop_size>0 then
-           emit_const_reg(A_ADD,S_L,pop_size,R_ESP);
+           emit_const_reg(A_ADD,S_L,pop_size,r);
 {$endif i386}
 
          { restore registers }
@@ -1359,7 +1372,8 @@ implementation
                 begin
 {$ifdef i386}
                   { release FPU stack }
-                  emit_reg(A_FSTP,S_NO,R_ST);
+                  r.enum:=R_ST;
+                  emit_reg(A_FSTP,S_NO,r);
                   {
                     dec(trgcpu(rg).fpuvaroffset);
                     do NOT decrement as the increment before
@@ -1555,7 +1569,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.32  2002-12-15 22:50:00  florian
+  Revision 1.33  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.32  2002/12/15 22:50:00  florian
     + some stuff for the new hidden parameter handling added
 
   Revision 1.31  2002/12/15 21:30:12  florian

+ 55 - 32
compiler/ncgflw.pas

@@ -663,7 +663,7 @@ implementation
          s : topsize;}
          otlabel,oflabel : tasmlabel;
          cgsize : tcgsize;
-         hreg : tregister;
+         r,hreg : tregister;
          allocated_acc,
          allocated_acchigh: boolean;
       label
@@ -702,17 +702,19 @@ implementation
 {$ifdef cpuflags}
                     LOC_FLAGS :
                       begin
-                        cg.a_reg_alloc(exprasmlist,accumulator);
+                        r.enum:=accumulator;
+                        cg.a_reg_alloc(exprasmlist,r);
                         allocated_acc := true;
-                        cg.g_flags2reg(exprasmlist,OS_INT,left.location.resflags,accumulator);
+                        cg.g_flags2reg(exprasmlist,OS_INT,left.location.resflags,r);
                         goto do_jmp;
                       end;
 {$endif cpuflags}
                     LOC_JUMP :
                       begin
-                        cg.a_reg_alloc(exprasmlist,accumulator);
+                        r.enum:=accumulator;
+                        cg.a_reg_alloc(exprasmlist,r);
                         { get an 8-bit register }
-                        hreg:=rg.makeregsize(accumulator,OS_8);
+                        hreg:=rg.makeregsize(r,OS_8);
                         allocated_acc := true;
                         cg.a_label(exprasmlist,truelabel);
                         cg.a_load_const_reg(exprasmlist,OS_8,1,hreg);
@@ -726,35 +728,39 @@ implementation
                     pointerdef,
                     procvardef :
                       begin
-                        cg.a_reg_alloc(exprasmlist,accumulator);
+                        r.enum:=accumulator;
+                        cg.a_reg_alloc(exprasmlist,r);
                         allocated_acc := true;
-                        cg.a_load_loc_reg(exprasmlist,left.location,accumulator);
+                        cg.a_load_loc_reg(exprasmlist,left.location,r);
                       end;
                     floatdef :
                       begin
+                        r.enum:=fpu_result_reg;
 {$ifndef i386}
-                        cg.a_reg_alloc(exprasmlist,FPU_RESULT_REG);
+                        cg.a_reg_alloc(exprasmlist,r);
 {$endif not i386}
-                        cg.a_loadfpu_loc_reg(exprasmlist,left.location,FPU_RESULT_REG);
+                        cg.a_loadfpu_loc_reg(exprasmlist,left.location,r);
                       end;
                     else
                       begin
                         cgsize:=def_cgsize(aktprocdef.rettype.def);
-                        cg.a_reg_alloc(exprasmlist,accumulator);
+                        r.enum:=accumulator;
+                        cg.a_reg_alloc(exprasmlist,r);
                         allocated_acc := true;
 {$ifndef cpu64bit}
 
                         if cgsize in [OS_64,OS_S64] then
                           begin
-                             cg.a_reg_alloc(exprasmlist,accumulatorhigh);
+                             hreg.enum:=accumulatorhigh;
+                             cg.a_reg_alloc(exprasmlist,hreg);
                              allocated_acchigh := true;
                              cg64.a_load64_loc_reg(exprasmlist,left.location,
-                                 joinreg64(accumulator,accumulatorhigh));
+                                 joinreg64(r,hreg));
                            end
                          else
 {$endif cpu64bit}
                            begin
-                              hreg:=rg.makeregsize(accumulator,cgsize);
+                              hreg:=rg.makeregsize(r,cgsize);
                               cg.a_load_loc_reg(exprasmlist,left.location,hreg);
                            end;
                      end;
@@ -764,15 +770,18 @@ implementation
                   truelabel:=otlabel;
                   falselabel:=oflabel;
                   cg.a_jmp_always(exprasmlist,aktexit2label);
+                  r.enum:=accumulator;
+                  hreg.enum:=accumulatorhigh;
                   if allocated_acc then
-                    cg.a_reg_dealloc(exprasmlist,accumulator);
+                    cg.a_reg_dealloc(exprasmlist,r);
 {$ifndef cpu64bit}
                   if allocated_acchigh then
-                    cg.a_reg_dealloc(exprasmlist,accumulatorhigh);
+                    cg.a_reg_dealloc(exprasmlist,hreg);
 {$endif cpu64bit}
 {$ifndef i386}
+                  r.enum:=fpu_result_reg;
                   if (aktprocdef.rettype.def.deftype = floatdef) then
-                    cg.a_reg_dealloc(exprasmlist,FPU_RESULT_REG);
+                    cg.a_reg_dealloc(exprasmlist,r);
 {$endif not i386}
                end;
            end
@@ -860,6 +869,7 @@ implementation
          a : tasmlabel;
          href : treference;
          href2: treference;
+         r:Tregister;
       begin
          if assigned(left) then
            begin
@@ -889,7 +899,8 @@ implementation
                    cg.a_label(exprasmlist,a);
                    reference_reset_symbol(href2,a,0);
                    { push current frame }
-                   cg.a_param_reg(exprasmlist,OS_ADDR,FRAME_POINTER_REG,paramanager.getintparaloc(2));
+                   r.enum:=frame_pointer_reg;
+                   cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(2));
                    { push current address }
                    cg.a_paramaddr_ref(exprasmlist,href2,paramanager.getintparaloc(1));
                 end;
@@ -941,9 +952,12 @@ implementation
     { in the except block                                    }
     procedure cleanupobjectstack;
 
+    var r:Tregister;
+
       begin
          cg.a_call_name(exprasmlist,'FPC_POPOBJECTSTACK');
-         cg.a_param_reg(exprasmlist,OS_ADDR,accumulator,paramanager.getintparaloc(1));
+         r.enum:=accumulator;
+         cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(1));
          cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
          cg.g_maybe_loadself(exprasmlist);
       end;
@@ -970,6 +984,7 @@ implementation
          exceptflowcontrol : tflowcontrol;
          tempbuf,tempaddr : treference;
          href : treference;
+         r:Tregister;
 
       label
          errorexit;
@@ -1074,7 +1089,8 @@ implementation
 
               cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
 
-              cg.a_param_reg(exprasmlist, OS_ADDR, accumulator, paramanager.getintparaloc(1));
+              r.enum:=accumulator;
+              cg.a_param_reg(exprasmlist, OS_ADDR, r, paramanager.getintparaloc(1));
               cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
               { we don't need to restore esi here because reraise never }
               { returns                                                 }
@@ -1186,8 +1202,10 @@ implementation
          tempbuf,tempaddr : treference;
          href : treference;
          href2: treference;
+         r:Tregister;
 
       begin
+         r.enum:=accumulator;
          oldflowcontrol:=flowcontrol;
          flowcontrol:=[];
          objectlibrary.getlabel(nextonlabel);
@@ -1198,14 +1216,14 @@ implementation
          cg.a_call_name(exprasmlist,'FPC_CATCHES');
 
          { is it this catch? No. go to next onlabel }
-         cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,accumulator,nextonlabel);
+         cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,r,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, accumulator, ref);
+         cg.a_load_reg_ref(exprasmlist, OS_ADDR, r, ref);
 
 
          { in the case that another exception is risen }
@@ -1242,7 +1260,7 @@ implementation
          try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
 
          cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
-         cg.a_param_reg(exprasmlist, OS_ADDR, accumulator, paramanager.getintparaloc(1));
+         cg.a_param_reg(exprasmlist, OS_ADDR, r, paramanager.getintparaloc(1));
          cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
          { we don't need to restore esi here because reraise never }
          { returns                                                 }
@@ -1317,6 +1335,7 @@ implementation
          decconst : longint;
          tempbuf,tempaddr : treference;
          href : treference;
+         r:Tregister;
 
       begin
          { check if child nodes do a break/continue/exit }
@@ -1369,29 +1388,30 @@ implementation
 
          { the value should now be in the exception handler }
          cg.g_exception_reason_load(exprasmlist,href);
-         cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,accumulator,endfinallylabel);
-         cg.a_op_const_reg(exprasmlist,OP_SUB,1,accumulator);
-         cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,accumulator,reraiselabel);
+         r.enum:=accumulator;
+         cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,r,endfinallylabel);
+         cg.a_op_const_reg(exprasmlist,OP_SUB,1,r);
+         cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,r,reraiselabel);
          if fc_exit in tryflowcontrol then
            begin
-              cg.a_op_const_reg(exprasmlist,OP_SUB,1,accumulator);
-              cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,accumulator,oldaktexitlabel);
+              cg.a_op_const_reg(exprasmlist,OP_SUB,1,r);
+              cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,r,oldaktexitlabel);
               decconst:=1;
            end
          else
            decconst:=2;
          if fc_break in tryflowcontrol then
            begin
-              cg.a_op_const_reg(exprasmlist,OP_SUB,decconst,accumulator);
-              cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,accumulator,oldaktbreaklabel);
+              cg.a_op_const_reg(exprasmlist,OP_SUB,decconst,r);
+              cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,r,oldaktbreaklabel);
               decconst:=1;
            end
          else
            inc(decconst);
          if fc_continue in tryflowcontrol then
            begin
-              cg.a_op_const_reg(exprasmlist,OP_SUB,decconst,accumulator);
-              cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,accumulator,oldaktcontinuelabel);
+              cg.a_op_const_reg(exprasmlist,OP_SUB,decconst,r);
+              cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,r,oldaktcontinuelabel);
            end;
          cg.a_label(exprasmlist,reraiselabel);
          cg.a_call_name(exprasmlist,'FPC_RERAISE');
@@ -1450,7 +1470,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.48  2003-01-03 09:51:58  daniel
+  Revision 1.49  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.48  2003/01/03 09:51:58  daniel
     * Compiler now cycles with var_notification
 
   Revision 1.47  2003/01/02 15:29:25  daniel

+ 7 - 2
compiler/ncginl.pas

@@ -177,6 +177,7 @@ 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
@@ -189,7 +190,8 @@ implementation
        maketojumpbool(exprasmlist,tcallparanode(left).left,lr_load_regvars);
        cg.a_label(exprasmlist,falselabel);
        { erroraddr }
-       cg.a_param_reg(exprasmlist,OS_ADDR,FRAME_POINTER_REG,paramanager.getintparaloc(4));
+       r.enum:=frame_pointer_reg;
+       cg.a_param_reg(exprasmlist,OS_ADDR,r,paramanager.getintparaloc(4));
        { lineno }
        cg.a_param_const(exprasmlist,OS_INT,aktfilepos.line,paramanager.getintparaloc(3));
        { filename string }
@@ -610,7 +612,10 @@ end.
 
 {
   $Log$
-  Revision 1.17  2002-11-25 17:43:18  peter
+  Revision 1.18  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.17  2002/11/25 17:43:18  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 17 - 13
compiler/ncgld.pas

@@ -67,7 +67,7 @@ implementation
     procedure tcgloadnode.pass_2;
       var
         intreg,
-        hregister : tregister;
+        r,hregister : tregister;
         symtabletype : tsymtabletype;
         i : longint;
         href : treference;
@@ -87,7 +87,7 @@ implementation
                    begin
 {$ifdef i386}
                      if tabsolutesym(symtableentry).absseg then
-                      location.reference.segment:=R_FS;
+                      location.reference.segment.enum:=R_FS;
 {$endif i386}
                      location.reference.offset:=tabsolutesym(symtableentry).address;
                    end
@@ -108,7 +108,7 @@ implementation
             varsym :
                begin
                   symtabletype:=symtable.symtabletype;
-                  hregister:=R_NO;
+                  hregister.enum:=R_NO;
                   { C variable }
                   if (vo_is_C_var in tvarsym(symtableentry).varoptions) then
                     begin
@@ -146,13 +146,14 @@ 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 }
-                       rg.saveusedregisters(exprasmlist,pushed,[accumulator]-[hregister]);
+                       rg.saveusedregisters(exprasmlist,pushed,[accumulator]-[hregister.enum]);
                        reference_reset_symbol(href,objectlibrary.newasmsymbol(tvarsym(symtableentry).mangledname),0);
                        cg.a_param_ref(exprasmlist,OS_ADDR,href,paramanager.getintparaloc(1));
                        { the called procedure isn't allowed to change }
                        { any register except EAX                    }
                        cg.a_call_reg(exprasmlist,hregister);
-                       cg.a_load_reg_reg(exprasmlist,OS_INT,OS_ADDR,accumulator,hregister);
+                       r.enum:=accumulator;
+                       cg.a_load_reg_reg(exprasmlist,OS_INT,OS_ADDR,r,hregister);
                        rg.restoreusedregisters(exprasmlist,pushed);
                        cg.a_label(exprasmlist,norelocatelab);
                        location.reference.base:=hregister;
@@ -161,9 +162,9 @@ implementation
                   else
                     begin
                        { in case it is a register variable: }
-                       if tvarsym(symtableentry).reg<>R_NO then
+                       if tvarsym(symtableentry).reg.enum<>R_NO then
                          begin
-                            if tvarsym(symtableentry).reg in fpuregs then
+                            if tvarsym(symtableentry).reg.enum in fpuregs then
                               begin
                                  location_reset(location,LOC_CFPUREGISTER,def_cgsize(resulttype.def));
                                  location.register:=tvarsym(symtableentry).reg;
@@ -171,12 +172,12 @@ implementation
                             else
                              begin
                                intreg:=rg.makeregsize(tvarsym(symtableentry).reg,OS_INT);
-                               if (intreg in general_registers) and
-                                  (not rg.regvar_loaded[intreg]) then
+                               if (intreg.enum in general_registers) and
+                                  (not rg.regvar_loaded[intreg.enum]) then
                                  load_regvar(exprasmlist,tvarsym(symtableentry));
                                location_reset(location,LOC_CREGISTER,cg.reg_cgsize(tvarsym(symtableentry).reg));
                                location.register:=tvarsym(symtableentry).reg;
-                               exclude(rg.unusedregsint,intreg);
+                               exclude(rg.unusedregsint,intreg.enum);
                              end;
                          end
                        else
@@ -246,7 +247,7 @@ implementation
                                    else
                                      begin
                                         rg.getexplicitregisterint(exprasmlist,SELF_POINTER_REG);
-                                        location.reference.base:=SELF_POINTER_REG;
+                                        location.reference.base.enum:=SELF_POINTER_REG;
                                         location.reference.offset:=tvarsym(symtableentry).address;
                                      end;
                                 end;
@@ -275,7 +276,7 @@ implementation
                       if (tvarsym(symtableentry).varspez in [vs_var,vs_out]) or
                          paramanager.push_addr_param(tvarsym(symtableentry).vartype.def,tprocdef(symtable.defowner).proccalloption) then
                         begin
-                           if hregister=R_NO then
+                           if hregister.enum=R_NO then
                              hregister:=rg.getaddressregister(exprasmlist);
                            { we need to load only an address }
                            location.size:=OS_ADDR;
@@ -959,7 +960,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.43  2003-01-05 22:44:14  peter
+  Revision 1.44  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.43  2003/01/05 22:44:14  peter
     * remove a lot of code to support typen in loadn-procsym
 
   Revision 1.42  2002/12/20 18:13:46  peter

+ 9 - 6
compiler/ncgmem.pas

@@ -352,12 +352,12 @@ implementation
             is_class(resulttype.def) then
           begin
             location_reset(location,LOC_CREGISTER,OS_ADDR);
-            location.register:=SELF_POINTER_REG;
+            location.register.enum:=SELF_POINTER_REG;
           end
          else
            begin
              location_reset(location,LOC_CREFERENCE,OS_ADDR);
-             location.reference.base:=SELF_POINTER_REG;
+             location.reference.base.enum:=SELF_POINTER_REG;
            end;
       end;
 
@@ -386,7 +386,7 @@ implementation
                secondpass(left);
 {$ifdef i386}
                if (left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) and
-                  (left.location.reference.segment<>R_NO) then
+                  (left.location.reference.segment.enum<>R_NO) then
                  message(parser_e_no_with_for_variable_in_other_segments);
 {$endif i386}
 
@@ -521,12 +521,12 @@ implementation
 
      procedure tcgvecnode.update_reference_reg_mul(reg:tregister;l:aword);
        begin
-         if location.reference.base=R_NO then
+         if location.reference.base.enum=R_NO then
           begin
             cg.a_op_const_reg(exprasmlist,OP_IMUL,l,reg);
             location.reference.base:=reg;
           end
-         else if location.reference.index=R_NO then
+         else if location.reference.index.enum=R_NO then
           begin
             cg.a_op_const_reg(exprasmlist,OP_IMUL,l,reg);
             location.reference.index:=reg;
@@ -924,7 +924,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.39  2002-12-20 18:13:19  peter
+  Revision 1.40  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.39  2002/12/20 18:13:19  peter
     * no rangecheck for openarrays with cdecl
 
   Revision 1.38  2002/12/17 22:19:33  peter

+ 9 - 4
compiler/ncgset.pas

@@ -169,6 +169,7 @@ implementation
          adjustment : longint;
          pushedregs : tmaybesave;
          l,l2,l3       : tasmlabel;
+         r:Tregister;
 
 {$ifdef oldset}
          function analizeset(Aset:Pconstset;is_small:boolean):boolean;
@@ -321,7 +322,7 @@ implementation
             { how much have we already substracted from the x in the }
             { "x in [y..z]" expression                               }
             adjustment := 0;
-            hr := R_NO;
+            hr.enum := R_NO;
 
             for i:=1 to numparts do
              if setparts[i].range then
@@ -337,7 +338,7 @@ 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 <> pleftreg) then
+                         (hr.enum <> pleftreg.enum) then
                         begin
                           hr:=cg.get_scratch_reg_int(exprasmlist);
                           cg.a_op_const_reg_reg(exprasmlist,OP_SUB,opsize,setparts[i].start,pleftreg,hr);
@@ -573,7 +574,8 @@ implementation
                   cg.a_param_ref(exprasmlist,OS_ADDR,right.location.reference,paramanager.getintparaloc(1));
                   cg.a_call_name(exprasmlist,'FPC_SET_IN_BYTE');
                   { result of value is always one full register }
-                  cg.a_load_reg_reg(exprasmlist,OS_INT,OS_INT,ACCUMULATOR,location.register);
+                  r.enum:=accumulator;
+                  cg.a_load_reg_reg(exprasmlist,OS_INT,OS_INT,r,location.register);
                   { release the allocated register  }
                   if not (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
                     rg.ungetregisterint(exprasmlist,pleftreg);
@@ -1062,7 +1064,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.24  2002-11-27 02:37:13  peter
+  Revision 1.25  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.24  2002/11/27 02:37:13  peter
     * case statement inlining added
     * fixed inlining of write()
     * switched statementnode left and right parts so the statements are

+ 97 - 43
compiler/ncgutil.pas

@@ -222,18 +222,26 @@ implementation
           LOC_REGISTER:
             begin
               { can't be a regvar, since it would be LOC_CREGISTER then }
-              exclude(regs,t.register);
-              if t.registerhigh <> R_NO then
-                exclude(regs,t.registerhigh);
+              if t.register.enum>lastreg then
+                internalerror(200201081);
+              if t.registerhigh.enum>lastreg then
+                internalerror(200201081);
+              exclude(regs,t.register.enum);
+              if t.registerhigh.enum <> R_NO then
+                exclude(regs,t.registerhigh.enum);
             end;
           LOC_CREFERENCE,LOC_REFERENCE:
             begin
+              if t.reference.base.enum>lastreg then
+                internalerror(200201081);
+              if t.reference.index.enum>lastreg then
+                internalerror(200201081);
               if not(cs_regalloc in aktglobalswitches) or
-                 (t.reference.base in rg.usableregsint) then
-                exclude(regs,t.reference.base);
+                 (t.reference.base.enum in rg.usableregsint) then
+                exclude(regs,t.reference.base.enum);
               if not(cs_regalloc in aktglobalswitches) or
-                 (t.reference.index in rg.usableregsint) then
-              exclude(regs,t.reference.index);
+                 (t.reference.index.enum in rg.usableregsint) then
+              exclude(regs,t.reference.index.enum);
             end;
         end;
       end;
@@ -244,6 +252,9 @@ 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(3));
        cg.a_paramaddr_ref(list,jmpbuf,paramanager.getintparaloc(2));
@@ -251,23 +262,28 @@ implementation
        cg.a_param_const(list,OS_S32,1,paramanager.getintparaloc(1));
        cg.a_call_name(list,'FPC_PUSHEXCEPTADDR');
 
-       cg.a_param_reg(list,OS_ADDR,accumulator,paramanager.getintparaloc(1));
+       r.enum:=accumulator;
+       cg.a_param_reg(list,OS_ADDR,r,paramanager.getintparaloc(1));
        cg.a_call_name(list,'FPC_SETJMP');
 
        cg.g_exception_reason_save(list, href);
-       cg.a_cmp_const_reg_label(list,OS_S32,OC_NE,0,accumulator,exceptlabel);
+       cg.a_cmp_const_reg_label(list,OS_S32,OC_NE,0,r,exceptlabel);
      end;
 
 
     procedure free_exception(list : taasmoutput;const jmpbuf, envbuf, href : treference;
      a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
+
+    var r:Tregister;
+
      begin
          cg.a_call_name(list,'FPC_POPADDRSTACK');
 
          if not onlyfree then
           begin
             cg.g_exception_reason_load(list, href);
-            cg.a_cmp_const_reg_label(list,OS_S32,OC_EQ,a,accumulator,endexceptlabel);
+            r.enum:=accumulator;
+            cg.a_cmp_const_reg_label(list,OS_S32,OC_EQ,a,r,endexceptlabel);
           end;
      end;
 
@@ -371,7 +387,7 @@ implementation
               if l.size in [OS_64,OS_S64] then
                begin
                  rg.ungetregisterint(list,l.registerhigh);
-                 l.registerhigh:=R_NO;
+                 l.registerhigh.enum:=R_NO;
                end;
               hregister:=l.register;
             end
@@ -609,11 +625,13 @@ implementation
              LOC_REFERENCE,
              LOC_CREFERENCE :
                begin
-                 if ((l.reference.base<>R_NO) or
-                     (l.reference.index<>R_NO)) then
+                 if l.reference.base.enum>lastreg then
+                   internalerror(200101081);
+                 if ((l.reference.base.enum<>R_NO) or
+                     (l.reference.index.enum<>R_NO)) then
                   begin
                     { load address into a single base register }
-                    if l.reference.index<>R_NO then
+                    if l.reference.index.enum<>R_NO then
                      begin
                        cg.a_loadaddr_ref_reg(list,l.reference,l.reference.index);
                        rg.ungetregister(list,l.reference.base);
@@ -703,6 +721,7 @@ implementation
         sizetopush,
         size : longint;
         cgsize : tcgsize;
+        r:Tregister;
       begin
         { we've nothing to push when the size of the parameter is 0 }
         if p.resulttype.def.size=0 then
@@ -730,10 +749,11 @@ implementation
 {$endif GDB}
 
                   { this is the easiest case for inlined !! }
+                  r.enum:=stack_pointer_reg;
                   if calloption=pocall_inline then
                    reference_reset_base(href,procinfo.framepointer,para_offset-pushedparasize)
                   else
-                   reference_reset_base(href,stack_pointer_reg,0);
+                   reference_reset_base(href,r,0);
 
                   cg.a_loadfpu_reg_ref(exprasmlist,
                     def_cgsize(p.resulttype.def),p.location.register,href);
@@ -785,7 +805,8 @@ implementation
               size:=align(p.resulttype.def.size,alignment);
               inc(pushedparasize,size);
               cg.g_stackpointer_alloc(exprasmlist,size);
-              reference_reset_base(href,STACK_POINTER_REG,0);
+              r.enum:=stack_pointer_reg;
+              reference_reset_base(href,r,0);
               cg.g_concatcopy(exprasmlist,p.location.reference,href,size,false,false);
             end
            else
@@ -1111,7 +1132,7 @@ implementation
     procedure handle_return_value(list:TAAsmoutput; inlined : boolean;var uses_acc,uses_acchi,uses_fpu : boolean);
       var
         href : treference;
-        hreg : tregister;
+        hreg,r,r2 : tregister;
         cgsize : TCGSize;
       begin
         if not is_void(aktprocdef.rettype.def) then
@@ -1130,13 +1151,17 @@ implementation
 {Here, we return the function result. In most architectures, the value is
 passed into the accumulator, but in a windowed architecure like sparc a
 function returns in a register and the caller receives it in an other one}
-                  cg.a_reg_alloc(list,return_result_reg);
+                  r.enum:=return_result_reg;
+                  cg.a_reg_alloc(list,r);
 {$ifndef cpu64bit}
                  if cgsize in [OS_64,OS_S64] then
                   begin
                     uses_acchi:=true;
-                    cg.a_reg_alloc(list,accumulatorhigh);
-                    cg64.a_load64_ref_reg(list,href,joinreg64(accumulator,accumulatorhigh));
+                    r.enum:=accumulatorhigh;
+                    cg.a_reg_alloc(list,r);
+                    r.enum:=accumulator;
+                    r2.enum:=accumulatorhigh;
+                    cg64.a_load64_ref_reg(list,href,joinreg64(r,r2));
                   end
                  else
 {$endif cpu64bit}
@@ -1145,32 +1170,39 @@ function returns in a register and the caller receives it in an other one}
 {Here, we return the function result. In most architectures, the value is
 passed into the accumulator, but in a windowed architecure like sparc a
 function returns in a register and the caller receives it in an other one}
-                    hreg:=rg.makeregsize(return_result_reg,cgsize);
+                    r.enum:=return_result_reg;
+                    hreg:=rg.makeregsize(r,cgsize);
                     cg.a_load_ref_reg(list,cgsize,href,hreg);
                   end;
                end;
              floatdef :
                begin
                  uses_fpu := true;
-                 cg.a_loadfpu_ref_reg(list,cgsize,href,FPU_RESULT_REG);
+                 r.enum:=fpu_result_reg;
+                 cg.a_loadfpu_ref_reg(list,cgsize,href,r);
                end;
              else
                begin
                  if paramanager.ret_in_acc(aktprocdef.rettype.def,aktprocdef.proccalloption) then
                   begin
                     uses_acc:=true;
-                    cg.a_reg_alloc(list,accumulator);
+                    r.enum:=accumulator;
+                    cg.a_reg_alloc(list,r);
 {$ifndef cpu64bit}
                     { Win32 can return records in EAX:EDX }
                     if cgsize in [OS_64,OS_S64] then
                      begin
                        uses_acchi:=true;
-                       cg.a_reg_alloc(list,accumulatorhigh);
-                       cg64.a_load64_ref_reg(list,href,joinreg64(accumulator,accumulatorhigh));
+                       r.enum:=accumulatorhigh;
+                       cg.a_reg_alloc(list,r);
+                       r.enum:=accumulator;
+                       r2.enum:=accumulatorhigh;
+                       cg64.a_load64_ref_reg(list,href,joinreg64(r,r2));
                      end
                     else
 {$endif cpu64bit}
-                     cg.a_load_ref_reg(list,cgsize,href,accumulator);
+                     r.enum:=accumulator;
+                     cg.a_load_ref_reg(list,cgsize,href,r);
                    end
                end;
            end;
@@ -1183,6 +1215,7 @@ function returns in a register and the caller receives it in an other one}
         href : treference;
         hreg : tregister;
         cgsize : TCGSize;
+        r,r2 : Tregister;
       begin
         if not is_void(aktprocdef.rettype.def) then
          begin
@@ -1193,23 +1226,27 @@ function returns in a register and the caller receives it in an other one}
              enumdef :
                begin
 {$ifndef cpu64bit}
+                 r.enum:=accumulator;
+                 r2.enum:=accumulatorhigh;
                  if cgsize in [OS_64,OS_S64] then
-                   cg64.a_load64_reg_ref(list,joinreg64(accumulator,accumulatorhigh),href)
+                   cg64.a_load64_reg_ref(list,joinreg64(r,r2),href)
                  else
 {$endif cpu64bit}
                   begin
-                    hreg:=rg.makeregsize(accumulator,cgsize);
+                    hreg:=rg.makeregsize(r,cgsize);
                     cg.a_load_reg_ref(list,cgsize,hreg,href);
                   end;
                end;
              floatdef :
                begin
-                 cg.a_loadfpu_reg_ref(list,cgsize,FPU_RESULT_REG,href);
+                 r.enum:=fpu_result_reg;
+                 cg.a_loadfpu_reg_ref(list,cgsize,r,href);
                end;
              else
                begin
+                 r.enum:=accumulator;
                  if paramanager.ret_in_acc(aktprocdef.rettype.def,aktprocdef.proccalloption) then
-                  cg.a_load_reg_ref(list,cgsize,accumulator,href);
+                  cg.a_load_reg_ref(list,cgsize,r,href);
                end;
            end;
          end;
@@ -1227,6 +1264,7 @@ function returns in a register and the caller receives it in an other one}
         stackalloclist : taasmoutput;
         hp : tparaitem;
         paraloc : tparalocation;
+        r:Tregister;
 
       begin
         if not inlined then
@@ -1281,9 +1319,10 @@ function returns in a register and the caller receives it in an other one}
           we must load it into ESI }
         If (po_containsself in aktprocdef.procoptions) then
           begin
-             list.concat(tai_regalloc.Alloc(self_pointer_reg));
+             r.enum:=self_pointer_reg;
+             list.concat(tai_regalloc.Alloc(r));
              reference_reset_base(href,procinfo.framepointer,procinfo.selfpointer_offset);
-             cg.a_load_ref_reg(list,OS_ADDR,href,self_pointer_reg);
+             cg.a_load_ref_reg(list,OS_ADDR,href,r);
           end;
 
 
@@ -1354,7 +1393,9 @@ function returns in a register and the caller receives it in an other one}
              hp:=tparaitem(procinfo.procdef.para.first);
              while assigned(hp) do
                begin
-                  if (tvarsym(hp.parasym).reg<>R_NO) then
+                  if Tvarsym(hp.parasym).reg.enum>lastreg then
+                    internalerror(200301081);
+                  if (tvarsym(hp.parasym).reg.enum<>R_NO) then
                     case hp.paraloc.loc of
                        LOC_CREGISTER,
                        LOC_REGISTER:
@@ -1368,7 +1409,7 @@ function returns in a register and the caller receives it in an other one}
                     end
                   else if (hp.paraloc.loc in [LOC_REGISTER,LOC_FPUREGISTER,LOC_MMREGISTER,
                     LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMREGISTER]) and
-                    (tvarsym(hp.parasym).reg=R_NO) then
+                    (tvarsym(hp.parasym).reg.enum=R_NO) then
                     begin
                        reference_reset_base(href,procinfo.framepointer,tvarsym(hp.parasym).address+
                          tvarsym(hp.parasym).owner.address_fixup);
@@ -1487,7 +1528,9 @@ function returns in a register and the caller receives it in an other one}
 {$ifndef powerpc}
            { at least for the ppc this applies always, so this code isn't usable (FK) }
            { omit stack frame ? }
-           if (procinfo.framepointer=STACK_POINTER_REG) then
+           if procinfo.framepointer.enum>lastreg then
+              internalerror(2003010801);
+           if (procinfo.framepointer.enum=STACK_POINTER_REG) then
             begin
               CGMessage(cg_d_stackframe_omited);
               nostackframe:=true;
@@ -1541,6 +1584,7 @@ function returns in a register and the caller receives it in an other one}
         usesacchi,
         usesself,usesfpu : boolean;
         pd : tprocdef;
+        r,r2:Tregister;
       begin
         if aktexit2label.is_used and
            ((procinfo.flags and (pi_needs_implicit_finally or pi_uses_exceptions)) <> 0) then
@@ -1612,14 +1656,15 @@ function returns in a register and the caller receives it in an other one}
                             objectlibrary.getlabel(nodestroycall);
                             reference_reset_base(href,procinfo.framepointer,procinfo.selfpointer_offset);
                             cg.a_cmp_const_ref_label(list,OS_ADDR,OC_EQ,0,href,nodestroycall);
+                            r.enum:=self_pointer_reg;
                             if is_class(procinfo._class) then
                              begin
                                cg.a_param_const(list,OS_INT,1,paramanager.getintparaloc(2));
-                               cg.a_param_reg(list,OS_ADDR,self_pointer_reg,paramanager.getintparaloc(1));
+                               cg.a_param_reg(list,OS_ADDR,r,paramanager.getintparaloc(1));
                              end
                             else if is_object(procinfo._class) then
                              begin
-                               cg.a_param_reg(list,OS_ADDR,self_pointer_reg,paramanager.getintparaloc(2));
+                               cg.a_param_reg(list,OS_ADDR,r,paramanager.getintparaloc(2));
                                reference_reset_symbol(href,objectlibrary.newasmsymbol(procinfo._class.vmt_mangledname),0);
                                cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(1));
                              end
@@ -1627,7 +1672,7 @@ function returns in a register and the caller receives it in an other one}
                              Internalerror(200006164);
                             if (po_virtualmethod in pd.procoptions) then
                              begin
-                               reference_reset_base(href,self_pointer_reg,0);
+                               reference_reset_base(href,r,0);
                                tmpreg:=cg.get_scratch_reg_address(list);
                                cg.a_load_ref_reg(list,OS_ADDR,href,tmpreg);
                                reference_reset_base(href,tmpreg,procinfo._class.vmtmethodoffset(pd.extnumber));
@@ -1694,12 +1739,15 @@ function returns in a register and the caller receives it in an other one}
                 { AfterConstruction                          }
                 if is_object(procinfo._class) then
                   begin
-                    cg.a_reg_alloc(list,accumulator);
-                    cg.a_load_reg_reg(list,OS_ADDR,OS_ADDR,self_pointer_reg,accumulator);
+                    r.enum:=self_pointer_reg;
+                    r2.enum:=accumulator;
+                    cg.a_reg_alloc(list,r2);
+                    cg.a_load_reg_reg(list,OS_ADDR,OS_ADDR,r,r2);
                     usesacc:=true;
                   end;
 {$ifdef i386}
-                list.concat(taicpu.op_reg_reg(A_TEST,S_L,R_ESI,R_ESI));
+                r.enum:=R_ESI;
+                list.concat(taicpu.op_reg_reg(A_TEST,S_L,r,r));
 {$else}
 {$warning constructor returns in flags for i386}
 {$endif i386}
@@ -1741,7 +1789,10 @@ function returns in a register and the caller receives it in an other one}
             cg.g_restore_frame_pointer(list)
            else
             if (tg.gettempsize<>0) then
-             cg.a_op_const_reg(list,OP_ADD,tg.gettempsize,STACK_POINTER_REG);
+              begin
+                 r.enum:=stack_pointer_reg;
+                 cg.a_op_const_reg(list,OP_ADD,tg.gettempsize,r);
+              end;
          end;
 
         { at last, the return is generated }
@@ -1903,7 +1954,10 @@ function returns in a register and the caller receives it in an other one}
 end.
 {
   $Log$
-  Revision 1.72  2002-12-29 23:51:43  florian
+  Revision 1.73  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.72  2002/12/29 23:51:43  florian
     * web bug 2214 fixed: ie 10 in const array constructors
 
   Revision 1.71  2002/12/24 15:56:50  peter

+ 14 - 11
compiler/paramgr.pas

@@ -248,7 +248,7 @@ unit paramgr;
          result.loc:=LOC_REFERENCE;
          result.size:=OS_ADDR;
          result.sp_fixup:=pointer_size;
-         result.reference.index:=stack_pointer_reg;
+         result.reference.index.enum:=stack_pointer_reg;
          result.reference.offset:=0;
       end;
 
@@ -258,7 +258,7 @@ unit paramgr;
          result.loc:=LOC_REFERENCE;
          result.size:=OS_ADDR;
          result.sp_fixup:=pointer_size;
-         result.reference.index:=stack_pointer_reg;
+         result.reference.index.enum:=stack_pointer_reg;
          result.reference.offset:=0;
       end;
 
@@ -277,29 +277,29 @@ unit paramgr;
 {$ifndef cpu64bit}
                if result.size in [OS_64,OS_S64] then
                 begin
-                  result.register64.reghi:=accumulatorhigh;
-                  result.register64.reglo:=accumulator;
+                  result.register64.reghi.enum:=accumulatorhigh;
+                  result.register64.reglo.enum:=accumulator;
                 end
                else
 {$endif cpu64bit}
-               result.register:=accumulator;
+               result.register.enum:=accumulator;
              end;
            floatdef :
              begin
                result.loc := LOC_FPUREGISTER;
 {$ifdef cpufpemu}
                if cs_fp_emulation in aktmoduleswitches then
-                  result.register := accumulator
+                  result.register.enum := accumulator
                else
 {$endif cpufpemu}
-                  result.register := FPU_RESULT_REG;
+                  result.register.enum := FPU_RESULT_REG;
              end;
           else
              begin
                 if ret_in_reg(def,calloption) then
                   begin
                     result.loc := LOC_REGISTER;
-                    result.register := accumulator;
+                    result.register.enum := accumulator;
                   end
                 else
                    begin
@@ -344,12 +344,12 @@ unit paramgr;
           LOC_CMMREGISTER,
           LOC_REGISTER,LOC_CREGISTER :
               begin
-                regset := regset + [paramloc.register];
+                regset := regset + [paramloc.register.enum];
                 if ((paramloc.size in [OS_S64,OS_64]) and
                    (sizeof(aword) < 8))
                 then
                   begin
-                     regset := regset + [paramloc.registerhigh];
+                     regset := regset + [paramloc.registerhigh.enum];
                   end;
               end;
           else
@@ -400,7 +400,10 @@ end.
 
 {
    $Log$
-   Revision 1.29  2002-12-23 20:58:03  peter
+   Revision 1.30  2003-01-08 18:43:56  daniel
+    * Tregister changed into a record
+
+   Revision 1.29  2002/12/23 20:58:03  peter
      * remove unused global var
 
    Revision 1.28  2002/12/17 22:19:33  peter

+ 5 - 2
compiler/pmodules.pas

@@ -732,7 +732,7 @@ implementation
          begin
            _class:=nil;
            para_offset:=target_info.first_parm_offset;
-           framepointer:=FRAME_POINTER_REG;
+           framepointer.enum:=FRAME_POINTER_REG;
            flags:=0;
            procdef:=aktprocdef;
          end;
@@ -1437,7 +1437,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.91  2003-01-05 13:36:53  florian
+  Revision 1.92  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.91  2003/01/05 13:36:53  florian
     * x86-64 compiles
     + very basic support for float128 type (x86-64 only)
 

+ 11 - 8
compiler/powerpc/agppcgas.pas

@@ -174,7 +174,7 @@ unit agppcgas;
            if (symaddr <> refs_full) then
              s := s+')'+symaddr2str[symaddr];
 
-           if (index=R_NO) and (base<>R_NO) then
+           if (index.enum=R_NO) and (base.enum<>R_NO) then
              begin
                 if offset=0 then
                   begin
@@ -183,11 +183,11 @@ unit agppcgas;
                      else
                        s:=s+'0';
                   end;
-                s:=s+'('+gas_reg2str[base]+')'
+                s:=s+'('+gas_reg2str[base.enum]+')'
              end
-           else if (index<>R_NO) and (base<>R_NO) and (offset=0) then
-             s:=s+gas_reg2str[base]+','+gas_reg2str[index]
-           else if ((index<>R_NO) or (base<>R_NO)) then
+           else if (index.enum<>R_NO) and (base.enum<>R_NO) and (offset=0) then
+             s:=s+gas_reg2str[base.enum]+','+gas_reg2str[index.enum]
+           else if ((index.enum<>R_NO) or (base.enum<>R_NO)) then
             internalerror(19992);
         end;
       getreferencestring:=s;
@@ -200,7 +200,7 @@ unit agppcgas;
     begin
       case o.typ of
         top_reg :
-          getopstr_jmp:=gas_reg2str[o.reg];
+          getopstr_jmp:=gas_reg2str[o.reg.enum];
         { no top_ref jumping for powerpc }
         top_const :
           getopstr_jmp:=tostr(o.val);
@@ -234,7 +234,7 @@ unit agppcgas;
     begin
       case o.typ of
         top_reg:
-          getopstr:=gas_reg2str[o.reg];
+          getopstr:=gas_reg2str[o.reg.enum];
         { no top_ref jumping for powerpc }
         top_const:
           getopstr:=tostr(longint(o.val));
@@ -366,7 +366,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.19  2002-11-07 15:50:23  jonas
+  Revision 1.20  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.19  2002/11/07 15:50:23  jonas
     * fixed bctr(l) problems
 
   Revision 1.18  2002/09/08 13:03:26  jonas

+ 13 - 10
compiler/powerpc/agppcmpw.pas

@@ -182,16 +182,16 @@ function getreferencestring(var ref : treference) : string;
                s:=s+tostr(offset);
             end;
 
-          if (index=R_NO) and (base<>R_NO) then
+          if (index.enum=R_NO) and (base.enum<>R_NO) then
             begin
               if offset=0 then
                 if not assigned(symbol) then
                   s:=s+'0';
-              s:=s+'('+mpw_reg2str[base]+')'
+              s:=s+'('+mpw_reg2str[base.enum]+')'
             end
-          else if (index<>R_NO) and (base<>R_NO) and (offset=0) then
-            s:=s+mpw_reg2str[base]+','+mpw_reg2str[index]
-          else if ((index<>R_NO) or (base<>R_NO)) then
+          else if (index.enum<>R_NO) and (base.enum<>R_NO) and (offset=0) then
+            s:=s+mpw_reg2str[base.enum]+','+mpw_reg2str[index.enum]
+          else if ((index.enum<>R_NO) or (base.enum<>R_NO)) then
             internalerror(19992);
         end;
       getreferencestring:=s;
@@ -203,7 +203,7 @@ function getreferencestring(var ref : treference) : string;
     begin
       case o.typ of
         top_reg :
-          getopstr_jmp:=mpw_reg2str[o.reg];
+          getopstr_jmp:=mpw_reg2str[o.reg.enum];
         { no top_ref jumping for powerpc }
         top_const :
           getopstr_jmp:=tostr(o.val);
@@ -238,7 +238,7 @@ function getreferencestring(var ref : treference) : string;
     begin
       case o.typ of
         top_reg:
-          getopstr:=mpw_reg2str[o.reg];
+          getopstr:=mpw_reg2str[o.reg.enum];
         { no top_ref jumping for powerpc }
         top_const:
           getopstr:=tostr(longint(o.val));
@@ -353,7 +353,7 @@ function getreferencestring(var ref : treference) : string;
         begin
           case op of
              A_MFSPR:
-               case taicpu(hp).oper[1].reg of
+               case taicpu(hp).oper[1].reg.enum of
                   R_CR:
                     begin
                        op:=A_MFCR;
@@ -368,7 +368,7 @@ function getreferencestring(var ref : treference) : string;
                     internalerror(2002100701);
                end;
              A_MTSPR:
-               case taicpu(hp).oper[1].reg of
+               case taicpu(hp).oper[1].reg.enum of
                   R_CR:
                     begin
                        op:=A_MTCR;
@@ -1122,7 +1122,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.16  2002-11-28 10:56:07  olle
+  Revision 1.17  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.16  2002/11/28 10:56:07  olle
     * changed proc ref from .xxx[PR] (refering to its section)
       to .xxx (refering to its label) to allow for multiple ref to a proc.
 

+ 217 - 149
compiler/powerpc/cgcpu.pas

@@ -323,7 +323,7 @@ const
          { 64 bit stuff should be handled separately }
          if size in [OS_64,OS_S64] then
            internalerror(200109236);
-         op := storeinstr[tcgsize2unsigned[size],ref2.index<>R_NO,false];
+         op := storeinstr[tcgsize2unsigned[size],ref2.index.enum<>R_NO,false];
          a_load_store(list,op,reg,ref2);
          if freereg then
            cg.free_scratch_reg(list,ref2.base);
@@ -355,7 +355,7 @@ const
             internalerror(2002090902);
           ref2 := ref;
           freereg := fixref(list,ref2);
-          op := loadinstr[size,ref2.index<>R_NO,false];
+          op := loadinstr[size,ref2.index.enum<>R_NO,false];
           a_load_store(list,op,reg,ref2);
           if freereg then
             free_scratch_reg(list,ref2.base);
@@ -369,7 +369,11 @@ const
      procedure tcgppc.a_load_reg_reg(list : taasmoutput;fromsize, tosize : tcgsize;reg1,reg2 : tregister);
 
        begin
-         if (reg1 <> reg2) or
+         if reg1.enum>lastreg then
+            internalerror(200301081);
+         if reg2.enum>lastreg then
+            internalerror(200301081);
+         if (reg1.enum <> reg2.enum) or
             (tcgsize2size[tosize] < tcgsize2size[fromsize]) or
             ((tcgsize2size[tosize] = tcgsize2size[fromsize]) and
              (tosize <> fromsize) and
@@ -426,7 +430,7 @@ const
           end;
          ref2 := ref;
          freereg := fixref(list,ref2);
-         op := fpuloadinstr[size,ref2.index <> R_NO,false];
+         op := fpuloadinstr[size,ref2.index.enum <> R_NO,false];
          a_load_store(list,op,reg,ref2);
          if freereg then
            cg.free_scratch_reg(list,ref2.base);
@@ -450,7 +454,7 @@ const
            internalerror(200201122);
          ref2 := ref;
          freereg := fixref(list,ref2);
-         op := fpustoreinstr[size,ref2.index <> R_NO,false];
+         op := fpustoreinstr[size,ref2.index.enum <> R_NO,false];
          a_load_store(list,op,reg,ref2);
          if freereg then
            cg.free_scratch_reg(list,ref2.base);
@@ -490,6 +494,8 @@ const
           end;
 
       begin
+        if src.enum>lastreg then
+          internalerror(200301081);
         if op = OP_SUB then
           begin
 {$ifopt q+}
@@ -606,7 +612,7 @@ const
           OP_OR:
             { try to use rlwimi }
             if gotrlwi and
-               (src = dst) then
+               (src.enum = dst.enum) then
               begin
                 scratchreg := get_scratch_reg_int(list);
                 list.concat(taicpu.op_reg_const(A_LI,scratchreg,-1));
@@ -675,6 +681,7 @@ const
           p: taicpu;
           scratch_register: TRegister;
           signed: boolean;
+          r:Tregister;
 
         begin
           signed := cmp_op in [OC_GT,OC_LT,OC_GTE,OC_LTE];
@@ -683,24 +690,25 @@ const
           if (cmp_op in [OC_EQ,OC_NE]) and
              (a > $ffff) then
             signed := true;
+          r.enum:=R_CR0;
           if signed then
             if (longint(a) >= low(smallint)) and (longint(a) <= high(smallint)) Then
-              list.concat(taicpu.op_reg_reg_const(A_CMPWI,R_CR0,reg,longint(a)))
+              list.concat(taicpu.op_reg_reg_const(A_CMPWI,r,reg,longint(a)))
             else
               begin
                 scratch_register := get_scratch_reg_int(list);
                 a_load_const_reg(list,OS_32,a,scratch_register);
-                list.concat(taicpu.op_reg_reg_reg(A_CMPW,R_CR0,reg,scratch_register));
+                list.concat(taicpu.op_reg_reg_reg(A_CMPW,r,reg,scratch_register));
                 free_scratch_reg(list,scratch_register);
               end
           else
             if (a <= $ffff) then
-              list.concat(taicpu.op_reg_reg_const(A_CMPLWI,R_CR0,reg,a))
+              list.concat(taicpu.op_reg_reg_const(A_CMPLWI,r,reg,a))
             else
               begin
                 scratch_register := get_scratch_reg_int(list);
                 a_load_const_reg(list,OS_32,a,scratch_register);
-                list.concat(taicpu.op_reg_reg_reg(A_CMPLW,R_CR0,reg,scratch_register));
+                list.concat(taicpu.op_reg_reg_reg(A_CMPLW,r,reg,scratch_register));
                 free_scratch_reg(list,scratch_register);
               end;
           a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
@@ -713,12 +721,14 @@ const
         var
           p: taicpu;
             op: tasmop;
+          r:Tregister;
 
         begin
           if cmp_op in [OC_GT,OC_LT,OC_GTE,OC_LTE] then
             op := A_CMPW
           else op := A_CMPLW;
-          list.concat(taicpu.op_reg_reg_reg(op,R_CR0,reg1,reg2));
+          r.enum:=R_CR0;
+          list.concat(taicpu.op_reg_reg_reg(op,r,reg1,reg2));
           a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
         end;
 
@@ -759,9 +769,11 @@ const
 
        var
          c: tasmcond;
+         r:Tregister;
        begin
          c := flags_to_cond(f);
-         a_jmp(list,A_BC,c.cond,ord(c.cr)-ord(R_CR0),l);
+         r.enum:=R_CR0;
+         a_jmp(list,A_BC,c.cond,ord(c.cr)-ord(r.enum),l);
        end;
 
      procedure tcgppc.g_flags2reg(list: taasmoutput; size: TCgSize; const f: TResFlags; reg: TRegister);
@@ -894,6 +906,7 @@ const
          usesfpr,usesgpr,gotgot : boolean;
          parastart : aword;
          offset : aword;
+         r,r2,rsp:Tregister;
 
       begin
         { we do our own localsize calculation }
@@ -902,15 +915,17 @@ 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           }
-        a_reg_alloc(list,STACK_POINTER_REG);
-        a_reg_alloc(list,R_0);
+        rsp.enum:=stack_pointer_reg;
+        a_reg_alloc(list,rsp);
+        r.enum:=R_0;
+        a_reg_alloc(list,r);
         { allocate registers containing reg parameters }
-        for regcounter := R_3 to R_10 do
+        for regcounter.enum := R_3 to R_10 do
           a_reg_alloc(list,regcounter);
 
         usesfpr:=false;
-        for regcounter:=R_F14 to R_F31 do
-          if regcounter in rg.usedbyproc then
+        for regcounter.enum:=R_F14 to R_F31 do
+          if regcounter.enum in rg.usedbyproc then
             begin
                usesfpr:=true;
                firstregfpu:=regcounter;
@@ -918,8 +933,8 @@ const
             end;
 
         usesgpr:=false;
-        for regcounter:=R_14 to R_31 do
-          if regcounter in rg.usedbyproc then
+        for regcounter.enum:=R_14 to R_31 do
+          if regcounter.enum in rg.usedbyproc then
             begin
                usesgpr:=true;
                firstreggpr:=regcounter;
@@ -930,25 +945,27 @@ const
         if (procinfo.flags and pi_do_call)<>0 then
           begin
              { save return address... }
-             list.concat(taicpu.op_reg(A_MFLR,R_0));
+             r.enum:=R_0;
+             list.concat(taicpu.op_reg(A_MFLR,r));
              { ... in caller's rframe }
-             reference_reset_base(href,STACK_POINTER_REG,4);
-             list.concat(taicpu.op_reg_ref(A_STW,R_0,href));
-             a_reg_dealloc(list,R_0);
+             reference_reset_base(href,rsp,4);
+             list.concat(taicpu.op_reg_ref(A_STW,r,href));
+             a_reg_dealloc(list,r);
           end;
 
         if usesfpr or usesgpr then
           begin
-             a_reg_alloc(list,R_11);
+             r.enum:=R_11;
+             a_reg_alloc(list,r);
              { save end of fpr save area }
-             list.concat(taicpu.op_reg_reg_const(A_ORI,R_11,STACK_POINTER_REG,0));
+             list.concat(taicpu.op_reg_reg_const(A_ORI,r,rsp,0));
           end;
 
         { calculate the size of the locals }
         if usesgpr then
-          inc(localsize,(ord(R_31)-ord(firstreggpr)+1)*4);
+          inc(localsize,(ord(R_31)-ord(firstreggpr.enum)+1)*4);
         if usesfpr then
-          inc(localsize,(ord(R_F31)-ord(firstregfpu)+1)*8);
+          inc(localsize,(ord(R_F31)-ord(firstregfpu.enum)+1)*8);
 
         { align to 16 bytes }
         localsize:=align(localsize,16);
@@ -959,8 +976,9 @@ const
 
         tppcprocinfo(procinfo).localsize:=localsize;
 
-        reference_reset_base(href,R_1,-localsize);
-        a_load_store(list,A_STWU,R_1,href);
+        r.enum:=R_1;
+        reference_reset_base(href,r,-localsize);
+        a_load_store(list,A_STWU,r,href);
 
         { no GOT pointer loaded yet }
         gotgot:=false;
@@ -975,8 +993,8 @@ const
              else
                a_call_name(objectlibrary.newasmsymbol('_savefpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14));
              }
-             for regcounter:=firstregfpu to R_F31 do
-               if regcounter in rg.usedbyproc then
+             for regcounter.enum:=firstregfpu.enum to R_F31 do
+               if regcounter.enum in rg.usedbyproc then
                  begin
                     { reference_reset_base(href,R_1,-localsize);
                     a_load_store(list,A_STWU,R_1,href);
@@ -984,7 +1002,8 @@ const
                  end;
 
              { compute end of gpr save area }
-             list.concat(taicpu.op_reg_reg_const(A_ADDI,R_11,R_11,-(ord(R_F31)-ord(firstregfpu)+1)*8));
+             r.enum:=R_11;
+             list.concat(taicpu.op_reg_reg_const(A_ADDI,r,r,-(ord(R_F31)-ord(firstregfpu.enum)+1)*8));
           end;
 
         { save gprs and fetch GOT pointer }
@@ -999,12 +1018,14 @@ const
              else
                a_call_name(objectlibrary.newasmsymbol('_savegpr_'+tostr(ord(firstreggpr)-ord(R_14)+14))
              }
-             reference_reset_base(href,R_11,-(ord(R_31)-ord(firstreggpr)+1)*4);
+             r.enum:=R_11;
+             reference_reset_base(href,r,-(ord(R_31)-ord(firstreggpr.enum)+1)*4);
              list.concat(taicpu.op_reg_ref(A_STMW,firstreggpr,href));
           end;
 
+        r.enum:=R_11;
         if usesfpr or usesgpr then
-          a_reg_dealloc(list,R_11);
+          a_reg_dealloc(list,r);
 
         { PIC code support, }
         if cs_create_pic in aktmoduleswitches then
@@ -1014,9 +1035,11 @@ const
                begin
                   {!!!!!!!!!!!!!}
                end;
-             a_reg_alloc(list,R_31);
+             r.enum:=R_31;
+             r2.enum:=R_LR;
+             a_reg_alloc(list,r);
              { place GOT ptr in r31 }
-             list.concat(taicpu.op_reg_reg(A_MFSPR,R_31,R_LR));
+             list.concat(taicpu.op_reg_reg(A_MFSPR,r,r2));
           end;
         { save the CR if necessary ( !!! always done currently ) }
         { still need to find out where this has to be done for SystemV
@@ -1034,16 +1057,17 @@ const
          regcounter,firstregfpu,firstreggpr : TRegister;
          href : treference;
          usesfpr,usesgpr,genret : boolean;
+         r,r2:Tregister;
 
       begin
         { release parameter registers }
-        for regcounter := R_3 to R_10 do
+        for regcounter.enum := R_3 to R_10 do
           a_reg_dealloc(list,regcounter);
         { AltiVec context restore, not yet implemented !!! }
 
         usesfpr:=false;
-        for regcounter:=R_F14 to R_F31 do
-          if regcounter in rg.usedbyproc then
+        for regcounter.enum:=R_F14 to R_F31 do
+          if regcounter.enum in rg.usedbyproc then
             begin
                usesfpr:=true;
                firstregfpu:=regcounter;
@@ -1051,8 +1075,8 @@ const
             end;
 
         usesgpr:=false;
-        for regcounter:=R_14 to R_30 do
-          if regcounter in rg.usedbyproc then
+        for regcounter.enum:=R_14 to R_30 do
+          if regcounter.enum in rg.usedbyproc then
             begin
                usesgpr:=true;
                firstreggpr:=regcounter;
@@ -1064,17 +1088,19 @@ const
         if usesgpr then
           begin
              { address of gpr save area to r11 }
+             r.enum:=R_1;
+             r2.enum:=R_11;
              if usesfpr then
-               list.concat(taicpu.op_reg_reg_const(A_ADDI,R_11,R_1,tppcprocinfo(procinfo).localsize-(ord(R_F31)-ord(firstregfpu)+1)*8))
+               list.concat(taicpu.op_reg_reg_const(A_ADDI,r2,r,tppcprocinfo(procinfo).localsize-(ord(R_F31)-ord(firstregfpu.enum)+1)*8))
              else
-               list.concat(taicpu.op_reg_reg_const(A_ADDI,R_11,R_1,tppcprocinfo(procinfo).localsize));
+               list.concat(taicpu.op_reg_reg_const(A_ADDI,r2,r,tppcprocinfo(procinfo).localsize));
 
              { restore gprs }
              { at least for now we use LMW }
              {
              a_call_name(objectlibrary.newasmsymbol('_restgpr_14');
              }
-             reference_reset_base(href,R_11,-(ord(R_31)-ord(firstreggpr)+1)*4);
+             reference_reset_base(href,r2,-(ord(R_31)-ord(firstreggpr.enum)+1)*4);
              list.concat(taicpu.op_reg_ref(A_LMW,firstreggpr,href));
           end;
 
@@ -1082,14 +1108,15 @@ const
         if usesfpr then
           begin
              { address of fpr save area to r11 }
-             list.concat(taicpu.op_reg_reg_const(A_ADDI,R_11,R_11,(ord(R_F31)-ord(firstregfpu)+1)*8));
+             r.enum:=R_11;
+             list.concat(taicpu.op_reg_reg_const(A_ADDI,r,r,(ord(R_F31)-ord(firstregfpu.enum)+1)*8));
              {
              if (procinfo.flags and pi_do_call)<>0 then
                a_call_name(objectlibrary.newasmsymbol('_restfpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)+
                  '_x')
              else
                { leaf node => lr haven't to be restored }
-               a_call_name('_restfpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)+
+               a_call_name('_restfpr_'+tostr(ord(firstregfpu.enum)-ord(R_F14)+14)+
                  '_l');
              genret:=false;
              }
@@ -1098,13 +1125,16 @@ const
         if genret then
           begin
              { adjust r1 }
-             a_op_const_reg(list,OP_ADD,tppcprocinfo(procinfo).localsize,R_1);
+             r.enum:=R_1;
+             a_op_const_reg(list,OP_ADD,tppcprocinfo(procinfo).localsize,r);
              { load link register? }
              if (procinfo.flags and pi_do_call)<>0 then
                begin
-                  reference_reset_base(href,STACK_POINTER_REG,4);
-                  list.concat(taicpu.op_reg_ref(A_LWZ,R_0,href));
-                  list.concat(taicpu.op_reg(A_MTLR,R_0));
+                  r.enum:=stack_pointer_reg;
+                  reference_reset_base(href,r,4);
+                  r.enum:=R_0;
+                  list.concat(taicpu.op_reg_ref(A_LWZ,r,href));
+                  list.concat(taicpu.op_reg(A_MTLR,r));
                end;
              list.concat(taicpu.op_none(A_BLR));
           end;
@@ -1119,11 +1149,12 @@ const
          usesfpr,usesgpr: boolean;
          href : treference;
          offset: integer;
+         r:Tregister;
 
     begin
       usesfpr:=false;
-      for regcounter:=R_F14 to R_F31 do
-        if regcounter in rg.usedbyproc then
+      for regcounter.enum:=R_F14 to R_F31 do
+        if regcounter.enum in rg.usedbyproc then
           begin
              usesfpr:=true;
              firstregfpu:=regcounter;
@@ -1131,8 +1162,8 @@ const
           end;
 
       usesgpr:=false;
-      for regcounter:=R_13 to R_31 do
-        if regcounter in rg.usedbyproc then
+      for regcounter.enum:=R_13 to R_31 do
+        if regcounter.enum in rg.usedbyproc then
           begin
              usesgpr:=true;
              firstreggpr:=regcounter;
@@ -1143,29 +1174,32 @@ const
 
       { save floating-point registers }
       if usesfpr then
-        for regcounter := firstregfpu to R_F31 do
+        for regcounter.enum := firstregfpu.enum to R_F31 do
           begin
             offset:= offset - 8;
-            reference_reset_base(href, STACK_POINTER_REG, offset);
+            r.enum:=stack_pointer_reg;
+            reference_reset_base(href, r, offset);
             list.concat(taicpu.op_reg_ref(A_STFD, regcounter, href));
           end;
         (* Optimiztion in the future:  a_call_name(list,'_savefXX'); *)
 
       { save gprs in gpr save area }
       if usesgpr then
-        if firstreggpr < R_30 then
+        if firstreggpr.enum < R_30 then
           begin
-            offset:= offset - 4 * (ord(R_31) - ord(firstreggpr) + 1);
-            reference_reset_base(href,STACK_POINTER_REG,offset);
+            offset:= offset - 4 * (ord(R_31) - ord(firstreggpr.enum) + 1);
+            r.enum:=stack_pointer_reg;
+            reference_reset_base(href,r,offset);
             list.concat(taicpu.op_reg_ref(A_STMW,firstreggpr,href));
               {STMW stores multiple registers}
           end
         else
           begin
-            for regcounter := firstreggpr to R_31 do
+            for regcounter.enum := firstreggpr.enum to R_31 do
               begin
                 offset:= offset - 4;
-                reference_reset_base(href, STACK_POINTER_REG, offset);
+                r.enum:=stack_pointer_reg;
+                reference_reset_base(href, r, offset);
                 list.concat(taicpu.op_reg_ref(A_STW, regcounter, href));
               end;
           end;
@@ -1183,11 +1217,12 @@ const
          usesfpr,usesgpr: boolean;
          href : treference;
          offset: integer;
+         r:Tregister;
 
     begin
       usesfpr:=false;
-      for regcounter:=R_F14 to R_F31 do
-        if regcounter in rg.usedbyproc then
+      for regcounter.enum:=R_F14 to R_F31 do
+        if regcounter.enum in rg.usedbyproc then
           begin
              usesfpr:=true;
              firstregfpu:=regcounter;
@@ -1195,8 +1230,8 @@ const
           end;
 
       usesgpr:=false;
-      for regcounter:=R_13 to R_31 do
-        if regcounter in rg.usedbyproc then
+      for regcounter.enum:=R_13 to R_31 do
+        if regcounter.enum in rg.usedbyproc then
           begin
              usesgpr:=true;
              firstreggpr:=regcounter;
@@ -1207,29 +1242,32 @@ const
 
       { restore fp registers }
       if usesfpr then
-        for regcounter := firstregfpu to R_F31 do
+        for regcounter.enum := firstregfpu.enum to R_F31 do
           begin
             offset:= offset - 8;
-            reference_reset_base(href, STACK_POINTER_REG, offset);
+            r.enum:=stack_pointer_reg;
+            reference_reset_base(href, r, offset);
             list.concat(taicpu.op_reg_ref(A_LFD, regcounter, href));
           end;
         (* Optimiztion in the future: a_call_name(list,'_restfXX'); *)
 
       { restore gprs }
       if usesgpr then
-        if firstreggpr < R_30 then
+        if firstreggpr.enum < R_30 then
           begin
-            offset:= offset - 4 * (ord(R_31) - ord(firstreggpr) + 1);
-            reference_reset_base(href,STACK_POINTER_REG,offset); //-220
+            offset:= offset - 4 * (ord(R_31) - ord(firstreggpr.enum) + 1);
+            r.enum:=stack_pointer_reg;
+            reference_reset_base(href,r,offset); //-220
             list.concat(taicpu.op_reg_ref(A_LMW,firstreggpr,href));
               {LMW loads multiple registers}
           end
         else
           begin
-            for regcounter := firstreggpr to R_31 do
+            for regcounter.enum := firstreggpr.enum to R_31 do
               begin
                 offset:= offset - 4;
-                reference_reset_base(href, STACK_POINTER_REG, offset);
+                r.enum:=stack_pointer_reg;
+                reference_reset_base(href, r, offset);
                 list.concat(taicpu.op_reg_ref(A_LWZ, regcounter, href));
               end;
           end;
@@ -1250,6 +1288,7 @@ const
      var regcounter: TRegister;
          href : treference;
          registerSaveAreaSize : longint;
+         r,r2,rsp:Tregister;
 
       begin
         if (localsize mod 8) <> 0 then internalerror(58991);
@@ -1257,30 +1296,34 @@ 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           }
-        a_reg_alloc(list,STACK_POINTER_REG);
-        a_reg_alloc(list,R_0);
+        r.enum:=R_0;
+        rsp.enum:=stack_pointer_reg;
+        a_reg_alloc(list,rsp);
+        a_reg_alloc(list,r);
 
         { allocate registers containing reg parameters }
-        for regcounter := R_3 to R_10 do
+        for regcounter.enum := R_3 to R_10 do
           a_reg_alloc(list,regcounter);
         {TODO: Allocate fp and altivec parameter registers also}
 
         { save return address in callers frame}
-        list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_LR));
+        r2.enum:=R_LR;
+        list.concat(taicpu.op_reg_reg(A_MFSPR,r,r2));
         { ... in caller's frame }
-        reference_reset_base(href,STACK_POINTER_REG,8);
-        list.concat(taicpu.op_reg_ref(A_STW,R_0,href));
-        a_reg_dealloc(list,R_0);
+        reference_reset_base(href,rsp,8);
+        list.concat(taicpu.op_reg_ref(A_STW,r,href));
+        a_reg_dealloc(list,r);
 
         { save non-volatile registers in callers frame}
         registerSaveAreaSize:= save_regs(list);
 
         { save the CR if necessary in callers frame ( !!! always done currently ) }
-        a_reg_alloc(list,R_0);
-        list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_CR));
-        reference_reset_base(href,stack_pointer_reg,LA_CR);
-        list.concat(taicpu.op_reg_ref(A_STW,R_0,href));
-        a_reg_dealloc(list,R_0);
+        a_reg_alloc(list,r);
+        r2.enum:=R_CR;
+        list.concat(taicpu.op_reg_reg(A_MFSPR,r,r2));
+        reference_reset_base(href,rsp,LA_CR);
+        list.concat(taicpu.op_reg_ref(A_STW,r,href));
+        a_reg_dealloc(list,r);
 
         (*
         { save pointer to incoming arguments }
@@ -1308,8 +1351,9 @@ const
         localsize:=align(localsize,16);
         tppcprocinfo(procinfo).localsize:=localsize;
 
-        reference_reset_base(href,R_1,-localsize);
-        a_load_store(list,A_STWU,R_1,href);
+        r.enum:=R_1;
+        reference_reset_base(href,r,-localsize);
+        a_load_store(list,A_STWU,r,href);
           { this also stores the old stack pointer in the new stack frame }
       end;
 
@@ -1318,27 +1362,32 @@ const
       var
         regcounter: TRegister;
         href : treference;
+        r,r2,rsp:Tregister;
       begin
         { release parameter registers }
-        for regcounter := R_3 to R_10 do
+        for regcounter.enum := R_3 to R_10 do
           a_reg_dealloc(list,regcounter);
         {TODO: Release fp and altivec parameter registers also}
 
-        a_reg_alloc(list,R_0);
+        r.enum:=R_0;
+        rsp.enum:=stack_pointer_reg;
+        a_reg_alloc(list,r);
 
         { restore stack pointer }
-        reference_reset_base(href,stack_pointer_reg,LA_SP);
-        list.concat(taicpu.op_reg_ref(A_LWZ,STACK_POINTER_REG,href));
+        reference_reset_base(href,rsp,LA_SP);
+        list.concat(taicpu.op_reg_ref(A_LWZ,rsp,href));
         (*
-        list.concat(taicpu.op_reg_reg_const(A_ORI,STACK_POINTER_REG,R_31,0));
+        list.concat(taicpu.op_reg_reg_const(A_ORI,rsp,R_31,0));
         *)
 
         { restore the CR if necessary from callers frame
             ( !!! always done currently ) }
-        reference_reset_base(href,STACK_POINTER_REG,LA_CR);
-        list.concat(taicpu.op_reg_ref(A_LWZ,R_0,href));
-        list.concat(taicpu.op_reg_reg(A_MTSPR,R_0,R_CR));
-        a_reg_dealloc(list,R_0);
+        reference_reset_base(href,rsp,LA_CR);
+        r.enum:=R_0;
+        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);
 
         (*
         { restore return address from callers frame }
@@ -1356,11 +1405,13 @@ const
         *)
 
         { restore return address from callers frame }
-        reference_reset_base(href,STACK_POINTER_REG,8);
-        list.concat(taicpu.op_reg_ref(A_LWZ,R_0,href));
+        r.enum:=R_0;
+        r2.enum:=R_LR;
+        reference_reset_base(href,rsp,8);
+        list.concat(taicpu.op_reg_ref(A_LWZ,r,href));
 
         { return to caller }
-        list.concat(taicpu.op_reg_reg(A_MTSPR,R_0,R_LR));
+        list.concat(taicpu.op_reg_reg(A_MTSPR,r,r2));
         list.concat(taicpu.op_none(A_BLR));
       end;
 
@@ -1377,6 +1428,7 @@ const
        var
          ref2, tmpref: treference;
          freereg: boolean;
+         r2:Tregister;
 
        begin
          ref2 := ref;
@@ -1385,15 +1437,16 @@ const
            begin
              if target_info.system = system_powerpc_macos then
                begin
-                 if ref2.base <> R_NO then
+                 if ref2.base.enum <> R_NO then
                    internalerror(2002103102); //TODO: Implement this if needed
 
                  reference_reset(tmpref);
                  tmpref.offset := ref2.offset;
                  tmpref.symbol := ref2.symbol;
                  tmpref.symaddr := refs_full;
-                 tmpref.base := R_NO;
-                 list.concat(taicpu.op_reg_reg_ref(A_ADDI,r,R_TOC,tmpref));
+                 tmpref.base.enum := R_NO;
+                 r2.enum:=R_TOC;
+                 list.concat(taicpu.op_reg_reg_ref(A_ADDI,r,r2,tmpref));
                end
              else
                begin
@@ -1404,7 +1457,7 @@ const
                  tmpref.offset := ref2.offset;
                  tmpref.symbol := ref2.symbol;
                  tmpref.symaddr := refs_ha;
-                 if ref2.base <> R_NO then
+                 if ref2.base .enum<> R_NO then
                    begin
                      list.concat(taicpu.op_reg_reg_ref(A_ADDIS,r,
                        ref2.base,tmpref));
@@ -1416,7 +1469,7 @@ const
                    end
                  else
                    list.concat(taicpu.op_reg_ref(A_LIS,r,tmpref));
-                 tmpref.base := R_NO;
+                 tmpref.base.enum := R_NO;
                  tmpref.symaddr := refs_l;
                  { can be folded with one of the next instructions by the }
                  { optimizer probably                                     }
@@ -1424,16 +1477,16 @@ const
                end
            end
          else if ref2.offset <> 0 Then
-           if ref2.base <> R_NO then
+           if ref2.base.enum <> R_NO then
              a_op_const_reg_reg(list,OP_ADD,OS_32,ref2.offset,ref2.base,r)
            { FixRef makes sure that "(ref.index <> R_NO) and (ref.offset <> 0)" never}
            { occurs, so now only ref.offset has to be loaded                         }
            else
              a_load_const_reg(list,OS_32,ref2.offset,r)
-         else if ref.index <> R_NO Then
+         else if ref.index.enum <> R_NO Then
            list.concat(taicpu.op_reg_reg_reg(A_ADD,r,ref2.base,ref2.index))
-         else if (ref2.base <> R_NO) and
-                 (r <> ref2.base) then
+         else if (ref2.base.enum <> R_NO) and
+                 (r.enum <> ref2.base.enum) then
            list.concat(taicpu.op_reg_reg(A_MR,r,ref2.base));
          if freereg then
            cg.free_scratch_reg(list,ref2.base);
@@ -1449,6 +1502,7 @@ const
         lab: tasmlabel;
         count, count2: aword;
         orgsrc, orgdst: boolean;
+        r:Tregister;
 
       begin
 {$ifdef extdebug}
@@ -1469,12 +1523,13 @@ const
                 end
               else
                 begin
-                  a_reg_alloc(list,R_F0);
-                  a_loadfpu_ref_reg(list,OS_F64,source,R_F0);
+                  r.enum:=R_F0;
+                  a_reg_alloc(list,r);
+                  a_loadfpu_ref_reg(list,OS_F64,source,r);
                   if delsource then
                     reference_release(list,source);
-                  a_loadfpu_reg_ref(list,OS_F64,R_F0,dest);
-                  a_reg_dealloc(list,R_F0);
+                  a_loadfpu_reg_ref(list,OS_F64,r,dest);
+                  a_reg_dealloc(list,r);
                 end;
               exit;
             end;
@@ -1489,7 +1544,7 @@ const
             orgsrc := false;
           end
         else if not issimpleref(source) or
-                ((source.index <> R_NO) and
+                ((source.index.enum <> R_NO) and
                  ((source.offset + longint(len)) > high(smallint))) then
           begin
             src.base := get_scratch_reg_address(list);
@@ -1505,7 +1560,7 @@ const
           reference_release(list,source);
         { load the address of dest into dst.base }
         if not issimpleref(dest) or
-           ((dest.index <> R_NO) and
+           ((dest.index.enum <> R_NO) and
             ((dest.offset + longint(len)) > high(smallint))) then
           begin
             dst.base := get_scratch_reg_address(list);
@@ -1534,15 +1589,17 @@ const
             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)                    }
-            a_reg_alloc(list,R_F0);
+            r.enum:=R_F0;
+            a_reg_alloc(list,r);
             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_LFDU,R_F0,src));
-            list.concat(taicpu.op_reg_ref(A_STFDU,R_F0,dst));
+            r.enum:=R_F0;
+            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);
             free_scratch_reg(list,countreg);
-            a_reg_dealloc(list,R_F0);
+            a_reg_dealloc(list,r);
             len := len mod 8;
           end;
 
@@ -1550,43 +1607,47 @@ const
         if count > 0 then
           { unrolled loop }
           begin
-            a_reg_alloc(list,R_F0);
+            r.enum:=R_F0;
+            a_reg_alloc(list,r);
             for count2 := 1 to count do
               begin
-                a_loadfpu_ref_reg(list,OS_F64,src,R_F0);
-                a_loadfpu_reg_ref(list,OS_F64,R_F0,dst);
+                a_loadfpu_ref_reg(list,OS_F64,src,r);
+                a_loadfpu_reg_ref(list,OS_F64,r,dst);
                 inc(src.offset,8);
                 inc(dst.offset,8);
               end;
-            a_reg_dealloc(list,R_F0);
+            a_reg_dealloc(list,r);
             len := len mod 8;
           end;
 
         if (len and 4) <> 0 then
           begin
-            a_reg_alloc(list,R_0);
-            a_load_ref_reg(list,OS_32,src,R_0);
-            a_load_reg_ref(list,OS_32,R_0,dst);
+            r.enum:=R_0;
+            a_reg_alloc(list,r);
+            a_load_ref_reg(list,OS_32,src,r);
+            a_load_reg_ref(list,OS_32,r,dst);
             inc(src.offset,4);
             inc(dst.offset,4);
-            a_reg_dealloc(list,R_0);
+            a_reg_dealloc(list,r);
           end;
        { copy the leftovers }
        if (len and 2) <> 0 then
          begin
-           a_reg_alloc(list,R_0);
-           a_load_ref_reg(list,OS_16,src,R_0);
-           a_load_reg_ref(list,OS_16,R_0,dst);
+           r.enum:=R_0;
+           a_reg_alloc(list,r);
+           a_load_ref_reg(list,OS_16,src,r);
+           a_load_reg_ref(list,OS_16,r,dst);
            inc(src.offset,2);
            inc(dst.offset,2);
-           a_reg_dealloc(list,R_0);
+           a_reg_dealloc(list,r);
          end;
        if (len and 1) <> 0 then
          begin
-           a_reg_alloc(list,R_0);
-           a_load_ref_reg(list,OS_8,src,R_0);
-           a_load_reg_ref(list,OS_8,R_0,dst);
-           a_reg_dealloc(list,R_0);
+           r.enum:=R_0;
+           a_reg_alloc(list,r);
+           a_load_ref_reg(list,OS_8,src,r);
+           a_load_reg_ref(list,OS_8,r,dst);
+           a_reg_dealloc(list,r);
          end;
        if orgsrc then
          begin
@@ -1604,6 +1665,7 @@ const
 
       var
          hl : tasmlabel;
+         r:Tregister;
       begin
          if not(cs_check_overflow in aktlocalswitches) then
           exit;
@@ -1613,7 +1675,8 @@ const
                  (torddef(p.resulttype.def).typ in [u64bit,u16bit,u32bit,u8bit,uchar,
                                                   bool8bit,bool16bit,bool32bit]))) then
            begin
-             list.concat(taicpu.op_reg(A_MCRXR,R_CR7));
+             r.enum:=R_CR7;
+             list.concat(taicpu.op_reg(A_MCRXR,r));
              a_jmp(list,A_BC,C_OV,7,hl)
            end
          else
@@ -1628,15 +1691,15 @@ const
     function tcgppc.issimpleref(const ref: treference): boolean;
 
       begin
-        if (ref.base = R_NO) and
-           (ref.index <> R_NO) then
+        if (ref.base.enum = R_NO) and
+           (ref.index.enum <> R_NO) then
           internalerror(200208101);
         result :=
           not(assigned(ref.symbol)) and
-          (((ref.index = R_NO) and
+          (((ref.index.enum = R_NO) and
             (ref.offset >= low(smallint)) and
             (ref.offset <= high(smallint))) or
-           ((ref.index <> R_NO) and
+           ((ref.index.enum <> R_NO) and
             (ref.offset = 0)));
       end;
 
@@ -1647,9 +1710,9 @@ const
          tmpreg: tregister;
        begin
          result := false;
-         if (ref.base <> R_NO) then
+         if (ref.base.enum <> R_NO) then
            begin
-             if (ref.index <> R_NO) and
+             if (ref.index.enum <> R_NO) and
                 ((ref.offset <> 0) or assigned(ref.symbol)) then
                begin
                  result := true;
@@ -1666,13 +1729,13 @@ const
                    begin
                      list.concat(taicpu.op_reg_reg_reg(
                        A_ADD,tmpreg,ref.base,ref.index));
-                     ref.index := R_NO;
+                     ref.index.enum := R_NO;
                    end;
                  ref.base := tmpreg;
                end
            end
          else
-           if ref.index <> R_NO then
+           if ref.index.enum <> R_NO then
              internalerror(200208102);
        end;
 
@@ -1751,16 +1814,17 @@ const
       var
         tmpreg: tregister;
         tmpref: treference;
+        r : Tregister;
 
       begin
-        tmpreg := R_NO;
+        tmpreg.enum := R_NO;
         if assigned(ref.symbol) or
            (cardinal(ref.offset-low(smallint)) >
             high(smallint)-low(smallint)) then
           begin
             if target_info.system = system_powerpc_macos then
               begin
-                if ref.base <> R_NO then
+                if ref.base.enum <> R_NO then
                   begin
                     {Generates
                       add   tempreg, ref.base, RTOC
@@ -1778,8 +1842,9 @@ const
                     tmpref.symaddr := refs_full;
                     tmpref.base:= tmpreg;
 
+                    r.enum:=R_TOC;
                     list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg,
-                        ref.base,R_TOC));
+                        ref.base,r));
                     list.concat(taicpu.op_reg_ref(op,reg,tmpref));
                   end
                 else
@@ -1788,7 +1853,7 @@ const
                     tmpref.symbol := ref.symbol;
                     tmpref.offset := ref.offset;
                     tmpref.symaddr := refs_full;
-                    tmpref.base:= R_TOC;
+                    tmpref.base.enum:= R_TOC;
                     list.concat(taicpu.op_reg_ref(op,reg,tmpref));
                   end;
               end
@@ -1799,7 +1864,7 @@ const
                 tmpref.symbol := ref.symbol;
                 tmpref.offset := ref.offset;
                 tmpref.symaddr := refs_ha;
-                if ref.base <> R_NO then
+                if ref.base.enum <> R_NO then
                   list.concat(taicpu.op_reg_reg_ref(A_ADDIS,tmpreg,
                     ref.base,tmpref))
                 else
@@ -1811,7 +1876,7 @@ const
           end
         else
           list.concat(taicpu.op_reg_ref(op,reg,ref));
-        if (tmpreg <> R_NO) then
+        if (tmpreg.enum <> R_NO) then
           free_scratch_reg(list,tmpreg);
       end;
 
@@ -1935,7 +2000,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.67  2002-12-15 19:22:01  florian
+  Revision 1.68  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.67  2002/12/15 19:22:01  florian
     * fixed some crashes and a rte 201
 
   Revision 1.66  2002/11/28 10:55:16  olle

+ 26 - 15
compiler/powerpc/cpubase.pas

@@ -100,7 +100,7 @@ uses
 *****************************************************************************}
 
     type
-      tregister = (R_NO,
+      Toldregister = (R_NO,
         R_0,R_1,R_2,R_3,R_4,R_5,R_6,R_7,R_8,R_9,R_10,R_11,R_12,R_13,R_14,R_15,R_16,
         R_17,R_18,R_19,R_20,R_21,R_22,R_23,R_24,R_25,R_26,R_27,R_28,R_29,R_30,R_31,
         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,
@@ -112,9 +112,14 @@ uses
         R_CR,R_CR0,R_CR1,R_CR2,R_CR3,R_CR4,R_CR5,R_CR6,R_CR7,
         R_XER,R_LR,R_CTR,R_FPSCR
       );
+      
+      Tregister=record
+        enum:Toldregister;
+        number:word;
+      end;
 
       {# Set type definition for registers }
-      tregisterset = set of tregister;
+      tregisterset = set of Toldregister;
 
       { A type to store register locations for 64 Bit values. }
       tregister64 = packed record
@@ -124,14 +129,17 @@ uses
       { alias for compact code }
       treg64 = tregister64;
 
-      {# Type definition for the array of string of register nnames }
-      treg2strtable = array[tregister] of string[5];
 
     Const
       {# First register in the tregister enumeration }
-      firstreg = low(tregister);
+      firstreg = low(Toldregister);
       {# Last register in the tregister enumeration }
-      lastreg  = high(tregister);
+      lastreg  = R_FPSCR;
+    type
+      {# Type definition for the array of string of register nnames }
+      treg2strtable = array[firstreg..lastreg] of string[5];
+
+    const
 
       R_SPR1 = R_XER;
       R_SPR8 = R_LR;
@@ -484,32 +492,32 @@ uses
       lastsavemmreg   = R_NO;
 
       maxvarregs = 17;
-      varregs : Array [1..maxvarregs] of Tregister =
+      varregs : Array [1..maxvarregs] of Toldregister =
                 (R_14,R_15,R_16,R_17,R_18,R_19,R_20,R_21,R_22,R_23,R_24,R_25,
                  R_26,R_27,R_28,R_29,R_30);
 
       maxfpuvarregs = 31-14+1;
-      fpuvarregs : Array [1..maxfpuvarregs] of Tregister =
+      fpuvarregs : Array [1..maxfpuvarregs] of Toldregister =
                 (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);
 
       max_param_regs_int = 8;
-      param_regs_int: Array[1..max_param_regs_int] of tregister =
+      param_regs_int: Array[1..max_param_regs_int] of Toldregister =
         (R_3,R_4,R_5,R_6,R_7,R_8,R_9,R_10);
 
       max_param_regs_fpu = 13;
-      param_regs_fpu: Array[1..max_param_regs_fpu] of tregister =
+      param_regs_fpu: Array[1..max_param_regs_fpu] of Toldregister =
         (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);
 
       max_param_regs_mm = 13;
-      param_regs_mm: Array[1..max_param_regs_mm] of tregister =
+      param_regs_mm: Array[1..max_param_regs_mm] of Toldregister =
         (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 TRegister = (R_28,R_29,R_30);
+      scratch_regs: Array[1..max_scratch_regs] of Toldregister = (R_28,R_29,R_30);
 
 {*****************************************************************************
                           Default generic sizes
@@ -538,7 +546,7 @@ uses
 
       }
 
-          stab_regindex : array[tregister] of shortint =
+          stab_regindex : array[firstreg..lastreg] of shortint =
           (
            { R_NO }
            -1,
@@ -733,14 +741,17 @@ implementation
         case cond of
           C_NONE:;
           C_T..C_DZF: r.crbit := cr
-          else r.cr := tregister(ord(R_CR0)+cr);
+          else r.cr := Toldregister(ord(R_CR0)+cr);
         end;
       end;
 
 end.
 {
   $Log$
-  Revision 1.38  2002-11-25 17:43:27  peter
+  Revision 1.39  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.38  2002/11/25 17:43:27  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 26 - 23
compiler/powerpc/cpupara.pas

@@ -60,7 +60,7 @@ unit cpupara;
          else
            begin
               result.loc:=LOC_REFERENCE;
-              result.reference.index:=stack_pointer_reg;
+              result.reference.index.enum:=stack_pointer_reg;
               result.reference.offset:=(nr-8)*4;
            end;
       end;
@@ -132,31 +132,31 @@ unit cpupara;
       procedure assignintreg;
 
         begin
-           if nextintreg<=R_10 then
+           if nextintreg.enum<=R_10 then
              begin
                 hp.paraloc.loc:=LOC_REGISTER;
                 hp.paraloc.register:=nextintreg;
-                inc(nextintreg);
+                inc(nextintreg.enum);
              end
            else
               begin
                  hp.paraloc.loc:=LOC_REFERENCE;
-                 hp.paraloc.reference.index:=stack_pointer_reg;
+                 hp.paraloc.reference.index.enum:=stack_pointer_reg;
                  hp.paraloc.reference.offset:=stack_offset;
                  inc(stack_offset,4);
              end;
         end;
 
       begin
-         nextintreg:=R_3;
-         nextfloatreg:=R_F1;
-         nextmmreg:=R_M1;
+         nextintreg.enum:=R_3;
+         nextfloatreg.enum:=R_F1;
+         nextmmreg.enum:=R_M1;
          stack_offset:=0;
          { pointer for structured results ? }
          if not is_void(p.rettype.def) then
            begin
               if not(ret_in_reg(p.rettype.def,p.proccalloption)) then
-                inc(nextintreg);
+                inc(nextintreg.enum);
            end;
 
          { frame pointer for nested procedures? }
@@ -176,22 +176,22 @@ unit cpupara;
                       if hp.paraloc.size = OS_NO then
                         hp.paraloc.size := OS_ADDR;
                       is_64bit := hp.paraloc.size in [OS_64,OS_S64];
-                      if nextintreg<=tregister(ord(R_10)-ord(is_64bit))  then
+                      if nextintreg.enum<=Toldregister(ord(R_10)-ord(is_64bit))  then
                         begin
                            hp.paraloc.loc:=LOC_REGISTER;
                            hp.paraloc.registerlow:=nextintreg;
-                           inc(nextintreg);
+                           inc(nextintreg.enum);
                            if is_64bit then
                              begin
                                hp.paraloc.registerhigh:=nextintreg;
-                               inc(nextintreg);
+                               inc(nextintreg.enum);
                              end;
                         end
                       else
                          begin
-                            nextintreg := R_11;
+                            nextintreg.enum := R_11;
                             hp.paraloc.loc:=LOC_REFERENCE;
-                            hp.paraloc.reference.index:=stack_pointer_reg;
+                            hp.paraloc.reference.index.enum:=stack_pointer_reg;
                             hp.paraloc.reference.offset:=stack_offset;
                             if not is_64bit then
                               inc(stack_offset,4)
@@ -203,12 +203,12 @@ unit cpupara;
                    begin
                       if hp.paratyp in [vs_var,vs_out] then
                         begin
-                            if nextintreg<=R_10 then
+                            if nextintreg.enum<=R_10 then
                              begin
                                 hp.paraloc.size:=OS_ADDR;
                                 hp.paraloc.loc:=LOC_REGISTER;
                                 hp.paraloc.register:=nextintreg;
-                                inc(nextintreg);
+                                inc(nextintreg.enum);
                              end
                            else
                               begin
@@ -217,12 +217,12 @@ unit cpupara;
                                  internalerror(2002071006);
                              end;
                         end
-                      else if nextfloatreg<=R_F10 then
+                      else if nextfloatreg.enum<=R_F10 then
                         begin
                            hp.paraloc.size:=def_cgsize(hp.paratype.def);
                            hp.paraloc.loc:=LOC_FPUREGISTER;
                            hp.paraloc.register:=nextfloatreg;
-                           inc(nextfloatreg);
+                           inc(nextfloatreg.enum);
                         end
                       else
                          begin
@@ -239,7 +239,7 @@ unit cpupara;
                       else
                         begin
                            hp.paraloc.loc:=LOC_REFERENCE;
-                           hp.paraloc.reference.index:=stack_pointer_reg;
+                           hp.paraloc.reference.index.enum:=stack_pointer_reg;
                            hp.paraloc.reference.offset:=stack_offset;
                            inc(stack_offset,hp.paratype.def.size);
                         end;
@@ -258,15 +258,15 @@ unit cpupara;
             enumdef:
               begin
                 getfuncretparaloc.loc:=LOC_REGISTER;
-                getfuncretparaloc.register:=R_3;
+                getfuncretparaloc.register.enum:=R_3;
                 getfuncretparaloc.size:=def_cgsize(p.rettype.def);
                 if getfuncretparaloc.size in [OS_S64,OS_64] then
-                  getfuncretparaloc.registerhigh:=R_4;
+                  getfuncretparaloc.registerhigh.enum:=R_4;
               end;
             floatdef:
               begin
                 getfuncretparaloc.loc:=LOC_FPUREGISTER;
-                getfuncretparaloc.register:=R_F1;
+                getfuncretparaloc.register.enum:=R_F1;
                 getfuncretparaloc.size:=def_cgsize(p.rettype.def);
               end;
             { smallsets are OS_INT in R3, others are OS_ADDR in R3 -> the same }
@@ -285,7 +285,7 @@ unit cpupara;
             errordef:
               begin
                 getfuncretparaloc.loc:=LOC_REGISTER;
-                getfuncretparaloc.register:=R_3;
+                getfuncretparaloc.register.enum:=R_3;
                 getfuncretparaloc.size:=OS_ADDR;
               end;
             else
@@ -299,7 +299,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.18  2002-12-15 19:22:01  florian
+  Revision 1.19  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.18  2002/12/15 19:22:01  florian
     * fixed some crashes and a rte 201
 
   Revision 1.17  2002/11/25 17:43:27  peter

+ 25 - 18
compiler/powerpc/nppcadd.pas

@@ -164,7 +164,7 @@ interface
       begin
         if (right.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
            (cmpop or
-            (location.register <> right.location.register)) then
+            (location.register.enum <> right.location.register.enum)) then
           begin
             rg.ungetregister(exprasmlist,right.location.register);
             if is_64bitint(right.resulttype.def) then
@@ -172,7 +172,7 @@ interface
           end;
         if (left.location.loc in [LOC_REGISTER,LOC_FPUREGISTER]) and
            (cmpop or
-            (location.register <> left.location.register)) then
+            (location.register.enum <> left.location.register.enum)) then
           begin
             rg.ungetregister(exprasmlist,left.location.register);
             if is_64bitint(left.resulttype.def) then
@@ -232,8 +232,8 @@ interface
                  (not unsigned and
                   (longint(right.location.value) < low(smallint)) or
                    (longint(right.location.value) > high(smallint))) then
-                // we can then maybe use a constant in the 'othersigned' case
-                // (the sign doesn't matter for // equal/unequal)
+                { we can then maybe use a constant in the 'othersigned' case
+                 (the sign doesn't matter for // equal/unequal)}
                 unsigned := not unsigned;
 
             if (unsigned and
@@ -449,6 +449,7 @@ interface
         reg   : tregister;
         op    : TAsmOp;
         cmpop : boolean;
+        r     : Tregister;
 
       procedure location_force_fpureg(var l: tlocation);
         begin
@@ -521,8 +522,9 @@ interface
           end
         else
           begin
+            r.enum:=location.resflags.cr;
             exprasmlist.concat(taicpu.op_reg_reg_reg(op,
-              location.resflags.cr,left.location.register,right.location.register))
+              r,left.location.register,right.location.register))
           end;
 
         clear_left_right(cmpop);
@@ -560,7 +562,7 @@ interface
         load_left_right(cmpop,false);
 
         if not(cmpop) and
-           (location.register = R_NO) then
+           (location.register.enum = R_NO) then
           location.register := rg.getregisterint(exprasmlist);
 
         case nodetype of
@@ -707,6 +709,7 @@ interface
         hl4        : tasmlabel;
         cmpop,
         unsigned   : boolean;
+        r          : Tregister;
 
 
       procedure emit_cmp64_hi;
@@ -936,13 +939,14 @@ interface
                          tempreg64);
                     end;
 
-                  cg.a_reg_alloc(exprasmlist,R_0);
-                  exprasmlist.concat(taicpu.op_reg_reg_reg(A_OR_,R_0,
+                  r.enum:=R_0;
+                  cg.a_reg_alloc(exprasmlist,r);
+                  exprasmlist.concat(taicpu.op_reg_reg_reg(A_OR_,r,
                     tempreg64.reglo,tempreg64.reghi));
-                  cg.a_reg_dealloc(exprasmlist,R_0);
-                  if (tempreg64.reglo <> left.location.registerlow) then
+                  cg.a_reg_dealloc(exprasmlist,r);
+                  if (tempreg64.reglo.enum <> left.location.registerlow.enum) then
                     cg.free_scratch_reg(exprasmlist,tempreg64.reglo);
-                  if (tempreg64.reghi <> left.location.registerhigh) then
+                  if (tempreg64.reghi.enum <> left.location.registerhigh.enum) then
                     cg.free_scratch_reg(exprasmlist,tempreg64.reghi);
 
                   location_reset(location,LOC_FLAGS,OS_NO);
@@ -950,7 +954,7 @@ interface
                 end;
               xorn,orn,andn,addn:
                 begin
-                  if (location.registerlow = R_NO) then
+                  if (location.registerlow.enum = R_NO) then
                     begin
                       location.registerlow := rg.getregisterint(exprasmlist);
                       location.registerhigh := rg.getregisterint(exprasmlist);
@@ -972,7 +976,7 @@ interface
 
                   if left.location.loc <> LOC_CONSTANT then
                     begin
-                      if (location.registerlow = R_NO) then
+                      if (location.registerlow.enum = R_NO) then
                         begin
                          location.registerlow := rg.getregisterint(exprasmlist);
                          location.registerhigh := rg.getregisterint(exprasmlist);
@@ -990,7 +994,7 @@ interface
                     end
                   else if ((left.location.valueqword shr 32) = 0) then
                     begin
-                      if (location.registerlow = R_NO) then
+                      if (location.registerlow.enum = R_NO) then
                         begin
                          location.registerlow := rg.getregisterint(exprasmlist);
                          location.registerhigh := rg.getregisterint(exprasmlist);
@@ -1018,7 +1022,7 @@ interface
                   else if (aword(left.location.valueqword) = 0) then
                     begin
                       // (const32 shl 32) - reg64
-                      if (location.registerlow = R_NO) then
+                      if (location.registerlow.enum = R_NO) then
                         begin
                          location.registerlow := rg.getregisterint(exprasmlist);
                          location.registerhigh := rg.getregisterint(exprasmlist);
@@ -1038,7 +1042,7 @@ interface
                         def_cgsize(left.resulttype.def),true);
                       if (left.location.loc = LOC_REGISTER) then
                         location.register64 := left.location.register64
-                      else if (location.registerlow = R_NO) then
+                      else if (location.registerlow.enum = R_NO) then
                         begin
                          location.registerlow := rg.getregisterint(exprasmlist);
                          location.registerhigh := rg.getregisterint(exprasmlist);
@@ -1364,7 +1368,7 @@ interface
          load_left_right(cmpop, (cs_check_overflow in aktlocalswitches) and
             (nodetype in [addn,subn,muln]));
 
-         if (location.register = R_NO) and
+         if (location.register.enum = R_NO) and
             not(cmpop) then
            location.register := rg.getregisterint(exprasmlist);
 
@@ -1464,7 +1468,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.20  2002-11-25 17:43:27  peter
+  Revision 1.21  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.20  2002/11/25 17:43:27  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 14 - 9
compiler/powerpc/nppcmat.pas

@@ -150,7 +150,7 @@ implementation
              rg.ungetregister(exprasmlist,divider);
            end;
        { free used registers }
-        if numerator <> resultreg then
+        if numerator.enum <> resultreg.enum then
           rg.ungetregisterint(exprasmlist,numerator);
         { set result location }
         location.loc:=LOC_REGISTER;
@@ -177,6 +177,7 @@ implementation
          asmop1, asmop2: tasmop;
          shiftval: aword;
          saved : tmaybesave;
+         r : Tregister;
 
       begin
          secondpass(left);
@@ -265,23 +266,24 @@ implementation
                    end;
 
                  rg.getexplicitregisterint(exprasmlist,R_0);
+                 r.enum:=R_0;
                  exprasmlist.concat(taicpu.op_reg_reg_const(A_SUBFIC,
-                   R_0,hregister1,32));
+                   r,hregister1,32));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(asmop1,
                    location.registerhigh,hregisterhigh,hregister1));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(asmop2,
-                   R_0,hregisterlow,R_0));
+                   r,hregisterlow,r));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(A_OR,
-                   location.registerhigh,location.registerhigh,R_0));
+                   location.registerhigh,location.registerhigh,r));
                  exprasmlist.concat(taicpu.op_reg_reg_const(A_SUBI,
-                   R_0,hregister1,32));
+                   r,hregister1,32));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(asmop1,
-                   R_0,hregisterlow,R_0));
+                   r,hregisterlow,r));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(A_OR,
-                   location.registerhigh,location.registerhigh,R_0));
+                   location.registerhigh,location.registerhigh,r));
                  exprasmlist.concat(taicpu.op_reg_reg_reg(asmop1,
                    location.registerlow,hregisterlow,hregister1));
-                 rg.ungetregister(exprasmlist,R_0);
+                 rg.ungetregister(exprasmlist,r);
 
                  if right.location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
                    cg.free_scratch_reg(exprasmlist,hregister1)
@@ -503,7 +505,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.20  2002-11-25 17:43:28  peter
+  Revision 1.21  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.20  2002/11/25 17:43:28  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 8 - 2
compiler/powerpc/nppcset.pas

@@ -65,6 +65,8 @@ implementation
 
       procedure genitem(t : pcaserecord);
 
+      var r:Tregister;
+
           procedure gensub(value:longint);
           var
             tmpreg: tregister;
@@ -95,8 +97,9 @@ implementation
              end;
            if t^._low=t^._high then
              begin
+                r.enum:=R_CR0;
                 if t^._low-last=0 then
-                  exprasmlist.concat(taicpu.op_reg_reg_const(A_CMPWI,R_CR0,
+                  exprasmlist.concat(taicpu.op_reg_reg_const(A_CMPWI,r,
                     hregister,0))
                 else
                   gensub(longint(t^._low-last));
@@ -156,7 +159,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.5  2002-11-25 17:43:28  peter
+  Revision 1.6  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.5  2002/11/25 17:43:28  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 8 - 5
compiler/powerpc/radirect.pas

@@ -171,11 +171,11 @@ interface
                                                  hs:=tvarsym(sym).mangledname
                                                else
                                                  begin
-                                                    if (tvarsym(sym).reg<>R_NO) then
-                                                      hs:=gas_reg2str[procinfo.framepointer]
+                                                    if (tvarsym(sym).reg.enum<>R_NO) then
+                                                      hs:=gas_reg2str[procinfo.framepointer.enum]
                                                     else
                                                       hs:=tostr(tvarsym(sym).address)+
-                                                        '('+gas_reg2str[procinfo.framepointer]+')';
+                                                        '('+gas_reg2str[procinfo.framepointer.enum]+')';
                                                  end;
                                             end
                                           else
@@ -196,7 +196,7 @@ interface
                                                     l:=tvarsym(sym).address;
                                                     { set offset }
                                                     inc(l,aktprocdef.parast.address_fixup);
-                                                    hs:=tostr(l)+'('+gas_reg2str[procinfo.framepointer]+')';
+                                                    hs:=tostr(l)+'('+gas_reg2str[procinfo.framepointer.enum]+')';
                                                     if pos(',',s) > 0 then
                                                       tvarsym(sym).varstate:=vs_used;
                                                  end;
@@ -314,7 +314,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.6  2002-11-25 17:43:28  peter
+  Revision 1.7  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.6  2002/11/25 17:43:28  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 12 - 6
compiler/powerpc/rgcpu.pas

@@ -35,7 +35,7 @@ unit rgcpu;
 
      type
        trgcpu = class(trgobj)
-         function getexplicitregisterint(list: taasmoutput; reg: tregister): tregister; override;
+         function getexplicitregisterint(list: taasmoutput; reg: Toldregister): tregister; override;
          procedure ungetregisterint(list: taasmoutput; reg: tregister); override;
        end;
 
@@ -44,13 +44,16 @@ unit rgcpu;
     uses
       cgobj;
 
-    function trgcpu.getexplicitregisterint(list: taasmoutput; reg: tregister): tregister;
+    function trgcpu.getexplicitregisterint(list: taasmoutput; reg: Toldregister): tregister;
+
+    var r:Tregister;
 
       begin
         if reg = R_0 then
           begin
-            cg.a_reg_alloc(list,reg);
-            result := reg;
+            r.enum:=R_0;
+            cg.a_reg_alloc(list,r);
+            result := r;
           end
         else result := inherited getexplicitregisterint(list,reg);
       end;
@@ -59,7 +62,7 @@ unit rgcpu;
     procedure trgcpu.ungetregisterint(list: taasmoutput; reg: tregister);
 
       begin
-        if reg = R_0 then
+        if reg.enum = R_0 then
           cg.a_reg_dealloc(list,reg)
         else
           inherited ungetregisterint(list,reg);
@@ -71,7 +74,10 @@ end.
 
 {
   $Log$
-  Revision 1.3  2002-07-07 09:44:32  florian
+  Revision 1.4  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.3  2002/07/07 09:44:32  florian
     * powerpc target fixed, very simple units can be compiled
 
   Revision 1.2  2002/05/16 19:46:53  carl

+ 5 - 2
compiler/ppu.pas

@@ -41,7 +41,7 @@ type
 {$endif Test_Double_checksum}
 
 const
-  CurrentPPUVersion=29;
+  CurrentPPUVersion=30;
 
 { buffer sizes }
   maxentrysize = 1024;
@@ -985,7 +985,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.28  2002-11-15 01:58:53  peter
+  Revision 1.29  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.28  2002/11/15 01:58:53  peter
     * merged changes from 1.0.7 up to 04-11
       - -V option for generating bug report tracing
       - more tracing for option parsing

+ 11 - 8
compiler/pstatmnt.pas

@@ -762,13 +762,13 @@ implementation
                   include(asmstat.flags,nf_object_preserved);
                   hs:=upper(pattern);
                   found:=false;
-                  for r:=low(tregister) to high(tregister) do
-                   if hs=upper(std_reg2str[r]) then
+                  for r.enum:=firstreg to lastreg do
+                   if hs=upper(std_reg2str[r.enum]) then
                     begin
-                      if r = SELF_POINTER_REG then
+                      if r.enum = SELF_POINTER_REG then
                         exclude(asmstat.flags,nf_object_preserved);
-                      include(rg.usedinproc,r);
-                      include(rg.usedbyproc,r);
+                      include(rg.usedinproc,r.enum);
+                      include(rg.usedbyproc,r.enum);
                       found:=true;
                       break;
                     end;
@@ -1017,7 +1017,7 @@ implementation
         aktprocdef.localst.datasize:=0;
         procinfo.firsttemp_offset:=0;
         { replace framepointer with stackpointer }
-        procinfo.framepointer:=STACK_POINTER_REG;
+        procinfo.framepointer.enum:=STACK_POINTER_REG;
         { set the right value for parameters }
         dec(aktprocdef.parast.address_fixup,pointer_size);
         dec(procinfo.para_offset,pointer_size);
@@ -1041,7 +1041,7 @@ implementation
                        ref_parafixup :
                          begin
                            ref^.offsetfixup:=parafixup;
-                           ref^.base:=STACK_POINTER_REG;
+                           ref^.base.enum:=STACK_POINTER_REG;
                          end;
                      end;
                    end;
@@ -1125,7 +1125,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.84  2003-01-01 21:05:24  peter
+  Revision 1.85  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.84  2003/01/01 21:05:24  peter
     * fixed assembler methods stackpointer optimization that was
       broken after the previous change
 

+ 5 - 2
compiler/psub.pas

@@ -542,7 +542,7 @@ implementation
           { clear flags }
             flags:=0;
           { standard frame pointer }
-            framepointer:=frame_pointer_reg;
+            framepointer.enum:=frame_pointer_reg;
           { is this a nested function of a method ? }
             if assigned(oldprocinfo) then
               _class:=oldprocinfo._class;
@@ -844,7 +844,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.87  2003-01-03 20:35:08  peter
+  Revision 1.88  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.87  2003/01/03 20:35:08  peter
     * check also interfacedef when checking for matching forwarddef
 
   Revision 1.86  2003/01/02 11:14:02  michael

+ 5 - 2
compiler/rautils.pas

@@ -825,7 +825,7 @@ Begin
                 that %esi is valid there }
               else
                 begin
-                  opr.ref.base:=SELF_POINTER_REG;
+                  opr.ref.base.enum:=SELF_POINTER_REG;
                   opr.ref.offset:=tvarsym(sym).address;
                 end;
               hasvar:=true;
@@ -1591,7 +1591,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.51  2002-12-14 15:02:03  carl
+  Revision 1.52  2003-01-08 18:43:56  daniel
+   * Tregister changed into a record
+
+  Revision 1.51  2002/12/14 15:02:03  carl
     * maxoperands -> max_operands (for portability in rautils.pas)
     * fix some range-check errors with loadconst
     + add ncgadd unit to m68k

+ 47 - 26
compiler/regvars.pas

@@ -139,6 +139,7 @@ implementation
       regvarinfo: pregvarinfo;
       i: longint;
       parasym : boolean;
+      r : Tregister;
     begin
       { max. optimizations     }
       { only if no asm is used }
@@ -172,7 +173,8 @@ implementation
                       { expressions                          }
                       { search the register which is the most }
                       { unused                                }
-                      rg.makeregvar(varregs[i]);
+                      r.enum:=varregs[i];
+                      rg.makeregvar(r);
 
                       { possibly no 32 bit register are needed }
                       { call by reference/const ? }
@@ -180,23 +182,27 @@ implementation
                          ((regvarinfo^.regvars[i].varspez=vs_const) and
                            paramanager.push_addr_param(regvarinfo^.regvars[i].vartype.def,aktprocdef.proccalloption)) then
                         begin
-                           regvarinfo^.regvars[i].reg:=varregs[i];
+                           r.enum:=varregs[i];
+                           regvarinfo^.regvars[i].reg:=r;
                         end
                       else
                        if (regvarinfo^.regvars[i].vartype.def.deftype in [orddef,enumdef]) and
                           (regvarinfo^.regvars[i].vartype.def.size=1) then
                         begin
-                          regvarinfo^.regvars[i].reg:=rg.makeregsize(varregs[i],OS_8);
+                          r.enum:=varregs[i];
+                          regvarinfo^.regvars[i].reg:=rg.makeregsize(r,OS_8);
                         end
                       else
                        if (regvarinfo^.regvars[i].vartype.def.deftype in [orddef,enumdef]) and
                           (regvarinfo^.regvars[i].vartype.def.size=2) then
                          begin
-                           regvarinfo^.regvars[i].reg:=rg.makeregsize(varregs[i],OS_16);
+                           r.enum:=varregs[i];
+                           regvarinfo^.regvars[i].reg:=rg.makeregsize(r,OS_16);
                          end
                       else
                         begin
-                          regvarinfo^.regvars[i].reg:=varregs[i];
+                          r.enum:=varregs[i];
+                          regvarinfo^.regvars[i].reg:=r;
                         end;
                       { procedure uses this register }
                       include(rg.usedinproc,varregs[i]);
@@ -251,7 +257,8 @@ implementation
                      begin
 {$ifdef i386}
                        { reserve place on the FPU stack }
-                       regvarinfo^.fpuregvars[i].reg:=trgcpu(rg).correct_fpuregister(R_ST0,i);
+                       r.enum:=R_ST0;
+                       regvarinfo^.fpuregvars[i].reg:=trgcpu(rg).correct_fpuregister(r,i);
 {$else i386}
                        rg.makeregvar(regvarinfo^.fpuregvars[i].reg);
 {$endif i386}
@@ -269,14 +276,16 @@ implementation
       regvarinfo: pregvarinfo;
       vsym: tvarsym;
     begin
+      if reg.enum>lastreg then
+        internalerror(200301081);
       regvarinfo := pregvarinfo(aktprocdef.regvarinfo);
       if not assigned(regvarinfo) then
         exit;
       for i := 1 to maxvarregs do
         if assigned(regvarinfo^.regvars[i]) and
-           (rg.makeregsize(regvarinfo^.regvars[i].reg,OS_INT) = reg) then
+           (rg.makeregsize(regvarinfo^.regvars[i].reg,OS_INT).enum = reg.enum) then
           begin
-            if rg.regvar_loaded[rg.makeregsize(reg,OS_INT)] then
+            if rg.regvar_loaded[rg.makeregsize(reg,OS_INT).enum] then
               begin
                 vsym := tvarsym(regvarinfo^.regvars[i]);
                 { we only have to store the regvar back to memory if it's }
@@ -292,7 +301,7 @@ implementation
                     cg.a_load_reg_ref(asml,def_cgsize(vsym.vartype.def),vsym.reg,hr);
                   end;
                 asml.concat(tai_regalloc.dealloc(rg.makeregsize(reg,OS_INT)));
-                rg.regvar_loaded[rg.makeregsize(reg,OS_INT)] := false;
+                rg.regvar_loaded[rg.makeregsize(reg,OS_INT).enum] := false;
               end;
             break;
           end;
@@ -305,7 +314,9 @@ implementation
       reg : tregister;
     begin
       reg:=rg.makeregsize(vsym.reg,OS_INT);
-      if not rg.regvar_loaded[reg] then
+      if reg.enum>lastreg then
+        internalerror(200301081);
+      if not rg.regvar_loaded[reg.enum] then
         begin
           asml.concat(tai_regalloc.alloc(reg));
           reference_reset(hr);
@@ -321,7 +332,7 @@ implementation
           else
             opsize := def_cgsize(vsym.vartype.def);
           cg.a_load_ref_reg(asml,opsize,hr,reg);
-          rg.regvar_loaded[reg] := true;
+          rg.regvar_loaded[reg.enum] := true;
         end;
     end;
 
@@ -335,9 +346,11 @@ implementation
       if not assigned(regvarinfo) then
         exit;
       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) = reg_spare) then
+           (rg.makeregsize(regvarinfo^.regvars[i].reg,OS_INT).enum = reg_spare.enum) then
           load_regvar(asml,tvarsym(regvarinfo^.regvars[i]))
     end;
 
@@ -360,6 +373,7 @@ implementation
     var
       i: longint;
       regvarinfo: pregvarinfo;
+      r:Tregister;
     begin
       if (cs_regalloc in aktglobalswitches) and
          ((procinfo.flags and (pi_uses_asm or pi_uses_exceptions))=0) then
@@ -375,9 +389,9 @@ implementation
                 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[regvarinfo^.regvars[i].reg])));
+                  std_reg2str[regvarinfo^.regvars[i].reg.enum])));
                 if (status.verbosity and v_debug)=v_debug then
-                 Message3(cg_d_register_weight,std_reg2str[regvarinfo^.regvars[i].reg],
+                 Message3(cg_d_register_weight,std_reg2str[regvarinfo^.regvars[i].reg.enum],
                   tostr(regvarinfo^.regvars[i].refs),regvarinfo^.regvars[i].name);
                end;
             end;
@@ -386,8 +400,9 @@ implementation
               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_ST0,i-1);
+                  regvarinfo^.fpuregvars[i].reg:=trgcpu(rg).correct_fpuregister(r,i-1);
                   asml.concat(Taicpu.op_none(A_FLDZ,S_NO));
 {$endif i386}
                 end;
@@ -405,9 +420,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])));
+                        std_reg2str[regvarinfo^.fpuregvars[i].reg.enum])));
                     if (status.verbosity and v_debug)=v_debug then
-                      Message3(cg_d_register_weight,std_reg2str[regvarinfo^.fpuregvars[i].reg],
+                      Message3(cg_d_register_weight,std_reg2str[regvarinfo^.fpuregvars[i].reg.enum],
                         tostr(regvarinfo^.fpuregvars[i].refs),regvarinfo^.fpuregvars[i].name);
                  end;
             end;
@@ -422,12 +437,12 @@ implementation
     var
       counter: tregister;
     begin
-      for counter := low(rg.regvar_loaded) to high(rg.regvar_loaded) do
+      for counter.enum := low(rg.regvar_loaded) to high(rg.regvar_loaded) do
         begin
-           rg.regvar_loaded[counter] := regvarsloaded1[counter] and
-             regvarsloaded2[counter];
-           if regvarsloaded1[counter] xor regvarsloaded2[counter] then
-             if regvarsloaded1[counter] then
+           rg.regvar_loaded[counter.enum] := regvarsloaded1[counter.enum] and
+             regvarsloaded2[counter.enum];
+           if regvarsloaded1[counter.enum] xor regvarsloaded2[counter.enum] then
+             if regvarsloaded1[counter.enum] then
                load_regvar_reg(list2,counter)
              else
                load_regvar_reg(list1,counter);
@@ -438,7 +453,7 @@ implementation
     procedure cleanup_regvars(asml: TAAsmoutput);
     var
       i: longint;
-      reg : tregister;
+      r,reg : tregister;
     begin
       { can happen when inlining assembler procedures (JM) }
       if not assigned(aktprocdef.regvarinfo) then
@@ -448,17 +463,20 @@ implementation
         with pregvarinfo(aktprocdef.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_ST0));
+                asml.concat(Taicpu.op_reg(A_FSTP,S_NO,r));
 {$endif i386}
             for i := 1 to maxvarregs do
              begin
                if assigned(regvars[i]) then
                 begin
                   reg:=rg.makeregsize(regvars[i].reg,OS_INT);
-                  if (rg.regvar_loaded[reg]) then
+                  if reg.enum>lastreg then
+                    internalerror(200201081);
+                  if (rg.regvar_loaded[reg.enum]) then
                    asml.concat(tai_regalloc.dealloc(reg));
                 end;
              end;
@@ -469,7 +487,10 @@ end.
 
 {
   $Log$
-  Revision 1.43  2002-11-25 17:43:24  peter
+  Revision 1.44  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.43  2002/11/25 17:43:24  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 101 - 80
compiler/rgobj.pas

@@ -155,12 +155,12 @@ unit rgobj;
 
              @param(r specific register to allocate)
           }
-          function getexplicitregisterint(list: taasmoutput; r : tregister) : tregister;virtual;
+          function getexplicitregisterint(list: taasmoutput; r : Toldregister) : tregister;virtual;
           {# Tries to allocate the passed fpu register, if possible
 
              @param(r specific register to allocate)
           }
-          function getexplicitregisterfpu(list : taasmoutput; r : tregister) : tregister;
+          function getexplicitregisterfpu(list : taasmoutput; r : Toldregister) : tregister;
 
           {# Deallocate any kind of register }
           procedure ungetregister(list: taasmoutput; r : tregister); virtual;
@@ -221,7 +221,7 @@ unit rgobj;
        protected
           { the following two contain the common (generic) code for all }
           { get- and ungetregisterxxx functions/procedures              }
-          function getregistergen(list: taasmoutput; const lowreg, highreg: tregister;
+          function getregistergen(list: taasmoutput; const lowreg, highreg: Toldregister;
               var unusedregs: tregisterset; var countunusedregs: byte): tregister;
           procedure ungetregistergen(list: taasmoutput; const r: tregister;
               const usableregs: tregisterset; var unusedregs: tregisterset; var countunusedregs: byte);
@@ -325,10 +325,11 @@ unit rgobj;
      end;
 
 
-    function trgobj.getregistergen(list: taasmoutput; const lowreg, highreg: tregister;
+    function trgobj.getregistergen(list: taasmoutput; const lowreg, highreg: Toldregister;
         var unusedregs: tregisterset; var countunusedregs: byte): tregister;
       var
-        i: tregister;
+        i: Toldregister;
+        r: Tregister;
       begin
          for i:=lowreg to highreg do
            begin
@@ -338,8 +339,9 @@ unit rgobj;
                    include(usedinproc,i);
                    include(usedbyproc,i);
                    dec(countunusedregs);
-                   list.concat(tai_regalloc.alloc(i));
-                   result := i;
+                   r.enum:=i;
+                   list.concat(tai_regalloc.alloc(r));
+                   result := r;
                    exit;
                 end;
            end;
@@ -350,14 +352,16 @@ unit rgobj;
     procedure trgobj.ungetregistergen(list: taasmoutput; const r: tregister;
         const usableregs: tregisterset; var unusedregs: tregisterset; var countunusedregs: byte);
       begin
+         if r.enum>lastreg then
+            internalerror(2003010801);
          { takes much time }
-         if not(r in usableregs) then
+         if not(r.enum in usableregs) then
            exit;
 {$ifdef TEMPREGDEBUG}
-         if (r in unusedregs) then
+         if (r.enum in unusedregs) then
 {$ifdef EXTTEMPREGDEBUG}
            begin
-             Comment(V_Debug,'register freed twice '+std_reg2str[r]);
+             Comment(V_Debug,'register freed twice '+std_reg2str[r.enum]);
              testregisters32;
              exit;
            end
@@ -367,7 +371,7 @@ unit rgobj;
          else
 {$endif TEMPREGDEBUG}
           inc(countunusedregs);
-        include(unusedregs,r);
+        include(unusedregs,r.enum);
         list.concat(tai_regalloc.dealloc(r));
       end;
 
@@ -407,7 +411,9 @@ unit rgobj;
 
 
     { tries to allocate the passed register, if possible }
-    function trgobj.getexplicitregisterint(list : taasmoutput; r : tregister) : tregister;
+    function trgobj.getexplicitregisterint(list : taasmoutput; r : Toldregister) : tregister;
+
+    var r2:Tregister;
 
       begin
          if r in unusedregsint then
@@ -421,8 +427,9 @@ unit rgobj;
               exclude(unusedregsint,r);
               include(usedinproc,r);
               include(usedbyproc,r);
-              list.concat(tai_regalloc.alloc(r));
-              getexplicitregisterint:=r;
+              r2.enum:=r;
+              list.concat(tai_regalloc.alloc(r2));
+              getexplicitregisterint:=r2;
 {$ifdef TEMPREGDEBUG}
               testregisters32;
 {$endif TEMPREGDEBUG}
@@ -433,7 +440,9 @@ unit rgobj;
 
 
     { tries to allocate the passed register, if possible }
-    function trgobj.getexplicitregisterfpu(list : taasmoutput; r : tregister) : tregister;
+    function trgobj.getexplicitregisterfpu(list : taasmoutput; r : Toldregister) : tregister;
+
+    var r2:Tregister;
 
       begin
          if r in unusedregsfpu then
@@ -447,8 +456,9 @@ unit rgobj;
               exclude(unusedregsint,r);
               include(usedinproc,r);
               include(usedbyproc,r);
-              list.concat(tai_regalloc.alloc(r));
-              getexplicitregisterfpu:=r;
+              r2.enum:=r;
+              list.concat(tai_regalloc.alloc(r2));
+              getexplicitregisterfpu:=r2;
 {$ifdef TEMPREGDEBUG}
               testregisters32;
 {$endif TEMPREGDEBUG}
@@ -458,6 +468,7 @@ unit rgobj;
       end;
 
     function trgobj.getregisterfpu(list: taasmoutput) : tregister;
+
       begin
         if countunusedregsfpu=0 then
           internalerror(10);
@@ -511,13 +522,15 @@ unit rgobj;
     procedure trgobj.ungetregister(list: taasmoutput; r : tregister);
 
       begin
-         if r=R_NO then
+         if r.enum=R_NO then
            exit;
-         if r in intregs then
+         if r.enum>lastreg then
+          internalerror(200301081);
+         if r.enum in intregs then
            ungetregisterint(list,r)
-         else if r in fpuregs then
+         else if r.enum in fpuregs then
            ungetregisterfpu(list,r)
-         else if r in mmregs then
+         else if r.enum in mmregs then
            ungetregistermm(list,r)
          else internalerror(2002070602);
       end;
@@ -545,23 +558,23 @@ unit rgobj;
 
     procedure trgobj.saveregvars(list: taasmoutput; const s: tregisterset);
       var
-        r: tregister;
+        r: Tregister;
       begin
         if not(cs_regalloc in aktglobalswitches) then
           exit;
-        for r := firstsaveintreg to lastsaveintreg do
-          if is_reg_var[r] and
-             (r in s) then
+        for r.enum := firstsaveintreg to lastsaveintreg do
+          if is_reg_var[r.enum] and
+             (r.enum in s) then
             store_regvar(list,r);
         if firstsavefpureg <> R_NO then
-          for r := firstsavefpureg to lastsavefpureg do
-            if is_reg_var[r] and
-               (r in s) then
+          for r.enum := firstsavefpureg to lastsavefpureg do
+            if is_reg_var[r.enum] and
+               (r.enum in s) then
               store_regvar(list,r);
         if firstsavemmreg <> R_NO then
-          for r := firstsavemmreg to lastsavemmreg do
-            if is_reg_var[r] and
-               (r in s) then
+          for r.enum := firstsavemmreg to lastsavemmreg do
+            if is_reg_var[r.enum] and
+               (r.enum in s) then
               store_regvar(list,r);
       end;
 
@@ -575,22 +588,22 @@ unit rgobj;
 
       begin
         usedinproc:=usedinproc + s;
-        for r:=firstsaveintreg to lastsaveintreg do
+        for r.enum:=firstsaveintreg to lastsaveintreg do
           begin
-            saved[r].ofs:=reg_not_saved;
+            saved[r.enum].ofs:=reg_not_saved;
             { if the register is used by the calling subroutine and if }
             { it's not a regvar (those are handled separately)         }
-            if not is_reg_var[r] and
-               (r in s) and
+            if not is_reg_var[r.enum] and
+               (r.enum in s) and
                { and is present in use }
-               not(r in unusedregsint) then
+               not(r.enum in unusedregsint) then
               begin
                 { then save it }
                 tg.GetTemp(list,sizeof(aword),tt_persistant,hr);
-                saved[r].ofs:=hr.offset;
+                saved[r.enum].ofs:=hr.offset;
                 cg.a_load_reg_ref(list,OS_INT,r,hr);
                 cg.a_reg_dealloc(list,r);
-                include(unusedregsint,r);
+                include(unusedregsint,r.enum);
                 inc(countunusedregsint);
               end;
           end;
@@ -598,44 +611,44 @@ unit rgobj;
         { don't try to save the fpu registers if not desired (e.g. for }
         { the 80x86)                                                   }
         if firstsavefpureg <> R_NO then
-          for r:=firstsavefpureg to lastsavefpureg do
+          for r.enum:=firstsavefpureg to lastsavefpureg do
             begin
-              saved[r].ofs:=reg_not_saved;
+              saved[r.enum].ofs:=reg_not_saved;
               { if the register is used by the calling subroutine and if }
               { it's not a regvar (those are handled separately)         }
-              if not is_reg_var[r] and
-                 (r in s) and
+              if not is_reg_var[r.enum] and
+                 (r.enum in s) and
                  { and is present in use }
-                 not(r in unusedregsfpu) then
+                 not(r.enum in unusedregsfpu) then
                 begin
                   { then save it }
                   tg.GetTemp(list,extended_size,tt_persistant,hr);
-                  saved[r].ofs:=hr.offset;
+                  saved[r.enum].ofs:=hr.offset;
                   cg.a_loadfpu_reg_ref(list,OS_FLOAT,r,hr);
                   cg.a_reg_dealloc(list,r);
-                  include(unusedregsfpu,r);
+                  include(unusedregsfpu,r.enum);
                   inc(countunusedregsfpu);
                 end;
             end;
 
         { don't save the vector registers if there's no support for them }
         if firstsavemmreg <> R_NO then
-          for r:=firstsavemmreg to lastsavemmreg do
+          for r.enum:=firstsavemmreg to lastsavemmreg do
             begin
-              saved[r].ofs:=reg_not_saved;
+              saved[r.enum].ofs:=reg_not_saved;
               { if the register is in use and if it's not a regvar (those }
               { are handled separately), save it                          }
-              if not is_reg_var[r] and
-                 (r in s) and
+              if not is_reg_var[r.enum] and
+                 (r.enum in s) and
                  { and is present in use }
-                 not(r in unusedregsmm) then
+                 not(r.enum in unusedregsmm) then
                 begin
                   { then save it }
                   tg.GetTemp(list,mmreg_size,tt_persistant,hr);
-                  saved[r].ofs:=hr.offset;
+                  saved[r.enum].ofs:=hr.offset;
                   cg.a_loadmm_reg_ref(list,r,hr);
                   cg.a_reg_dealloc(list,r);
-                  include(unusedregsmm,r);
+                  include(unusedregsmm,r.enum);
                   inc(countunusedregsmm);
                end;
             end;
@@ -649,19 +662,20 @@ unit rgobj;
         const saved : tpushedsaved);
 
       var
-         r : tregister;
+         r,r2 : tregister;
          hr : treference;
 
       begin
         if firstsavemmreg <> R_NO then
-          for r:=lastsavemmreg downto firstsavemmreg do
+          for r.enum:=lastsavemmreg downto firstsavemmreg do
             begin
-              if saved[r].ofs <> reg_not_saved then
+              if saved[r.enum].ofs <> reg_not_saved then
                 begin
-                  reference_reset_base(hr,FRAME_POINTER_REG,saved[r].ofs);
+                  r2.enum:=FRAME_POINTER_REG;
+                  reference_reset_base(hr,r2,saved[r.enum].ofs);
                   cg.a_reg_alloc(list,r);
                   cg.a_loadmm_ref_reg(list,hr,r);
-                  if not (r in unusedregsmm) then
+                  if not (r.enum in unusedregsmm) then
                     { internalerror(10)
                       in n386cal we always save/restore the reg *state*
                       using save/restoreunusedstate -> the current state
@@ -669,21 +683,22 @@ unit rgobj;
                   else
                     begin
                       dec(countunusedregsmm);
-                      exclude(unusedregsmm,r);
+                      exclude(unusedregsmm,r.enum);
                     end;
                   tg.UnGetTemp(list,hr);
                 end;
             end;
 
         if firstsavefpureg <> R_NO then
-          for r:=lastsavefpureg downto firstsavefpureg do
+          for r.enum:=lastsavefpureg downto firstsavefpureg do
             begin
-              if saved[r].ofs <> reg_not_saved then
+              if saved[r.enum].ofs <> reg_not_saved then
                 begin
-                  reference_reset_base(hr,FRAME_POINTER_REG,saved[r].ofs);
+                  r2.enum:=FRAME_POINTER_REG;
+                  reference_reset_base(hr,r2,saved[r.enum].ofs);
                   cg.a_reg_alloc(list,r);
                   cg.a_loadfpu_ref_reg(list,OS_FLOAT,hr,r);
-                  if not (r in unusedregsfpu) then
+                  if not (r.enum in unusedregsfpu) then
                     { internalerror(10)
                       in n386cal we always save/restore the reg *state*
                       using save/restoreunusedstate -> the current state
@@ -691,20 +706,21 @@ unit rgobj;
                   else
                     begin
                       dec(countunusedregsfpu);
-                      exclude(unusedregsfpu,r);
+                      exclude(unusedregsfpu,r.enum);
                     end;
                   tg.UnGetTemp(list,hr);
                 end;
             end;
 
-        for r:=lastsaveintreg downto firstsaveintreg do
+        for r.enum:=lastsaveintreg downto firstsaveintreg do
           begin
-            if saved[r].ofs <> reg_not_saved then
+            if saved[r.enum].ofs <> reg_not_saved then
               begin
-                reference_reset_base(hr,FRAME_POINTER_REG,saved[r].ofs);
+                r2.enum:=FRAME_POINTER_REG;
+                reference_reset_base(hr,r2,saved[r.enum].ofs);
                 cg.a_reg_alloc(list,r);
                 cg.a_load_ref_reg(list,OS_INT,hr,r);
-                if not (r in unusedregsint) then
+                if not (r.enum in unusedregsint) then
                   { internalerror(10)
                     in n386cal we always save/restore the reg *state*
                     using save/restoreunusedstate -> the current state
@@ -712,7 +728,7 @@ unit rgobj;
                 else
                   begin
                     dec(countunusedregsint);
-                    exclude(unusedregsint,r);
+                    exclude(unusedregsint,r.enum);
                   end;
                 tg.UnGetTemp(list,hr);
               end;
@@ -726,7 +742,7 @@ unit rgobj;
     procedure trgobj.incrementregisterpushed(const s: tregisterset);
 
       var
-         regi : tregister;
+         regi : Toldregister;
 
       begin
          for regi:=firstsaveintreg to lastsaveintreg do
@@ -774,28 +790,30 @@ unit rgobj;
 
     procedure trgobj.makeregvar(reg: tregister);
       begin
-        if reg in intregs then
+        if reg.enum>lastreg then
+          internalerror(200301081);
+        if reg.enum in intregs then
           begin
             dec(countusableregsint);
             dec(countunusedregsint);
-            exclude(usableregsint,reg);
-            exclude(unusedregsint,reg);
+            exclude(usableregsint,reg.enum);
+            exclude(unusedregsint,reg.enum);
           end
-        else if reg in fpuregs then
+        else if reg.enum in fpuregs then
           begin
              dec(countusableregsfpu);
              dec(countunusedregsfpu);
-             exclude(usableregsfpu,reg);
-             exclude(unusedregsfpu,reg);
+             exclude(usableregsfpu,reg.enum);
+             exclude(unusedregsfpu,reg.enum);
           end
-        else if reg in mmregs then
+        else if reg.enum in mmregs then
           begin
              dec(countusableregsmm);
              dec(countunusedregsmm);
-             exclude(usableregsmm,reg);
-             exclude(unusedregsmm,reg);
+             exclude(usableregsmm,reg.enum);
+             exclude(unusedregsmm,reg.enum);
           end;
-        is_reg_var[reg]:=true;
+        is_reg_var[reg.enum]:=true;
       end;
 
 
@@ -998,7 +1016,10 @@ end.
 
 {
   $Log$
-  Revision 1.20  2002-10-05 12:43:28  carl
+  Revision 1.21  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.20  2002/10/05 12:43:28  carl
     * fixes for Delphi 6 compilation
      (warning : Some features do not work under Delphi)
 

+ 8 - 5
compiler/sparc/aasmcpu.pas

@@ -102,12 +102,12 @@ const
 constructor tai_align.create(b:byte);
   begin
     inherited create(b);
-    reg:= R_NONE;
+    reg.enum:= R_NONE;
   end;
 constructor tai_align.create_op(b:byte; _op:byte);
   begin
     inherited create_op(b,_op);
-    reg:= R_NONE;
+    reg.enum:= R_NONE;
   end;
 {*****************************************************************************
                              Taicpu Constructors
@@ -456,7 +456,7 @@ begin
         if (ref^.base=R_NONE) and (ref^.index=R_NONE) then
           ot:=ot or OT_MEM_OFFS;}
       { fix scalefactor }
-        if (ref^.index=R_NONE) then
+        if (ref^.index.enum=R_NONE) then
          ref^.scalefactor:=0
         else
          if (ref^.scalefactor=0) then
@@ -857,7 +857,7 @@ begin
   o:=input.ref^.offset+input.ref^.offsetfixup;
   sym:=input.ref^.symbol;
 { it's direct address }
-  if (b=R_NONE) and (i=R_NONE) then
+  if (b.enum=R_NONE) and (i.enum=R_NONE) then
    begin
  { it's a pure offset }
  output.sib_present:=false;
@@ -1081,7 +1081,10 @@ procedure InitAsm;
 end.
 {
     $Log$
-    Revision 1.15  2003-01-05 21:32:35  mazen
+    Revision 1.16  2003-01-08 18:43:58  daniel
+     * Tregister changed into a record
+
+    Revision 1.15  2003/01/05 21:32:35  mazen
     * fixing several bugs compiling the RTL
 
     Revision 1.14  2002/12/14 15:02:03  carl

+ 88 - 53
compiler/sparc/cgcpu.pas

@@ -113,16 +113,19 @@ USES
     { we implement the following routines because otherwise we can't }
     { instantiate the class since it's abstract                      }
 procedure TCgSparc.a_param_reg(list:TAasmOutput;size:tcgsize;r:tregister;const LocPara:TParaLocation);
+
+var r2:Tregister;
+
   begin
+    r2.enum:=R_G0;
     if(Size<>OS_32)and(Size<>OS_S32)
     then
       InternalError(2002032212);
     with list,LocPara do
       case Loc of
         LOC_REGISTER:
-          if r<>Register
-          then
-            Concat(taicpu.op_Reg_Reg_Reg(A_OR,r,R_G0,Register));
+          if r.enum<>Register.enum then
+            Concat(taicpu.op_Reg_Reg_Reg(A_OR,r,r2,Register));
         else
           InternalError(2002101002);
       end;
@@ -190,17 +193,17 @@ procedure TCgSparc.a_paramaddr_ref(list:TAasmOutput;CONST r:TReference;CONST Loc
   VAR
     tmpreg:TRegister;
   BEGIN
-    IF r.segment<>R_NO
+    IF r.segment.enum<>R_NO
     THEN
       CGMessage(cg_e_cant_use_far_pointer_there);
-    IF(r.base=R_NO)AND(r.index=R_NO)
+    IF(r.base.enum=R_NO)AND(r.index.enum=R_NO)
     THEN
       list.concat(Taicpu.Op_sym_ofs(A_LD,S_SW,r.symbol,r.offset))
-    ELSE IF(r.base=R_NO)AND(r.index<>R_NO)AND
+    ELSE IF(r.base.enum=R_NO)AND(r.index.enum<>R_NO)AND
            (r.offset=0)AND(r.scalefactor=0)AND(r.symbol=nil)
     THEN
       list.concat(Taicpu.Op_reg(A_LD,r.index))
-    ELSE IF(r.base<>R_NO)AND(r.index=R_NO)AND
+    ELSE IF(r.base.enum<>R_NO)AND(r.index.enum=R_NO)AND
            (r.offset=0)AND(r.symbol=nil)
     THEN
       list.concat(Taicpu.Op_reg(A_LD,r.base))
@@ -240,24 +243,33 @@ procedure TCgSparc.a_jmp_always(List:TAasmOutput;l:TAsmLabel);
   end;
 {********************** load instructions ********************}
 procedure TCgSparc.a_load_const_reg(list:TAasmOutput;size:TCGSize;a:aword;reg:TRegister);
+
+var r:Tregister;
+
   BEGIN
+    r.enum:=R_G0;
     WITH List DO
       IF a<>0
       THEN{R_G0 is usually set to zero, so we use it}
-        Concat(taicpu.op_reg_const_reg(A_OR,R_G0,a,reg))
+        Concat(taicpu.op_reg_const_reg(A_OR,r,a,reg))
       ELSE{The is no A_MOV in sparc, that's why we use A_OR with help of R_G0}
-        Concat(taicpu.op_reg_reg_reg(A_OR,R_G0,R_G0,reg));
+        Concat(taicpu.op_reg_reg_reg(A_OR,r,r,reg));
   END;
 procedure TCgSparc.a_load_const_ref(list:TAasmOutput;size:tcgsize;a:aword;CONST ref:TReference);
+
+var r:Tregister;
+
   BEGIN
+    r.enum:=R_G0;
     WITH List DO
       IF a=0
       THEN
-        Concat(taicpu.op_reg_ref(A_ST,R_G0,Ref))
+        Concat(taicpu.op_reg_ref(A_ST,r,Ref))
       ELSE
         BEGIN
-          a_load_const_reg(list,size,a,R_G1);
-          a_load_reg_ref(list,size,R_G1,Ref);
+          r.enum:=R_G1;
+          a_load_const_reg(list,size,a,r);
+          a_load_reg_ref(list,size,r,Ref);
         END;
   END;
 procedure TCgSparc.a_load_reg_ref(list:TAasmOutput;size:TCGSize;reg:tregister;const Ref:TReference);
@@ -342,8 +354,10 @@ procedure TCgSparc.a_load_reg_reg(list:TAasmOutput;fromsize,tosize:tcgsize;reg1,
   var
     op:tasmop;
     s:topsize;
+    r:Tregister;
   begin
-    if(reg1<>reg2)or
+    r.enum:=R_G0;
+    if(reg1.enum<>reg2.enum)or
       (tcgsize2size[tosize]<tcgsize2size[fromsize])or
       ((tcgsize2size[tosize] = tcgsize2size[fromsize])and
         (tosize <> fromsize)and
@@ -360,7 +374,7 @@ procedure TCgSparc.a_load_reg_reg(list:TAasmOutput;fromsize,tosize:tcgsize;reg1,
           OS_S16:
             InternalError(2002100803);{concat(taicpu.op_reg_reg(A_EXTSH,reg2,reg1));}
           OS_32,OS_S32:
-            concat(taicpu.op_reg_reg_reg(A_OR,R_G0,reg1,reg2));
+            concat(taicpu.op_reg_reg_reg(A_OR,r,reg1,reg2));
           else internalerror(2002090901);
         end;
   end;
@@ -884,20 +898,24 @@ procedure TCgSparc.a_jmp_cond(list:TAasmOutput;cond:TOpCmp;l:tasmlabel);
 procedure TCgSparc.g_flags2reg(list:TAasmOutput;Size:TCgSize;CONST f:tresflags;reg:TRegister);
   VAR
     ai:taicpu;
-    hreg:tregister;
+    r,hreg:tregister;
+    
   BEGIN
+    r.enum:=R_PSR;
     hreg := rg.makeregsize(reg,OS_8);
-    ai:=Taicpu.Op_reg_reg(A_RDPSR,R_PSR,hreg);
+    ai:=Taicpu.Op_reg_reg(A_RDPSR,r,hreg);
     ai.SetCondition(flags_to_cond(f));
     list.concat(ai);
-    IF hreg<>reg
+    IF hreg.enum<>reg.enum
     THEN
       a_load_reg_reg(list,OS_32,OS_32,hreg,reg);
   END;
 procedure TCgSparc.g_overflowCheck(List:TAasmOutput;const p:TNode);
   var
     hl:TAsmLabel;
+    r:Tregister;
   begin
+    r.enum:=R_NONE;
     if not(cs_check_overflow in aktlocalswitches)
     then
       exit;
@@ -908,7 +926,7 @@ procedure TCgSparc.g_overflowCheck(List:TAasmOutput;const p:TNode);
                                          bool8bit,bool16bit,bool32bit])))
     then
       begin
-        list.concat(taicpu.op_reg(A_NONE,R_NONE));
+        list.concat(taicpu.op_reg(A_NONE,r));
         a_jmp_always(list,hl)
       end
     else
@@ -921,6 +939,7 @@ procedure TCgSparc.g_overflowCheck(List:TAasmOutput;const p:TNode);
 procedure TCgSparc.g_stackframe_entry(list:TAasmOutput;LocalSize:LongInt);
   var
     href:TReference;
+    r:Tregister;
     i:integer;
     again:tasmlabel;
   begin
@@ -932,8 +951,9 @@ aligned}
 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:=stack_pointer_reg;
     with list do
-      concat(Taicpu.Op_reg_const_reg(A_SAVE,Stack_Pointer_Reg,-LocalSize,Stack_Pointer_Reg));
+      concat(Taicpu.Op_reg_const_reg(A_SAVE,r,-LocalSize,r));
   end;
 procedure TCgSparc.g_restore_all_registers(list:TaasmOutput;selfused,accused,acchiused:boolean);
   begin
@@ -945,6 +965,9 @@ procedure TCgSparc.g_restore_frame_pointer(list:TAasmOutput);
 delay slot of the return instrucion done in g_return_from_proc}
   end;
 procedure TCgSparc.g_return_from_proc(list:TAasmOutput;parasize:aword);
+
+var r,r2:Tregister;
+
   begin
 {According to the SPARC ABI, the stack is cleared using the RESTORE instruction
 which is genereted in the g_restore_frame_pointer. Notice that SPARC has no
@@ -959,10 +982,12 @@ If no inversion we can use just
     with list do
       begin
 {Return address is computed by adding 8 to the CALL address saved onto %i6}
-        concat(Taicpu.Op_caddr_reg(A_JMPL,R_I7,8,R_G0));
+        r.enum:=R_G0;
+        r2.enum:=R_I7;
+        concat(Taicpu.Op_caddr_reg(A_JMPL,r,8,r));
 {We use trivial restore in the delay slot of the JMPL instruction, as we
 already set result onto %i0}
-        concat(Taicpu.Op_reg_const_reg(A_RESTORE,R_G0,0,R_G0));
+        concat(Taicpu.Op_reg_const_reg(A_RESTORE,r,0,r));
       end
   end;
 procedure TCgSparc.g_save_all_registers(list : taasmoutput);
@@ -1049,7 +1074,7 @@ procedure TCgSparc.a_loadaddr_ref_reg(list:TAasmOutput;CONST ref:TReference;r:tr
               end;
           OP_ADD, OP_SUB:
             begin
-              // can't use a_op_const_ref because this may use dec/inc
+              {can't use a_op_const_ref because this may use dec/inc}
               get_64bit_ops(op,op1,op2);
               list.concat(taicpu.op_const_reg(op1,Lo(Value),regdst.reglo));
               list.concat(taicpu.op_const_reg(op2,Hi(Value),regdst.reghi));
@@ -1077,7 +1102,7 @@ procedure TCg64fSPARC.a_op64_const_ref(list:TAasmOutput;op:TOpCG;value:qWord;con
       OP_ADD, OP_SUB:
             begin
               get_64bit_ops(op,op1,op2);
-              // can't use a_op_const_ref because this may use dec/inc
+              { can't use a_op_const_ref because this may use dec/inc}
 {              list.concat(taicpu.op_const_ref(op1,Lo(Value),ref));
               tempref:=ref;
               inc(tempref.offset,4);
@@ -1098,6 +1123,7 @@ procedure TCgSparc.g_concatcopy(list:taasmoutput;const source,dest:treference;le
     lab: tasmlabel;
     count, count2: aword;
     orgsrc, orgdst: boolean;
+    r:Tregister;
   begin
 {$ifdef extdebug}
     if len > high(longint)
@@ -1117,12 +1143,13 @@ procedure TCgSparc.g_concatcopy(list:taasmoutput;const source,dest:treference;le
                 end
               else
                 begin
-                  a_reg_alloc(list,R_F0);
-                  a_loadfpu_ref_reg(list,OS_F64,source,R_F0);
+                  r.enum:=R_F0;
+                  a_reg_alloc(list,r);
+                  a_loadfpu_ref_reg(list,OS_F64,source,r);
                   if delsource then
                     reference_release(list,source);
-                  a_loadfpu_reg_ref(list,OS_F64,R_F0,dest);
-                  a_reg_dealloc(list,R_F0);
+                  a_loadfpu_reg_ref(list,OS_F64,r,dest);
+                  a_reg_dealloc(list,r);
                 end;
               exit;
             end;
@@ -1137,7 +1164,7 @@ procedure TCgSparc.g_concatcopy(list:taasmoutput;const source,dest:treference;le
             orgsrc := false;
           end
         else if not issimpleref(source) or
-                ((source.index <> R_NO) and
+                ((source.index.enum <> R_NO) and
                  ((source.offset + longint(len)) > high(smallint))) then
           begin
             src.base := get_scratch_reg_address(list);
@@ -1153,7 +1180,7 @@ procedure TCgSparc.g_concatcopy(list:taasmoutput;const source,dest:treference;le
           reference_release(list,source);
         { load the address of dest into dst.base }
         if not issimpleref(dest) or
-           ((dest.index <> R_NO) and
+           ((dest.index.enum <> R_NO) and
             ((dest.offset + longint(len)) > high(smallint))) then
           begin
             dst.base := get_scratch_reg_address(list);
@@ -1182,15 +1209,16 @@ procedure TCgSparc.g_concatcopy(list:taasmoutput;const source,dest:treference;le
             a_load_const_reg(list,OS_32,count,countreg);
             { explicitely allocate R_O0 since it can be used safely here }
             { (for holding date that's being copied)                    }
-            a_reg_alloc(list,R_F0);
+            r.enum:=R_F0;
+            a_reg_alloc(list,r);
             objectlibrary.getlabel(lab);
             a_label(list, lab);
             list.concat(taicpu.op_reg_const_reg(A_SUB,countreg,1,countreg));
-            list.concat(taicpu.op_reg_ref(A_LDF,R_F0,src));
-            list.concat(taicpu.op_reg_ref(A_STD,R_F0,dst));
+            list.concat(taicpu.op_reg_ref(A_LDF,r,src));
+            list.concat(taicpu.op_reg_ref(A_STD,r,dst));
             //a_jmp(list,A_BC,C_NE,0,lab);
             free_scratch_reg(list,countreg);
-            a_reg_dealloc(list,R_F0);
+            a_reg_dealloc(list,r);
             len := len mod 8;
           end;
 
@@ -1198,43 +1226,47 @@ procedure TCgSparc.g_concatcopy(list:taasmoutput;const source,dest:treference;le
         if count > 0 then
           { unrolled loop }
           begin
-            a_reg_alloc(list,R_F0);
+            r.enum:=R_F0;
+            a_reg_alloc(list,r);
             for count2 := 1 to count do
               begin
-                a_loadfpu_ref_reg(list,OS_F64,src,R_F0);
-                a_loadfpu_reg_ref(list,OS_F64,R_F0,dst);
+                a_loadfpu_ref_reg(list,OS_F64,src,r);
+                a_loadfpu_reg_ref(list,OS_F64,r,dst);
                 inc(src.offset,8);
                 inc(dst.offset,8);
               end;
-            a_reg_dealloc(list,R_F0);
+            a_reg_dealloc(list,r);
             len := len mod 8;
           end;
 
         if (len and 4) <> 0 then
           begin
-            a_reg_alloc(list,R_O0);
-            a_load_ref_reg(list,OS_32,src,R_O0);
-            a_load_reg_ref(list,OS_32,R_O0,dst);
+            r.enum:=R_O0;
+            a_reg_alloc(list,r);
+            a_load_ref_reg(list,OS_32,src,r);
+            a_load_reg_ref(list,OS_32,r,dst);
             inc(src.offset,4);
             inc(dst.offset,4);
-            a_reg_dealloc(list,R_O0);
+            a_reg_dealloc(list,r);
           end;
        { copy the leftovers }
        if (len and 2) <> 0 then
          begin
-           a_reg_alloc(list,R_O0);
-           a_load_ref_reg(list,OS_16,src,R_O0);
-           a_load_reg_ref(list,OS_16,R_O0,dst);
+           r.enum:=R_O0;
+           a_reg_alloc(list,r);
+           a_load_ref_reg(list,OS_16,src,r);
+           a_load_reg_ref(list,OS_16,r,dst);
            inc(src.offset,2);
            inc(dst.offset,2);
-           a_reg_dealloc(list,R_O0);
+           a_reg_dealloc(list,r);
          end;
        if (len and 1) <> 0 then
          begin
-           a_reg_alloc(list,R_O0);
-           a_load_ref_reg(list,OS_8,src,R_O0);
-           a_load_reg_ref(list,OS_8,R_O0,dst);
-           a_reg_dealloc(list,R_O0);
+           r.enum:=R_O0;
+           a_reg_alloc(list,r);
+           a_load_ref_reg(list,OS_8,src,r);
+           a_load_reg_ref(list,OS_8,r,dst);
+           a_reg_dealloc(list,r);
          end;
        if orgsrc then
          begin
@@ -1255,14 +1287,14 @@ function TCgSparc.reg_cgsize(CONST reg:tregister):tcgsize;
 {***************** This is private property, keep out! :) *****************}
 function TCgSparc.IsSimpleRef(const ref:treference):boolean;
   begin
-    if(ref.base=R_NONE)and(ref.index <> R_NO)
+    if(ref.base.enum=R_NONE)and(ref.index.enum <> R_NO)
     then
       InternalError(2002100804);
     result :=not(assigned(ref.symbol))and
-              (((ref.index = R_NO) and
+              (((ref.index.enum = R_NO) and
                (ref.offset >= low(smallint)) and
                 (ref.offset <= high(smallint))) or
-              ((ref.index <> R_NO) and
+              ((ref.index.enum <> R_NO) and
               (ref.offset = 0)));
   end;
 procedure TCgSparc.sizes2load(s1:tcgsize;s2:topsize;var op:tasmop;var s3:topsize);
@@ -1377,7 +1409,10 @@ BEGIN
 END.
 {
   $Log$
-  Revision 1.33  2003-01-07 22:03:40  mazen
+  Revision 1.34  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.33  2003/01/07 22:03:40  mazen
   * adding unequaln node support to sparc compiler
 
   Revision 1.32  2003/01/06 22:51:47  mazen

+ 20 - 9
compiler/sparc/cpubase.pas

@@ -191,18 +191,26 @@ CONST
 TYPE
   { enumeration for registers, don't change the order }
   { it's used by the register size conversions        }
-  TRegister=({$INCLUDE registers.inc});
+  ToldRegister=({$INCLUDE registers.inc});
+  Tregister=record
+    enum:Toldregister;
+    number:word;
+  end;
   TRegister64=PACKED RECORD
   {A type to store register locations for 64 Bit values.}
      RegLo,RegHi:TRegister;
   END;
   treg64=tregister64;{alias for compact code}
-  TRegisterSet=SET OF TRegister;
-  reg2strtable=ARRAY[tregister] OF STRING[6];
+  TRegisterSet=SET OF ToldRegister;
 CONST
   R_NO=R_NONE;
-  firstreg = low(tregister);
-  lastreg  = high(tregister);
+  firstreg = low(Toldregister);
+  lastreg  = high(R_ASR31);
+  
+type
+  reg2strtable=ARRAY[firstreg..lastreg] OF STRING[6];
+
+const
   std_reg2str:reg2strtable=({$INCLUDE strregs.inc});
 {*****************************************************************************
                                    Flags
@@ -401,7 +409,7 @@ const
 
       }
 
-  stab_regindex:ARRAY[tregister]OF ShortInt=({$INCLUDE stabregi.inc});
+  stab_regindex:ARRAY[firstreg..lastreg]OF ShortInt=({$INCLUDE stabregi.inc});
 {*************************** generic register names **************************}
 	stack_pointer_reg		=	R_O6;
   frame_pointer_reg		=	R_I6;
@@ -443,7 +451,7 @@ PARM_BOUNDARY / BITS_PER_UNIT in the GCC source.}
 {# Registers which are defined as scratch and no need to save across routine
 calls or in assembler blocks.}
   ScratchRegsCount=3;
-  scratch_regs:ARRAY[1..ScratchRegsCount]OF TRegister=(R_O4,R_O5,R_I7);
+  scratch_regs:ARRAY[1..ScratchRegsCount]OF ToldRegister=(R_O4,R_O5,R_I7);
   {$WARNING FIXME : Scratch registers list has to be verified}
 { low and high of the available maximum width integer general purpose }
 { registers                                                           }
@@ -489,7 +497,7 @@ VAR
 *****************************************************************************}
 const
   maxvarregs=30;
-  VarRegs:ARRAY[1..maxvarregs]OF TRegister=(
+  VarRegs:ARRAY[1..maxvarregs]OF ToldRegister=(
              R_G0,R_G1,R_G2,R_G3,R_G4,R_G5,R_G6,R_G7,
              R_O0,R_O1,R_O2,R_O3,R_O4,R_O5,{R_R14=R_SP}R_O7,
              R_L0,R_L1,R_L2,R_L3,R_L4,R_L5,R_L6,R_L7,
@@ -523,7 +531,10 @@ function flags_to_cond(const f:TResFlags):TAsmCond;
 END.
 {
   $Log$
-  Revision 1.17  2003-01-05 20:39:53  mazen
+  Revision 1.18  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.17  2003/01/05 20:39:53  mazen
   * warnings about FreeTemp already free fixed with appropriate registers handling
 
   Revision 1.16  2002/10/28 20:59:17  mazen

+ 11 - 8
compiler/sparc/cpugas.pas

@@ -60,16 +60,16 @@ function GetReferenceString(var ref:TReference):string;
       else
         begin
           inc(offset,offsetfixup);
-          if base<>R_NONE
+          if base.enum<>R_NONE
           then
-            GetReferenceString:=gas_reg2str[base]+'+';
-          if index<>R_NONE
+            GetReferenceString:=gas_reg2str[base.enum]+'+';
+          if index.enum<>R_NONE
           then
             begin
               if ScaleFactor<>0
               then
                 GetReferenceString:=GetReferenceString+ToStr(ScaleFactor)+'*';
-              GetReferenceString:=GetReferenceString+gas_reg2str[index]+'+';
+              GetReferenceString:=GetReferenceString+gas_reg2str[index.enum]+'+';
             end;
           if Offset=0
           then
@@ -92,7 +92,7 @@ function getopstr(const Oper:TOper):string;
     with Oper do
       case typ of
         top_reg:
-          getopstr:=gas_reg2str[reg];
+          getopstr:=gas_reg2str[reg.enum];
         top_ref:
           getopstr:='['+getreferencestring(ref^)+']';
         top_const:
@@ -114,9 +114,9 @@ function getopstr(const Oper:TOper):string;
             getopstr:=hs;
           end;
         top_raddr:
-          getopstr:=std_reg2str[reg1]+'+'+std_reg2str[reg2];
+          getopstr:=std_reg2str[reg1.enum]+'+'+std_reg2str[reg2.enum];
         top_caddr:
-          getopstr:=std_reg2str[regb]+'+'+ToStr(const13);
+          getopstr:=std_reg2str[regb.enum]+'+'+ToStr(const13);
         else
           internalerror(10001);
       end;
@@ -209,7 +209,10 @@ initialization
 end.
 {
     $Log$
-    Revision 1.10  2002-11-16 15:29:16  florian
+    Revision 1.11  2003-01-08 18:43:58  daniel
+     * Tregister changed into a record
+
+    Revision 1.10  2002/11/16 15:29:16  florian
       * fixed Cish syntax
 
     Revision 1.9  2002/11/10 19:07:46  mazen

+ 24 - 21
compiler/sparc/cpupara.pas

@@ -59,7 +59,7 @@ function TSparcParaManager.GetIntParaLoc(nr:longint):TParaLocation;
       else{The other parameters are passed into the frame}
         begin
           loc:=LOC_REFERENCE;
-          reference.index:=frame_pointer_reg;
+          reference.index.enum:=frame_pointer_reg;
           reference.offset:=-68-nr*4;
         end;
   end;
@@ -127,8 +127,8 @@ procedure TSparcParaManager.create_param_loc_info(p:TAbstractProcDef);
     loc:tloc;
     is_64bit:boolean;
   begin
-    nextintreg:=R_O0;
-    nextfloatreg:=R_F0;
+    nextintreg.enum:=R_O0;
+    nextfloatreg.enum:=R_F0;
     stack_offset:=92;
     hp:=TParaItem(p.para.First);
     while assigned(hp) do
@@ -142,24 +142,24 @@ procedure TSparcParaManager.create_param_loc_info(p:TAbstractProcDef);
               then
                 hp.paraloc.size:=OS_ADDR;
               is_64bit:=hp.paraloc.size in [OS_64,OS_S64];
-              if NextIntReg<=TRegister(ord(R_i5)-ord(is_64bit))
+              if NextIntReg.enum<=ToldRegister(ord(R_i5)-ord(is_64bit))
               then
                 begin
                   hp.paraloc.loc:=LOC_REGISTER;
                   hp.paraloc.registerlow:=NextIntReg;
-                  inc(NextIntReg);
+                  inc(NextIntReg.enum);
                   if is_64bit
                   then
                     begin
                       hp.paraloc.registerhigh:=nextintreg;
-                      inc(nextintreg);
+                      inc(nextintreg.enum);
                     end;
                 end
               else
                 begin
-                  nextintreg:=R_i6;
+                  nextintreg.enum:=R_i6;
                   hp.paraloc.loc:=LOC_REFERENCE;
-                  hp.paraloc.reference.index:=stack_pointer_reg;
+                  hp.paraloc.reference.index.enum:=stack_pointer_reg;
                   hp.paraloc.reference.offset:=stack_offset;
                   if not is_64bit
                   then
@@ -173,13 +173,13 @@ procedure TSparcParaManager.create_param_loc_info(p:TAbstractProcDef);
               if hp.paratyp in [vs_var,vs_out]
               then
                 begin
-                  if NextIntReg<=R_O5
+                  if NextIntReg.enum<=R_O5
                   then
                     begin
                       hp.paraloc.size:=OS_ADDR;
                       hp.paraloc.loc:=LOC_REGISTER;
                       hp.paraloc.register:=nextintreg;
-                      inc(nextintreg);
+                      inc(nextintreg.enum);
                     end
                   else
                     begin
@@ -188,12 +188,12 @@ procedure TSparcParaManager.create_param_loc_info(p:TAbstractProcDef);
                       internalerror(2002071006);
                     end;
                 end
-              else if nextfloatreg<=R_F10 then
+              else if nextfloatreg.enum<=R_F10 then
                 begin
                   hp.paraloc.size:=def_cgsize(hp.paratype.def);
                   hp.paraloc.loc:=LOC_FPUREGISTER;
                   hp.paraloc.register:=nextfloatreg;
-                  inc(nextfloatreg);
+                  inc(nextfloatreg.enum);
                 end
               else
                 begin
@@ -207,16 +207,16 @@ procedure TSparcParaManager.create_param_loc_info(p:TAbstractProcDef);
                       hp.paraloc.size:=OS_ADDR;
                       if push_addr_param(hp.paratype.def,p.proccalloption) or (hp.paratyp in [vs_var,vs_out]) then
                         begin
-                           if nextintreg<=R_O5 then
+                           if nextintreg.enum<=R_O5 then
                              begin
                                 hp.paraloc.loc:=LOC_REGISTER;
                                 hp.paraloc.register:=nextintreg;
-                                inc(nextintreg);
+                                inc(nextintreg.enum);
                              end
                            else
                               begin
                                  hp.paraloc.loc:=LOC_REFERENCE;
-                                 hp.paraloc.reference.index:=stack_pointer_reg;
+                                 hp.paraloc.reference.index.enum:=stack_pointer_reg;
                                  hp.paraloc.reference.offset:=stack_offset;
                                  inc(stack_offset,4);
                              end;
@@ -224,7 +224,7 @@ procedure TSparcParaManager.create_param_loc_info(p:TAbstractProcDef);
                       else
                         begin
                            hp.paraloc.loc:=LOC_REFERENCE;
-                           hp.paraloc.reference.index:=stack_pointer_reg;
+                           hp.paraloc.reference.index.enum:=stack_pointer_reg;
                            hp.paraloc.reference.offset:=stack_offset;
                            inc(stack_offset,hp.paratype.def.size);
                         end;
@@ -242,16 +242,16 @@ function tSparcParaManager.GetFuncRetParaLoc(p:TAbstractProcDef):TParaLocation;
         orddef,enumdef:
           begin
             loc:=LOC_REGISTER;
-            register:=return_result_reg;
+            register.enum:=return_result_reg;
             size:=def_cgsize(p.rettype.def);
             if size in [OS_S64,OS_64]
             then
-              RegisterHigh:=R_I1;
+              RegisterHigh.enum:=R_I1;
           end;
         floatdef:
           begin
             loc:=LOC_FPUREGISTER;
-            register:=R_F1;
+            register.enum:=R_F1;
             size:=def_cgsize(p.rettype.def);
           end;
         setdef,
@@ -268,7 +268,7 @@ function tSparcParaManager.GetFuncRetParaLoc(p:TAbstractProcDef):TParaLocation;
         errordef:
           begin
             loc:=LOC_REFERENCE;
-            reference.index:=frame_pointer_reg;
+            reference.index.enum:=frame_pointer_reg;
             reference.offset:=64;
             size:=OS_ADDR;
           end;
@@ -281,7 +281,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.13  2003-01-05 21:32:35  mazen
+  Revision 1.14  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.13  2003/01/05 21:32:35  mazen
   * fixing several bugs compiling the RTL
 
   Revision 1.12  2002/11/25 19:21:49  mazen

+ 5 - 2
compiler/sparc/ncpuadd.pas

@@ -475,7 +475,7 @@ procedures }
       location_reset(location,LOC_FLAGS,OS_NO);
     //load_left_right(cmpop, (cs_check_overflow in aktlocalswitches) and
     //(nodetype in [addn,subn,muln]));
-    if(location.register = R_NO)and not(cmpop)
+    if(location.register.enum = R_NO)and not(cmpop)
     then
       location.register := rg.getregisterint(exprasmlist);
     if not(cs_check_overflow in aktlocalswitches)or cmpop or (nodetype in [orn,andn,xorn])
@@ -573,7 +573,10 @@ begin
 end.
 {
     $Log$
-    Revision 1.5  2003-01-07 22:03:40  mazen
+    Revision 1.6  2003-01-08 18:43:58  daniel
+     * Tregister changed into a record
+
+    Revision 1.5  2003/01/07 22:03:40  mazen
     * adding unequaln node support to sparc compiler
 
     Revision 1.4  2002/12/30 21:17:22  mazen

+ 8 - 3
compiler/sparc/ncpumat.pas

@@ -150,7 +150,7 @@ implementation
              rg.ungetregister(exprasmlist,divider);
            end;
        { free used registers }
-        if numerator <> resultreg then
+        if numerator.enum <> resultreg.enum then
           rg.ungetregisterint(exprasmlist,numerator);
         { set result location }
         location.loc:=LOC_REGISTER;
@@ -174,6 +174,7 @@ procedure tSparcshlshrnode.pass_2;
     asmop1, asmop2: tasmop;
     shiftval: aword;
     saved : tmaybesave;
+    r:Tregister;
   begin
     secondpass(left);
     maybe_save(exprasmlist,right.registers32,left.location,saved);
@@ -252,6 +253,7 @@ procedure tSparcshlshrnode.pass_2;
                 location.registerhigh := location.registerlow;
                 location.registerlow := resultreg;
               end;
+            r.enum:=R_G0;
             rg.getexplicitregisterint(exprasmlist,R_G0);
 {            exprasmlist.concat(taicpu.op_reg_reg_const(A_SUBFIC,R_0,hregister1,32));
             exprasmlist.concat(taicpu.op_reg_reg_reg(asmop1,location.registerhigh,hregisterhigh,hregister1));
@@ -261,7 +263,7 @@ procedure tSparcshlshrnode.pass_2;
             exprasmlist.concat(taicpu.op_reg_reg_reg(asmop1,R_0,hregisterlow,R_0));
             exprasmlist.concat(taicpu.op_reg_reg_reg(A_OR,location.registerhigh,location.registerhigh,R_0));
             exprasmlist.concat(taicpu.op_reg_reg_reg(asmop1,location.registerlow,hregisterlow,hregister1));}
-            rg.ungetregister(exprasmlist,R_G0);
+            rg.ungetregister(exprasmlist,r);
             if right.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]
             then
               cg.free_scratch_reg(exprasmlist,hregister1)
@@ -475,7 +477,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.2  2002-12-30 21:17:22  mazen
+  Revision 1.3  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.2  2002/12/30 21:17:22  mazen
   - unit cga no more used in sparc compiler.
 
   Revision 1.1  2002/12/21 23:22:59  mazen

+ 9 - 6
compiler/sparc/radirect.pas

@@ -99,7 +99,7 @@ end;
           is_fpu(aktprocdef.rettype.def) then
          tfuncretsym(aktprocdef.funcretsym).funcretstate:=vs_assigned;
        if (not is_void(aktprocdef.rettype.def)) then
-         retstr:=upper(tostr(procinfo.return_offset)+'('+std_reg2str[procinfo.framepointer]+')')
+         retstr:=upper(tostr(procinfo.return_offset)+'('+std_reg2str[procinfo.framepointer.enum]+')')
        else
          retstr:='';
          c:=current_scanner.asmgetchar;
@@ -180,7 +180,7 @@ end;
                                                hs:=tvarsym(sym).mangledname
                                              else
                                                hs:='-'+tostr(tvarsym(sym).address)+
-                                                   '('+std_reg2str[procinfo.framepointer]+')';
+                                                   '('+std_reg2str[procinfo.framepointer.enum]+')';
                                              end
                                            else
                                            { call to local function }
@@ -203,7 +203,7 @@ end;
                                                      l:=tvarsym(sym).address;
                                                      { set offset }
                                                      inc(l,aktprocdef.parast.address_fixup);
-                                                     hs:=tostr(l)+'('+std_reg2str[procinfo.framepointer]+')';
+                                                     hs:=tostr(l)+'('+std_reg2str[procinfo.framepointer.enum]+')';
                                                      if pos(',',s) > 0 then
                                                        tvarsym(sym).varstate:=vs_used;
                                                   end;
@@ -249,7 +249,7 @@ end;
                                              begin
                                                 if assigned(procinfo._class) then
                                                   hs:=tostr(procinfo.selfpointer_offset)+
-                                                      '('+std_reg2str[procinfo.framepointer]+')'
+                                                      '('+std_reg2str[procinfo.framepointer.enum]+')'
                                                 else
                                                  Message(asmr_e_cannot_use_SELF_outside_a_method);
                                              end
@@ -266,7 +266,7 @@ end;
                                                 { we do it: }
                                                 if lexlevel>normal_function_level then
                                                   hs:=tostr(procinfo.framepointer_offset)+
-                                                    '('+std_reg2str[procinfo.framepointer]+')'
+                                                    '('+std_reg2str[procinfo.framepointer.enum]+')'
                                                 else
                                                   Message(asmr_e_cannot_use_OLDEBP_outside_nested_procedure);
                                              end;
@@ -314,7 +314,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.4  2002-11-25 17:43:29  peter
+  Revision 1.5  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.4  2002/11/25 17:43:29  peter
     * splitted defbase in defutil,symutil,defcmp
     * merged isconvertable and is_equal into compare_defs(_ext)
     * made operator search faster by walking the list only once

+ 13 - 6
compiler/sparc/rgcpu.pas

@@ -33,25 +33,29 @@ code generator to allocate and free registers which might be valid across
 nodes. It also contains utility routines related to registers. Some of the
 methods in this class overrides generic implementations in rgobj.pas.}
   trgcpu=class(trgobj)
-    function GetExplicitRegisterInt(list:taasmoutput;Reg:tregister):tregister;override;
+    function GetExplicitRegisterInt(list:taasmoutput;Reg:Toldregister):tregister;override;
     procedure UngetregisterInt(list:taasmoutput;Reg:tregister);override;
   end;
 implementation
 uses
   cgobj;
-function trgcpu.GetExplicitRegisterInt(list:taasmoutput;reg:tregister):tregister;
+function trgcpu.GetExplicitRegisterInt(list:taasmoutput;reg:Toldregister):tregister;
+
+var r:Tregister;
+
   begin
     if reg in [R_O7,R_I7]
     then
       begin
-        cg.a_reg_alloc(list,Reg);
-        result := Reg;
+        r.enum:=reg;
+        cg.a_reg_alloc(list,r);
+        result := r;
       end
     else result := inherited GetExplicitRegisterInt(list,reg);
   end;
 procedure trgcpu.UngetregisterInt(list: taasmoutput; reg: tregister);
   begin
-    if reg in [R_O7,R_I7]
+    if reg.enum in [R_O7,R_I7]
     then
       cg.a_reg_dealloc(list,reg)
     else
@@ -62,7 +66,10 @@ initialization
 end.
 {
   $Log$
-  Revision 1.4  2002-10-13 21:46:07  mazen
+  Revision 1.5  2003-01-08 18:43:58  daniel
+   * Tregister changed into a record
+
+  Revision 1.4  2002/10/13 21:46:07  mazen
   * assembler output format fixed
 
   Revision 1.3  2002/10/12 19:03:23  mazen

+ 14 - 7
compiler/symsym.pas

@@ -1607,7 +1607,7 @@ implementation
            include(varoptions,vo_fpuregable)
          else
            exclude(varoptions,vo_fpuregable);
-         reg:=R_NO;
+         reg.enum:=R_NO;
       end;
 
 
@@ -1630,7 +1630,7 @@ implementation
       begin
          inherited loadsym(ppufile);
          typ:=varsym;
-         reg:=R_NO;
+         reg.enum:=R_NO;
          refs := 0;
          varstate:=vs_used;
          varspez:=tvarspez(ppufile.getbyte);
@@ -1813,13 +1813,15 @@ implementation
                   so some optimizing will make things harder to debug }
          end
        else if (owner.symtabletype in [localsymtable,inlinelocalsymtable]) then
-         if reg<>R_NO then
+         if reg.enum<>R_NO then
            begin
+              if reg.enum>lastreg then
+                internalerror(200201081);
               { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
               { this is the register order for GDB}
               stabstring:=strpnew('"'+name+':r'+st+'",'+
                         tostr(N_RSYM)+',0,'+
-                        tostr(fileinfo.line)+','+tostr(stab_regindex[reg]));
+                        tostr(fileinfo.line)+','+tostr(stab_regindex[reg.enum]));
            end
          else
            { I don't know if this will work (PM) }
@@ -1841,14 +1843,16 @@ implementation
            exit;
          inherited concatstabto(asmlist);
       if (owner.symtabletype=parasymtable) and
-         (reg<>R_NO) then
+         (reg.enum<>R_NO) then
            begin
+              if reg.enum>lastreg then
+                internalerror(2003010801);
            { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "eip", "ps", "cs", "ss", "ds", "es", "fs", "gs", }
            { this is the register order for GDB}
               stab_str:=strpnew('"'+name+':r'
                      +tstoreddef(vartype.def).numberstring+'",'+
                      tostr(N_RSYM)+',0,'+
-                     tostr(fileinfo.line)+','+tostr(stab_regindex[reg]));
+                     tostr(fileinfo.line)+','+tostr(stab_regindex[reg.enum]));
               asmList.concat(Tai_stabs.Create(stab_str));
            end;
       end;
@@ -2559,7 +2563,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.90  2003-01-03 12:15:56  daniel
+  Revision 1.91  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.90  2003/01/03 12:15:56  daniel
     * Removed ifdefs around notifications
       ifdefs around for loop optimizations remain
 

+ 14 - 5
compiler/tgobj.pas

@@ -439,16 +439,22 @@ unit tgobj;
          { ref.index = R_NO was missing
            led to problems with local arrays
            with lower bound > 0 (PM) }
+         if ref.base.enum>lastreg then
+           internalerror(200301081);
+         if ref.index.enum>lastreg then
+           internalerror(200301081);
+         if procinfo.framepointer.enum>lastreg then
+           internalerror(200301081);
          if direction = 1 then
            begin
-             istemp:=((ref.base=procinfo.framepointer) and
-                     (ref.index=R_NO) and
+             istemp:=((ref.base.enum=procinfo.framepointer.enum) and
+                     (ref.index.enum=R_NO) and
                       (ref.offset>firsttemp));
            end
         else
            begin
-             istemp:=((ref.base=procinfo.framepointer) and
-                     (ref.index=R_NO) and
+             istemp:=((ref.base.enum=procinfo.framepointer.enum) and
+                     (ref.index.enum=R_NO) and
                       (ref.offset<firsttemp));
            end;
       end;
@@ -537,7 +543,10 @@ finalization
 end.
 {
   $Log$
-  Revision 1.22  2002-12-01 18:58:26  carl
+  Revision 1.23  2003-01-08 18:43:57  daniel
+   * Tregister changed into a record
+
+  Revision 1.22  2002/12/01 18:58:26  carl
     * fix bugs with istemp() was wrong, and every reference was a temp
 
   Revision 1.21  2002/11/24 18:18:04  carl

Разлика између датотеке није приказан због своје велике величине
+ 323 - 166
compiler/x86/cgx86.pas


Неке датотеке нису приказане због велике количине промена