Ignore:
Timestamp:
Nov 14, 2015, 5:38:36 PM (3 years ago)
Author:
nmedfort
Message:

Bug fix for Multiplexing. Added ability to set the body of a If/While? node after creation.

File:
1 edited

Legend:

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

    r4860 r4870  
    5353    }
    5454
    55     inline static PabloBlock & Create(SymbolGenerator * symbolGenerator) {
    56         assert (symbolGenerator);
    57         return *(new PabloBlock(symbolGenerator));
    58     }
    59 
    60     inline static PabloBlock & Create(PabloBlock & parent) {
    61         return *(new PabloBlock(&parent));
     55    inline static PabloBlock * Create(PabloFunction & function) noexcept {
     56        return new PabloBlock(function.mSymbolTable);
    6257    }
    6358
     
    136131    PabloAST * createCount(PabloAST * expr, const std::string prefix);
    137132   
    138     If * createIf(PabloAST * condition, const std::initializer_list<Assign *> definedVars, PabloBlock & body);
    139 
    140     If * createIf(PabloAST * condition, const std::vector<Assign *> & definedVars, PabloBlock & body);
    141 
    142     If * createIf(PabloAST * condition, std::vector<Assign *> && definedVars, PabloBlock & body);
    143 
    144     While * createWhile(PabloAST * condition, const std::initializer_list<Next *> nextVars, PabloBlock & body);
    145 
    146     While * createWhile(PabloAST * condition, const std::vector<Next *> & nextVars, PabloBlock & body);
    147 
    148     While * createWhile(PabloAST * condition, std::vector<Next *> && nextVars, PabloBlock & body);
     133    If * createIf(PabloAST * condition, const std::initializer_list<Assign *> definedVars, PabloBlock * body);
     134
     135    If * createIf(PabloAST * condition, const std::vector<Assign *> & definedVars, PabloBlock * body);
     136
     137    If * createIf(PabloAST * condition, std::vector<Assign *> && definedVars, PabloBlock * body);
     138
     139    While * createWhile(PabloAST * condition, const std::initializer_list<Next *> nextVars, PabloBlock * body);
     140
     141    While * createWhile(PabloAST * condition, const std::vector<Next *> & nextVars, PabloBlock * body);
     142
     143    While * createWhile(PabloAST * condition, std::vector<Next *> && nextVars, PabloBlock * body);
    149144
    150145    PabloAST * createMod64Advance(PabloAST * expr, const Integer::Type shiftAmount);
     
    189184    }
    190185   
     186    void setParent(PabloBlock * parent) {
     187        mParent = parent;
     188        // Add test to assert this block is in the same function.
     189    }
     190
    191191    void insert(Statement * const statement);
    192192
     
    197197    }
    198198   
     199    void eraseFromParent(const bool recursively = false);
     200
    199201    virtual ~PabloBlock();
    200202
    201203protected:
    202204
    203     explicit PabloBlock(SymbolGenerator * symbolGenerator);
    204 
    205     explicit PabloBlock(PabloBlock * predecessor);
     205    explicit PabloBlock(SymbolGenerator * symbolGenerator) noexcept;
    206206
    207207    PabloAST * renameNonNamedNode(PabloAST * expr, const std::string && prefix);
     
    211211        if (isa<Statement>(expr)) {
    212212            if (LLVM_UNLIKELY(isa<If>(expr) || isa<While>(expr))) {
    213                 PabloBlock & body = isa<If>(expr) ? cast<If>(expr)->getBody() : cast<While>(expr)->getBody();
    214                 this->addUser(&body);
     213                PabloBlock * const body = isa<If>(expr) ? cast<If>(expr)->getBody() : cast<While>(expr)->getBody();
     214                body->setParent(this);
     215                addUser(body);
    215216            }
    216217            insert(cast<Statement>(expr));
     
    228229    static Zeroes                                       mZeroes;
    229230    static Ones                                         mOnes;
    230     SymbolGenerator *                                   mSymbolGenerator;
     231    SymbolGenerator *                                   mSymbolGenerator; // TODO: need a better way of passing a symbol generator around
    231232    PabloBlock *                                        mParent;
    232233    unsigned                                            mScopeIndex;
Note: See TracChangeset for help on using the changeset viewer.