nv50/ir: Add support code for calculating the clobber set of a BB or function.
authorFrancisco Jerez <currojerez@riseup.net>
Wed, 21 Mar 2012 20:43:26 +0000 (21:43 +0100)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sat, 14 Apr 2012 19:54:01 +0000 (21:54 +0200)
src/gallium/drivers/nv50/codegen/nv50_ir.h
src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp
src/gallium/drivers/nv50/codegen/nv50_ir_ssa.cpp

index d50e61f..d4e7c94 100644 (file)
@@ -887,6 +887,7 @@ public:
    Graph::Node dom;
 
    BitSet liveSet;
+   BitSet defSet;
 
    uint32_t binPos;
    uint32_t binSize;
@@ -937,6 +938,7 @@ public:
 
    inline LValue *getLValue(int id);
 
+   void buildDefSets();
    bool convertToSSA();
 
 public:
@@ -960,6 +962,7 @@ public:
 
 private:
    void buildLiveSetsPreSSA(BasicBlock *, const int sequence);
+   void buildDefSetsPreSSA(BasicBlock *bb, const int seq);
 
 private:
    int id;
index 07d8dec..7c8f2e9 100644 (file)
@@ -415,6 +415,16 @@ Function::orderInstructions(ArrayList &result)
    return result.getSize();
 }
 
+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)
 {
index b3a1486..21b6cba 100644 (file)
@@ -256,6 +256,27 @@ Function::buildLiveSetsPreSSA(BasicBlock *bb, const int seq)
    bb->liveSet |= usedBeforeAssigned;
 }
 
+void
+Function::buildDefSetsPreSSA(BasicBlock *bb, const int seq)
+{
+   bb->defSet.allocate(allLValues.getSize(), !bb->liveSet.marker);
+   bb->liveSet.marker = true;
+
+   for (Graph::EdgeIterator ei = bb->cfg.incident(); !ei.end(); ei.next()) {
+      BasicBlock *in = BasicBlock::get(ei.getNode());
+
+      if (in->cfg.visit(seq))
+         buildDefSetsPreSSA(in, seq);
+
+      bb->defSet |= in->defSet;
+   }
+
+   for (Instruction *i = bb->getEntry(); i; i = i->next) {
+      for (int d = 0; i->defExists(d); ++d)
+         bb->defSet.set(i->getDef(d)->id);
+   }
+}
+
 class RenamePass
 {
 public: