Ignore:
Timestamp:
Oct 16, 2015, 10:49:26 AM (4 years ago)
Author:
cameron
Message:

Encapsulation of bitblock and carry pack construction

File:
1 edited

Legend:

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

    r4827 r4837  
    5959, mBuilder(nullptr)
    6060, mCarryManager(nullptr)
    61 , mBitBlockType(VectorType::get(IntegerType::get(getGlobalContext(), 64), BLOCK_SIZE / 64))
     61    , mBitBlockType(VectorType::get(IntegerType::get(getGlobalContext(), 64), BLOCK_SIZE/64))
    6262, iBuilder(mBitBlockType)
    6363, mInputType(nullptr)
     
    236236        if (t1 == mBitBlockType) {
    237237            if (t2 == mBitBlockType) {
    238                 return iBuilder.bitblock_any(mBuilder->CreateOr(e1, e2));
     238                return iBuilder.bitblock_any(iBuilder.simd_or(e1, e2));
    239239            }
    240240            else {
     
    438438    }
    439439    else if (const And * pablo_and = dyn_cast<And>(stmt)) {
    440         expr = mBuilder->CreateAnd(compileExpression(pablo_and->getExpr1()), compileExpression(pablo_and->getExpr2()), "and");
     440        expr = iBuilder.simd_and(compileExpression(pablo_and->getExpr1()), compileExpression(pablo_and->getExpr2()));
    441441    }
    442442    else if (const Or * pablo_or = dyn_cast<Or>(stmt)) {
    443         expr = mBuilder->CreateOr(compileExpression(pablo_or->getExpr1()), compileExpression(pablo_or->getExpr2()), "or");
     443        expr = iBuilder.simd_or(compileExpression(pablo_or->getExpr1()), compileExpression(pablo_or->getExpr2()));
    444444    }
    445445    else if (const Xor * pablo_xor = dyn_cast<Xor>(stmt)) {
    446         expr = mBuilder->CreateXor(compileExpression(pablo_xor->getExpr1()), compileExpression(pablo_xor->getExpr2()), "xor");
     446        expr = iBuilder.simd_xor(compileExpression(pablo_xor->getExpr1()), compileExpression(pablo_xor->getExpr2()));
    447447    }
    448448    else if (const Sel * sel = dyn_cast<Sel>(stmt)) {
    449449        Value* ifMask = compileExpression(sel->getCondition());
    450         Value* ifTrue = mBuilder->CreateAnd(ifMask, compileExpression(sel->getTrueExpr()));
    451         Value* ifFalse = mBuilder->CreateAnd(mBuilder->CreateNot(ifMask), compileExpression(sel->getFalseExpr()));
    452         expr = mBuilder->CreateOr(ifTrue, ifFalse);
     450        Value* ifTrue = iBuilder.simd_and(ifMask, compileExpression(sel->getTrueExpr()));
     451        Value* ifFalse = iBuilder.simd_and(iBuilder.simd_not(ifMask), compileExpression(sel->getFalseExpr()));
     452        expr = iBuilder.simd_or(ifTrue, ifFalse);
    453453    }
    454454    else if (const Not * pablo_not = dyn_cast<Not>(stmt)) {
    455         expr = mBuilder->CreateNot(compileExpression(pablo_not->getExpr()));
     455        expr = iBuilder.simd_not(compileExpression(pablo_not->getExpr()));
    456456    }
    457457    else if (const Advance * adv = dyn_cast<Advance>(stmt)) {
     
    469469        Value * marker = compileExpression(mstar->getMarker());
    470470        Value * cc = compileExpression(mstar->getCharClass());
    471         Value * marker_and_cc = mBuilder->CreateAnd(marker, cc);
     471        Value * marker_and_cc = iBuilder.simd_and(marker, cc);
    472472        unsigned carry_index = mstar->getLocalCarryIndex();
    473473        Value * sum = mCarryManager->addCarryInCarryOut(carry_index, marker_and_cc, cc);
    474         expr = mBuilder->CreateOr(mBuilder->CreateXor(sum, cc), marker, "matchstar");
     474        expr = iBuilder.simd_or(iBuilder.simd_xor(sum, cc), marker);
    475475    }
    476476    else if (const Mod64MatchStar * mstar = dyn_cast<Mod64MatchStar>(stmt)) {
    477477        Value * marker = compileExpression(mstar->getMarker());
    478478        Value * cc = compileExpression(mstar->getCharClass());
    479         Value * marker_and_cc = mBuilder->CreateAnd(marker, cc);
     479        Value * marker_and_cc = iBuilder.simd_and(marker, cc);
    480480        Value * sum = iBuilder.simd_add(64, marker_and_cc, cc);
    481         expr = mBuilder->CreateOr(mBuilder->CreateXor(sum, cc), marker, "matchstar64");
     481        expr = iBuilder.simd_or(iBuilder.simd_xor(sum, cc), marker);
    482482    }
    483483    else if (const ScanThru * sthru = dyn_cast<ScanThru>(stmt)) {
     
    486486        unsigned carry_index = sthru->getLocalCarryIndex();
    487487        Value * sum = mCarryManager->addCarryInCarryOut(carry_index, marker_expr, cc_expr);
    488         expr = mBuilder->CreateAnd(sum, mBuilder->CreateNot(cc_expr), "scanthru");
     488        expr = iBuilder.simd_and(sum, iBuilder.simd_not(cc_expr));
    489489    }
    490490    else if (const Mod64ScanThru * sthru = dyn_cast<Mod64ScanThru>(stmt)) {
     
    492492        Value * cc_expr = compileExpression(sthru->getScanThru());
    493493        Value * sum = iBuilder.simd_add(64, marker_expr, cc_expr);
    494         expr = mBuilder->CreateAnd(sum, mBuilder->CreateNot(cc_expr), "scanthru64");
     494        expr = iBuilder.simd_and(sum, iBuilder.simd_not(cc_expr));
    495495    }
    496496    else if (const Count * c = dyn_cast<Count>(stmt)) {
     
    539539    Value* indices[] = {mBuilder->getInt64(0), mBuilder->getInt32(index)};
    540540    Value* gep = mBuilder->CreateGEP(mOutputAddressPtr, indices);
     541    if (marker->getType() != mBitBlockType) {
     542        marker = mBuilder->CreateBitCast(marker, mBitBlockType);
     543    }
    541544    mBuilder->CreateAlignedStore(marker, gep, iBuilder.getBitBlockWidth()/8, false);
    542545}
Note: See TracChangeset for help on using the changeset viewer.