Ignore:
Timestamp:
Jul 9, 2015, 6:08:35 PM (4 years ago)
Author:
cameron
Message:

packh, packl, signmask

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

Legend:

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

    r4652 r4653  
    107107    std::vector<Constant*> Idxs;
    108108    for (unsigned i = field_count/2; i < field_count; i++) {
    109         Idxs.push_back(llvm_builder->getInt32(i));    // selects elements 1, 3, ... from first reg.
    110         Idxs.push_back(llvm_builder->getInt32(i + field_count)); // selects elements 1, 3, ... from second reg.
     109        Idxs.push_back(llvm_builder->getInt32(i));    // selects elements from first reg.
     110        Idxs.push_back(llvm_builder->getInt32(i + field_count)); // selects elements from second reg.
    111111    }
    112112    return bitBlockCast(llvm_builder->CreateShuffleVector(aVec, bVec, ConstantVector::get(Idxs)));
     
    119119    std::vector<Constant*> Idxs;
    120120    for (unsigned i = 0; i < field_count/2; i++) {
    121         Idxs.push_back(llvm_builder->getInt32(i));    // selects elements 1, 3, ... from first reg.
    122         Idxs.push_back(llvm_builder->getInt32(i + field_count)); // selects elements 1, 3, ... from second reg.
     121        Idxs.push_back(llvm_builder->getInt32(i));    // selects elements from first reg.
     122        Idxs.push_back(llvm_builder->getInt32(i + field_count)); // selects elements from second reg.
    123123    }
    124124    return bitBlockCast(llvm_builder->CreateShuffleVector(aVec, bVec, ConstantVector::get(Idxs)));
    125125}
    126126
     127Value * IDISA_Builder::hsimd_packh(unsigned fw, Value * a, Value * b) {
     128    unsigned field_count = 2 * mBitBlockSize/fw;
     129    Value * aVec = fwCast(fw/2, a);
     130    Value * bVec = fwCast(fw/2, b);
     131    std::vector<Constant*> Idxs;
     132    for (unsigned i = 0; i < field_count; i++) {
     133        Idxs.push_back(llvm_builder->getInt32(2*i));
     134    }
     135    return bitBlockCast(llvm_builder->CreateShuffleVector(aVec, bVec, ConstantVector::get(Idxs)));
     136}
     137
     138Value * IDISA_Builder::hsimd_packl(unsigned fw, Value * a, Value * b) {
     139    unsigned field_count = 2 * mBitBlockSize/fw;
     140    Value * aVec = fwCast(fw/2, a);
     141    Value * bVec = fwCast(fw/2, b);
     142    std::vector<Constant*> Idxs;
     143    for (unsigned i = 0; i < field_count; i++) {
     144        Idxs.push_back(llvm_builder->getInt32(2*i+1));
     145    }
     146    return bitBlockCast(llvm_builder->CreateShuffleVector(aVec, bVec, ConstantVector::get(Idxs)));
     147}
     148
     149Value * IDISA_Builder::hsimd_signmask(unsigned fw, Value * a) {
     150    Value * mask = llvm_builder->CreateICmpSLT(fwCast(fw, a), ConstantAggregateZero::get(fwVectorType(fw)));
     151    return mask;
     152}
    127153
    128154
     155
  • icGREP/icgrep-devel/icgrep/IDISA/idisa_builder.h

    r4652 r4653  
    4444    Value * esimd_mergeh(unsigned fw, Value * a, Value * b);
    4545    Value * esimd_mergel(unsigned fw, Value * a, Value * b);
     46   
     47    Value * hsimd_packh(unsigned fw, Value * a, Value * b);
     48    Value * hsimd_packl(unsigned fw, Value * a, Value * b);
     49    Value * hsimd_signmask(unsigned fw, Value * a);
    4650
    4751private:
Note: See TracChangeset for help on using the changeset viewer.