Front-end: Add specialization-constant subtrees for const variables/symbols.
This commit is contained in:
parent
7cc0e2896e
commit
a5845766e0
8 changed files with 61 additions and 23 deletions
|
|
@ -612,25 +612,29 @@ public:
|
|||
// if symbol is initialized as symbol(sym), the memory comes from the pool allocator of sym. If sym comes from
|
||||
// per process threadPoolAllocator, then it causes increased memory usage per compile
|
||||
// it is essential to use "symbol = sym" to assign to symbol
|
||||
TIntermSymbol(int i, const TString& n, const TType& t) :
|
||||
TIntermTyped(t), id(i) { name = n;}
|
||||
TIntermSymbol(int i, const TString& n, const TType& t)
|
||||
: TIntermTyped(t), id(i), constSubtree(nullptr)
|
||||
{ name = n; }
|
||||
virtual int getId() const { return id; }
|
||||
virtual const TString& getName() const { return name; }
|
||||
virtual void traverse(TIntermTraverser*);
|
||||
virtual TIntermSymbol* getAsSymbolNode() { return this; }
|
||||
virtual const TIntermSymbol* getAsSymbolNode() const { return this; }
|
||||
void setConstArray(const TConstUnionArray& c) { unionArray = c; }
|
||||
const TConstUnionArray& getConstArray() const { return unionArray; }
|
||||
void setConstArray(const TConstUnionArray& c) { constArray = c; }
|
||||
const TConstUnionArray& getConstArray() const { return constArray; }
|
||||
void setConstSubtree(TIntermTyped* subtree) { constSubtree = subtree; }
|
||||
TIntermTyped* getConstSubtree() const { return constSubtree; }
|
||||
protected:
|
||||
int id; // the unique id of the symbol this node represents
|
||||
TString name; // the name of the symbol this node represents
|
||||
TConstUnionArray unionArray; // if the symbol is a front-end compile-time constant, this is its value
|
||||
TConstUnionArray constArray; // if the symbol is a front-end compile-time constant, this is its value
|
||||
TIntermTyped* constSubtree;
|
||||
};
|
||||
|
||||
class TIntermConstantUnion : public TIntermTyped {
|
||||
public:
|
||||
TIntermConstantUnion(const TConstUnionArray& ua, const TType& t) : TIntermTyped(t), unionArray(ua), literal(false) { }
|
||||
const TConstUnionArray& getConstArray() const { return unionArray; }
|
||||
TIntermConstantUnion(const TConstUnionArray& ua, const TType& t) : TIntermTyped(t), constArray(ua), literal(false) { }
|
||||
const TConstUnionArray& getConstArray() const { return constArray; }
|
||||
virtual TIntermConstantUnion* getAsConstantUnion() { return this; }
|
||||
virtual const TIntermConstantUnion* getAsConstantUnion() const { return this; }
|
||||
virtual void traverse(TIntermTraverser*);
|
||||
|
|
@ -640,7 +644,7 @@ public:
|
|||
void setExpression() { literal = false; }
|
||||
bool isLiteral() const { return literal; }
|
||||
protected:
|
||||
const TConstUnionArray unionArray;
|
||||
const TConstUnionArray constArray;
|
||||
bool literal; // true if node represents a literal in the source code
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue