Ignore:
Timestamp:
Jan 12, 2017, 7:03:38 PM (2 years ago)
Author:
cameron
Message:

finalSegment kernel methods initial check-in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/kernels/interface.cpp

    r5246 r5257  
    9191    arg->setName("blockCnt");
    9292    doSegmentFn->setDoesNotCapture(1); // for self parameter only.
     93    //
     94    // Create the finalSegment function prototype.
     95    std::vector<Type *> finalSegmentParameters = {selfType, iBuilder->getSizeTy()};
     96    FunctionType * finalSegmentFunctionType = FunctionType::get(iBuilder->getVoidTy(), finalSegmentParameters, false);
     97    std::string finalSegmentName = mKernelName + finalSegment_suffix;
     98    Function * finalSegmentFn = Function::Create(finalSegmentFunctionType, GlobalValue::ExternalLinkage, finalSegmentName, client);
     99    finalSegmentFn->setCallingConv(CallingConv::C);
     100    finalSegmentFn->setDoesNotThrow();
     101    Function::arg_iterator finalSegmentArgs = finalSegmentFn->arg_begin();
     102    Value * finalSegmentArg = &*(finalSegmentArgs++);
     103    finalSegmentArg->setName("self");
     104    finalSegmentArg = &*(finalSegmentArgs++);
     105    finalSegmentArg->setName("blockCnt");
     106    finalSegmentFn->setDoesNotCapture(1); // for self parameter only.
    93107    iBuilder->setModule(saveModule);
    94108    iBuilder->restoreIP(savePoint);
     
    132146}
    133147
     148Value * KernelInterface::createFinalSegmentCall(Value * self, Value * blksToDo) const {
     149    Module * m = iBuilder->getModule();
     150    std::string fnName = mKernelName + finalSegment_suffix;
     151    Function * method = m->getFunction(fnName);
     152    if (!method) {
     153        throw std::runtime_error("Cannot find " + fnName);
     154    }
     155    return iBuilder->CreateCall(method, {self, blksToDo});
     156}
     157
    134158Value * KernelInterface::createGetAccumulatorCall(Value * self, std::string accumName) const {
    135159    Module * m = iBuilder->getModule();
Note: See TracChangeset for help on using the changeset viewer.