Ignore:
Timestamp:
Dec 23, 2015, 11:47:47 AM (3 years ago)
Author:
cameron
Message:

Add IRBuilder functionality to IDISA_Builder; eliminate separate mBuilder

File:
1 edited

Legend:

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

    r4897 r4898  
    5252    f->setCallingConv(CallingConv::C);
    5353    f->setAttributes(AttrSet);
    54     llvm::IRBuilderBase::InsertPoint ip = mBuilder->saveIP();
    55     mBuilder->SetInsertPoint(BasicBlock::Create(m->getContext(), "entry1", f,0));
    56     mBuilder->CreateMemSet(mCarryBitBlockPtr, mBuilder->getInt8(0), mTotalCarryDataBitBlocks * mBITBLOCK_WIDTH/8, 4);
    57     ReturnInst::Create(m->getContext(), mBuilder->GetInsertBlock());
    58     mBuilder->restoreIP(ip);
     54    llvm::IRBuilderBase::InsertPoint ip = iBuilder->saveIP();
     55    iBuilder->SetInsertPoint(BasicBlock::Create(m->getContext(), "entry1", f,0));
     56    iBuilder->CreateMemSet(mCarryBitBlockPtr, iBuilder->getInt8(0), mTotalCarryDataBitBlocks * mBITBLOCK_WIDTH/8, 4);
     57    ReturnInst::Create(m->getContext(), iBuilder->GetInsertBlock());
     58    iBuilder->restoreIP(ip);
    5959}
    6060   
     
    6868        mPACK_SIZE = 64;
    6969        mITEMS_PER_PACK = 64;
    70         mCarryPackType = mBuilder->getIntNTy(mPACK_SIZE);
     70        mCarryPackType = iBuilder->getIntNTy(mPACK_SIZE);
    7171    }
    7272    else {
     
    9797    cdArray->setInitializer(cdInitData);
    9898   
    99     mCarryPackBasePtr = mBuilder->CreateBitCast(cdArray, PointerType::get(mCarryPackType, 0));
    100     mCarryBitBlockPtr = mBuilder->CreateBitCast(cdArray, PointerType::get(mBitBlockType, 0));
     99    mCarryPackBasePtr = iBuilder->CreateBitCast(cdArray, PointerType::get(mCarryPackType, 0));
     100    mCarryBitBlockPtr = iBuilder->CreateBitCast(cdArray, PointerType::get(mBitBlockType, 0));
    101101   
    102102    generateCarryDataInitializer(m);
     
    104104    // Popcount data is stored after all the carry data.
    105105    if (mPabloCountCount > 0) {
    106         ArrayType* pcArrayTy = ArrayType::get(mBuilder->getIntNTy(64), mPabloCountCount);
     106        ArrayType* pcArrayTy = ArrayType::get(iBuilder->getIntNTy(64), mPabloCountCount);
    107107        GlobalVariable* pcArray = new GlobalVariable(*m, pcArrayTy, /*isConstant=*/false, GlobalValue::CommonLinkage, 0, "popcount_data");
    108108        cdArray->setAlignment(mBITBLOCK_WIDTH/8);
    109109        ConstantAggregateZero* pcInitData = ConstantAggregateZero::get(pcArrayTy);
    110110        pcArray->setInitializer(pcInitData);
    111         mPopcountBasePtr = mBuilder->CreateBitCast(pcArray, Type::getInt64PtrTy(mBuilder->getContext()));
     111        mPopcountBasePtr = iBuilder->CreateBitCast(pcArray, Type::getInt64PtrTy(iBuilder->getContext()));
    112112    }
    113113    // Carry Data area will have one extra bit block to store the block number.
    114     GlobalVariable* blkNo = new GlobalVariable(*m, mBuilder->getIntNTy(64), /*isConstant=*/false, GlobalValue::CommonLinkage, 0, "blockNo");
     114    GlobalVariable* blkNo = new GlobalVariable(*m, iBuilder->getIntNTy(64), /*isConstant=*/false, GlobalValue::CommonLinkage, 0, "blockNo");
    115115    blkNo->setAlignment(16);
    116     blkNo->setInitializer(mBuilder->getInt64(0));
     116    blkNo->setInitializer(iBuilder->getInt64(0));
    117117    mBlockNoPtr = blkNo;
    118     mBlockNo = mBuilder->CreateLoad(mBlockNoPtr);
     118    mBlockNo = iBuilder->CreateLoad(mBlockNoPtr);
    119119    /*  Set the current scope to PabloRoot */
    120120    mCurrentScope = mPabloRoot;
     
    124124   
    125125void CarryManager::generateBlockNoIncrement() {
    126     mBuilder->CreateStore(mBuilder->CreateAdd(mBlockNo, mBuilder->getInt64(1)), mBlockNoPtr);
     126    iBuilder->CreateStore(iBuilder->CreateAdd(mBlockNo, iBuilder->getInt64(1)), mBlockNoPtr);
    127127}
    128128
     
    277277Value * CarryManager::getCarryPack(unsigned packIndex) {
    278278    if (mCarryInPack[packIndex] == nullptr) {
    279         Value * packPtr = mBuilder->CreateGEP(mCarryPackBasePtr, mBuilder->getInt64(packIndex));
     279        Value * packPtr = iBuilder->CreateGEP(mCarryPackBasePtr, iBuilder->getInt64(packIndex));
    280280        // Save the computed pointer - so that it can be used in storeCarryPack.
    281281        mCarryPackPtr[packIndex] = packPtr;
    282         mCarryInPack[packIndex] = mBuilder->CreateAlignedLoad(packPtr, mPACK_SIZE/8);
     282        mCarryInPack[packIndex] = iBuilder->CreateAlignedLoad(packPtr, mPACK_SIZE/8);
    283283    }
    284284    return mCarryInPack[packIndex];
     
    286286   
    287287void CarryManager::storeCarryPack(unsigned packIndex) {
    288     mBuilder->CreateAlignedStore(mCarryOutPack[packIndex], mCarryPackPtr[packIndex], mPACK_SIZE/8);
     288    iBuilder->CreateAlignedStore(mCarryOutPack[packIndex], mCarryPackPtr[packIndex], mPACK_SIZE/8);
    289289}
    290290
     
    299299    }
    300300    uint64_t mask = ((((uint64_t) 1) << bitCount) - 1) << lo_bit;
    301     return mBuilder->CreateAnd(pack, ConstantInt::get(mCarryPackType, mask));
     301    return iBuilder->CreateAnd(pack, ConstantInt::get(mCarryPackType, mask));
    302302}
    303303   
     
    307307    Value * selected = maskSelectBitRange(getCarryPack(packIndex), packOffset, carryBitCount);
    308308    if (packOffset == 0) return selected;
    309     return mBuilder->CreateLShr(selected, packOffset);
     309    return iBuilder->CreateLShr(selected, packOffset);
    310310}
    311311
     
    319319    //Value * field = maskSelectBitRange(field, PACK_SIZE - carryBitCount, carryBitCount);
    320320    if (rshift != 0) {
    321         field = mBuilder->CreateLShr(field, mBuilder->getInt64(rshift));
     321        field = iBuilder->CreateLShr(field, iBuilder->getInt64(rshift));
    322322    }
    323323    if (packOffset != 0) {
    324         field = mBuilder->CreateAnd(field, mBuilder->getInt64(mask));
     324        field = iBuilder->CreateAnd(field, iBuilder->getInt64(mask));
    325325    }
    326326    if (mCarryOutPack[packIndex] == nullptr) {
     
    328328    }
    329329    else {
    330         mCarryOutPack[packIndex] = mBuilder->CreateOr(mCarryOutPack[packIndex], field);
     330        mCarryOutPack[packIndex] = iBuilder->CreateOr(mCarryOutPack[packIndex], field);
    331331    }
    332332}
    333333
    334334Value * CarryManager::pack2bitblock(Value * pack) {
    335     return iBuilder->bitCast(mBuilder->CreateZExt(pack, mBuilder->getIntNTy(mBITBLOCK_WIDTH)));
     335    return iBuilder->bitCast(iBuilder->CreateZExt(pack, iBuilder->getIntNTy(mBITBLOCK_WIDTH)));
    336336}
    337337   
     
    361361    else {
    362362#ifndef LONGADD
    363         Value * carry_bit = mBuilder->CreateLShr(mBuilder->CreateBitCast(carry_out_strm, mBuilder->getIntNTy(mBITBLOCK_WIDTH)), mBITBLOCK_WIDTH-1);
    364         mCarryOutPack[posn] = mBuilder->CreateBitCast(carry_bit, mBitBlockType);
     363        Value * carry_bit = iBuilder->CreateLShr(iBuilder->CreateBitCast(carry_out_strm, iBuilder->getIntNTy(mBITBLOCK_WIDTH)), mBITBLOCK_WIDTH-1);
     364        mCarryOutPack[posn] = iBuilder->CreateBitCast(carry_bit, mBitBlockType);
    365365#else
    366366        mCarryOutPack[posn] = carry_out_strm;
     
    380380        Value* digitsum = iBuilder->simd_add(64, e1, e2);
    381381        Value* partial = iBuilder->simd_add(64, digitsum, carryq_value);
    382         Value* digitcarry = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, mBuilder->CreateNot(partial)));
    383         Value* mid_carry_in = iBuilder->simd_slli(128, mBuilder->CreateLShr(digitcarry, 63), 64);
    384         Value* sum = iBuilder->simd_add(64, partial, mBuilder->CreateBitCast(mid_carry_in, mBitBlockType));
    385         Value* carry_out_strm = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, mBuilder->CreateNot(sum)));
     382        Value* digitcarry = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, iBuilder->CreateNot(partial)));
     383        Value* mid_carry_in = iBuilder->simd_slli(128, iBuilder->CreateLShr(digitcarry, 63), 64);
     384        Value* sum = iBuilder->simd_add(64, partial, iBuilder->CreateBitCast(mid_carry_in, mBitBlockType));
     385        Value* carry_out_strm = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, iBuilder->CreateNot(sum)));
    386386        setCarryOpCarryOut(localIndex, carry_out_strm);
    387387        return sum;
     
    393393        Value* carryprop = iBuilder->simd_or(e1, e2);
    394394        Value * sum = iBuilder->simd_add(mBITBLOCK_WIDTH, iBuilder->simd_add(mBITBLOCK_WIDTH, e1, e2), carryq_value);
    395         Value* carry_out_strm = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, mBuilder->CreateNot(sum)));
     395        Value* carry_out_strm = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, iBuilder->CreateNot(sum)));
    396396        setCarryOpCarryOut(localIndex, carry_out_strm);
    397397        return sum;
     
    402402        Value * carryprop = iBuilder->simd_or(e1, e2);
    403403        Value * digitsum = iBuilder->simd_add(64, e1, e2);
    404         Value * digitcarry = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, mBuilder->CreateNot(digitsum)));
     404        Value * digitcarry = iBuilder->simd_or(carrygen, iBuilder->simd_and(carryprop, iBuilder->CreateNot(digitsum)));
    405405        Value * carryMask = iBuilder->hsimd_signmask(64, digitcarry);
    406         Value * carryMask2 = mBuilder->CreateOr(mBuilder->CreateAdd(carryMask, carryMask), carryin);
     406        Value * carryMask2 = iBuilder->CreateOr(iBuilder->CreateAdd(carryMask, carryMask), carryin);
    407407        Value * bubble = iBuilder->simd_eq(64, digitsum, iBuilder->allOnes());
    408408        Value * bubbleMask = iBuilder->hsimd_signmask(64, bubble);
    409         Value * incrementMask = mBuilder->CreateXor(mBuilder->CreateAdd(bubbleMask, carryMask2), bubbleMask);
     409        Value * incrementMask = iBuilder->CreateXor(iBuilder->CreateAdd(bubbleMask, carryMask2), bubbleMask);
    410410        Value * increments = iBuilder->esimd_bitspread(64,incrementMask);
    411411        Value * sum = iBuilder->simd_add(64, digitsum, increments);
    412         Value * carry_out_strm = iBuilder->mvmd_insert(32, iBuilder->allZeroes(), mBuilder->CreateLShr(incrementMask, iBuilder->getBitBlockWidth()/64), 0);
     412        Value * carry_out_strm = iBuilder->mvmd_insert(32, iBuilder->allZeroes(), iBuilder->CreateLShr(incrementMask, iBuilder->getBitBlockWidth()/64), 0);
    413413        setCarryOpCarryOut(localIndex, carry_out_strm);
    414414        return sum;
     
    436436    if (mITEMS_PER_PACK > 1) {// #ifdef PACKING
    437437        extractAndSaveCarryOutBits(strm, posn, 1);
    438         Value* carry_longint = mBuilder->CreateZExt(getCarryInBits(posn, 1), mBuilder->getIntNTy(mBITBLOCK_WIDTH));
    439         Value* strm_longint = mBuilder->CreateBitCast(strm, mBuilder->getIntNTy(mBITBLOCK_WIDTH));
    440         Value* adv_longint = mBuilder->CreateOr(mBuilder->CreateShl(strm_longint, 1), carry_longint);
    441         Value* result_value = mBuilder->CreateBitCast(adv_longint, mBitBlockType);
     438        Value* carry_longint = iBuilder->CreateZExt(getCarryInBits(posn, 1), iBuilder->getIntNTy(mBITBLOCK_WIDTH));
     439        Value* strm_longint = iBuilder->CreateBitCast(strm, iBuilder->getIntNTy(mBITBLOCK_WIDTH));
     440        Value* adv_longint = iBuilder->CreateOr(iBuilder->CreateShl(strm_longint, 1), carry_longint);
     441        Value* result_value = iBuilder->CreateBitCast(adv_longint, mBitBlockType);
    442442        return result_value;
    443443    }
     
    456456        extractAndSaveCarryOutBits(strm, posn, shift_amount);
    457457        //std::cerr << "shortAdvanceCarryInCarryOut: posn = " << posn << ", shift_amount = " << shift_amount << std::endl;
    458         Value* carry_longint = mBuilder->CreateZExt(getCarryInBits(posn, shift_amount), mBuilder->getIntNTy(mBITBLOCK_WIDTH));
    459         Value* strm_longint = mBuilder->CreateBitCast(strm, mBuilder->getIntNTy(mBITBLOCK_WIDTH));
    460         Value* adv_longint = mBuilder->CreateOr(mBuilder->CreateShl(strm_longint, shift_amount), carry_longint);
    461         Value* result_value = mBuilder->CreateBitCast(adv_longint, mBitBlockType);
     458        Value* carry_longint = iBuilder->CreateZExt(getCarryInBits(posn, shift_amount), iBuilder->getIntNTy(mBITBLOCK_WIDTH));
     459        Value* strm_longint = iBuilder->CreateBitCast(strm, iBuilder->getIntNTy(mBITBLOCK_WIDTH));
     460        Value* adv_longint = iBuilder->CreateOr(iBuilder->CreateShl(strm_longint, shift_amount), carry_longint);
     461        Value* result_value = iBuilder->CreateBitCast(adv_longint, mBitBlockType);
    462462        return result_value;
    463463    }
     
    475475        return iBuilder->simd_or(iBuilder->simd_srli(DSSLI_FIELDWIDTH, ahead, DSSLI_FIELDWIDTH-shift_amount), iBuilder->simd_slli(DSSLI_FIELDWIDTH, strm, shift_amount));
    476476    }
    477     Value* advanceq_longint = mBuilder->CreateBitCast(carry_in, mBuilder->getIntNTy(mBITBLOCK_WIDTH));
    478     Value* strm_longint = mBuilder->CreateBitCast(strm, mBuilder->getIntNTy(mBITBLOCK_WIDTH));
    479     Value* adv_longint = mBuilder->CreateOr(mBuilder->CreateShl(strm_longint, shift_amount), mBuilder->CreateLShr(advanceq_longint, mBITBLOCK_WIDTH - shift_amount), "advance");
    480     return mBuilder->CreateBitCast(adv_longint, mBitBlockType);
     477    Value* advanceq_longint = iBuilder->CreateBitCast(carry_in, iBuilder->getIntNTy(mBITBLOCK_WIDTH));
     478    Value* strm_longint = iBuilder->CreateBitCast(strm, iBuilder->getIntNTy(mBITBLOCK_WIDTH));
     479    Value* adv_longint = iBuilder->CreateOr(iBuilder->CreateShl(strm_longint, shift_amount), iBuilder->CreateLShr(advanceq_longint, mBITBLOCK_WIDTH - shift_amount), "advance");
     480    return iBuilder->CreateBitCast(adv_longint, mBitBlockType);
    481481}
    482482   
     
    502502Value * CarryManager::longAdvanceCarryInCarryOut(int localIndex, unsigned shift_amount, Value * carry_out) {
    503503    unsigned carryDataIndex = longAdvanceBitBlockPosition(localIndex);
    504     Value * advBaseIndex = mBuilder->getInt64(carryDataIndex);
     504    Value * advBaseIndex = iBuilder->getInt64(carryDataIndex);
    505505    if (shift_amount <= mBITBLOCK_WIDTH) {
    506506        // special case using a single buffer entry and the carry_out value.
    507         Value * advanceDataPtr = mBuilder->CreateGEP(mCarryBitBlockPtr, advBaseIndex);
    508         Value * carry_block0 = mBuilder->CreateAlignedLoad(advanceDataPtr, mBITBLOCK_WIDTH/8);
    509         mBuilder->CreateAlignedStore(carry_out, advanceDataPtr, mBITBLOCK_WIDTH/8);
     507        Value * advanceDataPtr = iBuilder->CreateGEP(mCarryBitBlockPtr, advBaseIndex);
     508        Value * carry_block0 = iBuilder->CreateAlignedLoad(advanceDataPtr, mBITBLOCK_WIDTH/8);
     509        iBuilder->CreateAlignedStore(carry_out, advanceDataPtr, mBITBLOCK_WIDTH/8);
    510510        /* Very special case - no combine */
    511511        if (shift_amount == mBITBLOCK_WIDTH) return carry_block0;
    512         Value* block0_shr = mBuilder->CreateLShr(mBuilder->CreateBitCast(carry_block0, mBuilder->getIntNTy(mBITBLOCK_WIDTH)), mBITBLOCK_WIDTH - shift_amount);
    513         Value* block1_shl = mBuilder->CreateShl(mBuilder->CreateBitCast(carry_out, mBuilder->getIntNTy(mBITBLOCK_WIDTH)), shift_amount);
    514         return mBuilder->CreateBitCast(mBuilder->CreateOr(block1_shl, block0_shr), mBitBlockType);
     512        Value* block0_shr = iBuilder->CreateLShr(iBuilder->CreateBitCast(carry_block0, iBuilder->getIntNTy(mBITBLOCK_WIDTH)), mBITBLOCK_WIDTH - shift_amount);
     513        Value* block1_shl = iBuilder->CreateShl(iBuilder->CreateBitCast(carry_out, iBuilder->getIntNTy(mBITBLOCK_WIDTH)), shift_amount);
     514        return iBuilder->CreateBitCast(iBuilder->CreateOr(block1_shl, block0_shr), mBitBlockType);
    515515    }
    516516    // We need a buffer of at least two elements for storing the advance data.
     
    518518    const unsigned advanceEntries = mCarryInfo->longAdvanceEntries(shift_amount);
    519519    const unsigned bufsize = mCarryInfo->longAdvanceBufferSize(shift_amount);
    520     Value * indexMask = mBuilder->getInt64(bufsize - 1);  // A mask to implement circular buffer indexing
    521     Value * loadIndex0 = mBuilder->CreateAdd(mBuilder->CreateAnd(mBuilder->CreateSub(mBlockNo, mBuilder->getInt64(advanceEntries)), indexMask), advBaseIndex);
    522     Value * storeIndex = mBuilder->CreateAdd(mBuilder->CreateAnd(mBlockNo, indexMask), advBaseIndex);
    523     Value * carry_block0 = mBuilder->CreateAlignedLoad(mBuilder->CreateGEP(mCarryBitBlockPtr, loadIndex0), mBITBLOCK_WIDTH/8);
     520    Value * indexMask = iBuilder->getInt64(bufsize - 1);  // A mask to implement circular buffer indexing
     521    Value * loadIndex0 = iBuilder->CreateAdd(iBuilder->CreateAnd(iBuilder->CreateSub(mBlockNo, iBuilder->getInt64(advanceEntries)), indexMask), advBaseIndex);
     522    Value * storeIndex = iBuilder->CreateAdd(iBuilder->CreateAnd(mBlockNo, indexMask), advBaseIndex);
     523    Value * carry_block0 = iBuilder->CreateAlignedLoad(iBuilder->CreateGEP(mCarryBitBlockPtr, loadIndex0), mBITBLOCK_WIDTH/8);
    524524    // If the long advance is an exact multiple of mBITBLOCK_WIDTH, we simply return the oldest
    525525    // block in the long advance carry data area. 
    526526    if (block_shift == 0) {
    527         mBuilder->CreateAlignedStore(carry_out, mBuilder->CreateGEP(mCarryBitBlockPtr, storeIndex), mBITBLOCK_WIDTH/8);
     527        iBuilder->CreateAlignedStore(carry_out, iBuilder->CreateGEP(mCarryBitBlockPtr, storeIndex), mBITBLOCK_WIDTH/8);
    528528        return carry_block0;
    529529    }
    530530    // Otherwise we need to combine data from the two oldest blocks.
    531     Value * loadIndex1 = mBuilder->CreateAdd(mBuilder->CreateAnd(mBuilder->CreateSub(mBlockNo, mBuilder->getInt64(advanceEntries-1)), indexMask), advBaseIndex);
    532     Value * carry_block1 = mBuilder->CreateAlignedLoad(mBuilder->CreateGEP(mCarryBitBlockPtr, loadIndex1), mBITBLOCK_WIDTH/8);
    533     Value* block0_shr = mBuilder->CreateLShr(mBuilder->CreateBitCast(carry_block0, mBuilder->getIntNTy(mBITBLOCK_WIDTH)), mBITBLOCK_WIDTH - block_shift);
    534     Value* block1_shl = mBuilder->CreateShl(mBuilder->CreateBitCast(carry_block1, mBuilder->getIntNTy(mBITBLOCK_WIDTH)), block_shift);
    535     mBuilder->CreateAlignedStore(carry_out, mBuilder->CreateGEP(mCarryBitBlockPtr, storeIndex), mBITBLOCK_WIDTH/8);
    536     return mBuilder->CreateBitCast(mBuilder->CreateOr(block1_shl, block0_shr), mBitBlockType);
     531    Value * loadIndex1 = iBuilder->CreateAdd(iBuilder->CreateAnd(iBuilder->CreateSub(mBlockNo, iBuilder->getInt64(advanceEntries-1)), indexMask), advBaseIndex);
     532    Value * carry_block1 = iBuilder->CreateAlignedLoad(iBuilder->CreateGEP(mCarryBitBlockPtr, loadIndex1), mBITBLOCK_WIDTH/8);
     533    Value* block0_shr = iBuilder->CreateLShr(iBuilder->CreateBitCast(carry_block0, iBuilder->getIntNTy(mBITBLOCK_WIDTH)), mBITBLOCK_WIDTH - block_shift);
     534    Value* block1_shl = iBuilder->CreateShl(iBuilder->CreateBitCast(carry_block1, iBuilder->getIntNTy(mBITBLOCK_WIDTH)), block_shift);
     535    iBuilder->CreateAlignedStore(carry_out, iBuilder->CreateGEP(mCarryBitBlockPtr, storeIndex), mBITBLOCK_WIDTH/8);
     536    return iBuilder->CreateBitCast(iBuilder->CreateOr(block1_shl, block0_shr), mBitBlockType);
    537537}
    538538   
     
    551551        if (mITEMS_PER_PACK > 1) {// #ifdef PACKING
    552552            Value * summary_bits = maskSelectBitRange(summary_pack, summaryPosition() % mPACK_SIZE, summaryBits());
    553             test_expr = iBuilder->simd_or(test_expr, mBuilder->CreateZExt(summary_bits, mBuilder->getIntNTy(mBITBLOCK_WIDTH)));
     553            test_expr = iBuilder->simd_or(test_expr, iBuilder->CreateZExt(summary_bits, iBuilder->getIntNTy(mBITBLOCK_WIDTH)));
    554554        }
    555555        else {
     
    577577        const unsigned currentScopeBase = scopeBasePack();
    578578        for (unsigned index = currentScopeBase; index < currentScopeBase + scopeCarryPacks; ++index) {
    579             PHINode * phi_out = mBuilder->CreatePHI(mCarryPackType, 2);
     579            PHINode * phi_out = iBuilder->CreatePHI(mCarryPackType, 2);
    580580            phi_out->addIncoming(Constant::getNullValue(mCarryPackType),ifEntryBlock);
    581581            phi_out->addIncoming(mCarryOutPack[index], ifBodyFinalBlock);
     
    592592        if (ifScopeCarrySize <= mPACK_SIZE) {
    593593            unsigned const ifPackIndex = scopeBasePack();
    594             PHINode * ifPack_phi = mBuilder->CreatePHI(mCarryPackType, 2, "ifPack");
     594            PHINode * ifPack_phi = iBuilder->CreatePHI(mCarryPackType, 2, "ifPack");
    595595            ifPack_phi->addIncoming(mCarryInfo->ifEntryPack, ifEntryBlock);
    596596            ifPack_phi->addIncoming(mCarryOutPack[ifPackIndex], ifBodyFinalBlock);
     
    603603        // its own summary.
    604604        const unsigned summaryIndex = summaryPackIndex();
    605         PHINode * summary_phi = mBuilder->CreatePHI(mCarryPackType, 2, "summary");
     605        PHINode * summary_phi = iBuilder->CreatePHI(mCarryPackType, 2, "summary");
    606606        summary_phi->addIncoming(Constant::getNullValue(mCarryPackType), ifEntryBlock);
    607607        summary_phi->addIncoming(mCarryOutPack[summaryIndex], ifBodyFinalBlock);
     
    617617    }
    618618    const unsigned carrySummaryIndex = summaryPackIndex();
    619     PHINode * summary_phi = mBuilder->CreatePHI(mCarryPackType, 2, "summary");
     619    PHINode * summary_phi = iBuilder->CreatePHI(mCarryPackType, 2, "summary");
    620620    summary_phi->addIncoming(Constant::getNullValue(mCarryPackType), ifEntryBlock);
    621621    summary_phi->addIncoming(mCarryOutPack[carrySummaryIndex], ifBodyFinalBlock);
     
    644644            carry_summary = mCarryOutPack[localCarryIndex];
    645645            for (unsigned i = 1; i < localCarryPacks; i++) {
    646                 carry_summary = mBuilder->CreateOr(carry_summary, mCarryOutPack[localCarryIndex+i]);
     646                carry_summary = iBuilder->CreateOr(carry_summary, mCarryOutPack[localCarryIndex+i]);
    647647            }
    648648        }
     
    652652                enterScope(inner_blk);
    653653                if (blockHasCarries()) {
    654                   carry_summary = mBuilder->CreateOr(carry_summary, mCarryOutPack[summaryPackIndex()]);
     654                  carry_summary = iBuilder->CreateOr(carry_summary, mCarryOutPack[summaryPackIndex()]);
    655655                }
    656656                leaveScope();
     
    660660                enterScope(inner_blk);
    661661                if (blockHasCarries()) {
    662                     carry_summary = mBuilder->CreateOr(carry_summary, mCarryOutPack[summaryPackIndex()]);
     662                    carry_summary = iBuilder->CreateOr(carry_summary, mCarryOutPack[summaryPackIndex()]);
    663663                }
    664664                leaveScope();
     
    692692    for (unsigned index = 0; index < scopeCarryPacks; ++index) {
    693693#ifdef SET_WHILE_CARRY_IN_TO_ZERO_AFTER_FIRST_ITERATION
    694         PHINode * phi_in = mBuilder->CreatePHI(mCarryPackType, 2);
     694        PHINode * phi_in = iBuilder->CreatePHI(mCarryPackType, 2);
    695695        phi_in->addIncoming(mCarryInPack[currentScopeBase+index], whileEntryBlock);
    696696        mCarryInPhis[index] = phi_in;
    697697#endif
    698         PHINode * phi_out = mBuilder->CreatePHI(mCarryPackType, 2);
     698        PHINode * phi_out = iBuilder->CreatePHI(mCarryPackType, 2);
    699699        phi_out->addIncoming(Constant::getNullValue(mCarryPackType), whileEntryBlock);
    700700        mCarryOutAccumPhis[index] = phi_out;
     
    711711#endif
    712712        PHINode * phi = mCarryOutAccumPhis[index];
    713         Value * carryOut = mBuilder->CreateOr(phi, mCarryOutPack[currentScopeBase+index]);
     713        Value * carryOut = iBuilder->CreateOr(phi, mCarryOutPack[currentScopeBase+index]);
    714714        phi->addIncoming(carryOut, whileBodyFinalBlock);
    715715        mCarryOutPack[currentScopeBase+index] = carryOut;
     
    748748
    749749Value * CarryManager::popCount(Value * to_count, unsigned globalIdx) {
    750     Value * countPtr = mBuilder->CreateGEP(mPopcountBasePtr, mBuilder->getInt64(globalIdx));
    751     Value * countSoFar = mBuilder->CreateAlignedLoad(countPtr, 8);
     750    Value * countPtr = iBuilder->CreateGEP(mPopcountBasePtr, iBuilder->getInt64(globalIdx));
     751    Value * countSoFar = iBuilder->CreateAlignedLoad(countPtr, 8);
    752752    Value * fieldCounts = iBuilder->simd_popcount(64, to_count);
    753753    for (int i = 0; i < mBITBLOCK_WIDTH/64; i++) {
    754         countSoFar = mBuilder->CreateAdd(countSoFar, iBuilder->mvmd_extract(64, fieldCounts, i));
    755     }
    756     mBuilder->CreateAlignedStore(countSoFar, countPtr, 8);
    757     return iBuilder->bitCast(mBuilder->CreateZExt(countSoFar, mBuilder->getIntNTy(mBITBLOCK_WIDTH)));
     754        countSoFar = iBuilder->CreateAdd(countSoFar, iBuilder->mvmd_extract(64, fieldCounts, i));
     755    }
     756    iBuilder->CreateAlignedStore(countSoFar, countPtr, 8);
     757    return iBuilder->bitCast(iBuilder->CreateZExt(countSoFar, iBuilder->getIntNTy(mBITBLOCK_WIDTH)));
    758758}
    759759
Note: See TracChangeset for help on using the changeset viewer.