mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 14:39:36 +01:00 
			
		
		
		
	* optimized releasing of registers
This commit is contained in:
		
							parent
							
								
									e732233993
								
							
						
					
					
						commit
						d77cf79d3b
					
				@ -252,10 +252,10 @@ interface
 | 
				
			|||||||
         case tstringdef(resulttype.def).string_typ of
 | 
					         case tstringdef(resulttype.def).string_typ of
 | 
				
			||||||
           st_shortstring :
 | 
					           st_shortstring :
 | 
				
			||||||
             begin
 | 
					             begin
 | 
				
			||||||
 | 
					               location_release(exprasmlist,left.location);
 | 
				
			||||||
               tg.GetTemp(exprasmlist,256,tt_normal,location.reference);
 | 
					               tg.GetTemp(exprasmlist,256,tt_normal,location.reference);
 | 
				
			||||||
               cg.a_load_loc_ref(exprasmlist,left.location.size,left.location,
 | 
					               cg.a_load_loc_ref(exprasmlist,left.location.size,left.location,
 | 
				
			||||||
                 location.reference);
 | 
					                 location.reference);
 | 
				
			||||||
               location_release(exprasmlist,left.location);
 | 
					 | 
				
			||||||
               location_freetemp(exprasmlist,left.location);
 | 
					               location_freetemp(exprasmlist,left.location);
 | 
				
			||||||
             end;
 | 
					             end;
 | 
				
			||||||
           { the rest is removed in the resulttype pass and converted to compilerprocs }
 | 
					           { the rest is removed in the resulttype pass and converted to compilerprocs }
 | 
				
			||||||
@ -511,7 +511,10 @@ end.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  $Log$
 | 
					  $Log$
 | 
				
			||||||
  Revision 1.45  2003-08-26 12:43:02  peter
 | 
					  Revision 1.46  2003-09-28 13:39:38  peter
 | 
				
			||||||
 | 
					    * optimized releasing of registers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Revision 1.45  2003/08/26 12:43:02  peter
 | 
				
			||||||
    * methodpointer fixes
 | 
					    * methodpointer fixes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Revision 1.44  2003/06/03 21:11:09  peter
 | 
					  Revision 1.44  2003/06/03 21:11:09  peter
 | 
				
			||||||
 | 
				
			|||||||
@ -287,12 +287,12 @@ implementation
 | 
				
			|||||||
                         LOC_CREFERENCE,
 | 
					                         LOC_CREFERENCE,
 | 
				
			||||||
                         LOC_REFERENCE:
 | 
					                         LOC_REFERENCE:
 | 
				
			||||||
                           begin
 | 
					                           begin
 | 
				
			||||||
 | 
					                              location_release(exprasmlist,left.location);
 | 
				
			||||||
                              hregister:=rg.getaddressregister(exprasmlist);
 | 
					                              hregister:=rg.getaddressregister(exprasmlist);
 | 
				
			||||||
                              if is_class_or_interface(left.resulttype.def) then
 | 
					                              if is_class_or_interface(left.resulttype.def) then
 | 
				
			||||||
                                cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,left.location.reference,hregister)
 | 
					                                cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,left.location.reference,hregister)
 | 
				
			||||||
                              else
 | 
					                              else
 | 
				
			||||||
                                cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,hregister);
 | 
					                                cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,hregister);
 | 
				
			||||||
                              location_release(exprasmlist,left.location);
 | 
					 | 
				
			||||||
                              location_freetemp(exprasmlist,left.location);
 | 
					                              location_freetemp(exprasmlist,left.location);
 | 
				
			||||||
                           end;
 | 
					                           end;
 | 
				
			||||||
                         else
 | 
					                         else
 | 
				
			||||||
@ -535,12 +535,17 @@ implementation
 | 
				
			|||||||
                      begin
 | 
					                      begin
 | 
				
			||||||
                        cgsize:=def_cgsize(left.resulttype.def);
 | 
					                        cgsize:=def_cgsize(left.resulttype.def);
 | 
				
			||||||
                        if cgsize in [OS_64,OS_S64] then
 | 
					                        if cgsize in [OS_64,OS_S64] then
 | 
				
			||||||
                         cg64.a_load64_ref_reg(exprasmlist,
 | 
					                          begin
 | 
				
			||||||
                             right.location.reference,left.location.register64,false)
 | 
					                            cg64.a_load64_ref_reg(exprasmlist,
 | 
				
			||||||
 | 
					                               right.location.reference,left.location.register64,false);
 | 
				
			||||||
 | 
					                            location_release(exprasmlist,right.location);
 | 
				
			||||||
 | 
					                          end
 | 
				
			||||||
                        else
 | 
					                        else
 | 
				
			||||||
                         cg.a_load_ref_reg(exprasmlist,cgsize,cgsize,
 | 
					                          begin
 | 
				
			||||||
                             right.location.reference,left.location.register);
 | 
					                            location_release(exprasmlist,right.location);
 | 
				
			||||||
                        location_release(exprasmlist,right.location);
 | 
					                            cg.a_load_ref_reg(exprasmlist,cgsize,cgsize,
 | 
				
			||||||
 | 
					                                right.location.reference,left.location.register);
 | 
				
			||||||
 | 
					                          end;
 | 
				
			||||||
                      end;
 | 
					                      end;
 | 
				
			||||||
                    LOC_CFPUREGISTER :
 | 
					                    LOC_CFPUREGISTER :
 | 
				
			||||||
                      begin
 | 
					                      begin
 | 
				
			||||||
