Open leozp opened 5 years ago
A program is in SSA-form iff each variable has exactly one definition.
An explicit dependency graph (EDG) is a directed, marked graph. The nodes are marked with a signature of ΣEDG, which is their operation. The nodes have ordered in- and outputs. Their number and order correspond to the parameters and results of the respective term in ΣEDG. The in- and outputs are marked with types of TEDG. Edges connect outs with ins of the same type.
Two non-null paths X0 →+ XJ and Y0 →+ YK are said to converge at a block Z iff the following conditions hold: X0 ̸=Y0; (1) XJ =Z=YK; (2) (Xj =Yk)⇒(j=J∨k=K). (3)
A φ-function for variable v is necessary in block Z iff two non-null paths X →+ Z and Y →+ Z converge at a block Z, such that the blocks X and Y contain assignments to v.
A (control) flow graph G is reducible iff for each cycle C of G there is a node of C which dominates all other nodes in C.
SSA
Static Single Assignment form, where each variable is assigned exactly once.
EDG
explicit dependency graph
Proj
extract values from tuples
φ-functions
the insertion of special φ-functions at places where different assignments meet.
Phi-Nodes
Phi-nodes for example are an exception, because the behavior that all Phi-nodes must be evaluated simultaneously at beginning of a basic block is not represented with edges.
CFG
control flow graph
Mature
We use this knowledge to improve our construction algorithm: Blocks with known predecessors are called mature other blocks immature.
If we have to create additional φ-functions in a mature block, we will immediately calculate their arguments. Obviously the φ can be omitted if a mature block has exactly 1 predecessor.
A second simplification called REMOVEUNNECESSARYPHI is applied when all arguments of a φ-function have been determined
only create φ-functions as a result of a situation where someone will use it
φ-functions for a variable v only occur at basic blocks where different definitions of v meet for the first time.
Add B × Num × Num → Num
Alloc B × M × Num → M × P
And B × Num × Num → Num
ASM B × variable → variable
Bad → Any
Block X0 × · · · × Xn →→ B
Call B×Num0 ×···×Numk ×M →Num0 ×···×Numk ×M
Cmp B×Num×Num→b0 ×···×b15
Cond B×b→X×X
Const → Num
Conv B × Num → Num
Div B × Num × Num → Num
End B×X→
Eor B × Num × Num → Num
Free B → M × P × Num
Jmp B→X
Load B × P × M → Num × M
Minus B × Num → Num
Mod B × Num × Num → Num
Mul B × Num × Num → Num
Mux B×b×Num×Num→Num
NoMem →M
Not B × Num → Num
Or B × Num × Num → Num
Phi B×Num0 ×···×Numn →Num
Proj B×T →Num
Return B × M × N um0 × · · · × N umn → X
Rotl B×Num×Num→Num
Sel B×M×P→M×P
Shl B×Num×Num→Num
Shr B×Num×Num→Num
Shrs B×Num×Num→Num
Start B→X×M×P×P×T
Store B × M × P × Num → M
Sub B×Num×Num→Num
SymConst B×P
Sync B × M0 × · · · × Mn → M
Unknown → Any
FIRM—A Graph-Based Intermediate Representation
FIRM Node Types and Signatures
FIRM construction optimizes
Arithmetic Simplification (implicit)
Common Subexpression Elimination (implicit)
Constant Folding (implicit)
Copy Propagation (inherent)
Dead Code Elimination (inherent)