Ignore:
Timestamp:
Oct 29, 2014, 1:16:44 PM (5 years ago)
Author:
linmengl
Message:

USE_UADD_OVERFLOW flag is now working

File:
1 edited

Legend:

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

    r4274 r4275  
    372372                                              /*isVarArg=*/false);
    373373
    374     mFunc_llvm_uadd_with_overflow = mMod->getFunction("llvm.uadd.with.overflow.carryin.i"##BLOCK_SIZE);
    375     if (!mFunc_llvm_uadd_with_overflow) {
    376         mFunc_llvm_uadd_with_overflow = Function::Create(
     374    mFunctionUaddOverflow = mMod->getFunction("llvm.uadd.with.overflow.carryin.i" +
     375                                              std::to_string(BLOCK_SIZE));
     376    if (!mFunctionUaddOverflow) {
     377        mFunctionUaddOverflow = Function::Create(
    377378          /*Type=*/ FuncTy_1,
    378379          /*Linkage=*/ GlobalValue::ExternalLinkage,
    379           /*Name=*/ "llvm.uadd.with.overflow.carryin.i"##BLOCK_SIZE, mMod); // (external, no body)
    380         mFunc_llvm_uadd_with_overflow->setCallingConv(CallingConv::C);
    381     }
    382     AttributeSet mFunc_llvm_uadd_with_overflow_PAL;
     380          /*Name=*/ "llvm.uadd.with.overflow.carryin.i" + std::to_string(BLOCK_SIZE), mMod); // (external, no body)
     381        mFunctionUaddOverflow->setCallingConv(CallingConv::C);
     382    }
     383    AttributeSet mFunctionUaddOverflowPAL;
    383384    {
    384385        SmallVector<AttributeSet, 4> Attrs;
     
    392393
    393394        Attrs.push_back(PAS);
    394         mFunc_llvm_uadd_with_overflow_PAL = AttributeSet::get(mMod->getContext(), Attrs);
    395     }
    396     mFunc_llvm_uadd_with_overflow->setAttributes(mFunc_llvm_uadd_with_overflow_PAL);
     395        mFunctionUaddOverflowPAL = AttributeSet::get(mMod->getContext(), Attrs);
     396    }
     397    mFunctionUaddOverflow->setAttributes(mFunctionUaddOverflowPAL);
    397398#endif
    398399
     
    796797
    797798#ifdef USE_UADD_OVERFLOW
    798 SumWithOverflowPack PabloCompiler::callUaddOverflow(Value* int128_e1, Value* int128_e2, Value* int1_cin) {
     799PabloCompiler::SumWithOverflowPack PabloCompiler::callUaddOverflow(Value* int128_e1, Value* int128_e2, Value* int1_cin) {
    799800    std::vector<Value*> struct_res_params;
    800801    struct_res_params.push_back(int128_e1);
    801802    struct_res_params.push_back(int128_e2);
    802803    struct_res_params.push_back(int1_cin);
    803     CallInst* struct_res = CallInst::Create(mFunc_llvm_uadd_with_overflow, struct_res_params, "uadd_overflow_res", mBasicBlock);
     804    CallInst* struct_res = CallInst::Create(mFunctionUaddOverflow, struct_res_params, "uadd_overflow_res", mBasicBlock);
    804805    struct_res->setCallingConv(CallingConv::C);
    805806    struct_res->setTailCall(false);
     
    838839    sumpack0 = callUaddOverflow(int128_e1, int128_e2, int1_carryq_value);
    839840    Value* obit = sumpack0.obit;
    840     Value* sum = b.CreateBitCast(sumpack0.sum, mXi64Vect, "sum");
     841    Value* sum = b.CreateBitCast(sumpack0.sum, mBitBlockType, "sum");
    841842    /*obit is the i1 carryout, zero extend and insert it into a v2i64 or v4i64 vector.*/
    842     ConstantAggregateZero* const_packed_5 = ConstantAggregateZero::get(mXi64Vect);
     843    ConstantAggregateZero* const_packed_5 = ConstantAggregateZero::get(mBitBlockType);
    843844    CastInst* int64_o0 = new ZExtInst(obit, IntegerType::get(mMod->getContext(), 64), "o0", mBasicBlock);
    844845    InsertElementInst* carry_out = InsertElementInst::Create(const_packed_5, int64_o0, const_int32_6, "carry_out", mBasicBlock);
Note: See TracChangeset for help on using the changeset viewer.