Bläddra i källkod

* and more new register allocator fixes (in the i386 code generator this
time). At least now the ppc cross compiler can compile the linux
system unit again, but I haven't tested it.

Jonas Maebe 22 år sedan
förälder
incheckning
e8a0c0cd62
5 ändrade filer med 66 tillägg och 36 borttagningar
  1. 16 6
      compiler/i386/n386add.pas
  2. 10 3
      compiler/i386/n386cal.pas
  3. 12 6
      compiler/i386/n386cnv.pas
  4. 7 2
      compiler/i386/n386set.pas
  5. 21 19
      compiler/x86/cgx86.pas

+ 16 - 6
compiler/i386/n386add.pas

@@ -675,17 +675,22 @@ interface
            if not(RS_EAX in rg.unusedregsint) then
            if not(RS_EAX in rg.unusedregsint) then
              begin
              begin
                rg.getexplicitregisterint(exprasmlist,NR_EDI);
                rg.getexplicitregisterint(exprasmlist,NR_EDI);
-               r.enum:=R_EAX;
-               r2.enum:=R_EDI;
+               r.enum:=R_INTREGISTER;
+               r.number:=NR_EAX;
+               r2.enum:=R_INTREGISTER;;
+               r2.number:=NR_EDI;
                emit_reg_reg(A_MOV,S_L,r,r2);
                emit_reg_reg(A_MOV,S_L,r,r2);
              end;
              end;
-           r.enum:=R_AX;
+           r.enum:=R_INTREGISTER;
+           r.number:=NR_AX;
            emit_reg(A_FNSTSW,S_NO,r);
            emit_reg(A_FNSTSW,S_NO,r);
            emit_none(A_SAHF,S_NO);
            emit_none(A_SAHF,S_NO);
            if not(RS_EAX in rg.unusedregsint) then
            if not(RS_EAX in rg.unusedregsint) then
              begin
              begin
-               r.enum:=R_EAX;
-               r2.enum:=R_EDI;
+               r.enum:=R_INTREGISTER;
+               r.number:=NR_EAX;
+               r2.enum:=R_INTREGISTER;;
+               r2.number:=NR_EDI;
                emit_reg_reg(A_MOV,S_L,r2,r);
                emit_reg_reg(A_MOV,S_L,r2,r);
                rg.ungetregisterint(exprasmlist,r2);
                rg.ungetregisterint(exprasmlist,r2);
              end;
              end;
@@ -1640,7 +1645,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.58  2003-03-08 20:36:41  daniel
+  Revision 1.59  2003-03-13 19:52:23  jonas
+    * and more new register allocator fixes (in the i386 code generator this
+      time). At least now the ppc cross compiler can compile the linux
+      system unit again, but I haven't tested it.
+
+  Revision 1.58  2003/03/08 20:36:41  daniel
     + Added newra version of Ti386shlshrnode
     + Added newra version of Ti386shlshrnode
     + Added interference graph construction code
     + Added interference graph construction code
 
 

+ 10 - 3
compiler/i386/n386cal.pas

@@ -340,7 +340,8 @@ implementation
          dont_call;
          dont_call;
 
 
       begin
       begin
-         rsp.enum:=R_ESP;
+         rsp.enum:=R_INTREGISTER;
+         rsp.number:=NR_ESP;
          extended_new:=false;
          extended_new:=false;
          iolabel:=nil;
          iolabel:=nil;
          inlinecode:=nil;
          inlinecode:=nil;
@@ -505,7 +506,8 @@ implementation
                    emit_const_reg(A_AND,S_L,$fffffff8,rsp);
                    emit_const_reg(A_AND,S_L,$fffffff8,rsp);
                    emit_const_reg(A_SUB,S_L,push_size,rsp);
                    emit_const_reg(A_SUB,S_L,push_size,rsp);
                 end;
                 end;
-              r.enum:=R_EDI;
+              r.enum:=R_INTREGISTER;
+              r.number:=R_EDI;
               emit_reg(A_PUSH,S_L,r);
               emit_reg(A_PUSH,S_L,r);
            end
            end
          else
          else
