diff options
author | Christoph Bumiller <[email protected]> | 2013-02-27 15:32:35 +0100 |
---|---|---|
committer | Christoph Bumiller <[email protected]> | 2013-03-12 12:55:36 +0100 |
commit | 1b4faa2b1717225a0c7b08a227436091d5fdceaf (patch) | |
tree | 6513a54d7d38e3455ff643948aad003c34a149d6 /src | |
parent | 1535b754fbf386c8953b8b66999dc7b4d4682de5 (diff) |
nv50/ir/ssa: add a few comments regarding RenamePass
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp index 175e9b5a4c6..16f08d3e76e 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp @@ -441,12 +441,21 @@ bool RenamePass::run() return true; } +// Go through BBs in dominance order, create new values for each definition, +// and replace all sources with their current new values. +// +// NOTE: The values generated for function inputs/outputs have no connection +// to their corresponding outputs/inputs in other functions. Only allocation +// of physical registers will establish this connection. +// void RenamePass::search(BasicBlock *bb) { LValue *lval, *ssa; int d, s; const Target *targ = prog->getTarget(); + // Put current definitions for function inputs values on the stack. + // They can be used before any redefinitions are pushed. if (bb == BasicBlock::get(func->cfg.getRoot())) { for (std::deque<ValueDef>::iterator it = func->ins.begin(); it != func->ins.end(); ++it) { @@ -463,11 +472,15 @@ void RenamePass::search(BasicBlock *bb) } for (Instruction *stmt = bb->getFirst(); stmt; stmt = stmt->next) { + // PHI sources get definitions from the passes through the incident BBs, + // so skip them here. if (stmt->op != OP_PHI) { for (s = 0; stmt->srcExists(s); ++s) { lval = stmt->getSrc(s)->asLValue(); if (!lval) continue; + // Values on the stack created in previously visited blocks, and + // function inputs, will be valid because they dominate this one. lval = getStackTop(lval); if (!lval) lval = mkUndefined(stmt->getSrc(s)); @@ -485,6 +498,7 @@ void RenamePass::search(BasicBlock *bb) } } + // Update sources of PHI ops corresponding to this BB in outgoing BBs. for (Graph::EdgeIterator ei = bb->cfg.outgoing(); !ei.end(); ei.next()) { Instruction *phi; int p = 0; @@ -506,9 +520,12 @@ void RenamePass::search(BasicBlock *bb) } } + // Visit the BBs we dominate. for (Graph::EdgeIterator ei = bb->dom.outgoing(); !ei.end(); ei.next()) search(BasicBlock::get(ei.getNode())); + // Update function outputs to the last definitions of their pre-SSA values. + // I hope they're unique, i.e. that we get PHIs for all of them ... if (bb == BasicBlock::get(func->cfgExit)) { for (std::deque<ValueRef>::iterator it = func->outs.begin(); it != func->outs.end(); ++it) { @@ -522,6 +539,8 @@ void RenamePass::search(BasicBlock *bb) } } + // Pop the values we created in this block from the stack because we will + // return to blocks that we do not dominate. for (Instruction *stmt = bb->getFirst(); stmt; stmt = stmt->next) { if (stmt->op == OP_NOP) continue; |