Changeset 3955


Ignore:
Timestamp:
Aug 4, 2014, 9:46:49 AM (5 years ago)
Author:
daled
Message:

icGREP now uses scanthru for multibyte unicode character classes.

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/CMakeLists.txt

    r3940 r3955  
    3838
    3939 
    40 add_library(PabloADT pe_advance.cpp  pe_all.cpp  pe_and.cpp pe_call.cpp pe_charclass.cpp  pe_matchstar.cpp pe_not.cpp  pe_or.cpp  pe_pabloe.cpp  pe_sel.cpp  pe_var.cpp  pe_xor.cpp ps_assign.cpp  ps_if.cpp  ps_pablos.cpp  ps_while.cpp printer_pablos.cpp)
     40add_library(PabloADT pe_advance.cpp  pe_all.cpp  pe_and.cpp pe_call.cpp pe_charclass.cpp  pe_matchstar.cpp pe_scanthru.cpp pe_not.cpp  pe_or.cpp  pe_pabloe.cpp  pe_sel.cpp  pe_var.cpp  pe_xor.cpp ps_assign.cpp  ps_if.cpp  ps_pablos.cpp  ps_while.cpp printer_pablos.cpp)
    4141
    4242add_library(RegExpADT re_alt.cpp  re_cc.cpp  re_end.cpp  re_name.cpp re_parser.cpp  re_re.cpp  re_rep.cpp  re_seq.cpp  re_start.cpp parsefailure.cpp  parseresult.cpp  parsesuccess.cpp printer_re.cpp)
  • icGREP/icgrep-devel/icgrep/cc_compiler.cpp

    r3926 r3955  
    307307            combined_item.lo_codepoint = (last_item.lo_codepoint & 0xFE);
    308308            combined_item.hi_codepoint = (first_item.hi_codepoint | 0x01);
    309             std::cout << "Combined!" << std::endl;
     309
    310310            return char_or_range_expr(combined_item);
    311311        }
  • icGREP/icgrep-devel/icgrep/llvm_gen.cpp

    r3941 r3955  
    3030}
    3131
    32 LLVM_Generator::LLVM_Generator(std::string basis_pattern, std::string lf_ccname, int bits)
    33 {
     32LLVM_Generator::LLVM_Generator(std::map<std::string, std::string> name_map, std::string basis_pattern, int bits)
     33{
     34    m_name_map = name_map;
    3435    mBasis_Pattern = basis_pattern;
    35     m_lf_ccname = lf_ccname;
    3636    mBits = bits;
    3737}
     
    4242}
    4343
    44 LLVM_Gen_RetVal LLVM_Generator::Generate_LLVMIR(CodeGenState cg_state, std::list<PabloS*> cc_cgo_stmtsl)
     44LLVM_Gen_RetVal LLVM_Generator::Generate_LLVMIR(CodeGenState cg_state, CodeGenState subexpression_cg_state, std::list<PabloS*> cc_cgo_stmtsl)
    4545{
    4646    //Create the module.
     
    7474    //Create the carry queue.
    7575    mCarryQueueIdx = 0;
    76     mCarryQueueSize = LLVM_Generator_Helper::CarryCount_PabloStatements(cg_state.stmtsl);
     76    mCarryQueueSize = LLVM_Generator_Helper::CarryCount_PabloStatements(subexpression_cg_state.stmtsl);
     77    mCarryQueueSize += LLVM_Generator_Helper::CarryCount_PabloStatements(cg_state.stmtsl);
    7778
    7879    mBasicBlock = BasicBlock::Create(mMod->getContext(), "parabix_entry", mFunc_process_block,0);
     
    9495
    9596    Generate_PabloStatements(cc_cgo_stmtsl);
     97    Generate_PabloStatements(subexpression_cg_state.stmtsl);
    9698    Generate_PabloStatements(cg_state.stmtsl);
    9799    SetReturnMarker(cg_state.newsym, 0);
    98     SetReturnMarker(m_lf_ccname, 1);
     100    SetReturnMarker(m_name_map.find("LineFeed")->second, 1);
    99101
    100102    //Terminate the block
     
    557559        retVal = result_value;
    558560    }
     561    else if (ScanThru* sthru = dynamic_cast<ScanThru*>(expr))
     562    {
     563        IRBuilder<> b(mBasicBlock);
     564
     565        //CarryQ - carry in.
     566        Value* carryq_idx = b.getInt64(mCarryQueueIdx);
     567        Value* carryq_GEP = b.CreateGEP(mptr_carry_q, carryq_idx);
     568        Value* carryq_value = b.CreateLoad(carryq_GEP);
     569        //Get the input stream.
     570        Value* strm_value = Generate_PabloE(sthru->getScanFrom());
     571        //Get the scanthru bit stream.
     572        Value* scanthru_value = Generate_PabloE(sthru->getScanThru());
     573
     574        Value* and_value_1 = b.CreateAnd(scanthru_value, strm_value, "scanthru_and_value_1");
     575        Value* add_value_1 = b.CreateAdd(and_value_1, carryq_value, "scanthru_add_value_1");
     576        Value* add_value_2 = b.CreateAdd(add_value_1, scanthru_value, "scanthru_add_value_2");
     577
     578        Value* srli_instr_1 = b.CreateLShr(and_value_1, 63);
     579
     580        Value* cast_marker_value_1 = b.CreateBitCast(srli_instr_1, IntegerType::get(mMod->getContext(), 128));
     581        Value* sll_1_value = b.CreateShl(cast_marker_value_1, 64);
     582        Value* cast_marker_value_2 = b.CreateBitCast(sll_1_value, m64x2Vect);
     583
     584        Value* add_value_3 = b.CreateAdd(cast_marker_value_2, add_value_2, "scanthru_add_value_3");
     585        Value* xor_value_1  = b.CreateXor(scanthru_value, mConst_Aggregate_64x2_neg1, "scanthru_xor_value_1");
     586        Value* result_value = b.CreateAnd(add_value_3, xor_value_1, "scanthru_result_value");
     587
     588        //CarryQ - carry out:
     589        Value* cast_marker_value_3 = b.CreateBitCast(add_value_3, IntegerType::get(mMod->getContext(), 128));
     590        Value* srli_2_value = b.CreateLShr(cast_marker_value_3, 127);
     591        Value* carryout_2_carry = b.CreateBitCast(srli_2_value, m64x2Vect);
     592
     593        Value* void_1 = b.CreateStore(carryout_2_carry, carryq_GEP);
     594
     595        mCarryQueueIdx++;
     596
     597        retVal = result_value;
     598    }
    559599
    560600    return retVal;
  • icGREP/icgrep-devel/icgrep/llvm_gen.h

    r3940 r3955  
    101101{
    102102public:
    103     LLVM_Generator(std::string basis_pattern, std::string lf_ccname, int bits);
     103    LLVM_Generator(std::map<std::string, std::string> name_map, std::string basis_pattern, int bits);
    104104    ~LLVM_Generator();
    105105    LLVM_Gen_RetVal Generate_LLVMIR(CodeGenState cg_state,
     106                                    CodeGenState subexpression_cg_state,
    106107                                    std::list<PabloS*> cc_cgo);
    107108    void Print_Register(char* name, BitBlock bit_block);
     
    120121
    121122    int         mBits;
    122     std::string m_lf_ccname;
     123    std::map<std::string, std::string> m_name_map;
    123124    std::string mBasis_Pattern;
    124125
  • icGREP/icgrep-devel/icgrep/llvm_gen_helper.cpp

    r3850 r3955  
    6565        retVal = 1 + CarryCount_PabloE(mstar->getExpr1()) + CarryCount_PabloE(mstar->getExpr2());
    6666    }
     67    else if (ScanThru* sthru = dynamic_cast<ScanThru*>(expr))
     68    {
     69        retVal = 1 + CarryCount_PabloE(sthru->getScanFrom()) + CarryCount_PabloE(sthru->getScanThru());
     70    }
    6771
    6872    return retVal;
  • icGREP/icgrep-devel/icgrep/llvm_gen_helper.h

    r3850 r3955  
    2323#include "pe_or.h"
    2424#include "pe_matchstar.h"
     25#include "pe_scanthru.h"
    2526
    2627//Pablo Statements
  • icGREP/icgrep-devel/icgrep/pbix_compiler.cpp

    r3940 r3955  
    77#include "pbix_compiler.h"
    88
    9 Pbix_Compiler::Pbix_Compiler(std::string lf_ccname)
    10 {
    11     m_lf_ccname = lf_ccname;
     9Pbix_Compiler::Pbix_Compiler(std::map<std::string, std::string> name_map)
     10{
     11    m_name_map = name_map;
    1212    symgen = SymbolGenerator();
     13}
     14
     15CodeGenState Pbix_Compiler::compile_subexpressions(const std::map<std::string, RE*>& re_map)
     16{
     17    CodeGenState cg_state;
     18
     19    for (auto it =  re_map.rbegin(); it != re_map.rend(); ++it)
     20    {
     21        if (Seq* seq = dynamic_cast<Seq*>(it->second))
     22        {
     23            if (seq->getType() == Seq::Byte)
     24            {
     25                std::string gs_retVal = symgen.gensym("start_marker");
     26                cg_state.stmtsl.push_back(new Assign(gs_retVal, new All(1)));
     27                cg_state.newsym = gs_retVal;
     28
     29                std::list<RE*>::iterator endit;
     30                endit = seq->GetREList()->end();
     31                --endit;
     32                std::list<RE*>::iterator it;
     33                for (it = seq->GetREList()->begin(); it != seq->GetREList()->end(); ++it)
     34                {
     35                    Name* name = dynamic_cast<Name*>(*it);
     36                    if (it != endit)
     37                    {
     38                        gs_retVal = symgen.gensym("marker");
     39                        cg_state.stmtsl.push_back(new Assign(gs_retVal, new Advance(new And(new Var(cg_state.newsym), new CharClass(name->getName())))));
     40                        cg_state.newsym = gs_retVal;
     41                    }
     42                    else
     43                    {
     44                        cg_state.stmtsl.push_back(new Assign(seq->getName(), new And(new Var(cg_state.newsym), new CharClass(name->getName()))));
     45                    }
     46                }
     47            }
     48        }
     49    }
     50
     51    return cg_state;
    1352}
    1453
     
    1655{   
    1756    std::string gs_retVal;
     57    CodeGenState cg_state;
     58
     59    //Set the 'internal.initial' bit stream for the utf-8 multi-byte encoding.
    1860    gs_retVal = symgen.gensym("start_marker");
    19 
    20     CodeGenState cg_state;
    2161    cg_state.stmtsl.push_back(new Assign(gs_retVal, new All(1)));
    2262    cg_state.newsym = gs_retVal;
    2363
     64    std::string gs_retVal_m1 = symgen.gensym("marker");
     65    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))));
     66
     67    std::string gs_retVal_m2 = symgen.gensym("marker");
     68    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))));
     69
     70    std::string gs_retVal_m3 = symgen.gensym("marker");
     71    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))));
     72
     73    std::string gs_retVal_m4 = symgen.gensym("marker");
     74    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))));
     75
     76    std::string gs_retVal_m5 = symgen.gensym("marker");
     77    cg_state.stmtsl.push_back(new Assign(gs_retVal_m5, new Or(new Var(gs_retVal_m2), new Var(gs_retVal_m1))));
     78
     79    std::string gs_retVal_m6 = symgen.gensym("marker");
     80    cg_state.stmtsl.push_back(new Assign(gs_retVal_m6, new Or(new Var(gs_retVal_m5), new Var(gs_retVal_m3))));
     81
     82    gs_retVal = symgen.gensym("internal.initial");
     83    m_name_map.insert(make_pair("internal.initial", gs_retVal));
     84    cg_state.stmtsl.push_back(new Assign(gs_retVal, new Or(new Var(gs_retVal_m6), new Var(gs_retVal_m4))));
     85    cg_state.newsym = gs_retVal;
     86
     87    //Set the 'internal.nonfinal' bit stream for the utf-8 multi-byte encoding.
     88    gs_retVal = symgen.gensym("start_marker");
     89    cg_state.stmtsl.push_back(new Assign(gs_retVal, new All(1)));
     90    cg_state.newsym = gs_retVal;
     91
     92    gs_retVal_m1 = symgen.gensym("marker");
     93    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))));
     94
     95    gs_retVal_m2 = symgen.gensym("marker");
     96    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))));
     97
     98    gs_retVal_m3 = symgen.gensym("marker");
     99    cg_state.stmtsl.push_back(new Assign(gs_retVal_m3, new Advance(new Var(gs_retVal_m2))));
     100
     101    gs_retVal_m4 = symgen.gensym("marker");
     102    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))));
     103
     104    gs_retVal_m5 = symgen.gensym("marker");
     105    cg_state.stmtsl.push_back(new Assign(gs_retVal_m5, new Advance(new Var(gs_retVal_m4))));
     106
     107    gs_retVal_m6 = symgen.gensym("marker");
     108    cg_state.stmtsl.push_back(new Assign(gs_retVal_m6, new Advance(new Var(gs_retVal_m5))));
     109
     110    std::string gs_retVal_m7 = symgen.gensym("marker");
     111    cg_state.stmtsl.push_back(new Assign(gs_retVal_m7, new Or(new Var(gs_retVal_m2), new Var(gs_retVal_m1))));
     112
     113    std::string gs_retVal_m8 = symgen.gensym("marker");
     114    cg_state.stmtsl.push_back(new Assign(gs_retVal_m8, new Or(new Var(gs_retVal_m7), new Var(gs_retVal_m3))));
     115
     116    std::string gs_retVal_m9 = symgen.gensym("marker");
     117    cg_state.stmtsl.push_back(new Assign(gs_retVal_m9, new Or(new Var(gs_retVal_m8), new Var(gs_retVal_m4))));
     118
     119    std::string gs_retVal_m10 = symgen.gensym("marker");
     120    cg_state.stmtsl.push_back(new Assign(gs_retVal_m10, new Or(new Var(gs_retVal_m9), new Var(gs_retVal_m5))));
     121
     122    gs_retVal = symgen.gensym("internal.nonfinal");
     123    m_name_map.insert(make_pair("internal.nonfinal", gs_retVal));
     124    cg_state.stmtsl.push_back(new Assign(gs_retVal, new Or(new Var(gs_retVal_m10), new Var(gs_retVal_m6))));
     125    cg_state.newsym = gs_retVal;
     126
     127
     128    gs_retVal = symgen.gensym("start_marker");
     129    cg_state.stmtsl.push_back(new Assign(gs_retVal, new All(1)));
     130    cg_state.newsym = gs_retVal;
    24131    cg_state = re2pablo_helper(re, cg_state);
    25132
    26133    //These three lines are specifically for grep.
    27134    gs_retVal = symgen.gensym("marker");
    28     cg_state.stmtsl.push_back(new Assign(gs_retVal, new And(new MatchStar(new Var(cg_state.newsym), new Not(new Var(m_lf_ccname))), new Var(m_lf_ccname))));
     135    cg_state.stmtsl.push_back(new Assign(gs_retVal, new And(new MatchStar(new Var(cg_state.newsym),
     136                                new Not(new Var(m_name_map.find("LineFeed")->second))), new Var(m_name_map.find("LineFeed")->second))));
    29137    cg_state.newsym = gs_retVal;
    30138
     
    38146        std::string gs_retVal = symgen.gensym("marker");
    39147
    40         PabloE* expr;
    41         if (name->getType() == Name::UnicodeCategory)
    42             expr = new Call(name->getName());
    43         else
    44             expr =  new CharClass(name->getName());
    45 
    46         cg_state.stmtsl.push_back(new Assign(gs_retVal, new Advance(new And(new Var(cg_state.newsym), expr))));
     148        if (name->getType() == Name::FixedLength)
     149        {
     150            cg_state.stmtsl.push_back(new Assign(gs_retVal, new Advance(new And(new Var(cg_state.newsym), new CharClass(name->getName())))));
     151        }
     152        else if (name->getType() == Name::UnicodeCategory)
     153        {
     154            cg_state.stmtsl.push_back(new Assign(gs_retVal, new Advance(new And(new Var(cg_state.newsym), new Call(name->getName())))));
     155        }
     156        else //Name::Unicode
     157        {
     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        }
    47160        cg_state.newsym = gs_retVal;
    48161
     
    52165    {
    53166        std::string gs_retVal = symgen.gensym("start_of_line_marker");
    54         cg_state.stmtsl.push_back(new Assign(gs_retVal, new And(new Var(cg_state.newsym), new Not(new Advance(new Not(new CharClass(m_lf_ccname)))))));
     167        cg_state.stmtsl.push_back(new Assign(gs_retVal, new And(new Var(cg_state.newsym), new Not(new Advance(new Not(new CharClass(m_name_map.find("LineFeed")->second)))))));
    55168        cg_state.newsym = gs_retVal;
    56169    }
     
    58171    {
    59172        std::string gs_retVal = symgen.gensym("end_of_line_marker");
    60         cg_state.stmtsl.push_back(new Assign(gs_retVal, new And(new Var(cg_state.newsym), new CharClass(m_lf_ccname))));
     173        cg_state.stmtsl.push_back(new Assign(gs_retVal, new And(new Var(cg_state.newsym), new CharClass(m_name_map.find("LineFeed")->second))));
    61174        cg_state.newsym = gs_retVal;
    62175    }
  • icGREP/icgrep-devel/icgrep/pbix_compiler.h

    r3940 r3955  
    2626#include "pe_call.h"
    2727#include "pe_matchstar.h"
     28#include "pe_scanthru.h"
    2829#include "pe_not.h"
    2930#include "pe_or.h"
     
    4546#include <list>
    4647#include <vector>
     48#include <map>
    4749
    4850
     
    5557{
    5658public:
    57     Pbix_Compiler(std::string lf_ccname);
     59    Pbix_Compiler(std::map<std::string, std::string> name_map);
    5860    CodeGenState compile(RE *re);
     61    CodeGenState compile_subexpressions(const std::map<std::string, RE*>& re_map);
    5962private:
    6063    CodeGenState re2pablo_helper(RE *re, CodeGenState cg_state);
     
    6366
    6467    SymbolGenerator symgen;
    65     std::string m_lf_ccname;
     68    std::map<std::string, std::string> m_name_map;
    6669};
    6770
  • icGREP/icgrep-devel/icgrep/printer_pablos.cpp

    r3940 r3955  
    105105        retVal = "CharClass '" + cc->getCharClass() + "'";
    106106    }
     107    else if (Name* name = dynamic_cast<Name*>(expr))
     108    {
     109        retVal = "Name '" + name->getName() + "'";
     110    }
    107111    else if (Advance* adv = dynamic_cast<Advance*>(expr))
    108112    {
     
    113117        retVal = "MatchStar (" + ShowPabloE(mstar->getExpr1()) + ", " + ShowPabloE(mstar->getExpr2()) + ")";
    114118    }
     119    else if (ScanThru* sthru = dynamic_cast<ScanThru*>(expr))
     120    {
     121        retVal = "ScanThru (" + ShowPabloE(sthru->getScanFrom()) + ", " + ShowPabloE(sthru->getScanThru()) + ")";
     122    }
    115123
    116124    return retVal;
  • icGREP/icgrep-devel/icgrep/re_compiler.cpp

    r3940 r3955  
    6969
    7070    //Build our list of predefined characters.
     71    std::string cc_name;
     72    std::map<std::string,std::string> name_map;
    7173    std::list<CC*> predefined_characters;
    72     CC* cc_lf = new CC('\n');
    73     std::string lf_ccname = cc_lf->getName();
    74     re_map.insert(make_pair(lf_ccname, cc_lf));
     74
     75    CC* cc_lf = new CC(0x0A);
     76    cc_name = cc_lf->getName();
     77    re_map.insert(make_pair(cc_name, cc_lf));
     78    name_map.insert(make_pair("LineFeed", cc_name));
     79
     80    CC* cc_utf8_single_byte = new CC(0x80, 0xBF);
     81    cc_name = cc_utf8_single_byte->getName();
     82    re_map.insert(make_pair(cc_name, cc_utf8_single_byte));
     83    name_map.insert(make_pair("UTF8-SingleByte", cc_name));
     84
     85    CC* cc_utf8_prefix2 = new CC(0xC2, 0xDF);
     86    cc_name = cc_utf8_prefix2->getName();
     87    re_map.insert(make_pair(cc_name, cc_utf8_prefix2));
     88    name_map.insert(make_pair("UTF8-Prefix2", cc_name));
     89
     90    CC* cc_utf8_prefix3 = new CC(0xE0, 0xEF);
     91    cc_name = cc_utf8_prefix3->getName();
     92    re_map.insert(make_pair(cc_name, cc_utf8_prefix3));
     93    name_map.insert(make_pair("UTF8-Prefix3", cc_name));
     94
     95    CC* cc_utf8_prefix4 = new CC(0xF0, 0xF4);
     96    cc_name = cc_utf8_prefix4->getName();
     97    re_map.insert(make_pair(cc_name, cc_utf8_prefix4));
     98    name_map.insert(make_pair("UTF8-Prefix4", cc_name));
    7599
    76100    CC_Compiler cc_compiler(encoding);
     
    80104    //std::cout << "\n" << "(" << StatementPrinter::Print_CC_PabloStmts(cc_stmtsl) << ")" << "\n" << std::endl;
    81105
    82     Pbix_Compiler pbix_compiler(lf_ccname);
    83     CodeGenState cg_state = pbix_compiler.compile(re_ast);
     106    Pbix_Compiler pbix_compiler(name_map);
     107    CodeGenState re_subexpression_cg_state = pbix_compiler.compile_subexpressions(re_map);
     108    CodeGenState re_cg_state = pbix_compiler.compile(re_ast);
    84109
    85110    //Print to the terminal the AST that was generated by the pararallel bit-stream compiler.
    86     //std::cout << "\n" << "(" << StatementPrinter::PrintStmts(cg_state) << ")" << "\n" << std::endl;
     111    //std::cout << "\n" << "Subexpressions: (" << StatementPrinter::PrintStmts(re_subexpression_cg_state) << ")" << std::endl;
     112    //std::cout << "\n" << "(" << StatementPrinter::PrintStmts(re_cg_state) << ")" << "\n" << std::endl;
    87113
    88114    //Print a count of the Pablo statements and expressions that are contained in the AST from the pbix compiler.
    89     //std::cout << "\nPablo Statement Count: " << Pbix_Counter::Count_PabloStatements(cg_state.stmtsl) <<  "\n" << std::endl;
     115    //std::cout << "\nPablo Statement Count: " << Pbix_Counter::Count_PabloStatements(re_cg_state.stmtsl) <<  "\n" << std::endl;
    90116
    91     LLVM_Generator irgen(basis_pattern, lf_ccname, encoding.getBits());
     117    LLVM_Generator irgen(name_map, basis_pattern, encoding.getBits());
    92118
    93119    unsigned long long cycles = 0;
     
    99125    }
    100126
    101     LLVM_Gen_RetVal retVal = irgen.Generate_LLVMIR(cg_state, cc_stmtsl);
     127    LLVM_Gen_RetVal retVal = irgen.Generate_LLVMIR(re_cg_state, re_subexpression_cg_state, cc_stmtsl);
    102128    if (show_compile_time)
    103129    {
     
    108134    }
    109135
    110     return  retVal;  //irgen.Generate_LLVMIR(cg_state, cc_stmtsl);
     136    return  retVal;  //irgen.Generate_LLVMIR(re_cg_state, cc_stmtsl);
    111137}
    112138
  • icGREP/icgrep-devel/icgrep/re_parser.cpp

    r3940 r3955  
    386386
    387387    int next_byte = (s.operator [](0) & 0xFF);
     388
    388389    if ((next_byte >= 0xC0) && (next_byte <= 0xDF))
    389390    {       
  • icGREP/icgrep-devel/icgrep/re_reducer.cpp

    r3940 r3955  
    2020    else if (Seq* re_seq = dynamic_cast<Seq*>(re))
    2121    {
    22 /*
     22
    2323        if (re_seq->getType() == Seq::Byte)
    2424        {
    2525            //If this is a sequence of byte classes then this is a multibyte sequence for a Unicode character class.
    26             std::string seqname = re_seq->getName();
    27             re_map.insert(make_pair(seqname, re_seq));
    28             retVal = new Name(seqname);
     26            std::list<RE*> re_list;
     27            std::list<RE*>::iterator it;
     28
     29            for (it = re_seq->GetREList()->begin(); it != re_seq->GetREList()->end(); ++it)
     30            {
     31                re_list.push_front(reduce(*it, re_map));
     32            }
     33
     34            Seq* new_seq =  new Seq(&re_list);
     35            new_seq->setType(Seq::Byte);
     36            std::string seqname = new_seq->getName();
     37            re_map.insert(make_pair(seqname, new_seq));
     38            Name* name = new Name(seqname);
     39            name->setType(Name::Unicode);
     40            retVal = name;
    2941        }
    3042        else
    3143        {
    32 */
    3344            std::list<RE*> re_list;
    3445            std::list<RE*>::iterator it;
     
    4051
    4152            retVal = new Seq(&re_list);
    42 //        }
     53        }
    4354    }
    4455    else if (Rep* re_rep = dynamic_cast<Rep*>(re))
  • icGREP/icgrep-devel/icgrep/re_seq.cpp

    r3935 r3955  
    5454                name += seq_cc->getName();
    5555            }
     56            else if (Name* seq_name = dynamic_cast<Name*>(*it))
     57            {
     58                name += seq_name->getName();
     59            }
    5660            else
    5761            {
  • icGREP/icgrep-devel/icgrep/re_seq.h

    r3935 r3955  
    1010#include "re_re.h"
    1111#include "re_cc.h"
     12#include "re_name.h"
    1213#include <list>
    1314#include <sstream>
  • icGREP/icgrep-devel/icgrep/re_simplifier.cpp

    r3940 r3955  
    6767    t1_list->assign(re_list->begin(), re_list->end());
    6868    if (t1_list->size() > 0)
    69     {
     69    { 
    7070        std::list<RE*>* t2_list = mkSeqList(t1_list);
    7171        if (t2_list->size() > 1)
     
    104104    else if (Seq* seq = dynamic_cast<Seq*>(re_list->back()))
    105105    {
    106         re_list->pop_back();
    107         seq->GetREList()->reverse();
    108         re_list->insert(re_list->end(), seq->GetREList()->begin(), seq->GetREList()->end());
    109 
    110         return mkSeqList_helper(ret_list, re_list);
     106        if (seq->getType() == Seq::Byte)
     107        {
     108            ret_list->push_front(re_list->back());
     109            re_list->pop_back();
     110            return mkSeqList_helper(ret_list, re_list);
     111        }
     112        else
     113        {
     114            re_list->pop_back();
     115            seq->GetREList()->reverse();
     116            re_list->insert(re_list->end(), seq->GetREList()->begin(), seq->GetREList()->end());
     117
     118            return mkSeqList_helper(ret_list, re_list);
     119        }
    111120    }
    112121    else
Note: See TracChangeset for help on using the changeset viewer.