if (F.hasAvailableExternallyLinkage())
return false;
+ // As we inline all function calls, so skip non-kernel functions
+ bool bKernel = isKernelFunction(F);
+ if(!bKernel) return false;
+
LI = &getAnalysis<LoopInfo>();
emitFunction(F);
/*! Get the type size in bytes */
uint32_t getTypeByteSize(const ir::Unit &unit, llvm::Type* Ty);
+ /*! whether this is a kernel function */
+ bool isKernelFunction(const llvm::Function &f);
+
/*! Create a Gen-IR unit */
llvm::FunctionPass *createGenPass(ir::Unit &unit);
namespace gbe
{
+ bool isKernelFunction(const llvm::Function &F) {
+ const Module *module = F.getParent();
+ const Module::NamedMDListType& globalMD = module->getNamedMDList();
+ bool bKernel = false;
+ for(auto i = globalMD.begin(); i != globalMD.end(); i++) {
+ const NamedMDNode &md = *i;
+ if(strcmp(md.getName().data(), "opencl.kernels") != 0) continue;
+ uint32_t ops = md.getNumOperands();
+ for(uint32_t x = 0; x < ops; x++) {
+ MDNode* node = md.getOperand(x);
+ Value * op = node->getOperand(0);
+ if(op == &F) bKernel = true;
+ }
+ }
+ return bKernel;
+ }
+
uint32_t getPadding(uint32_t offset, uint32_t align) {
return (align - (offset % align)) % align;
}
default: GBE_ASSERTM(false, "Unsupported calling convention");
}
+ // As we inline all function calls, so skip non-kernel functions
+ bool bKernel = isKernelFunction(F);
+ if(!bKernel) return false;
+
bool changed = false;
module = F.getParent();
intTy = IntegerType::get(module->getContext(), 32);