Ignore:
Timestamp:
Jul 10, 2015, 9:10:06 AM (4 years ago)
Author:
cameron
Message:

Move logic for advance operations entirely within carry manager.

File:
1 edited

Legend:

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

    r4647 r4654  
    121121    mIfDepth = 0;
    122122    mMaxWhileDepth = 0;
    123     mCarryManager = new CarryManager(mBuilder, mBitBlockType, mZeroInitializer, mOneInitializer);
     123    mCarryManager = new CarryManager(mMod, mBuilder, mBitBlockType, mZeroInitializer, mOneInitializer);
    124124   
    125125    std::string errMessage;
     
    607607        int shift = adv->getAdvanceAmount();
    608608        unsigned advance_index = adv->getLocalAdvanceIndex();
    609         if (shift == 1) {
    610             expr = genUnitAdvanceWithCarry(strm_value, advance_index);
    611         }
    612         else if (shift < LongAdvanceBase) {
    613             expr = genShortAdvanceWithCarry(strm_value, advance_index, shift);
    614         }
    615         else {
    616             expr = genLongAdvanceWithCarry(strm_value, advance_index, shift);
    617         }
     609        expr = mCarryManager->advanceCarryInCarryOut(mPabloBlock, advance_index, shift, strm_value);
    618610    }
    619611    else if (const MatchStar * mstar = dyn_cast<MatchStar>(stmt)) {
     
    797789}
    798790
    799 Value* PabloCompiler::genUnitAdvanceWithCarry(Value* strm_value, unsigned localIndex) {
    800     Value * carry_in = mCarryManager->getUnitAdvanceCarryIn(mPabloBlock, localIndex);
    801     Value* result_value;
    802    
    803 #if (BLOCK_SIZE == 128) && !defined(USE_LONG_INTEGER_SHIFT)
    804     Value* advanceq_value = genShiftHighbitToLow(BLOCK_SIZE, carry_in);
    805     Value* srli_1_value = mBuilder->CreateLShr(strm_value, 63);
    806     Value* packed_shuffle;
    807     Constant* const_packed_1_elems [] = {mBuilder->getInt32(0), mBuilder->getInt32(2)};
    808     Constant* const_packed_1 = ConstantVector::get(const_packed_1_elems);
    809     packed_shuffle = mBuilder->CreateShuffleVector(advanceq_value, srli_1_value, const_packed_1);
    810    
    811     Constant* const_packed_2_elems[] = {mBuilder->getInt64(1), mBuilder->getInt64(1)};
    812     Constant* const_packed_2 = ConstantVector::get(const_packed_2_elems);
    813    
    814     Value* shl_value = mBuilder->CreateShl(strm_value, const_packed_2);
    815     result_value = mBuilder->CreateOr(shl_value, packed_shuffle, "advance");
    816 #else
    817     Value* advanceq_longint = mBuilder->CreateBitCast(carry_in, mBuilder->getIntNTy(BLOCK_SIZE));
    818     Value* strm_longint = mBuilder->CreateBitCast(strm_value, mBuilder->getIntNTy(BLOCK_SIZE));
    819     Value* adv_longint = mBuilder->CreateOr(mBuilder->CreateShl(strm_longint, 1), mBuilder->CreateLShr(advanceq_longint, BLOCK_SIZE - 1), "advance");
    820     result_value = mBuilder->CreateBitCast(adv_longint, mBitBlockType);
    821    
    822 #endif
    823     mCarryManager->setUnitAdvanceCarryOut(mPabloBlock, localIndex, strm_value);
    824     return result_value;
    825 }
    826                    
    827 Value* PabloCompiler::genShortAdvanceWithCarry(Value* strm_value, unsigned localIndex, int shift_amount) {
    828     Value * carry_in = mCarryManager->getShortAdvanceCarryIn(mPabloBlock, localIndex, shift_amount);
    829     Value* advanceq_longint = mBuilder->CreateBitCast(carry_in, mBuilder->getIntNTy(BLOCK_SIZE));
    830     Value* strm_longint = mBuilder->CreateBitCast(strm_value, mBuilder->getIntNTy(BLOCK_SIZE));
    831     Value* adv_longint = mBuilder->CreateOr(mBuilder->CreateShl(strm_longint, shift_amount), mBuilder->CreateLShr(advanceq_longint, BLOCK_SIZE - shift_amount), "advance");
    832     Value* result_value = mBuilder->CreateBitCast(adv_longint, mBitBlockType);
    833     mCarryManager->setShortAdvanceCarryOut(mPabloBlock, localIndex, shift_amount, strm_value);
    834     return result_value;
    835 }
    836                    
    837 Value* PabloCompiler::genLongAdvanceWithCarry(Value* strm_value, unsigned localIndex, int shift_amount) {
    838     return mCarryManager->longAdvanceCarryInCarryOut(mPabloBlock, localIndex, shift_amount, strm_value);
    839 }
    840791   
    841792void PabloCompiler::SetOutputValue(Value * marker, const unsigned index) {
Note: See TracChangeset for help on using the changeset viewer.