1 // 2 // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 #ifndef _LOCAL_INTERMEDIATE_INCLUDED_ 8 #define _LOCAL_INTERMEDIATE_INCLUDED_ 9 10 #include "compiler/translator/intermediate.h" 11 12 struct TVectorFields { 13 int offsets[4]; 14 int num; 15 }; 16 17 // 18 // Set of helper functions to help parse and build the tree. 19 // 20 class TInfoSink; 21 class TIntermediate { 22 public: 23 POOL_ALLOCATOR_NEW_DELETE(); 24 TIntermediate(TInfoSink& i) : infoSink(i) { } 25 26 TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TSourceLoc&); 27 TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*); 28 TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&); 29 TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&); 30 TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, const TSourceLoc&); 31 TIntermTyped* addUnaryMath(TOperator op, TIntermNode* child, const TSourceLoc&); 32 TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, const TSourceLoc&); 33 TIntermAggregate* makeAggregate(TIntermNode* node, const TSourceLoc&); 34 TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, const TSourceLoc&); 35 TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, const TSourceLoc&); 36 TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc&); 37 TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc&); 38 TIntermConstantUnion* addConstantUnion(ConstantUnion*, const TType&, const TSourceLoc&); 39 TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ; 40 bool parseConstTree(const TSourceLoc&, TIntermNode*, ConstantUnion*, TOperator, TType, bool singleConstantParam = false); 41 TIntermNode* addLoop(TLoopType, TIntermNode*, TIntermTyped*, TIntermTyped*, TIntermNode*, const TSourceLoc&); 42 TIntermBranch* addBranch(TOperator, const TSourceLoc&); 43 TIntermBranch* addBranch(TOperator, TIntermTyped*, const TSourceLoc&); 44 TIntermTyped* addSwizzle(TVectorFields&, const TSourceLoc&); 45 bool postProcess(TIntermNode*); 46 void remove(TIntermNode*); 47 void outputTree(TIntermNode*); 48 49 private: 50 void operator=(TIntermediate&); // prevent assignments 51 52 TInfoSink& infoSink; 53 }; 54 55 #endif // _LOCAL_INTERMEDIATE_INCLUDED_ 56