Ignore:
Timestamp:
May 19, 2018, 1:48:24 PM (17 months ago)
Author:
cameron
Message:

IDISA testing

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

Legend:

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

    r6046 r6050  
    138138    if (fw < 8) report_fatal_error("Unsupported field width: ult " + std::to_string(fw));
    139139    return CreateSExt(CreateICmpULT(fwCast(fw, a), fwCast(fw, b)), fwVectorType(fw));
     140}
     141
     142Value * IDISA_Builder::simd_ule(unsigned fw, Value * a, Value * b) {
     143    if (fw < 8) report_fatal_error("Unsupported field width: ult " + std::to_string(fw));
     144    return CreateSExt(CreateICmpULE(fwCast(fw, a), fwCast(fw, b)), fwVectorType(fw));
     145}
     146
     147Value * IDISA_Builder::simd_uge(unsigned fw, Value * a, Value * b) {
     148    if (fw < 8) report_fatal_error("Unsupported field width: ult " + std::to_string(fw));
     149    return CreateSExt(CreateICmpUGE(fwCast(fw, a), fwCast(fw, b)), fwVectorType(fw));
    140150}
    141151
     
    375385   
    376386Value * IDISA_Builder::esimd_mergeh(unsigned fw, Value * a, Value * b) {   
    377     if (fw < 8) report_fatal_error("Unsupported field width: mergeh " + std::to_string(fw));
     387    if (fw == 4) {
     388        Value * abh = simd_or(simd_and(simd_himask(fw*2), a), simd_srli(32, simd_and(simd_himask(fw*2), b), fw));
     389        Value * abl = simd_or(simd_slli(32, simd_and(simd_lomask(fw*2), a), fw), simd_and(simd_lomask(fw*2), b));
     390        return esimd_mergeh(fw * 2, abh, abl);
     391    }
     392    if (fw < 4) report_fatal_error("Unsupported field width: mergeh " + std::to_string(fw));
    378393    const auto field_count = mBitBlockWidth / fw;
    379394    Constant * Idxs[field_count];
     
    385400}
    386401
    387 Value * IDISA_Builder::esimd_mergel(unsigned fw, Value * a, Value * b) {   
    388     if (fw < 8) report_fatal_error("Unsupported field width: mergel " + std::to_string(fw));
     402Value * IDISA_Builder::esimd_mergel(unsigned fw, Value * a, Value * b) {
     403    if (fw == 4) {
     404        Value * abh = simd_or(simd_and(simd_himask(fw*2), a), simd_srli(32, simd_and(simd_himask(fw*2), b), fw));
     405        Value * abl = simd_or(simd_slli(32, simd_and(simd_lomask(fw*2), a), fw), simd_and(simd_lomask(fw*2), b));
     406        return esimd_mergel(fw * 2, abh, abl);
     407    }
     408    if (fw < 4) report_fatal_error("Unsupported field width: mergel " + std::to_string(fw));
    389409    const auto field_count = mBitBlockWidth / fw;
    390410    Constant * Idxs[field_count];
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_builder.h

    r6045 r6050  
    111111    virtual llvm::Value * simd_lt(unsigned fw, llvm::Value * a, llvm::Value * b);
    112112    virtual llvm::Value * simd_ult(unsigned fw, llvm::Value * a, llvm::Value * b);
     113    virtual llvm::Value * simd_ule(unsigned fw, llvm::Value * a, llvm::Value * b);
     114    virtual llvm::Value * simd_uge(unsigned fw, llvm::Value * a, llvm::Value * b);
    113115    virtual llvm::Value * simd_max(unsigned fw, llvm::Value * a, llvm::Value * b);
    114116    virtual llvm::Value * simd_umax(unsigned fw, llvm::Value * a, llvm::Value * b);
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_sse_builder.cpp

    r6024 r6050  
    152152    return std::pair<Value *, Value *>(shiftout, shifted);
    153153}
     154   
     155Value * IDISA_SSE2_Builder::mvmd_shuffle(unsigned fw, Value * a, Value * shuffle_table) {
     156    if ((mBitBlockWidth == 128) && (fw == 64)) {
     157        // First create a vector with exchanged values of the 2 fields.
     158        Constant * idx[2] = {ConstantInt::get(getInt32Ty(), 1), ConstantInt::get(getInt32Ty(), 0)};
     159        Value * exchanged = CreateShuffleVector(a, UndefValue::get(fwVectorType(fw)), ConstantVector::get({idx, 2}));
     160        // bits that change if we the value in a needs to be exchanged.
     161        Value * changed = simd_xor(a, exchanged);
     162        // Now create a mask to select between original and exchanged values.
     163        Constant * xchg[2] = {ConstantInt::get(getInt64Ty(), 1), ConstantInt::get(getInt64Ty(), 0)};
     164        Value * exchange_mask = simd_eq(fw, shuffle_table, ConstantVector::get({xchg, 2}));
     165        Value * rslt = simd_xor(simd_and(changed, exchange_mask), a);
     166        return rslt;
     167    }
     168    return IDISA_Builder::mvmd_shuffle(fw, a, shuffle_table);
     169}
    154170
    155171Value * IDISA_SSE_Builder::mvmd_compress(unsigned fw, Value * a, Value * selector) {
  • icGREP/icgrep-devel/icgrep/IR_Gen/idisa_sse_builder.h

    r6024 r6050  
    4040    llvm::Value * hsimd_packl(unsigned fw, llvm::Value * a, llvm::Value * b) override;
    4141    std::pair<llvm::Value *, llvm::Value *> bitblock_advance(llvm::Value * a, llvm::Value * shiftin, unsigned shift) override;
     42    llvm::Value * mvmd_shuffle(unsigned fw, llvm::Value * a, llvm::Value * shuffle_table) override;
    4243    ~IDISA_SSE2_Builder() {}
    4344};
Note: See TracChangeset for help on using the changeset viewer.