Ignore:
Timestamp:
Oct 25, 2014, 4:41:50 PM (5 years ago)
Author:
nmedfort
Message:

Minor changes.

File:
1 edited

Legend:

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

    r4268 r4270  
    7474namespace pablo {
    7575
    76 PabloCompiler::PabloCompiler(const BasisBitVars & basisBitVars, int bits)
    77 : mBits(bits)
    78 , mBasisBitVars(basisBitVars)
     76PabloCompiler::PabloCompiler(const std::vector<Var*> & basisBits)
     77: mBasisBits(basisBits)
    7978, mMod(new Module("icgrep", getGlobalContext()))
    8079, mBasicBlock(nullptr)
    8180, mExecutionEngine(nullptr)
    82 , mXi64Vect(VectorType::get(IntegerType::get(mMod->getContext(), 64), BLOCK_SIZE / 64))
    83 , mXi128Vect(VectorType::get(IntegerType::get(mMod->getContext(), 128), BLOCK_SIZE / 128))
     81, mBitBlockType(VectorType::get(IntegerType::get(mMod->getContext(), 64), BLOCK_SIZE / 64))
    8482, mBasisBitsInputPtr(nullptr)
    8583, mCarryQueueIdx(0)
     
    8785, mNestingDepth(0)
    8886, mCarryQueueSize(0)
    89 , mZeroInitializer(ConstantAggregateZero::get(mXi64Vect))
    90 , mOneInitializer(ConstantVector::getAllOnesValue(mXi64Vect))
     87, mZeroInitializer(ConstantAggregateZero::get(mBitBlockType))
     88, mOneInitializer(ConstantVector::getAllOnesValue(mBitBlockType))
    9189, mFunctionType(nullptr)
    9290, mFunc_process_block(nullptr)
     
    165163
    166164    //The basis bits structure
    167     for (unsigned i = 0; i < mBits; ++i) {
     165    for (unsigned i = 0; i != mBasisBits.size(); ++i) {
    168166        IRBuilder<> b(mBasicBlock);
    169167        Value* indices[] = {b.getInt64(0), b.getInt32(i)};
    170         const String * const name = mBasisBitVars[i]->getName();
     168        const String * const name = mBasisBits[i]->getName();
    171169        Value * gep = b.CreateGEP(mBasisBitsAddr, indices);
    172170        LoadInst * basisBit = b.CreateAlignedLoad(gep, BLOCK_SIZE/8, false, name->str());
     
    239237    }
    240238    std::vector<Type*>StructTy_struct_Basis_bits_fields;
    241     for (int i = 0; i < mBits; i++)
    242     {
    243         StructTy_struct_Basis_bits_fields.push_back(mXi64Vect);
     239    for (int i = 0; i != mBasisBits.size(); i++)
     240    {
     241        StructTy_struct_Basis_bits_fields.push_back(mBitBlockType);
    244242    }
    245243    if (structBasisBits->isOpaque()) {
     
    253251    //The carry q array.
    254252    //A pointer to the BitBlock vector.
    255     functionTypeArgs.push_back(PointerType::get(mXi64Vect, 0));
     253    functionTypeArgs.push_back(PointerType::get(mBitBlockType, 0));
    256254
    257255    //The output structure.
     
    262260    if (outputStruct->isOpaque()) {
    263261        std::vector<Type*>fields;
    264         fields.push_back(mXi64Vect);
    265         fields.push_back(mXi64Vect);
     262        fields.push_back(mBitBlockType);
     263        fields.push_back(mBitBlockType);
    266264        outputStruct->setBody(fields, /*isPacked=*/false);
    267265    }
     
    434432            throw std::runtime_error("Unknown unicode category \"" + callee->str() + "\"");
    435433            #undef CHECK_GENERAL_CODE_CATEGORY
    436             Value * unicodeCategory = mMod->getOrInsertFunction("__get_category_" + callee->str(), mXi64Vect, mBasisBitsInputPtr, NULL);
     434            Value * unicodeCategory = mMod->getOrInsertFunction("__get_category_" + callee->str(), mBitBlockType, mBasisBitsInputPtr, NULL);
    437435            if (unicodeCategory == nullptr) {
    438436                throw std::runtime_error("Could not create static method call for unicode category \"" + callee->str() + "\"");
     
    601599        unsigned index = 0;
    602600        for (index = 0; index != whileStatement->getInclusiveCarryCount(); ++index) {
    603             PHINode * phi = bCond.CreatePHI(mXi64Vect, 2);
     601            PHINode * phi = bCond.CreatePHI(mBitBlockType, 2);
    604602            phi->addIncoming(mCarryQueueVector[baseCarryQueueIdx + index], mBasicBlock);
    605603            mCarryQueueVector[baseCarryQueueIdx + index] = mZeroInitializer; // (use phi for multi-carry mode.)
     
    608606        // and for any Next nodes in the loop body
    609607        for (Next * n : nextNodes) {
    610             PHINode * phi = bCond.CreatePHI(mXi64Vect, 2, n->getName()->str());
     608            PHINode * phi = bCond.CreatePHI(mBitBlockType, 2, n->getName()->str());
    611609            auto f = mMarkerMap.find(n->getName());
    612610            assert (f != mMarkerMap.end());
     
    675673    }
    676674    else if (const Var * var = dyn_cast<Var>(expr))
    677     {       
     675    {
    678676        auto f = mMarkerMap.find(var->getName());
    679677        assert (f != mMarkerMap.end());
     
    702700    {
    703701        Value* strm_value = compileExpression(adv->getExpr());
    704                 int shift = adv->getAdvanceAmount();
     702        int shift = adv->getAdvanceAmount();
    705703        retVal = genAdvanceWithCarry(strm_value, shift);
    706704    }
     
    813811    IRBuilder<> b(mBasicBlock);
    814812    Value* i128_val = b.CreateBitCast(e, IntegerType::get(mMod->getContext(), BLOCK_SIZE));
    815     return b.CreateBitCast(b.CreateLShr(i128_val, BLOCK_SIZE - 1, namehint), mXi64Vect);
     813    return b.CreateBitCast(b.CreateLShr(i128_val, BLOCK_SIZE - 1, namehint), mBitBlockType);
    816814}
    817815
     
    819817    IRBuilder<> b(mBasicBlock);
    820818    Value* i128_val = b.CreateBitCast(e, IntegerType::get(mMod->getContext(), BLOCK_SIZE));
    821     return b.CreateBitCast(b.CreateShl(i128_val, 64, namehint), mXi64Vect);
     819    return b.CreateBitCast(b.CreateShl(i128_val, 64, namehint), mBitBlockType);
    822820}
    823821
     
    858856        Value* strm_longint = b.CreateBitCast(strm_value, IntegerType::get(mMod->getContext(), BLOCK_SIZE));
    859857        Value* adv_longint = b.CreateOr(b.CreateShl(strm_longint, shift_amount), carryq_longint, "advance");
    860         Value* result_value = b.CreateBitCast(adv_longint, mXi64Vect);
    861         Value* carry_out = b.CreateBitCast(b.CreateLShr(strm_longint, BLOCK_SIZE - shift_amount, "advance_out"), mXi64Vect);
     858    Value* result_value = b.CreateBitCast(adv_longint, mBitBlockType);
     859    Value* carry_out = b.CreateBitCast(b.CreateLShr(strm_longint, BLOCK_SIZE - shift_amount, "advance_out"), mBitBlockType);
    862860        //CarryQ - carry out:
    863861        genCarryOutStore(carry_out, carryIdx);
Note: See TracChangeset for help on using the changeset viewer.