Browse Source

* more regalloc fixes (still not complete)

Jonas Maebe 26 years ago
parent
commit
246a653a5d
7 changed files with 200 additions and 50 deletions
  1. 65 6
      compiler/cg386add.pas
  2. 5 2
      compiler/cg386cal.pas
  3. 44 13
      compiler/cg386cnv.pas
  4. 60 23
      compiler/cg386ld.pas
  5. 5 2
      compiler/cg386mat.pas
  6. 8 1
      compiler/cg386set.pas
  7. 13 3
      compiler/daopt386.pas

+ 65 - 6
compiler/cg386add.pas

@@ -299,10 +299,19 @@ implementation
                         secondpass(p^.right);
                         secondpass(p^.right);
 
 
                         { on the right we do not need the register anymore too }
                         { on the right we do not need the register anymore too }
+{$IfNDef regallocfix}
                         del_reference(p^.right^.location.reference);
                         del_reference(p^.right^.location.reference);
                         pushusedregisters(pushedregs,$ff);
                         pushusedregisters(pushedregs,$ff);
+{$Else regallocfix}
+                        pushusedregisters(pushedregs,$ff
+                          xor ($80 shr byte(p^.right^.location.reference.base))
+                          xor ($80 shr byte(p^.right^.location.reference.index)));
+{$EndIf regallocfix}
                         emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
                         emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
                         emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
                         emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
+{$IfDef regallocfix}
+                        del_reference(p^.right^.location.reference);
+{$EndIf regallocfix}
                         emitcall('FPC_SHORTSTR_CONCAT',true);
                         emitcall('FPC_SHORTSTR_CONCAT',true);
                         maybe_loadesi;
                         maybe_loadesi;
                         popusedregisters(pushedregs);
                         popusedregisters(pushedregs);
@@ -324,8 +333,6 @@ implementation
                              pushed:=maybe_push(p^.right^.registers32,p);
                              pushed:=maybe_push(p^.right^.registers32,p);
                              secondpass(p^.right);
                              secondpass(p^.right);
                              if pushed then restore(p);
                              if pushed then restore(p);
-                             del_reference(p^.right^.location.reference);
-                             del_reference(p^.left^.location.reference);
                              { only one node can be stringconstn }
                              { only one node can be stringconstn }
                              { else pass 1 would have evaluted   }
                              { else pass 1 would have evaluted   }
                              { this node                         }
                              { this node                         }
@@ -335,16 +342,18 @@ implementation
                              else
                              else
                                exprasmlist^.concat(new(pai386,op_const_ref(
                                exprasmlist^.concat(new(pai386,op_const_ref(
                                  A_CMP,S_B,0,newreference(p^.left^.location.reference))));
                                  A_CMP,S_B,0,newreference(p^.left^.location.reference))));
+                             del_reference(p^.right^.location.reference);
+                             del_reference(p^.left^.location.reference);
                           end
                           end
                         else
                         else
                           begin
                           begin
                              pushusedregisters(pushedregs,$ff);
                              pushusedregisters(pushedregs,$ff);
                              secondpass(p^.left);
                              secondpass(p^.left);
-                             del_reference(p^.left^.location.reference);
                              emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
                              emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
+                             del_reference(p^.left^.location.reference);
                              secondpass(p^.right);
                              secondpass(p^.right);
-                             del_reference(p^.right^.location.reference);
                              emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
                              emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
+                             del_reference(p^.right^.location.reference);
                              emitcall('FPC_SHORTSTR_COMPARE',true);
                              emitcall('FPC_SHORTSTR_COMPARE',true);
                              maybe_loadesi;
                              maybe_loadesi;
                              popusedregisters(pushedregs);
                              popusedregisters(pushedregs);
@@ -402,6 +411,14 @@ implementation
         set_location(p^.location,p^.left^.location);
         set_location(p^.location,p^.left^.location);
 
 
         { handle operations }
         { handle operations }
+
+{$IfDef regallocfix}
+        pushusedregisters(pushedregs,$ff
+          xor ($80 shr byte(p^.left^.location.reference.base))
+          xor ($80 shr byte(p^.left^.location.reference.index))
+          xor ($80 shr byte(p^.right^.location.reference.base))
+          xor ($80 shr byte(p^.right^.location.reference.index)));
+{$EndIf regallocfix}
         case p^.treetype of
         case p^.treetype of
           equaln,
           equaln,
         unequaln
         unequaln
