Ignore:
Timestamp:
Jul 30, 2015, 12:30:21 PM (4 years ago)
Author:
cameron
Message:

Move add-with-carry into carry manager

File:
1 edited

Legend:

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

    r4703 r4708  
    365365}
    366366
    367 Value * PabloCompiler::genBitTest2(Value * e1, Value * e2) {
    368     Type * t1 = e1->getType();
    369     Type * t2 = e2->getType();
    370     if (t1 == mBitBlockType) {
    371         if (t2 == mBitBlockType) {
    372             return iBuilder.bitblock_any(mBuilder->CreateOr(e1, e2));
     367    Value * PabloCompiler::genBitTest2(Value * e1, Value * e2) {
     368        Type * t1 = e1->getType();
     369        Type * t2 = e2->getType();
     370        if (t1 == mBitBlockType) {
     371            if (t2 == mBitBlockType) {
     372                return iBuilder.bitblock_any(mBuilder->CreateOr(e1, e2));
     373            }
     374            else {
     375                Value * m1 = mBuilder->CreateZExt(iBuilder.hsimd_signmask(16, e1), t2);
     376                return mBuilder->CreateICmpNE(mBuilder->CreateOr(m1, e2), ConstantInt::get(t2, 0));
     377            }
     378        }
     379        else if (t2 == mBitBlockType) {
     380            Value * m2 = mBuilder->CreateZExt(iBuilder.hsimd_signmask(16, e2), t1);
     381            return mBuilder->CreateICmpNE(mBuilder->CreateOr(e1, m2), ConstantInt::get(t1, 0));
    373382        }
    374383        else {
    375             Value * m1 = mBuilder->CreateZExt(iBuilder.hsimd_signmask(16, e1), t2);
    376             return mBuilder->CreateICmpNE(mBuilder->CreateOr(m1, e2), ConstantInt::get(t2, 0));
    377         }
    378     }
    379     else if (t2 == mBitBlockType) {
    380         Value * m2 = mBuilder->CreateZExt(iBuilder.hsimd_signmask(16, e2), t1);
    381         return mBuilder->CreateICmpNE(mBuilder->CreateOr(e1, m2), ConstantInt::get(t1, 0));
    382     }
    383     else {
    384         return mBuilder->CreateICmpNE(mBuilder->CreateOr(e1, e2), ConstantInt::get(t1, 0));
    385     }
    386 }
    387 
    388 void PabloCompiler::compileIf(const If * ifStatement) {       
     384            return mBuilder->CreateICmpNE(mBuilder->CreateOr(e1, e2), ConstantInt::get(t1, 0));
     385        }
     386    }
     387   
     388    void PabloCompiler::compileIf(const If * ifStatement) {       
    389389    //
    390390    //  The If-ElseZero stmt:
     
    446446    // Create the phi Node for the summary variable, if needed.
    447447    mCarryManager->buildCarryDataPhisAfterIfBody(ifEntryBlock, ifBodyFinalBlock);
    448     //mCarryManager->addSummaryPhiIfNeeded(ifEntryBlock, ifBodyFinalBlock);
    449448    mCarryManager->leaveScope();
    450449}
     
    610609        Value * marker_and_cc = mBuilder->CreateAnd(marker, cc);
    611610        unsigned carry_index = mstar->getLocalCarryIndex();
    612         expr = mBuilder->CreateOr(mBuilder->CreateXor(genAddWithCarry(marker_and_cc, cc, carry_index), cc), marker, "matchstar");
     611        Value * sum = mCarryManager->addCarryInCarryOut(carry_index, marker_and_cc, cc);
     612        expr = mBuilder->CreateOr(mBuilder->CreateXor(sum, cc), marker, "matchstar");
    613613    }
    614614    else if (const ScanThru * sthru = dyn_cast<ScanThru>(stmt)) {
     
    616616        Value * cc_expr = compileExpression(sthru->getScanThru());
    617617        unsigned carry_index = sthru->getLocalCarryIndex();
    618         expr = mBuilder->CreateAnd(genAddWithCarry(marker_expr, cc_expr, carry_index), genNot(cc_expr), "scanthru");
     618        Value * sum = mCarryManager->addCarryInCarryOut(carry_index, marker_expr, cc_expr);
     619        expr = mBuilder->CreateAnd(sum, genNot(cc_expr), "scanthru");
    619620    }
    620621    else {
Note: See TracChangeset for help on using the changeset viewer.