Browse Source

+ (de)allocation info for EDI to fix reported bug on mailinglist.
Also some (de)allocation info for ESI added. Between -dallocEDI
because at this time of the night bugs could easily slip in ;)

Jonas Maebe 25 years ago
parent
commit
86ff0db0b5

+ 79 - 4
compiler/cg386add.pas

@@ -1053,12 +1053,26 @@ implementation
                            popedx:=true;
                            popedx:=true;
                           end;
                           end;
                          { p^.left^.location can be R_EAX !!! }
                          { p^.left^.location can be R_EAX !!! }
+{$ifdef AllocEDI}
+                         exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                          emitloadord2reg(p^.left^.location,u32bitdef,R_EDI,true);
                          emitloadord2reg(p^.left^.location,u32bitdef,R_EDI,true);
                          emitloadord2reg(p^.right^.location,u32bitdef,R_EAX,true);
                          emitloadord2reg(p^.right^.location,u32bitdef,R_EAX,true);
+{$ifdef AllocEDI}
+                         if R_EDX in unused then
+                           exprasmlist^.concat(new(pairegalloc,alloc(R_EDX)));
+{$endif AllocEDI}
                          emit_reg(A_MUL,S_L,R_EDI);
                          emit_reg(A_MUL,S_L,R_EDI);
+{$ifdef AllocEDI}
+                         exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                          emit_reg_reg(A_MOV,S_L,R_EAX,p^.location.register);
                          emit_reg_reg(A_MOV,S_L,R_EAX,p^.location.register);
                          if popedx then
                          if popedx then
                           emit_reg(A_POP,S_L,R_EDX);
                           emit_reg(A_POP,S_L,R_EDX);
+{$ifdef AllocEDI}
+                         if R_EDX in unused then
+                           exprasmlist^.concat(new(pairegalloc,dealloc(R_EDX)));
+{$endif AllocEDI}
                          if popeax then
                          if popeax then
                           emit_reg(A_POP,S_L,R_EAX);
                           emit_reg(A_POP,S_L,R_EAX);
 {$IfNDef NoShlMul}
 {$IfNDef NoShlMul}
@@ -1152,20 +1166,31 @@ implementation
                                begin
                                begin
                                   if extra_not then
                                   if extra_not then
                                     emit_reg(A_NOT,opsize,p^.location.register);
                                     emit_reg(A_NOT,opsize,p^.location.register);
-
+{$ifdef AllocEDI}
+                                  exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                   emit_reg_reg(A_MOV,opsize,p^.right^.location.register,R_EDI);
                                   emit_reg_reg(A_MOV,opsize,p^.right^.location.register,R_EDI);
                                   emit_reg_reg(op,opsize,p^.location.register,R_EDI);
                                   emit_reg_reg(op,opsize,p^.location.register,R_EDI);
                                   emit_reg_reg(A_MOV,opsize,R_EDI,p^.location.register);
                                   emit_reg_reg(A_MOV,opsize,R_EDI,p^.location.register);
+{$ifdef AllocEDI}
+                                  exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                end
                                end
                              else
                              else
                                begin
                                begin
                                   if extra_not then
                                   if extra_not then
                                     emit_reg(A_NOT,opsize,p^.location.register);
                                     emit_reg(A_NOT,opsize,p^.location.register);
 
 
+{$ifdef AllocEDI}
+                                  exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                   emit_ref_reg(A_MOV,opsize,
                                   emit_ref_reg(A_MOV,opsize,
                                     newreference(p^.right^.location.reference),R_EDI);
                                     newreference(p^.right^.location.reference),R_EDI);
                                   emit_reg_reg(op,opsize,p^.location.register,R_EDI);
                                   emit_reg_reg(op,opsize,p^.location.register,R_EDI);
                                   emit_reg_reg(A_MOV,opsize,R_EDI,p^.location.register);
                                   emit_reg_reg(A_MOV,opsize,R_EDI,p^.location.register);
+{$ifdef AllocEDI}
+                                  exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                   ungetiftemp(p^.right^.location.reference);
                                   ungetiftemp(p^.right^.location.reference);
                                   del_reference(p^.right^.location.reference);
                                   del_reference(p^.right^.location.reference);
                                end;
                                end;
@@ -1209,10 +1234,16 @@ implementation
                                     begin
                                     begin
                                        if extra_not then
                                        if extra_not then
                                          begin
                                          begin
+{$ifdef AllocEDI}
+                                            exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                             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);
                                             emit_reg(A_NOT,S_L,R_EDI);
                                             emit_reg(A_NOT,S_L,R_EDI);
                                             emit_reg_reg(A_AND,S_L,R_EDI,
                                             emit_reg_reg(A_AND,S_L,R_EDI,
                                               p^.location.register);
                                               p^.location.register);
+{$ifdef AllocEDI}
+                                            exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                          end
                                          end
                                        else
                                        else
                                          begin
                                          begin
@@ -1224,11 +1255,17 @@ implementation
                                     begin
                                     begin
                                        if extra_not then
                                        if extra_not then
                                          begin
                                          begin
+{$ifdef AllocEDI}
+                                            exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                             emit_ref_reg(A_MOV,S_L,newreference(
                                             emit_ref_reg(A_MOV,S_L,newreference(
                                               p^.right^.location.reference),R_EDI);
                                               p^.right^.location.reference),R_EDI);
                                             emit_reg(A_NOT,S_L,R_EDI);
                                             emit_reg(A_NOT,S_L,R_EDI);
                                             emit_reg_reg(A_AND,S_L,R_EDI,
                                             emit_reg_reg(A_AND,S_L,R_EDI,
                                               p^.location.register);
                                               p^.location.register);
+{$ifdef AllocEDI}
+                                            exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                          end
                                          end
                                        else
                                        else
                                          begin
                                          begin
@@ -1622,20 +1659,37 @@ implementation
                                begin
                                begin
                                   if p^.right^.location.loc=LOC_CREGISTER then
                                   if p^.right^.location.loc=LOC_CREGISTER then
                                     begin
                                     begin
+{$ifdef AllocEDI}
+                                       exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                        emit_reg_reg(A_MOV,opsize,p^.right^.location.register,R_EDI);
                                        emit_reg_reg(A_MOV,opsize,p^.right^.location.register,R_EDI);
                                        emit_reg_reg(op,opsize,p^.location.register,R_EDI);
                                        emit_reg_reg(op,opsize,p^.location.register,R_EDI);
                                        emit_reg_reg(A_MOV,opsize,R_EDI,p^.location.register);
                                        emit_reg_reg(A_MOV,opsize,R_EDI,p^.location.register);
+{$ifdef AllocEDI}
+                                            exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+                                            exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                        emit_reg_reg(A_MOV,opsize,p^.right^.location.registerhigh,R_EDI);
                                        emit_reg_reg(A_MOV,opsize,p^.right^.location.registerhigh,R_EDI);
                                        { the carry flag is still ok }
                                        { the carry flag is still ok }
                                        emit_reg_reg(op2,opsize,p^.location.registerhigh,R_EDI);
                                        emit_reg_reg(op2,opsize,p^.location.registerhigh,R_EDI);
                                        emit_reg_reg(A_MOV,opsize,R_EDI,p^.location.registerhigh);
                                        emit_reg_reg(A_MOV,opsize,R_EDI,p^.location.registerhigh);
+{$ifdef AllocEDI}
+                                       exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                     end
                                     end
                                   else
                                   else
                                     begin
                                     begin
+{$ifdef AllocEDI}
+                                       exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                        emit_ref_reg(A_MOV,opsize,
                                        emit_ref_reg(A_MOV,opsize,
                                          newreference(p^.right^.location.reference),R_EDI);
                                          newreference(p^.right^.location.reference),R_EDI);
                                        emit_reg_reg(op,opsize,p^.location.registerlow,R_EDI);
                                        emit_reg_reg(op,opsize,p^.location.registerlow,R_EDI);
                                        emit_reg_reg(A_MOV,opsize,R_EDI,p^.location.registerlow);
                                        emit_reg_reg(A_MOV,opsize,R_EDI,p^.location.registerlow);
