Ignore:
Timestamp:
May 3, 2016, 5:53:12 PM (3 years ago)
Author:
xuedongx
Message:

If '-c', ignore the scanmatch kernel.

File:
1 edited

Legend:

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

    r5021 r5025  
    6969}
    7070
    71 void GrepEngine::doGrep(const std::string & fileName, const int fileIdx) {
     71void GrepEngine::doGrep(const std::string & fileName, const int fileIdx, bool CountOnly, std::vector<int> & total_CountOnly) {
    7272    const path file(fileName);
    7373    if (exists(file)) {
     
    8989        }
    9090        char * fileBuffer = const_cast<char *>(file.data());
    91         mGrepFunction(fileBuffer, fileSize, fileIdx, finalLineIsUnterminated(fileBuffer, fileSize));
     91        if(CountOnly){
     92            total_CountOnly[fileIdx] = mGrepFunction_CountOnly(fileBuffer, fileSize, fileIdx, finalLineIsUnterminated(fileBuffer, fileSize));
     93        }
     94        else{
     95            mGrepFunction(fileBuffer, fileSize, fileIdx, finalLineIsUnterminated(fileBuffer, fileSize));
     96        }
    9297        file.close();
    9398    }
    9499    else {
    95         mGrepFunction(nullptr, 0, fileIdx, false);
     100        if(CountOnly) {
     101            mGrepFunction_CountOnly(nullptr, 0, fileIdx, false);
     102        }
     103        else{
     104            mGrepFunction(nullptr, 0, fileIdx, false);
     105        }
    96106    }
    97107}
    98108
    99109
    100 void GrepEngine::grepCodeGen(std::string moduleName, re::RE * re_ast, bool isNameExpression) {
    101                            
     110void GrepEngine::grepCodeGen(std::string moduleName, re::RE * re_ast, bool CountOnly, bool isNameExpression) {
    102111    Module * M = new Module(moduleName, getGlobalContext());
    103112   
     
    114123    pipelineBuilder.CreateKernels(function, isNameExpression);
    115124
    116     llvm::Function * grepIR = pipelineBuilder.ExecuteKernels();
     125    llvm::Function * grepIR = pipelineBuilder.ExecuteKernels(CountOnly);
    117126
    118127    mEngine = JIT_to_ExecutionEngine(M);
     
    125134    delete idb;
    126135
    127     mGrepFunction = reinterpret_cast<GrepFunctionType>(mEngine->getPointerToFunction(grepIR));
     136    if(CountOnly){
     137        mGrepFunction_CountOnly = reinterpret_cast<GrepFunctionType_CountOnly>(mEngine->getPointerToFunction(grepIR));
     138    }
     139    else{
     140        mGrepFunction = reinterpret_cast<GrepFunctionType>(mEngine->getPointerToFunction(grepIR));
     141    }
     142
    128143}
    129144
Note: See TracChangeset for help on using the changeset viewer.