本文整理汇总了C++中Argument类的典型用法代码示例。如果您正苦于以下问题:C++ Argument类的具体用法?C++ Argument怎么用?C++ Argument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Argument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visitArgument
SizeOffsetType ObjectSizeOffsetVisitor::visitArgument(Argument &A) {
// no interprocedural analysis is done at the moment
if (!A.hasByValOrInAllocaAttr()) {
++ObjectVisitorArgument;
return unknown();
}
PointerType *PT = cast<PointerType>(A.getType());
APInt Size(IntTyBits, DL.getTypeAllocSize(PT->getElementType()));
return std::make_pair(align(Size, A.getParamAlignment()), Zero);
}
示例2: addArgument
void ArgumentParser::addArgument(const Argument& arg) {
vargs.push_back(arg);
if (arg.getShortArg().size() > 0) {
args.insert(pair<string, Argument>(arg.getShortArg(), arg));
}
if (arg.getLongArg().size() > 0) {
args.insert(pair<string, Argument>(arg.getLongArg(), arg));
}
}
示例3: ali
/*! the argument list is documented if one of its
* arguments is documented
*/
bool ArgumentList::hasDocumentation() const
{
bool hasDocs=FALSE;
ArgumentListIterator ali(*this);
Argument *a;
for (ali.toFirst();!hasDocs && (a=ali.current());++ali)
{
hasDocs = hasDocs || a->hasDocumentation();
}
return hasDocs;
}
示例4: get
AValue get(string name) {
Argument *arg = getArgument(name);
for (auto entry : map) {
if (arg->is(entry.first)) {
return AValue(entry.second);
}
}
return AValue({});
}
示例5: Argument
Argument* Argument::applySubstitution(){
Argument* args = new Argument();
try {
for (Argument::iterator it = begin(); it != end(); it++)
args->push_back((*it)->applySubstitution());
return args;
}
catch (OutOfRange&){
delete args;
throw;
}
}
示例6: Builder
void GCOVProfiler::insertIndirectCounterIncrement() {
Function *Fn =
cast<Function>(GCOVProfiler::getIncrementIndirectCounterFunc());
Fn->setUnnamedAddr(true);
Fn->setLinkage(GlobalValue::InternalLinkage);
Fn->addFnAttr(Attributes::NoInline);
if (NoRedZone)
Fn->addFnAttr(Attributes::NoRedZone);
Type *Int32Ty = Type::getInt32Ty(*Ctx);
Type *Int64Ty = Type::getInt64Ty(*Ctx);
Constant *NegOne = ConstantInt::get(Int32Ty, 0xffffffff);
// Create basic blocks for function.
BasicBlock *BB = BasicBlock::Create(*Ctx, "entry", Fn);
IRBuilder<> Builder(BB);
BasicBlock *PredNotNegOne = BasicBlock::Create(*Ctx, "", Fn);
BasicBlock *CounterEnd = BasicBlock::Create(*Ctx, "", Fn);
BasicBlock *Exit = BasicBlock::Create(*Ctx, "exit", Fn);
// uint32_t pred = *predecessor;
// if (pred == 0xffffffff) return;
Argument *Arg = Fn->arg_begin();
Arg->setName("predecessor");
Value *Pred = Builder.CreateLoad(Arg, "pred");
Value *Cond = Builder.CreateICmpEQ(Pred, NegOne);
BranchInst::Create(Exit, PredNotNegOne, Cond, BB);
Builder.SetInsertPoint(PredNotNegOne);
// uint64_t *counter = counters[pred];
// if (!counter) return;
Value *ZExtPred = Builder.CreateZExt(Pred, Int64Ty);
Arg = llvm::next(Fn->arg_begin());
Arg->setName("counters");
Value *GEP = Builder.CreateGEP(Arg, ZExtPred);
Value *Counter = Builder.CreateLoad(GEP, "counter");
Cond = Builder.CreateICmpEQ(Counter,
Constant::getNullValue(Int64Ty->getPointerTo()));
Builder.CreateCondBr(Cond, Exit, CounterEnd);
// ++*counter;
Builder.SetInsertPoint(CounterEnd);
Value *Add = Builder.CreateAdd(Builder.CreateLoad(Counter),
ConstantInt::get(Int64Ty, 1));
Builder.CreateStore(Add, Counter);
Builder.CreateBr(Exit);
// Fill in the exit block.
Builder.SetInsertPoint(Exit);
Builder.CreateRetVoid();
}
示例7: switch
int tesla::ArgIndex(const Argument& A) {
switch (A.type()) {
case Argument::Any:
case Argument::Constant:
return -1;
case Argument::Variable:
case Argument::Field:
case Argument::Indirect:
return A.index();
}
}
示例8: browseAction
CyberXML::Node *MediaPlayer::browse(
Device *dev,
const char *objectID,
const char *browseFlag,
const char *filter,
int startIndex,
int requestedCount,
const char *sortCaiteria)
{
if (dev == NULL)
return NULL;
Service *conDir = dev->getService(ContentDirectory::SERVICE_TYPE);
if (conDir == NULL)
return NULL;
Action *action = conDir->getAction(ContentDirectory::BROWSE);
if (action == NULL)
return NULL;
BrowseAction browseAction(action);
browseAction.setObjectID(objectID);
browseAction.setBrowseFlag(browseFlag);
browseAction.setStartingIndex(startIndex);
browseAction.setRequestedCount(requestedCount);
browseAction.setFilter(filter);
browseAction.setSortCriteria(sortCaiteria);
if (browseAction.postControlAction() == false)
return NULL;
Argument *resultArg = browseAction.getArgument(BrowseAction::RESULT);
if (resultArg == NULL)
return NULL;
const char *resultStr = resultArg->getValue();
if (resultStr == NULL)
return NULL;
Node *node = NULL;
Parser xmlParser;
int resultUniStrLen;
UnicodeStr *resultUniStr = XML::Local2Unicode(resultStr, resultUniStrLen);
if (resultUniStr != NULL) {
node = xmlParser.parse(resultUniStr, resultUniStrLen);
delete []resultUniStr;
}
if (node == NULL)
node = xmlParser.parse(resultStr);
return node;
}
示例9: accept
void ArgumentGroup::accept(const Argument & argument)
{
bool same_option = this->_num_selected > 0 && (this->_num_selected == 1 && this->_last_selected_option == argument.option());
if(this->_mutually_exclusive && (this->_num_selected > 0) && (! same_option))
{
throw ArgParserError(DEBUG_INFO, "invalid option " + argument.option().option_string() + ": option " + this->_last_selected_option.option_string() + " already set in mutually exclusive group " + this->_name);
}
if(! same_option)
{
this->_last_selected_option = argument.option();
++this->_num_selected;
}
}
示例10: isSameArrayElement
inline static bool isSameArrayElement(const Argument<Base>* oldArg,
const Argument<Base>& arg) {
if (oldArg != nullptr) {
if (oldArg->getParameter() != nullptr) {
if (arg.getParameter() != nullptr) {
return (*arg.getParameter() == *oldArg->getParameter());
}
} else {
return (arg.getOperation() == oldArg->getOperation());
}
}
return false;
}
示例11: to_string
std::string to_string(const Argument<hns::Namespace>& ns)
{
std::ostringstream os;
os << ns->getName() << " [" << ns->getID().short_string() << "] NS[";
for(hns::Namespace::IDListType::const_iterator it = ns->accessChildNamespaceList().begin();
it != ns->accessChildNamespaceList().end();
it++)
{
os << ";" << it->short_string();;
}
return os.str();
}
示例12: ICmpInst
static Function *CreateFibFunction(Module *M, LLVMContext &Context) {
// Create the fib function and insert it into module M. This function is said
// to return an int and take an int parameter.
Function *FibF =
cast<Function>(M->getOrInsertFunction("fib", Type::getInt32Ty(Context),
Type::getInt32Ty(Context),
(Type *)0));
// Add a basic block to the function.
BasicBlock *BB = BasicBlock::Create(Context, "EntryBlock", FibF);
// Get pointers to the constants.
Value *One = ConstantInt::get(Type::getInt32Ty(Context), 1);
Value *Two = ConstantInt::get(Type::getInt32Ty(Context), 2);
// Get pointer to the integer argument of the add1 function...
Argument *ArgX = FibF->arg_begin(); // Get the arg.
ArgX->setName("AnArg"); // Give it a nice symbolic name for fun.
// Create the true_block.
BasicBlock *RetBB = BasicBlock::Create(Context, "return", FibF);
// Create an exit block.
BasicBlock* RecurseBB = BasicBlock::Create(Context, "recurse", FibF);
// Create the "if (arg <= 2) goto exitbb"
Value *CondInst = new ICmpInst(*BB, ICmpInst::ICMP_SLE, ArgX, Two, "cond");
BranchInst::Create(RetBB, RecurseBB, CondInst, BB);
// Create: ret int 1
ReturnInst::Create(Context, One, RetBB);
// create fib(x-1)
Value *Sub = BinaryOperator::CreateSub(ArgX, One, "arg", RecurseBB);
CallInst *CallFibX1 = CallInst::Create(FibF, Sub, "fibx1", RecurseBB);
CallFibX1->setTailCall();
// create fib(x-2)
Sub = BinaryOperator::CreateSub(ArgX, Two, "arg", RecurseBB);
CallInst *CallFibX2 = CallInst::Create(FibF, Sub, "fibx2", RecurseBB);
CallFibX2->setTailCall();
// fib(x-1)+fib(x-2)
Value *Sum = BinaryOperator::CreateAdd(CallFibX1, CallFibX2,
"addresult", RecurseBB);
// Create the return instruction and add it to the basic block
ReturnInst::Create(Context, Sum, RecurseBB);
return FibF;
}
示例13: checkArgumentUses
bool AMDGPURewriteOutArguments::isOutArgumentCandidate(Argument &Arg) const {
const unsigned MaxOutArgSizeBytes = 4 * MaxNumRetRegs;
PointerType *ArgTy = dyn_cast<PointerType>(Arg.getType());
// TODO: It might be useful for any out arguments, not just privates.
if (!ArgTy || (ArgTy->getAddressSpace() != DL->getAllocaAddrSpace() &&
!AnyAddressSpace) ||
Arg.hasByValAttr() || Arg.hasStructRetAttr() ||
DL->getTypeStoreSize(ArgTy->getPointerElementType()) > MaxOutArgSizeBytes) {
return false;
}
return checkArgumentUses(Arg);
}
示例14:
unordered_multimap<const char*, Value*>& ArgumentRecovery::exposeAllRegisters(llvm::Function* fn)
{
auto iter = registerAddresses.find(fn);
if (iter != registerAddresses.end())
{
return iter->second;
}
auto& addresses = registerAddresses[fn];
if (fn->isDeclaration())
{
// If a function has no body, it doesn't need a register map.
return addresses;
}
Argument* firstArg = fn->arg_begin();
assert(isStructType(firstArg));
// Get explicitly-used GEPs
const auto& target = getAnalysis<TargetInfo>();
for (User* user : firstArg->users())
{
if (auto gep = dyn_cast<GetElementPtrInst>(user))
{
const char* name = target.registerName(*gep);
const char* largestRegister = target.largestOverlappingRegister(name);
addresses.insert({largestRegister, gep});
}
}
// Synthesize GEPs for implicitly-used registers.
// Implicit uses are when a function callee uses a register without there being a reference in the caller.
// This happens either because the parameter is passed through, or because the register is a scratch register that
// the caller doesn't use itself.
auto insertionPoint = fn->begin()->begin();
auto& regUse = getAnalysis<RegisterUse>();
const auto& modRefInfo = *regUse.getModRefInfo(fn);
for (const auto& pair : modRefInfo)
{
if ((pair.second & RegisterUse::ModRef) != 0 && addresses.find(pair.first) == addresses.end())
{
// Need a GEP here, because the function ModRefs the register implicitly.
GetElementPtrInst* synthesizedGep = target.getRegister(firstArg, pair.first);
synthesizedGep->insertBefore(insertionPoint);
addresses.insert({pair.first, synthesizedGep});
}
}
return addresses;
}
示例15: getActionNode
void ActionRequest::initArgumentList() {
Node *actNode = getActionNode();
if (actNode == NULL)
return;
int nArgNodes = actNode->getNNodes();
argumentList.clear();
for (int n = 0; n < nArgNodes; n++) {
Argument *arg = new Argument();
Node *argNode = actNode->getNode(n);
arg->setName(argNode->getName());
arg->setValue(argNode->getValue());
argumentList.add(arg);
}
}