@@ -410,21 +427,35 @@ implementation
 {$EndIf NoSetInclusion}
 {$EndIf NoSetInclusion}
                   : begin
                   : begin
                      cmpop:=true;
                      cmpop:=true;
+{$IfNDef regallocfix}
                      del_reference(p^.left^.location.reference);
                      del_reference(p^.left^.location.reference);
                      del_reference(p^.right^.location.reference);
                      del_reference(p^.right^.location.reference);
                      pushusedregisters(pushedregs,$ff);
                      pushusedregisters(pushedregs,$ff);
+{$EndIf regallocfix}
 {$IfNDef NoSetInclusion}
 {$IfNDef NoSetInclusion}
                      If (p^.treetype in [equaln, unequaln, lten]) Then
                      If (p^.treetype in [equaln, unequaln, lten]) Then
                        Begin
                        Begin
 {$EndIf NoSetInclusion}
 {$EndIf NoSetInclusion}
                          emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
                          emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
+{$IfDef regallocfix}
+                         del_reference(p^.right^.location.reference);
+{$EndIf regallocfix}
                          emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
                          emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
+{$IfDef regallocfix}
+                         del_reference(p^.left^.location.reference);
+{$EndIf regallocfix}
 {$IfNDef NoSetInclusion}
 {$IfNDef NoSetInclusion}
                        End
                        End
                      Else  {gten = lten, if the arguments are reversed}
                      Else  {gten = lten, if the arguments are reversed}
                        Begin
                        Begin
                          emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
                          emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
+{$IfDef regallocfix}
+                         del_reference(p^.left^.location.reference);
+{$EndIf regallocfix}
                          emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
                          emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
+{$IfDef regallocfix}
+                         del_reference(p^.right^.location.reference);
+{$EndIf regallocfix}
                        End;
                        End;
                      Case p^.treetype of
                      Case p^.treetype of
                        equaln, unequaln:
                        equaln, unequaln:
@@ -441,13 +472,19 @@ implementation
                    end;
                    end;
             addn : begin
             addn : begin
                    { add can be an other SET or Range or Element ! }
                    { add can be an other SET or Range or Element ! }
+{$IfNDef regallocfix}
                      del_reference(p^.left^.location.reference);
                      del_reference(p^.left^.location.reference);
                      del_reference(p^.right^.location.reference);
                      del_reference(p^.right^.location.reference);
                      pushusedregisters(pushedregs,$ff);
                      pushusedregisters(pushedregs,$ff);
+{$EndIf regallocfix}
                      href.symbol:=nil;
                      href.symbol:=nil;
                      gettempofsizereference(32,href);
                      gettempofsizereference(32,href);
                      if createset then
                      if createset then
                       begin
                       begin
+{$IfDef regallocfix}
+                        del_reference(p^.left^.location.reference);
+                        del_reference(p^.right^.location.reference);
+{$EndIf regallocfix}
                         pushsetelement(p^.right^.left);
                         pushsetelement(p^.right^.left);
                         emitpushreferenceaddr(exprasmlist,href);
                         emitpushreferenceaddr(exprasmlist,href);
                         emitcall('FPC_SET_CREATE_ELEMENT',true);
                         emitcall('FPC_SET_CREATE_ELEMENT',true);
@@ -457,7 +494,11 @@ implementation
                       { add a range or a single element? }
                       { add a range or a single element? }
                         if p^.right^.treetype=setelementn then
                         if p^.right^.treetype=setelementn then
                          begin
                          begin
+{$IfNDef regallocfix}
                            concatcopy(p^.left^.location.reference,href,32,false,false);
                            concatcopy(p^.left^.location.reference,href,32,false,false);
+{$Else regallocfix}
+                           concatcopy(p^.left^.location.reference,href,32,true,false);
+{$EndIf regallocfix}
                            if assigned(p^.right^.right) then
                            if assigned(p^.right^.right) then
                             begin
                             begin
                               pushsetelement(p^.right^.right);
                               pushsetelement(p^.right^.right);
@@ -477,7 +518,13 @@ implementation
                          { must be an other set }
                          { must be an other set }
                            emitpushreferenceaddr(exprasmlist,href);
                            emitpushreferenceaddr(exprasmlist,href);
                            emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
                            emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
