本文整理汇总了C++中BasicBlock::addSuccessor方法的典型用法代码示例。如果您正苦于以下问题:C++ BasicBlock::addSuccessor方法的具体用法?C++ BasicBlock::addSuccessor怎么用?C++ BasicBlock::addSuccessor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BasicBlock
的用法示例。
在下文中一共展示了BasicBlock::addSuccessor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: splitCriticalEdge
void PhiElimination::splitCriticalEdge(
IRFunction * func, BasicBlock * block)
{
//if (block->numOfPrecursors() <= 1)
// return;
auto GetInnerBlock = [func, block]
(const std::string &from, const std::string &to) {
BasicBlock *BB = func->createBasicBlock(from + "-" + to);
Goto *go2 = IRContext::create<Goto>(block);
BB->push_back(go2);
BB->addSuccessor(block);
go2->set_parent(BB);
return BB;
};
size_t size = block->numOfPrecursors();
for (auto pre = block->precursor_begin();
pre != block->precursor_end();
++pre) {
BasicBlock *PBB = *pre;
// Check whether split.
if (PBB->numOfSuccessors() <= 1)
continue;
// split it.
BasicBlock *BB = GetInnerBlock(
PBB->getBlockName(), block->getBlockName());
*pre = BB;
PBB->successor_replace(block, BB);
if (PBB->back()->is_goto()) {
Goto *GT = static_cast<Goto*>(PBB->back());
GT->setTarget(BB);
}
else if (PBB->back()->is_branch()) {
Branch *branch = static_cast<Branch*>(PBB->back());
if (branch->then() == block)
branch->setThen(BB);
else
branch->setElse(BB);
}
else {
assert(0 && "impossible");
}
}
}
示例2: readBasicBlock
BasicBlock* BasicBlock::readBasicBlock(FILE* in)
{
if (feof(in) || ferror(in)) return NULL;
uint32_t id;
uint32_t typeInt;
int succ1;
int succ2;
if (4 == fscanf(in, "%u,%u,%i,%i", &id, &typeInt, &succ1, &succ2))
{
BasicBlock* b = new BasicBlock((uint32_t)id);
b->setType((task_type)typeInt);
if (succ1 != -1) b->addSuccessor((uint32_t)succ1);
if (succ2 != -1) b->addSuccessor((uint32_t)succ2);
return b;
} else {
return NULL;
}
}