Ignore:
Timestamp:
Jan 16, 2018, 4:22:13 PM (18 months ago)
Author:
nmedfort
Message:

Added PabloBlock/Builder? createScope() methods + minor code changes.

File:
1 edited

Legend:

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

    r5834 r5836  
    4949///
    5050
    51 Count * PabloBlock::createCount(PabloAST * const expr) {
     51Count * PabloBlock::createCount(PabloAST * const expr, const String * const name) {
    5252    IntegerType * const type = getParent()->getSizeTy();
    53     return insertAtInsertionPoint(new (mAllocator) Count(expr, makeName("count"), type, mAllocator));
    54 }
    55 
    56 Count * PabloBlock::createCount(PabloAST * const expr, const llvm::StringRef & prefix)  {
    57     IntegerType * const type = getParent()->getSizeTy();
    58     return insertAtInsertionPoint(new (mAllocator) Count(expr, makeName(prefix), type, mAllocator));
    59 }
    60 
    61 Not * PabloBlock::createNot(PabloAST * expr, String * name) {
     53    return insertAtInsertionPoint(new (mAllocator) Count(expr, name, type, mAllocator));
     54}
     55
     56Not * PabloBlock::createNot(PabloAST * expr, const String * const name) {
    6257    assert (expr);
    6358    return insertAtInsertionPoint(new (mAllocator) Not(expr, name, mAllocator));
    6459}
    6560
    66 Var * PabloBlock::createVar(String * name, Type * type) {
     61Var * PabloBlock::createVar(const String * const name, Type * type) {
    6762    if (type == nullptr) {
    6863        type = getParent()->getStreamTy();
     
    7166        throw std::runtime_error("Var objects must have a String name");
    7267    }
    73     return mParent->makeVariable(cast<String>(name), type);
    74 }
    75 
    76 InFile * PabloBlock::createInFile(PabloAST * expr, String * name) {
     68    return mParent->makeVariable(name, type);
     69}
     70
     71InFile * PabloBlock::createInFile(PabloAST * expr, const String * const name) {
    7772    assert (expr);
    7873    return insertAtInsertionPoint(new (mAllocator) InFile(expr, name, mAllocator));
    7974}
    8075
    81 AtEOF * PabloBlock::createAtEOF(PabloAST * expr, String * name) {
     76AtEOF * PabloBlock::createAtEOF(PabloAST * expr, const String * const name) {
    8277    assert (expr);
    8378    return insertAtInsertionPoint(new (mAllocator) AtEOF(expr, name, mAllocator));
     
    8681/// BINARY CREATE FUNCTIONS
    8782
    88 Advance * PabloBlock::createAdvance(PabloAST * expr, Integer * shiftAmount, String * name) {
     83Advance * PabloBlock::createAdvance(PabloAST * expr, Integer * shiftAmount, const String * const name) {
    8984    return insertAtInsertionPoint(new (mAllocator) Advance(expr, shiftAmount, name, mAllocator));
    9085}
    9186
    92 Lookahead * PabloBlock::createLookahead(PabloAST * expr, Integer * shiftAmount, String * name) {
     87Lookahead * PabloBlock::createLookahead(PabloAST * expr, Integer * shiftAmount, const String * const name) {
    9388    return insertAtInsertionPoint(new (mAllocator) Lookahead(expr, shiftAmount, name, mAllocator));
    9489}
     
    112107}
    113108
    114 And * PabloBlock::createAnd(PabloAST * expr1, PabloAST * expr2, String * name) {
     109And * PabloBlock::createAnd(PabloAST * expr1, PabloAST * expr2, const String * const name) {
    115110    CHECK_SAME_TYPE(expr1, expr2);
    116111    return insertAtInsertionPoint(new (mAllocator) And(expr1->getType(), expr1, expr2, name, mAllocator));
    117112}
    118113
    119 Or * PabloBlock::createOr(PabloAST * expr1, PabloAST * expr2, String * name) {
     114Or * PabloBlock::createOr(PabloAST * expr1, PabloAST * expr2, const String * const name) {
    120115    CHECK_SAME_TYPE(expr1, expr2);
    121116    return insertAtInsertionPoint(new (mAllocator) Or(expr1->getType(), expr1, expr2, name, mAllocator));
    122117}
    123118
    124 Xor * PabloBlock::createXor(PabloAST * expr1, PabloAST * expr2, String * name) {
     119Xor * PabloBlock::createXor(PabloAST * expr1, PabloAST * expr2, const String * const name) {
    125120    CHECK_SAME_TYPE(expr1, expr2);
    126121    return insertAtInsertionPoint(new (mAllocator) Xor(expr1->getType(), expr1, expr2, name, mAllocator));
     
    186181}
    187182
    188 MatchStar * PabloBlock::createMatchStar(PabloAST * marker, PabloAST * charclass, String * name) {
     183MatchStar * PabloBlock::createMatchStar(PabloAST * marker, PabloAST * charclass, const String * const name) {
    189184    CHECK_SAME_TYPE(marker, charclass);
    190185    return insertAtInsertionPoint(new (mAllocator) MatchStar(marker, charclass, name, mAllocator));
    191186}
    192187
    193 ScanThru * PabloBlock::createScanThru(PabloAST * from, PabloAST * thru, String * name) {
     188ScanThru * PabloBlock::createScanThru(PabloAST * from, PabloAST * thru, const String * const name) {
    194189    CHECK_SAME_TYPE(from, thru);
    195190    return insertAtInsertionPoint(new (mAllocator) ScanThru(from, thru, name, mAllocator));
    196191}
    197192
    198 ScanTo * PabloBlock::createScanTo(PabloAST * from, PabloAST * to, String * name) {
     193ScanTo * PabloBlock::createScanTo(PabloAST * from, PabloAST * to, const String * const name) {
    199194    CHECK_SAME_TYPE(from, to);
    200195    return insertAtInsertionPoint(new (mAllocator) ScanTo(from, to, name, mAllocator));
    201196}
    202197
    203 AdvanceThenScanThru * PabloBlock::createAdvanceThenScanThru(PabloAST * from, PabloAST * thru, String * name) {
     198AdvanceThenScanThru * PabloBlock::createAdvanceThenScanThru(PabloAST * from, PabloAST * thru, const String * const name) {
    204199    CHECK_SAME_TYPE(from, thru);
    205200    return insertAtInsertionPoint(new (mAllocator) AdvanceThenScanThru(from, thru, name, mAllocator));
    206201}
    207202
    208 AdvanceThenScanTo * PabloBlock::createAdvanceThenScanTo(PabloAST * from, PabloAST * to, String * name) {
     203AdvanceThenScanTo * PabloBlock::createAdvanceThenScanTo(PabloAST * from, PabloAST * to, const String * const name) {
    209204    CHECK_SAME_TYPE(from, to);
    210205    return insertAtInsertionPoint(new (mAllocator) AdvanceThenScanTo(from, to, name, mAllocator));
     
    225220}
    226221
    227 Repeat * PabloBlock::createRepeat(Integer * fieldWidth, PabloAST * value, String * name) {
     222Repeat * PabloBlock::createRepeat(Integer * fieldWidth, PabloAST * value, const String * const name) {
    228223    assert (fieldWidth && value);
    229224    Type * const type = VectorType::get(IntegerType::get(value->getType()->getContext(), fieldWidth->value()), 0);
     
    231226}
    232227
    233 PackH * PabloBlock::createPackH(Integer * fieldWidth, PabloAST * value, String * name) {
     228PackH * PabloBlock::createPackH(Integer * fieldWidth, PabloAST * value, const String * const name) {
    234229    assert (fieldWidth && value);
    235230    Type * const type = VectorType::get(IntegerType::get(value->getType()->getContext(), fieldWidth->value()), 0);
     
    237232}
    238233
    239 PackL * PabloBlock::createPackL(Integer * fieldWidth, PabloAST * value, String * name) {
     234PackL * PabloBlock::createPackL(Integer * fieldWidth, PabloAST * value, const String * const name) {
    240235    assert (fieldWidth && value);
    241236    Type * const type = VectorType::get(IntegerType::get(value->getType()->getContext(), fieldWidth->value()), 0);
     
    245240/// TERNARY CREATE FUNCTIONS
    246241
    247 Sel * PabloBlock::createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr, String * name) {
     242Sel * PabloBlock::createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr, const String * const name) {
    248243    CHECK_SAME_TYPE(trueExpr, falseExpr);
    249244    return insertAtInsertionPoint(new (mAllocator) Sel(condition, trueExpr, falseExpr, name, mAllocator));
    250245}
    251246
    252 IndexedAdvance * PabloBlock::createIndexedAdvance(PabloAST * expr, PabloAST * indexStream, Integer * shiftAmount, String * name) {
     247IndexedAdvance * PabloBlock::createIndexedAdvance(PabloAST * expr, PabloAST * indexStream, Integer * shiftAmount, const String * const name) {
    253248    return insertAtInsertionPoint(new (mAllocator) IndexedAdvance(expr, indexStream, shiftAmount, name, mAllocator));
    254249}
     
    256251
    257252/** ------------------------------------------------------------------------------------------------------------- *
    258  * @brief Create
    259  ** ------------------------------------------------------------------------------------------------------------- */
    260 PabloBlock * PabloBlock::Create(PabloKernel * const parent) noexcept {
    261     Allocator & allocator = parent->mAllocator;
    262     return new (allocator) PabloBlock(parent, allocator);
     253 * @brief createScope
     254 ** ------------------------------------------------------------------------------------------------------------- */
     255PabloBlock & PabloBlock::createScope() noexcept {
     256    return *new (mAllocator) PabloBlock(mParent, mAllocator);
    263257}
    264258
Note: See TracChangeset for help on using the changeset viewer.