+{$IfDef regallocfix}
+                        del_reference(p^.right^.location.reference);
+{$EndIf regallocfix}
                            emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
                            emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
+{$IfDef regallocfix}
+                        del_reference(p^.left^.location.reference);
+{$EndIf regallocfix}
                            emitcall('FPC_SET_ADD_SETS',true);
                            emitcall('FPC_SET_ADD_SETS',true);
                          end;
                          end;
                       end;
                       end;
@@ -491,14 +538,22 @@ implementation
             subn,
             subn,
          symdifn,
          symdifn,
             muln : begin
             muln : begin
+{$IfNDef regallocfix}
                      del_reference(p^.left^.location.reference);
                      del_reference(p^.left^.location.reference);
                      del_reference(p^.right^.location.reference);
                      del_reference(p^.right^.location.reference);
-                     href.symbol:=nil;
                      pushusedregisters(pushedregs,$ff);
                      pushusedregisters(pushedregs,$ff);
+{$EndIf regallocfix}
+                     href.symbol:=nil;
                      gettempofsizereference(32,href);
                      gettempofsizereference(32,href);
                      emitpushreferenceaddr(exprasmlist,href);
                      emitpushreferenceaddr(exprasmlist,href);
                      emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
                      emitpushreferenceaddr(exprasmlist,p^.right^.location.reference);
+{$IfDef regallocfix}
+                     del_reference(p^.right^.location.reference);
+{$EndIf regallocfix}
                      emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
                      emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
+{$IfDef regallocfix}
+                     del_reference(p^.left^.location.reference);
+{$EndIf regallocfix}
                      case p^.treetype of
                      case p^.treetype of
                       subn : emitcall('FPC_SET_SUB_SETS',true);
                       subn : emitcall('FPC_SET_SUB_SETS',true);
                    symdifn : emitcall('FPC_SET_SYMDIF_SETS',true);
                    symdifn : emitcall('FPC_SET_SYMDIF_SETS',true);
@@ -734,6 +789,7 @@ implementation
                                       begin
                                       begin
                                         ungetiftemp(p^.left^.location.reference);
                                         ungetiftemp(p^.left^.location.reference);
                                         del_reference(p^.left^.location.reference);
                                         del_reference(p^.left^.location.reference);
+{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
                                         hregister:=getregister32;
                                         hregister:=getregister32;
                                         exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
                                         exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
                                           newreference(p^.left^.location.reference),hregister)));
                                           newreference(p^.left^.location.reference),hregister)));
@@ -1914,7 +1970,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.49  1999-04-16 11:44:24  peter
+  Revision 1.50  1999-04-16 13:42:35  jonas
+    * more regalloc fixes (still not complete)
+
+  Revision 1.49  1999/04/16 11:44:24  peter
     * better support for flags result
     * better support for flags result
 
 
   Revision 1.48  1999/04/14 09:14:45  peter
   Revision 1.48  1999/04/14 09:14:45  peter

+ 5 - 2
compiler/cg386cal.pas

@@ -560,8 +560,8 @@ implementation
                                             LOC_CREGISTER,
                                             LOC_CREGISTER,
                                             LOC_REGISTER:
                                             LOC_REGISTER:
                                               begin
                                               begin
-                                                 ungetregister32(p^.methodpointer^.location.register);
                                                  emit_reg_reg(A_MOV,S_L,p^.methodpointer^.location.register,R_ESI);
                                                  emit_reg_reg(A_MOV,S_L,p^.methodpointer^.location.register,R_ESI);
+                                                 ungetregister32(p^.methodpointer^.location.register);
                                               end;
                                               end;
                                             else
                                             else
                                               begin
                                               begin
@@ -1202,7 +1202,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.73  1999-04-16 10:26:56  pierre
+  Revision 1.74  1999-04-16 13:42:23  jonas
+    * more regalloc fixes (still not complete)
+
+  Revision 1.73  1999/04/16 10:26:56  pierre
    * no add $0,%esp for cdecl functions without parameters
    * no add $0,%esp for cdecl functions without parameters
 
 
   Revision 1.72  1999/04/09 08:41:48  peter
   Revision 1.72  1999/04/09 08:41:48  peter

+ 44 - 13
compiler/cg386cnv.pas

@@ -134,15 +134,29 @@ implementation
            LOC_REFERENCE,LOC_MEM:
            LOC_REFERENCE,LOC_MEM:
              begin
              begin
                 ungetiftemp(source^.location.reference);
                 ungetiftemp(source^.location.reference);
