source: icGREP/icgrep-devel/icgrep/pablo/ps_if.h @ 4888

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

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

File size: 1.6 KB
Line 
1/*
2 *  Copyright (c) 2014 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#ifndef PS_IF_H
8#define PS_IF_H
9
10#include <pablo/pabloAST.h>
11#include <vector>
12
13namespace pablo {
14
15class Assign;
16
17class If : public Statement {
18    friend class PabloBlock;
19    friend class Statement;
20    friend class Simplifier;
21public:
22    using DefinedAllocator = VectorAllocator::rebind<Assign *>::other;
23    using DefinedVars = std::vector<Assign *, DefinedAllocator>;
24
25    static inline bool classof(const PabloAST * e) {
26        return e->getClassTypeId() == ClassTypeId::If;
27    }
28    static inline bool classof(const void *) {
29        return false;
30    }
31    virtual ~If() {
32        mDefined.clear();
33    }
34    inline PabloAST * getCondition() const {
35        return getOperand(0);
36    }
37    inline PabloBlock * getBody() {
38        return mBody;
39    }
40    inline  PabloBlock * getBody() const {
41        return mBody;
42    }
43    PabloBlock * setBody(PabloBlock * body);
44    inline const DefinedVars & getDefined() const {
45        return mDefined;
46    }
47    inline DefinedVars & getDefined() {
48        return mDefined;
49    }
50    void addDefined(Assign * def);
51    DefinedVars::iterator removeDefined(Assign * def);
52protected:
53    If(PabloAST * expr, const std::initializer_list<Assign *> definedVars, PabloBlock * body);
54    If(PabloAST * expr, const std::vector<Assign *> & definedVars, PabloBlock * body);
55private:
56    PabloBlock *    mBody;
57    DefinedVars     mDefined;
58};
59
60}
61
62#endif // PS_IF_H
63
64
Note: See TracBrowser for help on using the repository browser.