Ignore:
Timestamp:
Feb 24, 2017, 9:38:11 AM (2 years ago)
Author:
lindanl
Message:

Group multiple regular expressions for separate compilation.

File:
1 edited

Legend:

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

    r5338 r5344  
    8686         Gives you colored output + back-referencing capability."), cl::cat(EnhancedGrepOptions));
    8787
    88 static cl::opt<bool> MultiGrepKernels("enable-multiGrep-kernels", cl::desc("Construct separated kernels for each regular expression"), cl::cat(EnhancedGrepOptions));
    89 
     88static cl::opt<bool> MultiGrepKernels("enable-multigrep-kernels", cl::desc("Construct separated kernels for each regular expression"), cl::cat(EnhancedGrepOptions));
     89static cl::opt<int> REsPerGroup("re-num", cl::desc("Number of regular expressions processed by each kernel."), cl::init(1));
    9090static std::vector<std::string> allFiles;
    9191//
     
    113113static std::string allREs;
    114114static re::ModeFlagSet globalFlags = 0;
    115 std::vector<re::RE *> REs;
     115std::vector<re::RE *> RELists;
    116116
    117117re::RE * get_icgrep_RE() {
     
    138138    if (CaseInsensitive) globalFlags |= re::CASE_INSENSITIVE_MODE_FLAG;
    139139
    140 
     140    std::vector<re::RE *> REs;
    141141    re::RE * re_ast = nullptr;
    142142    for (unsigned i = 0; i < regexVector.size(); i++) {
     
    149149        allREs += regexVector[i] + "\n";
    150150    }
     151
     152    std::vector<re::RE *>::iterator start = REs.begin();
     153    std::vector<re::RE *>::iterator end = start + REsPerGroup;
     154    while(end < REs.end()) {
     155        RELists.push_back(re::makeAlt(start, end));
     156        start = end;
     157        end += REsPerGroup;
     158    }
     159    if(REs.end()-start>1)
     160        RELists.push_back(re::makeAlt(start, REs.end()));
     161    else
     162        RELists.push_back(*start);
     163
    151164    if (REs.size() > 1) {
    152165        re_ast = re::makeAlt(REs.begin(), REs.end());
     
    373386    GrepEngine grepEngine;
    374387    if(MultiGrepKernels){
    375         grepEngine.multiGrepCodeGen(module_name, REs, CountOnly, UTF_16);
     388        grepEngine.multiGrepCodeGen(module_name, RELists, CountOnly, UTF_16);
    376389    }
    377390    else{
Note: See TracChangeset for help on using the changeset viewer.