+{$IfNDef regallocfix}
                 del_reference(source^.location.reference);
                 del_reference(source^.location.reference);
                 pushusedregisters(pushed,$ff);
                 pushusedregisters(pushed,$ff);
                 emit_push_mem(source^.location.reference);
                 emit_push_mem(source^.location.reference);
+{$Else regallocfix}
+                 pushusedregisters(pushed,$ff
+                   xor ($80 shr byte(source^.location.reference.base))
+                   xor ($80 shr byte(source^.location.reference.index)));
+                 emit_push_mem(source^.location.reference);
+                 del_reference(source^.location.reference);
+{$EndIf regallocfix}
              end;
              end;
            LOC_REGISTER,LOC_CREGISTER:
            LOC_REGISTER,LOC_CREGISTER:
              begin
              begin
+{$IfNDef regallocfix}
                 ungetregister32(source^.location.register);
                 ungetregister32(source^.location.register);
                 pushusedregisters(pushed,$ff);
                 pushusedregisters(pushed,$ff);
                 exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,source^.location.register)));
                 exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,source^.location.register)));
+{$Else regallocfix}
+                 pushusedregisters(pushed, $ff xor ($80 shr byte(source^.location.register)));
+                 exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,source^.location.register)));
+                 ungetregister32(source^.location.register);
+{$EndIf regallocfix}
              end;
              end;
          end;
          end;
          push_shortstring_length(dest);
          push_shortstring_length(dest);
@@ -1052,18 +1066,32 @@ implementation
                 ltemptoremove^.concat(new(ptemptodestroy,init(pto^.location.reference,pto^.resulttype)));
                 ltemptoremove^.concat(new(ptemptodestroy,init(pto^.location.reference,pto^.resulttype)));
                 exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_L,0,newreference(pto^.location.reference))));
                 exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_L,0,newreference(pto^.location.reference))));
                 case pfrom^.location.loc of
                 case pfrom^.location.loc of
-                   LOC_REGISTER,LOC_CREGISTER:
-                     begin
-                        ungetregister32(pfrom^.location.register);
-                        pushusedregisters(pushed,$ff);
-                        exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,pfrom^.location.register)));
-                     end;
-                   LOC_REFERENCE,LOC_MEM:
-                     begin
-                        del_reference(pfrom^.location.reference);
-                        pushusedregisters(pushed,$ff);
-                        emit_push_mem(pfrom^.location.reference);
-                     end;
+                  LOC_REFERENCE,LOC_MEM:
+                    begin
+{$IfNDef regallocfix}
+                      del_reference(pfrom^.location.reference);
+                      pushusedregisters(pushed,$ff);
+                      emit_push_mem(pfrom^.location.reference);
+{$Else regallocfix}
+                      pushusedregisters(pushed,$ff
+                        xor ($80 shr byte(pfrom^.location.reference.base))
+                        xor ($80 shr byte(pfrom^.location.reference.index)));
+                      emit_push_mem(pfrom^.location.reference);
+                      del_reference(pfrom^.location.reference);
+{$EndIf regallocfix}
+                    end;
+                  LOC_REGISTER,LOC_CREGISTER:
+                    begin
+{$IfNDef regallocfix}
+                      ungetregister32(pfrom^.location.register);
+                      pushusedregisters(pushed,$ff);
+                      exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,pfrom^.location.register)));
+{$Else regallocfix}
+                      pushusedregisters(pushed, $ff xor ($80 shr byte(pfrom^.location.register)));
+                      exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,pfrom^.location.register)));
+                      ungetregister32(pfrom^.location.register);
+{$EndIf regallocfix}
+                   end;
                 end;
                 end;
                 emitpushreferenceaddr(exprasmlist,pto^.location.reference);
                 emitpushreferenceaddr(exprasmlist,pto^.location.reference);
                 emitcall('FPC_PCHAR_TO_ANSISTR',true);
                 emitcall('FPC_PCHAR_TO_ANSISTR',true);
@@ -1260,7 +1288,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.63  1999-04-15 08:56:25  peter
+  Revision 1.64  1999-04-16 13:42:25  jonas
+    * more regalloc fixes (still not complete)
+
+  Revision 1.63  1999/04/15 08:56:25  peter
     * fixed bool-bool conversion
     * fixed bool-bool conversion
 
 
   Revision 1.62  1999/04/13 18:51:47  florian
   Revision 1.62  1999/04/13 18:51:47  florian

+ 60 - 23
compiler/cg386ld.pas

@@ -282,6 +282,9 @@ implementation
                               { load vmt pointer }
                               { load vmt pointer }
                               exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
                               exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
                                 hp,R_EDI)));
                                 hp,R_EDI)));
+{$IfDef regallocfix}
+                              del_reference(hp^);
+{$EndIf regallocfix}
                               { load method address }
                               { load method address }
                               new(hp);
                               new(hp);
                               reset_reference(hp^);
                               reset_reference(hp^);
@@ -292,7 +295,6 @@ implementation
                               { ... and store it }
                               { ... and store it }
                               exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,
                               exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,
                                 R_EDI,newreference(p^.location.reference))));
                                 R_EDI,newreference(p^.location.reference))));
-
                            end
                            end
                          else
                          else
                            begin
                            begin
@@ -300,7 +302,6 @@ implementation
 
 
                               exprasmlist^.concat(new(pai386,op_sym_ofs_ref(A_MOV,S_L,s,0,
                               exprasmlist^.concat(new(pai386,op_sym_ofs_ref(A_MOV,S_L,s,0,
                                 newreference(p^.location.reference))));
                                 newreference(p^.location.reference))));
-
                               maybe_concat_external(p^.symtable,p^.symtableentry^.mangledname);
                               maybe_concat_external(p^.symtable,p^.symtableentry^.mangledname);
                            end;
                            end;
                       end
                       end
@@ -439,8 +440,13 @@ implementation
                     begin
                     begin
                       if (p^.right^.treetype=stringconstn) and
                       if (p^.right^.treetype=stringconstn) and
                          (p^.right^.length=0) then
                          (p^.right^.length=0) then
-                        exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_B,
-                          0,newreference(p^.left^.location.reference))))
+                        begin
+                          exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_B,
+                            0,newreference(p^.left^.location.reference))));
+{$IfDef regallocfix}
+                          del_reference(p^.left^.location.reference);
+{$EndIf regallocfix}
+                        end
                       else
                       else
                         loadansi2short(p^.right,p^.left);
                         loadansi2short(p^.right,p^.left);
                     end
                     end
@@ -472,16 +478,27 @@ implementation
                                  4 : opsize:=S_L;
                                  4 : opsize:=S_L;
                               end;
                               end;
                               if loc=LOC_CREGISTER then
                               if loc=LOC_CREGISTER then
-                                exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
-                                  newreference(p^.right^.location.reference),
-                                  p^.left^.location.register)))
+                                begin
+                                  exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
+                                    newreference(p^.right^.location.reference),
+                                    p^.left^.location.register)));
+{$IfDef regallocfix}
+                                  del_reference(p^.right^.location.reference);
+{$EndIf regallocfix}
+                                end
                               else
                               else
-                                exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,opsize,
-                                  p^.right^.location.reference.offset,
-                                  newreference(p^.left^.location.reference))));
-                              {exprasmlist^.concat(new(pai386,op_const_loc(A_MOV,opsize,
-                                  p^.right^.location.reference.offset,
-                                  p^.left^.location)));}
+                                begin
+                                  exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,opsize,
+                                    p^.right^.location.reference.offset,
+                                    newreference(p^.left^.location.reference))));
+{$IfDef regallocfix}
+                                  del_reference(p^.left^.location.reference);
+{$EndIf regallocfix}
+                                {exprasmlist^.concat(new(pai386,op_const_loc(A_MOV,opsize,
+                                    p^.right^.location.reference.offset,
+                                    p^.left^.location)));}
+                                end;
+
                            end
                            end
                          else
                          else
                            begin
                            begin
@@ -520,9 +537,16 @@ implementation
                                      concat_external('FPC_DECREF',EXT_NEAR);
                                      concat_external('FPC_DECREF',EXT_NEAR);
 
 
                                 end;
                                 end;
