Graph::Node dom;
BitSet liveSet;
+ BitSet defSet;
uint32_t binPos;
uint32_t binSize;
inline LValue *getLValue(int id);
+ void buildDefSets();
bool convertToSSA();
public:
private:
void buildLiveSetsPreSSA(BasicBlock *, const int sequence);
+ void buildDefSetsPreSSA(BasicBlock *bb, const int seq);
private:
int id;
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)
{
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: