Ignore:
Timestamp:
Apr 18, 2017, 10:41:50 PM (2 years ago)
Author:
cameron
Message:

Factor out CountOnly? and InvertMatches? as separate kernels

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r5404 r5413  
    198198}
    199199
    200 void RE_Compiler::finalizeMatchResult(MarkerType match_result, bool InvertMatches) {
     200void RE_Compiler::finalizeMatchResult(MarkerType match_result) {
    201201    PabloAST * match_follow = mPB.createMatchStar(markerVar(match_result), mAny);
    202     if (InvertMatches) {
    203         match_follow = mPB.createNot(match_follow);
    204     }
    205     PabloAST * matches = mPB.createAnd(match_follow, mLineBreak, "matches");
    206     if (mCountOnly) {
    207         Var * const output = mKernel->getOutputScalarVar("matchedLineCount");
    208         PabloBuilder nestedCount = PabloBuilder::Create(mPB);
    209         mPB.createIf(matches, nestedCount);
    210         nestedCount.createAssign(output, nestedCount.createCount(matches));
    211     } else {
    212         Var * const output = mKernel->getOutputStreamVar("matches");
    213         mPB.createAssign(mPB.createExtract(output, mPB.getInteger(0)), matches);
    214     }
     202    PabloAST * matches = mPB.createAnd(match_follow, mLineBreak, "matchedLine3s");
     203    Var * const output = mKernel->getOutputStreamVar("matches");
     204    mPB.createAssign(mPB.createExtract(output, mPB.getInteger(0)), matches);
    215205}
    216206
     
    625615   
    626616
    627 RE_Compiler::RE_Compiler(PabloKernel * kernel, cc::CC_Compiler & ccCompiler, bool CountOnly)
     617RE_Compiler::RE_Compiler(PabloKernel * kernel, cc::CC_Compiler & ccCompiler)
    628618: mKernel(kernel)
    629 , mCountOnly(CountOnly)
    630619, mCCCompiler(ccCompiler)
    631620, mLineBreak(nullptr)
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r5357 r5413  
    6060public:
    6161
    62     RE_Compiler(pablo::PabloKernel * kernel, cc::CC_Compiler & ccCompiler, bool CountOnly = false);
     62    RE_Compiler(pablo::PabloKernel * kernel, cc::CC_Compiler & ccCompiler);
    6363    void initializeRequiredStreams(const unsigned encodingBits, pablo::Var * linebreak);
    6464    void compileUnicodeNames(RE *& re);
    65     void finalizeMatchResult(MarkerType match_result, bool InvertMatches = false);
     65    void finalizeMatchResult(MarkerType match_result);
    6666    MarkerType compile(RE * re) {
    6767        return compile(re, mPB);
  • icGREP/icgrep-devel/icgrep/re/re_toolchain.cpp

    r5357 r5413  
    8585}
    8686   
    87 void re2pablo_compiler(PabloKernel * kernel, RE * re_ast, const bool CountOnly) {
     87void re2pablo_compiler(PabloKernel * kernel, RE * re_ast) {
    8888    Var * const basis = kernel->getInputStreamVar("basis");
    8989    Var * const linebreak = kernel->getInputStreamVar("linebreak");
    9090    cc::CC_Compiler cc_compiler(kernel, basis);
    91     re::RE_Compiler re_compiler(kernel, cc_compiler, CountOnly);
     91    re::RE_Compiler re_compiler(kernel, cc_compiler);
    9292    re_compiler.initializeRequiredStreams(basis->getType()->getArrayNumElements(), linebreak);
    9393    re_compiler.compileUnicodeNames(re_ast);
    94     re_compiler.finalizeMatchResult(re_compiler.compile(re_ast), AlgorithmOptions.isSet(InvertMatches));
     94    re_compiler.finalizeMatchResult(re_compiler.compile(re_ast));
    9595}
    9696
  • icGREP/icgrep-devel/icgrep/re/re_toolchain.h

    r5310 r5413  
    3131RE * regular_expression_passes(RE * re_ast);
    3232
    33 void re2pablo_compiler(pablo::PabloKernel * kernel, RE * re_ast, const bool CountOnly = false);
     33void re2pablo_compiler(pablo::PabloKernel * kernel, RE * re_ast);
    3434   
    3535}
Note: See TracChangeset for help on using the changeset viewer.