本文整理汇总了C++中GlobalVariable::getOperand方法的典型用法代码示例。如果您正苦于以下问题:C++ GlobalVariable::getOperand方法的具体用法?C++ GlobalVariable::getOperand怎么用?C++ GlobalVariable::getOperand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlobalVariable
的用法示例。
在下文中一共展示了GlobalVariable::getOperand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_new_join
Function* HeterotbbTransform::create_new_join(Module &M,Function *join) {
//reduce->dump();
if(!templat) {
DEBUG(dbgs()<<"NO Template Found\n");
return NULL;
}
//join_main->dump();
DEBUG(dbgs()<<"Objext size array"<<object_size_hetero<<"\n");
//create a global with 64*object/4 size
GlobalVariable *gb = M.getGlobalVariable("opencl_kernel_join_name_local_arr",true);
//gb->dump();
Value *val=gb->getOperand(0);
//if(isa<ArrayType>(val->getType()))DEBUG(dbgs()<<"YES\n");
//since we are creating an integer array, the size gets divided by 4
// Do not make it a global variable -- make it a local variable with annotation for local
int local_size = 64*object_size_hetero;
/*const*/ ArrayType *arr= ArrayType::get(Type::getInt32Ty(M.getContext()),(64*object_size_hetero)/4);
/*vector<Constant *> Initializer;
APInt zero(32,0);
for(int i=0;i<(16*object_size_hetero);i++){
Initializer.push_back(ConstantInt::get(M.getContext(),zero));
}
Constant *init = ConstantArray::get(arr, Initializer);
GlobalVariable *new_gb = new GlobalVariable(M, arr, false, GlobalVariable::InternalLinkage,init, "__hetero_local_"+join->getName()+"__local__arr",gb,false,3);
new_gb->setAlignment(gb->getAlignment());
DEBUG(dbgs()<<"Global Created\n");
new_gb->dump();
*/
vector</*const*/ Type *> params;
int temp_size=0;
object_size_hetero=0;
// void join(class.name *,class.name *)
//re-write join
const FunctionType *FTy = join->getFunctionType();
Function::arg_iterator ArgI = join->arg_begin();
// class.name *
params.push_back(PointerType::get((dyn_cast<PointerType>(ArgI->getType())->getElementType()),3));
params.push_back(PointerType::get((dyn_cast<PointerType>(ArgI->getType())->getElementType()),3));
/*const*/ Type *RetTy = FTy->getReturnType();
FunctionType *NFty = FunctionType::get(RetTy,params, false);
Function *NF=Function::Create(NFty, join->getLinkage(), join->getName()+"_inline");
NF->copyAttributesFrom(join);
#if EXPLICIT_REWRITE
copy_function(NF,join);
#else
ValueToValueMapTy VMap;
for(Function::arg_iterator FI = join->arg_begin(), FE=join->arg_end(), DI=NF->arg_begin(); FE!=FI; ++FI,++DI) {
DI->setName(FI->getName());
VMap[FI]=DI;
}
CloneFunctionWithExistingBBInto(NF, NULL, join, VMap);
#endif
//NF->removeFnAttr(Attributes::get(NF->getContext(), Attribute::NoInline));
NF->addFnAttr(Attribute::AlwaysInline);
join->getParent()->getFunctionList().insert(join, NF);
params.clear();
const FunctionType *FTemp = templat->getFunctionType();
//create a new template
for(Function::arg_iterator FI = templat->arg_begin(), FE=templat->arg_end(); FE!=FI; ++FI) {
params.push_back(FI->getType());
}
// templat->replaceUsesOfWith(reduce,NF);
RetTy = FTy->getReturnType();
NFty = FunctionType::get(RetTy,params, false);
Function *templat_copy =Function::Create(NFty, join->getLinkage(), join->getName()+"_hetero");
templat_copy->copyAttributesFrom(templat);
#if EXPLICIT_REWRITE
copy_function(templat_copy,templat);
#else
ValueToValueMapTy VMapp;
for(Function::arg_iterator FI = templat->arg_begin(), FE=templat->arg_end(), DI=templat_copy->arg_begin(); FE!=FI; ++FI,++DI) {
DI->setName(FI->getName());
VMapp[FI]=DI;
}
CloneFunctionWithExistingBBInto(templat_copy, NULL, templat, VMapp);
#endif
/* create a local variable with the following type */
Function::iterator BI = templat_copy->begin();
BasicBlock::iterator II = BI->begin();
Instruction *insn = &(*II);
Constant *l_size = ConstantInt::get(Type::getInt32Ty(M.getContext()), local_size);
Instruction *new_gb_ = new AllocaInst(arr, l_size, gb->getAlignment(), "hetero_local", insn);
//new_gb_->dump();
Value *Elts[] = {MDString::get(M.getContext(), new_gb_->getName())};
MDNode *Node = MDNode::get(M.getContext(), Elts);
new_gb_->setMetadata("local",Node);
Instruction *new_gb= CastInst::Create(Instruction::BitCast, new_gb_,
PointerType::get(arr,3), "hetero_local_cast", insn);
//new_gb->dump();
Value *Elts1[] = {MDString::get(M.getContext(), new_gb->getName())};
MDNode *Node1 = MDNode::get(M.getContext(), Elts1);
//.........这里部分代码省略.........