+{$ifdef AllocEDI}
+                                       exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+                                       exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                        hr:=newreference(p^.right^.location.reference);
                                        hr:=newreference(p^.right^.location.reference);
                                        inc(hr^.offset,4);
                                        inc(hr^.offset,4);
                                        emit_ref_reg(A_MOV,opsize,
                                        emit_ref_reg(A_MOV,opsize,
@@ -1644,6 +1698,9 @@ implementation
                                        emit_reg_reg(op2,opsize,p^.location.registerhigh,R_EDI);
                                        emit_reg_reg(op2,opsize,p^.location.registerhigh,R_EDI);
                                        emit_reg_reg(A_MOV,opsize,R_EDI,
                                        emit_reg_reg(A_MOV,opsize,R_EDI,
                                          p^.location.registerhigh);
                                          p^.location.registerhigh);
+{$ifdef AllocEDI}
+                                       exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                        ungetiftemp(p^.right^.location.reference);
                                        ungetiftemp(p^.right^.location.reference);
                                        del_reference(p^.right^.location.reference);
                                        del_reference(p^.right^.location.reference);
                                     end;
                                     end;
@@ -1892,11 +1949,21 @@ implementation
                     if cmpop then
                     if cmpop then
                      begin
                      begin
                        if not(R_EAX in unused) then
                        if not(R_EAX in unused) then
-                         emit_reg_reg(A_MOV,S_L,R_EAX,R_EDI);
+                         begin
+{$ifdef AllocEDI}
+                           exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
+                           emit_reg_reg(A_MOV,S_L,R_EAX,R_EDI);
+                         end;
                        emit_reg(A_FNSTSW,S_NO,R_AX);
                        emit_reg(A_FNSTSW,S_NO,R_AX);
                        emit_none(A_SAHF,S_NO);
                        emit_none(A_SAHF,S_NO);
                        if not(R_EAX in unused) then
                        if not(R_EAX in unused) then
-                         emit_reg_reg(A_MOV,S_L,R_EDI,R_EAX);
+                         begin
+                           emit_reg_reg(A_MOV,S_L,R_EDI,R_EAX);
+{$ifdef AllocEDI}
+                           exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
+                         end;
                        if p^.swaped then
                        if p^.swaped then
                         begin
                         begin
                           case p^.treetype of
                           case p^.treetype of
@@ -2076,6 +2143,9 @@ implementation
                              if p^.right^.location.loc=LOC_CMMXREGISTER then
                              if p^.right^.location.loc=LOC_CMMXREGISTER then
                                begin
                                begin
                                   emit_reg_reg(A_MOVQ,S_NO,p^.right^.location.register,R_MM7);
                                   emit_reg_reg(A_MOVQ,S_NO,p^.right^.location.register,R_MM7);
+{$ifdef AllocEDI}
+                          { where does the result of this (R_EDI) get used?? }
+{$endif AllocEDI}
                                   emit_reg_reg(op,S_NO,p^.location.register,R_EDI);
                                   emit_reg_reg(op,S_NO,p^.location.register,R_EDI);
                                   emit_reg_reg(A_MOVQ,S_NO,R_MM7,p^.location.register);
                                   emit_reg_reg(A_MOVQ,S_NO,R_MM7,p^.location.register);
                                end
                                end
@@ -2136,7 +2206,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.84  2000-01-07 01:14:20  peter
+  Revision 1.85  2000-01-09 01:44:18  jonas
+    + (de)allocation info for EDI to fix reported bug on mailinglist.
+      Also some (de)allocation info for ESI added. Between -dallocEDI
+      because at this time of the night bugs could easily slip in ;)
+
+  Revision 1.84  2000/01/07 01:14:20  peter
     * updated copyright to 2000
     * updated copyright to 2000
 
 
   Revision 1.83  1999/12/11 18:53:31  jonas
   Revision 1.83  1999/12/11 18:53:31  jonas

+ 69 - 5
compiler/cg386cal.pas

@@ -120,10 +120,16 @@ implementation
                      begin
                      begin
                        if inlined then
                        if inlined then
                          begin
                          begin
+{$ifdef AllocEDI}
+                           exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                            emit_ref_reg(A_LEA,S_L,
                            emit_ref_reg(A_LEA,S_L,
                              newreference(p^.left^.location.reference),R_EDI);
                              newreference(p^.left^.location.reference),R_EDI);
                            r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                            r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                            emit_reg_ref(A_MOV,S_L,R_EDI,r);
                            emit_reg_ref(A_MOV,S_L,R_EDI,r);
+{$ifdef AllocEDI}
+                           exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                          end
                          end
                       else
                       else
                         emitpushreferenceaddr(p^.left^.location.reference);
                         emitpushreferenceaddr(p^.left^.location.reference);
@@ -140,10 +146,16 @@ implementation
               inc(pushedparasize,4);
               inc(pushedparasize,4);
               if inlined then
               if inlined then
                 begin
                 begin
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                    emit_ref_reg(A_LEA,S_L,
                    emit_ref_reg(A_LEA,S_L,
                      newreference(p^.left^.location.reference),R_EDI);
                      newreference(p^.left^.location.reference),R_EDI);
                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                    emit_reg_ref(A_MOV,S_L,R_EDI,r);
                    emit_reg_ref(A_MOV,S_L,R_EDI,r);
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                 end
                 end
               else
               else
                 emitpushreferenceaddr(p^.left^.location.reference);
                 emitpushreferenceaddr(p^.left^.location.reference);
@@ -165,11 +177,17 @@ implementation
                    inc(pushedparasize,4);
                    inc(pushedparasize,4);
                    if inlined then
                    if inlined then
                      begin
                      begin
+{$ifdef AllocEDI}
+                           exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                         emit_ref_reg(A_LEA,S_L,
                         emit_ref_reg(A_LEA,S_L,
                           newreference(p^.left^.location.reference),R_EDI);
                           newreference(p^.left^.location.reference),R_EDI);
                         r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                         r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                         emit_reg_ref(A_MOV,S_L,
                         emit_reg_ref(A_MOV,S_L,
                           R_EDI,r);
                           R_EDI,r);
+{$ifdef AllocEDI}
+                        exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                      end
                      end
                    else
                    else
                      emitpushreferenceaddr(p^.left^.location.reference);
                      emitpushreferenceaddr(p^.left^.location.reference);
@@ -405,11 +423,16 @@ implementation
 {$endif not OLD_C_STACK}
 {$endif not OLD_C_STACK}
               if inlined then
               if inlined then
                 begin
                 begin
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                    emit_ref_reg(A_LEA,S_L,
                    emit_ref_reg(A_LEA,S_L,
                      newreference(funcretref),R_EDI);
                      newreference(funcretref),R_EDI);
                    r:=new_reference(procinfo^.framepointer,inlinecode^.retoffset);
                    r:=new_reference(procinfo^.framepointer,inlinecode^.retoffset);
-                   emit_reg_ref(A_MOV,S_L,
-                     R_EDI,r);
+                   emit_reg_ref(A_MOV,S_L,R_EDI,r);
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                 end
                 end
               else
               else
                 emitpushreferenceaddr(funcretref);
                 emitpushreferenceaddr(funcretref);
@@ -755,6 +778,9 @@ implementation
                             r^.base:=R_ESI;
                             r^.base:=R_ESI;
                             { this is one point where we need vmt_offset (PM) }
                             { this is one point where we need vmt_offset (PM) }
                             r^.offset:= pprocdef(p^.procdefinition)^._class^.vmt_offset;
                             r^.offset:= pprocdef(p^.procdefinition)^._class^.vmt_offset;
+{$ifdef AllocEDI}
+                           exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                             emit_ref_reg(A_MOV,S_L,r,R_EDI);
                             emit_ref_reg(A_MOV,S_L,r,R_EDI);
                             new(r);
                             new(r);
                             reset_reference(r^);
                             reset_reference(r^);
@@ -794,6 +820,9 @@ implementation
                      end;
                      end;
 {$endif TESTOBJEXT}
 {$endif TESTOBJEXT}
                    emit_ref(A_CALL,S_NO,r);
                    emit_ref(A_CALL,S_NO,r);
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                 end
                 end
               else if not inlined then
               else if not inlined then
                 emitcall(pprocdef(p^.procdefinition)^.mangledname)
                 emitcall(pprocdef(p^.procdefinition)^.mangledname)
@@ -829,6 +858,9 @@ implementation
                       (p^.right^.location.reference.index=R_ESI) then
                       (p^.right^.location.reference.index=R_ESI) then
                      begin
                      begin
                         del_reference(p^.right^.location.reference);
                         del_reference(p^.right^.location.reference);
+{$ifdef AllocEDI}
+                        exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                         emit_ref_reg(A_MOV,S_L,
                         emit_ref_reg(A_MOV,S_L,
                           newreference(p^.right^.location.reference),R_EDI);
                           newreference(p^.right^.location.reference),R_EDI);
                         hregister:=R_EDI;
                         hregister:=R_EDI;
@@ -849,7 +881,14 @@ implementation
                    if hregister=R_NO then
                    if hregister=R_NO then
                      emit_ref(A_CALL,S_NO,newreference(p^.right^.location.reference))
                      emit_ref(A_CALL,S_NO,newreference(p^.right^.location.reference))
                    else
                    else
-                     emit_reg(A_CALL,S_NO,hregister);
+                     begin
+{$ifdef AllocEDI}
+                       if hregister = R_EDI then
+                         exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)))
+                       else ungetregister32(hregister);
+{$endif AllocEDI}
+                       emit_reg(A_CALL,S_NO,hregister);
+                     end;
 
 
                    del_reference(p^.right^.location.reference);
                    del_reference(p^.right^.location.reference);
                 end
                 end
@@ -878,7 +917,15 @@ implementation
                 pop_size:=0;
                 pop_size:=0;
                 { better than an add on all processors }
                 { better than an add on all processors }
                 if pushedparasize=4 then
                 if pushedparasize=4 then
-                  emit_reg(A_POP,S_L,R_EDI)
+                  begin
+{$ifdef AllocEDI}
+                    exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
+                    emit_reg(A_POP,S_L,R_EDI);
+{$ifdef AllocEDI}
+                exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
+                  end
                 { the pentium has two pipes and pop reg is pairable }
                 { the pentium has two pipes and pop reg is pairable }
                 { but the registers must be different!        }
                 { but the registers must be different!        }
                 else if (pushedparasize=8) and
                 else if (pushedparasize=8) and
@@ -886,8 +933,20 @@ implementation
                   (aktoptprocessor=ClassP5) and
                   (aktoptprocessor=ClassP5) and
                   (procinfo^._class=nil) then
                   (procinfo^._class=nil) then
                     begin
                     begin
+{$ifdef AllocEDI}
+                       exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                        emit_reg(A_POP,S_L,R_EDI);
                        emit_reg(A_POP,S_L,R_EDI);
+{$ifdef AllocEDI}
+                       exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
+{$ifdef AllocEDI}
+                       exprasmlist^.concat(new(pairegalloc,alloc(R_ESI)));
+{$endif AllocEDI}
                        emit_reg(A_POP,S_L,R_ESI);
                        emit_reg(A_POP,S_L,R_ESI);
+{$ifdef AllocEDI}
+                       exprasmlist^.concat(new(pairegalloc,alloc(R_ESI)));
+{$endif AllocEDI}
                     end
                     end
                 else if pushedparasize<>0 then
                 else if pushedparasize<>0 then
                   emit_const_reg(A_ADD,S_L,pushedparasize,R_ESP);
                   emit_const_reg(A_ADD,S_L,pushedparasize,R_ESP);
@@ -1230,7 +1289,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.114  2000-01-07 01:14:20  peter
+  Revision 1.115  2000-01-09 01:44:19  jonas
+    + (de)allocation info for EDI to fix reported bug on mailinglist.
+      Also some (de)allocation info for ESI added. Between -dallocEDI
+      because at this time of the night bugs could easily slip in ;)
+
+  Revision 1.114  2000/01/07 01:14:20  peter
     * updated copyright to 2000
     * updated copyright to 2000
 
 
   Revision 1.113  1999/12/22 01:01:46  peter
   Revision 1.113  1999/12/22 01:01:46  peter

+ 54 - 2
compiler/cg386cnv.pas

