Lines Matching refs:llvm
57 class RSForEachExpandPass : public llvm::ModulePass {
90 llvm::Module *Module;
91 llvm::LLVMContext *Context;
98 llvm::FunctionType *ExpandedFunctionType;
107 uint32_t getRootSignature(llvm::Function *Function) { in getRootSignature()
108 const llvm::NamedMDNode *ExportForEachMetadata = in getRootSignature()
112 llvm::SmallVector<llvm::Type*, 8> RootArgTys; in getRootSignature()
113 for (llvm::Function::arg_iterator B = Function->arg_begin(), in getRootSignature()
134 llvm::MDNode *SigNode = ExportForEachMetadata->getOperand(0); in getRootSignature()
136 llvm::Metadata *SigMD = SigNode->getOperand(0); in getRootSignature()
137 if (llvm::MDString *SigS = llvm::dyn_cast<llvm::MDString>(SigMD)) { in getRootSignature()
138 llvm::StringRef SigString = SigS->getString(); in getRootSignature()
151 bool isStepOptSupported(llvm::Type *AllocType) { in isStepOptSupported()
153 llvm::PointerType *PT = llvm::dyn_cast<llvm::PointerType>(AllocType); in isStepOptSupported()
154 llvm::Type *VoidPtrTy = llvm::Type::getInt8PtrTy(*Context); in isStepOptSupported()
174 if (AllocType->getStructName().find("coerce") != llvm::StringRef::npos) { in isStepOptSupported()
179 llvm::Type *V2xi64Ty = llvm::VectorType::get(llvm::Type::getInt64Ty(*Context), 2); in isStepOptSupported()
180 llvm::Type *Int128Ty = llvm::Type::getIntNTy(*Context, 128); in isStepOptSupported()
198 llvm::Value *getStepValue(llvm::DataLayout *DL, llvm::Type *AllocType, in getStepValue()
199 llvm::Value *OrigStep) { in getStepValue()
203 llvm::PointerType *PT = llvm::dyn_cast<llvm::PointerType>(AllocType); in getStepValue()
205 llvm::Type *ET = PT->getElementType(); in getStepValue()
207 llvm::Type *Int32Ty = llvm::Type::getInt32Ty(*Context); in getStepValue()
208 return llvm::ConstantInt::get(Int32Ty, ETSize); in getStepValue()
218 llvm::Type *Int8Ty = llvm::Type::getInt8Ty(*Context); in buildTypes()
219 llvm::Type *Int8PtrTy = Int8Ty->getPointerTo(); in buildTypes()
220 llvm::Type *Int8PtrArrayInputLimitTy = llvm::ArrayType::get(Int8PtrTy, RS_KERNEL_INPUT_LIMIT); in buildTypes()
221 llvm::Type *Int32Ty = llvm::Type::getInt32Ty(*Context); in buildTypes()
222 llvm::Type *Int32ArrayInputLimitTy = llvm::ArrayType::get(Int32Ty, RS_KERNEL_INPUT_LIMIT); in buildTypes()
223 llvm::Type *VoidPtrTy = llvm::Type::getInt8PtrTy(*Context); in buildTypes()
224 llvm::Type *Int32Array4Ty = llvm::ArrayType::get(Int32Ty, 4); in buildTypes()
237 llvm::SmallVector<llvm::Type*, RsLaunchDimensionsFieldCount> RsLaunchDimensionsTypes; in buildTypes()
244 llvm::StructType *RsLaunchDimensionsTy = in buildTypes()
245 llvm::StructType::create(RsLaunchDimensionsTypes, "RsLaunchDimensions"); in buildTypes()
274 …llvm::SmallVector<llvm::Type*, RsExpandKernelDriverInfoPfxFieldCount> RsExpandKernelDriverInfoPfxT… in buildTypes()
285 llvm::StructType *RsExpandKernelDriverInfoPfxTy = in buildTypes()
286 llvm::StructType::create(RsExpandKernelDriverInfoPfxTypes, "RsExpandKernelDriverInfoPfx"); in buildTypes()
290 llvm::Type *RsExpandKernelDriverInfoPfxPtrTy = RsExpandKernelDriverInfoPfxTy->getPointerTo(); in buildTypes()
292 llvm::SmallVector<llvm::Type*, 8> ParamTypes; in buildTypes()
299 llvm::FunctionType::get(llvm::Type::getVoidTy(*Context), ParamTypes, in buildTypes()
310 llvm::Function *createEmptyExpandedFunction(llvm::StringRef OldName) { in createEmptyExpandedFunction()
311 llvm::Function *ExpandedFunction = in createEmptyExpandedFunction()
312 llvm::Function::Create(ExpandedFunctionType, in createEmptyExpandedFunction()
313 llvm::GlobalValue::ExternalLinkage, in createEmptyExpandedFunction()
318 llvm::Function::arg_iterator AI = ExpandedFunction->arg_begin(); in createEmptyExpandedFunction()
325 llvm::BasicBlock *Begin = llvm::BasicBlock::Create(*Context, "Begin", in createEmptyExpandedFunction()
327 llvm::IRBuilder<> Builder(Begin); in createEmptyExpandedFunction()
350 llvm::BasicBlock *createLoop(llvm::IRBuilder<> &Builder, in createLoop()
351 llvm::Value *LowerBound, in createLoop()
352 llvm::Value *UpperBound, in createLoop()
353 llvm::PHINode **LoopIV) { in createLoop()
356 llvm::BasicBlock *CondBB, *AfterBB, *HeaderBB; in createLoop()
357 llvm::Value *Cond, *IVNext; in createLoop()
358 llvm::PHINode *IV; in createLoop()
361 AfterBB = llvm::SplitBlock(CondBB, Builder.GetInsertPoint(), nullptr, nullptr); in createLoop()
362 HeaderBB = llvm::BasicBlock::Create(*Context, "Loop", CondBB->getParent()); in createLoop()
403 void finishArgList( llvm::SmallVector<llvm::Value *, ArgVectorLen> &ArgVector, in finishArgList()
404 const llvm::SmallVector<llvm::Value *, SpecialArgVectorLen> &SpecialArgVector, in finishArgList()
406 const llvm::Function &CalleeFunction, in finishArgList()
407 llvm::IRBuilder<> &CallerBuilder) { in finishArgList()
417 llvm::Type *ContextArgType = nullptr; in finishArgList()
437 virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const override { in getAnalysisUsage()
456 llvm::Value *X, in ExpandSpecialArguments()
457 llvm::Value *Arg_p, in ExpandSpecialArguments()
458 llvm::IRBuilder<> &Builder, in ExpandSpecialArguments()
459 llvm::SmallVector<llvm::Value*, 8> &CalleeArgs, in ExpandSpecialArguments()
479 …llvm::Value *Current = Builder.CreateStructGEP(nullptr, Arg_p, RsExpandKernelDriverInfoPfxFieldCur… in ExpandSpecialArguments()
482 llvm::Value *Y = Builder.CreateLoad( in ExpandSpecialArguments()
490 llvm::Value *Z = Builder.CreateLoad( in ExpandSpecialArguments()
504 bool ExpandFunction(llvm::Function *Function, uint32_t Signature) { in ExpandFunction()
517 llvm::DataLayout DL(Module); in ExpandFunction()
519 llvm::Function *ExpandedFunction = in ExpandFunction()
529 llvm::Function::arg_iterator ExpandedFunctionArgIter = in ExpandFunction()
532 llvm::Value *Arg_p = &*(ExpandedFunctionArgIter++); in ExpandFunction()
533 llvm::Value *Arg_x1 = &*(ExpandedFunctionArgIter++); in ExpandFunction()
534 llvm::Value *Arg_x2 = &*(ExpandedFunctionArgIter++); in ExpandFunction()
535 llvm::Value *Arg_outstep = &*(ExpandedFunctionArgIter); in ExpandFunction()
537 llvm::Value *InStep = nullptr; in ExpandFunction()
538 llvm::Value *OutStep = nullptr; in ExpandFunction()
541 llvm::IRBuilder<> Builder(ExpandedFunction->getEntryBlock().begin()); in ExpandFunction()
545 llvm::Function::arg_iterator FunctionArgIter = Function->arg_begin(); in ExpandFunction()
547 llvm::Type *InTy = nullptr; in ExpandFunction()
548 llvm::Value *InBasePtr = nullptr; in ExpandFunction()
550 …llvm::Value *InsBasePtr = Builder.CreateStructGEP(nullptr, Arg_p, RsExpandKernelDriverInfoPfxFiel… in ExpandFunction()
552 …llvm::Value *InStepsBase = Builder.CreateStructGEP(nullptr, Arg_p, RsExpandKernelDriverInfoPfxFiel… in ExpandFunction()
554 llvm::Value *InStepAddr = Builder.CreateConstInBoundsGEP2_32(nullptr, InStepsBase, 0, 0); in ExpandFunction()
555 llvm::LoadInst *InStepArg = Builder.CreateLoad(InStepAddr, in ExpandFunction()
563 llvm::Value *InputAddr = Builder.CreateConstInBoundsGEP2_32(nullptr, InsBasePtr, 0, 0); in ExpandFunction()
567 llvm::Type *OutTy = nullptr; in ExpandFunction()
568 llvm::Value *OutBasePtr = nullptr; in ExpandFunction()
579 llvm::Value *UsrData = nullptr; in ExpandFunction()
581 llvm::Type *UsrDataTy = (FunctionArgIter++)->getType(); in ExpandFunction()
587 llvm::PHINode *IV; in ExpandFunction()
590 llvm::SmallVector<llvm::Value*, 8> CalleeArgs; in ExpandFunction()
597 llvm::SmallVector<llvm::Value*, 8> RootArgs; in ExpandFunction()
599 llvm::Value *InPtr = nullptr; in ExpandFunction()
600 llvm::Value *OutPtr = nullptr; in ExpandFunction()
611 llvm::Value *OutOffset = Builder.CreateSub(IV, Arg_x1); in ExpandFunction()
618 llvm::Value *InOffset = Builder.CreateSub(IV, Arg_x1); in ExpandFunction()
645 bool ExpandKernel(llvm::Function *Function, uint32_t Signature) { in ExpandKernel()
650 llvm::DataLayout DL(Module); in ExpandKernel()
652 llvm::Function *ExpandedFunction = in ExpandKernel()
662 llvm::Function::arg_iterator ExpandedFunctionArgIter = in ExpandKernel()
665 llvm::Value *Arg_p = &*(ExpandedFunctionArgIter++); in ExpandKernel()
666 llvm::Value *Arg_x1 = &*(ExpandedFunctionArgIter++); in ExpandKernel()
667 llvm::Value *Arg_x2 = &*(ExpandedFunctionArgIter++); in ExpandKernel()
668 llvm::Value *Arg_outstep = &*(ExpandedFunctionArgIter); in ExpandKernel()
671 llvm::IRBuilder<> Builder(ExpandedFunction->getEntryBlock().begin()); in ExpandKernel()
674 llvm::MDNode *TBAARenderScriptDistinct, *TBAARenderScript, in ExpandKernel()
676 llvm::MDBuilder MDHelper(*Context); in ExpandKernel()
690 llvm::MDNode *AliasingDomain, *AliasingScope; in ExpandKernel()
705 llvm::Function::arg_iterator ArgIter = Function->arg_begin(); in ExpandKernel()
708 llvm::Type *OutTy = nullptr; in ExpandKernel()
709 llvm::Value *OutStep = nullptr; in ExpandKernel()
710 llvm::LoadInst *OutBasePtr = nullptr; in ExpandKernel()
711 llvm::Value *CastedOutBasePtr = nullptr; in ExpandKernel()
716 llvm::Type *OutBaseTy = Function->getReturnType(); in ExpandKernel()
745 llvm::PHINode *IV; in ExpandKernel()
748 llvm::SmallVector<llvm::Value*, 8> CalleeArgs; in ExpandKernel()
752 llvm::SmallVector<llvm::Type*, 8> InTypes; in ExpandKernel()
753 llvm::SmallVector<llvm::Value*, 8> InSteps; in ExpandKernel()
754 llvm::SmallVector<llvm::Value*, 8> InBasePtrs; in ExpandKernel()
755 llvm::SmallVector<llvm::Value*, 8> InStructTempSlots; in ExpandKernel()
760 …llvm::Value *InsBasePtr = Builder.CreateStructGEP(nullptr, Arg_p, RsExpandKernelDriverInfoPfxFiel… in ExpandKernel()
762 …llvm::Value *InStepsBase = Builder.CreateStructGEP(nullptr, Arg_p, RsExpandKernelDriverInfoPfxFiel… in ExpandKernel()
764 llvm::Instruction *AllocaInsertionPoint = &*ExpandedFunction->getEntryBlock().begin(); in ExpandKernel()
768 …llvm::Value *InStepAddr = Builder.CreateConstInBoundsGEP2_32(nullptr, InStepsBase, 0, InputInde… in ExpandKernel()
769 llvm::LoadInst *InStepArg = Builder.CreateLoad(InStepAddr, in ExpandKernel()
772 llvm::Type *InType = ArgIter->getType(); in ExpandKernel()
784 if (auto PtrType = llvm::dyn_cast<llvm::PointerType>(InType)) { in ExpandKernel()
785 llvm::Type *ElementType = PtrType->getElementType(); in ExpandKernel()
787 llvm::Value *Slot = new llvm::AllocaInst(ElementType, in ExpandKernel()
798 llvm::Value *InStep = getStepValue(&DL, InType, InStepArg); in ExpandKernel()
802 …llvm::Value *InputAddr = Builder.CreateConstInBoundsGEP2_32(nullptr, InsBasePtr, 0, InputIndex); in ExpandKernel()
803 llvm::LoadInst *InBasePtr = Builder.CreateLoad(InputAddr, in ExpandKernel()
805 llvm::Value *CastInBasePtr = Builder.CreatePointerCast(InBasePtr, in ExpandKernel()
820 llvm::SmallVector<llvm::Value*, 8> RootArgs; in ExpandKernel()
835 llvm::Value *OutPtr = nullptr; in ExpandKernel()
837 llvm::Value *OutOffset = Builder.CreateSub(IV, Arg_x1); in ExpandKernel()
849 llvm::Value *Offset = Builder.CreateSub(IV, Arg_x1); in ExpandKernel()
852 llvm::Value *InPtr = Builder.CreateGEP(InBasePtrs[Index], Offset); in ExpandKernel()
853 llvm::Value *Input; in ExpandKernel()
855 if (llvm::Value *TemporarySlot = InStructTempSlots[Index]) { in ExpandKernel()
860 llvm::Type *ElementType = llvm::cast<llvm::PointerType>( in ExpandKernel()
872 llvm::LoadInst *InputLoad = Builder.CreateLoad(InPtr, "input"); in ExpandKernel()
889 llvm::Value *RetVal = Builder.CreateCall(Function, RootArgs); in ExpandKernel()
892 llvm::StoreInst *Store = Builder.CreateStore(RetVal, OutPtr); in ExpandKernel()
912 bool allocPointersExposed(llvm::Module &Module) { in allocPointersExposed()
947 llvm::Function *Function = Module.getFunction(*FI); in allocPointersExposed()
972 void connectRenderScriptTBAAMetadata(llvm::Module &Module) { in connectRenderScriptTBAAMetadata()
973 llvm::MDBuilder MDHelper(*Context); in connectRenderScriptTBAAMetadata()
974 llvm::MDNode *TBAARenderScriptDistinct = in connectRenderScriptTBAAMetadata()
976 llvm::MDNode *TBAARenderScript = MDHelper.createTBAANode( in connectRenderScriptTBAAMetadata()
978 llvm::MDNode *TBAARoot = MDHelper.createTBAARoot("Simple C/C++ TBAA"); in connectRenderScriptTBAAMetadata()
982 virtual bool runOnModule(llvm::Module &Module) { in runOnModule()
1003 llvm::Function *kernel = Module.getFunction(name); in runOnModule()
1007 kernel->setLinkage(llvm::GlobalValue::InternalLinkage); in runOnModule()
1010 kernel->setLinkage(llvm::GlobalValue::InternalLinkage); in runOnModule()
1035 static llvm::RegisterPass<RSForEachExpandPass> X("foreachexp", "ForEach Expand Pass");
1039 llvm::ModulePass *