source: icGREP/icgrep-devel/icgrep/pablo/ps_if.cpp @ 4641

Last change on this file since 4641 was 4641, checked in by nmedfort, 4 years ago

Next nodes for While statements must be declared similar to how Defined Vars are for Ifs. (Temporarily breaks multiplexing correctness.)

File size: 1.3 KB
Line 
1#include <pablo/ps_if.h>
2#include <pablo/codegenstate.h>
3#include <pablo/ps_assign.h>
4
5namespace pablo {
6
7If::If(PabloAST * expr, const std::initializer_list<Assign *> definedVars, PabloBlock & body, PabloBlock * parent)
8: Statement(ClassTypeId::If, {expr}, nullptr, parent)
9, mBody(body)
10, mDefined(definedVars.begin(), definedVars.end(), reinterpret_cast<DefinedAllocator &>(mVectorAllocator))
11{
12    // Conceptually, having a defined var X is identical to having:
13    //
14    // Assign(X, 0)
15    // If (...)
16    //    Next(Assign(X), ...)
17    //
18    // Since the implied 'Next' node is a user of the Assign node, and the Assign node is
19    // embedded into the If, the defined var is a user of the If node. However, since the
20    // Assign's value is also dependant on the 'Next' value, the If node is also a user
21    // of it.
22
23    for (PabloAST * assign : mDefined) {
24        assign->addUser(this);
25        addUser(assign);
26    }
27}
28
29If::If(PabloAST * expr, const std::vector<Assign *> & definedVars, PabloBlock & body, PabloBlock * parent)
30: Statement(ClassTypeId::If, {expr}, nullptr, parent)
31, mBody(body)
32, mDefined(definedVars.begin(), definedVars.end(), reinterpret_cast<DefinedAllocator &>(mVectorAllocator))
33{
34    for (PabloAST * assign : mDefined) {
35        assign->addUser(this);
36        addUser(assign);
37    }
38}
39
40
41}
Note: See TracBrowser for help on using the repository browser.