Ignore:
Timestamp:
Aug 7, 2015, 10:04:46 AM (4 years ago)
Author:
cameron
Message:

Mod64Advance, Mod64MatchStar, Mod64ScanThru ops; -mod64-approximate command-line option

File:
1 edited

Legend:

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

    r4716 r4717  
    5555
    5656static cl::OptionCategory fTracingOptions("Run-time Tracing Options", "These options control execution traces.");
    57 static cl::opt<bool> TraceNext("trace-next-nodes", cl::init(false), cl::desc("Generate dynamic traces of executed Next nodes (while control variables)."), cl::cat(fTracingOptions));
    5857static cl::opt<bool> DumpTrace("dump-trace", cl::init(false), cl::desc("Generate dynamic traces of executed assignments."), cl::cat(fTracingOptions));
    5958
     
    193192    mCarryManager->generateBlockNoIncrement();
    194193
    195     if (DumpTrace || TraceNext) {
     194    if (DumpTrace) {
    196195        genPrintRegister("mBlockNo", mBuilder->CreateAlignedLoad(mBuilder->CreateBitCast(mCarryManager->getBlockNoPtr(), PointerType::get(mBitBlockType, 0)), BLOCK_SIZE/8, false));
    197196    }
     
    351350
    352351inline void PabloCompiler::DeclareDebugFunctions() {
    353     if (DumpTrace || TraceNext) {
     352    if (DumpTrace) {
    354353        //This function can be used for testing to print the contents of a register from JIT'd code to the terminal window.
    355354        mPrintRegisterFunction = mMod->getOrInsertFunction("wrapped_print_register", Type::getVoidTy(mMod->getContext()), Type::getInt8PtrTy(mMod->getContext()), mBitBlockType, NULL);
     
    532531    else if (const Next * next = dyn_cast<const Next>(stmt)) {
    533532        expr = compileExpression(next->getExpr());
    534         if (TraceNext) {
    535             genPrintRegister(next->getName()->to_string(), expr);
    536         }
    537533    }
    538534    else if (const If * ifStatement = dyn_cast<const If>(stmt)) {
     
    603599        Value* strm_value = compileExpression(adv->getExpr());
    604600        int shift = adv->getAdvanceAmount();
    605         if (adv->isMod64()) {
    606             expr = iBuilder.simd_slli(64, strm_value, shift);
    607         }
    608         else {
    609             unsigned advance_index = adv->getLocalAdvanceIndex();
    610             expr = mCarryManager->advanceCarryInCarryOut(advance_index, shift, strm_value);
    611         }
     601        unsigned advance_index = adv->getLocalAdvanceIndex();
     602        expr = mCarryManager->advanceCarryInCarryOut(advance_index, shift, strm_value);
     603    }
     604    else if (const Mod64Advance * adv = dyn_cast<Mod64Advance>(stmt)) {
     605        Value* strm_value = compileExpression(adv->getExpr());
     606        int shift = adv->getAdvanceAmount();
     607        expr = iBuilder.simd_slli(64, strm_value, shift);
    612608    }
    613609    else if (const MatchStar * mstar = dyn_cast<MatchStar>(stmt)) {
     
    615611        Value * cc = compileExpression(mstar->getCharClass());
    616612        Value * marker_and_cc = mBuilder->CreateAnd(marker, cc);
    617         Value * sum = nullptr;
    618         if (mstar->isMod64()) {
    619             sum = iBuilder.simd_add(64, marker_and_cc, cc);
    620         }
    621         else {
    622             unsigned carry_index = mstar->getLocalCarryIndex();
    623             sum = mCarryManager->addCarryInCarryOut(carry_index, marker_and_cc, cc);
    624         }
     613        unsigned carry_index = mstar->getLocalCarryIndex();
     614        Value * sum = mCarryManager->addCarryInCarryOut(carry_index, marker_and_cc, cc);
    625615        expr = mBuilder->CreateOr(mBuilder->CreateXor(sum, cc), marker, "matchstar");
     616    }
     617    else if (const Mod64MatchStar * mstar = dyn_cast<Mod64MatchStar>(stmt)) {
     618        Value * marker = compileExpression(mstar->getMarker());
     619        Value * cc = compileExpression(mstar->getCharClass());
     620        Value * marker_and_cc = mBuilder->CreateAnd(marker, cc);
     621        Value * sum = iBuilder.simd_add(64, marker_and_cc, cc);
     622        expr = mBuilder->CreateOr(mBuilder->CreateXor(sum, cc), marker, "matchstar64");
    626623    }
    627624    else if (const ScanThru * sthru = dyn_cast<ScanThru>(stmt)) {
    628625        Value * marker_expr = compileExpression(sthru->getScanFrom());
    629626        Value * cc_expr = compileExpression(sthru->getScanThru());
    630         Value * sum = nullptr;
    631         if (sthru->isMod64()) {
    632             sum = iBuilder.simd_add(64, marker_expr, cc_expr);
    633         }
    634         else {
    635             unsigned carry_index = sthru->getLocalCarryIndex();
    636             sum = mCarryManager->addCarryInCarryOut(carry_index, marker_expr, cc_expr);
    637         }
     627        unsigned carry_index = sthru->getLocalCarryIndex();
     628        Value * sum = mCarryManager->addCarryInCarryOut(carry_index, marker_expr, cc_expr);
    638629        expr = mBuilder->CreateAnd(sum, genNot(cc_expr), "scanthru");
     630    }
     631    else if (const Mod64ScanThru * sthru = dyn_cast<Mod64ScanThru>(stmt)) {
     632        Value * marker_expr = compileExpression(sthru->getScanFrom());
     633        Value * cc_expr = compileExpression(sthru->getScanThru());
     634        Value * sum = iBuilder.simd_add(64, marker_expr, cc_expr);
     635        expr = mBuilder->CreateAnd(sum, genNot(cc_expr), "scanthru64");
    639636    }
    640637    else {
Note: See TracChangeset for help on using the changeset viewer.