本文整理汇总了C++中PHINode::moveBefore方法的典型用法代码示例。如果您正苦于以下问题:C++ PHINode::moveBefore方法的具体用法?C++ PHINode::moveBefore怎么用?C++ PHINode::moveBefore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHINode
的用法示例。
在下文中一共展示了PHINode::moveBefore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addOperandToPHI
Value *RegionGenerator::copyPHIInstruction(ScopStmt &Stmt, const PHINode *PHI,
ValueMapT &BBMap,
ValueMapT &GlobalMap,
LoopToScevMapT <S) {
unsigned NumIncoming = PHI->getNumIncomingValues();
PHINode *PHICopy =
Builder.CreatePHI(PHI->getType(), NumIncoming, "polly." + PHI->getName());
PHICopy->moveBefore(PHICopy->getParent()->getFirstNonPHI());
BBMap[PHI] = PHICopy;
for (unsigned u = 0; u < NumIncoming; u++)
addOperandToPHI(Stmt, PHI, PHICopy, PHI->getIncomingBlock(u), GlobalMap,
LTS);
return PHICopy;
}
示例2: runOnLoop
bool ModuloSchedulerDriverPass::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) {
subscripts subs(IncomingLoop);
if (!loop_is_ms_able(IncomingLoop) ) return false;
// The header before the parallelized loop will be placed here
BasicBlock* preheader = IncomingLoop->getLoopPreheader();
assert(preheader && "Unable to get a hold of the preheader");
// Balance all BasicBlocks in this loop
for (Loop::block_iterator it=IncomingLoop->block_begin(); it!=IncomingLoop->block_end();++it) {
duplicateValuesWithMultipleUses(*it,subs.getInductionVar());
}
// For each BB in loop
for (Loop::block_iterator it=IncomingLoop->block_begin(); it!=IncomingLoop->block_end();++it) {
instructionPriority ip(*it);
(*it)->setName("PipelinedLoop");
// ++++++++ Preheader part +++++++++
// Make a copy of the body for each instruction. Place a pointer to the
// parallel cloned instruction in the map below. Later on we will replace it
// with a PHINode.
DenseMap<const Value *, Value *> InstToPreheader;
// For each Instruction in body of the loop, clone, store, etc.
for (BasicBlock::iterator ib = (*it)->begin(), eb = (*it)->end(); ib!=eb; ++ib) {
// If this is NOT a phi node
if (!dyn_cast<PHINode>(ib)) {
// Get the priority of the instruction
unsigned int p = ip.getPriority(ib);
// This is the header version of each variable that goes into a PHI node.
// The other edge needs to come from the 'prev' iteration
// We subtract -1 because this is one iteration before
// Store the result into the map of the cloned
InstToPreheader[ib] = copyLoopBodyToHeader(ib, subs.getInductionVar(), preheader, p-1);
}
}
// ++++++++ Loop body part +++++++++
// For each of the cloned increment the indexs if needed and place the PHINode.
for (BasicBlock::iterator ib = (*it)->begin(), eb = (*it)->end(); ib!=eb; ++ib) {
// If this is NOT a phi node
if (!dyn_cast<PHINode>(ib)) {
unsigned int p = ip.getPriority(ib);
// If this variable is not dependent on i (not i:=i+1)
// then we need to replace each i to i+5 ...
// We also do not need to create a PHI node, etc.
if (!subs.isUsedByInductionVariable(ib)) {
incrementInductionVarIfUsed(ib,subs.getInductionVar(),p);
// Create the new PHI Node to replace the node
if (!dyn_cast<StoreInst>(ib) && !ib->isTerminator()) {
std::string newname = "glue" + (*it)->getName();
//PHINode* np = PHINode::Create(ib->getType(), "glue", *it);
PHINode* np = PHINode::Create(ib->getType(), newname, *it);
ib->replaceAllUsesWith(np);
np->reserveOperandSpace(2);
np->addIncoming(InstToPreheader[ib], preheader);
np->addIncoming(ib, *it);
np->moveBefore((*it)->begin());
}
}// end of if this is not an IV node (i:=i+1)
}
}
}
eliminateDuplicatedLoads(preheader);
for (Loop::block_iterator it=IncomingLoop->block_begin(); it!=IncomingLoop->block_end();++it) {
eliminateDuplicatedLoads(*it);
for (BasicBlock::iterator in = (*it)->begin(); in != (*it)->end(); ++in) {
foldAddInstructions(in);
}
}
return true;
}