* converted all non-x86-specific and non-32bit-specific code to use hlcgobj

git-svn-id: branches/jvmbackend@18281 -
This commit is contained in:
Jonas Maebe 2011-08-20 07:21:21 +00:00
parent 72e9cfee24
commit 2cb4514c07

View File

@ -74,7 +74,8 @@ interface
symconst,symdef,paramgr, symconst,symdef,paramgr,
aasmbase,aasmtai,aasmdata,defutil, aasmbase,aasmtai,aasmdata,defutil,
cgbase,procinfo,pass_2,tgobj, cgbase,procinfo,pass_2,tgobj,
nutils,ncon,nset,ncgutil,cgobj,cgutils nutils,ncon,nset,ncgutil,cgobj,cgutils,
hlcgobj
; ;
@ -108,7 +109,7 @@ interface
end; end;
secondpass(left); secondpass(left);
if left.location.loc in [LOC_FLAGS,LOC_JUMP] then if left.location.loc in [LOC_FLAGS,LOC_JUMP] then
location_force_reg(current_asmdata.CurrAsmList,left.location,def_cgsize(resultdef),false); hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,resultdef,false);
if isjump then if isjump then
begin begin
current_procinfo.CurrTrueLabel:=otl; current_procinfo.CurrTrueLabel:=otl;
@ -136,7 +137,7 @@ interface
end; end;
secondpass(right); secondpass(right);
if right.location.loc in [LOC_FLAGS,LOC_JUMP] then if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
location_force_reg(current_asmdata.CurrAsmList,right.location,def_cgsize(resultdef),false); hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,resultdef,false);
if isjump then if isjump then
begin begin
current_procinfo.CurrTrueLabel:=otl; current_procinfo.CurrTrueLabel:=otl;
@ -213,7 +214,7 @@ interface
end end
else else
{$endif} {$endif}
location.register := cg.getintregister(current_asmdata.CurrAsmList,location.size); location.register := hlcg.getintregister(current_asmdata.CurrAsmList,resultdef);
end; end;
end; end;
@ -225,14 +226,14 @@ interface
allow_constant and allow_constant and
(left.location.loc in [LOC_CONSTANT,LOC_CREGISTER]) (left.location.loc in [LOC_CONSTANT,LOC_CREGISTER])
) then ) then
location_force_reg(current_asmdata.CurrAsmList,left.location,left.location.size,false); hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
if (right.location.loc<>LOC_REGISTER) and if (right.location.loc<>LOC_REGISTER) and
not( not(
allow_constant and allow_constant and
(right.location.loc in [LOC_CONSTANT,LOC_CREGISTER]) and (right.location.loc in [LOC_CONSTANT,LOC_CREGISTER]) and
(left.location.loc<>LOC_CONSTANT) (left.location.loc<>LOC_CONSTANT)
) then ) then
location_force_reg(current_asmdata.CurrAsmList,right.location,right.location.size,false); hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,false);
{ Left is always a register, right can be register or constant } { Left is always a register, right can be register or constant }
if left.location.loc=LOC_CONSTANT then if left.location.loc=LOC_CONSTANT then
@ -305,11 +306,11 @@ interface
internalerror(2010123001); internalerror(2010123001);
{ make sure we don't modify left/right.location, because we told { make sure we don't modify left/right.location, because we told
force_reg_left_right above that they can be constant } force_reg_left_right above that they can be constant }
cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NOT,location.size,right.location.register,location.register); hlcg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NOT,resultdef,right.location.register,location.register);
if left.location.loc = LOC_CONSTANT then if left.location.loc = LOC_CONSTANT then
cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_AND,location.size,left.location.value,location.register) hlcg.a_op_const_reg(current_asmdata.CurrAsmList,OP_AND,resultdef,left.location.value,location.register)
else else
cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_AND,location.size,left.location.register,location.register); hlcg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_AND,resultdef,left.location.register,location.register);
end; end;
end; end;
else else
@ -322,11 +323,11 @@ interface
if (left.location.loc = LOC_CONSTANT) then if (left.location.loc = LOC_CONSTANT) then
swapleftright; swapleftright;
if (right.location.loc = LOC_CONSTANT) then if (right.location.loc = LOC_CONSTANT) then
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,cgop,location.size, hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,cgop,resultdef,
right.location.value,left.location.register, right.location.value,left.location.register,
location.register) location.register)
else else
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,cgop,location.size, hlcg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,cgop,resultdef,
right.location.register,left.location.register, right.location.register,left.location.register,
location.register); location.register);
end; end;
@ -359,7 +360,7 @@ interface
mask:=aint((aword(1) shl (resultdef.size*8-1)) shr aword(right.location.value-setbase)) mask:=aint((aword(1) shl (resultdef.size*8-1)) shr aword(right.location.value-setbase))
else else
mask:=aint(1 shl (right.location.value-setbase)); mask:=aint(1 shl (right.location.value-setbase));
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_OR,location.size, hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_OR,resultdef,
mask,left.location.register,location.register); mask,left.location.register,location.register);
end end
else else
@ -374,17 +375,17 @@ interface
mask:=1; mask:=1;
cgop:=OP_SHL cgop:=OP_SHL
end; end;
tmpreg := cg.getintregister(current_asmdata.CurrAsmList,location.size); tmpreg:=hlcg.getintregister(current_asmdata.CurrAsmList,resultdef);
cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,mask,tmpreg); hlcg.a_load_const_reg(current_asmdata.CurrAsmList,resultdef,mask,tmpreg);
location_force_reg(current_asmdata.CurrAsmList,right.location,location.size,true); hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,resultdef,true);
register_maybe_adjust_setbase(current_asmdata.CurrAsmList,right.location,setbase); register_maybe_adjust_setbase(current_asmdata.CurrAsmList,right.location,setbase);
cg.a_op_reg_reg(current_asmdata.CurrAsmList,cgop,location.size, hlcg.a_op_reg_reg(current_asmdata.CurrAsmList,cgop,resultdef,
right.location.register,tmpreg); right.location.register,tmpreg);
if left.location.loc <> LOC_CONSTANT then if left.location.loc <> LOC_CONSTANT then
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_OR,location.size,tmpreg, hlcg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_OR,resultdef,tmpreg,
left.location.register,location.register) left.location.register,location.register)
else else
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_OR,location.size, hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_OR,resultdef,
left.location.value,tmpreg,location.register); left.location.value,tmpreg,location.register);
end; end;
end; end;
@ -422,8 +423,8 @@ interface
otl:=current_procinfo.CurrTrueLabel; otl:=current_procinfo.CurrTrueLabel;
current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel); current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
secondpass(left); secondpass(left);
maketojumpbool(current_asmdata.CurrAsmList,left,lr_load_regvars); hlcg.maketojumpbool(current_asmdata.CurrAsmList,left);
cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel); hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
current_procinfo.CurrTrueLabel:=otl; current_procinfo.CurrTrueLabel:=otl;
end; end;
orn : orn :
@ -431,8 +432,8 @@ interface
ofl:=current_procinfo.CurrFalseLabel; ofl:=current_procinfo.CurrFalseLabel;
current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel); current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
secondpass(left); secondpass(left);
maketojumpbool(current_asmdata.CurrAsmList,left,lr_load_regvars); hlcg.maketojumpbool(current_asmdata.CurrAsmList,left);
cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel); hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
current_procinfo.CurrFalseLabel:=ofl; current_procinfo.CurrFalseLabel:=ofl;
end; end;
else else
@ -443,7 +444,7 @@ interface
include(flowcontrol,fc_inflowcontrol); include(flowcontrol,fc_inflowcontrol);
secondpass(right); secondpass(right);
maketojumpbool(current_asmdata.CurrAsmList,right,lr_load_regvars); hlcg.maketojumpbool(current_asmdata.CurrAsmList,right);
flowcontrol:=oldflowcontrol+(flowcontrol-[fc_inflowcontrol]); flowcontrol:=oldflowcontrol+(flowcontrol-[fc_inflowcontrol]);
end end
@ -479,11 +480,11 @@ interface
{$endif cpu64bitalu} {$endif cpu64bitalu}
begin begin
if right.location.loc <> LOC_CONSTANT then if right.location.loc <> LOC_CONSTANT then
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,cgop,location.size, hlcg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,cgop,resultdef,
left.location.register,right.location.register, left.location.register,right.location.register,
location.register) location.register)
else else
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,cgop,location.size, hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,cgop,resultdef,
right.location.value,left.location.register, right.location.value,left.location.register,
location.register); location.register);
end; end;
@ -554,10 +555,10 @@ interface
xorn,orn,andn,addn: xorn,orn,andn,addn:
begin begin
if (right.location.loc = LOC_CONSTANT) then if (right.location.loc = LOC_CONSTANT) then
cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,op,location.size,right.location.value, hlcg.a_op_const_reg_reg(current_asmdata.CurrAsmList,op,resultdef,right.location.value,
left.location.register,location.register) left.location.register,location.register)
else else
cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,op,location.size,right.location.register, hlcg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,op,resultdef,right.location.register,
left.location.register,location.register); left.location.register,location.register);
end; end;
subn: subn:
@ -569,20 +570,20 @@ interface
begin begin
if right.location.loc <> LOC_CONSTANT then if right.location.loc <> LOC_CONSTANT then
// reg64 - reg64 // reg64 - reg64
cg.a_op_reg_reg_reg_checkoverflow(current_asmdata.CurrAsmList,OP_SUB,location.size, hlcg.a_op_reg_reg_reg_checkoverflow(current_asmdata.CurrAsmList,OP_SUB,resultdef,
right.location.register,left.location.register,location.register, right.location.register,left.location.register,location.register,
checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc) checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc)
else else
// reg64 - const64 // reg64 - const64
cg.a_op_const_reg_reg_checkoverflow(current_asmdata.CurrAsmList,OP_SUB,location.size, hlcg.a_op_const_reg_reg_checkoverflow(current_asmdata.CurrAsmList,OP_SUB,resultdef,
right.location.value,left.location.register,location.register, right.location.value,left.location.register,location.register,
checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc); checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc);
end end
else else
begin begin
// const64 - reg64 // const64 - reg64
location_force_reg(current_asmdata.CurrAsmList,left.location,left.location.size,true); hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
cg.a_op_reg_reg_reg_checkoverflow(current_asmdata.CurrAsmList,OP_SUB,location.size, hlcg.a_op_reg_reg_reg_checkoverflow(current_asmdata.CurrAsmList,OP_SUB,resultdef,
right.location.register,left.location.register,location.register, right.location.register,left.location.register,location.register,
checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc); checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc);
end; end;
@ -640,7 +641,7 @@ interface
{ emit overflow check if enabled } { emit overflow check if enabled }
if checkoverflow then if checkoverflow then
cg.g_overflowcheck_loc(current_asmdata.CurrAsmList,Location,resultdef,ovloc); hlcg.g_overflowcheck_loc(current_asmdata.CurrAsmList,Location,resultdef,ovloc);
end; end;
@ -743,11 +744,11 @@ interface
if nodetype<>subn then if nodetype<>subn then
begin begin
if (right.location.loc<>LOC_CONSTANT) then if (right.location.loc<>LOC_CONSTANT) then
cg.a_op_reg_reg_reg_checkoverflow(current_asmdata.CurrAsmList,cgop,location.size, hlcg.a_op_reg_reg_reg_checkoverflow(current_asmdata.CurrAsmList,cgop,resultdef,
left.location.register,right.location.register, left.location.register,right.location.register,
location.register,checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc) location.register,checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc)
else else
cg.a_op_const_reg_reg_checkoverflow(current_asmdata.CurrAsmList,cgop,location.size, hlcg.a_op_const_reg_reg_checkoverflow(current_asmdata.CurrAsmList,cgop,resultdef,
right.location.value,left.location.register, right.location.value,left.location.register,
location.register,checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc); location.register,checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc);
end end
@ -758,27 +759,27 @@ interface
if left.location.loc<>LOC_CONSTANT then if left.location.loc<>LOC_CONSTANT then
begin begin
if right.location.loc<>LOC_CONSTANT then if right.location.loc<>LOC_CONSTANT then
cg.a_op_reg_reg_reg_checkoverflow(current_asmdata.CurrAsmList,OP_SUB,location.size, hlcg.a_op_reg_reg_reg_checkoverflow(current_asmdata.CurrAsmList,OP_SUB,resultdef,
right.location.register,left.location.register, right.location.register,left.location.register,
location.register,checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc) location.register,checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc)
else else
cg.a_op_const_reg_reg_checkoverflow(current_asmdata.CurrAsmList,OP_SUB,location.size, hlcg.a_op_const_reg_reg_checkoverflow(current_asmdata.CurrAsmList,OP_SUB,resultdef,
right.location.value,left.location.register, right.location.value,left.location.register,
location.register,checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc); location.register,checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc);
end end
else else
begin begin
tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size); tmpreg:=hlcg.getintregister(current_asmdata.CurrAsmList,resultdef);
cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size, hlcg.a_load_const_reg(current_asmdata.CurrAsmList,resultdef,
left.location.value,tmpreg); left.location.value,tmpreg);
cg.a_op_reg_reg_reg_checkoverflow(current_asmdata.CurrAsmList,OP_SUB,location.size, hlcg.a_op_reg_reg_reg_checkoverflow(current_asmdata.CurrAsmList,OP_SUB,resultdef,
right.location.register,tmpreg,location.register,checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc); right.location.register,tmpreg,location.register,checkoverflow and (cs_check_overflow in current_settings.localswitches),ovloc);
end; end;
end; end;
{ emit overflow check if required } { emit overflow check if required }
if checkoverflow then if checkoverflow then
cg.g_overflowcheck_loc(current_asmdata.CurrAsmList,Location,resultdef,ovloc); hlcg.g_overflowcheck_loc(current_asmdata.CurrAsmList,Location,resultdef,ovloc);
end; end;