@ -820,8 +825,8 @@ implementation
 | 
				
			|||||||
                    if vaddr then
 | 
					                    if vaddr then
 | 
				
			||||||
                     begin
 | 
					                     begin
 | 
				
			||||||
                       location_force_mem(exprasmlist,hp.left.location);
 | 
					                       location_force_mem(exprasmlist,hp.left.location);
 | 
				
			||||||
                       cg.a_paramaddr_ref(exprasmlist,hp.left.location.reference,paraloc);
 | 
					 | 
				
			||||||
                       location_release(exprasmlist,hp.left.location);
 | 
					                       location_release(exprasmlist,hp.left.location);
 | 
				
			||||||
 | 
					                       cg.a_paramaddr_ref(exprasmlist,hp.left.location.reference,paraloc);
 | 
				
			||||||
                       if freetemp then
 | 
					                       if freetemp then
 | 
				
			||||||
                         location_freetemp(exprasmlist,hp.left.location);
 | 
					                         location_freetemp(exprasmlist,hp.left.location);
 | 
				
			||||||
                       inc(pushedparasize,pointer_size);
 | 
					                       inc(pushedparasize,pointer_size);
 | 
				
			||||||
@ -842,11 +847,11 @@ implementation
 | 
				
			|||||||
                    if vaddr then
 | 
					                    if vaddr then
 | 
				
			||||||
                     begin
 | 
					                     begin
 | 
				
			||||||
                       location_force_mem(exprasmlist,hp.left.location);
 | 
					                       location_force_mem(exprasmlist,hp.left.location);
 | 
				
			||||||
 | 
					                       location_release(exprasmlist,hp.left.location);
 | 
				
			||||||
                       tmpreg:=rg.getaddressregister(exprasmlist);
 | 
					                       tmpreg:=rg.getaddressregister(exprasmlist);
 | 
				
			||||||
                       cg.a_loadaddr_ref_reg(exprasmlist,hp.left.location.reference,tmpreg);
 | 
					                       cg.a_loadaddr_ref_reg(exprasmlist,hp.left.location.reference,tmpreg);
 | 
				
			||||||
                       cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
 | 
					 | 
				
			||||||
                       rg.ungetregisterint(exprasmlist,tmpreg);
 | 
					                       rg.ungetregisterint(exprasmlist,tmpreg);
 | 
				
			||||||
                       location_release(exprasmlist,hp.left.location);
 | 
					                       cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
 | 
				
			||||||
                       if freetemp then
 | 
					                       if freetemp then
 | 
				
			||||||
                         location_freetemp(exprasmlist,hp.left.location);
 | 
					                         location_freetemp(exprasmlist,hp.left.location);
 | 
				
			||||||
                     end
 | 
					                     end
 | 
				
			||||||
@ -869,7 +874,6 @@ implementation
 | 
				
			|||||||
                    is_widestring(left.resulttype.def) or
 | 
					                    is_widestring(left.resulttype.def) or
 | 
				
			||||||
                    (left.resulttype.def.deftype=variantdef) then
 | 
					                    (left.resulttype.def.deftype=variantdef) then
 | 
				
			||||||
                   freetemp:=false;
 | 
					                   freetemp:=false;
 | 
				
			||||||
                 location_release(exprasmlist,hp.left.location);
 | 
					 | 
				
			||||||
                 case hp.left.location.loc of
 | 
					                 case hp.left.location.loc of
 | 
				
			||||||
                   LOC_FPUREGISTER,
 | 
					                   LOC_FPUREGISTER,
 | 
				
			||||||
                   LOC_CFPUREGISTER :
 | 
					                   LOC_CFPUREGISTER :
 | 
				
			||||||
