|
@@ -27,7 +27,8 @@ unit optutils;
|
|
|
|
|
|
uses
|
|
|
cclasses,
|
|
|
- node;
|
|
|
+ node,
|
|
|
+ globtype;
|
|
|
|
|
|
type
|
|
|
{ this implementation should be really improved,
|
|
@@ -47,12 +48,16 @@ unit optutils;
|
|
|
}
|
|
|
procedure CalcDefSum(p : tnode);
|
|
|
|
|
|
+ { calculates/estimates the field execution weight of optinfo }
|
|
|
+ procedure CalcExecutionWeights(p : tnode;Initial : AWord = 100);
|
|
|
+
|
|
|
{ returns true, if n is a valid node and has life info }
|
|
|
function has_life_info(n : tnode) : boolean;
|
|
|
|
|
|
implementation
|
|
|
|
|
|
uses
|
|
|
+ cutils,
|
|
|
verbose,
|
|
|
optbase,
|
|
|
ncal,nbas,nflw,nutils,nset,ncon;
|
|
@@ -352,6 +357,49 @@ unit optutils;
|
|
|
end;
|
|
|
|
|
|
|
|
|
+ function SetExecutionWeight(var n: tnode; arg: pointer): foreachnoderesult;
|
|
|
+ var
|
|
|
+ Weight : AWord absolute arg;
|
|
|
+ i : Integer;
|
|
|
+ begin
|
|
|
+ Result:=fen_false;
|
|
|
+ n.allocoptinfo;
|
|
|
+ case n.nodetype of
|
|
|
+ casen:
|
|
|
+ begin
|
|
|
+ CalcExecutionWeights(tcasenode(n).left,Weight);
|
|
|
+ for i:=0 to tcasenode(n).blocks.count-1 do
|
|
|
+ CalcExecutionWeights(pcaseblock(tcasenode(n).blocks[i])^.statement,max(1,Weight div case_count_labels(tcasenode(n).labels)));
|
|
|
+
|
|
|
+ CalcExecutionWeights(tcasenode(n).elseblock,max(1,Weight div case_count_labels(tcasenode(n).labels)));
|
|
|
+ Result:=fen_norecurse_false;
|
|
|
+ end;
|
|
|
+ whilerepeatn:
|
|
|
+ begin
|
|
|
+ CalcExecutionWeights(twhilerepeatnode(n).right,max(Weight,1)*8);
|
|
|
+ CalcExecutionWeights(twhilerepeatnode(n).left,max(Weight,1)*8);
|
|
|
+ Result:=fen_norecurse_false;
|
|
|
+ end;
|
|
|
+ ifn:
|
|
|
+ begin
|
|
|
+ CalcExecutionWeights(tifnode(n).left,Weight);
|
|
|
+ CalcExecutionWeights(tifnode(n).right,max(Weight div 2,1));
|
|
|
+ CalcExecutionWeights(tifnode(n).t1,max(Weight div 2,1));
|
|
|
+ Result:=fen_norecurse_false;
|
|
|
+ end;
|
|
|
+ else
|
|
|
+ n.optinfo^.executionweight:=AWord(arg);
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
+ procedure CalcExecutionWeights(p : tnode;Initial : AWord = 100);
|
|
|
+ begin
|
|
|
+ if assigned(p) then
|
|
|
+ foreachnodestatic(pm_postprocess,p,@SetExecutionWeight,Pointer(Initial));
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
function has_life_info(n : tnode) : boolean;
|
|
|
begin
|
|
|
result:=assigned(n) and assigned(n.optinfo) and
|