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


C++ SelectInst类代码示例

本文整理汇总了C++中SelectInst的典型用法代码示例。如果您正苦于以下问题:C++ SelectInst类的具体用法?C++ SelectInst怎么用?C++ SelectInst使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: visitSelectInst

SizeOffsetType ObjectSizeOffsetVisitor::visitSelectInst(SelectInst &I) {
  SizeOffsetType TrueSide  = compute(I.getTrueValue());
  SizeOffsetType FalseSide = compute(I.getFalseValue());
  if (bothKnown(TrueSide) && bothKnown(FalseSide)) {
    if (TrueSide == FalseSide) {
        return TrueSide;
    }

    APInt TrueResult = getSizeWithOverflow(TrueSide);
    APInt FalseResult = getSizeWithOverflow(FalseSide);

    if (TrueResult == FalseResult) {
      return TrueSide;
    }
    if (Options.EvalMode == ObjectSizeOpts::Mode::Min) {
      if (TrueResult.slt(FalseResult))
        return TrueSide;
      return FalseSide;
    }
    if (Options.EvalMode == ObjectSizeOpts::Mode::Max) {
      if (TrueResult.sgt(FalseResult))
        return TrueSide;
      return FalseSide;
    }
  }
  return unknown();
}
开发者ID:Leedehai,项目名称:llvm,代码行数:27,代码来源:MemoryBuiltins.cpp

示例2: visitSelectInst

SizeOffsetType ObjectSizeOffsetVisitor::visitSelectInst(SelectInst &I) {
  SizeOffsetType TrueSide  = compute(I.getTrueValue());
  SizeOffsetType FalseSide = compute(I.getFalseValue());
  if (bothKnown(TrueSide) && bothKnown(FalseSide) && TrueSide == FalseSide)
    return TrueSide;
  return unknown();
}
开发者ID:Jerdak,项目名称:llvm-mirror,代码行数:7,代码来源:MemoryBuiltins.cpp

示例3: utccAbort

// -- handle select instruction -- 
void UnsafeTypeCastingCheck::handleSelectInstruction (Instruction *inst) {
  SelectInst *sinst = dyn_cast<SelectInst>(inst); 
  if (sinst == NULL) 
    utccAbort("handleSelectInstruction cannot process with a non-select instruction");       
  assert(sinst->getNumOperands() == 3); 
  Value *choice0 = sinst->getOperand(1); 
  Value *choice1 = sinst->getOperand(2); 
  Type *type0 = choice0->getType();
  Type *type1 = choice1->getType(); 
  UTCC_TYPE ut0 = llvmT2utccT(type0, choice0); 
  UTCC_TYPE ut1 = llvmT2utccT(type1, choice1); 

  if (type0->isIntegerTy() && 
      type1->isIntegerTy()) {
    if (ut0 == ut1) 
      setExprType(sinst, ut0); 
    else if (ut0 == INT_UT || ut1 == INT_UT) 
      setExprType(sinst, INT_UT); 
    else setExprType(sinst, NINT_UT); 
  }
  else if (type0->isFloatingPointTy() && 
	   type1->isFloatingPointTy()) {
    if (ut0 == ut1) 
      setExprType(sinst, ut0); 
    else if (ut0 == FP_UT || ut1 == FP_UT) 
      setExprType(sinst, FP_UT); 
    else setExprType(sinst, NFP_UT); 
  }
  else {
    setExprType(sinst, llvmT2utccT(sinst->getType(), sinst)); 
  }
}
开发者ID:wfchiang,项目名称:llvm-utcc,代码行数:33,代码来源:UnsafeTypeCastingCheck.cpp

示例4: CanSelectOperandBeMappingIntoPredBlock

