本文整理汇总了C++中IntrinsicInst::setArgOperand方法的典型用法代码示例。如果您正苦于以下问题:C++ IntrinsicInst::setArgOperand方法的具体用法?C++ IntrinsicInst::setArgOperand怎么用?C++ IntrinsicInst::setArgOperand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IntrinsicInst
的用法示例。
在下文中一共展示了IntrinsicInst::setArgOperand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CleanupSelectors
/// CleanupSelectors - Any remaining eh.selector intrinsic calls which still use
/// the "llvm.eh.catch.all.value" call need to convert to using its
/// initializer instead.
bool DwarfEHPrepare::CleanupSelectors(SmallPtrSet<IntrinsicInst*, 32> &Sels) {
if (!EHCatchAllValue) return false;
if (!SelectorIntrinsic) {
SelectorIntrinsic =
Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_selector);
if (!SelectorIntrinsic) return false;
}
bool Changed = false;
for (SmallPtrSet<IntrinsicInst*, 32>::iterator
I = Sels.begin(), E = Sels.end(); I != E; ++I) {
IntrinsicInst *Sel = *I;
// Index of the "llvm.eh.catch.all.value" variable.
unsigned OpIdx = Sel->getNumArgOperands() - 1;
GlobalVariable *GV = dyn_cast<GlobalVariable>(Sel->getArgOperand(OpIdx));
if (GV != EHCatchAllValue) continue;
Sel->setArgOperand(OpIdx, EHCatchAllValue->getInitializer());
Changed = true;
}
return Changed;
}
示例2: decomposeIntrinsics
//.........这里部分代码省略.........
llvm::Type* newCoordType;
if (newCoordWidth > 1)
newCoordType = llvm::VectorType::get(GetBasicType(coords), newCoordWidth);
else
newCoordType = GetBasicType(coords);
// create space to hold results
llvm::Value* newCoords = llvm::UndefValue::get(newCoordType);
llvm::Value* smearedProj = llvm::UndefValue::get(newCoordType);
if (newCoordWidth > 1) {
for (int i = 0; i < newCoordWidth; ++i) {
llvm::Value* idx = MakeUnsignedConstant(module->getContext(), i);
// smear projection
smearedProj = builder.CreateInsertElement(smearedProj, divisor, idx);
// shrink coordinates to remove projection component
llvm::Value* oldCoord = builder.CreateExtractElement(coords, idx);
newCoords = builder.CreateInsertElement(newCoords, oldCoord, idx);
}
} else {
smearedProj = divisor;
newCoords = builder.CreateExtractElement(coords, MakeUnsignedConstant(module->getContext(), 0));
}
// divide coordinates
newCoords = builder.CreateFDiv(newCoords, smearedProj);
//
// Remaining code declares new intrinsic and modifies call arguments
//
// build up argTypes for flexible parameters, including result
llvm::SmallVector<llvm::Type*, 5> types;
// result type
types.push_back(intrinsic->getType());
// use new coords to reflect shrink
types.push_back(newCoords->getType());
// add offset
switch (intrinsic->getIntrinsicID()) {
case Intrinsic::gla_fTextureSampleLodRefZOffset:
case Intrinsic::gla_fTextureSampleLodRefZOffsetGrad:
types.push_back(intrinsic->getArgOperand(ETOOffset)->getType());
default:
break;
}
// add gradients
switch (intrinsic->getIntrinsicID()) {
case Intrinsic::gla_fTextureSampleLodRefZOffsetGrad:
types.push_back(intrinsic->getArgOperand(ETODPdx)->getType());
types.push_back(intrinsic->getArgOperand(ETODPdy)->getType());
default:
break;
}
// declare the new intrinsic
// TODO: functionality: texturing correctness: is this getting the correct non-projective form?
Function* texture = Intrinsic::getDeclaration(module, intrinsic->getIntrinsicID(), types);
// modify arguments to match new intrinsic
intrinsic->setCalledFunction(texture);
intrinsic->setArgOperand(ETOFlag, MakeUnsignedConstant(module->getContext(), texFlags));
intrinsic->setArgOperand(ETOCoord, newCoords);
switch (intrinsic->getIntrinsicID()) {
case Intrinsic::gla_fTextureSampleLodRefZ:
case Intrinsic::gla_fTextureSampleLodRefZOffset:
case Intrinsic::gla_fTextureSampleLodRefZOffsetGrad:
intrinsic->setArgOperand(ETORefZ, builder.CreateFDiv(intrinsic->getArgOperand(ETORefZ), divisor));
default:
break;
}
// mark our change, but don't replace the intrinsic
changed = true;
}
}
break;
default:
// The cases above needs to be comprehensive in terms of checking
// for what intrinsics to decompose. If not there the assumption is
// it never needs to be decomposed.
break;
}
if (newInst) {
inst->replaceAllUsesWith(newInst);
inst->dropAllReferences();
inst->eraseFromParent();
changed = true;
}
}
}