本文整理汇总了C++中ConstantInt::equalsInt方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstantInt::equalsInt方法的具体用法?C++ ConstantInt::equalsInt怎么用?C++ ConstantInt::equalsInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstantInt
的用法示例。
在下文中一共展示了ConstantInt::equalsInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lowerGlobalCtors
void MemoryInstrumenter::lowerGlobalCtors(Module &M) {
// Find llvm.global_ctors.
GlobalVariable *GV = M.getNamedGlobal("llvm.global_ctors");
if (!GV)
return;
assert(!GV->isDeclaration() && !GV->hasLocalLinkage());
// Should be an array of '{ int, void ()* }' structs. The first value is
// the init priority, which must be 65535 if the bitcode is generated using
// clang.
if (ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer())) {
for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) {
ConstantStruct *CS =
dyn_cast<ConstantStruct>(InitList->getOperand(i));
assert(CS);
assert(CS->getNumOperands() == 2);
// Get the priority.
ConstantInt *Priority = dyn_cast<ConstantInt>(CS->getOperand(0));
assert(Priority);
// TODO: For now, we assume all priorities must be 65535.
assert(Priority->equalsInt(65535));
// Get the constructor function.
Constant *FP = CS->getOperand(1);
if (FP->isNullValue())
break; // Found a null terminator, exit.
// Explicitly call the constructor at the main entry.
CallInst::Create(FP, "", Main->begin()->getFirstNonPHI());
}
}
// Clear the global_ctors array.
// Use eraseFromParent() instead of removeFromParent().
GV->eraseFromParent();
}
示例2: parseName
//.........这里部分代码省略.........
name += esp::parseName(icmp->getOperand(0));
continueFlag = false;
}
break;
}
case Instruction::Alloca :{
name += current->getNameStr();
break;
}
case Instruction::Load :{
if (((LoadInst*) inst)->isVolatile())
name += std::string("@VolatileLoad");
name += "*";
name += esp::parseName(inst->getOperand(0));
continueFlag = false;
break;
}
case Instruction::Store :{
// need to handle
continueFlag = false;
break;
}
case Instruction::GetElementPtr :{
GetElementPtrInst * gep = dyn_cast<GetElementPtrInst>(current);
unsigned ops = gep->getNumOperands();
name += "[";
for (unsigned i = 1; i < ops; i++) {
Value *v = gep->getOperand(i);
if (ConstantInt * ci = dyn_cast<ConstantInt>(v)) {
if (i == 1 && ci->equalsInt(0))
continue;
name += ".";
name += ci->getValue().toString(10, false);
} else {
name += ".";
name += esp::parseName(v);
}
}
name += "]";
name += esp::parseName(gep->getOperand(0));
continueFlag = false;
break;
}
case Instruction::BitCast:{
name += esp::parseName(inst->getOperand(0));
continueFlag = false;
break;
}
default :{
// Illegal or unsupported instruction
name += current->getNameStr();
break;
}
}
}else if(isa<Argument>(current)){
if (arguments.find(current) != arguments.end())
name += std::string("$") + current->getNameStr();
}else if(isa<GlobalValue>(current)){