* debugging register allocation

This commit is contained in:
mazen 2002-10-08 21:02:22 +00:00
parent 87d602ac5b
commit 754077f199

View File

@ -35,10 +35,10 @@ uses
cpubase, cpubase,
symconst,symbase,symtype,symdef,paramgr; symconst,symbase,symtype,symdef,paramgr;
type type
tSparcparamanager = class(tparamanager) TSparcParaManager=class(TParaManager)
function getintparaloc(nr : longint) : tparalocation;override; function GetIntParaLoc(nr:longint):TParaLocation;override;
procedure create_param_loc_info(p : tabstractprocdef);override; procedure create_param_loc_info(p:TAbstractProcDef);override;
function getfuncretparaloc(p : tabstractprocdef) : tparalocation;override; function GetFuncRetParaLoc(p:TAbstractProcDef):TParaLocation;override;
end; end;
implementation implementation
uses uses
@ -46,38 +46,38 @@ uses
globtype, globtype,
cpuinfo,cginfo,cgbase, cpuinfo,cginfo,cgbase,
defbase; defbase;
function TSparcParaManager.getintparaloc(nr:longint):TParaLocation; function TSparcParaManager.GetIntParaLoc(nr:longint):TParaLocation;
begin begin
FillChar(result,SizeOf(TParaLocation),0);
with Result do
if nr<1 if nr<1
then then
InternalError(2002070801) InternalError(2002100806);
else if nr<=8 FillChar(Result,SizeOf(TParaLocation),0);
then Dec(nr);
with Result do
if nr<6
then{The six first parameters are passed into registers}
begin begin
loc:=LOC_REGISTER; loc:=LOC_REGISTER;
register:=tregister(longint(R_O0)+nr); register:=TRegister(LongInt(R_O0)+nr);
WriteLn('-------------------------------------------');
end end
else else{The other parameters are passed into the frame}
begin begin
loc:=LOC_REFERENCE; loc:=LOC_REFERENCE;
reference.index:=stack_pointer_reg; reference.index:=frame_pointer_reg;
reference.offset:=(nr-8)*4; reference.offset:=-92-(nr-6)*4;
WriteLn('+++++++++++++++++++++++++++++++++++++++++++');
end; end;
end; end;
function GetParaLoc(p:TDef):TLoc;
function getparaloc(p : tdef) : tloc;
begin begin
{ Later, the LOC_REFERENCE is in most cases changed into LOC_REGISTER {Later, the LOC_REFERENCE is in most cases changed into LOC_REGISTER if
if push_addr_param for the def is true push_addr_param for the def is true}
} case p.DefType of
case p.deftype of OrdDef:
orddef: GetParaLoc:=LOC_REGISTER;
getparaloc:=LOC_REGISTER; FloatDef:
floatdef: GetParaLoc:=LOC_FPUREGISTER;
getparaloc:=LOC_FPUREGISTER;
enumdef: enumdef:
getparaloc:=LOC_REGISTER; getparaloc:=LOC_REGISTER;
pointerdef: pointerdef:
@ -121,51 +121,51 @@ function TSparcParaManager.getintparaloc(nr:longint):TParaLocation;
internalerror(2002071001); internalerror(2002071001);
end; end;
end; end;
procedure TSparcParaManager.create_param_loc_info(p:tabstractprocdef);
procedure tSparcparamanager.create_param_loc_info(p : tabstractprocdef);
var var
nextintreg,nextfloatreg,nextmmreg : tregister; nextintreg,nextfloatreg,nextmmreg : tregister;
stack_offset : aword; stack_offset : aword;
hp : tparaitem; hp : tparaitem;
loc : tloc; loc : tloc;
is_64bit: boolean; is_64bit: boolean;
begin begin
nextintreg:=R_O3; nextintreg:=R_O0;
nextfloatreg:=R_F1; nextfloatreg:=R_F0;
nextmmreg:=R_NONE; nextmmreg:=R_NONE;
stack_offset:=0; stack_offset:=92;
{pointer for structured results ?} {pointer for structured results ?}
if not is_void(p.rettype.def) then if not is_void(p.RetType.def)
begin then
if not(ret_in_reg(p.rettype.def)) then if not(ret_in_reg(p.rettype.def))
then
inc(nextintreg); inc(nextintreg);
end;
{frame pointer for nested procedures?} {frame pointer for nested procedures?}
{ inc(nextintreg); } { inc(nextintreg); }
{ constructor? } { constructor? }
{ destructor? } { destructor? }
hp:=tparaitem(p.para.last); WriteLn('***********************************************');
hp:=TParaItem(p.para.last);
while assigned(hp) do while assigned(hp) do
begin begin
loc:=getparaloc(hp.paratype.def); loc:=GetParaLoc(hp.paratype.def);
hp.paraloc.sp_fixup:=0; hp.paraloc.sp_fixup:=0;
case loc of case loc of
LOC_REGISTER: LOC_REGISTER:
begin begin
hp.paraloc.size := def_cgsize(hp.paratype.def); hp.paraloc.size:=def_cgSize(hp.paratype.def);
{ for things like formaldef } if hp.paraloc.size=OS_NO
if hp.paraloc.size = OS_NO then then
hp.paraloc.size:=OS_ADDR; hp.paraloc.size:=OS_ADDR;
is_64bit:=hp.paraloc.size in [OS_64,OS_S64]; is_64bit:=hp.paraloc.size in [OS_64,OS_S64];
if nextintreg<=tregister(ord(R_O4)-ord(is_64bit)) then if NextIntReg<=TRegister(ord(R_O5)-ord(is_64bit))
then
begin begin
WriteLn('Allocating ',std_reg2str[NextIntReg]);
hp.paraloc.loc:=LOC_REGISTER; hp.paraloc.loc:=LOC_REGISTER;
hp.paraloc.registerlow:=nextintreg; hp.paraloc.registerlow:=NextIntReg;
inc(nextintreg); inc(NextIntReg);
if is_64bit then if is_64bit
then
begin begin
hp.paraloc.registerhigh:=nextintreg; hp.paraloc.registerhigh:=nextintreg;
inc(nextintreg); inc(nextintreg);
@ -173,11 +173,12 @@ function TSparcParaManager.getintparaloc(nr:longint):TParaLocation;
end end
else else
begin begin
nextintreg := R_O5; nextintreg:=R_O6;
hp.paraloc.loc:=LOC_REFERENCE; hp.paraloc.loc:=LOC_REFERENCE;
hp.paraloc.reference.index:=stack_pointer_reg; hp.paraloc.reference.index:=stack_pointer_reg;
hp.paraloc.reference.offset:=stack_offset; hp.paraloc.reference.offset:=stack_offset;
if not is_64bit then if not is_64bit
then
inc(stack_offset,4) inc(stack_offset,4)
else else
inc(stack_offset,8); inc(stack_offset,8);
@ -291,12 +292,15 @@ function TSparcParaManager.getintparaloc(nr:longint):TParaLocation;
end; end;
end; end;
BEGIN begin
paramanager:=TSparcParaManager.create; ParaManager:=TSparcParaManager.create;
end. end.
{ {
$Log$ $Log$
Revision 1.3 2002-10-07 20:33:05 mazen Revision 1.4 2002-10-08 21:02:22 mazen
* debugging register allocation
Revision 1.3 2002/10/07 20:33:05 mazen
word alignement modified in g_stack_frame word alignement modified in g_stack_frame
Revision 1.2 2002/10/04 21:57:42 mazen Revision 1.2 2002/10/04 21:57:42 mazen