source: icGREP/icgrep-devel/icgrep/pablo/pe_var.h @ 5299

Last change on this file since 5299 was 5283, checked in by nmedfort, 2 years ago

Optimized Symbol Generation (and fixed potential bug that could allow duplicate names being constructed); made PabloKernel? extend PabloAST (temporarily removed PabloAST::getName() to avoid diamond problem); added an internal scalar to PabloKernel? struct for each Count to avoid InOut? output scalar variable problem; allowed CodeMotionPass? to move code within the same scope but across a branch statement. Began work on separating Kernels into either Block-Oriented or Segment-Oriented kernels.

File size: 2.3 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 PE_VAR_H
8#define PE_VAR_H
9
10#include <pablo/pabloAST.h>
11#include <pablo/pe_string.h>
12
13namespace pablo {
14
15class Var : public PabloAST {
16    friend class PabloBlock;
17    friend class PabloAST;
18    friend class PabloKernel;
19    friend class Statement;
20public:
21
22    enum Attribute {
23        None = 0
24        , ReadOnly = 1
25        , ReadNone = 2
26    };
27
28    static inline bool classof(const PabloAST * e) {
29        return e->getClassTypeId() == ClassTypeId::Var;
30    }
31    static inline bool classof(const void *) {
32        return false;
33    }
34    bool isReadOnly() const {
35        return mAttribute & Attribute::ReadOnly;
36    }
37    void setReadOnly(const bool value = true) {
38        if (value) {
39            mAttribute |= Attribute::ReadOnly;
40        } else {
41            mAttribute &= ~(Attribute::ReadOnly);
42        }
43    }
44    bool isReadNone() const {
45        return mAttribute & Attribute::ReadNone;
46    }
47    void setReadNone(const bool value = true) {
48        if (value) {
49            mAttribute |= Attribute::ReadNone;
50        } else {
51            mAttribute &= ~(Attribute::ReadNone);
52        }
53    }
54
55    const String & getName() const noexcept {
56        return *mName;
57    }
58
59protected:
60    Var(const String * name, llvm::Type * const type, Allocator & allocator, const Attribute attr = Attribute::None)
61    : PabloAST(ClassTypeId::Var, type, allocator)
62    , mAttribute(attr)
63    , mName(name) {
64
65    }
66private:
67    unsigned mAttribute;
68    const String * const mName;
69};
70
71class Extract : public Statement {
72    friend class PabloBlock;
73public:
74    static inline bool classof(const PabloAST * e) {
75        return e->getClassTypeId() == ClassTypeId::Extract;
76    }
77    static inline bool classof(const void *) {
78        return false;
79    }
80    virtual ~Extract(){
81    }
82    inline PabloAST * getArray() const {
83        return getOperand(0);
84    }
85    inline PabloAST * getIndex() const {
86        return getOperand(1);
87    }
88protected:
89    Extract(PabloAST * array, PabloAST * const index, const String * const name, llvm::Type * type, Allocator & allocator)
90    : Statement(ClassTypeId::Extract, type, {array, index}, name, allocator) {
91
92    }
93};
94
95}
96
97#endif // PE_VAR_H
98
99
Note: See TracBrowser for help on using the repository browser.