@@ -98,6 +98,9 @@ implementation
                  else
                  else
                    begin
                    begin
                       { not so elegant (goes better with extra register }
                       { not so elegant (goes better with extra register }
+{$ifdef AllocEDI}
+                      exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                       if (p^.right^.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
                       if (p^.right^.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
                         begin
                         begin
                            emit_reg_reg(A_MOV,S_L,makereg32(p^.right^.location.register),R_EDI);
                            emit_reg_reg(A_MOV,S_L,makereg32(p^.right^.location.register),R_EDI);
@@ -111,6 +114,9 @@ implementation
                       emit_const_reg(A_SHL,S_L,8,R_EDI);
                       emit_const_reg(A_SHL,S_L,8,R_EDI);
                       emit_const_reg(A_OR,S_L,1,R_EDI);
                       emit_const_reg(A_OR,S_L,1,R_EDI);
                       emit_reg_ref(A_MOV,S_W,R_DI,newreference(p^.left^.location.reference));
                       emit_reg_ref(A_MOV,S_W,R_DI,newreference(p^.left^.location.reference));
+{$ifdef AllocEDI}
+                      exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                    end;
                    end;
               end;
               end;
          else
          else
@@ -695,6 +701,10 @@ implementation
          if (pfrom^.location.loc=LOC_REGISTER) or
          if (pfrom^.location.loc=LOC_REGISTER) or
             (pfrom^.location.loc=LOC_CREGISTER) then
             (pfrom^.location.loc=LOC_CREGISTER) then
            begin
            begin
+{$ifdef AllocEDI}
+              if not (porddef(pfrom^.resulttype)^.typ in [u32bit,s32bit,u64bit,s64bit]) then
+                exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
               case porddef(pfrom^.resulttype)^.typ of
               case porddef(pfrom^.resulttype)^.typ of
                  s8bit : emit_reg_reg(A_MOVSX,S_BL,pfrom^.location.register,R_EDI);
                  s8bit : emit_reg_reg(A_MOVSX,S_BL,pfrom^.location.register,R_EDI);
                  u8bit : emit_reg_reg(A_MOVZX,S_BL,pfrom^.location.register,R_EDI);
                  u8bit : emit_reg_reg(A_MOVZX,S_BL,pfrom^.location.register,R_EDI);
@@ -713,6 +723,9 @@ implementation
          else
          else
            begin
            begin
               r:=newreference(pfrom^.location.reference);
               r:=newreference(pfrom^.location.reference);
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
               case porddef(pfrom^.resulttype)^.typ of
               case porddef(pfrom^.resulttype)^.typ of
                  s8bit:
                  s8bit:
                    emit_ref_reg(A_MOVSX,S_BL,r,R_EDI);
                    emit_ref_reg(A_MOVSX,S_BL,r,R_EDI);
@@ -738,6 +751,10 @@ implementation
            end;
            end;
          { for 64 bit integers, the high dword is already pushed }
          { for 64 bit integers, the high dword is already pushed }
          emit_reg(A_PUSH,S_L,hregister);
          emit_reg(A_PUSH,S_L,hregister);
+{$ifdef AllocEDI}
+         if hregister = R_EDI then
+           exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
          r:=new_reference(R_ESP,0);
          r:=new_reference(R_ESP,0);
          case porddef(pfrom^.resulttype)^.typ of
          case porddef(pfrom^.resulttype)^.typ of
            u32bit:
            u32bit:
@@ -757,10 +774,16 @@ implementation
                 { if it is 1 then we add $80000000 000000000 }
                 { if it is 1 then we add $80000000 000000000 }
                 { as double                                  }
                 { as double                                  }
                 inc(r^.offset,4);
                 inc(r^.offset,4);
+{$ifdef AllocEDI}
+                exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                 emit_ref_reg(A_MOV,S_L,r,R_EDI);
                 emit_ref_reg(A_MOV,S_L,r,R_EDI);
                 r:=new_reference(R_ESP,4);
                 r:=new_reference(R_ESP,4);
                 emit_const_ref(A_AND,S_L,$7fffffff,r);
                 emit_const_ref(A_AND,S_L,$7fffffff,r);
-                emit_const_reg(A_AND,S_L,$80000000,R_EDI);
+                emit_const_reg(A_TEST,S_L,$80000000,R_EDI);
+{$ifdef AllocEDI}
+                exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                 r:=new_reference(R_ESP,0);
                 r:=new_reference(R_ESP,0);
                 emit_ref(A_FILD,S_IQ,r);
                 emit_ref(A_FILD,S_IQ,r);
                 getdatalabel(l1);
                 getdatalabel(l1);
@@ -779,7 +802,13 @@ implementation
            else
            else
              begin
              begin
                 emit_ref(A_FILD,S_IL,r);
                 emit_ref(A_FILD,S_IL,r);
+{$ifdef AllocEDI}
+                exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                 emit_reg(A_POP,S_L,R_EDI);
                 emit_reg(A_POP,S_L,R_EDI);
+{$ifdef AllocEDI}
+                exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
              end;
              end;
          end;
          end;
          inc(fpuvaroffset);
          inc(fpuvaroffset);
@@ -818,7 +847,13 @@ implementation
          rreg:=getregister32;
          rreg:=getregister32;
          emit_reg(A_POP,S_L,rreg);
          emit_reg(A_POP,S_L,rreg);
          { better than an add on all processors }
          { better than an add on all processors }
+{$ifdef AllocEDI}
+         exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
          emit_reg(A_POP,S_L,R_EDI);
          emit_reg(A_POP,S_L,R_EDI);
+{$ifdef AllocEDI}
+         exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
 
 
          clear_location(pto^.location);
          clear_location(pto^.location);
          pto^.location.loc:=LOC_REGISTER;
          pto^.location.loc:=LOC_REGISTER;
@@ -1355,19 +1390,31 @@ implementation
                            r^.base:=p^.location.register
                            r^.base:=p^.location.register
                           else
                           else
                             begin
                             begin
+{$ifdef AllocEDI}
+                               exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                emit_mov_loc_reg(p^.location,R_EDI);
                                emit_mov_loc_reg(p^.location,R_EDI);
                                r^.base:=R_EDI;
                                r^.base:=R_EDI;
                             end;
                             end;
                           { NIL must be accepted !! }
                           { NIL must be accepted !! }
                           emit_reg_reg(A_OR,S_L,r^.base,r^.base);
                           emit_reg_reg(A_OR,S_L,r^.base,r^.base);
+{$ifdef AllocEDI}
+                          exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                           getlabel(nillabel);
                           getlabel(nillabel);
                           emitjmp(C_E,nillabel);
                           emitjmp(C_E,nillabel);
                           { this is one point where we need vmt_offset (PM) }
                           { this is one point where we need vmt_offset (PM) }
                           r^.offset:= pobjectdef(ppointerdef(p^.resulttype)^.definition)^.vmt_offset;
                           r^.offset:= pobjectdef(ppointerdef(p^.resulttype)^.definition)^.vmt_offset;
+{$ifdef AllocEDI}
+                          exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                           emit_ref_reg(A_MOV,S_L,r,R_EDI);
                           emit_ref_reg(A_MOV,S_L,r,R_EDI);
                           emit_sym(A_PUSH,S_L,
                           emit_sym(A_PUSH,S_L,
                             newasmsymbol(pobjectdef(ppointerdef(p^.resulttype)^.definition)^.vmt_mangledname));
                             newasmsymbol(pobjectdef(ppointerdef(p^.resulttype)^.definition)^.vmt_mangledname));
                           emit_reg(A_PUSH,S_L,R_EDI);
                           emit_reg(A_PUSH,S_L,R_EDI);
+{$ifdef AllocEDI}
+                          exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                           emitcall('FPC_CHECK_OBJECT_EXT');
                           emitcall('FPC_CHECK_OBJECT_EXT');
                           emitlab(nillabel);
                           emitlab(nillabel);
                        end;
                        end;
@@ -1486,7 +1533,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.98  2000-01-07 01:14:20  peter
+  Revision 1.99  2000-01-09 01:44:19  jonas
+    + (de)allocation info for EDI to fix reported bug on mailinglist.
+      Also some (de)allocation info for ESI added. Between -dallocEDI
+      because at this time of the night bugs could easily slip in ;)
+
+  Revision 1.98  2000/01/07 01:14:20  peter
     * updated copyright to 2000
     * updated copyright to 2000
 
 
   Revision 1.97  1999/12/22 01:01:46  peter
   Revision 1.97  1999/12/22 01:01:46  peter

+ 38 - 2
compiler/cg386inl.pas

@@ -191,6 +191,9 @@ implementation
             reset_reference(r^);
             reset_reference(r^);
             r^.symbol:=newasmsymbol(
             r^.symbol:=newasmsymbol(
             'U_'+upper(target_info.system_unit)+io[doread]);
             'U_'+upper(target_info.system_unit)+io[doread]);
+{$ifdef AllocEDI}
+            exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
             emit_ref_reg(A_LEA,S_L,r,R_EDI)
             emit_ref_reg(A_LEA,S_L,r,R_EDI)
           end;
           end;
 
 
@@ -233,6 +236,9 @@ implementation
                 loadstream;
                 loadstream;
                 { save @aktfile in temporary variable }
                 { save @aktfile in temporary variable }
                 emit_reg_ref(A_MOV,S_L,R_EDI,newreference(aktfile));
                 emit_reg_ref(A_MOV,S_L,R_EDI,newreference(aktfile));
+{$ifdef AllocEDI}
+                exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
              end
              end
            else
            else
              begin
              begin
@@ -258,6 +264,9 @@ implementation
                           CGMessage(cg_e_illegal_expression);
                           CGMessage(cg_e_illegal_expression);
                           exit;
                           exit;
                        end;
                        end;
+{$ifdef AllocEDI}
+                     exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
 
 
                      emit_ref_reg(A_LEA,S_L,newreference(node^.left^.location.reference),R_EDI);
                      emit_ref_reg(A_LEA,S_L,newreference(node^.left^.location.reference),R_EDI);
 
 
@@ -272,6 +281,9 @@ implementation
 
 
                 { save @aktfile in temporary variable }
                 { save @aktfile in temporary variable }
                 emit_reg_ref(A_MOV,S_L,R_EDI,newreference(aktfile));
                 emit_reg_ref(A_MOV,S_L,R_EDI,newreference(aktfile));
+{$ifdef AllocEDI}
+                exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                 if doread then
                 if doread then
                 { parameter by READ gives call by reference }
                 { parameter by READ gives call by reference }
                   dummycoll.paratyp:=vs_var
                   dummycoll.paratyp:=vs_var
@@ -298,7 +310,7 @@ implementation
                      if hp^.is_colon_para then
                      if hp^.is_colon_para then
                        CGMessage(parser_e_illegal_colon_qualifier);
                        CGMessage(parser_e_illegal_colon_qualifier);
                      { when float is written then we need bestreal to be pushed
                      { when float is written then we need bestreal to be pushed
-                       convert here else we loose the old flaot type }
+                       convert here else we loose the old float type }
                      if (not doread) and
                      if (not doread) and
                         (ft<>ft_typed) and
                         (ft<>ft_typed) and
                         (hp^.left^.resulttype^.deftype=floatdef) then
                         (hp^.left^.resulttype^.deftype=floatdef) then
@@ -786,12 +798,21 @@ implementation
               {load the address of the code parameter}
               {load the address of the code parameter}
                secondpass(code_para^.left);
                secondpass(code_para^.left);
               {move the code to its destination}
               {move the code to its destination}
+{$ifdef AllocEDI}
+               exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                emit_ref_reg(A_MOV,S_L,NewReference(hr),R_EDI);
                emit_ref_reg(A_MOV,S_L,NewReference(hr),R_EDI);
                emit_mov_reg_loc(R_DI,code_para^.left^.location);
                emit_mov_reg_loc(R_DI,code_para^.left^.location);
+{$ifdef AllocEDI}
+               exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                Disposetree(code_para);
                Disposetree(code_para);
              End;
              End;
 
 
           {restore the address of the result}
           {restore the address of the result}
+{$ifdef AllocEDI}
+           exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
            emit_reg(A_POP,S_L,R_EDI);
            emit_reg(A_POP,S_L,R_EDI);
 
 
           {set up hr2 to a refernce with EDI as base register}
           {set up hr2 to a refernce with EDI as base register}
@@ -824,6 +845,9 @@ implementation
                    end;
                    end;
                End;
                End;
            End;
            End;
+{$ifdef AllocEDI}
+           exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
            If (cs_check_range in aktlocalswitches) and
            If (cs_check_range in aktlocalswitches) and
               (dest_para^.left^.resulttype^.deftype = orddef) and
               (dest_para^.left^.resulttype^.deftype = orddef) and
               (not(is_64bitint(dest_para^.left^.resulttype))) and
               (not(is_64bitint(dest_para^.left^.resulttype))) and
@@ -1356,6 +1380,9 @@ implementation
                              hregister:=p^.left^.right^.left^.location.register
                              hregister:=p^.left^.right^.left^.location.register
                            else
                            else
                              begin
                              begin
+{$ifdef AllocEDI}
+                                exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                 hregister:=R_EDI;
                                 hregister:=R_EDI;
                                 opsize:=def2def_opsize(p^.left^.right^.left^.resulttype,u32bitdef);
                                 opsize:=def2def_opsize(p^.left^.right^.left^.resulttype,u32bitdef);
                                 if opsize in [S_B,S_W,S_L] then
                                 if opsize in [S_B,S_W,S_L] then
@@ -1371,6 +1398,10 @@ implementation
                           else
                           else
                             emit_reg_reg(asmop,S_L,hregister,
                             emit_reg_reg(asmop,S_L,hregister,
                               p^.left^.left^.location.register);
                               p^.left^.left^.location.register);
+{$ifdef AllocEDI}
+                        if hregister = R_EDI then
+                          exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                         end
                         end
                       else
                       else
                         begin
                         begin
@@ -1479,7 +1510,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.87  2000-01-07 01:14:20  peter
+  Revision 1.88  2000-01-09 01:44:19  jonas
+    + (de)allocation info for EDI to fix reported bug on mailinglist.
+      Also some (de)allocation info for ESI added. Between -dallocEDI
+      because at this time of the night bugs could easily slip in ;)
+
+  Revision 1.87  2000/01/07 01:14:20  peter
     * updated copyright to 2000
     * updated copyright to 2000
 
 
   Revision 1.86  1999/12/22 01:01:46  peter
   Revision 1.86  1999/12/22 01:01:46  peter

+ 15 - 1
compiler/cg386ld.pas

@@ -300,6 +300,9 @@ implementation
                             LOC_MEM,
                             LOC_MEM,
                             LOC_REFERENCE:
                             LOC_REFERENCE:
                               begin
                               begin
+{$ifdef AllocEDI}
+                                 exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                  hregister:=R_EDI;
                                  hregister:=R_EDI;
                                  if pobjectdef(p^.left^.resulttype)^.is_class then
                                  if pobjectdef(p^.left^.resulttype)^.is_class then
                                    emit_ref_reg(A_MOV,S_L,
                                    emit_ref_reg(A_MOV,S_L,
@@ -343,9 +346,15 @@ implementation
                               { ... and store it }
                               { ... and store it }
                               emit_reg_ref(A_MOV,S_L,
                               emit_reg_ref(A_MOV,S_L,
                                 R_EDI,newreference(p^.location.reference));
                                 R_EDI,newreference(p^.location.reference));
+{$ifdef AllocEDI}
+                              exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                            end
                            end
                          else
                          else
                            begin
                            begin
+{$ifdef AllocEDI}
+                              exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                               s:=newasmsymbol(pprocsym(p^.symtableentry)^.definition^.mangledname);
                               s:=newasmsymbol(pprocsym(p^.symtableentry)^.definition^.mangledname);
                               emit_sym_ofs_ref(A_MOV,S_L,s,0,
                               emit_sym_ofs_ref(A_MOV,S_L,s,0,
                                 newreference(p^.location.reference));
                                 newreference(p^.location.reference));
@@ -996,7 +1005,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.94  2000-01-07 01:14:21  peter
+  Revision 1.95  2000-01-09 01:44:20  jonas
+    + (de)allocation info for EDI to fix reported bug on mailinglist.
+      Also some (de)allocation info for ESI added. Between -dallocEDI
+      because at this time of the night bugs could easily slip in ;)
+
+  Revision 1.94  2000/01/07 01:14:21  peter
     * updated copyright to 2000
     * updated copyright to 2000
 
 
   Revision 1.93  1999/12/30 15:04:31  peter
   Revision 1.93  1999/12/30 15:04:31  peter

+ 70 - 10
compiler/cg386mat.pas

@@ -52,7 +52,7 @@ implementation
 
 
     procedure secondmoddiv(var p : ptree);
     procedure secondmoddiv(var p : ptree);
       var
       var
-         hreg1 : tregister;
+         hreg1, hreg2 : tregister;
          shrdiv, andmod, pushed,popeax,popedx : boolean;
          shrdiv, andmod, pushed,popeax,popedx : boolean;
 
 
          power : longint;
          power : longint;
@@ -137,15 +137,58 @@ implementation
                      "Cardinal($ffffffff) div 16" overflows! (JM)}
                      "Cardinal($ffffffff) div 16" overflows! (JM)}
                     If is_signed(p^.left^.resulttype) Then
                     If is_signed(p^.left^.resulttype) Then
                       Begin
                       Begin
-                        emit_reg_reg(A_OR,S_L,hreg1,hreg1);
-                        getlabel(hl);
-                        emitjmp(C_NS,hl);
-                        if power=1 then
-                          emit_reg(A_INC,S_L,hreg1)
+{$ifdef newOptimizations}
+                        If (aktOptProcessor <> class386) and
+                           not(CS_LittleSize in aktglobalswitches) then
+                        { use a sequence without jumps, saw this in
+                          comp.compilers (JM) }
+                          begin
+                          { no jumps, but more operations }
+                            if (hreg1 = R_EAX) and
+                               (R_EDX in unused) then
+                              begin
+                                hreg2 := getexplicitregister32(R_EDX);
+                                emit_none(A_CDQ,S_NO);
+                              end
+                            else
+                              begin
+{$ifdef AllocEDI}
+                                exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
+                                hreg2 := R_EDI;
+                                emit_reg_reg(A_MOV,S_L,hreg1,R_EDI);
+                              { if the left value is signed, R_EDI := $ffffffff,
+                                otherwise 0 }
+                                emit_const_reg(A_SAR,S_L,31,R_EDI);
+                            { if signed, R_EDI := right value-1, otherwise 0 }
+                              end;
+                            emit_const_reg(A_AND,S_L,p^.right^.value-1,hreg2);
+                          { add to the left value }
+                            emit_reg_reg(A_ADD,S_L,hreg2,hreg1);
+                          { release EDX if we used it }
+                            if (hreg2 = R_EDX) then
+                              ungetregister32(hreg2)
+{$ifdef AllocEDI}
+                            else
+                              exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)))
+{$endif AllocEDI}
+                            ;
+                          { do the shift }
+                            emit_const_reg(A_SAR,S_L,power,hreg1);
+                          end
                         else
                         else
