Ignore:
Timestamp:
Jul 13, 2015, 12:15:19 PM (4 years ago)
Author:
cameron
Message:

Prepare for non-bitblock carry summaries; use IDISA bitblock_any

Location:
icGREP/icgrep-devel/icgrep/pablo
Files:
4 edited

Legend:

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

    r4659 r4663  
    9090   
    9191#if (BLOCK_SIZE == 128) && !defined(USE_LONG_INTEGER_SHIFT)
    92     Value * ahead64 = iBuilder.mvmd_dslli(64, carry_in, strm, 1);
    93     result_value = mBuilder->CreateOr(iBuilder.simd_srli(64, ahead64, 63), iBuilder.simd_slli(64, strm, 1));
     92    Value * ahead64 = iBuilder->mvmd_dslli(64, carry_in, strm, 1);
     93    result_value = mBuilder->CreateOr(iBuilder->simd_srli(64, ahead64, 63), iBuilder->simd_slli(64, strm, 1));
    9494#else
    9595    Value* advanceq_longint = mBuilder->CreateBitCast(carry_in, mBuilder->getIntNTy(BLOCK_SIZE));
  • icGREP/icgrep-devel/icgrep/pablo/carry_manager.h

    r4659 r4663  
    3131public:
    3232 
    33     CarryManager(Module * m, IRBuilder <> * b, VectorType * bitBlockType, ConstantAggregateZero * zero, Constant * one)
    34     : mMod(m)
    35     , mBuilder(b)
     33    CarryManager(IRBuilder <> * b, VectorType * bitBlockType, ConstantAggregateZero * zero, Constant * one, IDISA::IDISA_Builder * idb)
     34    : mBuilder(b)
    3635    , mBitBlockType(bitBlockType)
    3736    , mZeroInitializer(zero)
    3837    , mOneInitializer(one)
    39     , iBuilder(mMod, mBuilder, mBitBlockType) {
     38    , iBuilder(idb) {
    4039
    4140    }
     
    8584   
    8685private:
    87     Module * mMod;
    8886    IRBuilder <> * mBuilder;
    8987    VectorType * mBitBlockType;
    9088    ConstantAggregateZero * mZeroInitializer;
    9189    Constant * mOneInitializer;
    92     IDISA::IDISA_Builder iBuilder;
     90    IDISA::IDISA_Builder * iBuilder;
    9391    PabloBlock * mPabloRoot;
    9492    Value * mCarryDataPtr;
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp

    r4661 r4663  
    1616#include <include/simd-lib/bitblock.hpp>
    1717#include <sstream>
     18#include <IDISA/idisa_builder.h>
    1819#include <llvm/IR/Verifier.h>
    1920#include <llvm/Pass.h>
     
    7576, mCarryManager(nullptr)
    7677, mBitBlockType(VectorType::get(IntegerType::get(mMod->getContext(), 64), BLOCK_SIZE / 64))
     78, iBuilder(mMod, mBuilder, mBitBlockType)
    7779, mInputPtr(nullptr)
    7880, mCarryDataPtr(nullptr)
     
    113115    mIfDepth = 0;
    114116    mMaxWhileDepth = 0;
    115     mCarryManager = new CarryManager(mMod, mBuilder, mBitBlockType, mZeroInitializer, mOneInitializer);
     117    mCarryManager = new CarryManager(mBuilder, mBitBlockType, mZeroInitializer, mOneInitializer, &iBuilder);
    116118
    117119    Examine(function.getEntryBlock());
     
    368370}
    369371
     372Value * PabloCompiler::genBitTest2(Value * e1, Value * e2) {
     373    Type * t1 = e1->getType();
     374    Type * t2 = e2->getType();
     375    if (t1 == mBitBlockType) {
     376        if (t2 == mBitBlockType) {
     377            return iBuilder.bitblock_any(mBuilder->CreateOr(e1, e2));
     378        }
     379        else {
     380            Value * m1 = mBuilder->CreateZExt(iBuilder.hsimd_signmask(16, e1), t2);
     381            return mBuilder->CreateICmpNE(mBuilder->CreateOr(m1, e2), ConstantInt::get(t2, 0));
     382        }
     383    }
     384    else if (t2 == mBitBlockType) {
     385        Value * m2 = mBuilder->CreateZExt(iBuilder.hsimd_signmask(16, e2), t1);
     386        return mBuilder->CreateICmpNE(mBuilder->CreateOr(e1, m2), ConstantInt::get(t1, 0));
     387    }
     388    else {
     389        return mBuilder->CreateICmpNE(mBuilder->CreateOr(e1, e2), ConstantInt::get(t1, 0));
     390    }
     391}
    370392
    371393void PabloCompiler::compileIf(const If * ifStatement) {       
     
    393415    PabloBlock & ifBody = ifStatement -> getBody();
    394416   
    395     Value* if_test_value = compileExpression(ifStatement->getCondition());
     417    Value * if_test_value = compileExpression(ifStatement->getCondition());
    396418    if (mCarryManager->blockHasCarries(ifBody)) {
    397419        // load the summary variable
    398420        Value* last_if_pending_data = mCarryManager->getCarrySummaryExpr(ifBody);
    399         if_test_value = mBuilder->CreateOr(if_test_value, last_if_pending_data);
    400     }
    401     mBuilder->CreateCondBr(genBitBlockAny(if_test_value), ifEndBlock, ifBodyBlock);
     421        mBuilder->CreateCondBr(genBitTest2(if_test_value, last_if_pending_data), ifBodyBlock, ifEndBlock);
     422
     423    }
     424    else {
     425        mBuilder->CreateCondBr(iBuilder.bitblock_any(if_test_value), ifBodyBlock, ifEndBlock);
     426    }
    402427    // Entry processing is complete, now handle the body of the if.
    403428    mBuilder->SetInsertPoint(ifBodyBlock);
     
    478503
    479504    // Terminate the while loop body with a conditional branch back.
    480     mBuilder->CreateCondBr(genBitBlockAny(compileExpression(whileStatement->getCondition())), whileEndBlock, whileBodyBlock);
     505    mBuilder->CreateCondBr(iBuilder.bitblock_any(compileExpression(whileStatement->getCondition())), whileBodyBlock, whileEndBlock);
    481506
    482507    // and for any Next nodes in the loop body
     
    710735}
    711736
    712 inline Value* PabloCompiler::genBitBlockAny(Value* test) {
    713     Value* cast_marker_value_1 = mBuilder->CreateBitCast(test, mBuilder->getIntNTy(BLOCK_SIZE));
    714     return mBuilder->CreateICmpEQ(cast_marker_value_1, ConstantInt::get(mBuilder->getIntNTy(BLOCK_SIZE), 0));
    715 }
    716 
    717737Value * PabloCompiler::genShiftHighbitToLow(unsigned FieldWidth, Value * op) {
    718738    unsigned FieldCount = BLOCK_SIZE/FieldWidth;
  • icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.h

    r4661 r4663  
    2828#include <llvm/ADT/Twine.h>
    2929#include <llvm/IR/IRBuilder.h>
     30#include <IDISA/idisa_builder.h>
    3031
    3132namespace llvm {
     
    121122    void compileBlock(PabloBlock & block);
    122123    void compileStatement(const Statement * stmt);
     124    Value * genBitTest2(Value * e1, Value * e2);
    123125    void compileIf(const If * ifStmt);
    124126    void compileWhile(const While * whileStmt);
     
    128130    Value* genShortAdvanceWithCarry(Value* e1, unsigned localIndex, int shift_amount);
    129131    Value* genLongAdvanceWithCarry(Value* e1, unsigned localIndex, int shift_amount);
    130     Value* genBitBlockAny(Value* test);
    131132    Value* genShiftHighbitToLow(unsigned FieldWidth, Value * op);
    132133    Value* genShiftLeft64(Value* e, const Twine & namehint = "") ;
     
    155156#endif
    156157    IRBuilder <> *                      mBuilder;
     158
    157159    CarryManager *                      mCarryManager;
    158160
    159161    VectorType* const                   mBitBlockType;
     162    IDISA::IDISA_Builder                iBuilder;
    160163    PointerType*                        mInputPtr;
    161164
Note: See TracChangeset for help on using the changeset viewer.