mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-31 10:11:27 +01:00 
			
		
		
		
	+ Fixes from Jonas.
This commit is contained in:
		
							parent
							
								
									02381105d6
								
							
						
					
					
						commit
						587a967353
					
				| @ -337,7 +337,7 @@ implementation | |||||||
|         pushed : boolean; |         pushed : boolean; | ||||||
|         href   : treference; |         href   : treference; | ||||||
|         pushedregs : tpushed; |         pushedregs : tpushed; | ||||||
|         regstopush: longint; |         regstopush: byte; | ||||||
|       begin |       begin | ||||||
|         cmpop:=false; |         cmpop:=false; | ||||||
| 
 | 
 | ||||||
| @ -425,24 +425,8 @@ implementation | |||||||
|                      pushusedregisters(pushedregs,$ff);} |                      pushusedregisters(pushedregs,$ff);} | ||||||
| 
 | 
 | ||||||
|                      regstopush := $ff; |                      regstopush := $ff; | ||||||
|                      case p^.right^.location.loc of |                      remove_non_regvars_from_loc(p^.right^.location,regstopush); | ||||||
|                        LOC_REGISTER: |                      remove_non_regvars_from_loc(p^.left^.location,regstopush); | ||||||
|                          regstopush := regstopush and |  | ||||||
|                            not($80 shr byte(p^.right^.location.register)); |  | ||||||
|                        LOC_MEM,LOC_REFERENCE: |  | ||||||
|                          regstopush := regstopush and |  | ||||||
|                            not($80 shr byte(p^.right^.location.reference.base)) and |  | ||||||
|                            not($80 shr byte(p^.right^.location.reference.index)); |  | ||||||
|                      end; |  | ||||||
|                      case p^.left^.location.loc of |  | ||||||
|                        LOC_REGISTER: |  | ||||||
|                          regstopush := regstopush and |  | ||||||
|                            not($80 shr byte(p^.left^.location.register)); |  | ||||||
|                        LOC_MEM,LOC_REFERENCE: |  | ||||||
|                          regstopush := regstopush and |  | ||||||
|                            not($80 shr byte(p^.left^.location.reference.base)) and |  | ||||||
|                            not($80 shr byte(p^.left^.location.reference.index)); |  | ||||||
|                      end; |  | ||||||
|                      pushusedregisters(pushedregs,regstopush); |                      pushusedregisters(pushedregs,regstopush); | ||||||
|                      { this is still right before the instruction that uses } |                      { this is still right before the instruction that uses } | ||||||
|                      { p^.left^.location, but that can be fixed by the      } |                      { p^.left^.location, but that can be fixed by the      } | ||||||
| @ -580,6 +564,7 @@ implementation | |||||||
| {$endif SUPPORT_MMX} | {$endif SUPPORT_MMX} | ||||||
|          pushedreg : tpushed; |          pushedreg : tpushed; | ||||||
|          hloc : tlocation; |          hloc : tlocation; | ||||||
|  |          regstopush: byte; | ||||||
| 
 | 
 | ||||||
|       procedure firstjmp64bitcmp; |       procedure firstjmp64bitcmp; | ||||||
| 
 | 
 | ||||||
