




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Mahlke; Class: Advanced Compilers; Subject: Electrical Engineering And Computer Science; University: University of Michigan - Ann Arbor; Term: Winter 2002;
Typology: Study notes
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















Announcements^ Y^ Preliminary course webpage is available
”, by Kathail,
Rau, Schlansker, http://www.hpl.hp.com/techreports/93/HPL-93-80R1.pdf » “EPIC: An Architecture For Instruction-Level ParallelProcessors”, by Schlansker and Rau http://www.hpl.hp.com/techreports/1999/HPL-1999-111.pdf » “On Predicated Execution”, by Park and Schlansker” http://www.hpl.hp.com/techreports/91/HPL-91-58.pdf
Compiler backend IR – Our input^ Y^ Variable home location »^ Frontend – every variable in memory »^ Backend – maximal but safe register promotion^ y^
All temporaries put into registers y All local scalars put into registers, except those accessed via & y All globals, local arrays/structs, unpromotable local scalars put inmemory. Accessed via load/store.
machine independent assembly code – really resource indep! » aka RTL (register transfer language), 3-address code » r1 = r2 + r3 or equivalently add r1, r2, r3^ y^ Opcode – not machine independent (HPL-PD, RISC++)^ y^ Operands^ X^
Virtual registers – infinite number of these X Special registers – stack pointer, pc, etc (macro regs) X Literals – compile-time constants
Control flow^ Y^ Control transfer = branch (taken or fall-through)^ Y^ Control flow
Identifying BBs - Example
L1: r7 = load(r8) L2: r1 = r2 + r3 L3: beq r1, 0, L10 L4: r4 = r5 * r6 L5: r1 = r1 + 1 L6: beq r1 100 L2 L7: beq r2 100 L10 L8: r5 = r9 + 1 L9: r7 = r7 & 3 L10: r9 = load (r3) L11: store(r9, r1)
Control flow graph (CFG)^ Y^ Defn Control Flow Graph
Directed graph, G = (V,E)where each vertex V is abasic block and there is anedge E, v1 (BB1)
Æ^ v2 (BB2) if BB2 can immediately followBB1 in some executionsequence^ »^ A BB has an edge to allblocks it can branch to^ »^ Standard representationused by many compilers^ »^ Often have 2 pseudo V’s^ y^
entry node y exit node
Entry^ BB1 BB2^ BB3^ BB4 BB5 BB6^ BB7^ Exit
Dominator^ Y^ Defn: Dominator
Dominator example
Entry^ BB1 BB2^ BB3^ BB4 BB5 BB6^ BB7^ Exit
Entry
BB1 BB6 Exit
Immediate dominator^ Y^ Defn: Immediate dominator^ (idom)– Each node n has aunique immediate dominatorm that is the last dominatorof n on any path from theinitial node to n »^ Closest node that dominates
Entry^ BB1 BB2^ BB3^ BB4 BB5 BB6^ BB7^ Exit
Post dominator^ Y^ Defn: Post Dominator
Post dominator analysis^ Y^ Compute pdom(BBi) = set ofBBs that post dominate BBi^ Y^ Initialization »^ Pdom(exit) = exit »^ Pdom(everything else) = allnodesIterative computation Y »^ while change, do^ y^
change = false y for each BB (except the exitBB)^ X^ tmp(BB) = BB +{intersect of pdom ofall successor BB’s}^ X^ if (tmp(BB) != pdom(BB))^ ± pdom(BB) = tmp(BB) ± change = true
Entry^ BB1 BB2^ BB3^ BB4 BB5 BB6^ BB7^ Exit
Immediate post dominator^ Y^ Defn: Immediate post^ dominator
(ipdom) – Each node n has a uniqueimmediate post dominator mthat is the first postdominator of n on any pathfrom n to the Exit^ »^ Closest node that postdominates^ »^ First breadth-firstsuccessor that postdominates a node
Entry^ BB1 BB2^ BB3^ BB4 BB5 BB6^ BB7^ Exit
Backedge example
Entry
BB1 BB6 Exit
Loop detection^ Y^ Identify all backedges using Dom info^ Y^ Each backedge (x
»^ Loop header is the backedge target (y) »^ Loop BB – basic blocks that comprise the loop^ y^
All predecessor blocks of x for which control can reach x withoutgoing through y are in the loop
I.e., a loop with 2 continues » LoopBackedge = LoopBackedge1 + LoopBackedge2 » LoopBB = LoopBB1 + LoopBB
Header dominates all LoopBB