* 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 //
begin // Change into:
// Example: //
// l?? r20d, 8(r1) ; r20d must be spilled into -60(r1) // l?? r21d, 8(r1)
// // st? r21d, -60(r1)
// Change into: //
// // And:
// l?? r21d, 8(r1) //
// st? r21d, -60(r1) // st? r20d, 8(r1) ; r20d must be spilled into -60(r1)
// //
// And: // Change into:
// //
// st? r20d, 8(r1) ; r20d must be spilled into -60(r1) // l?? r21d, -60(r1)
// // st? r21d, 8(r1)
// Change into:
//
// l?? r21d, -60(r1)
// st? r21d, 8(r1)
pos := get_insert_pos(Tai(previous),supreg, pos := get_insert_pos(Tai(previous),supreg,
getsupreg(oper[1]^.ref^.base), getsupreg(oper[1]^.ref^.base),
getsupreg(oper[1]^.ref^.index), getsupreg(oper[1]^.ref^.index),
unusedregsint); unusedregsint);
rgget(list,pos,R_SUBWHOLE,helpreg); rgget(list,pos,R_SUBWHOLE,helpreg);
spill_registers := true; spill_registers := true;
if wasload then if wasload then
begin
helpins:=spilling_create_loadstore(opcode,helpreg,oper[1]^.ref^);
loadref(1,spilltemplist[supreg]);
opcode := op;
end
else
helpins:=spilling_create_loadstore(op,helpreg,spilltemplist[supreg]);
if pos=nil then
list.insertafter(helpins,list.first)
else
list.insertafter(helpins,pos.next);
loadreg(0,helpreg);
rgunget(list,helpins,helpreg);
forward_allocation(tai(helpins.next),unusedregsint);
{
writeln('spilling!');
list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
}
end;
{ now the registers used in the reference }
{ a) base }
supreg := getsupreg(oper[1]^.ref^.base);
if supregset_in(r,supreg) then
begin begin
if wasload then helpins:=spilling_create_loadstore(opcode,helpreg,oper[1]^.ref^);
pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.index),getsupreg(oper[0]^.reg),0,unusedregsint) loadref(1,spilltemplist[supreg]);
else opcode := op;
pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.index),0,0,unusedregsint); end
rgget(list,pos,R_SUBWHOLE,helpreg); else
spill_registers:=true; helpins:=spilling_create_loadstore(op,helpreg,spilltemplist[supreg]);
helpins:=spilling_create_load(spilltemplist[supreg],helpreg); if pos=nil then
if pos=nil then list.insertafter(helpins,list.first)
list.insertafter(helpins,list.first) else
else list.insertafter(helpins,pos.next);
list.insertafter(helpins,pos.next); loadreg(0,helpreg);
oper[1]^.ref^.base:=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);}
{ end;
writeln('spilling!');
list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
}
end;
{ b) index } { now the registers used in the reference }
supreg := getsupreg(oper[1]^.ref^.index); { a) base }
if supregset_in(r,supreg) then supreg := getsupreg(oper[1]^.ref^.base);
begin if supregset_in(r,supreg) then
if wasload then begin
pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.base),getsupreg(oper[0]^.reg),0,unusedregsint) if wasload then
else pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.index),getsupreg(oper[0]^.reg),0,unusedregsint)
pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.base),0,0,unusedregsint); else
rgget(list,pos,R_SUBWHOLE,helpreg); pos:=get_insert_pos(Tai(previous),getsupreg(oper[1]^.ref^.index),0,0,unusedregsint);
spill_registers:=true; rgget(list,pos,R_SUBWHOLE,helpreg);
helpins:=spilling_create_load(spilltemplist[supreg],helpreg); spill_registers:=true;
if pos=nil then helpins:=spilling_create_load(spilltemplist[supreg],helpreg);
list.insertafter(helpins,list.first) if pos=nil then
else list.insertafter(helpins,list.first)
list.insertafter(helpins,pos.next); else
oper[1]^.ref^.index:=helpreg; list.insertafter(helpins,pos.next);
rgunget(list,helpins,helpreg); oper[1]^.ref^.base:=helpreg;
forward_allocation(Tai(helpins.next),unusedregsint); rgunget(list,helpins,helpreg);
{ forward_allocation(Tai(helpins.next),unusedregsint);
writeln('spilling!'); { list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);}
list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins); end;
}
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);
{ list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);}
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)