Changeset 4838


Ignore:
Timestamp:
Oct 16, 2015, 11:53:10 AM (2 years ago)
Author:
cameron
Message:

Clean-up and encapsulate if/summary test in carry_manager

Location:
icGREP/icgrep-devel/icgrep/pablo
Files:
4 edited

Legend:

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

    r4837 r4838  
    522522
    523523
    524 Value * CarryManager::getCarrySummaryExpr() {
    525     unsigned summary_index = summaryPackIndex();
    526     if (mITEMS_PER_PACK > 1) {// #ifdef PACKING
    527         Value * pack = getCarryPack(summary_index);
    528         Value * summary_bits = maskSelectBitRange(pack, summaryPosition() % mPACK_SIZE, summaryBits());
    529         return mBuilder->CreateBitCast(mBuilder->CreateZExt(summary_bits, mBuilder->getIntNTy(mBITBLOCK_WIDTH)), mBitBlockType);
    530     }
    531     else {
    532         return getCarryPack(summary_index);
    533     }
     524Value * CarryManager::generateBitBlockOrSummaryTest(Value * bitblock) {
     525    Value * test_expr = bitblock;
     526    if (mCarryInfo->blockHasCarries()) {
     527        Value * summary_pack = getCarryPack(summaryPackIndex());
     528        if (mITEMS_PER_PACK > 1) {// #ifdef PACKING
     529            Value * summary_bits = maskSelectBitRange(summary_pack, summaryPosition() % mPACK_SIZE, summaryBits());
     530            test_expr = iBuilder->simd_or(test_expr, mBuilder->CreateZExt(summary_bits, mBuilder->getIntNTy(mBITBLOCK_WIDTH)));
     531        }
     532        else {
     533            test_expr = iBuilder->simd_or(test_expr, summary_pack);
     534        }
     535    }
     536    return iBuilder->bitblock_any(test_expr);
    534537}
    535538
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.h

    r4828 r4838  
    9595    void initializeCarryDataAtIfEntry();
    9696   
    97     Value * getCarrySummaryExpr();
     97    Value * generateBitBlockOrSummaryTest(Value * bitblock);
    9898   
    9999    void generateCarryOutSummaryCodeIfNeeded();
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4837 r4838  
    231231}
    232232
    233     Value * PabloCompiler::genBitTest2(Value * e1, Value * e2) {
    234         Type * t1 = e1->getType();
    235         Type * t2 = e2->getType();
    236         if (t1 == mBitBlockType) {
    237             if (t2 == mBitBlockType) {
    238                 return iBuilder.bitblock_any(iBuilder.simd_or(e1, e2));
    239             }
    240             else {
    241                 Value * m1 = mBuilder->CreateZExt(iBuilder.hsimd_signmask(16, e1), t2);
    242                 return mBuilder->CreateICmpNE(mBuilder->CreateOr(m1, e2), ConstantInt::get(t2, 0));
    243             }
    244         }
    245         else if (t2 == mBitBlockType) {
    246             Value * m2 = mBuilder->CreateZExt(iBuilder.hsimd_signmask(16, e2), t1);
    247             return mBuilder->CreateICmpNE(mBuilder->CreateOr(e1, m2), ConstantInt::get(t1, 0));
    248         }
    249         else {
    250             return mBuilder->CreateICmpNE(mBuilder->CreateOr(e1, e2), ConstantInt::get(t1, 0));
    251         }
    252     }
    253    
    254233void PabloCompiler::compileIf(const If * ifStatement) {       
    255234    //
     
    280259   
    281260    mCarryManager->enterScope(&ifBody);
    282     if (mCarryManager->blockHasCarries()) {
    283         // load the summary variable
    284         Value* last_if_pending_data = mCarryManager->getCarrySummaryExpr();
    285         mBuilder->CreateCondBr(genBitTest2(if_test_value, last_if_pending_data), ifBodyBlock, ifEndBlock);
    286 
    287     }
    288     else {
    289         mBuilder->CreateCondBr(iBuilder.bitblock_any(if_test_value), ifBodyBlock, ifEndBlock);
    290     }
     261    mBuilder->CreateCondBr(mCarryManager->generateBitBlockOrSummaryTest(if_test_value), ifBodyBlock, ifEndBlock);
     262   
    291263    // Entry processing is complete, now handle the body of the if.
    292264    mBuilder->SetInsertPoint(ifBodyBlock);
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.h

    r4837 r4838  
    9090    void compileBlock(PabloBlock & block);
    9191    void compileStatement(const Statement * stmt);
    92     Value * genBitTest2(Value * e1, Value * e2);
    9392    void compileIf(const If * ifStmt);
    9493    void compileWhile(const While * whileStmt);
    9594    Value* compileExpression(const PabloAST * expr);
    96 
    97     #ifdef USE_UADD_OVERFLOW
    98     #ifdef USE_TWO_UADD_OVERFLOW
    99     Function* mFunctionUaddOverflow;
    100     SumWithOverflowPack callUaddOverflow(Value *e1, Value *e2);
    101     #else
    102     Function* mFunctionUaddOverflowCarryin;
    103     SumWithOverflowPack callUaddOverflow(Value *e1, Value *e2, Value *cin);
    104     #endif
    105     #endif
    10695
    10796    ASTToValueMap                       mMarkerMap;
Note: See TracChangeset for help on using the changeset viewer.