/// CanSelectOperandBeMappingIntoPredBlock - SI is a select whose condition is a
/// PHI node (but the two may be in different blocks).  See if the true/false
/// values (V) are live in all of the predecessor blocks of the PHI.  For
/// example, cases like this cannot be mapped:
///
///   X = phi [ C1, BB1], [C2, BB2]
///   Y = add
///   Z = select X, Y, 0
///
/// because Y is not live in BB1/BB2.
///
static bool CanSelectOperandBeMappingIntoPredBlock(const Value *V,
                                                   const SelectInst &SI) {
  // If the value is a non-instruction value like a constant or argument, it
  // can always be mapped.
  const Instruction *I = dyn_cast<Instruction>(V);
  if (!I) return true;

  // If V is a PHI node defined in the same block as the condition PHI, we can
  // map the arguments.
  const PHINode *CondPHI = cast<PHINode>(SI.getCondition());

  if (const PHINode *VP = dyn_cast<PHINode>(I))
    if (VP->getParent() == CondPHI->getParent())
      return true;

  // Otherwise, if the PHI and select are defined in the same block and if V is
  // defined in a different block, then we can transform it.
  if (SI.getParent() == CondPHI->getParent() &&
      I->getParent() != CondPHI->getParent())
    return true;

  // Otherwise we have a 'hard' case and we can't tell without doing more
  // detailed dominator based analysis, punt.
  return false;
}
开发者ID:IamSpid3r,项目名称:cheerp-llvm,代码行数:36,代码来源:InstCombineSelect.cpp

示例5: getOperandValue

void Interpreter::visitSelectInst(SelectInst &I) {
  ExecutionContext &SF = ECStack.back();
  GenericValue Src1 = getOperandValue(I.getOperand(0), SF);
  GenericValue Src2 = getOperandValue(I.getOperand(1), SF);
  GenericValue Src3 = getOperandValue(I.getOperand(2), SF);
  GenericValue R = executeSelectInst(Src1, Src2, Src3);
  SetValue(&I, R, SF);
}
开发者ID:chris-wood,项目名称:llvm-pgopre,代码行数:8,代码来源:Execution.cpp

示例6: visitSelectInst

void GraphBuilder::visitSelectInst(SelectInst &SI) {
  if (!isa<PointerType>(SI.getType()))
    return; // Only pointer Selects

  DSNodeHandle &Dest = G.getNodeForValue(&SI);
  DSNodeHandle S1 = getValueDest(SI.getOperand(1));
  DSNodeHandle S2 = getValueDest(SI.getOperand(2));
  Dest.mergeWith(S1);
  Dest.mergeWith(S2);
}
开发者ID:brills,项目名称:pfpa,代码行数:10,代码来源:Local.cpp

示例7: assert

bool AMDGPUCodeGenPrepare::promoteUniformOpToI32(SelectInst &I) const {
  assert(needsPromotionToI32(I.getType()) &&
         "I does not need promotion to i32");

  IRBuilder<> Builder(&I);
  Builder.SetCurrentDebugLocation(I.getDebugLoc());

  Type *I32Ty = getI32Ty(Builder, I.getType());
  Value *ExtOp1 = nullptr;
  Value *ExtOp2 = nullptr;
  Value *ExtRes = nullptr;
  Value *TruncRes = nullptr;

  if (isSigned(I)) {
    ExtOp1 = Builder.CreateSExt(I.getOperand(1), I32Ty);
    ExtOp2 = Builder.CreateSExt(I.getOperand(2), I32Ty);
  } else {
    ExtOp1 = Builder.CreateZExt(I.getOperand(1), I32Ty);
    ExtOp2 = Builder.CreateZExt(I.getOperand(2), I32Ty);
  }
  ExtRes = Builder.CreateSelect(I.getOperand(0), ExtOp1, ExtOp2);
  TruncRes = Builder.CreateTrunc(ExtRes, I.getType());

  I.replaceAllUsesWith(TruncRes);
  I.eraseFromParent();

  return true;
}
开发者ID:avr-llvm,项目名称:llvm,代码行数:28,代码来源:AMDGPUCodeGenPrepare.cpp

示例8: visitSelectInst

bool Scalarizer::visitSelectInst(SelectInst &SI) {
  VectorType *VT = dyn_cast<VectorType>(SI.getType());
  if (!VT)
    return false;

  unsigned NumElems = VT->getNumElements();
  IRBuilder<> Builder(SI.getParent(), &SI);
  Scatterer Op1 = scatter(&SI, SI.getOperand(1));
  Scatterer Op2 = scatter(&SI, SI.getOperand(2));
  assert(Op1.size() == NumElems && "Mismatched select");
  assert(Op2.size() == NumElems && "Mismatched select");
  ValueVector Res;
  Res.resize(NumElems);

  if (SI.getOperand(0)->getType()->isVectorTy()) {
    Scatterer Op0 = scatter(&SI, SI.getOperand(0));
    assert(Op0.size() == NumElems && "Mismatched select");
    for (unsigned I = 0; I < NumElems; ++I)
      Res[I] = Builder.CreateSelect(Op0[I], Op1[I], Op2[I],
                                    SI.getName() + ".i" + Twine(I));
  } else {
    Value *Op0 = SI.getOperand(0);
    for (unsigned I = 0; I < NumElems; ++I)
      Res[I] = Builder.CreateSelect(Op0, Op1[I], Op2[I],
                                    SI.getName() + ".i" + Twine(I));
  }
  gather(&SI, Res);
  return true;
}
开发者ID:gwowen,项目名称:pocl,代码行数:29,代码来源:Scalarizer.cpp