| @ -1070,14 +1055,19 @@ implementation | |||||||
|                        Else |                        Else | ||||||
|                         Begin |                         Begin | ||||||
| {$EndIf NoShlMul} | {$EndIf NoShlMul} | ||||||
|                          if not(R_EAX in unused) and not(reg_in_loc(R_EAX,p^.right^.location)) and |                          regstopush := $ff; | ||||||
|                             not(reg_in_loc(R_EAX,p^.left^.location)) then |                          remove_non_regvars_from_loc(p^.right^.location,regstopush); | ||||||
|  |                          remove_non_regvars_from_loc(p^.left^.location,regstopush); | ||||||
|  |                          { now, regstopush does NOT contain EAX and/or EDX if they are } | ||||||
|  |                          { used in either the left or the right location, excepts if   } | ||||||
|  |                          {they are regvars. It DOES contain them if they are used in   } | ||||||
|  |                          { another location (JM)                                       } | ||||||
|  |                          if ((regstopush and ($80 shr byte(R_EAX))) <> 0) then | ||||||
|                           begin |                           begin | ||||||
|                            emit_reg(A_PUSH,S_L,R_EAX); |                            emit_reg(A_PUSH,S_L,R_EAX); | ||||||
|                            popeax:=true; |                            popeax:=true; | ||||||
|                           end; |                           end; | ||||||
|                          if not(R_EDX in unused) and not(reg_in_loc(R_EDX,p^.right^.location)) and |                          if ((regstopush and ($80 shr byte(R_EDX))) <> 0) then | ||||||
|                             not(reg_in_loc(R_EDX,p^.left^.location)) then |  | ||||||
|                           begin |                           begin | ||||||
|                            emit_reg(A_PUSH,S_L,R_EDX); |                            emit_reg(A_PUSH,S_L,R_EDX); | ||||||
|                            popedx:=true; |                            popedx:=true; | ||||||
| @ -1095,11 +1085,8 @@ implementation | |||||||
|                          { load he right value } |                          { load he right value } | ||||||
|                          emitloadord2reg(p^.right^.location,u32bitdef,R_EAX,true); |                          emitloadord2reg(p^.right^.location,u32bitdef,R_EAX,true); | ||||||
|                          release_loc(p^.right^.location); |                          release_loc(p^.right^.location); | ||||||
|                          { a hack, I know :( Necessary for when EAX is in } |                          { allocate EAX if it isn't yet allocated (JM) } | ||||||
|                          { p^.right^.location, since it can't be released } |                          if (R_EAX in unused) then | ||||||
|                          { yet (JM)                                       } |  | ||||||
|                          if reg_in_loc(R_EAX,p^.right^.location) and |  | ||||||
|                             (R_EAX in unused) then |  | ||||||
|                            exprasmlist^.concat(new(pairegalloc,alloc(R_EAX))); |                            exprasmlist^.concat(new(pairegalloc,alloc(R_EAX))); | ||||||
| {$ifndef noAllocEdi} | {$ifndef noAllocEdi} | ||||||
|                          { also allocate EDX, since it is also modified by } |                          { also allocate EDX, since it is also modified by } | ||||||
| @ -2249,7 +2236,10 @@ implementation | |||||||
| end. | end. | ||||||
| { | { | ||||||
|   $Log$ |   $Log$ | ||||||
|   Revision 1.90  2000-01-22 16:02:38  jonas |   Revision 1.91  2000-01-23 11:11:36  michael | ||||||
|  |   + Fixes from Jonas. | ||||||
|  | 
 | ||||||
|  |   Revision 1.90  2000/01/22 16:02:38  jonas | ||||||
|     * fixed more regalloc bugs (for set adding and unsigned |     * fixed more regalloc bugs (for set adding and unsigned | ||||||
|       multiplication) |       multiplication) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -76,8 +76,9 @@ unit cgai386; | |||||||
|     procedure emit_pushq_loc(const t : tlocation); |     procedure emit_pushq_loc(const t : tlocation); | ||||||
|     procedure release_qword_loc(const t : tlocation); |     procedure release_qword_loc(const t : tlocation); | ||||||
| 
 | 
 | ||||||
|     { is a register used in a location? } |     { remove non regvar registers in loc from regs (in the format } | ||||||
|     function reg_in_loc(reg: tregister; const t: tlocation): boolean; |     { pushusedregisters uses)                                     }  | ||||||
|  |     procedure remove_non_regvars_from_loc(const t: tlocation; var regs: byte); | ||||||
|     { releases the registers of a location } |     { releases the registers of a location } | ||||||
|     procedure release_loc(const t : tlocation); |     procedure release_loc(const t : tlocation); | ||||||
| 
 | 
 | ||||||
| @ -611,16 +612,27 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister); | |||||||
|          end; |          end; | ||||||
|       end; |       end; | ||||||
| 
 | 
 | ||||||
|     function reg_in_loc(reg: tregister; const t: tlocation): boolean; |     procedure remove_non_regvars_from_loc(const t: tlocation; var regs: byte); | ||||||
|     begin |     begin | ||||||
|       reg_in_loc := false; |  | ||||||
|       case t.loc of |       case t.loc of | ||||||
|         LOC_REGISTER: reg_in_loc := t.register = reg; |         LOC_REGISTER: | ||||||
|         LOC_MEM, LOC_REFERENCE: |           { can't be a regvar, since it would be LOC_CREGISTER then }  | ||||||
|           reg_in_loc := (t.reference.base = reg) or (t.reference.index = reg); |           regs := regs and not($80 shr byte(t.register)); | ||||||
|  |         LOC_MEM,LOC_REFERENCE: | ||||||
|  |           begin | ||||||
|  |             if not(cs_regalloc in aktglobalswitches) or | ||||||
|  |                (t.reference.base in usableregs) then | ||||||
|  |               regs := regs and | ||||||
|  |                 not($80 shr byte(t.reference.base)); | ||||||
|  |             if not(cs_regalloc in aktglobalswitches) or | ||||||
|  |                (t.reference.index in usableregs) then | ||||||
|  |               regs := regs and | ||||||
|  |                 not($80 shr byte(t.reference.index)); | ||||||
|  |           end; | ||||||
|       end; |       end; | ||||||
|     end; |     end; | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|     procedure release_loc(const t : tlocation); |     procedure release_loc(const t : tlocation); | ||||||
| 
 | 
 | ||||||
|       begin |       begin | ||||||
| @ -3672,7 +3684,10 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister); | |||||||
| end. | end. | ||||||
| { | { | ||||||
|   $Log$ |   $Log$ | ||||||
|   Revision 1.71  2000-01-22 16:02:37  jonas |   Revision 1.72  2000-01-23 11:11:36  michael | ||||||
|  |   + Fixes from Jonas. | ||||||
|  | 
 | ||||||
|  |   Revision 1.71  2000/01/22 16:02:37  jonas | ||||||
|     * fixed more regalloc bugs (for set adding and unsigned |     * fixed more regalloc bugs (for set adding and unsigned | ||||||
|       multiplication) |       multiplication) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -736,10 +736,13 @@ begin | |||||||
|         end; |         end; | ||||||
|     end; |     end; | ||||||
|   sequenceEnd := sequenceEnd and |   sequenceEnd := sequenceEnd and | ||||||
|      RegSizesOk(orgReg,newReg,paicpu(endP)) and |      (not(assigned(endp)) or | ||||||
|      not(newRegModified and |       not(endp^.typ = ait_instruction) or | ||||||
|          (orgReg in PPaiProp(endP^.optInfo)^.usedRegs) and |       (noHardCodedRegs(paicpu(endP)) and | ||||||
|          not(RegLoadedWithNewValue(orgReg,true,paicpu(endP)))); |        RegSizesOk(orgReg,newReg,paicpu(endP)) and | ||||||
|  |        not(newRegModified and | ||||||
|  |            (orgReg in PPaiProp(endP^.optInfo)^.usedRegs) and | ||||||
|  |            not(RegLoadedWithNewValue(orgReg,true,paicpu(endP)))))); | ||||||
| 
 | 
 | ||||||
|   if SequenceEnd then |   if SequenceEnd then | ||||||
|     begin |     begin | ||||||
| @ -1167,7 +1170,10 @@ End. | |||||||
| 
 | 
 | ||||||
| { | { | ||||||
|  $Log$ |  $Log$ | ||||||
|  Revision 1.40  2000-01-22 16:10:06  jonas |  Revision 1.41  2000-01-23 11:11:37  michael | ||||||
|  |  + Fixes from Jonas. | ||||||
|  | 
 | ||||||
|  |  Revision 1.40  2000/01/22 16:10:06  jonas | ||||||
|    + all code generator generated "mov reg1,reg2" instructions are now |    + all code generator generated "mov reg1,reg2" instructions are now | ||||||
|      attempted to be removed using the replacereg code |      attempted to be removed using the replacereg code | ||||||
|      (-dnewoptimizations) |      (-dnewoptimizations) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 michael
						michael