* don't try to reuse registers from left/right, impedes optimal register

allocation

git-svn-id: trunk@3669 -
This commit is contained in:
Jonas Maebe 2006-05-25 11:31:32 +00:00
parent 5601c2c1a1
commit a20f211811

View File

@ -111,43 +111,15 @@ interface
procedure load_node(var n: tnode); procedure load_node(var n: tnode);
begin begin
case n.location.loc of case n.location.loc of
LOC_REGISTER,
LOC_CREGISTER: LOC_CREGISTER:
; ;
LOC_REGISTER:
if (not cmpop) and
((nodetype <> muln) or
not is_64bit(resulttype.def)) then
begin
location.register := n.location.register;
if is_64bit(n.resulttype.def) then
location.register64.reghi := n.location.register64.reghi;
end;
LOC_REFERENCE,LOC_CREFERENCE: LOC_REFERENCE,LOC_CREFERENCE:
begin location_force_reg(current_asmdata.CurrAsmList,n.location,def_cgsize(n.resulttype.def),false);
location_force_reg(current_asmdata.CurrAsmList,n.location,def_cgsize(n.resulttype.def),false);
if (not cmpop) and
((nodetype <> muln) or
not is_64bit(resulttype.def)) then
begin
location.register := n.location.register;
if is_64bit(n.resulttype.def) then
location.register64.reghi := n.location.register64.reghi;
end;
end;
LOC_CONSTANT: LOC_CONSTANT:
begin begin
if load_constants then if load_constants then
begin location_force_reg(current_asmdata.CurrAsmList,n.location,def_cgsize(n.resulttype.def),false);
location_force_reg(current_asmdata.CurrAsmList,n.location,def_cgsize(n.resulttype.def),false);
if (not cmpop) and
((nodetype <> muln) or
not is_64bit(resulttype.def)) then
begin
location.register := n.location.register;
if is_64bit(n.resulttype.def) then
location.register64.reghi := n.location.register64.reghi;
end;
end;
end; end;
else else
location_force_reg(current_asmdata.CurrAsmList,n.location,def_cgsize(n.resulttype.def),false); location_force_reg(current_asmdata.CurrAsmList,n.location,def_cgsize(n.resulttype.def),false);
@ -159,10 +131,8 @@ interface
load_node(right); load_node(right);
if not(cmpop) then if not(cmpop) then
begin begin
if (location.register = NR_NO) then location.register := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
location.register := cg.getintregister(current_asmdata.CurrAsmList,OS_INT); if is_64bit(resulttype.def) then
if is_64bit(resulttype.def) and
(location.register64.reghi = NR_NO) then
location.register64.reghi := cg.getintregister(current_asmdata.CurrAsmList,OS_INT); location.register64.reghi := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
end; end;
end; end;
@ -468,12 +438,7 @@ interface
if not cmpop then if not cmpop then
begin begin
location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def)); location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
if left.location.loc = LOC_FPUREGISTER then location.register := cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
location.register := left.location.register
else if right.location.loc = LOC_FPUREGISTER then
location.register := right.location.register
else
location.register := cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
end end
else else
begin begin
@ -526,8 +491,7 @@ interface
load_left_right(cmpop,false); load_left_right(cmpop,false);
if not(cmpop) and if not(cmpop) then
(location.register = NR_NO) then
location.register := cg.getintregister(current_asmdata.CurrAsmList,OS_INT); location.register := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
case nodetype of case nodetype of
@ -916,11 +880,8 @@ interface
end; end;
xorn,orn,andn,addn: xorn,orn,andn,addn:
begin begin
if (location.register64.reglo = NR_NO) then location.register64.reglo := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
begin location.register64.reghi := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
location.register64.reglo := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
location.register64.reghi := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
end;
if (left.location.loc = LOC_CONSTANT) then if (left.location.loc = LOC_CONSTANT) then
swapleftright; swapleftright;
@ -933,13 +894,10 @@ interface
end; end;
subn: subn:
begin begin
location.register64.reglo := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
location.register64.reghi := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
if left.location.loc <> LOC_CONSTANT then if left.location.loc <> LOC_CONSTANT then
begin begin
if (location.register64.reglo = NR_NO) then
begin
location.register64.reglo := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
location.register64.reghi := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
end;
if right.location.loc <> LOC_CONSTANT then if right.location.loc <> LOC_CONSTANT then
// reg64 - reg64 // reg64 - reg64
cg64.a_op64_reg_reg_reg(current_asmdata.CurrAsmList,OP_SUB,location.size, cg64.a_op64_reg_reg_reg(current_asmdata.CurrAsmList,OP_SUB,location.size,
@ -953,11 +911,6 @@ interface
end end
else if ((left.location.value64 shr 32) = 0) then else if ((left.location.value64 shr 32) = 0) then
begin begin
if (location.register64.reglo = NR_NO) then
begin
location.register64.reglo := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
location.register64.reghi := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
end;
if (int64(left.location.value64) >= low(smallint)) and if (int64(left.location.value64) >= low(smallint)) and
(int64(left.location.value64) <= high(smallint)) then (int64(left.location.value64) <= high(smallint)) then
begin begin
@ -981,11 +934,6 @@ interface
else if (aint(left.location.value64) = 0) then else if (aint(left.location.value64) = 0) then
begin begin
// (const32 shl 32) - reg64 // (const32 shl 32) - reg64
if (location.register64.reglo = NR_NO) then
begin
location.register64.reglo := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
location.register64.reghi := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
end;
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_SUBFIC, current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_SUBFIC,
location.register64.reglo,right.location.register64.reglo,0)); location.register64.reglo,right.location.register64.reglo,0));
left.location.value64 := left.location.value64 shr 32; left.location.value64 := left.location.value64 shr 32;
@ -999,13 +947,6 @@ interface
// const64 - reg64 // const64 - reg64
location_force_reg(current_asmdata.CurrAsmList,left.location, location_force_reg(current_asmdata.CurrAsmList,left.location,
def_cgsize(left.resulttype.def),false); def_cgsize(left.resulttype.def),false);
if (left.location.loc = LOC_REGISTER) then
location.register64 := left.location.register64
else if (location.register64.reglo = NR_NO) then
begin
location.register64.reglo := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
location.register64.reghi := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
end;
cg64.a_op64_reg_reg_reg(current_asmdata.CurrAsmList,OP_SUB,location.size, cg64.a_op64_reg_reg_reg(current_asmdata.CurrAsmList,OP_SUB,location.size,
right.location.register64,left.location.register64, right.location.register64,left.location.register64,
location.register64); location.register64);
@ -1367,8 +1308,7 @@ interface
load_left_right(cmpop, (cs_check_overflow in aktlocalswitches) and load_left_right(cmpop, (cs_check_overflow in aktlocalswitches) and
(nodetype in [addn,subn,muln])); (nodetype in [addn,subn,muln]));
if (location.register = NR_NO) and if not(cmpop) then
not(cmpop) then
location.register := cg.getintregister(current_asmdata.CurrAsmList,OS_INT); location.register := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
if not(cs_check_overflow in aktlocalswitches) or if not(cs_check_overflow in aktlocalswitches) or