nitc :: PhiFunction :: defaultinit
# A PhiFunction is a kind of Variable used in SSA-construction,
# it is placed at the beginning of a BasicBlock with many incoming blocks
class PhiFunction
super Variable
# The dependences of this variable for SSA-Algorithm
var dependences = new Array[Couple[Variable, BasicBlock]]
# The position in the AST of the phi-function
var block: BasicBlock
# Set the dependences for the phi-function
# *`block` BasicBlock in which we go through the dominance-frontier
# *`v` The variable to looking for
fun add_dependences(block: BasicBlock, v: Variable)
do
# Look in which blocks of DF(block) `v` has been assigned
for b in block.predecessors do
if v.assignment_blocks.has(b) then
var dep = new Couple[Variable, BasicBlock](v, b)
dependences.add(dep)
end
end
end
# Print the PhiFunction with all its dependences
redef fun to_s: String
do
var s = ""
s += " dependences = [ "
for d in dependences do
s += d.first.to_s + " "
end
s += "]"
return s
end
end
src/ssa.nit:159,1--196,3