* code reformatted

This commit is contained in:
mazen 2003-10-29 14:42:14 +00:00
parent 2d061f8108
commit 81123566d3

View File

@ -1755,109 +1755,100 @@ implementation
helpins:Tai; helpins:Tai;
op:Tasmop; op:Tasmop;
pos:Tai; pos:Tai;
wasload: boolean;
procedure DoSpill2RegInstructions; procedure DoSpill2RegInstructions;
var
wasload: boolean;
begin begin
if (oper[1]^.typ=top_ref) and { oper[1] can also be ref in case of "lis r3,symbol@ha" or so }
{ oper[1] can also be ref in case of "lis r3,symbol@ha" or so } if not((oper[1]^.typ=top_ref) and
spilling_decode_loadstore(opcode,op,wasload) then spilling_decode_loadstore(opcode,op,wasload)) then
Exit;
{ the register that's being stored/loaded }
supreg:=getsupreg(oper[0]^.reg);
if supregset_in(r,supreg) then
begin begin
{ the register that's being stored/loaded } // Example:
supreg:=getsupreg(oper[0]^.reg); // l?? r20d, 8(r1) ; r20d must be spilled into -60(r1)
if supregset_in(r,supreg) then //
// Change into:
//
// l?? r21d, 8(r1)
// st? r21d, -60(r1)
//
// And:
//
// st? r20d, 8(r1) ; r20d must be spilled into -60(r1)
//
// Change into:
//
// l?? r21d, -60(r1)
// st? r21d, 8(r1)
pos := get_insert_pos(Tai(previous),supreg,
getsupreg(oper[1]^.ref^.base),
getsupreg(oper[1]^.ref^.index),
unusedregsint);
rgget(list,pos,R_SUBWHOLE,helpreg);
spill_registers := true;
if wasload then
begin begin
// Example: helpins:=spilling_create_loadstore(opcode,helpreg,oper[1]^.ref^);
// l?? r20d, 8(r1) ; r20d must be spilled into -60(r1) loadref(1,spilltemplist[supreg]);
// opcode := op;
// Change into: end
// else
// l?? r21d, 8(r1) helpins:=spilling_create_loadstore(op,helpreg,spilltemplist[supreg]);
// st? r21d, -60(r1) if pos=nil then
// list.insertafter(helpins,list.first)
// And: else
// list.insertafter(helpins,pos.next);
// st? r20d, 8(r1) ; r20d must be spilled into -60(r1) loadreg(0,helpreg);
// rgunget(list,helpins,helpreg);
// Change into: forward_allocation(tai(helpins.next),unusedregsint);
// { list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);}
// l?? r21d, -60(r1) end;
// st? r21d, 8(r1)
{ now the registers used in the reference }
pos := get_insert_pos(Tai(previous),supreg, { a) base }
getsupreg(oper[1]^.ref^.base), supreg := getsupreg(oper[1]^.ref^.base);
getsupreg(oper[1]^.ref^.index), if supregset_in(r,supreg) then
unusedregsint); begin
rgget(list,pos,R_SUBWHOLE,helpreg); if wasload then
spill_registers := true; pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.index),getsupreg(oper[0]^.reg),0,unusedregsint)
if wasload then else
begin pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.index),0,0,unusedregsint);
helpins:=spilling_create_loadstore(opcode,helpreg,oper[1]^.ref^); rgget(list,pos,R_SUBWHOLE,helpreg);
loadref(1,spilltemplist[supreg]); spill_registers:=true;
opcode := op; helpins:=spilling_create_load(spilltemplist[supreg],helpreg);
end if pos=nil then
else list.insertafter(helpins,list.first)
helpins:=spilling_create_loadstore(op,helpreg,spilltemplist[supreg]); else
if pos=nil then list.insertafter(helpins,pos.next);
list.insertafter(helpins,list.first) oper[1]^.ref^.base:=helpreg;
else rgunget(list,helpins,helpreg);
list.insertafter(helpins,pos.next); forward_allocation(Tai(helpins.next),unusedregsint);
loadreg(0,helpreg); { list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);}
rgunget(list,helpins,helpreg); end;
forward_allocation(tai(helpins.next),unusedregsint);
{ { b) index }
writeln('spilling!'); supreg := getsupreg(oper[1]^.ref^.index);
list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins); if supregset_in(r,supreg) then
} begin
end; if wasload then
pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.base),getsupreg(oper[0]^.reg),0,unusedregsint)
{ now the registers used in the reference } else
{ a) base } pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.base),0,0,unusedregsint);
supreg := getsupreg(oper[1]^.ref^.base); rgget(list,pos,R_SUBWHOLE,helpreg);
if supregset_in(r,supreg) then spill_registers:=true;
begin helpins:=spilling_create_load(spilltemplist[supreg],helpreg);
if wasload then if pos=nil then
pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.index),getsupreg(oper[0]^.reg),0,unusedregsint) list.insertafter(helpins,list.first)
else else
pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.index),0,0,unusedregsint); list.insertafter(helpins,pos.next);
rgget(list,pos,R_SUBWHOLE,helpreg); oper[1]^.ref^.index:=helpreg;
spill_registers:=true; rgunget(list,helpins,helpreg);
helpins:=spilling_create_load(spilltemplist[supreg],helpreg); forward_allocation(Tai(helpins.next),unusedregsint);
if pos=nil then { list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);}
list.insertafter(helpins,list.first)
else
list.insertafter(helpins,pos.next);
oper[1]^.ref^.base:=helpreg;
rgunget(list,helpins,helpreg);
forward_allocation(Tai(helpins.next),unusedregsint);
{
writeln('spilling!');
list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
}
end;
{ b) index }
supreg := getsupreg(oper[1]^.ref^.index);
if supregset_in(r,supreg) then
begin
if wasload then
pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.base),getsupreg(oper[0]^.reg),0,unusedregsint)
else
pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.base),0,0,unusedregsint);
rgget(list,pos,R_SUBWHOLE,helpreg);
spill_registers:=true;
helpins:=spilling_create_load(spilltemplist[supreg],helpreg);
if pos=nil then
list.insertafter(helpins,list.first)
else
list.insertafter(helpins,pos.next);
oper[1]^.ref^.index:=helpreg;
rgunget(list,helpins,helpreg);
forward_allocation(Tai(helpins.next),unusedregsint);
{
writeln('spilling!');
list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
}
end;
end; end;
end; end;
@ -1866,7 +1857,7 @@ implementation
i:byte; i:byte;
begin begin
if oper[0]^.typ <> top_reg then if oper[0]^.typ <> top_reg then
exit; Exit;
reg1 := getsupreg(oper[0]^.reg); reg1 := getsupreg(oper[0]^.reg);
if oper[1]^.typ = top_reg then if oper[1]^.typ = top_reg then
reg2 := getsupreg(oper[1]^.reg) reg2 := getsupreg(oper[1]^.reg)
@ -1903,10 +1894,7 @@ implementation
loadreg(0,helpreg); loadreg(0,helpreg);
rgunget(list,helpins,helpreg); rgunget(list,helpins,helpreg);
forward_allocation(tai(helpins.next),unusedregsint); forward_allocation(tai(helpins.next),unusedregsint);
{ { list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);}
writeln('spilling!');
list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
}
end; end;
for i := 1 to 2 do for i := 1 to 2 do
@ -1935,10 +1923,7 @@ implementation
loadreg(i,helpreg); loadreg(i,helpreg);
rgunget(list,helpins,helpreg); rgunget(list,helpins,helpreg);
forward_allocation(tai(helpins.next),unusedregsint); forward_allocation(tai(helpins.next),unusedregsint);
{ { list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);}
writeln('spilling!');
list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
}
end; end;
end; end;
end; end;
@ -1946,7 +1931,7 @@ implementation
spill_registers:=false; spill_registers:=false;
case ops of case ops of
0,1: 0,1:
Exit; {Mazen : Do no thing like in a delay slot for sparc : nop;};
2: 2:
DoSpill2RegInstructions; DoSpill2RegInstructions;
3: 3:
@ -2153,7 +2138,10 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.49 2003-10-29 14:05:45 mazen Revision 1.50 2003-10-29 14:42:14 mazen
* code reformatted
Revision 1.49 2003/10/29 14:05:45 mazen
* Splling function devided to sub functions to make it easy to understand. * Splling function devided to sub functions to make it easy to understand.
This commit is just to allow easy diffs to validate the migration (hint use -w) This commit is just to allow easy diffs to validate the migration (hint use -w)