Changeset 3963 for icGREP


Ignore:
Timestamp:
Aug 6, 2014, 8:47:08 AM (5 years ago)
Author:
daled
Message:

Eliminated all of the extra marker bit stream variables that were being used to generate the internal.inital and internal.nonfinal bit streams.

File:
1 edited

Legend:

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

    r3961 r3963  
    5555CodeGenState Pbix_Compiler::compile(RE *re)
    5656{   
    57     std::string gs_retVal;
    5857    CodeGenState cg_state;
    5958
     59    std::string gs_m0 = symgen.gensym("start_marker");
     60    cg_state.stmtsl.push_back(new Assign(gs_m0, new All(1)));
     61    cg_state.newsym = gs_m0;
     62
    6063    //Set the 'internal.initial' bit stream for the utf-8 multi-byte encoding.
    61     gs_retVal = symgen.gensym("start_marker");
    62     cg_state.stmtsl.push_back(new Assign(gs_retVal, new All(1)));
    63     cg_state.newsym = gs_retVal;
    64 
    65     std::string gs_retVal_m1 = symgen.gensym("marker");
    66     cg_state.stmtsl.push_back(new Assign(gs_retVal_m1, new And(new Var(m_name_map.find("UTF8-SingleByte")->second), new Var(cg_state.newsym))));
    67 
    68     std::string gs_retVal_m2 = symgen.gensym("marker");
    69     cg_state.stmtsl.push_back(new Assign(gs_retVal_m2, new And(new Var(m_name_map.find("UTF8-Prefix2")->second), new Var(cg_state.newsym))));
    70 
    71     std::string gs_retVal_m3 = symgen.gensym("marker");
    72     cg_state.stmtsl.push_back(new Assign(gs_retVal_m3, new And(new Var(m_name_map.find("UTF8-Prefix3")->second), new Var(cg_state.newsym))));
    73 
    74     std::string gs_retVal_m4 = symgen.gensym("marker");
    75     cg_state.stmtsl.push_back(new Assign(gs_retVal_m4, new And(new Var(m_name_map.find("UTF8-Prefix4")->second), new Var(cg_state.newsym))));
    76 
    77     std::string gs_retVal_m5 = symgen.gensym("marker");
    78     cg_state.stmtsl.push_back(new Assign(gs_retVal_m5, new Or(new Var(gs_retVal_m2), new Var(gs_retVal_m1))));
    79 
    80     std::string gs_retVal_m6 = symgen.gensym("marker");
    81     cg_state.stmtsl.push_back(new Assign(gs_retVal_m6, new Or(new Var(gs_retVal_m5), new Var(gs_retVal_m3))));
    82 
    83     gs_retVal = symgen.gensym("internal.initial");
    84     m_name_map.insert(make_pair("internal.initial", gs_retVal));
    85     cg_state.stmtsl.push_back(new Assign(gs_retVal, new Or(new Var(gs_retVal_m6), new Var(gs_retVal_m4))));
    86     cg_state.newsym = gs_retVal;
     64    std::string gs_initial = symgen.gensym("internal.initial");
     65    m_name_map.insert(make_pair("internal.initial", gs_initial));
     66    cg_state.stmtsl.push_back(new Assign(gs_initial, new Or(new Or( new Or( new And(new Var(m_name_map.find("UTF8-Prefix2")->second),
     67        new Var(cg_state.newsym)),  new And(new Var(m_name_map.find("UTF8-SingleByte")->second), new Var(cg_state.newsym))),
     68        new And(new Var(m_name_map.find("UTF8-Prefix3")->second), new Var(cg_state.newsym))),
     69        new And(new Var(m_name_map.find("UTF8-Prefix4")->second), new Var(cg_state.newsym)))));
     70    cg_state.newsym = gs_initial;
    8771
    8872    //Set the 'internal.nonfinal' bit stream for the utf-8 multi-byte encoding.
    89     gs_retVal = symgen.gensym("start_marker");
    90     cg_state.stmtsl.push_back(new Assign(gs_retVal, new All(1)));
    91     cg_state.newsym = gs_retVal;
    92 
    93     gs_retVal_m1 = symgen.gensym("marker");
    94     cg_state.stmtsl.push_back(new Assign(gs_retVal_m1, new And(new Var(m_name_map.find("UTF8-Prefix2")->second), new Var(cg_state.newsym))));
    95 
    96     gs_retVal_m2 = symgen.gensym("marker");
    97     cg_state.stmtsl.push_back(new Assign(gs_retVal_m2, new And(new Var(m_name_map.find("UTF8-Prefix3")->second), new Var(cg_state.newsym))));
    98 
    99     gs_retVal_m3 = symgen.gensym("marker");
    100     cg_state.stmtsl.push_back(new Assign(gs_retVal_m3, new Advance(new Var(gs_retVal_m2))));
    101 
    102     gs_retVal_m4 = symgen.gensym("marker");
    103     cg_state.stmtsl.push_back(new Assign(gs_retVal_m4, new And(new Var(m_name_map.find("UTF8-Prefix4")->second), new Var(cg_state.newsym))));
    104 
    105     gs_retVal_m5 = symgen.gensym("marker");
    106     cg_state.stmtsl.push_back(new Assign(gs_retVal_m5, new Advance(new Var(gs_retVal_m4))));
    107 
    108     gs_retVal_m6 = symgen.gensym("marker");
    109     cg_state.stmtsl.push_back(new Assign(gs_retVal_m6, new Advance(new Var(gs_retVal_m5))));
    110 
    111     std::string gs_retVal_m7 = symgen.gensym("marker");
    112     cg_state.stmtsl.push_back(new Assign(gs_retVal_m7, new Or(new Var(gs_retVal_m2), new Var(gs_retVal_m1))));
    113 
    114     std::string gs_retVal_m8 = symgen.gensym("marker");
    115     cg_state.stmtsl.push_back(new Assign(gs_retVal_m8, new Or(new Var(gs_retVal_m7), new Var(gs_retVal_m3))));
    116 
    117     std::string gs_retVal_m9 = symgen.gensym("marker");
    118     cg_state.stmtsl.push_back(new Assign(gs_retVal_m9, new Or(new Var(gs_retVal_m8), new Var(gs_retVal_m4))));
    119 
    120     std::string gs_retVal_m10 = symgen.gensym("marker");
    121     cg_state.stmtsl.push_back(new Assign(gs_retVal_m10, new Or(new Var(gs_retVal_m9), new Var(gs_retVal_m5))));
    122 
    123     gs_retVal = symgen.gensym("internal.nonfinal");
    124     m_name_map.insert(make_pair("internal.nonfinal", gs_retVal));
    125     cg_state.stmtsl.push_back(new Assign(gs_retVal, new Or(new Var(gs_retVal_m10), new Var(gs_retVal_m6))));
    126     cg_state.newsym = gs_retVal;
    127 
    128 
    129     gs_retVal = symgen.gensym("start_marker");
    130     cg_state.stmtsl.push_back(new Assign(gs_retVal, new All(1)));
    131     cg_state.newsym = gs_retVal;
     73    cg_state.newsym = gs_m0;
     74    std::string gs_nonfinal = symgen.gensym("internal.nonfinal");
     75    m_name_map.insert(make_pair("internal.nonfinal", gs_nonfinal));
     76    cg_state.stmtsl.push_back(new Assign(gs_nonfinal, new Or(new Or(new Or(new Or(new Or( new And(new Var(m_name_map.find("UTF8-Prefix3")->second),
     77        new Var(cg_state.newsym)),  new And(new Var(m_name_map.find("UTF8-Prefix2")->second), new Var(cg_state.newsym))),
     78        new Advance( new And(new Var(m_name_map.find("UTF8-Prefix3")->second), new Var(cg_state.newsym)))),
     79        new And(new Var(m_name_map.find("UTF8-Prefix4")->second), new Var(cg_state.newsym))), new Advance(
     80        new And(new Var(m_name_map.find("UTF8-Prefix4")->second), new Var(cg_state.newsym)))), new Advance(
     81        new Advance( new And(new Var(m_name_map.find("UTF8-Prefix4")->second), new Var(cg_state.newsym)))))));
     82    cg_state.newsym = gs_nonfinal;
     83
     84    cg_state.newsym = gs_m0;
    13285    cg_state = re2pablo_helper(re, cg_state);
    13386
    13487    //These three lines are specifically for grep.
    135     gs_retVal = symgen.gensym("marker");
     88    std::string gs_retVal = symgen.gensym("marker");
    13689    cg_state.stmtsl.push_back(new Assign(gs_retVal, new And(new MatchStar(new Var(cg_state.newsym),
    137                                 new Not(new Var(m_name_map.find("LineFeed")->second))), new Var(m_name_map.find("LineFeed")->second))));
     90        new Not(new Var(m_name_map.find("LineFeed")->second))), new Var(m_name_map.find("LineFeed")->second))));
    13891    cg_state.newsym = gs_retVal;
    13992
     
    226179                cg_state.stmtsl.push_back(new Assign(gs_retVal,
    227180                    new And(new MatchStar(new Var(cg_state.newsym), new Or(new CharClass(m_name_map.find("internal.nonfinal")->second),
    228                                                                            new CharClass(rep_name->getName()))), new CharClass(m_name_map.find("internal.initial")->second))));
     181                    new CharClass(rep_name->getName()))), new CharClass(m_name_map.find("internal.initial")->second))));
    229182            }
    230183
Note: See TracChangeset for help on using the changeset viewer.