Changeset 4543


Ignore:
Timestamp:
Apr 30, 2015, 5:54:51 PM (4 years ago)
Author:
cameron
Message:

Minor clean-ups

File:
1 edited

Legend:

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

    r4542 r4543  
    811811    //This is the ideal implementation, which uses two uadd.with.overflow
    812812    //The back end should be able to recognize this pattern and combine it into uadd.with.overflow.carryin
    813     CastInst* int128_e1 = new BitCastInst(e1, IntegerType::get(mMod->getContext(), BLOCK_SIZE), "e1_128", mBasicBlock);
    814     CastInst* int128_e2 = new BitCastInst(e2, IntegerType::get(mMod->getContext(), BLOCK_SIZE), "e2_128", mBasicBlock);
    815     CastInst* int128_carryq_value = new BitCastInst(carryq_value, IntegerType::get(mMod->getContext(), BLOCK_SIZE), "carryq_128", mBasicBlock);
     813    CastInst* int128_e1 = new BitCastInst(e1, b.getIntNTy(BLOCK_SIZE), "e1_128", mBasicBlock);
     814    CastInst* int128_e2 = new BitCastInst(e2, b.getIntNTy(BLOCK_SIZE), "e2_128", mBasicBlock);
     815    CastInst* int128_carryq_value = new BitCastInst(carryq_value, b.getIntNTy(BLOCK_SIZE), "carryq_128", mBasicBlock);
    816816
    817817    SumWithOverflowPack sumpack0, sumpack1;
     
    831831#elif defined USE_UADD_OVERFLOW
    832832    //use llvm.uadd.with.overflow.i128 or i256
    833     CastInst* int128_e1 = new BitCastInst(e1, IntegerType::get(mMod->getContext(), BLOCK_SIZE), "e1_128", mBasicBlock);
    834     CastInst* int128_e2 = new BitCastInst(e2, IntegerType::get(mMod->getContext(), BLOCK_SIZE), "e2_128", mBasicBlock);
     833    CastInst* int128_e1 = new BitCastInst(e1, b.getIntNTy(BLOCK_SIZE), "e1_128", mBasicBlock);
     834    CastInst* int128_e2 = new BitCastInst(e2, b.getIntNTy(BLOCK_SIZE), "e2_128", mBasicBlock);
    835835
    836836    //get i1 carryin from iBLOCK_SIZE
     
    867867    return sum;
    868868}
    869 #define CARRY_DEBUG
     869//#define CARRY_DEBUG
    870870Value* PabloCompiler::genCarryDataLoad(const unsigned index) {
    871871    assert (index < mCarryDataVector.size());
     
    889889    mCarryDataSummaryIdx[index] = -1;
    890890#ifdef CARRY_DEBUG
    891     genPrintRegister("carry_out_" + std::to_string(index), mCarryVector[index]);
     891    genPrintRegister("carry_out_" + std::to_string(index), mCarryDataVector[index]);
    892892#endif
    893893    mCarryDataVector[index] = carryOut;
     
    896896inline Value* PabloCompiler::genBitBlockAny(Value* test) {
    897897    IRBuilder<> b(mBasicBlock);
    898     Value* cast_marker_value_1 = b.CreateBitCast(test, IntegerType::get(mMod->getContext(), BLOCK_SIZE));
    899     return b.CreateICmpEQ(cast_marker_value_1, ConstantInt::get(IntegerType::get(mMod->getContext(), BLOCK_SIZE), 0));
     898    Value* cast_marker_value_1 = b.CreateBitCast(test, b.getIntNTy(BLOCK_SIZE));
     899    return b.CreateICmpEQ(cast_marker_value_1, ConstantInt::get(b.getIntNTy(BLOCK_SIZE), 0));
    900900}
    901901
     
    910910Value* PabloCompiler::genShiftLeft64(Value* e, const Twine &namehint) {
    911911    IRBuilder<> b(mBasicBlock);
    912     Value* i128_val = b.CreateBitCast(e, IntegerType::get(mMod->getContext(), BLOCK_SIZE));
     912    Value* i128_val = b.CreateBitCast(e, b.getIntNTy(BLOCK_SIZE));
    913913    return b.CreateBitCast(b.CreateShl(i128_val, 64, namehint), mBitBlockType);
    914914}
     
    950950            // This is the preferred logic, but is too slow for the general case.
    951951            // We need to speed up our custom LLVM for this code.
    952             Value* advanceq_longint = b.CreateBitCast(genCarryDataLoad(loadIdx), IntegerType::get(mMod->getContext(), BLOCK_SIZE));
    953             Value* strm_longint = b.CreateBitCast(strm_value, IntegerType::get(mMod->getContext(), BLOCK_SIZE));
     952            Value* advanceq_longint = b.CreateBitCast(genCarryDataLoad(loadIdx), b.getIntNTy(BLOCK_SIZE));
     953            Value* strm_longint = b.CreateBitCast(strm_value, b.getIntNTy(BLOCK_SIZE));
    954954            Value* adv_longint = b.CreateOr(b.CreateShl(strm_longint, block_shift), b.CreateLShr(advanceq_longint, BLOCK_SIZE - block_shift), "advance");
    955955            result_value = b.CreateBitCast(adv_longint, mBitBlockType);
    956956        }
    957957#else
    958         Value* advanceq_longint = b.CreateBitCast(genCarryDataLoad(loadIdx), IntegerType::get(mMod->getContext(), BLOCK_SIZE));
    959         Value* strm_longint = b.CreateBitCast(strm_value, IntegerType::get(mMod->getContext(), BLOCK_SIZE));
     958        Value* advanceq_longint = b.CreateBitCast(genCarryDataLoad(loadIdx), b.getIntNTy(BLOCK_SIZE));
     959        Value* strm_longint = b.CreateBitCast(strm_value, b.getIntNTy(BLOCK_SIZE));
    960960        Value* adv_longint = b.CreateOr(b.CreateShl(strm_longint, block_shift), b.CreateLShr(advanceq_longint, BLOCK_SIZE - block_shift), "advance");
    961961        result_value = b.CreateBitCast(adv_longint, mBitBlockType);
     
    969969        else {
    970970            // The advance is based on the two oldest bit blocks in the advance queue.
    971             Value* advanceq_longint = b.CreateBitCast(genCarryDataLoad(loadIdx), IntegerType::get(mMod->getContext(), BLOCK_SIZE));
    972             Value* strm_longint = b.CreateBitCast(genCarryDataLoad(loadIdx-1), IntegerType::get(mMod->getContext(), BLOCK_SIZE));
     971            Value* advanceq_longint = b.CreateBitCast(genCarryDataLoad(loadIdx), b.getIntNTy(BLOCK_SIZE));
     972            Value* strm_longint = b.CreateBitCast(genCarryDataLoad(loadIdx-1), b.getIntNTy(BLOCK_SIZE));
    973973            Value* adv_longint = b.CreateOr(b.CreateShl(strm_longint, block_shift), b.CreateLShr(advanceq_longint, BLOCK_SIZE - block_shift), "longadvance");
    974974            result_value = b.CreateBitCast(adv_longint, mBitBlockType);
Note: See TracChangeset for help on using the changeset viewer.