Changeset 5035


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

Location:
icGREP/icgrep-devel/icgrep
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.cpp

    r5023 r5035  
    4646}
    4747
     48
     49   
    4850template<typename PabloBlockOrBuilder>
    4951PabloAST * CC_Compiler::charset_expr(const CC * cc, PabloBlockOrBuilder & pb) {
     
    5153        return pb.createZeroes();
    5254    }
     55#ifdef CC_COMPILER_ENFORCES_INFILE
    5356    bool includes_codepoint_zero = lo_codepoint(cc->begin()) == 0;
     57#endif
    5458    if (cc->size() > 2) {
    5559        bool combine = true;
     
    8892        expr = (expr == nullptr) ? temp : pb.createOr(expr, temp);
    8993    }
     94#ifdef CC_COMPILER_ENFORCES_INFILE
    9095    if (includes_codepoint_zero) {
    9196        return pb.createInFile(expr);
     
    9499        return expr;
    95100    }
     101#else
     102    return expr;
     103#endif
     104   
    96105}
    97106
  • icGREP/icgrep-devel/icgrep/kernels/pipeline.cpp

    r5033 r5035  
    211211    Value * EOF_pos = iBuilder->CreateShl(ConstantInt::get(iBuilder->getIntNTy(mBlockSize), 1), remaining);
    212212    EOF_pos = iBuilder->CreateBitCast(EOF_pos, mBitBlockType);
     213    Value * EOF_mask = iBuilder->CreateShl(Constant::getAllOnesValue(iBuilder->getIntNTy(mBlockSize)), remaining);
     214        icGrepInstance->setInternalState("EOFmask", iBuilder->CreateBitCast(EOF_mask, mBitBlockType));
    213215
    214216
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r5031 r5035  
    112112
    113113    mCarryManager->initialize(function, mKernelBuilder);
    114 
     114   
     115    mKernelBuilder->addInternalState(mBitBlockType, "EOFmask");
     116   
    115117    mFunction = mKernelBuilder->prepareFunction({mInputStreamOffset.begin(), mInputStreamOffset.end()});
    116118
     
    396398    } else if (const InFile * e = dyn_cast<InFile>(stmt)) {
    397399        // Currently InFile(x) => x;  a no-op
    398         expr = compileExpression(e->getExpr());
     400        Value * EOFmask = iBuilder->CreateLoad(mKernelBuilder->getInternalState("EOFmask"));
     401        expr = iBuilder->simd_and(compileExpression(e->getExpr()), iBuilder->simd_not(EOFmask));
    399402    } else if (const Count * c = dyn_cast<Count>(stmt)) {
    400403        Value * const to_count = compileExpression(c->getExpr());
  • 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.