@@ -1315,7 +1317,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.83  2003-03-06 11:35:50  daniel
+  Revision 1.84  2003-03-13 19:52:23  jonas
+    * and more new register allocator fixes (in the i386 code generator this
+      time). At least now the ppc cross compiler can compile the linux
+      system unit again, but I haven't tested it.
+
+  Revision 1.83  2003/03/06 11:35:50  daniel
     * Fixed internalerror 7843 issue
     * Fixed internalerror 7843 issue
 
 
   Revision 1.82  2003/02/19 22:00:15  daniel
   Revision 1.82  2003/02/19 22:00:15  daniel

+ 12 - 6
compiler/i386/n386cnv.pas

@@ -149,18 +149,17 @@ implementation
          exprasmlist.concat(taicpu.op_reg(A_PUSH,S_L,hregister));
          exprasmlist.concat(taicpu.op_reg(A_PUSH,S_L,hregister));
          if freereg then
          if freereg then
            cg.free_scratch_reg(exprasmlist,hregister);
            cg.free_scratch_reg(exprasmlist,hregister);
-         r.enum:=R_ESP;
+         r.enum:=R_INTREGISTER;
+         r.number:=NR_ESP;
          reference_reset_base(href,r,0);
          reference_reset_base(href,r,0);
          case torddef(left.resulttype.def).typ of
          case torddef(left.resulttype.def).typ of
            u32bit:
            u32bit:
              begin
              begin
-                r.enum:=R_ESP;
                 emit_ref(A_FILD,S_IQ,href);
                 emit_ref(A_FILD,S_IQ,href);
                 emit_const_reg(A_ADD,S_L,8,r);
                 emit_const_reg(A_ADD,S_L,8,r);
              end;
              end;
            s64bit:
            s64bit:
              begin
              begin
-                r.enum:=R_ESP;
                 emit_ref(A_FILD,S_IQ,href);
                 emit_ref(A_FILD,S_IQ,href);
                 emit_const_reg(A_ADD,S_L,8,r);
                 emit_const_reg(A_ADD,S_L,8,r);
              end;
              end;
@@ -175,14 +174,16 @@ implementation
                 inc(href.offset,4);
                 inc(href.offset,4);
                 rg.getexplicitregisterint(exprasmlist,NR_EDI);
                 rg.getexplicitregisterint(exprasmlist,NR_EDI);
                 emit_ref_reg(A_MOV,S_L,href,r);
                 emit_ref_reg(A_MOV,S_L,href,r);
-                r.enum:=R_ESP;
+                r.enum:=R_INTREGISTER;
+                r.number:=NR_ESP;
                 reference_reset_base(href,r,4);
                 reference_reset_base(href,r,4);
                 emit_const_ref(A_AND,S_L,$7fffffff,href);
                 emit_const_ref(A_AND,S_L,$7fffffff,href);
                 r.enum:=R_INTREGISTER;
                 r.enum:=R_INTREGISTER;
                 r.number:=NR_EDI;
                 r.number:=NR_EDI;
                 emit_const_reg(A_TEST,S_L,longint($80000000),r);
                 emit_const_reg(A_TEST,S_L,longint($80000000),r);
                 rg.ungetregisterint(exprasmlist,r);
                 rg.ungetregisterint(exprasmlist,r);
-                r.enum:=R_ESP;
+                r.enum:=R_INTREGISTER;
+                r.number:=NR_ESP;
                 reference_reset_base(href,r,0);
                 reference_reset_base(href,r,0);
                 emit_ref(A_FILD,S_IQ,href);
                 emit_ref(A_FILD,S_IQ,href);
                 objectlibrary.getdatalabel(l1);
                 objectlibrary.getdatalabel(l1);
@@ -431,7 +432,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.56  2003-02-19 22:00:15  daniel
+  Revision 1.57  2003-03-13 19:52:23  jonas
+    * and more new register allocator fixes (in the i386 code generator this
+      time). At least now the ppc cross compiler can compile the linux
+      system unit again, but I haven't tested it.
+
+  Revision 1.56  2003/02/19 22:00:15  daniel
     * Code generator converted to new register notation
     * Code generator converted to new register notation
     - Horribily outdated todo.txt removed
     - Horribily outdated todo.txt removed
 
 

+ 7 - 2
compiler/i386/n386set.pas

@@ -277,7 +277,7 @@ implementation
                       { so in case of a LOC_CREGISTER first move the value }
                       { so in case of a LOC_CREGISTER first move the value }
                       { to edi (not done before because now we can do the  }
                       { to edi (not done before because now we can do the  }
                       { move and substract in one instruction with LEA)    }
                       { move and substract in one instruction with LEA)    }
-                      if (pleftreg.enum <> R_EDI) and
+                      if (pleftreg.number <> NR_EDI) and
                          (left.location.loc = LOC_CREGISTER) then
                          (left.location.loc = LOC_CREGISTER) then
                         begin
                         begin
                           r.enum:=R_INTREGISTER;
                           r.enum:=R_INTREGISTER;
@@ -720,7 +720,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.50  2003-02-26 23:06:13  daniel
+  Revision 1.51  2003-03-13 19:52:23  jonas
+    * and more new register allocator fixes (in the i386 code generator this
+      time). At least now the ppc cross compiler can compile the linux
+      system unit again, but I haven't tested it.
+
+  Revision 1.50  2003/02/26 23:06:13  daniel
     * Fixed an illegal use of makeregsize
     * Fixed an illegal use of makeregsize
 
 
   Revision 1.49  2003/02/19 22:39:56  daniel
   Revision 1.49  2003/02/19 22:39:56  daniel

+ 21 - 19
compiler/x86/cgx86.pas

@@ -302,7 +302,8 @@ unit cgx86;
       begin
       begin
         if reg.enum>lastreg then
         if reg.enum>lastreg then
           internalerror(200301081);
           internalerror(200301081);
-        result := regsize_2_cgsize[reg2opsize[reg.enum]];
+        if (reg.enum = R_INTREGISTER) then
+          result := regsize_2_cgsize[subreg2opsize[reg.number and $ff]];
       end;
       end;
 
 
 
 
@@ -610,7 +611,8 @@ unit cgx86;
          href : treference;
          href : treference;
          r : Tregister;
          r : Tregister;
        begin
        begin
-         r.enum:=R_ESP;
+         r.enum:=R_INTREGISTER;
+         r.number:=NR_ESP;
          list.concat(taicpu.op_const_reg(A_SUB,S_L,8,r));
          list.concat(taicpu.op_const_reg(A_SUB,S_L,8,r));
          reference_reset_base(href,r,0);
          reference_reset_base(href,r,0);
          list.concat(taicpu.op_reg_ref(A_MOVQ,S_NO,reg,href));
          list.concat(taicpu.op_reg_ref(A_MOVQ,S_NO,reg,href));
@@ -1002,9 +1004,9 @@ unit cgx86;
           internalerror(200201081);
           internalerror(200201081);
         if dst.enum>lastreg then
         if dst.enum>lastreg then
           internalerror(200201081);
           internalerror(200201081);
-        opsize := reg2opsize[src1.enum];
+        opsize := subreg2opsize[src1.number and $ff];
         if (opsize <> S_L) or
         if (opsize <> S_L) or
-           (reg2opsize[src2.enum] <> S_L) or
+           (subreg2opsize[src2.number and $ff] <> S_L) or
            not (size in [OS_32,OS_S32]) then
            not (size in [OS_32,OS_S32]) then
           begin
           begin
             inherited a_op_reg_reg_reg(list,op,size,src1,src2,dst);
             inherited a_op_reg_reg_reg(list,op,size,src1,src2,dst);
@@ -1044,12 +1046,7 @@ unit cgx86;
                 list.concat(taicpu.op_const_reg(A_CMP,subreg2opsize[reg.number and $ff],a,reg));
                 list.concat(taicpu.op_const_reg(A_CMP,subreg2opsize[reg.number and $ff],a,reg));
             end
             end
           else
           else
-            begin
-              if (a = 0) then
-                list.concat(taicpu.op_reg_reg(A_TEST,reg2opsize[reg.enum],reg,reg))
-              else
-                list.concat(taicpu.op_const_reg(A_CMP,reg2opsize[reg.enum],a,reg));
-            end;
+            internalerror(200303131);
           a_jmp_cond(list,cmp_op,l);
           a_jmp_cond(list,cmp_op,l);
         end;
         end;
 
 
