Changeset 5709 for icGREP


Ignore:
Timestamp:
Oct 26, 2017, 8:31:35 AM (16 months ago)
Author:
cameron
Message:

createIndexedAdvance

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

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/builder.cpp

    r5329 r5709  
    133133}
    134134
     135PabloAST * PabloBuilder::createIndexedAdvance(PabloAST * expr, PabloAST * indexStream, PabloAST * shiftAmount) {
     136    if (isa<Zeroes>(expr) || cast<Integer>(shiftAmount)->value() == 0) {
     137        return expr;
     138    }
     139    else if (isa<Ones>(expr)) {
     140        return createAdvance(expr, shiftAmount);
     141    }
     142    else if (cast<Integer>(shiftAmount)->value() == 1) {
     143        return createAdvanceThenScanTo(expr, indexStream);
     144    }
     145    MAKE_TERNARY(createIndexedAdvance, TypeId::IndexedAdvance, expr, indexStream, shiftAmount);
     146    return result;
     147}
     148
     149PabloAST * PabloBuilder::createIndexedAdvance(PabloAST * expr, PabloAST * indexStream, PabloAST * shiftAmount, const llvm::StringRef & prefix) {
     150    if (isa<Zeroes>(expr) || cast<Integer>(shiftAmount)->value() == 0) {
     151        return expr;
     152    }
     153    else if (isa<Ones>(expr)) {
     154        return createAdvance(expr, shiftAmount, prefix);
     155    }
     156    else if (cast<Integer>(shiftAmount)->value() == 1) {
     157        return createAdvanceThenScanTo(expr, indexStream, prefix);
     158    }
     159    MAKE_NAMED_TERNARY(createIndexedAdvance, TypeId::IndexedAdvance, prefix, expr, indexStream, shiftAmount);
     160    return result;
     161}
     162   
    135163Extract * PabloBuilder::createExtract(PabloAST * value, not_null<PabloAST *> index) {
    136164    MAKE_BINARY(createExtract, TypeId::Extract, value, index);
  • icGREP/icgrep-devel/icgrep/pablo/builder.hpp

    r5440 r5709  
    104104    PabloAST * createAdvance(PabloAST * expr, PabloAST * shiftAmount, const llvm::StringRef & prefix);
    105105
     106    inline PabloAST * createIndexedAdvance(PabloAST * expr, PabloAST * indexStream, const int64_t shiftAmount) {
     107        return createIndexedAdvance(expr, indexStream, mPb->getInteger(shiftAmount));
     108    }
     109   
     110    PabloAST * createIndexedAdvance(PabloAST * expr, PabloAST * indexStream, PabloAST * shiftAmount);
     111   
     112    inline PabloAST * createIndexedAdvance(PabloAST * expr, PabloAST * indexStream, const int64_t shiftAmount, const llvm::StringRef & prefix) {
     113        return createIndexedAdvance(expr, indexStream, mPb->getInteger(shiftAmount), prefix);
     114    }
     115   
     116    PabloAST * createIndexedAdvance(PabloAST * expr, PabloAST * indexStream, PabloAST * shiftAmount, const llvm::StringRef & prefix);
     117   
    106118    inline PabloAST * createLookahead(PabloAST * expr, const int64_t shiftAmount) {
    107119        if (shiftAmount == 0) {
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.cpp

    r5446 r5709  
    302302}
    303303
    304 /// TERNARY CREATE FUNCTION
     304/// TERNARY CREATE FUNCTIONS
    305305
    306306Sel * PabloBlock::createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr, String * name) {
     
    311311    return insertAtInsertionPoint(new (mAllocator) Sel(condition, trueExpr, falseExpr, name, mAllocator));
    312312}
     313
     314IndexedAdvance * PabloBlock::createIndexedAdvance(PabloAST * expr, PabloAST * indexStream, PabloAST * shiftAmount, String * name) {
     315    if (name == nullptr) {
     316        name = makeName("indexed_advance");
     317    }
     318    return insertAtInsertionPoint(new (mAllocator) IndexedAdvance(expr, indexStream, shiftAmount, name, mAllocator));
     319}
     320   
    313321
    314322/** ------------------------------------------------------------------------------------------------------------- *
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.h

    r5436 r5709  
    1515namespace pablo { class Add; }
    1616namespace pablo { class Advance; }
     17namespace pablo { class IndexedAdvance; }
    1718namespace pablo { class AdvanceThenScanThru; }
    1819namespace pablo { class AdvanceThenScanTo; }
     
    7071        return createAdvance(expr, shiftAmount, nullptr);
    7172    }
    72 
     73   
    7374    Advance * createAdvance(PabloAST * expr, PabloAST * shiftAmount, const llvm::StringRef & prefix) {
    7475        return createAdvance(expr, shiftAmount, makeName(prefix));
    7576    }
    76 
     77   
    7778    Advance * createAdvance(PabloAST * expr, PabloAST * shiftAmount, String * name);
    78 
     79   
     80    IndexedAdvance * createIndexedAdvance(PabloAST * expr, PabloAST * indexStream, PabloAST * shiftAmount) {
     81        return createIndexedAdvance(expr, indexStream, shiftAmount, nullptr);
     82    }
     83   
     84    IndexedAdvance * createIndexedAdvance(PabloAST * expr, PabloAST * indexStream, PabloAST * shiftAmount, const llvm::StringRef & prefix) {
     85        return createIndexedAdvance(expr, indexStream, shiftAmount, makeName(prefix));
     86    }
     87   
     88    IndexedAdvance * createIndexedAdvance(PabloAST * expr, PabloAST * indexStream, PabloAST * shiftAmount, String * name);
     89   
    7990    Lookahead * createLookahead(PabloAST * expr, PabloAST * shiftAmount) {
    8091        return createLookahead(expr, shiftAmount, nullptr);
Note: See TracChangeset for help on using the changeset viewer.