X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fnv50%2Fcodegen%2Fnv50_ir_bb.cpp;h=6515ba7e0c9a4e79f8acf2bf9d1542511057553b;hb=1e957941735fae514de658c836b8bdaf6c66bc06;hp=e6f3c353a1be1490754a200dd6d0a9496849cdeb;hpb=da28ba00d84f59650bf180769d9d9a1609eb6164;p=mesa.git diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp index e6f3c353a1b..6515ba7e0c9 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp @@ -24,8 +24,9 @@ namespace nv50_ir { -Function::Function(Program *p, const char *fnName) +Function::Function(Program *p, const char *fnName, uint32_t label) : call(this), + label(label), name(fnName), prog(p) { @@ -45,6 +46,8 @@ Function::Function(Program *p, const char *fnName) Function::~Function() { + prog->del(this, id); + if (domTree) delete domTree; if (bbArray) @@ -80,6 +83,26 @@ BasicBlock::~BasicBlock() // nothing yet } +BasicBlock * +BasicBlock::clone(ClonePolicy& pol) const +{ + BasicBlock *bb = new BasicBlock(pol.context()); + + pol.set(this, bb); + + for (Instruction *i = getFirst(); i; i = i->next) + bb->insertTail(i->clone(pol)); + + pol.context()->cfg.insert(&bb->cfg); + + for (Graph::EdgeIterator it = cfg.outgoing(); !it.end(); it.next()) { + BasicBlock *obb = BasicBlock::get(it.getNode()); + bb->cfg.attach(&pol.get(obb)->cfg, it.getType()); + } + + return bb; +} + BasicBlock * BasicBlock::idom() const { @@ -382,19 +405,37 @@ Function::setExit(BasicBlock *bb) unsigned int Function::orderInstructions(ArrayList &result) { - Iterator *iter; - for (iter = cfg.iteratorCFG(); !iter->end(); iter->next()) { + for (IteratorRef it = cfg.iteratorCFG(); !it->end(); it->next()) { BasicBlock *bb = - BasicBlock::get(reinterpret_cast(iter->get())); + BasicBlock::get(reinterpret_cast(it->get())); for (Instruction *insn = bb->getFirst(); insn; insn = insn->next) result.insert(insn, insn->serial); } - cfg.putIterator(iter); return result.getSize(); } +void +Function::buildLiveSets() +{ + for (unsigned i = 0; i <= loopNestingBound; ++i) + buildLiveSetsPreSSA(BasicBlock::get(cfg.getRoot()), cfg.nextSequence()); + + for (ArrayList::Iterator bi = allBBlocks.iterator(); !bi.end(); bi.next()) + BasicBlock::get(bi)->liveSet.marker = false; +} + +void +Function::buildDefSets() +{ + for (unsigned i = 0; i <= loopNestingBound; ++i) + buildDefSetsPreSSA(BasicBlock::get(cfgExit), cfg.nextSequence()); + + for (ArrayList::Iterator bi = allBBlocks.iterator(); !bi.end(); bi.next()) + BasicBlock::get(bi)->liveSet.marker = false; +} + bool Pass::run(Program *prog, bool ordered, bool skipPhi) { @@ -406,10 +447,10 @@ Pass::run(Program *prog, bool ordered, bool skipPhi) bool Pass::doRun(Program *prog, bool ordered, bool skipPhi) { - for (ArrayList::Iterator fi = prog->allFuncs.iterator(); - !fi.end(); fi.next()) { - Function *fn = reinterpret_cast(fi.get()); - if (!doRun(fn, ordered, skipPhi)) + for (IteratorRef it = prog->calls.iteratorDFS(false); + !it->end(); it->next()) { + Graph::Node *n = reinterpret_cast(it->get()); + if (!doRun(Function::get(n), ordered, skipPhi)) return false; } return !err; @@ -426,7 +467,7 @@ Pass::run(Function *func, bool ordered, bool skipPhi) bool Pass::doRun(Function *func, bool ordered, bool skipPhi) { - Iterator *bbIter; + IteratorRef bbIter; BasicBlock *bb; Instruction *insn, *next; @@ -447,7 +488,7 @@ Pass::doRun(Function *func, bool ordered, bool skipPhi) break; } } - func->cfg.putIterator(bbIter); + return !err; } @@ -463,10 +504,9 @@ Function::printCFGraph(const char *filePath) fprintf(out, "digraph G {\n"); - Iterator *iter; - for (iter = cfg.iteratorDFS(); !iter->end(); iter->next()) { + for (IteratorRef it = cfg.iteratorDFS(); !it->end(); it->next()) { BasicBlock *bb = BasicBlock::get( - reinterpret_cast(iter->get())); + reinterpret_cast(it->get())); int idA = bb->getId(); for (Graph::EdgeIterator ei = bb->cfg.outgoing(); !ei.end(); ei.next()) { int idB = BasicBlock::get(ei.getNode())->getId(); @@ -492,7 +532,6 @@ Function::printCFGraph(const char *filePath) } } } - cfg.putIterator(iter); fprintf(out, "}\n"); fclose(out);