Browse Source

* Work on register conversion

daniel 23 years ago
parent
commit
7be2b727f2

+ 10 - 4
compiler/i386/cpubase.pas

@@ -234,10 +234,12 @@ uses
               RS_32   = 3;    {Like EAX}
               RS_32   = 3;    {Like EAX}
               RS_64   = 4;    {Like RAX}
               RS_64   = 4;    {Like RAX}
 
 
-      type  Tregister = packed record
+      type  Tnewregister=word;
+
+            Tregister = packed record
               enum:Toldregister;
               enum:Toldregister;
-              number:word;        {This is a word for now, change to cardinal when
-                                   the old register coding is away.}
+              number:Tnewregister;  {This is a word for now, change to cardinal
+                                     when the old register coding is away.}
             end;
             end;
       {$packenum normal}
       {$packenum normal}
 
 
@@ -251,6 +253,7 @@ uses
 
 
       {# Set type definition for registers }
       {# Set type definition for registers }
       tregisterset = set of Toldregister;
       tregisterset = set of Toldregister;
+      Tsupregset = set of byte;
 
 
 
 
     const
     const
@@ -711,7 +714,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.39  2003-01-09 20:41:00  daniel
+  Revision 1.40  2003-01-13 18:37:44  daniel
+    * Work on register conversion
+
+  Revision 1.39  2003/01/09 20:41:00  daniel
     * Converted some code in cgx86.pas to new register numbering
     * Converted some code in cgx86.pas to new register numbering
 
 
   Revision 1.38  2003/01/09 15:49:56  daniel
   Revision 1.38  2003/01/09 15:49:56  daniel

+ 27 - 15
compiler/i386/n386add.pas

@@ -224,11 +224,13 @@ interface
             begin
             begin
               if extra_not then
               if extra_not then
                 emit_reg(A_NOT,opsize,left.location.register);
                 emit_reg(A_NOT,opsize,left.location.register);
-              r.enum:=R_EDI;
               rg.getexplicitregisterint(exprasmlist,R_EDI);
               rg.getexplicitregisterint(exprasmlist,R_EDI);
+              r.enum:=R_INTREGISTER;
+              r.number:=NR_EDI;
               cg.a_load_loc_reg(exprasmlist,right.location,r);
               cg.a_load_loc_reg(exprasmlist,right.location,r);
               emit_reg_reg(op,opsize,left.location.register,r);
               emit_reg_reg(op,opsize,left.location.register,r);
               emit_reg_reg(A_MOV,opsize,r,left.location.register);
               emit_reg_reg(A_MOV,opsize,r,left.location.register);
+              r.enum:=R_EDI;
               rg.ungetregisterint(exprasmlist,r);
               rg.ungetregisterint(exprasmlist,r);
             end
             end
            else
            else
@@ -269,11 +271,13 @@ interface
                  begin
                  begin
                    if extra_not then
                    if extra_not then
                      begin
                      begin
-                        r.enum:=R_EDI;
                         rg.getexplicitregisterint(exprasmlist,R_EDI);
                         rg.getexplicitregisterint(exprasmlist,R_EDI);
+                        r.enum:=R_INTREGISTER;
+                        r.number:=NR_EDI;
                         cg.a_load_loc_reg(exprasmlist,right.location,r);
                         cg.a_load_loc_reg(exprasmlist,right.location,r);
                         emit_reg(A_NOT,S_L,r);
                         emit_reg(A_NOT,S_L,r);
                         emit_reg_reg(A_AND,S_L,r,left.location.register);
                         emit_reg_reg(A_AND,S_L,r,left.location.register);
+                        r.enum:=R_EDI;
                         rg.ungetregisterint(exprasmlist,r);
                         rg.ungetregisterint(exprasmlist,r);
                      end
                      end
                    else
                    else
@@ -1025,8 +1029,9 @@ interface
            { right.location<>LOC_REGISTER }
            { right.location<>LOC_REGISTER }
            if (nodetype=subn) and (nf_swaped in flags) then
            if (nodetype=subn) and (nf_swaped in flags) then
             begin
             begin
-              r.enum:=R_EDI;
               rg.getexplicitregisterint(exprasmlist,R_EDI);
               rg.getexplicitregisterint(exprasmlist,R_EDI);
+              r.enum:=R_INTREGISTER;
+              r.number:=NR_EDI;
               cg64.a_load64low_loc_reg(exprasmlist,right.location,r);
               cg64.a_load64low_loc_reg(exprasmlist,right.location,r);
               emit_reg_reg(op1,opsize,left.location.registerlow,r);
               emit_reg_reg(op1,opsize,left.location.registerlow,r);
               emit_reg_reg(A_MOV,opsize,r,left.location.registerlow);
               emit_reg_reg(A_MOV,opsize,r,left.location.registerlow);
@@ -1034,6 +1039,7 @@ interface
               { the carry flag is still ok }
               { the carry flag is still ok }
               emit_reg_reg(op2,opsize,left.location.registerhigh,r);
               emit_reg_reg(op2,opsize,left.location.registerhigh,r);
               emit_reg_reg(A_MOV,opsize,r,left.location.registerhigh);
               emit_reg_reg(A_MOV,opsize,r,left.location.registerhigh);
+              r.enum:=R_EDI;
               rg.ungetregisterint(exprasmlist,r);
               rg.ungetregisterint(exprasmlist,r);
               if right.location.loc<>LOC_CREGISTER then
               if right.location.loc<>LOC_CREGISTER then
                begin
                begin
@@ -1468,28 +1474,29 @@ interface
                { used in either the left or the right location, excepts if   }
                { used in either the left or the right location, excepts if   }
                {they are regvars. It DOES contain them if they are used in   }
                {they are regvars. It DOES contain them if they are used in   }
                { another location (JM)                                       }
                { another location (JM)                                       }
+               r.enum:=R_INTREGISTER;
                if not(R_EAX in rg.unusedregsint) and
                if not(R_EAX in rg.unusedregsint) and
                   (R_EAX in regstopush) then
                   (R_EAX in regstopush) then
                  begin
                  begin
-                   r.enum:=R_EAX;
+                   r.number:=NR_EAX;
                    emit_reg(A_PUSH,S_L,r);
                    emit_reg(A_PUSH,S_L,r);
                    popeax:=true;
                    popeax:=true;
                  end;
                  end;
                if not(R_EDX in rg.unusedregsint) and
                if not(R_EDX in rg.unusedregsint) and
                    (R_EDX in regstopush) then
                    (R_EDX in regstopush) then
                  begin
                  begin
-                   r.enum:=R_EDX;
+                   r.number:=NR_EDX;
                    emit_reg(A_PUSH,S_L,r);
                    emit_reg(A_PUSH,S_L,r);
                    popedx:=true;
                    popedx:=true;
                  end;
                  end;
                { left.location can be R_EAX !!! }
                { left.location can be R_EAX !!! }
-               r.enum:=R_EDI;
                rg.getexplicitregisterint(exprasmlist,R_EDI);
                rg.getexplicitregisterint(exprasmlist,R_EDI);
                { load the left value }
                { load the left value }
+               r.number:=NR_EDI;
                cg.a_load_loc_reg(exprasmlist,left.location,r);
                cg.a_load_loc_reg(exprasmlist,left.location,r);
                location_release(exprasmlist,left.location);
                location_release(exprasmlist,left.location);
                { allocate EAX }
                { allocate EAX }
-               r.enum:=R_EAX;
+               r.number:=NR_EAX;
                if R_EAX in rg.unusedregsint then
                if R_EAX in rg.unusedregsint then
                  exprasmList.concat(tai_regalloc.Alloc(r));
                  exprasmList.concat(tai_regalloc.Alloc(r));
                { load he right value }
                { load he right value }
@@ -1500,25 +1507,27 @@ interface
                  exprasmList.concat(tai_regalloc.Alloc(r));
                  exprasmList.concat(tai_regalloc.Alloc(r));
                { also allocate EDX, since it is also modified by }
                { also allocate EDX, since it is also modified by }
                { a mul (JM)                                      }
                { a mul (JM)                                      }
-               r.enum:=R_EDX;
+               r.number:=NR_EDX;
                if R_EDX in rg.unusedregsint then
                if R_EDX in rg.unusedregsint then
                  exprasmList.concat(tai_regalloc.Alloc(r));
                  exprasmList.concat(tai_regalloc.Alloc(r));
-               r.enum:=R_EDI;
+               r.number:=NR_EDI;
                emit_reg(A_MUL,S_L,r);
                emit_reg(A_MUL,S_L,r);
+               r.enum:=R_EDI;
                rg.ungetregisterint(exprasmlist,r);
                rg.ungetregisterint(exprasmlist,r);
-               r.enum:=R_EDX;
+               r.enum:=R_INTREGISTER;
+               r.number:=NR_EDX;
                if R_EDX in rg.unusedregsint then
                if R_EDX in rg.unusedregsint then
                  exprasmList.concat(tai_regalloc.DeAlloc(r));
                  exprasmList.concat(tai_regalloc.DeAlloc(r));
-               r.enum:=R_EAX;
+               r.number:=NR_EAX;
                if R_EAX in rg.unusedregsint then
                if R_EAX in rg.unusedregsint then
                  exprasmList.concat(tai_regalloc.DeAlloc(r));
                  exprasmList.concat(tai_regalloc.DeAlloc(r));
                location.register:=rg.getregisterint(exprasmlist);
                location.register:=rg.getregisterint(exprasmlist);
-               r.enum:=R_EAX;
+               r.number:=NR_EAX;
                emit_reg_reg(A_MOV,S_L,r,location.register);
                emit_reg_reg(A_MOV,S_L,r,location.register);
-               r.enum:=R_EDX;
+               r.number:=NR_EDX;
                if popedx then
                if popedx then
                  emit_reg(A_POP,S_L,r);
                  emit_reg(A_POP,S_L,r);
-               r.enum:=R_EAX;
+               r.number:=NR_EAX;
                if popeax then
                if popeax then
                  emit_reg(A_POP,S_L,r);
                  emit_reg(A_POP,S_L,r);
                location_freetemp(exprasmlist,left.location);
                location_freetemp(exprasmlist,left.location);
@@ -1580,7 +1589,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.53  2003-01-08 18:43:57  daniel
+  Revision 1.54  2003-01-13 18:37:44  daniel
+    * Work on register conversion
+
+  Revision 1.53  2003/01/08 18:43:57  daniel
    * Tregister changed into a record
    * Tregister changed into a record
 
 
   Revision 1.52  2002/11/25 17:43:26  peter
   Revision 1.52  2002/11/25 17:43:26  peter

+ 6 - 2
compiler/i386/n386cal.pas

@@ -1124,8 +1124,9 @@ implementation
                   (aktoptprocessor=ClassP5) and
                   (aktoptprocessor=ClassP5) and
                   (procinfo._class=nil) then
                   (procinfo._class=nil) then
                     begin
                     begin
-                       r.enum:=R_EDI;
                        rg.getexplicitregisterint(exprasmlist,R_EDI);
                        rg.getexplicitregisterint(exprasmlist,R_EDI);
+                       r.enum:=R_INTREGISTER;
+                       r.number:=NR_EDI;
                        emit_reg(A_POP,S_L,r);
                        emit_reg(A_POP,S_L,r);
                        rg.ungetregisterint(exprasmlist,r);
                        rg.ungetregisterint(exprasmlist,r);
                        r.enum:=R_ESI;
                        r.enum:=R_ESI;
@@ -1276,7 +1277,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.79  2003-01-08 18:43:57  daniel
+  Revision 1.80  2003-01-13 18:37:44  daniel
+    * Work on register conversion
+
+  Revision 1.79  2003/01/08 18:43:57  daniel
    * Tregister changed into a record
    * Tregister changed into a record
 
 
   Revision 1.78  2002/12/15 21:30:12  florian
   Revision 1.78  2002/12/15 21:30:12  florian

+ 7 - 2
compiler/i386/n386cnv.pas

@@ -199,8 +199,10 @@ implementation
              begin
              begin
                 emit_ref(A_FILD,S_IL,href);
                 emit_ref(A_FILD,S_IL,href);
                 rg.getexplicitregisterint(exprasmlist,R_EDI);
                 rg.getexplicitregisterint(exprasmlist,R_EDI);
-                r.enum:=R_EDI;
+                r.enum:=R_INTREGISTER;
+                r.number:=NR_EDI;
                 emit_reg(A_POP,S_L,r);
                 emit_reg(A_POP,S_L,r);
+                r.enum:=R_EDI;
                 rg.ungetregisterint(exprasmlist,r);
                 rg.ungetregisterint(exprasmlist,r);
              end;
              end;
          end;
          end;
@@ -428,7 +430,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.54  2003-01-08 18:43:57  daniel
+  Revision 1.55  2003-01-13 18:37:44  daniel
+    * Work on register conversion
+
+  Revision 1.54  2003/01/08 18:43:57  daniel
    * Tregister changed into a record
    * Tregister changed into a record
 
 
   Revision 1.53  2002/12/05 14:27:42  florian
   Revision 1.53  2002/12/05 14:27:42  florian

+ 7 - 2
compiler/i386/n386mat.pas

@@ -814,7 +814,8 @@ implementation
              secondpass(left);
              secondpass(left);
              location_reset(location,LOC_MMXREGISTER,OS_NO);
              location_reset(location,LOC_MMXREGISTER,OS_NO);
              { prepare EDI }
              { prepare EDI }
-             r.enum:=R_EDI;
+             r.enum:=R_INTREGISTER;
+             r.number:=NR_EDI;
              r2.enum:=R_MM7;
              r2.enum:=R_MM7;
              rg.getexplicitregisterint(exprasmlist,R_EDI);
              rg.getexplicitregisterint(exprasmlist,R_EDI);
              emit_const_reg(A_MOV,S_L,longint($ffffffff),r);
              emit_const_reg(A_MOV,S_L,longint($ffffffff),r);
@@ -837,6 +838,7 @@ implementation
              end;
              end;
              { load mask }
              { load mask }
              emit_reg_reg(A_MOVD,S_NO,r,r2);
              emit_reg_reg(A_MOVD,S_NO,r,r2);
+             r.enum:=R_EDI;
              rg.ungetregisterint(exprasmlist,r);
              rg.ungetregisterint(exprasmlist,r);
              { lower 32 bit }
              { lower 32 bit }
              emit_reg_reg(A_PXOR,S_D,r2,location.register);
              emit_reg_reg(A_PXOR,S_D,r2,location.register);
@@ -875,7 +877,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.43  2003-01-13 14:54:34  daniel
+  Revision 1.44  2003-01-13 18:37:44  daniel
+    * Work on register conversion
+
+  Revision 1.43  2003/01/13 14:54:34  daniel
     * Further work to convert codegenerator register convention;
     * Further work to convert codegenerator register convention;
       internalerror bug fixed.
       internalerror bug fixed.
 
 

+ 12 - 3
compiler/i386/n386mem.pas

@@ -82,7 +82,10 @@ implementation
       begin
       begin
          inherited pass_2;
          inherited pass_2;
          if tpointerdef(left.resulttype.def).is_far then
          if tpointerdef(left.resulttype.def).is_far then
-          location.reference.segment.enum:=R_FS;
+          begin
+            location.reference.segment.enum:=R_INTREGISTER;
+            location.reference.segment.number:=NR_FS;
+          end;
       end;
       end;
 
 
 
 
@@ -135,7 +138,10 @@ implementation
         inherited pass_2;
         inherited pass_2;
 
 
         if nf_memseg in flags then
         if nf_memseg in flags then
-          location.reference.segment.enum:=R_FS;
+          begin
+            location.reference.segment.enum:=R_INTREGISTER;
+            location.reference.segment.number:=NR_FS;
+          end;
       end;
       end;
 
 
 
 
@@ -146,7 +152,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.48  2003-01-08 18:43:57  daniel
+  Revision 1.49  2003-01-13 18:37:44  daniel
+    * Work on register conversion
+
+  Revision 1.48  2003/01/08 18:43:57  daniel
    * Tregister changed into a record
    * Tregister changed into a record
 
 
   Revision 1.47  2002/12/03 22:14:12  carl
   Revision 1.47  2002/12/03 22:14:12  carl