Changeset 5114


Ignore:
Timestamp:
Aug 4, 2016, 10:19:36 PM (3 years ago)
Author:
cameron
Message:

bitblock_add, bitblock_advance

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

Legend:

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

    r5106 r5114  
    366366}
    367367
     368// full add producing {carryout, sum}
     369std::pair<Value *, Value *> IDISA_Builder::bitblock_add(Value * a, Value * b, Value * carryin) {
     370    Value * carrygen = simd_and(a, b);
     371    Value * carryprop = simd_or(a, b);
     372    Value * sum = simd_add(mBitBlockWidth, simd_add(mBitBlockWidth, a, b), carryin);
     373    Value * carryout = CreateBitCast(simd_or(carrygen, simd_and(carryprop, CreateNot(sum))), getIntNTy(mBitBlockWidth));
     374    return std::pair<Value *, Value *>(bitCast(simd_srli(mBitBlockWidth, carryout, mBitBlockWidth - 1)), bitCast(sum));
     375}
     376
     377// full shift producing {shiftout, shifted}
     378std::pair<Value *, Value *> IDISA_Builder::bitblock_advance(Value * a, Value * shiftin, unsigned shift) {
     379    Value * shiftin_bitblock = CreateBitCast(shiftin, getIntNTy(mBitBlockWidth));
     380    Value * a_bitblock = CreateBitCast(a, getIntNTy(mBitBlockWidth));
     381    Value * shifted = bitCast(CreateOr(CreateShl(a_bitblock, shift), shiftin_bitblock));
     382    Value * shiftout = bitCast(CreateLShr(a_bitblock, mBitBlockWidth - shift));
     383    return std::pair<Value *, Value *>(shiftout, shifted);
     384}
     385
    368386Value * IDISA_Builder::simd_and(Value * a, Value * b) {
    369387    return a->getType() == b->getType() ? CreateAnd(a, b) : CreateAnd(bitCast(a), bitCast(b));
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.h

    r5106 r5114  
    118118    virtual Value * mvmd_dslli(unsigned fw, Value * a, Value * b, unsigned shift);
    119119   
     120   
    120121    virtual Value * bitblock_any(Value * a);
     122    // full add producing {carryout, sum}
     123    virtual std::pair<Value *, Value *> bitblock_add(Value * a, Value * b, Value * carryin);
     124    // full shift producing {shiftout, shifted}
     125    virtual std::pair<Value *, Value *> bitblock_advance(Value * a, Value * shiftin, unsigned shift);
     126   
     127   
    121128    Value * simd_and(Value * a, Value * b);
    122129    Value * simd_or(Value * a, Value * b);
Note: See TracChangeset for help on using the changeset viewer.