@ -880,14 +884,21 @@ implementation
 | 
				
			|||||||
                   LOC_REFERENCE,
 | 
					                   LOC_REFERENCE,
 | 
				
			||||||
                   LOC_CREFERENCE :
 | 
					                   LOC_CREFERENCE :
 | 
				
			||||||
                     begin
 | 
					                     begin
 | 
				
			||||||
 | 
					                       location_release(exprasmlist,hp.left.location);
 | 
				
			||||||
                       cg.g_concatcopy(exprasmlist,hp.left.location.reference,href,elesize,freetemp,false);
 | 
					                       cg.g_concatcopy(exprasmlist,hp.left.location.reference,href,elesize,freetemp,false);
 | 
				
			||||||
                     end;
 | 
					                     end;
 | 
				
			||||||
                   else
 | 
					                   else
 | 
				
			||||||
                     begin
 | 
					                     begin
 | 
				
			||||||
                       if hp.left.location.size in [OS_64,OS_S64] then
 | 
					                       if hp.left.location.size in [OS_64,OS_S64] then
 | 
				
			||||||
                         cg64.a_load64_loc_ref(exprasmlist,hp.left.location,href)
 | 
					                         begin
 | 
				
			||||||
 | 
					                           cg64.a_load64_loc_ref(exprasmlist,hp.left.location,href);
 | 
				
			||||||
 | 
					                           location_release(exprasmlist,hp.left.location);
 | 
				
			||||||
 | 
					                         end
 | 
				
			||||||
                       else
 | 
					                       else
 | 
				
			||||||
                         cg.a_load_loc_ref(exprasmlist,hp.left.location.size,hp.left.location,href);
 | 
					                         begin
 | 
				
			||||||
 | 
					                           location_release(exprasmlist,hp.left.location);
 | 
				
			||||||
 | 
					                           cg.a_load_loc_ref(exprasmlist,hp.left.location.size,hp.left.location,href);
 | 
				
			||||||
 | 
					                         end;
 | 
				
			||||||
                     end;
 | 
					                     end;
 | 
				
			||||||
                 end;
 | 
					                 end;
 | 
				
			||||||
                 inc(href.offset,elesize);
 | 
					                 inc(href.offset,elesize);
 | 
				
			||||||
@ -905,7 +916,10 @@ begin
 | 
				
			|||||||
end.
 | 
					end.
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  $Log$
 | 
					  $Log$
 | 
				
			||||||
  Revision 1.84  2003-09-25 21:27:31  peter
 | 
					  Revision 1.85  2003-09-28 13:39:38  peter
 | 
				
			||||||
 | 
					    * optimized releasing of registers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Revision 1.84  2003/09/25 21:27:31  peter
 | 
				
			||||||
    * rearranged threadvar code so the result register is the same
 | 
					    * rearranged threadvar code so the result register is the same
 | 
				
			||||||
      for the relocated and address loaded variables
 | 
					      for the relocated and address loaded variables
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -635,13 +635,17 @@ implementation
 | 
				
			|||||||
            begin
 | 
					            begin
 | 
				
			||||||
              tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,r);
 | 
					              tg.GetTemp(list,TCGSize2Size[l.size],tt_normal,r);
 | 
				
			||||||
              if l.size in [OS_64,OS_S64] then
 | 
					              if l.size in [OS_64,OS_S64] then
 | 
				
			||||||
                cg64.a_load64_loc_ref(list,l,r)
 | 
					                begin
 | 
				
			||||||
 | 
					                  cg64.a_load64_loc_ref(list,l,r);
 | 
				
			||||||
 | 
					                  location_release(list,l);
 | 
				
			||||||
 | 
					                end
 | 
				
			||||||
              else
 | 
					              else
 | 
				
			||||||
                cg.a_load_loc_ref(list,l.size,l,r);
 | 
					                begin
 | 
				
			||||||
              location_release(list,l);
 | 
					                  location_release(list,l);
 | 
				
			||||||
 | 
					                  cg.a_load_loc_ref(list,l.size,l,r);
 | 
				
			||||||
 | 
					                end;
 | 
				
			||||||
              location_reset(l,LOC_REFERENCE,l.size);
 | 
					              location_reset(l,LOC_REFERENCE,l.size);
 | 
				
			||||||
              l.reference:=r;
 | 
					              l.reference:=r;
 | 
				
			||||||
 | 
					 | 
				
			||||||
            end;
 | 
					            end;
 | 
				
			||||||
          LOC_CREFERENCE,
 | 
					          LOC_CREFERENCE,
 | 
				
			||||||
          LOC_REFERENCE : ;
 | 
					          LOC_REFERENCE : ;
 | 
				
			||||||
@ -717,6 +721,7 @@ implementation
 | 
				
			|||||||
           else
 | 
					           else
 | 
				
			||||||
