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/carry_manager.cpp

    r4828 r4837  
    287287    return mCarryInPack[packIndex];
    288288}
    289 
     289   
    290290void CarryManager::storeCarryPack(unsigned packIndex) {
    291     mBuilder->CreateAlignedStore(mCarryOutPack[packIndex], mCarryPackPtr[packIndex], mPACK_SIZE/8);
     291    mBuilder->CreateAlignedStore(mPackBuilder->bitCast(mCarryOutPack[packIndex]), mCarryPackPtr[packIndex], mPACK_SIZE/8);
    292292}
    293293
     
    302302    }
    303303    uint64_t mask = ((((uint64_t) 1) << bitCount) - 1) << lo_bit;
    304     return mBuilder->CreateAnd(pack, mBuilder->getInt64(mask));
     304    return mPackBuilder->simd_and(pack, mBuilder->getInt64(mask));
    305305}
    306306   
     
    331331    }
    332332    else {
    333         mCarryOutPack[packIndex] = mBuilder->CreateOr(mCarryOutPack[packIndex], field);
     333        mCarryOutPack[packIndex] = mPackBuilder->simd_or(mCarryOutPack[packIndex], field);
    334334    }
    335335}
    336336
    337337Value * CarryManager::pack2bitblock(Value * pack) {
    338     return mBuilder->CreateBitCast(mBuilder->CreateZExt(pack, mBuilder->getIntNTy(mBITBLOCK_WIDTH)), mBitBlockType);
     338    return iBuilder->bitCast(mBuilder->CreateZExt(pack, mBuilder->getIntNTy(mBITBLOCK_WIDTH)));
    339339}
    340340   
     
    371371        Value * carryq_value = getCarryOpCarryIn(localIndex);
    372372        //calculate carry through logical ops
    373         Value* carrygen = mBuilder->CreateAnd(e1, e2, "carrygen");
    374         Value* carryprop = mBuilder->CreateOr(e1, e2, "carryprop");
     373        Value* carrygen = iBuilder->simd_and(e1, e2);
     374        Value* carryprop = iBuilder->simd_or(e1, e2);
    375375        Value* digitsum = iBuilder->simd_add(64, e1, e2);
    376376        Value* partial = iBuilder->simd_add(64, digitsum, carryq_value);
    377         Value* digitcarry = mBuilder->CreateOr(carrygen, mBuilder->CreateAnd(carryprop, mBuilder->CreateNot(partial)));
     377        Value* digitcarry = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, mBuilder->CreateNot(partial)));
    378378        Value* mid_carry_in = iBuilder->simd_slli(128, mBuilder->CreateLShr(digitcarry, 63), 64);
    379379        Value* sum = iBuilder->simd_add(64, partial, mBuilder->CreateBitCast(mid_carry_in, mBitBlockType));
    380         Value* carry_out_strm = mBuilder->CreateOr(carrygen, mBuilder->CreateAnd(carryprop, mBuilder->CreateNot(sum)));
     380        Value* carry_out_strm = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, mBuilder->CreateNot(sum)));
    381381        setCarryOpCarryOut(localIndex, carry_out_strm);
    382382        return sum;
     
    384384    else {
    385385        Value * carryq_value = getCarryOpCarryIn(localIndex);
    386         Value* carrygen = mBuilder->CreateAnd(e1, e2, "carrygen");
    387         Value* carryprop = mBuilder->CreateOr(e1, e2, "carryprop");
     386        Value* carrygen = iBuilder->simd_and(e1, e2);
     387        Value* carryprop = iBuilder->simd_or(e1, e2);
    388388        Value * sum = iBuilder->simd_add(mBITBLOCK_WIDTH, iBuilder->simd_add(mBITBLOCK_WIDTH, e1, e2), carryq_value);
    389         Value* carry_out_strm = mBuilder->CreateOr(carrygen, mBuilder->CreateAnd(carryprop, mBuilder->CreateNot(sum)));
     389        Value* carry_out_strm = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, mBuilder->CreateNot(sum)));
    390390        setCarryOpCarryOut(localIndex, carry_out_strm);
    391391        return sum;
     
    425425    if (mBITBLOCK_WIDTH == 128) {
    426426        Value * ahead64 = iBuilder->mvmd_dslli(64, carry_in, strm, 1);
    427         result_value = mBuilder->CreateOr(iBuilder->simd_srli(64, ahead64, 63), iBuilder->simd_slli(64, strm, 1));
     427        result_value = iBuilder->simd_or(iBuilder->simd_srli(64, ahead64, 63), iBuilder->simd_slli(64, strm, 1));
    428428    }
    429429    else {
     
    553553            PHINode * phi_out = mBuilder->CreatePHI(mCarryPackType, 2);
    554554            phi_out->addIncoming(mPackBuilder->allZeroes(),ifEntryBlock);
    555             phi_out->addIncoming(mCarryOutPack[index],ifBodyFinalBlock);
     555            phi_out->addIncoming(mPackBuilder->bitCast(mCarryOutPack[index]), ifBodyFinalBlock);
    556556            mCarryOutPack[index] = phi_out;
    557557        }
     
    568568            PHINode * ifPack_phi = mBuilder->CreatePHI(mCarryPackType, 2, "ifPack");
    569569            ifPack_phi->addIncoming(mCarryInfo->ifEntryPack, ifEntryBlock);
    570             ifPack_phi->addIncoming(mCarryOutPack[ifPackIndex], ifBodyFinalBlock);
     570            ifPack_phi->addIncoming(mPackBuilder->bitCast(mCarryOutPack[ifPackIndex]), ifBodyFinalBlock);
    571571            mCarryOutPack[ifPackIndex] = ifPack_phi;
    572572            return;
     
    579579        PHINode * summary_phi = mBuilder->CreatePHI(mCarryPackType, 2, "summary");
    580580        summary_phi->addIncoming(mPackBuilder->allZeroes(), ifEntryBlock);
    581         summary_phi->addIncoming(mCarryOutPack[summaryIndex], ifBodyFinalBlock);
     581        summary_phi->addIncoming(mPackBuilder->bitCast(mCarryOutPack[summaryIndex]), ifBodyFinalBlock);
    582582        mCarryOutPack[summaryIndex] = summary_phi;
    583583    }
     
    593593    PHINode * summary_phi = mBuilder->CreatePHI(mCarryPackType, 2, "summary");
    594594    summary_phi->addIncoming(mPackBuilder->allZeroes(), ifEntryBlock);
    595     summary_phi->addIncoming(mCarryOutPack[carrySummaryIndex], ifBodyFinalBlock);
     595    summary_phi->addIncoming(mPackBuilder->bitCast(mCarryOutPack[carrySummaryIndex]), ifBodyFinalBlock);
    596596    mCarryOutPack[carrySummaryIndex] = summary_phi;
    597597}
     
    618618            carry_summary = mCarryOutPack[localCarryIndex];
    619619            for (unsigned i = 1; i < localCarryPacks; i++) {
    620                 carry_summary = mBuilder->CreateOr(carry_summary, mCarryOutPack[localCarryIndex+i]);
     620                carry_summary = mPackBuilder->simd_or(carry_summary, mCarryOutPack[localCarryIndex+i]);
    621621            }
    622622        }
     
    626626                enterScope(inner_blk);
    627627                if (blockHasCarries()) {
    628                   carry_summary = mBuilder->CreateOr(carry_summary, mCarryOutPack[summaryPackIndex()]);
     628                  carry_summary = mPackBuilder->simd_or(carry_summary, mCarryOutPack[summaryPackIndex()]);
    629629                }
    630630                leaveScope();
     
    634634                enterScope(inner_blk);
    635635                if (blockHasCarries()) {
    636                     carry_summary = mBuilder->CreateOr(carry_summary, mCarryOutPack[summaryPackIndex()]);
     636                    carry_summary = mPackBuilder->simd_or(carry_summary, mCarryOutPack[summaryPackIndex()]);
    637637                }
    638638                leaveScope();
     
    685685#endif
    686686        PHINode * phi = mCarryOutAccumPhis[index];
    687         Value * carryOut = mBuilder->CreateOr(phi, mCarryOutPack[currentScopeBase+index]);
    688         phi->addIncoming(carryOut, whileBodyFinalBlock);
     687        Value * carryOut = mPackBuilder->simd_or(phi, mCarryOutPack[currentScopeBase+index]);
     688        phi->addIncoming(mPackBuilder->bitCast(carryOut), whileBodyFinalBlock);
    689689        mCarryOutPack[currentScopeBase+index] = carryOut;
    690690    }
     
    729729    }
    730730    mBuilder->CreateAlignedStore(countSoFar, countPtr, 8);
    731     return mBuilder->CreateBitCast(mBuilder->CreateZExt(countSoFar, mBuilder->getIntNTy(mBITBLOCK_WIDTH)), mBitBlockType);
     731    return iBuilder->bitCast(mBuilder->CreateZExt(countSoFar, mBuilder->getIntNTy(mBITBLOCK_WIDTH)));
    732732}
    733733
Note: See TracChangeset for help on using the changeset viewer.