* keep upper bound of loops in a register instead of in memory

git-svn-id: trunk@2105 -
This commit is contained in:
Jonas Maebe 2006-01-01 17:02:34 +00:00
parent 9603f4bf82
commit 3f86e6b728
3 changed files with 30 additions and 6 deletions

View File

@ -305,6 +305,9 @@ interface
{ return the inverse condition of opcmp }
function inverse_opcmp(opcmp: topcmp): topcmp;{$ifdef USEINLINE}inline;{$endif}
{ return the opcmp needed when swapping the operands }
function swap_opcmp(opcmp: topcmp): topcmp;{$ifdef USEINLINE}inline;{$endif}
{ return whether op is commutative }
function commutativeop(op: topcg): boolean;{$ifdef USEINLINE}inline;{$endif}
@ -551,6 +554,16 @@ implementation
end;
function swap_opcmp(opcmp: topcmp): topcmp;{$ifdef USEINLINE}inline;{$endif}
const
list: array[TOpCmp] of TOpCmp =
(OC_NONE,OC_EQ,OC_LT,OC_GT,OC_LTE,OC_GTE,OC_NE,OC_AE,OC_A,
OC_BE,OC_B);
begin
swap_opcmp := list[opcmp];
end;
function commutativeop(op: topcg): boolean;{$ifdef USEINLINE}inline;{$endif}
const
list: array[topcg] of boolean =

View File

@ -264,6 +264,7 @@ unit cgobj;
procedure a_cmp_ref_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const ref: treference; reg : tregister; l : tasmlabel); virtual;
procedure a_cmp_reg_ref_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg : tregister; const ref: treference; l : tasmlabel); virtual;
procedure a_cmp_loc_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const loc: tlocation; reg : tregister; l : tasmlabel);
procedure a_cmp_reg_loc_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; reg: tregister; const loc: tlocation; l : tasmlabel);
procedure a_cmp_ref_loc_label(list: taasmoutput; size: tcgsize;cmp_op: topcmp; const ref: treference; const loc: tlocation;
l : tasmlabel);
@ -1220,6 +1221,12 @@ implementation
end;
procedure tcg.a_cmp_reg_loc_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; reg: tregister; const loc: tlocation; l : tasmlabel);
begin
a_cmp_loc_reg_label(list,size,swap_opcmp(cmp_op),loc,reg,l);
end;
procedure tcg.a_cmp_loc_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp; const loc: tlocation; reg : tregister; l : tasmlabel);
begin
case loc.loc of

View File

@ -332,7 +332,7 @@ implementation
var
l3,oldclabel,oldblabel : tasmlabel;
temptovalue : boolean;
temp1 : treference;
// temp1 : tregister;
hop : topcg;
hcond : topcmp;
opsize : tcgsize;
@ -368,10 +368,14 @@ implementation
if t1.nodetype<>ordconstn then
begin
do_loopvar_at_end:=false;
tg.GetTemp(exprasmlist,t1.resulttype.def.size,tt_normal,temp1);
location_force_reg(exprasmlist,t1.location,t1.location.size,true);
temptovalue:=true;
{
temp1 := cg.getintregister(exprasmlist,
tg.GetTemp(exprasmlist,t1.resulttype.def.size,tt_normal,temp1);
cg.a_load_loc_ref(exprasmlist,opsize,t1.location,temp1);
location_freetemp(exprasmlist,t1.location);
}
end
else
temptovalue:=false;
@ -407,8 +411,8 @@ implementation
if temptovalue then
begin
cg.a_cmp_ref_loc_label(exprasmlist,opsize,hcond,
temp1,left.location,aktbreaklabel);
cg.a_cmp_reg_loc_label(exprasmlist,opsize,hcond,
t1.location.register,left.location,aktbreaklabel);
end
else
begin
@ -504,9 +508,9 @@ implementation
{ jump }
if temptovalue then
begin
cg.a_cmp_ref_loc_label(exprasmlist,opsize,hcond,temp1,
cg.a_cmp_reg_loc_label(exprasmlist,opsize,hcond,t1.location.register,
left.location,l3);
tg.ungetiftemp(exprasmlist,temp1);
{ tg.ungetiftemp(exprasmlist,temp1); }
end
else
begin