示例9: processPHI

bool CorrelatedValuePropagation::processPHI(PHINode *P) {
  bool Changed = false;

  BasicBlock *BB = P->getParent();
  for (unsigned i = 0, e = P->getNumIncomingValues(); i < e; ++i) {
    Value *Incoming = P->getIncomingValue(i);
    if (isa<Constant>(Incoming)) continue;

    Value *V = LVI->getConstantOnEdge(Incoming, P->getIncomingBlock(i), BB);

    // Look if the incoming value is a select with a constant but LVI tells us
    // that the incoming value can never be that constant. In that case replace
    // the incoming value with the other value of the select. This often allows
    // us to remove the select later.
    if (!V) {
      SelectInst *SI = dyn_cast<SelectInst>(Incoming);
      if (!SI) continue;

      Constant *C = dyn_cast<Constant>(SI->getFalseValue());
      if (!C) continue;

      if (LVI->getPredicateOnEdge(ICmpInst::ICMP_EQ, SI, C,
                                  P->getIncomingBlock(i), BB) !=
          LazyValueInfo::False)
        continue;

      DEBUG(dbgs() << "CVP: Threading PHI over " << *SI << '\n');
      V = SI->getTrueValue();
    }

    P->setIncomingValue(i, V);
    Changed = true;
  }

  if (Value *V = SimplifyInstruction(P)) {
    P->replaceAllUsesWith(V);
    P->eraseFromParent();
    Changed = true;
  }

  if (Changed)
    ++NumPhis;

  return Changed;
}
开发者ID:AmesianX,项目名称:dagger,代码行数:45,代码来源:CorrelatedValuePropagation.cpp

示例10: visitSelectInst

bool AMDGPUCodeGenPrepare::visitSelectInst(SelectInst &I) {
  bool Changed = false;

  if (ST->has16BitInsts() && needsPromotionToI32(I.getType()) &&
      DA->isUniform(&I))
    Changed |= promoteUniformOpToI32(I);

  return Changed;
}
开发者ID:avr-llvm,项目名称:llvm,代码行数:9,代码来源:AMDGPUCodeGenPrepare.cpp

示例11: instrumentOneSelectInst

void SelectInstVisitor::instrumentOneSelectInst(SelectInst &SI) {
  Module *M = F.getParent();
  IRBuilder<> Builder(&SI);
  Type *Int64Ty = Builder.getInt64Ty();
  Type *I8PtrTy = Builder.getInt8PtrTy();
  auto *Step = Builder.CreateZExt(SI.getCondition(), Int64Ty);
  Builder.CreateCall(
      Intrinsic::getDeclaration(M, Intrinsic::instrprof_increment_step),
      {llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
       Builder.getInt64(FuncHash),
       Builder.getInt32(TotalNumCtrs), Builder.getInt32(*CurCtrIdx), Step});
  ++(*CurCtrIdx);
}
开发者ID:sanjoy,项目名称:llvm,代码行数:13,代码来源:PGOInstrumentation.cpp

示例12: annotateOneSelectInst

void SelectInstVisitor::annotateOneSelectInst(SelectInst &SI) {
  std::vector<uint64_t> &CountFromProfile = UseFunc->getProfileRecord().Counts;
  assert(*CurCtrIdx < CountFromProfile.size() &&
         "Out of bound access of counters");
  uint64_t SCounts[2];
  SCounts[0] = CountFromProfile[*CurCtrIdx]; // True count
  ++(*CurCtrIdx);
  uint64_t TotalCount = UseFunc->getBBInfo(SI.getParent()).CountValue;
  // False Count
  SCounts[1] = (TotalCount > SCounts[0] ? TotalCount - SCounts[0] : 0);
  uint64_t MaxCount = std::max(SCounts[0], SCounts[1]);
  if (MaxCount)
    setProfMetadata(F.getParent(), &SI, SCounts, MaxCount);
}
开发者ID:sanjoy,项目名称:llvm,代码行数:14,代码来源:PGOInstrumentation.cpp

