1 / 20

Extended Basic Blocks & Dominators

Extended Basic Blocks & Dominators. Prof. M. Rajasekhara Babu School of Computing Science and Engineering mrajasekharababu@vit.ac.in http://www.mrajababu.com. OutLine. Re-Cap Extended Basic Blocks Definition Example Practice Problem Algorithm Dominators Introduction Properties

armen
Download Presentation

Extended Basic Blocks & Dominators

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Extended Basic Blocks & Dominators Prof. M. Rajasekhara Babu School of Computing Science and Engineering mrajasekharababu@vit.ac.in http://www.mrajababu.com

  2. OutLine • Re-Cap • Extended Basic Blocks • Definition • Example • Practice Problem • Algorithm • Dominators • Introduction • Properties • Example & Practice Problem • Strict Dominators • Post Dominators • Immediate Dominators • Assignment • References

  3. Re-Cap 1. List of other Intermediate Representation? 2. Distinguish between Syntax tree and DAG 3. Tell about structure of Quadruples 4. Tell about structure of Triples 5. List functions to create syntax tree

  4. Objectives & Teaching Learning Material • Session Objectives • To provide the knowledge on Extended basic blocks and dominators. • At the end topic student able to identify Extended basic blocks and able to compute dominators of CFG. • Teaching Learning Material • LCD, White board Marker, Presentation slides

  5. Session Plan

  6. Extended Basic Blocks An extended basic block is defined as maximal sub graph of CFG which doesn't have join nodes An EBB is a set of blocks B1 B2 B3…….Bn where Bi may have multiple predecessors and every other Bi has a unique predecessor. The block Bi form a tree that can be entered only at its root B1 Bcan have multiple exits

  7. Example Entry B1 Root Nodes: {Entry, B1,B4,B5,Exit} B3 B2 Successor nodes for Root Node Entry {Entry} B4 Successor nodes for Root Node B1 {B1,B2,B3} Successor nodes for Root Node B4 {B4,B6} B5 B6 Successor nodes for Root Node B5 {B5,B7} B7 Successor nodes for Root Node Exit {Exit} Exit

  8. Entry Example A Root Nodes: C B Successor nodes for Root Node Entry E D Successor nodes for Root Node Successor nodes for Root Node F Successor nodes for Root Node G Successor nodes for Root Node Exit Exit

  9. Dominators & PostDominators • Introduction: • Dominator is a binary relation on a flow graph nodes • Dominance is the one of the oldest idea in compilation • Computation of Dominators • In a CFG, node ‘i’ denotes node j if every path from the entry node to j passes through i. • i dominates j , written as I dom j

  10. Properties of Dominators • Reflexive: Evey node dominates inteslf • Transitive If a dom b and b dom c then a dom c • Antisymmetric if a dom b and b dom a then b=a

  11. 1 2 3 4 5 7 6 8 9 10 Example

  12. Strict Dominators • A CFG node M strictly dominates (M Sdom N ) iff M dom N and M≠N • A Node can’t strictly dominates itself • N Sdom N is never true • Data flow Equation to compute Dominators Dom(n)={n} u (∩pЄ Pred(n) DOM(P))

  13. Immediate Dominators • If a CFG node has more than one dominator ( Which is common), there is always a unique closet dominator called its Immediate Dominators. • Immediate dominator m that is the last dominator of n on any path from the initial node to n • Using immediate dominators, we can create a dominator tree in which A→B in the dominator tree if and only if (A idom B).

  14. Algorithm Temp(n) Dominators(n)-{n} 1.Identify strict Dominators 2. r entry For each n Є N-{r} do For each S Є Temp(n) do if t Є Temp(n) then Temp(n)=Temp(n)-{s} For each n Є N-{r} do Idom(n) =Temp(n) Return Idom

  15. 1 2 3 4 5 7 6 8 9 10 Example

  16. Post Dominators • A block Z postdominates a block Y (Z pdom Y) if and only if all paths from Y to an exit block must pass through Z. • Notions of immediate postdominance and a postdominator tree carry over. • If a node p post dominates node i, written as p dom i.

  17. Assignment • Write a pseudo code for the computation of Extended Basic Block ( Ref: Steven Muchnick: Advanced Compiler Design and Implementation. Morgan Kaufmann, 1997, page No:175,176,177) • Write C /java code to compute dominators, immediate dominators and post dominators ( Ref: Steven Muchnick: Advanced Compiler Design and Implementation. Morgan Kaufmann, 1997,

  18. References • Steven Muchnick: Advanced Compiler Design and Implementation. Morgan Kaufmann, 1997 • Alfred Aho, Ravi Sethi, Jeffrey Ullman, Monica Lam: 21st Century Compilers. Addison-Wesley, 2004.

More Related