*)
 | 
					*)
 | 
				
			||||||
             begin
 | 
					             begin
 | 
				
			||||||
 | 
					               location_release(list,p.location);
 | 
				
			||||||
{$ifdef i386}
 | 
					{$ifdef i386}
 | 
				
			||||||
               case p.location.loc of
 | 
					               case p.location.loc of
 | 
				
			||||||
                 LOC_FPUREGISTER,
 | 
					                 LOC_FPUREGISTER,
 | 
				
			||||||
@ -769,13 +774,13 @@ implementation
 | 
				
			|||||||
               end;
 | 
					               end;
 | 
				
			||||||
{$endif i386}
 | 
					{$endif i386}
 | 
				
			||||||
             end;
 | 
					             end;
 | 
				
			||||||
           location_release(list,p.location);
 | 
					 | 
				
			||||||
         end
 | 
					         end
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
         begin
 | 
					         begin
 | 
				
			||||||
           { copy the value on the stack or use normal parameter push? }
 | 
					           { copy the value on the stack or use normal parameter push? }
 | 
				
			||||||
           if paramanager.copy_value_on_stack(varspez,p.resulttype.def,calloption) then
 | 
					           if paramanager.copy_value_on_stack(varspez,p.resulttype.def,calloption) then
 | 
				
			||||||
            begin
 | 
					            begin
 | 
				
			||||||
 | 
					              location_release(list,p.location);
 | 
				
			||||||
{$ifdef i386}
 | 
					{$ifdef i386}
 | 
				
			||||||
              if not (p.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
 | 
					              if not (p.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
 | 
				
			||||||
                internalerror(200204241);
 | 
					                internalerror(200204241);
 | 
				
			||||||
@ -817,9 +822,11 @@ implementation
 | 
				
			|||||||
                       else
 | 
					                       else
 | 
				
			||||||
*)
 | 
					*)
 | 
				
			||||||
                        cg64.a_param64_loc(list,p.location,locpara);
 | 
					                        cg64.a_param64_loc(list,p.location,locpara);
 | 
				
			||||||
 | 
					                        location_release(list,p.location);
 | 
				
			||||||
                     end
 | 
					                     end
 | 
				
			||||||
                    else
 | 
					                    else
 | 
				
			||||||
                     begin
 | 
					                     begin
 | 
				
			||||||
 | 
					                       location_release(list,p.location);
 | 
				
			||||||
                       inc(pushedparasize,alignment);
 | 
					                       inc(pushedparasize,alignment);
 | 
				
			||||||
(*
 | 
					(*
 | 
				
			||||||
                       if calloption=pocall_inline then
 | 
					                       if calloption=pocall_inline then
 | 
				
			||||||
@ -837,12 +844,12 @@ implementation
 | 
				
			|||||||
*)
 | 
					*)
 | 
				
			||||||
                        cg.a_param_loc(list,p.location,locpara);
 | 
					                        cg.a_param_loc(list,p.location,locpara);
 | 
				
			||||||
                     end;
 | 
					                     end;
 | 
				
			||||||
                    location_release(list,p.location);
 | 
					 | 
				
			||||||
                  end;
 | 
					                  end;
 | 
				
			||||||
{$ifdef SUPPORT_MMX}
 | 
					{$ifdef SUPPORT_MMX}
 | 
				
			||||||
                LOC_MMXREGISTER,
 | 
					                LOC_MMXREGISTER,
 | 
				
			||||||
                LOC_CMMXREGISTER:
 | 
					                LOC_CMMXREGISTER:
 | 
				
			||||||
                  begin
 | 
					                  begin
 | 
				
			||||||
 | 
					                     location_release(list,p.location);
 | 
				
			||||||
                     inc(pushedparasize,8);
 | 
					                     inc(pushedparasize,8);
 | 
				
			||||||
(*
 | 
					(*
 | 
				
			||||||
                     if calloption=pocall_inline then
 | 
					                     if calloption=pocall_inline then
 | 
				
			||||||
@ -2064,7 +2071,10 @@ implementation
 | 
				
			|||||||
end.
 | 
					end.
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  $Log$
 | 
					  $Log$
 | 
				
			||||||
  Revision 1.148  2003-09-25 21:28:00  peter
 | 
					  Revision 1.149  2003-09-28 13:39:38  peter
 | 
				
			||||||
 | 
					    * optimized releasing of registers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Revision 1.148  2003/09/25 21:28:00  peter
 | 
				
			||||||
    * parameter fixes
 | 
					    * parameter fixes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Revision 1.147  2003/09/23 21:03:59  peter
 | 
					  Revision 1.147  2003/09/23 21:03:59  peter
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user