-                          emit_const_reg(A_ADD,S_L,p^.right^.value-1,hreg1);
-                        emitlab(hl);
-                        emit_const_reg(A_SAR,S_L,power,hreg1);
+{$endif newOptimizations}
+                          begin
+                          { a jump, but less operations }
+                            emit_reg_reg(A_TEST,S_L,hreg1,hreg1);
+                            getlabel(hl);
+                            emitjmp(C_NS,hl);
+                            if power=1 then
+                              emit_reg(A_INC,S_L,hreg1)
+                            else
+                              emit_const_reg(A_ADD,S_L,p^.right^.value-1,hreg1);
+                            emitlab(hl);
+                          end
                       End
                       End
                     Else
                     Else
                       emit_const_reg(A_SHR,S_L,power,hreg1);
                       emit_const_reg(A_SHR,S_L,power,hreg1);
@@ -164,6 +207,9 @@ implementation
                       { EDI is always free, it's }
                       { EDI is always free, it's }
                       { only used for temporary  }
                       { only used for temporary  }
                       { purposes              }
                       { purposes              }
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                    if (p^.right^.location.loc<>LOC_REGISTER) and
                    if (p^.right^.location.loc<>LOC_REGISTER) and
                       (p^.right^.location.loc<>LOC_CREGISTER) then
                       (p^.right^.location.loc<>LOC_CREGISTER) then
                      begin
                      begin
@@ -215,6 +261,9 @@ implementation
                      emit_reg(A_DIV,S_L,R_EDI)
                      emit_reg(A_DIV,S_L,R_EDI)
                    else
                    else
                      emit_reg(A_IDIV,S_L,R_EDI);
                      emit_reg(A_IDIV,S_L,R_EDI);
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                    if p^.treetype=divn then
                    if p^.treetype=divn then
                      begin
                      begin
                         { if result register is busy then copy }
                         { if result register is busy then copy }
@@ -840,6 +889,9 @@ implementation
              secondpass(p^.left);
              secondpass(p^.left);
              p^.location.loc:=LOC_MMXREGISTER;
              p^.location.loc:=LOC_MMXREGISTER;
              { prepare EDI }
              { prepare EDI }
+{$ifdef AllocEDI}
+             exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
              emit_const_reg(A_MOV,S_L,$ffffffff,R_EDI);
              emit_const_reg(A_MOV,S_L,$ffffffff,R_EDI);
              { load operand }
              { load operand }
              case p^.left^.location.loc of
              case p^.left^.location.loc of
@@ -860,6 +912,9 @@ implementation
              end;
              end;
              { load mask }
              { load mask }
              emit_reg_reg(A_MOVD,S_NO,R_EDI,R_MM7);
              emit_reg_reg(A_MOVD,S_NO,R_EDI,R_MM7);
+{$ifdef AllocEDI}
+             exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
              { lower 32 bit }
              { lower 32 bit }
              emit_reg_reg(A_PXOR,S_D,R_MM7,p^.location.register);
              emit_reg_reg(A_PXOR,S_D,R_MM7,p^.location.register);
              { shift mask }
              { shift mask }
@@ -940,7 +995,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.38  2000-01-07 01:14:21  peter
+  Revision 1.39  2000-01-09 01:44:20  jonas
+    + (de)allocation info for EDI to fix reported bug on mailinglist.
+      Also some (de)allocation info for ESI added. Between -dallocEDI
+      because at this time of the night bugs could easily slip in ;)
+
+  Revision 1.38  2000/01/07 01:14:21  peter
     * updated copyright to 2000
     * updated copyright to 2000
 
 
   Revision 1.37  2000/01/07 00:12:10  peter
   Revision 1.37  2000/01/07 00:12:10  peter

+ 12 - 1
compiler/cg386mem.pas

@@ -827,6 +827,9 @@ implementation
                  end
                  end
                else
                else
                 { call can happend with a property }
                 { call can happend with a property }
+{$ifdef AllocEDI}
+                    exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                 if { (p^.left^.treetype=calln) and  Don't think that
                 if { (p^.left^.treetype=calln) and  Don't think that
                       this is necessary (FK) }
                       this is necessary (FK) }
                    (p^.left^.resulttype^.deftype=objectdef) and
                    (p^.left^.resulttype^.deftype=objectdef) and
@@ -863,6 +866,9 @@ implementation
                   { move to temp reference }
                   { move to temp reference }
                   emit_reg_ref(A_MOV,S_L,
                   emit_reg_ref(A_MOV,S_L,
                     R_EDI,newreference(p^.withreference^));
                     R_EDI,newreference(p^.withreference^));
+{$ifdef AllocEDI}
+                  exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                   del_reference(p^.left^.location.reference);
                   del_reference(p^.left^.location.reference);
                 end;
                 end;
 
 
@@ -885,7 +891,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.66  2000-01-07 01:14:21  peter
+  Revision 1.67  2000-01-09 01:44:20  jonas
+    + (de)allocation info for EDI to fix reported bug on mailinglist.
+      Also some (de)allocation info for ESI added. Between -dallocEDI
+      because at this time of the night bugs could easily slip in ;)
+
+  Revision 1.66  2000/01/07 01:14:21  peter
     * updated copyright to 2000
     * updated copyright to 2000
 
 
   Revision 1.65  2000/01/04 15:15:50  florian
   Revision 1.65  2000/01/04 15:15:50  florian

