当前位置: 首页>>代码示例>>C++>>正文


C++ TerminatorInst::getPrevNode方法代码示例

本文整理汇总了C++中TerminatorInst::getPrevNode方法的典型用法代码示例。如果您正苦于以下问题:C++ TerminatorInst::getPrevNode方法的具体用法?C++ TerminatorInst::getPrevNode怎么用?C++ TerminatorInst::getPrevNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TerminatorInst的用法示例。


在下文中一共展示了TerminatorInst::getPrevNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getGlobalContext

  bool
  LoopBarriers::ProcessLoop(Loop *L, LPPassManager &LPM)
  {
    bool isBLoop = false;
    bool changed = false;
  
    for (Loop::block_iterator i = L->block_begin(), e = L->block_end();
         i != e && !isBLoop; ++i) {
      for (BasicBlock::iterator j = (*i)->begin(), e = (*i)->end();
           j != e; ++j) {
        if (isa<BarrierInst>(j)) {
            isBLoop = true;
            break;
        }
      }
    }

    LLVMContext &LC = getGlobalContext();
    IntegerType * IntTy = IntegerType::get(LC, 32);
    Value *Args = ConstantInt::get(IntTy, 0);
  
    for (Loop::block_iterator i = L->block_begin(), e = L->block_end();
         i != e && isBLoop; ++i) {
      for (BasicBlock::iterator j = (*i)->begin(), e = (*i)->end();
           j != e; ++j) {
        if (isa<BarrierInst>(j)) {
          BasicBlock *preheader = L->getLoopPreheader();
          assert((preheader != NULL) && "Non-canonicalized loop found!\n");
          Instruction *PhdrBarrierInst = 
            BarrierInst::createBarrier(Args, preheader->getTerminator());
          MDNode* PhdrAuxBarrierInfo = 
            MDNode::get(LC, MDString::get(LC, "auxiliary phdr barrier"));
          PhdrBarrierInst->setMetadata("aux.phdr.barrier", PhdrAuxBarrierInfo);
          preheader->setName(preheader->getName() + ".loopbarrier");
  
          BasicBlock *header = L->getHeader();
          if (header->getFirstNonPHI() != &header->front()) {
            Instruction *HdrBarrierInst = 
              BarrierInst::createBarrier(Args, header->getFirstNonPHI());
            MDNode* HdrAuxBarrierInfo = 
              MDNode::get(LC, MDString::get(LC,  "auxiliary phihdr barrier"));
            HdrBarrierInst->setMetadata("aux.phihdr.barrier", HdrAuxBarrierInfo);
            header->setName(header->getName() + ".phibarrier");
          }
 
          /*
          SmallVector<BasicBlock*, 8> ExitingBlocks;
          L->getExitingBlocks(ExitingBlocks);
          */
          BasicBlock *brexit = L->getExitingBlock();
          if (brexit != NULL) {
            Instruction *ExitingBarrierInst = 
              BarrierInst::createBarrier(Args, brexit->getTerminator());
            MDNode* ExitingAuxBarrierInfo =
              MDNode::get(LC, MDString::get(LC, "auxiliary exiting barrier"));
            ExitingBarrierInst->setMetadata("aux.exiting.barrier", 
                                            ExitingAuxBarrierInfo);
            brexit->setName(brexit->getName() + ".brexitbarrier");
          }
  
          BasicBlock *latch = L->getLoopLatch();
          if (latch != NULL && brexit != latch) {
            Instruction *LatchBarrierInst =
              BarrierInst::createBarrier(Args, latch->getTerminator());
            MDNode* LatchAuxBarrierInfo =
              MDNode::get(LC, MDString::get(LC, "auxiliary latch barrier"));
            LatchBarrierInst->setMetadata("aux.latch.barrier", 
                                          LatchAuxBarrierInfo);
            latch->setName(latch->getName() + ".latchbarrier");
            return changed;
          }
  
          BasicBlock *Header = L->getHeader();
          typedef GraphTraits<Inverse<BasicBlock *> > InvBlockTraits;
          InvBlockTraits::ChildIteratorType PI = InvBlockTraits::child_begin(Header);
          InvBlockTraits::ChildIteratorType PE = InvBlockTraits::child_end(Header);
          BasicBlock *Latch = NULL;
          for (; PI != PE; ++PI) {
            InvBlockTraits::NodeType *N = *PI;
            if (L->contains(N)) {
              Latch = N;
              if (DT->dominates(j->getParent(), Latch)) {
                BarrierInst::createBarrier(Args, Latch->getTerminator());
                Latch->setName(Latch->getName() + ".latchbarrier");
              }
            }
          }
          return true;
        }
      }
    }
  
    BasicBlock *preheader = L->getLoopPreheader();
    assert((preheader != NULL) && "Non-canonicalized loop found!\n");
    TerminatorInst *t = preheader->getTerminator();
    Instruction *prev = NULL;
    if (&preheader->front() != t) {
      // If t is not the first/only instruction in the block, get the previous
      // instruction.
      prev = t->getPrevNode();
//.........这里部分代码省略.........
开发者ID:JiadingGai,项目名称:VariOCL,代码行数:101,代码来源:LoopBarriers.cpp


注:本文中的TerminatorInst::getPrevNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。