Changeset 4650 for icGREP


Ignore:
Timestamp:
Jul 8, 2015, 2:59:03 PM (4 years ago)
Author:
nmedfort
Message:

Partial roll back of Trie structure. Seemed to introduce the potential of generating a cycle in the AST. More analysis is needed here before mixing together multiple Advance DAG traversals.

Location:
icGREP/icgrep-devel/icgrep
Files:
23 edited

Legend:

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

    r4643 r4650  
    1818}
    1919
     20void PabloBlock::insert(Statement * const statement) {
     21    assert (statement);
     22    if (LLVM_UNLIKELY(mInsertionPoint == nullptr)) {
     23        if (mFirst) {
     24            statement->insertBefore(mFirst);
     25        }
     26        else {
     27            statement->removeFromParent();
     28            statement->mParent = this;
     29            mFirst = mLast = statement;
     30        }
     31    }
     32    else {
     33        statement->insertAfter(mInsertionPoint);
     34        mLast = (mLast == mInsertionPoint) ? statement : mLast;
     35        assert (statement->mPrev == mInsertionPoint);
     36    }
     37    mInsertionPoint = statement;
     38}
     39
    2040/// UNARY CREATE FUNCTIONS
    2141
    2242Assign * PabloBlock::createAssign(const std::string && prefix, PabloAST * expr, const int outputIndex)  {
    23     return insertAtInsertionPoint(new Assign(expr, outputIndex, makeName(prefix, false), this));
     43    return insertAtInsertionPoint(new Assign(expr, outputIndex, makeName(prefix, false)));
    2444}
    2545
     
    2848        return expr;
    2949    }
    30     return insertAtInsertionPoint(new Advance(expr, shiftAmount, makeName("advance"), this));
     50    return insertAtInsertionPoint(new Advance(expr, shiftAmount, makeName("advance")));
    3151}
    3252
     
    3555        return expr;
    3656    }
    37     return insertAtInsertionPoint(new Advance(expr, shiftAmount, makeName(prefix, false), this));
     57    return insertAtInsertionPoint(new Advance(expr, shiftAmount, makeName(prefix, false)));
    3858}
    3959
     
    4262        return expr;
    4363    }
    44     return insertAtInsertionPoint(new Advance(expr, getInteger(shiftAmount), makeName("advance"), this));
     64    return insertAtInsertionPoint(new Advance(expr, getInteger(shiftAmount), makeName("advance")));
    4565}
    4666
     
    4969        return renameNonNamedNode(expr, std::move(prefix));
    5070    }   
    51     return insertAtInsertionPoint(new Advance(expr, getInteger(shiftAmount), makeName(prefix, false), this));
     71    return insertAtInsertionPoint(new Advance(expr, getInteger(shiftAmount), makeName(prefix, false)));
    5272}
    5373
    5474Call * PabloBlock::createCall(PabloAST * name) {
    5575    assert (name);
    56     return insertAtInsertionPoint(new Call(name, this));
     76    return insertAtInsertionPoint(new Call(name));
    5777}
    5878
     
    6888        return not1->getExpr();
    6989    }
    70     return insertAtInsertionPoint(new Not(expr, makeName("not_"), this));
     90    return insertAtInsertionPoint(new Not(expr, makeName("not_")));
    7191}
    7292
     
    82102        return renameNonNamedNode(not1->getExpr(), std::move(prefix));
    83103    }
    84     return insertAtInsertionPoint(new Not(expr, makeName(prefix, false), this));
     104    return insertAtInsertionPoint(new Not(expr, makeName(prefix, false)));
    85105}
    86106
    87107Var * PabloBlock::createVar(PabloAST * name) {
    88108    assert (name);
    89     return new Var(name, this);
     109    return new Var(name);
    90110}
    91111
     
    94114Next * PabloBlock::createNext(Assign * assign, PabloAST * expr) {
    95115    assert (assign && expr);
    96     return insertAtInsertionPoint(new Next(assign, expr, this));
     116    return insertAtInsertionPoint(new Next(assign, expr));
    97117}
    98118
     
    102122        return marker;
    103123    }
    104     return insertAtInsertionPoint(new MatchStar(marker, charclass, makeName("matchstar"), this));
     124    return insertAtInsertionPoint(new MatchStar(marker, charclass, makeName("matchstar")));
    105125}
    106126
     
    110130        return renameNonNamedNode(marker, std::move(prefix));
    111131    }
    112     return insertAtInsertionPoint(new MatchStar(marker, charclass, makeName(prefix, false), this));
     132    return insertAtInsertionPoint(new MatchStar(marker, charclass, makeName(prefix, false)));
    113133}
    114134
     
    118138        return from;
    119139    }
    120     return insertAtInsertionPoint(new ScanThru(from, thru, makeName("scanthru"), this));
     140    return insertAtInsertionPoint(new ScanThru(from, thru, makeName("scanthru")));
    121141}
    122142
     
    126146        return renameNonNamedNode(from, std::move(prefix));
    127147    }
    128     return insertAtInsertionPoint(new ScanThru(from, thru, makeName(prefix, false), this));
     148    return insertAtInsertionPoint(new ScanThru(from, thru, makeName(prefix, false)));
    129149}
    130150
     
    153173        std::swap(expr1, expr2);
    154174    }
    155     return insertAtInsertionPoint(new And(expr1, expr2, makeName("and_"), this));
     175    return insertAtInsertionPoint(new And(expr1, expr2, makeName("and_")));
    156176}
    157177
     
    181201        std::swap(expr1, expr2);
    182202    }
    183     return insertAtInsertionPoint(new And(expr1, expr2, makeName(prefix, false), this));
     203    return insertAtInsertionPoint(new And(expr1, expr2, makeName(prefix, false)));
    184204}
    185205
     
    225245        }
    226246    }
    227     return insertAtInsertionPoint(new Or(expr1, expr2, makeName("or_"), this));
     247    return insertAtInsertionPoint(new Or(expr1, expr2, makeName("or_")));
    228248}
    229249
     
    266286        }
    267287    }
    268     return insertAtInsertionPoint(new Or(expr1, expr2, makeName(prefix, false), this));
     288    return insertAtInsertionPoint(new Or(expr1, expr2, makeName(prefix, false)));
    269289}
    270290
     
    288308        }
    289309    }
    290     return insertAtInsertionPoint(new Xor(expr1, expr2, makeName("xor_"), this));
     310    return insertAtInsertionPoint(new Xor(expr1, expr2, makeName("xor_")));
    291311}
    292312
     
    310330        }
    311331    }
    312     return insertAtInsertionPoint(new Xor(expr1, expr2, makeName(prefix, false), this));
     332    return insertAtInsertionPoint(new Xor(expr1, expr2, makeName(prefix, false)));
    313333}
    314334
     
    345365        return createXor(condition, falseExpr);
    346366    }
    347     return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, makeName("sel"), this));
     367    return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, makeName("sel")));
    348368}
    349369
     
    375395        return createXor(condition, falseExpr, prefix);
    376396    }
    377     return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, makeName(prefix, false), this));
     397    return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, makeName(prefix, false)));
    378398}
    379399
    380400If * PabloBlock::createIf(PabloAST * condition, const std::initializer_list<Assign *> definedVars, PabloBlock & body) {
    381401    assert (condition);
    382     return insertAtInsertionPoint(new If(condition, definedVars, body, this));
     402    return insertAtInsertionPoint(new If(condition, definedVars, body));
    383403}
    384404
    385405If * PabloBlock::createIf(PabloAST * condition, const std::vector<Assign *> & definedVars, PabloBlock & body) {
    386406    assert (condition);
    387     return insertAtInsertionPoint(new If(condition, definedVars, body, this));
     407    return insertAtInsertionPoint(new If(condition, definedVars, body));
    388408}
    389409
    390410If * PabloBlock::createIf(PabloAST * condition, std::vector<Assign *> && definedVars, PabloBlock & body) {
    391411    assert (condition);
    392     return insertAtInsertionPoint(new If(condition, definedVars, body, this));
     412    return insertAtInsertionPoint(new If(condition, definedVars, body));
    393413}
    394414
    395415While * PabloBlock::createWhile(PabloAST * condition, const std::initializer_list<Next *> nextVars, PabloBlock & body) {
    396416    assert (condition);
    397     return insertAtInsertionPoint(new While(condition, nextVars, body, this));
     417    return insertAtInsertionPoint(new While(condition, nextVars, body));
    398418}
    399419
    400420While * PabloBlock::createWhile(PabloAST * condition, const std::vector<Next *> & nextVars, PabloBlock & body) {
    401421    assert (condition);
    402     return insertAtInsertionPoint(new While(condition, nextVars, body, this));
     422    return insertAtInsertionPoint(new While(condition, nextVars, body));
    403423}
    404424
    405425While * PabloBlock::createWhile(PabloAST * condition, std::vector<Next *> && nextVars, PabloBlock & body) {
    406426    assert (condition);
    407     return insertAtInsertionPoint(new While(condition, nextVars, body, this));
     427    return insertAtInsertionPoint(new While(condition, nextVars, body));
    408428}
    409429
  • icGREP/icgrep-devel/icgrep/pablo/codegenstate.h

    r4641 r4650  
    160160    }
    161161   
     162    void insert(Statement * const statement);
     163
    162164    PabloBlockCarryData carryData;
    163165   
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/pablo_automultiplexing.cpp

    r4648 r4650  
    11#include "pablo_automultiplexing.hpp"
    2 #include <pablo/codegenstate.h>
     2#include <include/simd-lib/builtins.hpp>
     3#include <pablo/builder.hpp>
     4#include <pablo/printer_pablos.h>
     5#include <boost/container/flat_set.hpp>
     6#include <boost/numeric/ublas/matrix.hpp>
     7#include <boost/circular_buffer.hpp>
     8#include <boost/range/iterator_range.hpp>
    39#include <llvm/ADT/BitVector.h>
     10#include <cudd.h>
     11#include <util.h>
    412#include <stack>
    513#include <queue>
    614#include <unordered_set>
    7 #include <boost/container/flat_set.hpp>
    8 #include <boost/numeric/ublas/matrix.hpp>
    9 #include <boost/circular_buffer.hpp>
    10 #include <include/simd-lib/builtins.hpp>
    11 #include <pablo/builder.hpp>
    12 #include <boost/range/iterator_range.hpp>
    13 #include <pablo/printer_pablos.h>
    14 #include <cudd.h>
    15 #include <util.h>
    1615
    1716using namespace llvm;
     
    2019using namespace boost::numeric::ublas;
    2120
    22 #define PRINT_DEBUG_OUTPUT
     21// #define PRINT_DEBUG_OUTPUT
    2322
    2423#if !defined(NDEBUG) && !defined(PRINT_DEBUG_OUTPUT)
     
    101100bool AutoMultiplexing::optimize(const std::vector<Var *> & input, PabloBlock & entry) {
    102101
    103     // std::random_device rd;
    104     const auto seed = 2938639837; // rd();
     102    std::random_device rd;
     103    const auto seed = rd();
    105104    RNG rng(seed);
    106105
     
    123122
    124123    RECORD_TIMESTAMP(start_create_multiplex_graph);
    125     const bool multiplex = am.generateMultiplexSets(rng, 1);
     124    const bool multiplex = am.generateCandidateSets(rng);
    126125    RECORD_TIMESTAMP(end_create_multiplex_graph);
    127126    LOG("GenerateMultiplexSets:   " << (end_create_multiplex_graph - start_create_multiplex_graph));
     
    145144
    146145        RECORD_TIMESTAMP(start_topological_sort);
    147         // am.topologicalSort(entry);
     146        am.topologicalSort(entry);
    148147        RECORD_TIMESTAMP(end_topological_sort);
    149148        LOG("TopologicalSort:         " << (end_topological_sort - start_topological_sort));
     
    616615
    617616inline void AutoMultiplexing::Shutdown() {
    618     #ifdef PRINT_DEBUG_OUTPUT
    619     Cudd_PrintInfo(mManager, stderr);
    620     #endif
     617//    #ifdef PRINT_DEBUG_OUTPUT
     618//    Cudd_PrintInfo(mManager, stderr);
     619//    #endif
    621620    Cudd_Quit(mManager);
    622621}
     
    626625 * @param RNG random number generator
    627626 ** ------------------------------------------------------------------------------------------------------------- */
    628 bool AutoMultiplexing::generateMultiplexSets(RNG & rng, unsigned k) {
     627bool AutoMultiplexing::generateCandidateSets(RNG & rng) {
    629628
    630629    using degree_t = graph_traits<ConstraintGraph>::degree_size_type;
     
    634633    // have the same problem here but decomposed into subgraphs.
    635634
    636     VertexVector M;
     635    VertexVector S;
    637636    std::vector<degree_t> D(num_vertices(mConstraintGraph));
    638     M.reserve(15);
    639 
    640     Trie T;
    641     std::vector<ConstraintVertex> roots;
    642 
    643     while (k) {
    644 
    645         // Push all source nodes into the new independent set N
    646         for (auto v : make_iterator_range(vertices(mConstraintGraph))) {
    647             const auto d = in_degree(v, mConstraintGraph);
    648             D[v] = d;
    649             if (d == 0) {
    650                 M.push_back(v);
    651             }
    652         }
    653 
    654         std::sort(M.begin(), M.end());
    655 
    656         auto remainingVerticies = num_vertices(mConstraintGraph) - M.size();
    657 
    658         for (;;) {
    659 
    660             addCandidateSet(M, T, roots);
    661 
    662             if (remainingVerticies == 0) {
    663                 break;
    664             }
    665 
    666             auto entries = M.size();
    667 
    668             do {
    669                 // Randomly choose a vertex in S and discard it.
    670                 assert (!M.empty());
    671                 const auto i = M.begin() + IntDistribution(0, entries - 1)(rng);
    672                 const ConstraintVertex u = *i;
    673                 M.erase(i);
    674                 --remainingVerticies;
    675                 --entries;
    676                 for (auto e : make_iterator_range(out_edges(u, mConstraintGraph))) {
    677                     const ConstraintVertex v = target(e, mConstraintGraph);
    678                     if ((--D[v]) == 0) {
    679                         M.push_back(v);
    680                     }
    681                 }
    682             }
    683             while ((M.size() == entries) && remainingVerticies != 0);
    684             // sort our new entries then merge the sorted lists
    685             std::sort(M.begin() + entries, M.end());
    686             std::inplace_merge(M.begin(), M.begin() + entries, M.end());
    687             assert (std::is_sorted(M.begin(), M.end()));
    688         }
    689         M.clear();
    690 
    691         std::cerr << "T" << k << "=" << num_vertices(T) << std::endl;
    692 
    693         if (--k == 0) {
    694             break;
    695         }       
    696     }
    697 
    698     // At this point T is a forest in which the set of any vertices from a source to a sink represents a
    699     // unique candidate set. Add all of them to the multiplex set graph.
    700 
    701     if (num_vertices(T) == 0) {
    702         return false;
    703     }
     637    S.reserve(15);
    704638
    705639    mMultiplexSetGraph = MultiplexSetGraph(num_vertices(mConstraintGraph));
    706     for (auto t : roots) {
    707         writeCandidateSet(t, T, M);
    708     }
    709     return true;
     640
     641    // Push all source nodes into the new independent set N
     642    for (auto v : make_iterator_range(vertices(mConstraintGraph))) {
     643        const auto d = in_degree(v, mConstraintGraph);
     644        D[v] = d;
     645        if (d == 0) {
     646            S.push_back(v);
     647        }
     648    }
     649
     650    auto remainingVerticies = num_vertices(mConstraintGraph) - S.size();
     651
     652    do {
     653
     654        addCandidateSet(S);
     655
     656        bool noNewElements = true;
     657        do {
     658            // Randomly choose a vertex in S and discard it.
     659            const auto i = S.begin() + IntDistribution(0, S.size() - 1)(rng);
     660            const ConstraintVertex u = *i;
     661            S.erase(i);
     662            --remainingVerticies;
     663
     664            for (auto e : make_iterator_range(out_edges(u, mConstraintGraph))) {
     665                const ConstraintVertex v = target(e, mConstraintGraph);
     666                if ((--D[v]) == 0) {
     667                    S.push_back(v);
     668                    noNewElements = false;
     669                }
     670            }
     671        }
     672        while (noNewElements && remainingVerticies);
     673    }
     674    while (remainingVerticies);
     675
     676    return num_vertices(mMultiplexSetGraph) > num_vertices(mConstraintGraph);
    710677}
    711678
    712679/** ------------------------------------------------------------------------------------------------------------- *
    713680 * @brief addCandidateSet
    714  * @param M an independent set
     681 * @param S an independent set
    715682 * @param T the trie in which to encode this new set into
    716683 * @param roots the roots (source nodes) for each tree in T
    717684 ** ------------------------------------------------------------------------------------------------------------- */
    718 inline void AutoMultiplexing::addCandidateSet(const VertexVector & M, Trie & T, VertexVector & roots) const {
    719     if (M.size() >= 3) {
    720         auto mi = M.cbegin();
    721         ConstraintVertex u = 0;
    722         for (ConstraintVertex s : roots) {
    723             if (T[s] == *mi) {
    724                 u = s;
    725                 while (++mi != M.cend()) {
    726                     bool not_found = true;
    727                     for (const auto e : make_iterator_range(out_edges(u, T))) {
    728                         const auto v = target(e, T);
    729                         if (T[v] == *mi) {
    730                             u = v;
    731                             not_found = false;
    732                             break;
    733                         }
    734                     }
    735                     if (not_found) {
    736                         break;
    737                     }
    738                 }
    739                 break;
    740             }
    741         }
    742         if (mi == M.cbegin()) {
    743             u = add_vertex(*mi++, T);
    744             roots.push_back(u);
    745         }
    746         for (; mi != M.cend(); ++mi) {
    747             const auto v = add_vertex(*mi, T);
    748             add_edge(u, v, T);
    749             u = v;
    750         }
    751     }
    752 }
    753 
    754 /** ------------------------------------------------------------------------------------------------------------- *
    755  * @brief writeCandidateSet
    756  * @param M an independent set
    757  * @param T the trie in which to encode this new set into
    758  * @param roots the roots (source nodes) for each tree in T
    759  ** ------------------------------------------------------------------------------------------------------------- */
    760 void AutoMultiplexing::writeCandidateSet(const Trie::vertex_descriptor t, const Trie & T, VertexVector & S) {
    761     S.push_back(T[t]);
    762     if (out_degree(t, T) == 0) {
     685inline void AutoMultiplexing::addCandidateSet(const VertexVector & S) {
     686    if (S.size() >= 3) {
    763687        const auto u = add_vertex(mMultiplexSetGraph);
    764688        for (const auto v : S) {
     
    766690        }
    767691    }
    768     else {
    769         for (const auto e : make_iterator_range(out_edges(t, T))) {
    770             writeCandidateSet(target(e, T), T, S);
    771         }
    772     }
    773     assert (S.back() == T[t]);
    774     S.pop_back();
    775 }
    776 
     692}
    777693
    778694/** ------------------------------------------------------------------------------------------------------------- *
     
    797713 * This algorithm is simply computes a greedy set cover. We want an exact max-weight set cover but can generate new
    798714 * sets by taking a subset of any existing set. With a few modifications, the greedy approach seems to work well
    799  * enough but more analysis is needed.
     715 * enough but can be trivially shown to produce a suboptimal solution if there are three (or more) sets in which
     716 * two, labelled A and B, are disjoint and the third larger set, C, that consists of elements of A and B.
    800717 ** ------------------------------------------------------------------------------------------------------------- */
    801718void AutoMultiplexing::selectMultiplexSets(RNG &) {
     
    10941011            }
    10951012
    1096 
    10971013            /// Perform m-to-n Demultiplexing
    10981014            // Now construct the demuxed values and replaces all the users of the original advances with them.
     
    11481064 ** ------------------------------------------------------------------------------------------------------------- */
    11491065void AutoMultiplexing::topologicalSort(PabloBlock & entry) const {
    1150     // Note: not a real topological sort. I expect the original order to be very close to the resulting one.
     1066    // Note: not a real topological sort. I expect the original graph to be close to the resulting one. Thus cost
     1067    // of constructing a graph in which to perform the sort takes longer than potentially moving an instruction
     1068    // multiple times.
    11511069    std::unordered_set<const PabloAST *> encountered;
    11521070    std::stack<Statement *> scope;
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/pablo_automultiplexing.hpp

    r4648 r4650  
    4444    DdNode * characterize(Advance * adv, DdNode * input);
    4545    bool notTransitivelyDependant(const ConstraintVertex i, const ConstraintVertex j) const;
    46     bool generateMultiplexSets(RNG & rng, unsigned k = 1);
    47     void addCandidateSet(const VertexVector & M, Trie & T, VertexVector & roots) const;
    48     void writeCandidateSet(const Trie::vertex_descriptor t, const Trie & T, VertexVector & S);
     46    bool generateCandidateSets(RNG & rng);
     47    void addCandidateSet(const VertexVector & S);
    4948    void selectMultiplexSets(RNG &);
    5049    void applySubsetConstraints();
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.cpp

    r4611 r4650  
    88#include <pablo/codegenstate.h>
    99#include <llvm/Support/Compiler.h>
     10#include <pablo/printer_pablos.h>
     11
    1012#ifndef NDEBUG
    1113#include <queue>
     
    122124
    123125void Statement::insertBefore(Statement * const statement) {
    124     assert (statement);
    125     assert (statement != this);
    126     assert (statement->mParent);
     126    if (LLVM_UNLIKELY(statement == this)) {
     127        return;
     128    }
     129    else if (LLVM_UNLIKELY(statement == nullptr)) {
     130        throw std::runtime_error("Cannot insert before Null statement!");
     131    }
     132    else if (LLVM_UNLIKELY(statement->mParent == nullptr)) {
     133        throw std::runtime_error("Cannot insert before before statement in Null AST!");
     134    }
    127135    removeFromParent();
    128136    mParent = statement->mParent;
     
    143151
    144152void Statement::insertAfter(Statement * const statement) {
    145     assert (statement);
    146     assert (statement != this);
    147     assert (statement->mParent);
     153    if (LLVM_UNLIKELY(statement == this)) {
     154        return;
     155    }
     156    else if (LLVM_UNLIKELY(statement == nullptr)) {
     157        throw std::runtime_error("Cannot insert before Null statement!");
     158    }
     159    else if (LLVM_UNLIKELY(statement->mParent == nullptr)) {
     160        throw std::runtime_error("Cannot insert before before statement in Null AST!");
     161    }
    148162    removeFromParent();
    149163    mParent = statement->mParent;
     
    172186            mParent->mLast = mPrev;
    173187        }
    174         if (mParent->mInsertionPoint == this) {
    175             mParent->mInsertionPoint = mParent->mInsertionPoint->mPrev;
     188        if (LLVM_UNLIKELY(mParent->mInsertionPoint == this)) {
     189            mParent->mInsertionPoint = mPrev;
    176190        }
    177191        if (LLVM_LIKELY(mPrev != nullptr)) {
     
    264278#endif
    265279
    266 void StatementList::insert(Statement * const statement) {
    267     if (LLVM_UNLIKELY(mInsertionPoint == nullptr)) {
    268         statement->mNext = mFirst;
    269         if (mFirst) {
    270             assert (mFirst->mPrev == nullptr);
    271             mFirst->mPrev = statement;
    272         }
    273         mLast = (mLast == nullptr) ? statement : mLast;
    274         mInsertionPoint = mFirst = statement;
    275     }
    276     else {
    277         statement->insertAfter(mInsertionPoint);
    278         mLast = (mLast == mInsertionPoint) ? statement : mLast;
    279         assert (statement->mPrev == mInsertionPoint);
    280         mInsertionPoint = statement;
    281     }
    282 }
    283 
    284280StatementList::~StatementList() {
    285281
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.h

    r4611 r4650  
    203203    virtual ~Statement() {}
    204204protected:
    205     Statement(const ClassTypeId id, std::initializer_list<PabloAST *> operands, const String * const name, PabloBlock * const parent)
     205    Statement(const ClassTypeId id, std::initializer_list<PabloAST *> operands, const String * const name)
    206206    : PabloAST(id)
    207207    , mName(name)
    208208    , mNext(nullptr)
    209209    , mPrev(nullptr)
    210     , mParent(parent)
     210    , mParent(nullptr)
    211211    , mOperands(operands.size())
    212     , mOperand(reinterpret_cast<PabloAST**>(mAllocator.allocate(mOperands * sizeof(PabloAST *))))
    213     {
     212    , mOperand(reinterpret_cast<PabloAST**>(mAllocator.allocate(mOperands * sizeof(PabloAST *)))) {
    214213        unsigned i = 0;
    215214        for (PabloAST * const op : operands) {
     
    237236class StatementList {
    238237    friend class Statement;
     238    friend class PabloBlock;
    239239public:
    240240    class iterator: public std::iterator<std::forward_iterator_tag, Statement> {
     
    464464    }
    465465
    466     inline void setInsertPoint(StatementList * const list) {
    467         mInsertionPoint = list->back();
    468     }
    469 
    470466    inline Statement * getInsertPoint() const {
    471467        return mInsertionPoint;
    472468    }
    473 
    474     void insert(Statement * const statement);
    475469
    476470    ~StatementList();
  • icGREP/icgrep-devel/icgrep/pablo/pe_advance.h

    r4540 r4650  
    3838    }
    3939protected:
    40     Advance(PabloAST * expr, PabloAST * shiftAmount, String * name, PabloBlock * parent)
    41     : Statement(ClassTypeId::Advance, {expr, shiftAmount}, name, parent)
     40    Advance(PabloAST * expr, PabloAST * shiftAmount, String * name)
     41    : Statement(ClassTypeId::Advance, {expr, shiftAmount}, name)
    4242    {
    4343        assert(isa<Integer>(shiftAmount));
  • icGREP/icgrep-devel/icgrep/pablo/pe_and.h

    r4438 r4650  
    3030    }
    3131protected:
    32     And(PabloAST * expr1, PabloAST * expr2, String * name, PabloBlock * parent)
    33     : Statement(ClassTypeId::And, {expr1, expr2}, name, parent)
     32    And(PabloAST * expr1, PabloAST * expr2, String * name)
     33    : Statement(ClassTypeId::And, {expr1, expr2}, name)
    3434    {
    3535
  • icGREP/icgrep-devel/icgrep/pablo/pe_call.h

    r4438 r4650  
    2222    }
    2323protected:
    24     Call(PabloAST * callee, PabloBlock * parent)
    25     : Statement(ClassTypeId::Call, {callee}, cast<String>(callee), parent) {
     24    Call(PabloAST * callee)
     25    : Statement(ClassTypeId::Call, {callee}, cast<String>(callee)) {
    2626
    2727    }
  • icGREP/icgrep-devel/icgrep/pablo/pe_matchstar.h

    r4540 r4650  
    3535    virtual ~MatchStar() {}
    3636protected:
    37     MatchStar(PabloAST * marker, PabloAST * cc, String * name, PabloBlock * parent)
    38     : Statement(ClassTypeId::MatchStar, {marker, cc}, name, parent)
     37    MatchStar(PabloAST * marker, PabloAST * cc, String * name)
     38    : Statement(ClassTypeId::MatchStar, {marker, cc}, name)
    3939    {
    4040
  • icGREP/icgrep-devel/icgrep/pablo/pe_next.h

    r4643 r4650  
    2626    virtual ~Next() {}
    2727protected:
    28     explicit Next(PabloAST * initial, PabloAST * expr, PabloBlock * parent)
    29     : Statement(ClassTypeId::Next, {expr, cast<Assign>(initial)}, cast<Assign>(initial)->getName(), parent) {
     28    explicit Next(PabloAST * initial, PabloAST * expr)
     29    : Statement(ClassTypeId::Next, {expr, cast<Assign>(initial)}, cast<Assign>(initial)->getName()) {
    3030        this->addUser(initial);
    3131    }
  • icGREP/icgrep-devel/icgrep/pablo/pe_not.h

    r4438 r4650  
    2727    }
    2828protected:
    29     Not(PabloAST * expr, String * name, PabloBlock * parent)
    30     : Statement(ClassTypeId::Not, {expr}, name, parent)
     29    Not(PabloAST * expr, String * name)
     30    : Statement(ClassTypeId::Not, {expr}, name)
    3131    {
    3232
  • icGREP/icgrep-devel/icgrep/pablo/pe_or.h

    r4438 r4650  
    3030    }
    3131protected:
    32     Or(PabloAST * expr1, PabloAST * expr2, String * name, PabloBlock * parent)
    33     : Statement(ClassTypeId::Or, {expr1, expr2}, name, parent)
     32    Or(PabloAST * expr1, PabloAST * expr2, String * name)
     33    : Statement(ClassTypeId::Or, {expr1, expr2}, name)
    3434    {
    3535
  • icGREP/icgrep-devel/icgrep/pablo/pe_scanthru.h

    r4540 r4650  
    3636    }
    3737protected:
    38     ScanThru(PabloAST * from, PabloAST * thru, String * name, PabloBlock * parent)
    39     : Statement(ClassTypeId::ScanThru, {from, thru}, name, parent)
     38    ScanThru(PabloAST * from, PabloAST * thru, String * name)
     39    : Statement(ClassTypeId::ScanThru, {from, thru}, name)
    4040    {
    4141
  • icGREP/icgrep-devel/icgrep/pablo/pe_sel.h

    r4438 r4650  
    3333    }
    3434protected:
    35     Sel(PabloAST* if_expr, PabloAST* t_expr, PabloAST* f_expr, String * name, PabloBlock * parent)
    36     : Statement(ClassTypeId::Sel, {if_expr, t_expr, f_expr}, name, parent)
     35    Sel(PabloAST* if_expr, PabloAST* t_expr, PabloAST* f_expr, String * name)
     36    : Statement(ClassTypeId::Sel, {if_expr, t_expr, f_expr}, name)
    3737    {
    3838
  • icGREP/icgrep-devel/icgrep/pablo/pe_var.h

    r4414 r4650  
    4343    }
    4444protected:
    45     Var(PabloAST * var, PabloBlock *)
     45    Var(PabloAST * var)
    4646    : PabloAST(ClassTypeId::Var)
    47     , mName(cast<String>(var))
    48     {
     47    , mName(cast<String>(var)) {
    4948        var->addUser(this);
    5049    }
  • icGREP/icgrep-devel/icgrep/pablo/pe_xor.h

    r4438 r4650  
    3131    }
    3232protected:
    33     Xor(PabloAST * expr1, PabloAST * expr2, String * name, PabloBlock * parent)
    34     : Statement(ClassTypeId::Xor, {expr1, expr2}, name, parent)
     33    Xor(PabloAST * expr1, PabloAST * expr2, String * name)
     34    : Statement(ClassTypeId::Xor, {expr1, expr2}, name)
    3535    {
    3636
  • icGREP/icgrep-devel/icgrep/pablo/ps_assign.h

    r4433 r4650  
    3636    bool superfluous() const;
    3737protected:
    38     explicit Assign(PabloAST * expr, int outputIndex, String * name, PabloBlock * parent)
    39     : Statement(ClassTypeId::Assign, {expr}, name, parent)
     38    explicit Assign(PabloAST * expr, int outputIndex, String * name)
     39    : Statement(ClassTypeId::Assign, {expr}, name)
    4040    , mOutputIndex(outputIndex)
    4141    {
  • icGREP/icgrep-devel/icgrep/pablo/ps_if.cpp

    r4641 r4650  
    55namespace pablo {
    66
    7 If::If(PabloAST * expr, const std::initializer_list<Assign *> definedVars, PabloBlock & body, PabloBlock * parent)
    8 : Statement(ClassTypeId::If, {expr}, nullptr, parent)
     7If::If(PabloAST * expr, const std::initializer_list<Assign *> definedVars, PabloBlock & body)
     8: Statement(ClassTypeId::If, {expr}, nullptr)
    99, mBody(body)
    1010, mDefined(definedVars.begin(), definedVars.end(), reinterpret_cast<DefinedAllocator &>(mVectorAllocator))
     
    2727}
    2828
    29 If::If(PabloAST * expr, const std::vector<Assign *> & definedVars, PabloBlock & body, PabloBlock * parent)
    30 : Statement(ClassTypeId::If, {expr}, nullptr, parent)
     29If::If(PabloAST * expr, const std::vector<Assign *> & definedVars, PabloBlock & body)
     30: Statement(ClassTypeId::If, {expr}, nullptr)
    3131, mBody(body)
    3232, mDefined(definedVars.begin(), definedVars.end(), reinterpret_cast<DefinedAllocator &>(mVectorAllocator))
  • icGREP/icgrep-devel/icgrep/pablo/ps_if.h

    r4641 r4650  
    4848        return mDefined;
    4949    }
    50     If(PabloAST * expr, const std::initializer_list<Assign *> definedVars, PabloBlock & body, PabloBlock * parent);
     50    If(PabloAST * expr, const std::initializer_list<Assign *> definedVars, PabloBlock & body);
    5151
    52     If(PabloAST * expr, const std::vector<Assign *> & definedVars, PabloBlock & body, PabloBlock * parent);
     52    If(PabloAST * expr, const std::vector<Assign *> & definedVars, PabloBlock & body);
    5353private:
    5454    PabloBlock &    mBody;
  • icGREP/icgrep-devel/icgrep/pablo/ps_while.cpp

    r4641 r4650  
    44namespace pablo {
    55
    6 While::While(PabloAST * expr, const std::initializer_list<Next *> nextVars, PabloBlock & body, PabloBlock * parent)
    7 : Statement(ClassTypeId::While, {expr}, nullptr, parent)
     6While::While(PabloAST * expr, const std::initializer_list<Next *> nextVars, PabloBlock & body)
     7: Statement(ClassTypeId::While, {expr}, nullptr)
    88, mBody(body)
    99, mNext(nextVars.begin(), nextVars.end(), reinterpret_cast<NextAllocator &>(mVectorAllocator))
     
    1212}
    1313
    14 While::While(PabloAST * expr, const std::vector<Next *> & nextVars, PabloBlock & body, PabloBlock * parent)
    15 : Statement(ClassTypeId::While, {expr}, nullptr, parent)
     14While::While(PabloAST * expr, const std::vector<Next *> & nextVars, PabloBlock & body)
     15: Statement(ClassTypeId::While, {expr}, nullptr)
    1616, mBody(body)
    1717, mNext(nextVars.begin(), nextVars.end(), reinterpret_cast<NextAllocator &>(mVectorAllocator))
  • icGREP/icgrep-devel/icgrep/pablo/ps_while.h

    r4641 r4650  
    4242    }
    4343protected:
    44     While(PabloAST * expr, const std::initializer_list<Next *> nextVars, PabloBlock &body, PabloBlock * parent);
    45     While(PabloAST * expr, const std::vector<Next *> & nextVars, PabloBlock &body, PabloBlock * parent);
     44    While(PabloAST * expr, const std::initializer_list<Next *> nextVars, PabloBlock &body);
     45    While(PabloAST * expr, const std::vector<Next *> & nextVars, PabloBlock &body);
    4646
    4747private:
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4649 r4650  
    509509        PabloAST * m2 = pb.createOr(base, starAccum);
    510510        PabloAST * loopComputation = markerVar(AdvanceMarker(process(repeated, makeMarker(InitialPostPositionByte, m1), pb), InitialPostPositionByte, pb));
    511         PabloAST * starPending_ = pb.createAnd(loopComputation, pb.createNot(m2));
    512         PabloAST * starAccum_ = pb.createOr(loopComputation, m2);
    513         mWhileTest = pb.createOr(mWhileTest, starPending_);
    514        
    515         Next * nextPending = pb.createNext(starPending, starPending_);
    516         Next * nextStarAccum = pb.createNext(starAccum, starAccum_);
     511        Next * nextPending = pb.createNext(starPending, pb.createAnd(loopComputation, pb.createNot(m2)));
     512        Next * nextStarAccum = pb.createNext(starAccum, pb.createOr(loopComputation, m2));
     513        mWhileTest = pb.createOr(mWhileTest, nextPending);
    517514        mLoopVariants.push_back(nextPending);
    518515        mLoopVariants.push_back(nextStarAccum);
    519516        mStarDepth--;
    520517       
    521         return makeMarker(InitialPostPositionByte, pb.createAssign("unbounded", pb.createOr(base, starAccum_)));
     518        return makeMarker(InitialPostPositionByte, pb.createAssign("unbounded", pb.createOr(base, nextStarAccum)));
    522519    }   
    523520    else {
     
    531528
    532529        PabloAST * loopComputation = markerVar(AdvanceMarker(process(repeated, makeMarker(InitialPostPositionByte, whilePending), wb), InitialPostPositionByte, wb));
    533         PabloAST * whilePending_ = wb.createAnd(loopComputation, wb.createNot(whileAccum));
    534         PabloAST * whileAccum_ = wb.createOr(loopComputation, whileAccum);
    535         PabloAST * whileTest_ = wb.createOr(mWhileTest, whilePending_);
    536         Next * nextWhilePending = wb.createNext(whilePending, whilePending_);
    537         Next * nextWhileAccum = wb.createNext(whileAccum, whileAccum_);
    538         Next * nextWhileTest = wb.createNext(whileTest, whileTest_);
     530        Next * nextWhilePending = wb.createNext(whilePending, wb.createAnd(loopComputation, wb.createNot(whileAccum)));
     531        Next * nextWhileAccum = wb.createNext(whileAccum, wb.createOr(loopComputation, whileAccum));
     532        Next * nextWhileTest = wb.createNext(whileTest, wb.createOr(mWhileTest, nextWhilePending));
    539533        mLoopVariants.push_back(nextWhilePending);
    540534        mLoopVariants.push_back(nextWhileAccum);
    541535        mLoopVariants.push_back(nextWhileTest);
    542         pb.createWhile(whileTest_, mLoopVariants, wb);
     536        pb.createWhile(nextWhileTest, mLoopVariants, wb);
    543537        mStarDepth--;
    544538        mLoopVariants.clear();
    545         return makeMarker(InitialPostPositionByte, pb.createAssign("unbounded", whileAccum_));
     539        return makeMarker(InitialPostPositionByte, pb.createAssign("unbounded", nextWhileAccum));
    546540    }   
    547541} // end of namespace re
Note: See TracChangeset for help on using the changeset viewer.