Ignore:
Timestamp:
Nov 22, 2015, 3:17:10 PM (4 years ago)
Author:
nmedfort
Message:

More work on n-ary operations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/pabloAST.h

    r4876 r4878  
    101101    }
    102102
     103    inline unsigned getNumUsers() const {
     104        return mUsers.size();
     105    }
     106
    103107    inline Users & users() {
    104108        return mUsers;
     
    223227    , mOperand(reinterpret_cast<PabloAST**>(mAllocator.allocate(mOperands * sizeof(PabloAST *)))) {
    224228        unsigned i = 0;
    225         for (PabloAST * const op : operands) {
    226             mOperand[i++] = op;
    227             if (LLVM_LIKELY(op != nullptr)) {
    228                 op->addUser(this);
    229             }
     229        for (PabloAST * const value : operands) {
     230            assert (value);
     231            mOperand[i] = value;
     232            value->addUser(this);
     233            ++i;
    230234        }
    231235    } 
     236    Statement(const ClassTypeId id, unsigned operands, PabloAST * value, const String * const name)
     237    : PabloAST(id)
     238    , mName(name)
     239    , mNext(nullptr)
     240    , mPrev(nullptr)
     241    , mParent(nullptr)
     242    , mOperands(operands)
     243    , mOperand(reinterpret_cast<PabloAST**>(mAllocator.allocate(mOperands * sizeof(PabloAST *)))) {
     244        for (unsigned i = 0; i != operands; ++i) {
     245            assert (value);
     246            mOperand[i] = value;
     247            value->addUser(this);
     248        }
     249    }
    232250private:
    233251    template <class ValueType, class ValueList>
     
    269287        inline void increment() { ++mCurrent; }
    270288        inline void decrement() { --mCurrent; }
    271         inline void advance(const unsigned n) { mCurrent += n; }
     289        inline void advance(const std::ptrdiff_t n) { mCurrent += n; }
    272290        inline std::ptrdiff_t distance_to(const iterator & other) const { return other.mCurrent - mCurrent; }
    273291        inline PabloAST *& dereference() const { return *mCurrent; }
     
    284302
    285303    PabloAST * removeOperand(const unsigned index);
    286 
    287     inline iterator erase(iterator itr) {
    288         removeOperand(itr.distance_to(begin()));
    289         return itr;
    290     }
    291304
    292305    iterator begin() {
     
    310323    : Statement(id, operands, name)
    311324    , mCapacity(operands.size()) {
     325
     326    }
     327    Variadic(const ClassTypeId id, const unsigned operands, PabloAST * value, String * name)
     328    : Statement(id, operands, value, name)
     329    , mCapacity(operands) {
    312330
    313331    }
     
    570588 ** ------------------------------------------------------------------------------------------------------------- */
    571589inline void PabloAST::addUser(PabloAST *user) {
    572     assert (user);
     590    assert (user);   
    573591    // Note: for the rare situation that this node is used multiple times by a statement, duplicates are allowed.
    574592    mUsers.insert(std::lower_bound(mUsers.begin(), mUsers.end(), user), user);
Note: See TracChangeset for help on using the changeset viewer.