Changeset 4330


Ignore:
Timestamp:
Dec 10, 2014, 7:23:29 AM (4 years ago)
Author:
cameron
Message:

Restructuring so compile is independent of initialization/finalization

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

Legend:

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

    r4328 r4330  
    112112
    113113    RE_Compiler re_compiler(main, nameMap);
    114     re_compiler.compile(re_ast);
     114    re_compiler.initializeRequiredStreams();
     115    re_compiler.finalizeMatchResult(re_compiler.compile(re_ast));
    115116    #ifdef DEBUG_PRINT_PBIX_AST
    116117    //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4329 r4330  
    4242//#define USE_IF_FOR_NONFINAL 1
    4343
    44 void RE_Compiler::compile(RE * re, PabloBlock & pb) {
     44   
     45void RE_Compiler::initializeRequiredStreams() {
    4546
    4647    mLineFeed = mNameMap["LineFeed"]->getCompiled();
     
    5455    PabloAST * u8pfx3 = mNameMap["UTF8-Prefix3"]->getCompiled();
    5556    PabloAST * u8pfx4 = mNameMap["UTF8-Prefix4"]->getCompiled();
    56     PabloAST * u8pfx = pb.createOr(pb.createOr(u8pfx2, u8pfx3), u8pfx4);
    57     mInitial = pb.createVar(pb.createAssign(initial, pb.createOr(u8pfx, u8single)));
     57    PabloAST * u8pfx = mCG.createOr(mCG.createOr(u8pfx2, u8pfx3), u8pfx4);
     58    mInitial = mCG.createVar(mCG.createAssign(initial, mCG.createOr(u8pfx, u8single)));
    5859    #ifdef USE_IF_FOR_NONFINAL
    59     mNonFinal = pb.createVar(pb.createAssign(nonfinal, pb.createZeroes()));
     60    mNonFinal = mCG.createVar(pb.createAssign(nonfinal, mCG.createZeroes()));
    6061    #endif
    61     PabloAST * u8scope32 = pb.createAdvance(u8pfx3, 1);
    62     PabloAST * u8scope42 = pb.createAdvance(u8pfx4, 1);
    63     PabloAST * u8scope43 = pb.createAdvance(u8scope42, 1);
     62    PabloAST * u8scope32 = mCG.createAdvance(u8pfx3, 1);
     63    PabloAST * u8scope42 = mCG.createAdvance(u8pfx4, 1);
     64    PabloAST * u8scope43 = mCG.createAdvance(u8scope42, 1);
    6465    #ifdef USE_IF_FOR_NONFINAL
    65     PabloBlock it(pb);
     66    PabloBlock it(mCG);
    6667    it.createAssign(nonfinal, it.createOr(it.createOr(u8pfx, u8scope32), it.createOr(u8scope42, u8scope43)));
    67     pb.createIf(u8pfx, std::move(it));
     68    mCG.createIf(u8pfx, std::move(it));
    6869    #else
    69     mNonFinal = pb.createVar(pb.createAssign(nonfinal, pb.createOr(pb.createOr(u8pfx, u8scope32), pb.createOr(u8scope42, u8scope43))));
     70    mNonFinal = mCG.createVar(mCG.createAssign(nonfinal, mCG.createOr(mCG.createOr(u8pfx, u8scope32), mCG.createOr(u8scope42, u8scope43))));
    7071    #endif
    71 
    72     PabloAST * result = process(re, pb.createAssign("start", pb.createOnes()), pb);
    73 
     72}
     73
     74void RE_Compiler::finalizeMatchResult(Assign * match_result) {
    7475    //These three lines are specifically for grep.
    75     pb.createAssign("matches", pb.createAnd(pb.createMatchStar(pb.createVar(result), pb.createNot(mLineFeed)), mLineFeed), 0);
    76     pb.createAssign("lf", mLineFeed, 1);
    77 }
    78 
     76    mCG.createAssign("matches", mCG.createAnd(mCG.createMatchStar(mCG.createVar(match_result), mCG.createNot(mLineFeed)), mLineFeed), 0);
     77    mCG.createAssign("lf", mLineFeed, 1);
     78}
     79   
     80Assign * RE_Compiler::compile(RE * re, PabloBlock & pb) {
     81        return process(re, pb.createAssign("start", pb.createOnes()), pb);
     82}
     83       
    7984PabloAST * RE_Compiler::character_class_strm(Name * name, PabloBlock & pb) {
    8085    if (name->getType() == Name::Type::UnicodeCategory) {
  • icGREP/icgrep-devel/icgrep/re/re_compiler.h

    r4298 r4330  
    3030
    3131    RE_Compiler(pablo::PabloBlock & baseCG, const cc::CC_NameMap & nameMap);
    32 
    33     inline void compile(RE * re) {
    34         compile(re, mCG);
     32    void initializeRequiredStreams();
     33    void finalizeMatchResult(pablo::Assign * match_result);
     34    pablo::Assign * compile(RE * re) {
     35        return compile(re, mCG);
    3536    }
    3637
    3738private:
    3839
    39     void compile(RE * re, pablo::PabloBlock & cg);
     40    pablo::Assign * compile(RE * re, pablo::PabloBlock & cg);
    4041
    4142    pablo::PabloAST * character_class_strm(Name * name, pablo::PabloBlock & pb);
Note: See TracChangeset for help on using the changeset viewer.