m68k: Fix handling of small sets (based on how ARM does it)

Fixes 12 tests

git-svn-id: trunk@25589 -
This commit is contained in:
svenbarth 2013-09-28 08:17:13 +00:00
parent 83f4344c20
commit 4d1fb1573e

View File

@ -483,82 +483,57 @@ implementation
procedure t68kaddnode.second_cmpsmallset; procedure t68kaddnode.second_cmpsmallset;
var var
leftreg, tmpreg : tregister;
rightreg : tregister;
begin begin
pass_left_right; pass_left_right;
location_reset(location,LOC_FLAGS,OS_NO); location_reset(location,LOC_FLAGS,OS_NO);
if (not(nf_swapped in flags) and
(nodetype = lten)) or
((nf_swapped in flags) and
(nodetype = gten)) then
swapleftright;
{ Try to keep right as a constant }
if right.location.loc<>LOC_CONSTANT then
hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
case nodetype of case nodetype of
equaln, equaln,
unequaln : unequaln:
begin begin
{emit_compare(true);} if right.location.loc=LOC_CONSTANT then
end; current_asmdata.CurrAsmList.concat(taicpu.op_const_reg(A_CMP,S_L,right.location.value,left.location.register))
lten,gten: else
begin current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,S_L,right.location.register,left.location.register));
if (not(nf_swapped in flags) and if nodetype=equaln then
(nodetype = lten)) or location.resflags:=F_E
((nf_swapped in flags) and else
(nodetype = gten)) then location.resflags:=F_NE;
swapleftright; end;
// now we have to check whether left >= right lten,
gten:
// first load right into a register begin
case right.location.loc of tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
LOC_CONSTANT: if right.location.loc=LOC_CONSTANT then
begin begin
rightreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT); current_asmdata.CurrAsmList.concat(taicpu.op_const_reg(A_MOVE,S_L,right.location.value,tmpreg));
cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT, current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_AND,S_L,tmpreg,left.location.register));
aword(right.location.value),rightreg); current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,S_L,tmpreg,left.location.register));
end; end
LOC_REFERENCE: else
begin begin
rightreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT); current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_MOVE,S_L,right.location.register,tmpreg));
cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_INT,OS_INT,right.location.reference,rightreg); current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_AND,S_L,tmpreg,left.location.register));
end; current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,S_L,tmpreg,left.location.register));
LOC_REGISTER: end;
begin location.resflags:=F_E;
rightreg:=right.location.register; end;
end; else
else internalerror(2013092701);
internalerror(2012102001); end;
end;
// now process left
case left.location.loc of
LOC_CONSTANT:
begin
leftreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_AND,OS_INT,
not(left.location.value),rightreg,leftreg);
current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_TST,S_L,leftreg));
// the two instructions above should be folded together by
// the peepholeoptimizer
end;
LOC_REFERENCE:
begin
leftreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_INT,OS_INT,left.location.reference,leftreg);
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_AND,S_L,
rightreg,leftreg));
end;
LOC_REGISTER:
begin
current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_AND,S_L,
rightreg,left.location.register));
end;
else
internalerror(2012102002);
end;
location.resflags := getresflags(true);
end;
else
internalerror(2002072701);
end;
end; end;