mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 23:30:18 +02:00
+ dfa for more node types
git-svn-id: trunk@7560 -
This commit is contained in:
parent
b5e048691c
commit
496d73dc9d
@ -48,7 +48,7 @@ unit optdfa;
|
|||||||
defutil,
|
defutil,
|
||||||
procinfo,
|
procinfo,
|
||||||
nutils,
|
nutils,
|
||||||
nbas,nflw,ncon,ninl,ncal,
|
nbas,nflw,ncon,ninl,ncal,nset,
|
||||||
optbase,optutils;
|
optbase,optutils;
|
||||||
|
|
||||||
|
|
||||||
@ -184,6 +184,7 @@ unit optdfa;
|
|||||||
var
|
var
|
||||||
dfainfo : tdfainfo;
|
dfainfo : tdfainfo;
|
||||||
l : TDFASet;
|
l : TDFASet;
|
||||||
|
i : longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if node=nil then
|
if node=nil then
|
||||||
@ -244,6 +245,7 @@ unit optdfa;
|
|||||||
end;
|
end;
|
||||||
calclife(node);
|
calclife(node);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
statementn:
|
statementn:
|
||||||
begin
|
begin
|
||||||
{ nested statement }
|
{ nested statement }
|
||||||
@ -251,12 +253,14 @@ unit optdfa;
|
|||||||
{ inherit info }
|
{ inherit info }
|
||||||
node.optinfo^.life:=tstatementnode(node).statement.optinfo^.life;
|
node.optinfo^.life:=tstatementnode(node).statement.optinfo^.life;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
blockn:
|
blockn:
|
||||||
begin
|
begin
|
||||||
CreateInfo(tblocknode(node).statements);
|
CreateInfo(tblocknode(node).statements);
|
||||||
if assigned(tblocknode(node).statements) then
|
if assigned(tblocknode(node).statements) then
|
||||||
node.optinfo^.life:=tblocknode(node).statements.optinfo^.life;
|
node.optinfo^.life:=tblocknode(node).statements.optinfo^.life;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ifn:
|
ifn:
|
||||||
begin
|
begin
|
||||||
{ get information from cond. expression }
|
{ get information from cond. expression }
|
||||||
@ -284,11 +288,50 @@ unit optdfa;
|
|||||||
else
|
else
|
||||||
if assigned(node.successor) then
|
if assigned(node.successor) then
|
||||||
DFASetIncludeSet(l,node.successor.optinfo^.life);
|
DFASetIncludeSet(l,node.successor.optinfo^.life);
|
||||||
{ add use info from cond. expression }
|
{ add use info from the cond. expression }
|
||||||
DFASetIncludeSet(l,tifnode(node).optinfo^.use);
|
DFASetIncludeSet(l,tifnode(node).optinfo^.use);
|
||||||
{ finally, update the life info of the node }
|
{ finally, update the life info of the node }
|
||||||
UpdateLifeInfo(node,l);
|
UpdateLifeInfo(node,l);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
casen:
|
||||||
|
begin
|
||||||
|
{ get information from "case" expression }
|
||||||
|
if not(assigned(node.optinfo^.def)) and
|
||||||
|
not(assigned(node.optinfo^.use)) then
|
||||||
|
begin
|
||||||
|
dfainfo.use:=@node.optinfo^.use;
|
||||||
|
dfainfo.def:=@node.optinfo^.def;
|
||||||
|
dfainfo.map:=map;
|
||||||
|
foreachnodestatic(pm_postprocess,tcasenode(node).left,@AddDefUse,@dfainfo);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ create life info for block and else nodes }
|
||||||
|
for i:=0 to tcasenode(node).blocks.count-1 do
|
||||||
|
CreateInfo(pcaseblock(tcasenode(node).blocks[i])^.statement);
|
||||||
|
|
||||||
|
CreateInfo(tcasenode(node).elseblock);
|
||||||
|
|
||||||
|
{ ensure that we don't remove life info }
|
||||||
|
l:=node.optinfo^.life;
|
||||||
|
|
||||||
|
{ get life info from case branches }
|
||||||
|
for i:=0 to tcasenode(node).blocks.count-1 do
|
||||||
|
DFASetIncludeSet(l,pcaseblock(tcasenode(node).blocks[i])^.statement.optinfo^.life);
|
||||||
|
|
||||||
|
{ get life info from else branch or the succesor }
|
||||||
|
if assigned(tcasenode(node).elseblock) then
|
||||||
|
DFASetIncludeSet(l,tcasenode(node).elseblock.optinfo^.life)
|
||||||
|
else
|
||||||
|
if assigned(node.successor) then
|
||||||
|
DFASetIncludeSet(l,node.successor.optinfo^.life);
|
||||||
|
|
||||||
|
{ add use info from the "case" expression }
|
||||||
|
DFASetIncludeSet(l,tcasenode(node).optinfo^.use);
|
||||||
|
|
||||||
|
{ finally, update the life info of the node }
|
||||||
|
UpdateLifeInfo(node,l);
|
||||||
|
end;
|
||||||
exitn:
|
exitn:
|
||||||
begin
|
begin
|
||||||
if not(is_void(current_procinfo.procdef.returndef)) then
|
if not(is_void(current_procinfo.procdef.returndef)) then
|
||||||
|
@ -47,7 +47,7 @@ unit optutils;
|
|||||||
uses
|
uses
|
||||||
verbose,
|
verbose,
|
||||||
optbase,
|
optbase,
|
||||||
nbas,nflw,nutils;
|
nbas,nflw,nutils,nset;
|
||||||
|
|
||||||
function TIndexedNodeSet.Add(node : tnode) : boolean;
|
function TIndexedNodeSet.Add(node : tnode) : boolean;
|
||||||
var
|
var
|
||||||
@ -142,6 +142,7 @@ unit optutils;
|
|||||||
function DoSet(p : tnode;succ : tnode) : tnode;
|
function DoSet(p : tnode;succ : tnode) : tnode;
|
||||||
var
|
var
|
||||||
hp1,hp2 : tnode;
|
hp1,hp2 : tnode;
|
||||||
|
i : longint;
|
||||||
begin
|
begin
|
||||||
result:=nil;
|
result:=nil;
|
||||||
if p=nil then
|
if p=nil then
|
||||||
@ -245,15 +246,36 @@ unit optutils;
|
|||||||
result:=p;
|
result:=p;
|
||||||
p.successor:=nil;
|
p.successor:=nil;
|
||||||
end;
|
end;
|
||||||
inlinen,
|
casen:
|
||||||
calln,
|
begin
|
||||||
|
result:=p;
|
||||||
|
DoSet(tcasenode(p).elseblock,succ);
|
||||||
|
for i:=0 to tcasenode(p).blocks.count-1 do
|
||||||
|
DoSet(pcaseblock(tcasenode(p).blocks[i])^.statement,succ);
|
||||||
|
p.successor:=succ;
|
||||||
|
end;
|
||||||
|
calln:
|
||||||
|
begin
|
||||||
|
{ not sure if this is enough (FK) }
|
||||||
|
result:=p;
|
||||||
|
p.successor:=succ;
|
||||||
|
end;
|
||||||
|
inlinen:
|
||||||
|
begin
|
||||||
|
{ not sure if this is enough (FK) }
|
||||||
|
result:=p;
|
||||||
|
p.successor:=succ;
|
||||||
|
end;
|
||||||
|
nothingn:
|
||||||
|
begin
|
||||||
|
result:=p;
|
||||||
|
p.successor:=succ;
|
||||||
|
end;
|
||||||
withn,
|
withn,
|
||||||
casen,
|
|
||||||
tryexceptn,
|
tryexceptn,
|
||||||
raisen,
|
raisen,
|
||||||
tryfinallyn,
|
tryfinallyn,
|
||||||
onn,
|
onn:
|
||||||
nothingn:
|
|
||||||
internalerror(2007050501);
|
internalerror(2007050501);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user