Ignore:
Timestamp:
Oct 17, 2017, 8:59:21 AM (2 years ago)
Author:
cameron
Message:

Unified FDsource kernel; filename - now interpreted as stdin

File:
1 edited

Legend:

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

    r5692 r5693  
    9494   
    9595uint64_t GrepEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) const {
     96    if (fileName == "-") {
     97        return doGrep(STDIN_FILENO, fileIdx);
     98    }
    9699    struct stat sb;
    97100    const int32_t fd = open(fileName.c_str(), O_RDONLY);
     
    123126
    124127uint64_t GrepEngine::doGrep(const int32_t fileDescriptor, const uint32_t fileIdx) const {
    125     assert (mGrepDriver);
    126128    typedef uint64_t (*GrepFunctionType)(int32_t fileDescriptor, const uint32_t fileIdx);
    127129    auto f = reinterpret_cast<GrepFunctionType>(mGrepDriver->getMain());
     
    327329}
    328330
    329 void GrepEngine::grepCodeGen(std::vector<re::RE *> REs, const GrepModeType grepMode, GrepSource grepSource) {
     331void GrepEngine::grepCodeGen(std::vector<re::RE *> REs, const GrepModeType grepMode) {
    330332
    331333    assert (mGrepDriver == nullptr);
     
    340342    Type * const int32Ty = idb->getInt32Ty();
    341343
    342     kernel::Kernel * sourceK = nullptr;
    343    
    344344    Function * mainFunc = cast<Function>(M->getOrInsertFunction("Main", int64Ty, idb->getInt32Ty(), int32Ty, nullptr));
    345345    mainFunc->setCallingConv(CallingConv::C);
     
    353353
    354354    StreamSetBuffer * ByteStream = mGrepDriver->addBuffer(make_unique<SourceBuffer>(idb, idb->getStreamSetTy(1, 8)));
    355 
    356     if (grepSource == GrepSource::File) {
    357         sourceK = mGrepDriver->addKernelInstance(make_unique<kernel::MMapSourceKernel>(idb, segmentSize));
    358     } else {
    359         sourceK = mGrepDriver->addKernelInstance(make_unique<kernel::ReadSourceKernel>(idb, segmentSize));
    360     }
     355    kernel::Kernel * sourceK = mGrepDriver->addKernelInstance(make_unique<kernel::FDSourceKernel>(idb, segmentSize));
    361356    sourceK->setInitialArguments({fileDescriptor});
    362 
    363357    mGrepDriver->makeKernelCall(sourceK, {}, {ByteStream});
    364358   
Note: See TracChangeset for help on using the changeset viewer.