Ignore:
Timestamp:
Dec 23, 2015, 4:28:42 PM (3 years ago)
Author:
nmedfort
Message:

Work on lowering + minor bug fixes.

File:
1 edited

Legend:

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

    r4886 r4899  
    1010#include <pablo/printer_pablos.h>
    1111#include <llvm/ADT/SmallVector.h>
    12 #include <iostream>
    1312
    1413namespace pablo {
     
    7776 * @brief replaceAllUsesWith
    7877 ** ------------------------------------------------------------------------------------------------------------- */
    79 void PabloAST::replaceAllUsesWith(PabloAST * expr) {
     78void PabloAST::replaceAllUsesWith(PabloAST * const expr) {
    8079    assert (expr);
    8180    if (LLVM_UNLIKELY(this == expr)) {
     
    102101 ** ------------------------------------------------------------------------------------------------------------- */
    103102template <class ValueType, class ValueList>
    104 inline void Statement::checkEscapedValueList(Statement * branch, PabloAST * const from, PabloAST * const to, ValueList & list) {
     103inline void Statement::checkEscapedValueList(Statement * const branch, PabloAST * const from, PabloAST * const to, ValueList & list) {
    105104    if (LLVM_LIKELY(isa<ValueType>(from))) {
    106105        auto f = std::find(list.begin(), list.end(), cast<ValueType>(from));
    107106        if (LLVM_LIKELY(f != list.end())) {
     107            branch->removeUser(from);
     108            from->removeUser(branch);
    108109            if (LLVM_LIKELY(isa<ValueType>(to))) {
    109                 if (std::find(list.begin(), list.end(), cast<ValueType>(to)) == list.end()) {
     110                if (std::count(list.begin(), list.end(), cast<ValueType>(to)) == 0) {
    110111                    *f = cast<ValueType>(to);
    111112                    branch->addUser(to);
    112                 } else {
    113                     list.erase(f);
    114                 }
    115                 branch->removeUser(from);
    116                 assert (std::find(list.begin(), list.end(), cast<ValueType>(to)) != list.end());
    117                 assert (std::find(branch->user_begin(), branch->user_end(), cast<ValueType>(to)) != branch->user_end());
    118             } else {
    119                 list.erase(f);
    120                 branch->removeUser(from);
    121             }
    122         }               
    123         assert (std::find(list.begin(), list.end(), cast<ValueType>(from)) == list.end());
    124         assert (std::find(branch->user_begin(), branch->user_end(), cast<ValueType>(from)) == branch->user_end());
     113                    to->addUser(branch);
     114                    return;
     115                }
     116            }
     117            list.erase(f);
     118        }                             
    125119    }
    126120}
     
    149143 ** ------------------------------------------------------------------------------------------------------------- */
    150144void Statement::setOperand(const unsigned index, PabloAST * const value) {
    151     assert ("No operand can be null!" && value);
     145    assert ("Operand cannot be null!" && value);
    152146    assert (index < getNumOperands());
    153147    PabloAST * const prior = getOperand(index);
    154     assert ("No operand can be null!" && prior);
     148    assert ("Operand cannot be null!" && prior);
    155149    if (LLVM_UNLIKELY(prior == value)) {
    156150        return;
     
    343337        }
    344338    }
    345     replaceAllUsesWith(expr);   
     339    replaceAllUsesWith(expr);
    346340    return eraseFromParent(recursively);
    347341}
Note: See TracChangeset for help on using the changeset viewer.