+ 13 - 1
compiler/cg386set.pas

@@ -371,6 +371,9 @@ implementation
                       { the set element isn't never samller than a byte  }
                       { the set element isn't never samller than a byte  }
                       { and because it's a small set we need only 5 bits }
                       { and because it's a small set we need only 5 bits }
                       { but 8 bits are easier to load               }
                       { but 8 bits are easier to load               }
+{$ifdef AllocEDI}
+                      exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                       emit_ref_reg(A_MOVZX,S_BL,
                       emit_ref_reg(A_MOVZX,S_BL,
                         newreference(p^.left^.location.reference),R_EDI);
                         newreference(p^.left^.location.reference),R_EDI);
                       hr:=R_EDI;
                       hr:=R_EDI;
@@ -400,6 +403,10 @@ implementation
                           newreference(p^.right^.location.reference));
                           newreference(p^.right^.location.reference));
                     end;
                     end;
                   end;
                   end;
+{$ifdef AllocEDI}
+                  if hr = R_EDI then
+                    exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                   ungetregister32(hr);
                   ungetregister32(hr);
                   p^.location.loc:=LOC_FLAGS;
                   p^.location.loc:=LOC_FLAGS;
                   p^.location.resflags:=F_C;
                   p^.location.resflags:=F_C;
@@ -898,7 +905,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.45  2000-01-07 01:14:21  peter
+  Revision 1.46  2000-01-09 01:44:21  jonas
+    + (de)allocation info for EDI to fix reported bug on mailinglist.
+      Also some (de)allocation info for ESI added. Between -dallocEDI
+      because at this time of the night bugs could easily slip in ;)
+
+  Revision 1.45  2000/01/07 01:14:21  peter
     * updated copyright to 2000
     * updated copyright to 2000
 
 
   Revision 1.44  1999/12/01 22:45:54  peter
   Revision 1.44  1999/12/01 22:45:54  peter

+ 232 - 7
compiler/cgai386.pas

@@ -448,6 +448,10 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                                  S_W : hreg:=R_DI;
                                  S_W : hreg:=R_DI;
                                  S_L : hreg:=R_EDI;
                                  S_L : hreg:=R_EDI;
                                end;
                                end;
+{$ifdef AllocEDI}
+                               if hreg in [R_DI,R_EDI] then
+                                 exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                emit_ref_reg(A_MOV,siz,
                                emit_ref_reg(A_MOV,siz,
                                  newreference(t.reference),hreg);
                                  newreference(t.reference),hreg);
                                del_reference(t.reference);
                                del_reference(t.reference);
@@ -460,6 +464,10 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                                     else
                                     else
                                       ungetregister(hreg);
                                       ungetregister(hreg);
                                  end;
                                  end;
+{$ifdef AllocEDI}
+                               if hreg in [R_DI,R_EDI] then
+                                 exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                { we can release the registers }
                                { we can release the registers }
                                { but only AFTER the MOV! Important for the optimizer!
                                { but only AFTER the MOV! Important for the optimizer!
                                  (JM)}
                                  (JM)}
@@ -698,10 +706,16 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                              internalerror(331)
                              internalerror(331)
                            else
                            else
                              begin
                              begin
+{$ifdef AllocEDI}
+                               exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                emit_ref_reg(A_LEA,S_L,
                                emit_ref_reg(A_LEA,S_L,
                                  newreference(t.reference),R_EDI);
                                  newreference(t.reference),R_EDI);
                                exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,
                                exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,
                                  R_EDI,newreference(ref))));
                                  R_EDI,newreference(ref))));
+{$ifdef AllocEDI}
+                               exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                              end;
                              end;
                             { release the registers }
                             { release the registers }
                             del_reference(t.reference);
                             del_reference(t.reference);
@@ -723,9 +737,15 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                              internalerror(331)
                              internalerror(331)
                            else
                            else
                              begin
                              begin
+{$ifdef AllocEDI}
+                               exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                emit_ref_reg(A_LEA,S_L,
                                emit_ref_reg(A_LEA,S_L,
                                  newreference(t.reference),R_EDI);
                                  newreference(t.reference),R_EDI);
                                exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,S_L,R_EDI)));
                                exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,S_L,R_EDI)));
+{$ifdef AllocEDI}
+                               exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                              end;
                              end;
                            if freetemp then
                            if freetemp then
                             ungetiftemp(t.reference);
                             ungetiftemp(t.reference);
@@ -968,6 +988,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                       ) then
                       ) then
                   begin
                   begin
                      del_reference(p^.location.reference);
                      del_reference(p^.location.reference);
+{$ifdef AllocEDI}
+                    exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                      emit_ref_reg(A_LEA,S_L,newreference(p^.location.reference),
                      emit_ref_reg(A_LEA,S_L,newreference(p^.location.reference),
                        R_EDI);
                        R_EDI);
 {$ifdef TEMPS_NOT_PUSH}
 {$ifdef TEMPS_NOT_PUSH}
@@ -977,6 +1000,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
 {$else TEMPS_NOT_PUSH}
 {$else TEMPS_NOT_PUSH}
                      exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,S_L,R_EDI)));
                      exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,S_L,R_EDI)));
 {$endif TEMPS_NOT_PUSH}
 {$endif TEMPS_NOT_PUSH}
+{$ifdef AllocEDI}
+                     exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                      pushed:=true;
                      pushed:=true;
                   end
                   end
               else pushed:=false;
               else pushed:=false;
@@ -1021,10 +1047,16 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                       ) then
                       ) then
                   begin
                   begin
                      del_reference(p^.location.reference);
                      del_reference(p^.location.reference);
+{$ifdef AllocEDI}
+                     exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                      emit_ref_reg(A_LEA,S_L,newreference(p^.location.reference),
                      emit_ref_reg(A_LEA,S_L,newreference(p^.location.reference),
                        R_EDI);
                        R_EDI);
                      gettempofsizereference(href,4);
                      gettempofsizereference(href,4);
                      exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,href)));
                      exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,href)));
+{$ifdef AllocEDI}
+                     exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                      p^.temp_offset:=href.offset;
                      p^.temp_offset:=href.offset;
                      pushed:=true;
                      pushed:=true;
                   end
                   end
@@ -1043,8 +1075,14 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
             not(cs_littlesize in aktglobalswitches)
             not(cs_littlesize in aktglobalswitches)
            Then
            Then
              begin
              begin
+{$ifdef AllocEDI}
+               exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                emit_reg_reg(A_XOR,S_L,R_EDI,R_EDI);
                emit_reg_reg(A_XOR,S_L,R_EDI,R_EDI);
                exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,S_L,R_EDI)));
                exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,S_L,R_EDI)));
+{$ifdef AllocEDI}
+               exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
              end
              end
            else
            else
              exprasmlist^.concat(new(paicpu,op_const(A_PUSH,S_L,l)));
              exprasmlist^.concat(new(paicpu,op_const(A_PUSH,S_L,l)));
@@ -1061,8 +1099,14 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                 not(cs_littlesize in aktglobalswitches)
                 not(cs_littlesize in aktglobalswitches)
                then
                then
                  begin
                  begin
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                    emit_ref_reg(A_MOV,S_L,newreference(ref),R_EDI);
                    emit_ref_reg(A_MOV,S_L,newreference(ref),R_EDI);
                    exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,S_L,R_EDI)));
                    exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,S_L,R_EDI)));
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                  end
                  end
                else exprasmlist^.concat(new(paicpu,op_ref(A_PUSH,S_L,newreference(ref))));
                else exprasmlist^.concat(new(paicpu,op_ref(A_PUSH,S_L,newreference(ref))));
            end;
            end;
@@ -1097,8 +1141,14 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                 exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,S_L,ref.base)))
                 exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,S_L,ref.base)))
               else
               else
                 begin
                 begin
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                    emit_ref_reg(A_LEA,S_L,newreference(ref),R_EDI);
                    emit_ref_reg(A_LEA,S_L,newreference(ref),R_EDI);
                    exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,S_L,R_EDI)));
                    exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,S_L,R_EDI)));
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                 end;
                 end;
            end;
            end;
         end;
         end;
