Changeset 4676


Ignore:
Timestamp:
Jul 15, 2015, 6:20:38 PM (4 years ago)
Author:
cameron
Message:

Simplify/unify conditional creation of explicit carry summary code and summary phi nodes.

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

Legend:

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

    r4672 r4676  
    112112    scopeCarryDataBits = nestedframePosition;
    113113   
    114     if ((ifDepth > 0) && (scopeCarryDataBits > BLOCK_SIZE)) {
     114    if (explicitSummaryRequired()) {
    115115        // Need extra space for the summary variable, always the last
    116116        // entry within an if block.
  • icGREP/icgrep-devel/icgrep/pablo/carry_data.h

    r4672 r4676  
    9494    bool blockHasCarries() const { return scopeCarryDataBits > 0;}
    9595   
    96     bool explicitSummaryRequired() const { return scopeCarryDataBits > BLOCK_SIZE;}
    97    
    98     bool summaryNeededInParentBlock() const {return (ifDepth > 0) && blockHasCarries();}
     96    bool explicitSummaryRequired() const { return (ifDepth > 0) && (scopeCarryDataBits > BLOCK_SIZE);}
    9997   
    10098private:
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.cpp

    r4672 r4676  
    210210}
    211211
    212 bool CarryManager::summaryNeededInParentBlock(){
    213     return mCarryInfo->summaryNeededInParentBlock();
    214 }
    215 
    216 void CarryManager::addSummaryPhi(BasicBlock * ifEntryBlock, BasicBlock * ifBodyFinalBlock) {
     212void CarryManager::addSummaryPhiIfNeeded(BasicBlock * ifEntryBlock, BasicBlock * ifBodyFinalBlock) {
     213    if ((mCarryInfo->getIfDepth() <= 1) || !mCarryInfo->blockHasCarries()){
     214        // For ifDepth == 1, the parent does not need a summary as it is not itself within an if.
     215        // Therefore, it doesn't need access to this block's summary in building its own.
     216        return;
     217    }
    217218    const unsigned carrySummaryIndex = mCurrentScopeIndex + mCarryInfo->summaryCarryDataIndex();
    218219    PHINode * summary_phi = mBuilder->CreatePHI(mBitBlockType, 2, "summary");
     
    222223}
    223224
    224 void CarryManager::generateCarryOutSummaryCode() {
     225void CarryManager::generateCarryOutSummaryCodeIfNeeded() {
     226   
     227    if (!mCarryInfo->explicitSummaryRequired()) {
     228        // An explicit summary may not be required, if there is a single carry
     229        // operation within the block, or the carries are packed and all carry
     230        // bits fit within a single pack.
     231        return;
     232    }
    225233   
    226234    const unsigned carrySummaryIndex = mCurrentScopeIndex + mCarryInfo->summaryCarryDataIndex();
    227    
    228     if (mCarryInfo->getScopeCarryDataSize() == 1) {
    229         // If scopeCarryDataSize == 1, then we have one pack which serves as
    230         // the summary.   It should already be stored.   
    231         return;
    232     }
    233235   
    234236    Value * carry_summary = mZeroInitializer;
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.h

    r4672 r4676  
    7676    Value * getCarrySummaryExpr();
    7777   
    78     void generateCarryOutSummaryCode();
     78    void generateCarryOutSummaryCodeIfNeeded();
    7979   
    80     bool summaryNeededInParentBlock();
    81    
    82     void addSummaryPhi(BasicBlock * ifEntryBlock, BasicBlock * ifBodyFinalBlock);
     80    void addSummaryPhiIfNeeded(BasicBlock * ifEntryBlock, BasicBlock * ifBodyFinalBlock);
    8381   
    8482    /* Methods for load/store of carries for non-while blocks. */
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4674 r4676  
    462462    --mIfDepth;
    463463    if (mCarryManager->blockHasCarries()) {
    464         mCarryManager->generateCarryOutSummaryCode();
     464        mCarryManager->generateCarryOutSummaryCodeIfNeeded();
    465465    }
    466466    BasicBlock * ifBodyFinalBlock = mBuilder->GetInsertBlock();
     
    478478    }
    479479    // Create the phi Node for the summary variable, if needed.
    480     if (mCarryManager->summaryNeededInParentBlock()) {
    481         mCarryManager->addSummaryPhi(ifEntryBlock, ifBodyFinalBlock);
    482     }
     480    mCarryManager->addSummaryPhiIfNeeded(ifEntryBlock, ifBodyFinalBlock);
    483481    mCarryManager->leaveScope();
    484482}
Note: See TracChangeset for help on using the changeset viewer.