Changeset 3956


Ignore:
Timestamp:
Aug 4, 2014, 12:53:31 PM (5 years ago)
Author:
daled
Message:

Matchstar for utf-8 character classes works. Needs refactoring.

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

Legend:

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

    r3955 r3956  
    206206
    207207    //This function can be used for testing to print the contents of a register from JIT'd code to the terminal window.
    208     //mFunc_print_register = mMod->getOrInsertFunction("wrapped_print_register", Type::getVoidTy(getGlobalContext()), m64x2Vect, NULL);
    209 
    210     //mExecutionEngine->addGlobalMapping(cast<GlobalValue>(mFunc_print_register), (void *)&wrapped_print_register);
     208    mFunc_print_register = mMod->getOrInsertFunction("wrapped_print_register", Type::getVoidTy(getGlobalContext()), m64x2Vect, NULL);
     209
     210    mExecutionEngine->addGlobalMapping(cast<GlobalValue>(mFunc_print_register), (void *)&wrapped_print_register);
    211211    // to call->  b.CreateCall(mFunc_print_register, unicode_category);
    212212
  • icGREP/icgrep-devel/icgrep/pbix_compiler.cpp

    r3955 r3956  
    1919    for (auto it =  re_map.rbegin(); it != re_map.rend(); ++it)
    2020    {
     21        //This is specifically for the utf8 multibyte character classes.
    2122        if (Seq* seq = dynamic_cast<Seq*>(it->second))
    2223        {
     
    156157        else //Name::Unicode
    157158        {
    158             cg_state.stmtsl.push_back(new Assign(gs_retVal, new Advance(new And(new CharClass(name->getName()), new ScanThru(new Var(cg_state.newsym), new Var(m_name_map.find("internal.nonfinal")->second))))));
     159            cg_state.stmtsl.push_back(new Assign(gs_retVal, new Advance(new And(new CharClass(name->getName()), new ScanThru(new Var(cg_state.newsym), new CharClass(m_name_map.find("internal.nonfinal")->second))))));
    159160        }
    160161        cg_state.newsym = gs_retVal;
     
    210211        if ((dynamic_cast<Name*>(rep->getRE()) != 0) && (rep->getLB() == 0) && (rep->getUB()== unboundedRep))
    211212        {
    212             //std::cout << "Matchstar!" << std::endl;
     213            //std::cout << "Matchstar Name!" << std::endl;
    213214
    214215            Name* rep_name = dynamic_cast<Name*>(rep->getRE());
    215216            std::string gs_retVal = symgen.gensym("marker");
    216             cg_state.stmtsl.push_back(new Assign(gs_retVal, new MatchStar(new Var(cg_state.newsym), new CharClass(rep_name->getName()))));
     217
     218            if (rep_name->getType() == Name::FixedLength)
     219            {
     220                cg_state.stmtsl.push_back(new Assign(gs_retVal, new MatchStar(new Var(cg_state.newsym), new CharClass(rep_name->getName()))));
     221            }
     222            else if (rep_name->getType() == Name::UnicodeCategory)
     223            {
     224                // TODO:  ?? not too sure....
     225            }
     226            else //Name::unicode
     227            {
     228                std::string t_retVal = symgen.gensym("t");
     229                std::string u_retVal = symgen.gensym("u");
     230                std::string v_retVal = symgen.gensym("v");
     231                std::string new_cur_retVal = symgen.gensym("new_cur");
     232
     233                cg_state.stmtsl.push_back(new Assign(t_retVal, new Or(new CharClass(m_name_map.find("internal.nonfinal")->second), new CharClass(rep_name->getName()))));
     234                cg_state.stmtsl.push_back(new Assign(u_retVal, new MatchStar(new Var(cg_state.newsym), new Var(t_retVal))));
     235                cg_state.stmtsl.push_back(new Assign(v_retVal, new And(new Var(u_retVal), new CharClass(m_name_map.find("internal.initial")->second))));
     236                cg_state.stmtsl.push_back(new Assign(new_cur_retVal, new And(new Var(u_retVal), new Not(new Var(t_retVal)))));
     237
     238                cg_state.stmtsl.push_back(new Assign(gs_retVal, new Or(new Var(v_retVal), new Var(new_cur_retVal))));
     239
     240            }
     241
    217242            cg_state.newsym = gs_retVal;
    218243        }
  • icGREP/icgrep-devel/icgrep/re_compiler.cpp

    r3955 r3956  
    106106    Pbix_Compiler pbix_compiler(name_map);
    107107    CodeGenState re_subexpression_cg_state = pbix_compiler.compile_subexpressions(re_map);
     108    //Print to the terminal the AST that was generated for the re subexpressions.
     109    //std::cout << "\n" << "Subexpressions: (" << StatementPrinter::PrintStmts(re_subexpression_cg_state) << ")" << std::endl;
     110
    108111    CodeGenState re_cg_state = pbix_compiler.compile(re_ast);
    109 
    110112    //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
    111     //std::cout << "\n" << "Subexpressions: (" << StatementPrinter::PrintStmts(re_subexpression_cg_state) << ")" << std::endl;
    112113    //std::cout << "\n" << "(" << StatementPrinter::PrintStmts(re_cg_state) << ")" << "\n" << std::endl;
    113114
Note: See TracChangeset for help on using the changeset viewer.