+
+{$ifdef regallocfix}
+                              concatcopy(p^.right^.location.reference,
+                                p^.left^.location.reference,p^.left^.resulttype^.size,true,false);
+                              ungetiftemp(p^.right^.location.reference);
+{$Else regallocfix}
                               concatcopy(p^.right^.location.reference,
                               concatcopy(p^.right^.location.reference,
                                 p^.left^.location.reference,p^.left^.resulttype^.size,false,false);
                                 p^.left^.location.reference,p^.left^.resulttype^.size,false,false);
                               ungetiftemp(p^.right^.location.reference);
                               ungetiftemp(p^.right^.location.reference);
+{$endif regallocfix}
                            end;
                            end;
                       end;
                       end;
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
@@ -547,22 +571,24 @@ implementation
                               end;
                               end;
                               { simplified with op_reg_loc         }
                               { simplified with op_reg_loc         }
                               if loc=LOC_CREGISTER then
                               if loc=LOC_CREGISTER then
-                                exprasmlist^.concat(new(pai386,op_reg_reg(A_MOV,opsize,
-                                  p^.right^.location.register,
-                                  p^.left^.location.register)))
-                              else
+                                begin
+                                  exprasmlist^.concat(new(pai386,op_reg_reg(A_MOV,opsize,
+                                    p^.right^.location.register,
+                                    p^.left^.location.register)));
 {$IfDef regallocfix}
 {$IfDef regallocfix}
-                                Begin
+                                 ungetregister(p^.right^.location.register);
 {$EndIf regallocfix}
 {$EndIf regallocfix}
+                                end
+                              else
+                                Begin
                                   exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,opsize,
                                   exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,opsize,
                                     p^.right^.location.register,
                                     p^.right^.location.register,
                                     newreference(p^.left^.location.reference))));
                                     newreference(p^.left^.location.reference))));
 {$IfDef regallocfix}
 {$IfDef regallocfix}
                                   ungetregister(p^.right^.location.register);
                                   ungetregister(p^.right^.location.register);
                                   del_reference(p^.left^.location.reference);
                                   del_reference(p^.left^.location.reference);
-                                end;
 {$EndIf regallocfix}
 {$EndIf regallocfix}
-
+                                end;
                               if is_64bitint(p^.right^.resulttype) then
                               if is_64bitint(p^.right^.resulttype) then
                                 begin
                                 begin
                                    { simplified with op_reg_loc         }
                                    { simplified with op_reg_loc         }
@@ -608,8 +634,13 @@ implementation
                                   p^.left^.location.register,
                                   p^.left^.location.register,
                                   p^.left^.location.register)))
                                   p^.left^.location.register)))
                               else
                               else
-                                exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_B,
-                                  0,newreference(p^.left^.location.reference))));
+                                begin
+                                  exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_B,
+                                    0,newreference(p^.left^.location.reference))));
+{$IfDef regallocfix}
+                                  del_reference(p^.left^.location.reference);
+{$EndIf regallocfix}
+                                 end;
                               emitlab(hlabel);
                               emitlab(hlabel);
                            end;
                            end;
             LOC_FLAGS    : begin
             LOC_FLAGS    : begin
@@ -626,6 +657,9 @@ implementation
                                 exprasmlist^.concat(new(pai386,op_ref(flag_2_set[p^.right^.location.resflags],S_B,
                                 exprasmlist^.concat(new(pai386,op_ref(flag_2_set[p^.right^.location.resflags],S_B,
                                   newreference(p^.left^.location.reference))));
                                   newreference(p^.left^.location.reference))));
 {$endif}
 {$endif}
+{$IfDef regallocfix}
+                              del_reference(p^.left^.location.reference);
+{$EndIf regallocfix}
                            end;
                            end;
          end;
          end;
          removetemps(exprasmlist,temptoremove);
          removetemps(exprasmlist,temptoremove);
@@ -807,7 +841,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.49  1999-04-13 18:57:48  florian
+  Revision 1.50  1999-04-16 13:42:26  jonas
+    * more regalloc fixes (still not complete)
+
+  Revision 1.49  1999/04/13 18:57:48  florian
     * classes which contain ansistring get unnecessary calls
     * classes which contain ansistring get unnecessary calls
       to addref/decref when they are assigned, fixed
       to addref/decref when they are assigned, fixed
 
 

+ 5 - 2
compiler/cg386mat.pas

@@ -113,8 +113,8 @@ implementation
                 end
                 end
               else
               else
                 begin
                 begin