@@ -1403,15 +1453,25 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                                inc(pushedparasize,8);
                                inc(pushedparasize,8);
                                if inlined then
                                if inlined then
                                  begin
                                  begin
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                    emit_ref_reg(A_MOV,S_L,
                                    emit_ref_reg(A_MOV,S_L,
                                      newreference(tempreference),R_EDI);
                                      newreference(tempreference),R_EDI);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+                                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                    inc(tempreference.offset,4);
                                    inc(tempreference.offset,4);
                                    emit_ref_reg(A_MOV,S_L,
                                    emit_ref_reg(A_MOV,S_L,
                                      newreference(tempreference),R_EDI);
                                      newreference(tempreference),R_EDI);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize+4);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize+4);
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                  end
                                  end
                                else
                                else
                                  begin
                                  begin
@@ -1425,10 +1485,16 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                                inc(pushedparasize,4);
                                inc(pushedparasize,4);
                                if inlined then
                                if inlined then
                                  begin
                                  begin
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                    emit_ref_reg(A_MOV,S_L,
                                    emit_ref_reg(A_MOV,S_L,
                                      newreference(tempreference),R_EDI);
                                      newreference(tempreference),R_EDI);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                  end
                                  end
                                else
                                else
                                  emit_push_mem(tempreference);
                                  emit_push_mem(tempreference);
@@ -1448,10 +1514,16 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                                 end;
                                 end;
                                if inlined then
                                if inlined then
                                 begin
                                 begin
+{$ifdef AllocEDI}
+                                  exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                   emit_ref_reg(A_MOV,opsize,
                                   emit_ref_reg(A_MOV,opsize,
                                     newreference(tempreference),hreg);
                                     newreference(tempreference),hreg);
                                   r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                   r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                   exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,opsize,hreg,r)));
                                   exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,opsize,hreg,r)));
+{$ifdef AllocEDI}
+                                  exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                 end
                                 end
                                else
                                else
                                 exprasmlist^.concat(new(paicpu,op_ref(A_PUSH,opsize,
                                 exprasmlist^.concat(new(paicpu,op_ref(A_PUSH,opsize,
@@ -1470,10 +1542,16 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                                inc(pushedparasize,4);
                                inc(pushedparasize,4);
                                if inlined then
                                if inlined then
                                  begin
                                  begin
+{$ifdef AllocEDI}
+                                    exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                     emit_ref_reg(A_MOV,S_L,
                                     emit_ref_reg(A_MOV,S_L,
                                       newreference(tempreference),R_EDI);
                                       newreference(tempreference),R_EDI);
                                     r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                     r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                     exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
                                     exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
+{$ifdef AllocEDI}
+                                    exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                  end
                                  end
                                else
                                else
                                  emit_push_mem(tempreference);
                                  emit_push_mem(tempreference);
@@ -1485,10 +1563,16 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                               inc(tempreference.offset,4);
                               inc(tempreference.offset,4);
                               if inlined then
                               if inlined then
                                 begin
                                 begin
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                    emit_ref_reg(A_MOV,S_L,
                                    emit_ref_reg(A_MOV,S_L,
                                      newreference(tempreference),R_EDI);
                                      newreference(tempreference),R_EDI);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                 end
                                 end
                               else
                               else
                                 emit_push_mem(tempreference);
                                 emit_push_mem(tempreference);
@@ -1496,10 +1580,16 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                               dec(tempreference.offset,4);
                               dec(tempreference.offset,4);
                               if inlined then
                               if inlined then
                                 begin
                                 begin
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                    emit_ref_reg(A_MOV,S_L,
                                    emit_ref_reg(A_MOV,S_L,
                                      newreference(tempreference),R_EDI);
                                      newreference(tempreference),R_EDI);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                 end
                                 end
                               else
                               else
                                 emit_push_mem(tempreference);
                                 emit_push_mem(tempreference);
@@ -1513,10 +1603,16 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                                 inc(tempreference.offset,6);
                                 inc(tempreference.offset,6);
                               if inlined then
                               if inlined then
                                 begin
                                 begin
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                    emit_ref_reg(A_MOV,S_L,
                                    emit_ref_reg(A_MOV,S_L,
                                      newreference(tempreference),R_EDI);
                                      newreference(tempreference),R_EDI);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                 end
                                 end
                               else
                               else
                                 emit_push_mem(tempreference);
                                 emit_push_mem(tempreference);
@@ -1524,10 +1620,16 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                               inc(pushedparasize,4);
                               inc(pushedparasize,4);
                               if inlined then
                               if inlined then
                                 begin
                                 begin
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                    emit_ref_reg(A_MOV,S_L,
                                    emit_ref_reg(A_MOV,S_L,
                                      newreference(tempreference),R_EDI);
                                      newreference(tempreference),R_EDI);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                 end
                                 end
                               else
                               else
                                 emit_push_mem(tempreference);
                                 emit_push_mem(tempreference);
@@ -1547,10 +1649,16 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                                 end;
                                 end;
                               if inlined then
                               if inlined then
                                 begin
                                 begin
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                    emit_ref_reg(A_MOV,opsize,
                                    emit_ref_reg(A_MOV,opsize,
                                      newreference(tempreference),hreg);
                                      newreference(tempreference),hreg);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,opsize,hreg,r)));
                                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,opsize,hreg,r)));
+{$ifdef AllocEDI}
+                                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                 end
                                 end
                               else
                               else
                                 exprasmlist^.concat(new(paicpu,op_ref(A_PUSH,opsize,
                                 exprasmlist^.concat(new(paicpu,op_ref(A_PUSH,opsize,
@@ -1565,10 +1673,16 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                          inc(pushedparasize,4);
                          inc(pushedparasize,4);
                          if inlined then
                          if inlined then
                            begin
                            begin
+{$ifdef AllocEDI}
+                              exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                               emit_ref_reg(A_MOV,S_L,
                               emit_ref_reg(A_MOV,S_L,
                                 newreference(tempreference),R_EDI);
                                 newreference(tempreference),R_EDI);
                               r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                               r:=new_reference(procinfo^.framepointer,para_offset-pushedparasize);
                               exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
                               exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_L,R_EDI,r)));
+{$ifdef AllocEDI}
+                              exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                            end
                            end
                          else
                          else
                            emit_push_mem(tempreference);
                            emit_push_mem(tempreference);
@@ -1661,6 +1775,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                end;
                end;
              LOC_FLAGS:
              LOC_FLAGS:
                begin
                begin
+{$ifdef AllocEDI}
+                  exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                   if not(R_EAX in unused) then
                   if not(R_EAX in unused) then
                     emit_reg_reg(A_MOV,S_L,R_EAX,R_EDI);
                     emit_reg_reg(A_MOV,S_L,R_EAX,R_EDI);
                   emit_flag2reg(p^.location.resflags,R_AL);
                   emit_flag2reg(p^.location.resflags,R_AL);
@@ -1685,7 +1802,12 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                   else
                   else
                     exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,opsize,hreg)));
                     exprasmlist^.concat(new(paicpu,op_reg(A_PUSH,opsize,hreg)));
                   if not(R_EAX in unused) then
                   if not(R_EAX in unused) then
-                    emit_reg_reg(A_MOV,S_L,R_EDI,R_EAX);
+                    begin
+                      emit_reg_reg(A_MOV,S_L,R_EDI,R_EAX);
+{$ifdef AllocEDI}
+                      exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
+                    end;
                end;
                end;
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
              LOC_MMXREGISTER,
              LOC_MMXREGISTER,
@@ -1986,15 +2108,27 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
               emitjmp(C_L,neglabel);
               emitjmp(C_L,neglabel);
             end;
             end;
            { insert bound instruction only }
            { insert bound instruction only }
+{$ifdef AllocEDI}
+           exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
            exprasmlist^.concat(new(paicpu,op_sym_ofs_reg(A_MOV,S_L,newasmsymbol(rstr),0,R_EDI)));
            exprasmlist^.concat(new(paicpu,op_sym_ofs_reg(A_MOV,S_L,newasmsymbol(rstr),0,R_EDI)));
            emitcall('FPC_BOUNDCHECK');
            emitcall('FPC_BOUNDCHECK');
+{$ifdef AllocEDI}
+           exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
            { u32bit needs 2 checks }
            { u32bit needs 2 checks }
            if doublebound then
            if doublebound then
             begin
             begin
               emitjmp(C_None,poslabel);
               emitjmp(C_None,poslabel);
               emitlab(neglabel);
               emitlab(neglabel);
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
               exprasmlist^.concat(new(paicpu,op_sym_ofs_reg(A_MOV,S_L,newasmsymbol(rstr),8,R_EDI)));
               exprasmlist^.concat(new(paicpu,op_sym_ofs_reg(A_MOV,S_L,newasmsymbol(rstr),8,R_EDI)));
               emitcall('FPC_BOUNDCHECK');
               emitcall('FPC_BOUNDCHECK');
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
               emitlab(poslabel);
               emitlab(poslabel);
             end;
             end;
            if popecx then
            if popecx then
@@ -2012,12 +2146,18 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                hreg:=p^.location.register
                hreg:=p^.location.register
               else
               else
                begin
                begin
+{$ifdef AllocEDI}
+                 exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                  emit_reg_reg(op,opsize,p^.location.register,R_EDI);
                  emit_reg_reg(op,opsize,p^.location.register,R_EDI);
                  hreg:=R_EDI;
                  hreg:=R_EDI;
                end;
                end;
             end
             end
            else
            else
             begin
             begin
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
               emit_ref_reg(op,opsize,newreference(p^.location.reference),R_EDI);
               emit_ref_reg(op,opsize,newreference(p^.location.reference),R_EDI);
               hreg:=R_EDI;
               hreg:=R_EDI;
             end;
             end;
@@ -2025,7 +2165,7 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
             begin
             begin
               getlabel(neglabel);
               getlabel(neglabel);
               getlabel(poslabel);
               getlabel(poslabel);
-              emit_reg_reg(A_OR,S_L,hreg,hreg);
+              emit_reg_reg(A_TEST,S_L,hreg,hreg);
               emitjmp(C_L,neglabel);
               emitjmp(C_L,neglabel);
             end;
             end;
            { insert bound instruction only }
            { insert bound instruction only }
@@ -2039,6 +2179,10 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
               exprasmlist^.concat(new(paicpu,op_reg_ref(A_BOUND,S_L,hreg,newreference(href))));
               exprasmlist^.concat(new(paicpu,op_reg_ref(A_BOUND,S_L,hreg,newreference(href))));
               emitlab(poslabel);
               emitlab(poslabel);
             end;
             end;
+{$ifdef AllocEDI}
+           if hreg = R_EDI then
+             exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
          end;
          end;
       end;
       end;
 
 
