* factored out tcginnode.in_smallset

* indention changed to common compiler style

git-svn-id: trunk@22063 -
This commit is contained in:
florian 2012-08-11 22:07:36 +00:00
parent 9a82fb9eb4
commit c1bca748ee

View File

@ -41,7 +41,11 @@ interface
end;
Tsetparts=array[1..8] of Tsetpart;
{ tcginnode }
tcginnode = class(tinnode)
procedure in_smallset(uopsize: tcgsize; opdef: tdef; setbase: aint); virtual;
function pass_1: tnode;override;
procedure pass_generate_code;override;
protected
@ -178,6 +182,36 @@ implementation
end;
procedure tcginnode.in_smallset(uopsize: tcgsize; opdef: tdef; setbase: aint);
begin
{ location is always LOC_REGISTER }
location_reset(location, LOC_REGISTER, uopsize{def_cgsize(resultdef)});
{ allocate a register for the result }
location.register := cg.getintregister(current_asmdata.CurrAsmList, uopsize);
{**************************** SMALL SET **********************}
if left.location.loc=LOC_CONSTANT then
begin
hlcg.a_bit_test_const_loc_reg(current_asmdata.CurrAsmList,
right.resultdef, resultdef,
left.location.value-setbase, right.location,
location.register);
end
else
begin
hlcg.location_force_reg(current_asmdata.CurrAsmList, left.location,
left.resultdef, opdef, true);
register_maybe_adjust_setbase(current_asmdata.CurrAsmList, left.location,
setbase);
hlcg.a_bit_test_reg_loc_reg(current_asmdata.CurrAsmList, left.resultdef,
right.resultdef, resultdef, left.location.register, right.location,
location.register);
end;
location.size := def_cgsize(resultdef);
location.register := cg.makeregsize(current_asmdata.CurrAsmList,
location.register, location.size);
end;
function tcginnode.checkgenjumps(out setparts: Tsetparts; out numparts: byte;out use_small: boolean): boolean;
begin
{ check if we can use smallset operation using btl which is limited
@ -231,7 +265,6 @@ implementation
genjumps := checkgenjumps(setparts,numparts,use_small);
orgopsize := def_cgsize(left.resultdef);
orgopdef := left.resultdef;
uopsize := OS_32;
@ -364,34 +397,21 @@ implementation
{*****************************************************************}
{ NO JUMP TABLE GENERATION }
{*****************************************************************}
begin
{ We will now generated code to check the set itself, no jmps,
handle smallsets separate, because it allows faster checks }
if use_small then
begin
in_smallset(uopsize, opdef, setbase);
end
else
{************************** NOT SMALL SET ********************}
begin
{ location is always LOC_REGISTER }
location_reset(location, LOC_REGISTER, uopsize{def_cgsize(resultdef)});
{ allocate a register for the result }
location.register := cg.getintregister(current_asmdata.CurrAsmList, uopsize);
{ We will now generated code to check the set itself, no jmps,
handle smallsets separate, because it allows faster checks }
if use_small then
begin
{**************************** SMALL SET **********************}
if left.location.loc=LOC_CONSTANT then
begin
hlcg.a_bit_test_const_loc_reg(current_asmdata.CurrAsmList,right.resultdef,resultdef,
left.location.value-setbase,right.location,
location.register);
end
else
begin
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,opdef,true);
register_maybe_adjust_setbase(current_asmdata.CurrAsmList,left.location,setbase);
hlcg.a_bit_test_reg_loc_reg(current_asmdata.CurrAsmList,left.resultdef,
right.resultdef,resultdef,left.location.register,right.location,location.register);
end;
end
else
{************************** NOT SMALL SET ********************}
begin
if right.location.loc=LOC_CONSTANT then
begin
{ can it actually occur currently? CEC }
@ -470,12 +490,11 @@ implementation
if needslabel then
cg.a_label(current_asmdata.CurrAsmList, l2);
end;
location.size := def_cgsize(resultdef);
location.register := cg.makeregsize(current_asmdata.CurrAsmList, location.register, location.size);
end;
end;
location_freetemp(current_asmdata.CurrAsmList, right.location);
location.size := def_cgsize(resultdef);
location.register := cg.makeregsize(current_asmdata.CurrAsmList, location.register, location.size);
end;
{*****************************************************************************