示例13: InstDesc

/// Returns true if the select instruction has users in the compare-and-add
/// reduction pattern below. The select instruction argument is the last one
/// in the sequence.
///
/// %sum.1 = phi ...
/// ...
/// %cmp = fcmp pred %0, %CFP
/// %add = fadd %0, %sum.1
/// %sum.2 = select %cmp, %add, %sum.1
RecurrenceDescriptor::InstDesc
RecurrenceDescriptor::isConditionalRdxPattern(
    RecurrenceKind Kind, Instruction *I) {
  SelectInst *SI = dyn_cast<SelectInst>(I);
  if (!SI)
    return InstDesc(false, I);

  CmpInst *CI = dyn_cast<CmpInst>(SI->getCondition());
  // Only handle single use cases for now.
  if (!CI || !CI->hasOneUse())
    return InstDesc(false, I);

  Value *TrueVal = SI->getTrueValue();
  Value *FalseVal = SI->getFalseValue();
  // Handle only when either of operands of select instruction is a PHI
  // node for now.
  if ((isa<PHINode>(*TrueVal) && isa<PHINode>(*FalseVal)) ||
      (!isa<PHINode>(*TrueVal) && !isa<PHINode>(*FalseVal)))
    return InstDesc(false, I);

  Instruction *I1 =
      isa<PHINode>(*TrueVal) ? dyn_cast<Instruction>(FalseVal)
                             : dyn_cast<Instruction>(TrueVal);
  if (!I1 || !I1->isBinaryOp())
    return InstDesc(false, I);

  Value *Op1, *Op2;
  if ((m_FAdd(m_Value(Op1), m_Value(Op2)).match(I1)  ||
       m_FSub(m_Value(Op1), m_Value(Op2)).match(I1)) &&
      I1->isFast())
    return InstDesc(Kind == RK_FloatAdd, SI);

  if (m_FMul(m_Value(Op1), m_Value(Op2)).match(I1) && (I1->isFast()))
    return InstDesc(Kind == RK_FloatMult, SI);

  return InstDesc(false, I);
}
开发者ID:alex-t,项目名称:llvm,代码行数:46,代码来源:IVDescriptors.cpp

示例14: CheckAndInstrument

bool SelectInstrumenter::CheckAndInstrument(Instruction* inst) {
  SelectInst* selectInst = dyn_cast<SelectInst>(inst);

  if (selectInst != NULL) {

    safe_assert(parent_ != NULL);

    count_++;

    InstrPtrVector instrs;

    Constant* iidC = IID_CONSTANT(selectInst);

    Constant* inxC = computeIndex(selectInst);

    Value* condition = KVALUE_VALUE(selectInst->getCondition(), instrs, NOSIGN);
    if(condition == NULL) return false;

    Value* tvalue = KVALUE_VALUE(selectInst->getTrueValue(), instrs, NOSIGN);
    if(tvalue == NULL) return false;
    
    Value* fvalue = KVALUE_VALUE(selectInst->getFalseValue(), instrs, NOSIGN);
    if(fvalue == NULL) return false;
    
    Instruction* call = CALL_IID_KVALUE_KVALUE_KVALUE_INT("llvm_select", iidC, condition, tvalue, fvalue, inxC);
    
    instrs.push_back(call);

    // instrument
    InsertAllBefore(instrs, selectInst);

    return true;
  } 

  return false;
}
开发者ID:corvette-berkeley,项目名称:shadow-execution,代码行数:36,代码来源:SelectInstrumenter.cpp

示例15: visitSelectInst

void TracingNoGiri::visitSelectInst(SelectInst &SI) {
  instrumentLock(&SI);

  // Cast the predicate (boolean) value into an 8-bit value.
  Value *Predicate = SI.getCondition();
  Predicate = castTo(Predicate, Int8Type, Predicate->getName(), &SI);
  // Get the ID of the load instruction.
  Value *SelectID = ConstantInt::get(Int32Type, lsNumPass->getID(&SI));
  // Create the call to the run-time to record the load instruction.
  std::vector<Value *> args=make_vector<Value *>(SelectID, Predicate, 0);
  CallInst::Create(RecordSelect, args, "", &SI);

  instrumentUnlock(&SI);
  ++NumSelects; // Update statistics
}
开发者ID:Justme0,项目名称:giri,代码行数:15,代码来源:TracingNoGiri.cpp


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