Changeset 4122


Ignore:
Timestamp:
Sep 1, 2014, 1:46:40 PM (5 years ago)
Author:
cameron
Message:

UnboundedRep_helper

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

Legend:

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

    r4121 r4122  
    219219        else if (rep->getUB() == unboundedRep)
    220220        {
    221             if (rep->getLB() == 0)
    222             {
    223                 //std::cout << "While, no lb." << std::endl;
    224 
    225                 std::string while_test_gs_retVal = symgen.gensym("while_test");
    226                 std::string while_accum_gs_retVal = symgen.gensym("while_accum");
    227                 CodeGenState while_test_state;
    228                 while_test_state.newsym = while_test_gs_retVal;
    229                 CodeGenState t1_cg_state = re2pablo_helper(rep->getRE(), while_test_state);
    230                 cg_state.stmtsl.push_back(new Assign(while_test_gs_retVal, new Var(cg_state.newsym)));
    231                 cg_state.stmtsl.push_back(new Assign(while_accum_gs_retVal, new Var(cg_state.newsym)));
    232                 std::list<PabloS*> stmtList;
    233                 stmtList = t1_cg_state.stmtsl;
    234                 stmtList.push_back(new Assign(while_test_gs_retVal, new And(new Var(t1_cg_state.newsym), new Not(new Var(while_accum_gs_retVal)))));
    235                 stmtList.push_back(new Assign(while_accum_gs_retVal, new Or(new Var(while_accum_gs_retVal), new Var(t1_cg_state.newsym))));
    236                 cg_state.stmtsl.push_back( new While(new Var(while_test_gs_retVal), stmtList));
    237                 cg_state.newsym = while_accum_gs_retVal;
    238             }
    239             else //if (rep->getLB() > 1)
    240             {
    241                 CodeGenState t1_cg_state = re2pablo_helper(rep->getRE(), cg_state);
    242                 rep->setLB(rep->getLB() - 1);
    243                 cg_state = re2pablo_helper(rep, t1_cg_state);
    244             }
     221            cg_state = UnboundedRep_helper(rep->getRE(), rep->getLB(), cg_state);
    245222        }
    246223        else if (rep->getUB() != unboundedRep)
     
    285262    return cg_state;
    286263}
     264
     265CodeGenState Pbix_Compiler::UnboundedRep_helper(RE* repeated, int lb, CodeGenState cg_state) {
     266    if (lb == 0)
     267    {
     268         //std::cout << "While, no lb." << std::endl;
     269
     270         std::string while_test_gs_retVal = symgen.gensym("while_test");
     271         std::string while_accum_gs_retVal = symgen.gensym("while_accum");
     272         CodeGenState while_test_state;
     273         while_test_state.newsym = while_test_gs_retVal;
     274         CodeGenState t1_cg_state = re2pablo_helper(repeated, while_test_state);
     275         cg_state.stmtsl.push_back(new Assign(while_test_gs_retVal, new Var(cg_state.newsym)));
     276         cg_state.stmtsl.push_back(new Assign(while_accum_gs_retVal, new Var(cg_state.newsym)));
     277         std::list<PabloS*> stmtList;
     278         stmtList = t1_cg_state.stmtsl;
     279         stmtList.push_back(new Assign(while_test_gs_retVal, new And(new Var(t1_cg_state.newsym), new Not(new Var(while_accum_gs_retVal)))));
     280         stmtList.push_back(new Assign(while_accum_gs_retVal, new Or(new Var(while_accum_gs_retVal), new Var(t1_cg_state.newsym))));
     281         cg_state.stmtsl.push_back( new While(new Var(while_test_gs_retVal), stmtList));
     282         cg_state.newsym = while_accum_gs_retVal;
     283    }
     284    else //if (lb > 0)
     285    {
     286         CodeGenState t1_cg_state = re2pablo_helper(repeated, cg_state);
     287         cg_state = UnboundedRep_helper(repeated, lb -1, t1_cg_state);
     288    }
     289    return cg_state;
     290}
     291
    287292
    288293CodeGenState Pbix_Compiler::BoundedRep_helper(RE* repeated, int lb, int ub, CodeGenState cg_state) {
     
    306311    }
    307312    return cg_state;
    308 
    309313}
    310314
  • icGREP/icgrep-devel/icgrep/pbix_compiler.h

    r4121 r4122  
    6464    CodeGenState Seq_helper(std::list<RE*>* lst, std::list<RE*>::const_iterator it, CodeGenState cg_state);
    6565    CodeGenState Alt_helper(std::list<RE*>* lst, std::list<RE*>::const_iterator it, CodeGenState cg_state);
     66    CodeGenState UnboundedRep_helper(RE* repeated, int lb, CodeGenState cg_state);
    6667    CodeGenState BoundedRep_helper(RE* repeated, int lb, int ub, CodeGenState cg_state);
    6768
Note: See TracChangeset for help on using the changeset viewer.