Ignore:
Timestamp:
May 8, 2016, 7:01:04 PM (3 years ago)
Author:
cameron
Message:

Add EOFmask internal state value to generated Pablo functions; implement pablo.inFile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/wc.cpp

    r5034 r5035  
    113113    }
    114114    else function->setResult(0, pBuilder.createAssign("lineCount", pBuilder.createZeroes()));
    115     // FIXME - we need to limit this to pablo.inFile() because null bytes past EOF are matched by wordChar
    116115    if (CountWords) {
    117116        pablo::PabloAST * WS = ccc.compileCC(re::makeCC(re::makeCC(0x09, 0x0D), re::makeCC(0x20)));
    118117       
    119         pablo::PabloAST * wordChar = ccc.compileCC(re::makeCC(re::makeCC(re::makeCC(0x00, 0x08), re::makeCC(0xE, 0x1F)), re::makeCC(0x21, 0xFF)));
     118        pablo::PabloAST * wordChar = pBuilder.createNot(WS);
    120119        // WS_follow_or_start = 1 past WS or at start of file
    121         pablo::PabloAST * WS_follow_or_start = pBuilder.createNot(pBuilder.createAdvance(pBuilder.createNot(WS), 1));
     120        pablo::PabloAST * WS_follow_or_start = pBuilder.createNot(pBuilder.createAdvance(wordChar, 1));
    122121        //
    123         pablo::PabloAST * wordStart = pBuilder.createAnd(wordChar, WS_follow_or_start);
     122        pablo::PabloAST * wordStart = pBuilder.createInFile(pBuilder.createAnd(wordChar, WS_follow_or_start));
    124123        function->setResult(1, pBuilder.createAssign("wordCount", pBuilder.createCount(wordStart)));
    125124    }
     
    287286   
    288287    iBuilder->SetInsertPoint(finalBlock);
     288    Value * EOF_mask = iBuilder->CreateShl(Constant::getAllOnesValue(iBuilder->getIntNTy(mBlockSize)), remainingBytes);
     289        wcInstance->setInternalState("EOFmask", iBuilder->CreateBitCast(EOF_mask, mBitBlockType));
     290   
    289291    Value * emptyBlockCond = iBuilder->CreateICmpEQ(remainingBytes, ConstantInt::get(int64ty, 0));
    290292    iBuilder->CreateCondBr(emptyBlockCond, finalEmptyBlock, finalPartialBlock);
     
    293295    iBuilder->SetInsertPoint(finalPartialBlock);
    294296    s2pInstance->CreateDoBlockCall();
     297
    295298    iBuilder->CreateBr(endBlock);
    296299   
Note: See TracChangeset for help on using the changeset viewer.