@@ -2075,6 +2219,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
              (not(cs_littlesize in aktglobalswitches ) and (size<=12))) then
              (not(cs_littlesize in aktglobalswitches ) and (size<=12))) then
            begin
            begin
               helpsize:=size shr 2;
               helpsize:=size shr 2;
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
               for i:=1 to helpsize do
               for i:=1 to helpsize do
                 begin
                 begin
                    emit_ref_reg(A_MOV,S_L,newreference(source),R_EDI);
                    emit_ref_reg(A_MOV,S_L,newreference(source),R_EDI);
@@ -2099,6 +2246,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                    inc(dest.offset,2);
                    inc(dest.offset,2);
                    dec(size,2);
                    dec(size,2);
                 end;
                 end;
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
               if size>0 then
               if size>0 then
                 begin
                 begin
                    { and now look for an 8 bit register }
                    { and now look for an 8 bit register }
@@ -2130,7 +2280,12 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                       end;
                       end;
                    if swap then
                    if swap then
                      { was earlier XCHG, of course nonsense }
                      { was earlier XCHG, of course nonsense }
-                     emit_reg_reg(A_MOV,S_L,reg32,R_EDI);
+                     begin
+{$ifdef AllocEDI}
+                       exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
+                       emit_reg_reg(A_MOV,S_L,reg32,R_EDI);
+                     end;
                    emit_ref_reg(A_MOV,S_B,newreference(source),reg8);
                    emit_ref_reg(A_MOV,S_B,newreference(source),reg8);
 {$ifdef regallocfix}
 {$ifdef regallocfix}
                    If delsource then
                    If delsource then
@@ -2138,16 +2293,27 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
 {$endif regallocfix}
 {$endif regallocfix}
                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_B,reg8,newreference(dest))));
                    exprasmlist^.concat(new(paicpu,op_reg_ref(A_MOV,S_B,reg8,newreference(dest))));
                    if swap then
                    if swap then
-                     emit_reg_reg(A_MOV,S_L,R_EDI,reg32);
+                     begin
+                       emit_reg_reg(A_MOV,S_L,R_EDI,reg32);
+{$ifdef AllocEDI}
+                       exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
+                     end;
                 end;
                 end;
            end
            end
          else
          else
            begin
            begin
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
               emit_ref_reg(A_LEA,S_L,newreference(dest),R_EDI);
               emit_ref_reg(A_LEA,S_L,newreference(dest),R_EDI);
 {$ifdef regallocfix}
 {$ifdef regallocfix}
              {is this ok?? (JM)}
              {is this ok?? (JM)}
               del_reference(dest);
               del_reference(dest);
 {$endif regallocfix}
 {$endif regallocfix}
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,alloc(R_ESI)));
+{$endif AllocEDI}
               if loadref then
               if loadref then
                 emit_ref_reg(A_MOV,S_L,newreference(source),R_ESI)
                 emit_ref_reg(A_MOV,S_L,newreference(source),R_ESI)
               else
               else
@@ -2188,8 +2354,17 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                    if size=1 then
                    if size=1 then
                      exprasmlist^.concat(new(paicpu,op_none(A_MOVSB,S_NO)));
                      exprasmlist^.concat(new(paicpu,op_none(A_MOVSB,S_NO)));
                 end;
                 end;
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+              exprasmlist^.concat(new(pairegalloc,dealloc(R_ESI)));
+{$endif AllocEDI}
               if ecxpushed then
               if ecxpushed then
-                exprasmlist^.concat(new(paicpu,op_reg(A_POP,S_L,R_ECX)));
+                begin
+{$ifdef AllocEDI}
+                  exprasmlist^.concat(new(pairegalloc,alloc(R_ECX)));
+{$endif AllocEDI}
+                  exprasmlist^.concat(new(paicpu,op_reg(A_POP,S_L,R_ECX)));
+                end;
 
 
               { loading SELF-reference again }
               { loading SELF-reference again }
               maybe_loadesi;
               maybe_loadesi;
@@ -2277,6 +2452,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                    reset_reference(hp^);
                    reset_reference(hp^);
                    hp^.offset:=procinfo^.framepointer_offset;
                    hp^.offset:=procinfo^.framepointer_offset;
                    hp^.base:=procinfo^.framepointer;
                    hp^.base:=procinfo^.framepointer;
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,alloc(R_ESI)));
+{$endif AllocEDI}
                    emit_ref_reg(A_MOV,S_L,hp,R_ESI);
                    emit_ref_reg(A_MOV,S_L,hp,R_ESI);
                    p:=procinfo^.parent;
                    p:=procinfo^.parent;
                    for i:=3 to lexlevel-1 do
                    for i:=3 to lexlevel-1 do
@@ -2599,6 +2777,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
               reset_reference(r^);
               reset_reference(r^);
               r^.base:=procinfo^.framepointer;
               r^.base:=procinfo^.framepointer;
               r^.offset:=pvarsym(p)^.address+4+procinfo^.call_offset;
               r^.offset:=pvarsym(p)^.address+4+procinfo^.call_offset;
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
               exprasmlist^.concat(new(paicpu,
               exprasmlist^.concat(new(paicpu,
                 op_ref_reg(A_MOV,S_L,r,R_EDI)));
                 op_ref_reg(A_MOV,S_L,r,R_EDI)));
 
 
@@ -2630,11 +2811,17 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                    emitlab(ok);
                    emitlab(ok);
                    exprasmlist^.concat(new(paicpu,
                    exprasmlist^.concat(new(paicpu,
                      op_reg_reg(A_SUB,S_L,R_EDI,R_ESP)));
                      op_reg_reg(A_SUB,S_L,R_EDI,R_ESP)));
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                    { now reload EDI }
                    { now reload EDI }
                    new(r);
                    new(r);
                    reset_reference(r^);
                    reset_reference(r^);
                    r^.base:=procinfo^.framepointer;
                    r^.base:=procinfo^.framepointer;
                    r^.offset:=pvarsym(p)^.address+4+procinfo^.call_offset;
                    r^.offset:=pvarsym(p)^.address+4+procinfo^.call_offset;
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                    exprasmlist^.concat(new(paicpu,
                    exprasmlist^.concat(new(paicpu,
                      op_ref_reg(A_MOV,S_L,r,R_EDI)));
                      op_ref_reg(A_MOV,S_L,r,R_EDI)));
 
 
