Changeset 4962


Ignore:
Timestamp:
Mar 8, 2016, 3:15:22 PM (3 years ago)
Author:
hongpum
Message:

Add basic object cache implementation

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

Legend:

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

    r4953 r4962  
    108108ENDIF()
    109109
    110 add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp ${PRECOMPILED_FILES})
     110add_executable(icgrep icgrep.cpp toolchain.cpp grep_engine.cpp object_cache.cpp ${PRECOMPILED_FILES})
    111111IF(ENABLE_PREGENERATED_UCD_FUNCTIONS)
    112112add_dependencies(icgrep run_generate_predefined_ucd_functions)
  • icGREP/icgrep-devel/icgrep/toolchain.cpp

    r4959 r4962  
    5050#include <re/printer_re.h>
    5151#include <pablo/printer_pablos.h>
     52#include <object_cache.h>
    5253// Dynamic processor detection
    5354#define ISPC_LLVM_VERSION ISPC_LLVM_3_6
     
    132133static cl::opt<int> BlockSize("BlockSize", cl::init(0), cl::desc("specify a block size (defaults to widest SIMD register width in bits)."), cl::cat(dCodeGenOptions));
    133134
     135
     136static cl::OptionCategory cObjectCache("Object Caching", "These options control back-end object caching behaviours.");
     137
     138static cl::opt<bool> EnableObjectCache("enable-object-cache", cl::init(false), cl::desc("Enable object caching"), cl::cat(cObjectCache));
     139
     140static cl::opt<std::string> ObjectCacheDir("object-cache-dir", cl::init(""), cl::desc("Path to the object cache diretory"), cl::cat(cObjectCache));
    134141
    135142re::RE * regular_expression_passes(const Encoding encoding, re::RE * re_ast)  {
     
    447454    //builder.setOptLevel(mMaxWhileDepth ? CodeGenOpt::Level::Less : CodeGenOpt::Level::None);
    448455    ExecutionEngine * engine = builder.create();
     456    ICGrepObjectCache * cache = nullptr;
    449457    if (engine == nullptr) {
    450458        throw std::runtime_error("Could not create ExecutionEngine: " + errMessage);
    451459    }
    452460
     461    if (EnableObjectCache) {
     462        // TODO a better default cache diretory (HOME expansion?)
     463        if (ObjectCacheDir.empty())
     464            cache = new ICGrepObjectCache(".icgrep-cache/");
     465        else
     466            cache = new ICGrepObjectCache(ObjectCacheDir);
     467        engine->setObjectCache(cache);
     468    }
    453469    return engine;
    454470}
Note: See TracChangeset for help on using the changeset viewer.