Ignore:
Timestamp:
Dec 14, 2015, 2:01:49 PM (4 years ago)
Author:
cameron
Message:

Move AVX2 specific IDISA function implementations into subclassed builder

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

Legend:

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

    r4891 r4892  
    148148}
    149149
    150 Value * IDISA_Builder:: esimd_bitspread(unsigned fw, Value * bitmask) {
     150Value * IDISA_Builder::esimd_bitspread(unsigned fw, Value * bitmask) {
    151151    unsigned field_count = mBitBlockWidth/fw;
    152152    Type * field_type = mLLVMBuilder->getIntNTy(fw);
     
    193193}
    194194
    195 #if (BLOCK_SIZE==256)
    196 #define SIGNMASK_AVX2
    197 #endif
    198 
    199195Value * IDISA_Builder::hsimd_signmask(unsigned fw, Value * a) {
    200 #ifdef SIGNMASK_AVX2
    201     if (fw == 64) {
    202         Value * signmask_f64func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_avx_movmsk_pd_256);
    203         Type * bitBlock_f64type = VectorType::get(mLLVMBuilder->getDoubleTy(), mBitBlockWidth/64);
    204         Value * a_as_pd = mLLVMBuilder->CreateBitCast(a, bitBlock_f64type);
    205         Value * mask = mLLVMBuilder->CreateCall(signmask_f64func, std::vector<Value *>({a_as_pd}));
    206         return mask;
    207     }
    208     else if (fw == 32) {
    209         Value * signmask_f32func = Intrinsic::getDeclaration(mMod, Intrinsic::x86_avx_movmsk_ps_256);
    210         Type * bitBlock_f32type = VectorType::get(mLLVMBuilder->getFloatTy(), mBitBlockWidth/32);
    211         Value * a_as_ps = mLLVMBuilder->CreateBitCast(a, bitBlock_f32type);
    212         Value * mask = mLLVMBuilder->CreateCall(signmask_f32func, std::vector<Value *>({a_as_ps}));
    213         return mask;
    214     }
    215 #endif
    216196    Value * mask = mLLVMBuilder->CreateICmpSLT(fwCast(fw, a), ConstantAggregateZero::get(fwVectorType(fw)));
    217     return mLLVMBuilder->CreateBitCast(mask, mLLVMBuilder->getIntNTy(mBitBlockWidth/fw));
     197    return mLLVMBuilder->CreateZExt(mLLVMBuilder->CreateBitCast(mask, mLLVMBuilder->getIntNTy(mBitBlockWidth/fw)), mLLVMBuilder->getInt32Ty());
    218198}
    219199
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.h

    r4891 r4892  
    3030
    3131    }
     32    virtual ~IDISA_Builder() {};
    3233
    3334    void initialize(Module * m, IRBuilder <> * b) {
     
    4647    Constant * allOnes() {return mOneInitializer;}
    4748       
    48     Value * simd_add(unsigned fw, Value * a, Value * b);
    49     Value * simd_sub(unsigned fw, Value * a, Value * b);
    50     Value * simd_mult(unsigned fw, Value * a, Value * b);
    51     Value * simd_eq(unsigned fw, Value * a, Value * b);
    52     Value * simd_gt(unsigned fw, Value * a, Value * b);
    53     Value * simd_ugt(unsigned fw, Value * a, Value * b);
    54     Value * simd_lt(unsigned fw, Value * a, Value * b);
    55     Value * simd_ult(unsigned fw, Value * a, Value * b);
    56     Value * simd_max(unsigned fw, Value * a, Value * b);
    57     Value * simd_umax(unsigned fw, Value * a, Value * b);
    58     Value * simd_min(unsigned fw, Value * a, Value * b);
    59     Value * simd_umin(unsigned fw, Value * a, Value * b);
     49    virtual Value * simd_add(unsigned fw, Value * a, Value * b);
     50    virtual Value * simd_sub(unsigned fw, Value * a, Value * b);
     51    virtual Value * simd_mult(unsigned fw, Value * a, Value * b);
     52    virtual Value * simd_eq(unsigned fw, Value * a, Value * b);
     53    virtual Value * simd_gt(unsigned fw, Value * a, Value * b);
     54    virtual Value * simd_ugt(unsigned fw, Value * a, Value * b);
     55    virtual Value * simd_lt(unsigned fw, Value * a, Value * b);
     56    virtual Value * simd_ult(unsigned fw, Value * a, Value * b);
     57    virtual Value * simd_max(unsigned fw, Value * a, Value * b);
     58    virtual Value * simd_umax(unsigned fw, Value * a, Value * b);
     59    virtual Value * simd_min(unsigned fw, Value * a, Value * b);
     60    virtual Value * simd_umin(unsigned fw, Value * a, Value * b);
     61    virtual Value * simd_if(unsigned fw, Value * cond, Value * a, Value * b);
    6062    Value * simd_if(unsigned fw, Value * cond, Value * a, Value * b);
    6163   
    62     Value * simd_slli(unsigned fw, Value * a, unsigned shift);
    63     Value * simd_srli(unsigned fw, Value * a, unsigned shift);
    64     Value * simd_srai(unsigned fw, Value * a, unsigned shift);
     64    virtual Value * simd_slli(unsigned fw, Value * a, unsigned shift);
     65    virtual Value * simd_srli(unsigned fw, Value * a, unsigned shift);
     66    virtual Value * simd_srai(unsigned fw, Value * a, unsigned shift);
    6567   
    66     Value * simd_cttz(unsigned fw, Value * a);
    67     Value * simd_popcount(unsigned fw, Value * a);
     68    virtual Value * simd_cttz(unsigned fw, Value * a);
     69    virtual Value * simd_popcount(unsigned fw, Value * a);
    6870   
    69     Value * esimd_mergeh(unsigned fw, Value * a, Value * b);
    70     Value * esimd_mergel(unsigned fw, Value * a, Value * b);
    71     Value * esimd_bitspread(unsigned fw, Value * bitmask);
     71    virtual Value * esimd_mergeh(unsigned fw, Value * a, Value * b);
     72    virtual Value * esimd_mergel(unsigned fw, Value * a, Value * b);
     73    virtual Value * esimd_bitspread(unsigned fw, Value * bitmask);
    7274   
    73     Value * hsimd_packh(unsigned fw, Value * a, Value * b);
    74     Value * hsimd_packl(unsigned fw, Value * a, Value * b);
    75     Value * hsimd_signmask(unsigned fw, Value * a);
     75    virtual Value * hsimd_packh(unsigned fw, Value * a, Value * b);
     76    virtual Value * hsimd_packl(unsigned fw, Value * a, Value * b);
     77    virtual Value * hsimd_signmask(unsigned fw, Value * a);
    7678
    7779   
    78     Value * mvmd_extract(unsigned fw, Value * a, unsigned fieldIndex);
    79     Value * mvmd_insert(unsigned fw, Value * blk, Value * elt, unsigned fieldIndex);
    80     Value * mvmd_dslli(unsigned fw, Value * a, Value * b, unsigned shift);
     80    virtual Value * mvmd_extract(unsigned fw, Value * a, unsigned fieldIndex);
     81    virtual Value * mvmd_insert(unsigned fw, Value * blk, Value * elt, unsigned fieldIndex);
     82    virtual Value * mvmd_dslli(unsigned fw, Value * a, Value * b, unsigned shift);
    8183   
    82     Value * bitblock_any(Value * a);
     84    virtual Value * bitblock_any(Value * a);
    8385    Value * simd_and(Value * a, Value * b);
    8486    Value * simd_or(Value * a, Value * b);
     
    8789    Value * fwCast(unsigned fw, Value * a);
    8890   
    89 private:
     91protected:
    9092    Module * mMod;
    9193    IRBuilder <> * mLLVMBuilder;
Note: See TracChangeset for help on using the changeset viewer.