Ignore:
Timestamp:
Jan 29, 2017, 12:05:00 PM (2 years ago)
Author:
nmedfort
Message:

Continuation of work to simplify Kernel writing

File:
1 edited

Legend:

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

    r5283 r5286  
    1717namespace kernel {
    1818           
    19 void MMapSourceKernel::generateDoSegmentMethod() const {
    20     auto savePoint = iBuilder->saveIP();
    21     Module * m = iBuilder->getModule();
    22     Function * doSegmentFunction = m->getFunction(mKernelName + doSegment_suffix);
    23    
    24     iBuilder->SetInsertPoint(BasicBlock::Create(iBuilder->getContext(), mKernelName + "_entry", doSegmentFunction, 0));
     19void MMapSourceKernel::generateDoSegmentMethod(Function * doSegmentFunction, Value *self, Value *doFinal, const std::vector<Value *> &producerPos) const {
    2520    BasicBlock * setTermination = BasicBlock::Create(iBuilder->getContext(), "setTermination", doSegmentFunction, 0);
    2621    BasicBlock * mmapSourceExit = BasicBlock::Create(iBuilder->getContext(), "mmapSourceExit", doSegmentFunction, 0);
    27     Constant * segmentItems = iBuilder->getSize(mSegmentBlocks * iBuilder->getBitBlockWidth());
    28    
    29    
    30     auto args = doSegmentFunction->arg_begin();
    31     Value * self = &*(args++);
    32    
     22    ConstantInt * segmentItems = iBuilder->getSize(mSegmentBlocks * iBuilder->getBitBlockWidth());
    3323    Value * fileItems = getScalarField(self, "fileSize");
    3424    if (mCodeUnitWidth > 8) {
    35         fileItems = iBuilder->CreateUDiv(fileItems, iBuilder->getSize(mCodeUnitWidth/8));
     25        fileItems = iBuilder->CreateUDiv(fileItems, iBuilder->getSize(mCodeUnitWidth / 8));
    3626    }
    3727    Value * produced = getProducedItemCount(self, "sourceBuffer");   
     
    4030    produced = iBuilder->CreateSelect(lessThanFullSegment, fileItems, nextProduced);
    4131    setProducedItemCount(self, "sourceBuffer", produced);
    42    
     32
    4333    iBuilder->CreateCondBr(lessThanFullSegment, setTermination, mmapSourceExit);
    4434    iBuilder->SetInsertPoint(setTermination);
    4535    setTerminationSignal(self);
    46     iBuilder->CreateBr(mmapSourceExit);
    47    
     36    iBuilder->CreateBr(mmapSourceExit);   
     37
    4838    iBuilder->SetInsertPoint(mmapSourceExit);
    49     iBuilder->CreateRetVoid();
    50     iBuilder->restoreIP(savePoint);
    5139}
    5240
Note: See TracChangeset for help on using the changeset viewer.