Ignore:
Timestamp:
Nov 30, 2015, 4:30:02 PM (4 years ago)
Author:
nmedfort
Message:

More work on n-ary operations. Unresolved bug in DistributionPass?.

File:
1 edited

Legend:

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

    r4880 r4885  
    1010#include <llvm/Support/Casting.h>
    1111#include <llvm/Support/Compiler.h>
     12#include <boost/iterator/iterator_facade.hpp>
     13#include <iterator>
     14#include <slab_allocator.h>
     15#include <type_traits>
     16#include <unordered_map>
    1217#include <vector>
    13 #include <slab_allocator.h>
    14 #include <iterator>
    15 #include <unordered_map>
    16 #include <boost/iterator/iterator_facade.hpp>
    1718
    1819using namespace llvm;
     
    233234            ++i;
    234235        }
    235     } 
     236    }
    236237    Statement(const ClassTypeId id, unsigned operands, PabloAST * value, const String * const name)
    237238    : PabloAST(id)
     
    248249        }
    249250    }
     251    template<typename iterator>
     252    explicit Statement(const ClassTypeId id, iterator begin, iterator end, const String * const name)
     253    : PabloAST(id)
     254    , mName(name)
     255    , mNext(nullptr)
     256    , mPrev(nullptr)
     257    , mParent(nullptr)
     258    , mOperands(std::distance(begin, end))
     259    , mOperand(reinterpret_cast<PabloAST**>(mAllocator.allocate(mOperands * sizeof(PabloAST *)))) {
     260        unsigned i = 0;
     261        for (auto value = begin; value != end; ++value, ++i) {
     262            assert (*value);
     263            mOperand[i] = *value;
     264            (*value)->addUser(this);
     265        }
     266    }
    250267private:
    251268    template <class ValueType, class ValueList>
     
    303320    PabloAST * removeOperand(const unsigned index);
    304321
    305     unsigned removeOperand(const PabloAST * const expr);
     322    bool deleteOperand(const PabloAST * const expr);
    306323
    307324    iterator begin() {
     
    330347    : Statement(id, operands, value, name)
    331348    , mCapacity(operands) {
     349
     350    }
     351    template<typename iterator>
     352    explicit Variadic(const ClassTypeId id, iterator begin, iterator end, String * name)
     353    : Statement(id, begin, end, name)
     354    , mCapacity(std::distance(begin, end)) {
    332355
    333356    }
     
    608631 * @brief removeOperand
    609632 ** ------------------------------------------------------------------------------------------------------------- */
    610 inline unsigned Variadic::removeOperand(const PabloAST * const expr) {
     633inline bool Variadic::deleteOperand(const PabloAST * const expr) {
    611634    for (unsigned i = 0; i != getNumOperands(); ++i) {
    612635        if (getOperand(i) == expr) {
    613636            removeOperand(i);
    614             return i;
    615         }
    616     }
    617     return -1;
     637            return true;
     638        }
     639    }
     640    return false;
    618641}
    619642
Note: See TracChangeset for help on using the changeset viewer.