@@ -1066,13 +1063,13 @@ unit cgx86;
         reg1,reg2 : tregister;l : tasmlabel);
         reg1,reg2 : tregister;l : tasmlabel);
 
 
         begin
         begin
-          if reg1.enum>lastreg then
+          if reg1.enum<>R_INTREGISTER then
             internalerror(200101081);
             internalerror(200101081);
-          if reg2.enum>lastreg then
+          if reg2.enum<>R_INTREGISTER then
             internalerror(200101081);
             internalerror(200101081);
-          if reg2opsize[reg1.enum] <> reg2opsize[reg2.enum] then
+          if subreg2opsize[reg1.number and $ff] <> subreg2opsize[reg2.number and $ff] then
             internalerror(200109226);
             internalerror(200109226);
-          list.concat(taicpu.op_reg_reg(A_CMP,reg2opsize[reg1.enum],reg1,reg2));
+          list.concat(taicpu.op_reg_reg(A_CMP,subreg2opsize[reg1.number and $ff],reg1,reg2));
           a_jmp_cond(list,cmp_op,l);
           a_jmp_cond(list,cmp_op,l);
         end;
         end;
 
 
@@ -1129,7 +1126,7 @@ unit cgx86;
           ai:=Taicpu.op_reg(A_SETcc,S_B,hreg);
           ai:=Taicpu.op_reg(A_SETcc,S_B,hreg);
           ai.setcondition(flags_to_cond(f));
           ai.setcondition(flags_to_cond(f));
           list.concat(ai);
           list.concat(ai);
-          if (reg.enum <> hreg.enum) then
+          if (reg.number <> hreg.number) then
             a_load_reg_reg(list,OS_8,size,hreg,reg);
             a_load_reg_reg(list,OS_8,size,hreg,reg);
        end;
        end;
 
 
@@ -1225,17 +1222,17 @@ unit cgx86;
                          swap:=true;
                          swap:=true;
                          { we need only to check 3 registers, because }
                          { we need only to check 3 registers, because }
                          { one is always not index or base          }
                          { one is always not index or base          }
-                         if (dest.base.enum<>R_EAX) and (dest.index.enum<>R_EAX) then
+                         if (dest.base.number<>NR_EAX) and (dest.index.number<>NR_EAX) then
                            begin
                            begin
                               reg8.number:=NR_AL;
                               reg8.number:=NR_AL;
                               reg32.number:=NR_EAX;
                               reg32.number:=NR_EAX;
                            end
                            end
-                         else if (dest.base.enum<>R_EBX) and (dest.index.enum<>R_EBX) then
+                         else if (dest.base.number<>NR_EBX) and (dest.index.number<>NR_EBX) then
                            begin
                            begin
                               reg8.number:=NR_BL;
                               reg8.number:=NR_BL;
                               reg32.number:=NR_EBX;
                               reg32.number:=NR_EBX;
                            end
                            end
-                         else if (dest.base.enum<>R_ECX) and (dest.index.enum<>R_ECX) then
+                         else if (dest.base.number<>NR_ECX) and (dest.index.number<>NR_ECX) then
                            begin
                            begin
                               reg8.number:=NR_CL;
                               reg8.number:=NR_CL;
                               reg32.number:=NR_ECX;
                               reg32.number:=NR_ECX;
@@ -1924,7 +1921,12 @@ unit cgx86;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.34  2003-02-27 16:40:32  daniel
+  Revision 1.35  2003-03-13 19:52:23  jonas
+    * and more new register allocator fixes (in the i386 code generator this
+      time). At least now the ppc cross compiler can compile the linux
+      system unit again, but I haven't tested it.
+
+  Revision 1.34  2003/02/27 16:40:32  daniel
     * Fixed ie 200301234 problem on Win32 target
     * Fixed ie 200301234 problem on Win32 target
 
 
   Revision 1.33  2003/02/26 21:15:43  daniel
   Revision 1.33  2003/02/26 21:15:43  daniel