@@ -2656,6 +2843,10 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                 end;
                 end;
 
 
               { don't destroy the registers! }
               { don't destroy the registers! }
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,alloc(R_ECX)));
+              exprasmlist^.concat(new(pairegalloc,alloc(R_ESI)));
+{$endif AllocEDI}
               exprasmlist^.concat(new(paicpu,
               exprasmlist^.concat(new(paicpu,
                 op_reg(A_PUSH,S_L,R_ECX)));
                 op_reg(A_PUSH,S_L,R_ECX)));
               exprasmlist^.concat(new(paicpu,
               exprasmlist^.concat(new(paicpu,
@@ -2705,6 +2896,11 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                 S_W : exprasmlist^.concat(new(paicpu,op_none(A_MOVSW,S_NO)));
                 S_W : exprasmlist^.concat(new(paicpu,op_none(A_MOVSW,S_NO)));
                 S_L : exprasmlist^.concat(new(paicpu,op_none(A_MOVSD,S_NO)));
                 S_L : exprasmlist^.concat(new(paicpu,op_none(A_MOVSD,S_NO)));
               end;
               end;
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+              exprasmlist^.concat(new(pairegalloc,dealloc(R_ESI)));
+              exprasmlist^.concat(new(pairegalloc,dealloc(R_ECX)));
+{$endif AllocEDI}
               exprasmlist^.concat(new(paicpu,
               exprasmlist^.concat(new(paicpu,
                 op_reg(A_POP,S_L,R_ESI)));
                 op_reg(A_POP,S_L,R_ESI)));
               exprasmlist^.concat(new(paicpu,
               exprasmlist^.concat(new(paicpu,
@@ -2883,6 +3079,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
             begin
             begin
               exprasmlist^.insert(new(paicpu,op_cond_sym(A_Jcc,C_Z,S_NO,faillabel)));
               exprasmlist^.insert(new(paicpu,op_cond_sym(A_Jcc,C_Z,S_NO,faillabel)));
               emitinsertcall('FPC_HELP_CONSTRUCTOR');
               emitinsertcall('FPC_HELP_CONSTRUCTOR');
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
               exprasmlist^.insert(new(paicpu,op_const_reg(A_MOV,S_L,procinfo^._class^.vmt_offset,R_EDI)));
               exprasmlist^.insert(new(paicpu,op_const_reg(A_MOV,S_L,procinfo^._class^.vmt_offset,R_EDI)));
             end;
             end;
         end;
         end;
@@ -2897,6 +3096,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
            reset_reference(hr^);
            reset_reference(hr^);
            hr^.offset:=procinfo^.selfpointer_offset;
            hr^.offset:=procinfo^.selfpointer_offset;
            hr^.base:=procinfo^.framepointer;
            hr^.base:=procinfo^.framepointer;
+{$ifdef AllocEDI}
+           exprasmlist^.concat(new(pairegalloc,alloc(R_ESI)));
+{$endif AllocEDI}
            exprasmlist^.insert(new(paicpu,op_ref_reg(A_MOV,S_L,hr,R_ESI)));
            exprasmlist^.insert(new(paicpu,op_ref_reg(A_MOV,S_L,hr,R_ESI)));
         end;
         end;
       { should we save edi,esi,ebx like C ? }
       { should we save edi,esi,ebx like C ? }
@@ -2981,6 +3183,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                                   else
                                   else
                                     begin
                                     begin
                                        getlabel(again);
                                        getlabel(again);
+{$ifdef AllocEDI}
+                                       exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                                        exprasmlist^.concat(new(paicpu,
                                        exprasmlist^.concat(new(paicpu,
                                          op_const_reg(A_MOV,S_L,stackframe div winstackpagesize,R_EDI)));
                                          op_const_reg(A_MOV,S_L,stackframe div winstackpagesize,R_EDI)));
                                        emitlab(again);
                                        emitlab(again);
@@ -2991,6 +3196,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                                        exprasmlist^.concat(new(paicpu,
                                        exprasmlist^.concat(new(paicpu,
                                          op_reg(A_DEC,S_L,R_EDI)));
                                          op_reg(A_DEC,S_L,R_EDI)));
                                        emitjmp(C_NZ,again);
                                        emitjmp(C_NZ,again);
+{$ifdef AllocEDI}
+                                       exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                                        exprasmlist^.concat(new(paicpu,
                                        exprasmlist^.concat(new(paicpu,
                                          op_const_reg(A_SUB,S_L,stackframe mod winstackpagesize,R_ESP)));
                                          op_const_reg(A_SUB,S_L,stackframe mod winstackpagesize,R_ESP)));
                                     end
                                     end
@@ -3199,6 +3407,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
           else
           else
             begin
             begin
               emitinsertcall('FPC_HELP_DESTRUCTOR');
               emitinsertcall('FPC_HELP_DESTRUCTOR');
+{$ifdef AllocEDI}
+              exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
               exprasmlist^.insert(new(paicpu,op_const_reg(A_MOV,S_L,procinfo^._class^.vmt_offset,R_EDI)));
               exprasmlist^.insert(new(paicpu,op_const_reg(A_MOV,S_L,procinfo^._class^.vmt_offset,R_EDI)));
               { must the object be finalized ? }
               { must the object be finalized ? }
               if procinfo^._class^.needs_inittable then
               if procinfo^._class^.needs_inittable then
@@ -3206,6 +3417,9 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                    getlabel(nofinal);
                    getlabel(nofinal);
                    exprasmlist^.insert(new(pai_label,init(nofinal)));
                    exprasmlist^.insert(new(pai_label,init(nofinal)));
                    emitinsertcall('FPC_FINALIZE');
                    emitinsertcall('FPC_FINALIZE');
+{$ifdef AllocEDI}
+                   exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                    exprasmlist^.insert(new(paicpu,op_reg(A_PUSH,S_L,R_ESI)));
                    exprasmlist^.insert(new(paicpu,op_reg(A_PUSH,S_L,R_ESI)));
                    exprasmlist^.insert(new(paicpu,op_sym(A_PUSH,S_L,procinfo^._class^.get_inittable_label)));
                    exprasmlist^.insert(new(paicpu,op_sym(A_PUSH,S_L,procinfo^._class^.get_inittable_label)));
                    ai:=new(paicpu,op_sym(A_Jcc,S_NO,nofinal));
                    ai:=new(paicpu,op_sym(A_Jcc,S_NO,nofinal));
@@ -3281,13 +3495,19 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
                   else
                   else
                     begin
                     begin
                       emit_ref_reg(A_MOV,S_L,new_reference(procinfo^.framepointer,12),R_ESI);
                       emit_ref_reg(A_MOV,S_L,new_reference(procinfo^.framepointer,12),R_ESI);
+{$ifdef AllocEDI}
+                       exprasmlist^.concat(new(pairegalloc,alloc(R_EDI)));
+{$endif AllocEDI}
                       emit_const_reg(A_MOV,S_L,procinfo^._class^.vmt_offset,R_EDI);
                       emit_const_reg(A_MOV,S_L,procinfo^._class^.vmt_offset,R_EDI);
                       emitcall('FPC_HELP_FAIL');
                       emitcall('FPC_HELP_FAIL');
+{$ifdef AllocEDI}
+                      exprasmlist^.concat(new(pairegalloc,dealloc(R_EDI)));
+{$endif AllocEDI}
                     end;
                     end;
                   emitlab(okexitlabel);
                   emitlab(okexitlabel);
 
 
                   emit_reg_reg(A_MOV,S_L,R_ESI,R_EAX);
                   emit_reg_reg(A_MOV,S_L,R_ESI,R_EAX);
-                  emit_reg_reg(A_OR,S_L,R_EAX,R_EAX);
+                  emit_reg_reg(A_TEST,S_L,R_ESI,R_ESI);
               end;
               end;
 
 
       { stabs uses the label also ! }
       { stabs uses the label also ! }
@@ -3447,7 +3667,12 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.66  2000-01-07 01:14:22  peter
+  Revision 1.67  2000-01-09 01:44:21  jonas
+    + (de)allocation info for EDI to fix reported bug on mailinglist.
+      Also some (de)allocation info for ESI added. Between -dallocEDI
+      because at this time of the night bugs could easily slip in ;)
+
+  Revision 1.66  2000/01/07 01:14:22  peter
     * updated copyright to 2000
     * updated copyright to 2000
 
 
   Revision 1.65  1999/12/22 01:01:47  peter
   Revision 1.65  1999/12/22 01:01:47  peter

+ 108 - 4
compiler/daopt386.pas

@@ -133,16 +133,43 @@ type
 {contents of the FPU registers}
 {contents of the FPU registers}
   TRegFPUContent = Array[R_ST..R_ST7] Of TContent;
   TRegFPUContent = Array[R_ST..R_ST7] Of TContent;
 
 
+{$ifdef tempOpts}
+{ linked list which allows searching/deleting based on value, no extra frills}
+  PSearchLinkedListItem = ^TSearchLinkedListItem;
+  TSearchLinkedListItem = object(TLinkedList_Item)
+    constructor init;
+    function equals(p: PSearchLinkedListItem): boolean; virtual;
+  end;
+
+  PSearchDoubleIntItem = ^TSearchDoubleInttem;
+  TSearchDoubleIntItem = object(TLinkedList_Item)
+    constructor init(_int1,_int2: longint);
+    function equals(p: PSearchLinkedListItem): boolean; virtual;
+   private
+    int1, int2: longint;
+  end;
+
+  PSearchLinkedList = ^TSearchLinkedList;
+  TSearchLinkedList = object(TLinkedList)
+    function searchByValue(p: PSearchLinkedListItem): boolean;
+    procedure removeByValue(p: PSearchLinkedListItem);
+  end;
+{$endif tempOpts}
+
 {information record with the contents of every register. Every Pai object
 {information record with the contents of every register. Every Pai object
  gets one of these assigned: a pointer to it is stored in the OptInfo field}
  gets one of these assigned: a pointer to it is stored in the OptInfo field}
   TPaiProp = Record
   TPaiProp = Record
                Regs: TRegContent;
                Regs: TRegContent;
 {               FPURegs: TRegFPUContent;} {currently not yet used}
 {               FPURegs: TRegFPUContent;} {currently not yet used}
-    {allocated Registers}
+    { allocated Registers }
                UsedRegs: TRegSet;
                UsedRegs: TRegSet;
-    {status of the direction flag}
+    { status of the direction flag }
                DirFlag: TFlagContents;
                DirFlag: TFlagContents;
-    {can this instruction be removed?}
+{$ifdef tempOpts}
+    { currently used temps }
+               tempAllocs: PSearchLinkedList;
+{$endif tempOpts}
+    { can this instruction be removed? }
                CanBeRemoved: Boolean;
                CanBeRemoved: Boolean;
              End;
              End;
 
 
@@ -201,6 +228,76 @@ Var
   that modified the register}
   that modified the register}
   NrOfInstrSinceLastMod: TInstrSinceLastMod;
   NrOfInstrSinceLastMod: TInstrSinceLastMod;
 
 
+{$ifdef tempOpts}
+  constructor TSearchLinkedListItem.init;
+  begin
+  end;
+
+  function TSearchLinkedListItem.equals(p: PSearchLinkedListItem): boolean;
+  begin
+    equals := false;
+  end;
+
+  constructor TSearchDoubleIntItem.init(_int1,_int2: longint);
+  begin
+    int1 := _int1;
+    int2 := _int2;
+  end;
+
+  function TSearchDoubleIntItem.equals(p: PSearchLinkedListItem): boolean;
+  begin
+    equals := (TSearchDoubleIntItem(p).int1 = int1) and
+              (TSearchDoubleIntItem(p).int2 = int2);
+  end;
+
+  function TSearchLinkedList.searchByValue(p: PSearchLinkedListItem): boolean;
+  var temp: PSearchLinkedListItem;
+  begin
+    temp := first;
+    while (temp <> last^.next) and
+          not(temp^.equals(p)) do
+      temp := temp^.next;
+    searchByValue := temp <> last^.next;
+  end;
+
+  procedure TSearchLinkedList.removeByValue(p: PSearchLinkedListItem);
+  begin
+    temp := first;
+    while (temp <> last^.next) and
+          not(temp^.equals(p)) do
+      temp := temp^.next;
+    if temp <> last^.next then
+      begin
+        remove(temp);
+        dispose(temp,done);
+      end;
+  end;
+
+Procedure updateTempAllocs(Var UsedRegs: TRegSet; p: Pai);
+{updates UsedRegs with the RegAlloc Information coming after P}
+Begin
+  Repeat
+    While Assigned(p) And
+          ((p^.typ in (SkipInstr - [ait_RegAlloc])) or
+           ((p^.typ = ait_label) And
+            Not(Pai_Label(p)^.l^.is_used))) Do
+         p := Pai(p^.next);
+    While Assigned(p) And
+          (p^.typ=ait_RegAlloc) Do
+      Begin
+        if pairegalloc(p)^.allocation then
+          UsedRegs := UsedRegs + [PaiRegAlloc(p)^.Reg]
+        else
+          UsedRegs := UsedRegs - [PaiRegAlloc(p)^.Reg];
+        p := pai(p^.next);
+      End;
+  Until Not(Assigned(p)) Or
+        (Not(p^.typ in SkipInstr) And
+         Not((p^.typ = ait_label) And
+            Not(Pai_Label(p)^.l^.is_used)));
+End;
+
+{$endif tempOpts}
 
 
 {************************ Create the Label table ************************}
 {************************ Create the Label table ************************}
 
 
@@ -304,6 +401,8 @@ Begin
           If Pai_Label(p)^.l^.is_used Then
           If Pai_Label(p)^.l^.is_used Then
             LabelTable^[Pai_Label(p)^.l^.labelnr-LowLabel].PaiObj := p;
             LabelTable^[Pai_Label(p)^.l^.labelnr-LowLabel].PaiObj := p;
         ait_regAlloc:
         ait_regAlloc:
+          { ESI and EDI are (de)allocated manually, don't mess with them }
+          if not(paiRegAlloc(p)^.Reg in [R_EDI,R_ESI]) then
            begin
            begin
              if PairegAlloc(p)^.Allocation then
              if PairegAlloc(p)^.Allocation then
               Begin
               Begin
@@ -1918,7 +2017,12 @@ End.
 
 
 {
 {
  $Log$
  $Log$
- Revision 1.76  2000-01-07 01:14:23  peter
+ Revision 1.77  2000-01-09 01:44:21  jonas
+   + (de)allocation info for EDI to fix reported bug on mailinglist.
+     Also some (de)allocation info for ESI added. Between -dallocEDI
+     because at this time of the night bugs could easily slip in ;)
+
+ Revision 1.76  2000/01/07 01:14:23  peter
    * updated copyright to 2000
    * updated copyright to 2000
 
 
  Revision 1.75  1999/12/05 16:48:43  jonas
  Revision 1.75  1999/12/05 16:48:43  jonas