Ignore:
Timestamp:
Nov 19, 2015, 4:47:28 PM (4 years ago)
Author:
nmedfort
Message:

More work towards n-ary And/Or/Xor? functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/expression_map.hpp

    r4718 r4876  
    113113        }
    114114
     115        inline Key(PabloAST::ClassTypeId type, const Variadic * stmt, Allocator & allocator)
     116        : mType(type)
     117        , mArgs(stmt->getNumOperands())
     118        , mArg(allocator.Allocate<const PabloAST *>(mArgs)) {
     119            unsigned i = 0;
     120            for (PabloAST * arg : *stmt) {
     121                mArg[i++] = arg;
     122            }
     123        }
     124
    115125        inline Key(const Key & key) = default;
    116126
     
    168178    }
    169179
    170     inline std::pair<PabloAST *, bool> findOrAdd(PabloAST * object, const PabloAST::ClassTypeId type, PabloAST * arg1, const std::vector<PabloAST *> & args) {
    171         Key key(type, arg1, args, mAllocator);
     180    inline std::pair<PabloAST *, bool> findOrAdd(Variadic * object, const PabloAST::ClassTypeId type) {
     181        Key key(type, object, mAllocator);
    172182        PabloAST * const entry = find(key);
    173183        if (entry) {
     
    265275            case PabloAST::ClassTypeId::Or:
    266276            case PabloAST::ClassTypeId::Xor:
    267                 // test whether the communative version of this statement exists
    268                 if (PabloAST * commExpr = mBinary.find(stmt->getClassTypeId(), stmt->getOperand(1), stmt->getOperand(0))) {
    269                     return std::make_pair(commExpr, false);
    270                 }
     277                return mVariable.findOrAdd(cast<Variadic>(stmt), stmt->getClassTypeId());
    271278            case PabloAST::ClassTypeId::Advance:
    272279            case PabloAST::ClassTypeId::ScanThru:
Note: See TracChangeset for help on using the changeset viewer.