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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.