Changeset 4879


Ignore:
Timestamp:
Nov 23, 2015, 10:01:01 AM (3 years ago)
Author:
cameron
Message:

Add esimd_bitspread

Location:
icGREP/icgrep-devel/icgrep/IDISA
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.cpp

    r4845 r4879  
    141141}
    142142
     143Value * IDISA_Builder:: esimd_bitspread(unsigned fw, Value * bitmask) {
     144    unsigned field_count = mBitBlockWidth/fw;
     145    Type * field_type = mLLVMBuilder->getIntNTy(fw);
     146    if (bitmask->getType()->getIntegerBitWidth() < fw) {
     147        bitmask = mLLVMBuilder->CreateZExt(bitmask, field_type);
     148    }
     149    else if (bitmask->getType()->getIntegerBitWidth() > fw) {
     150        bitmask = mLLVMBuilder->CreateTrunc(bitmask, field_type);
     151    }
     152    Value * spread_field = mLLVMBuilder->CreateBitCast(bitmask, VectorType::get(mLLVMBuilder->getIntNTy(fw), 1));
     153    Value * undefVec = UndefValue::get(VectorType::get(mLLVMBuilder->getIntNTy(fw), 1));
     154    Value * broadcast = mLLVMBuilder->CreateShuffleVector(spread_field, undefVec, Constant::getNullValue(VectorType::get(mLLVMBuilder->getInt32Ty(), field_count)));
     155    std::vector<Constant*> bitSel;
     156    std::vector<Constant*> bitShift;
     157    for (unsigned i = 0; i < field_count; i++) {
     158        bitSel.push_back(ConstantInt::get(field_type, 1 << i));
     159        bitShift.push_back(ConstantInt::get(field_type, i));
     160    }
     161    Value * bitSelVec = ConstantVector::get(bitSel);
     162    Value * bitShiftVec = ConstantVector::get(bitShift);
     163    return mLLVMBuilder->CreateLShr(mLLVMBuilder->CreateAnd(bitSelVec, broadcast), bitShiftVec);
     164}
     165
    143166Value * IDISA_Builder::hsimd_packh(unsigned fw, Value * a, Value * b) {
    144167    unsigned field_count = 2 * mBitBlockWidth/fw;
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.h

    r4845 r4879  
    6767    Value * esimd_mergeh(unsigned fw, Value * a, Value * b);
    6868    Value * esimd_mergel(unsigned fw, Value * a, Value * b);
     69    Value * esimd_bitspread(unsigned fw, Value * bitmask);
    6970   
    7071    Value * hsimd_packh(unsigned fw, Value * a, Value * b);
Note: See TracChangeset for help on using the changeset viewer.