Ignore:
Timestamp:
May 10, 2017, 4:26:11 PM (2 years ago)
Author:
nmedfort
Message:

Large refactoring step. Removed IR generation code from Kernel (formally KernelBuilder?) and moved it into the new KernelBuilder? class.

File:
1 edited

Legend:

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

    r5436 r5440  
    1414namespace kernel {
    1515
    16 void CCScanKernel::generateDoBlockMethod() {
     16void CCScanKernel::generateDoBlockMethod(const std::unique_ptr<KernelBuilder> & iBuilder) {
    1717    auto savePoint = iBuilder->saveIP();
    18     Function * scanWordFunction = generateScanWordRoutine(iBuilder->getModule());
     18    Function * scanWordFunction = generateScanWordRoutine(iBuilder);
    1919    iBuilder->restoreIP(savePoint);
    2020
     
    2222    Type * T = iBuilder->getIntNTy(mScanwordBitWidth);
    2323    VectorType * scanwordVectorType =  VectorType::get(T, fieldCount);   
    24     Value * blockNo = getScalarField("BlockNo");
     24    Value * blockNo = iBuilder->getScalarField("BlockNo");
    2525    Value * scanwordPos = iBuilder->CreateMul(blockNo, ConstantInt::get(blockNo->getType(), iBuilder->getBitBlockWidth()));
    2626   
    2727    std::vector<Value * > matchWordVectors;
    2828    for(unsigned d = 0; d < mStreamNum; d++) {
    29         Value * matches = loadInputStreamBlock("matchResults", iBuilder->getInt32(d));
     29        Value * matches = iBuilder->loadInputStreamBlock("matchResults", iBuilder->getInt32(d));
    3030        matchWordVectors.push_back(iBuilder->CreateBitCast(matches, scanwordVectorType));
    3131    }
     
    3838        scanwordPos = iBuilder->CreateAdd(scanwordPos, ConstantInt::get(T, mScanwordBitWidth));
    3939    }   
    40     setScalarField("BlockNo", iBuilder->CreateAdd(blockNo, iBuilder->getSize(1)));
     40    iBuilder->setScalarField("BlockNo", iBuilder->CreateAdd(blockNo, iBuilder->getSize(1)));
    4141}
    4242
    43 Function * CCScanKernel::generateScanWordRoutine(Module * m) const {
     43Function * CCScanKernel::generateScanWordRoutine(const std::unique_ptr<KernelBuilder> & iBuilder) const {
    4444
    4545    IntegerType * T = iBuilder->getIntNTy(mScanwordBitWidth);
     46
     47    Module * const m = iBuilder->getModule();
    4648
    4749    Function * scanFunc = cast<Function>(m->getOrInsertFunction("scan_word", iBuilder->getVoidTy(), T, iBuilder->getInt32Ty(), T, nullptr));
Note: See TracChangeset for help on using the changeset viewer.