-                   ungetregister32(p^.right^.location.register);
                    emit_reg_reg(A_MOV,S_L,p^.right^.location.register,R_EDI);
                    emit_reg_reg(A_MOV,S_L,p^.right^.location.register,R_EDI);
+                   ungetregister32(p^.right^.location.register);
                 end;
                 end;
               popedx:=false;
               popedx:=false;
               popeax:=false;
               popeax:=false;
@@ -768,7 +768,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.20  1999-02-22 02:15:13  peter
+  Revision 1.21  1999-04-16 13:42:27  jonas
+    * more regalloc fixes (still not complete)
+
+  Revision 1.20  1999/02/22 02:15:13  peter
     * updates for ag386bin
     * updates for ag386bin
 
 
   Revision 1.19  1999/02/04 10:49:40  florian
   Revision 1.19  1999/02/04 10:49:40  florian

+ 8 - 1
compiler/cg386set.pas

@@ -794,6 +794,10 @@ implementation
            else
            else
            { it's always not bad }
            { it's always not bad }
            genlinearlist(p^.nodes);
            genlinearlist(p^.nodes);
+{$IfDef regallocfix}
+           ungetregister(hregister);
+{$EndIf regallocfix}
+
 
 
          { now generate the instructions }
          { now generate the instructions }
            hp:=p^.right;
            hp:=p^.right;
@@ -820,7 +824,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.26  1999-04-09 08:36:36  peter
+  Revision 1.27  1999-04-16 13:42:30  jonas
+    * more regalloc fixes (still not complete)
+
+  Revision 1.26  1999/04/09 08:36:36  peter
     * fix also for -Og
     * fix also for -Og
 
 
   Revision 1.25  1999/04/08 20:59:37  florian
   Revision 1.25  1999/04/08 20:59:37  florian

+ 13 - 3
compiler/daopt386.pas

@@ -785,10 +785,15 @@ Procedure BuildLabelTableAndFixRegAlloc(AsmL: PAasmOutput; Var LabelTable: PLabe
             Var LabelDif: Longint; BlockStart, BlockEnd: Pai);
             Var LabelDif: Longint; BlockStart, BlockEnd: Pai);
 {Builds a table with the locations of the labels in the paasmoutput.
 {Builds a table with the locations of the labels in the paasmoutput.
  Also fixes some RegDeallocs like "# %eax released; push (%eax)"}
  Also fixes some RegDeallocs like "# %eax released; push (%eax)"}
-Var p, hp1, hp2: Pai;
+Var p: Pai;
+{$IfNDef regallocfix}
+    hp1, hp2: Pai;
     UsedRegs: TRegSet;
     UsedRegs: TRegSet;
+{$EndIf regallocfix}
 Begin
 Begin
+{$IfNDef regallocfix}
   UsedRegs := [];
   UsedRegs := [];
+{$EndIf regallocfix}
   If (LabelDif <> 0) Then
   If (LabelDif <> 0) Then
     Begin
     Begin
 {$IfDef TP}
 {$IfDef TP}
@@ -805,6 +810,7 @@ Begin
                   ait_Label:
                   ait_Label:
                     If Pai_Label(p)^.l^.is_used Then
                     If Pai_Label(p)^.l^.is_used Then
                       LabelTable^[Pai_Label(p)^.l^.nb-LowLabel].PaiObj := p;
                       LabelTable^[Pai_Label(p)^.l^.nb-LowLabel].PaiObj := p;
+{$IfNDef regallocfix}
                   ait_regAlloc:
                   ait_regAlloc:
                      begin
                      begin
                        if PairegAlloc(p)^.Allocation then
                        if PairegAlloc(p)^.Allocation then
@@ -842,7 +848,8 @@ Begin
                               p := hp1;
                               p := hp1;
                             End;
                             End;
                         End;
                         End;
-                     end;
+                    End;
+{$EndIf regallocfix}
                 End;
                 End;
                 P := Pai(p^.Next);
                 P := Pai(p^.Next);
                 While Assigned(p) And
                 While Assigned(p) And
@@ -2233,7 +2240,10 @@ End.
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.40  1999-04-16 11:49:41  peter
+ Revision 1.41  1999-04-16 13:42:33  jonas
+   * more regalloc fixes (still not complete)
+
+ Revision 1.40  1999/04/16 11:49:41  peter
    + tempalloc
    + tempalloc
    + -at to show temp alloc info in .s file
    + -at to show temp alloc info in .s file