daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
shannon.woods%transgaming.com@gtempaccount.com | c0d0c22 | 2013-04-13 03:29:36 +0000 | [diff] [blame] | 2 | // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 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 | // |
| 8 | // Definition of the in-memory high-level intermediate representation |
| 9 | // of shaders. This is a tree that parser creates. |
| 10 | // |
| 11 | // Nodes in the tree are defined as a hierarchy of classes derived from |
| 12 | // TIntermNode. Each is a node in a tree. There is no preset branching factor; |
| 13 | // each node can have it's own type of list of children. |
| 14 | // |
| 15 | |
| 16 | #ifndef __INTERMEDIATE_H |
| 17 | #define __INTERMEDIATE_H |
| 18 | |
daniel@transgaming.com | 0aa3b5a | 2012-11-28 19:43:24 +0000 | [diff] [blame] | 19 | #include "GLSLANG/ShaderLang.h" |
| 20 | |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 21 | #include "compiler/Common.h" |
| 22 | #include "compiler/Types.h" |
| 23 | #include "compiler/ConstantUnion.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 24 | |
| 25 | // |
| 26 | // Operators used by the high-level (parse tree) representation. |
| 27 | // |
| 28 | enum TOperator { |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 29 | EOpNull, // if in a node, should only mean a node is still being built |
| 30 | EOpSequence, // denotes a list of statements, or parameters, etc. |
| 31 | EOpFunctionCall, |
| 32 | EOpFunction, // For function definition |
| 33 | EOpParameters, // an aggregate listing the parameters to a function |
daniel@transgaming.com | d1acd1e | 2010-04-13 03:25:57 +0000 | [diff] [blame] | 34 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 35 | EOpDeclaration, |
daniel@transgaming.com | d1acd1e | 2010-04-13 03:25:57 +0000 | [diff] [blame] | 36 | EOpPrototype, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 37 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 38 | // |
| 39 | // Unary operators |
| 40 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 41 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 42 | EOpNegative, |
| 43 | EOpLogicalNot, |
| 44 | EOpVectorLogicalNot, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 45 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 46 | EOpPostIncrement, |
| 47 | EOpPostDecrement, |
| 48 | EOpPreIncrement, |
| 49 | EOpPreDecrement, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 50 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 51 | EOpConvIntToBool, |
Nicolas Capens | ab60b93 | 2013-06-05 10:31:21 -0400 | [diff] [blame] | 52 | EOpConvUIntToBool, |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 53 | EOpConvFloatToBool, |
| 54 | EOpConvBoolToFloat, |
| 55 | EOpConvIntToFloat, |
Nicolas Capens | ab60b93 | 2013-06-05 10:31:21 -0400 | [diff] [blame] | 56 | EOpConvUIntToFloat, |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 57 | EOpConvFloatToInt, |
| 58 | EOpConvBoolToInt, |
Nicolas Capens | ab60b93 | 2013-06-05 10:31:21 -0400 | [diff] [blame] | 59 | EOpConvUIntToInt, |
| 60 | EOpConvIntToUInt, |
| 61 | EOpConvFloatToUInt, |
| 62 | EOpConvBoolToUInt, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 63 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 64 | // |
| 65 | // binary operations |
| 66 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 67 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 68 | EOpAdd, |
| 69 | EOpSub, |
| 70 | EOpMul, |
| 71 | EOpDiv, |
| 72 | EOpEqual, |
| 73 | EOpNotEqual, |
| 74 | EOpVectorEqual, |
| 75 | EOpVectorNotEqual, |
| 76 | EOpLessThan, |
| 77 | EOpGreaterThan, |
| 78 | EOpLessThanEqual, |
| 79 | EOpGreaterThanEqual, |
| 80 | EOpComma, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 81 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 82 | EOpVectorTimesScalar, |
| 83 | EOpVectorTimesMatrix, |
| 84 | EOpMatrixTimesVector, |
| 85 | EOpMatrixTimesScalar, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 86 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 87 | EOpLogicalOr, |
| 88 | EOpLogicalXor, |
| 89 | EOpLogicalAnd, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 90 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 91 | EOpIndexDirect, |
| 92 | EOpIndexIndirect, |
| 93 | EOpIndexDirectStruct, |
shannonwoods@chromium.org | 5668c5d | 2013-05-30 00:11:48 +0000 | [diff] [blame] | 94 | EOpIndexDirectInterfaceBlock, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 95 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 96 | EOpVectorSwizzle, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 97 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 98 | // |
| 99 | // Built-in functions potentially mapped to operators |
| 100 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 101 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 102 | EOpRadians, |
| 103 | EOpDegrees, |
| 104 | EOpSin, |
| 105 | EOpCos, |
| 106 | EOpTan, |
| 107 | EOpAsin, |
| 108 | EOpAcos, |
| 109 | EOpAtan, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 110 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 111 | EOpPow, |
| 112 | EOpExp, |
| 113 | EOpLog, |
| 114 | EOpExp2, |
| 115 | EOpLog2, |
| 116 | EOpSqrt, |
| 117 | EOpInverseSqrt, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 118 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 119 | EOpAbs, |
| 120 | EOpSign, |
| 121 | EOpFloor, |
| 122 | EOpCeil, |
| 123 | EOpFract, |
| 124 | EOpMod, |
| 125 | EOpMin, |
| 126 | EOpMax, |
| 127 | EOpClamp, |
| 128 | EOpMix, |
| 129 | EOpStep, |
| 130 | EOpSmoothStep, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 131 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 132 | EOpLength, |
| 133 | EOpDistance, |
| 134 | EOpDot, |
| 135 | EOpCross, |
| 136 | EOpNormalize, |
| 137 | EOpFaceForward, |
| 138 | EOpReflect, |
| 139 | EOpRefract, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 140 | |
alokp@chromium.org | 0609889 | 2010-08-26 19:36:42 +0000 | [diff] [blame] | 141 | EOpDFdx, // Fragment only, OES_standard_derivatives extension |
| 142 | EOpDFdy, // Fragment only, OES_standard_derivatives extension |
| 143 | EOpFwidth, // Fragment only, OES_standard_derivatives extension |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 144 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 145 | EOpMatrixTimesMatrix, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 146 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 147 | EOpAny, |
| 148 | EOpAll, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 149 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 150 | // |
| 151 | // Branch |
| 152 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 153 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 154 | EOpKill, // Fragment only |
| 155 | EOpReturn, |
| 156 | EOpBreak, |
| 157 | EOpContinue, |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 158 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 159 | // |
| 160 | // Constructors |
| 161 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 162 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 163 | EOpConstructInt, |
Nicolas Capens | ab60b93 | 2013-06-05 10:31:21 -0400 | [diff] [blame] | 164 | EOpConstructUInt, |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 165 | EOpConstructBool, |
| 166 | EOpConstructFloat, |
| 167 | EOpConstructVec2, |
| 168 | EOpConstructVec3, |
| 169 | EOpConstructVec4, |
| 170 | EOpConstructBVec2, |
| 171 | EOpConstructBVec3, |
| 172 | EOpConstructBVec4, |
| 173 | EOpConstructIVec2, |
| 174 | EOpConstructIVec3, |
| 175 | EOpConstructIVec4, |
shannonwoods@chromium.org | 8c788e8 | 2013-05-30 00:20:21 +0000 | [diff] [blame] | 176 | EOpConstructUVec2, |
| 177 | EOpConstructUVec3, |
| 178 | EOpConstructUVec4, |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 179 | EOpConstructMat2, |
| 180 | EOpConstructMat3, |
| 181 | EOpConstructMat4, |
| 182 | EOpConstructStruct, |
| 183 | |
| 184 | // |
| 185 | // moves |
| 186 | // |
| 187 | |
| 188 | EOpAssign, |
| 189 | EOpInitialize, |
| 190 | EOpAddAssign, |
| 191 | EOpSubAssign, |
| 192 | EOpMulAssign, |
| 193 | EOpVectorTimesMatrixAssign, |
| 194 | EOpVectorTimesScalarAssign, |
| 195 | EOpMatrixTimesScalarAssign, |
| 196 | EOpMatrixTimesMatrixAssign, |
daniel@transgaming.com | b3077d0 | 2013-01-11 04:12:09 +0000 | [diff] [blame] | 197 | EOpDivAssign |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 198 | }; |
| 199 | |
alokp@chromium.org | b59a778 | 2010-11-24 18:38:33 +0000 | [diff] [blame] | 200 | extern const char* getOperatorString(TOperator op); |
| 201 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 202 | class TIntermTraverser; |
| 203 | class TIntermAggregate; |
| 204 | class TIntermBinary; |
daniel@transgaming.com | 4a35ef2 | 2010-04-08 03:51:06 +0000 | [diff] [blame] | 205 | class TIntermUnary; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 206 | class TIntermConstantUnion; |
| 207 | class TIntermSelection; |
| 208 | class TIntermTyped; |
| 209 | class TIntermSymbol; |
alokp@chromium.org | d88b773 | 2010-05-26 15:13:14 +0000 | [diff] [blame] | 210 | class TIntermLoop; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 211 | class TInfoSink; |
| 212 | |
| 213 | // |
| 214 | // Base class for the tree nodes |
| 215 | // |
| 216 | class TIntermNode { |
| 217 | public: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 218 | POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 219 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 220 | TIntermNode() : line(0) {} |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 221 | |
| 222 | TSourceLoc getLine() const { return line; } |
| 223 | void setLine(TSourceLoc l) { line = l; } |
| 224 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 225 | virtual void traverse(TIntermTraverser*) = 0; |
alokp@chromium.org | d88b773 | 2010-05-26 15:13:14 +0000 | [diff] [blame] | 226 | virtual TIntermTyped* getAsTyped() { return 0; } |
| 227 | virtual TIntermConstantUnion* getAsConstantUnion() { return 0; } |
| 228 | virtual TIntermAggregate* getAsAggregate() { return 0; } |
| 229 | virtual TIntermBinary* getAsBinaryNode() { return 0; } |
| 230 | virtual TIntermUnary* getAsUnaryNode() { return 0; } |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 231 | virtual TIntermSelection* getAsSelectionNode() { return 0; } |
alokp@chromium.org | d88b773 | 2010-05-26 15:13:14 +0000 | [diff] [blame] | 232 | virtual TIntermSymbol* getAsSymbolNode() { return 0; } |
| 233 | virtual TIntermLoop* getAsLoopNode() { return 0; } |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 234 | virtual ~TIntermNode() { } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 235 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 236 | protected: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 237 | TSourceLoc line; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 238 | }; |
| 239 | |
| 240 | // |
| 241 | // This is just to help yacc. |
| 242 | // |
| 243 | struct TIntermNodePair { |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 244 | TIntermNode* node1; |
| 245 | TIntermNode* node2; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 246 | }; |
| 247 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 248 | // |
| 249 | // Intermediate class for nodes that have a type. |
| 250 | // |
| 251 | class TIntermTyped : public TIntermNode { |
| 252 | public: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 253 | TIntermTyped(const TType& t) : type(t) { } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 254 | virtual TIntermTyped* getAsTyped() { return this; } |
alokp@chromium.org | dd037b2 | 2010-03-30 18:47:20 +0000 | [diff] [blame] | 255 | |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 256 | void setType(const TType& t) { type = t; } |
| 257 | const TType& getType() const { return type; } |
| 258 | TType* getTypePointer() { return &type; } |
| 259 | |
| 260 | TBasicType getBasicType() const { return type.getBasicType(); } |
| 261 | TQualifier getQualifier() const { return type.getQualifier(); } |
| 262 | TPrecision getPrecision() const { return type.getPrecision(); } |
shannonwoods@chromium.org | 09e0988 | 2013-05-30 00:18:25 +0000 | [diff] [blame] | 263 | int getCols() const { return type.getCols(); } |
| 264 | int getRows() const { return type.getRows(); } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 265 | int getNominalSize() const { return type.getNominalSize(); } |
shannonwoods@chromium.org | 09e0988 | 2013-05-30 00:18:25 +0000 | [diff] [blame] | 266 | int getSecondarySize() const { return type.getSecondarySize(); } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 267 | |
| 268 | bool isMatrix() const { return type.isMatrix(); } |
| 269 | bool isArray() const { return type.isArray(); } |
| 270 | bool isVector() const { return type.isVector(); } |
| 271 | bool isScalar() const { return type.isScalar(); } |
shannonwoods@chromium.org | 6b70991 | 2013-05-30 00:20:04 +0000 | [diff] [blame] | 272 | bool isScalarInt() const { return type.isScalarInt(); } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 273 | const char* getBasicString() const { return type.getBasicString(); } |
| 274 | const char* getQualifierString() const { return type.getQualifierString(); } |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 275 | TString getCompleteString() const { return type.getCompleteString(); } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 276 | |
daniel@transgaming.com | 3ca980a | 2012-12-20 21:11:52 +0000 | [diff] [blame] | 277 | int totalRegisterCount() const { return type.totalRegisterCount(); } |
| 278 | int elementRegisterCount() const { return type.elementRegisterCount(); } |
| 279 | int getArraySize() const { return type.getArraySize(); } |
| 280 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 281 | protected: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 282 | TType type; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 283 | }; |
| 284 | |
| 285 | // |
| 286 | // Handle for, do-while, and while loops. |
| 287 | // |
alokp@chromium.org | 5281355 | 2010-11-16 18:36:09 +0000 | [diff] [blame] | 288 | enum TLoopType { |
| 289 | ELoopFor, |
| 290 | ELoopWhile, |
daniel@transgaming.com | b3077d0 | 2013-01-11 04:12:09 +0000 | [diff] [blame] | 291 | ELoopDoWhile |
alokp@chromium.org | 5281355 | 2010-11-16 18:36:09 +0000 | [diff] [blame] | 292 | }; |
| 293 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 294 | class TIntermLoop : public TIntermNode { |
| 295 | public: |
alokp@chromium.org | 5281355 | 2010-11-16 18:36:09 +0000 | [diff] [blame] | 296 | TIntermLoop(TLoopType aType, |
| 297 | TIntermNode *aInit, TIntermTyped* aCond, TIntermTyped* aExpr, |
| 298 | TIntermNode* aBody) : |
| 299 | type(aType), |
| 300 | init(aInit), |
| 301 | cond(aCond), |
| 302 | expr(aExpr), |
zmo@google.com | 0b8d4eb | 2011-04-04 19:17:11 +0000 | [diff] [blame] | 303 | body(aBody), |
| 304 | unrollFlag(false) { } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 305 | |
alokp@chromium.org | d88b773 | 2010-05-26 15:13:14 +0000 | [diff] [blame] | 306 | virtual TIntermLoop* getAsLoopNode() { return this; } |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 307 | virtual void traverse(TIntermTraverser*); |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 308 | |
alokp@chromium.org | 5281355 | 2010-11-16 18:36:09 +0000 | [diff] [blame] | 309 | TLoopType getType() const { return type; } |
| 310 | TIntermNode* getInit() { return init; } |
| 311 | TIntermTyped* getCondition() { return cond; } |
| 312 | TIntermTyped* getExpression() { return expr; } |
| 313 | TIntermNode* getBody() { return body; } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 314 | |
zmo@google.com | 0b8d4eb | 2011-04-04 19:17:11 +0000 | [diff] [blame] | 315 | void setUnrollFlag(bool flag) { unrollFlag = flag; } |
| 316 | bool getUnrollFlag() { return unrollFlag; } |
| 317 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 318 | protected: |
alokp@chromium.org | 5281355 | 2010-11-16 18:36:09 +0000 | [diff] [blame] | 319 | TLoopType type; |
| 320 | TIntermNode* init; // for-loop initialization |
| 321 | TIntermTyped* cond; // loop exit condition |
| 322 | TIntermTyped* expr; // for-loop expression |
| 323 | TIntermNode* body; // loop body |
zmo@google.com | 0b8d4eb | 2011-04-04 19:17:11 +0000 | [diff] [blame] | 324 | |
| 325 | bool unrollFlag; // Whether the loop should be unrolled or not. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 326 | }; |
| 327 | |
| 328 | // |
| 329 | // Handle break, continue, return, and kill. |
| 330 | // |
| 331 | class TIntermBranch : public TIntermNode { |
| 332 | public: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 333 | TIntermBranch(TOperator op, TIntermTyped* e) : |
| 334 | flowOp(op), |
| 335 | expression(e) { } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 336 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 337 | virtual void traverse(TIntermTraverser*); |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 338 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 339 | TOperator getFlowOp() { return flowOp; } |
| 340 | TIntermTyped* getExpression() { return expression; } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 341 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 342 | protected: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 343 | TOperator flowOp; |
| 344 | TIntermTyped* expression; // non-zero except for "return exp;" statements |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 345 | }; |
| 346 | |
| 347 | // |
| 348 | // Nodes that correspond to symbols or constants in the source code. |
| 349 | // |
| 350 | class TIntermSymbol : public TIntermTyped { |
| 351 | public: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 352 | // if symbol is initialized as symbol(sym), the memory comes from the poolallocator of sym. If sym comes from |
| 353 | // per process globalpoolallocator, then it causes increased memory usage per compile |
| 354 | // it is essential to use "symbol = sym" to assign to symbol |
| 355 | TIntermSymbol(int i, const TString& sym, const TType& t) : |
zmo@google.com | fd747b8 | 2011-04-23 01:30:07 +0000 | [diff] [blame] | 356 | TIntermTyped(t), id(i) { symbol = sym; originalSymbol = sym; } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 357 | |
| 358 | int getId() const { return id; } |
| 359 | const TString& getSymbol() const { return symbol; } |
| 360 | |
zmo@google.com | fd747b8 | 2011-04-23 01:30:07 +0000 | [diff] [blame] | 361 | void setId(int newId) { id = newId; } |
| 362 | void setSymbol(const TString& sym) { symbol = sym; } |
| 363 | |
| 364 | const TString& getOriginalSymbol() const { return originalSymbol; } |
| 365 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 366 | virtual void traverse(TIntermTraverser*); |
| 367 | virtual TIntermSymbol* getAsSymbolNode() { return this; } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 368 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 369 | protected: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 370 | int id; |
| 371 | TString symbol; |
zmo@google.com | fd747b8 | 2011-04-23 01:30:07 +0000 | [diff] [blame] | 372 | TString originalSymbol; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 373 | }; |
| 374 | |
| 375 | class TIntermConstantUnion : public TIntermTyped { |
| 376 | public: |
alokp@chromium.org | 6ff56fd | 2010-05-05 16:37:50 +0000 | [diff] [blame] | 377 | TIntermConstantUnion(ConstantUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 378 | |
alokp@chromium.org | 6ff56fd | 2010-05-05 16:37:50 +0000 | [diff] [blame] | 379 | ConstantUnion* getUnionArrayPointer() const { return unionArrayPointer; } |
shannon.woods%transgaming.com@gtempaccount.com | c0d0c22 | 2013-04-13 03:29:36 +0000 | [diff] [blame] | 380 | |
| 381 | int getIConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getIConst() : 0; } |
Nicolas Capens | c0f7c61 | 2013-06-05 11:46:09 -0400 | [diff] [blame] | 382 | unsigned int getUConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getUConst() : 0; } |
shannon.woods%transgaming.com@gtempaccount.com | c0d0c22 | 2013-04-13 03:29:36 +0000 | [diff] [blame] | 383 | float getFConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getFConst() : 0.0f; } |
| 384 | bool getBConst(int index) const { return unionArrayPointer ? unionArrayPointer[index].getBConst() : false; } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 385 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 386 | virtual TIntermConstantUnion* getAsConstantUnion() { return this; } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 387 | virtual void traverse(TIntermTraverser*); |
| 388 | |
| 389 | TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&); |
| 390 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 391 | protected: |
alokp@chromium.org | 6ff56fd | 2010-05-05 16:37:50 +0000 | [diff] [blame] | 392 | ConstantUnion *unionArrayPointer; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 393 | }; |
| 394 | |
| 395 | // |
| 396 | // Intermediate class for node types that hold operators. |
| 397 | // |
| 398 | class TIntermOperator : public TIntermTyped { |
| 399 | public: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 400 | TOperator getOp() const { return op; } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 401 | void setOp(TOperator o) { op = o; } |
| 402 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 403 | bool modifiesState() const; |
| 404 | bool isConstructor() const; |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 405 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 406 | protected: |
daniel@transgaming.com | a5d7623 | 2010-05-17 09:58:47 +0000 | [diff] [blame] | 407 | TIntermOperator(TOperator o) : TIntermTyped(TType(EbtFloat, EbpUndefined)), op(o) {} |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 408 | TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o) {} |
| 409 | TOperator op; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 410 | }; |
| 411 | |
| 412 | // |
| 413 | // Nodes for all the basic binary math operators. |
| 414 | // |
| 415 | class TIntermBinary : public TIntermOperator { |
| 416 | public: |
daniel@transgaming.com | 4167cc9 | 2013-01-11 04:11:53 +0000 | [diff] [blame] | 417 | TIntermBinary(TOperator o) : TIntermOperator(o), addIndexClamp(false) {} |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 418 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 419 | virtual TIntermBinary* getAsBinaryNode() { return this; } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 420 | virtual void traverse(TIntermTraverser*); |
| 421 | |
| 422 | void setLeft(TIntermTyped* n) { left = n; } |
| 423 | void setRight(TIntermTyped* n) { right = n; } |
| 424 | TIntermTyped* getLeft() const { return left; } |
| 425 | TIntermTyped* getRight() const { return right; } |
| 426 | bool promote(TInfoSink&); |
| 427 | |
daniel@transgaming.com | 4167cc9 | 2013-01-11 04:11:53 +0000 | [diff] [blame] | 428 | void setAddIndexClamp() { addIndexClamp = true; } |
| 429 | bool getAddIndexClamp() { return addIndexClamp; } |
| 430 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 431 | protected: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 432 | TIntermTyped* left; |
| 433 | TIntermTyped* right; |
daniel@transgaming.com | 4167cc9 | 2013-01-11 04:11:53 +0000 | [diff] [blame] | 434 | |
| 435 | // If set to true, wrap any EOpIndexIndirect with a clamp to bounds. |
| 436 | bool addIndexClamp; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 437 | }; |
| 438 | |
| 439 | // |
| 440 | // Nodes for unary math operators. |
| 441 | // |
| 442 | class TIntermUnary : public TIntermOperator { |
| 443 | public: |
zmo@google.com | 32e9731 | 2011-08-24 01:03:11 +0000 | [diff] [blame] | 444 | TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0), useEmulatedFunction(false) {} |
zmo@google.com | e4eb991 | 2011-08-29 21:13:12 +0000 | [diff] [blame] | 445 | TIntermUnary(TOperator o) : TIntermOperator(o), operand(0), useEmulatedFunction(false) {} |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 446 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 447 | virtual void traverse(TIntermTraverser*); |
daniel@transgaming.com | 4a35ef2 | 2010-04-08 03:51:06 +0000 | [diff] [blame] | 448 | virtual TIntermUnary* getAsUnaryNode() { return this; } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 449 | |
| 450 | void setOperand(TIntermTyped* o) { operand = o; } |
| 451 | TIntermTyped* getOperand() { return operand; } |
| 452 | bool promote(TInfoSink&); |
| 453 | |
zmo@google.com | 32e9731 | 2011-08-24 01:03:11 +0000 | [diff] [blame] | 454 | void setUseEmulatedFunction() { useEmulatedFunction = true; } |
| 455 | bool getUseEmulatedFunction() { return useEmulatedFunction; } |
| 456 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 457 | protected: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 458 | TIntermTyped* operand; |
zmo@google.com | f420c42 | 2011-09-12 18:27:59 +0000 | [diff] [blame] | 459 | |
| 460 | // If set to true, replace the built-in function call with an emulated one |
| 461 | // to work around driver bugs. |
| 462 | bool useEmulatedFunction; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 463 | }; |
| 464 | |
| 465 | typedef TVector<TIntermNode*> TIntermSequence; |
| 466 | typedef TVector<int> TQualifierList; |
alokp@chromium.org | 8b851c6 | 2012-06-15 16:25:11 +0000 | [diff] [blame] | 467 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 468 | // |
| 469 | // Nodes that operate on an arbitrary sized set of children. |
| 470 | // |
| 471 | class TIntermAggregate : public TIntermOperator { |
| 472 | public: |
alokp@chromium.org | 8b851c6 | 2012-06-15 16:25:11 +0000 | [diff] [blame] | 473 | TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false), endLine(0), useEmulatedFunction(false) { } |
| 474 | TIntermAggregate(TOperator o) : TIntermOperator(o), useEmulatedFunction(false) { } |
| 475 | ~TIntermAggregate() { } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 476 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 477 | virtual TIntermAggregate* getAsAggregate() { return this; } |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 478 | virtual void traverse(TIntermTraverser*); |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 479 | |
| 480 | TIntermSequence& getSequence() { return sequence; } |
alokp@chromium.org | b19403a | 2010-09-08 17:56:26 +0000 | [diff] [blame] | 481 | |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 482 | void setName(const TString& n) { name = n; } |
| 483 | const TString& getName() const { return name; } |
| 484 | |
| 485 | void setUserDefined() { userDefined = true; } |
maxvujovic@gmail.com | 66ebd01 | 2012-05-30 22:18:11 +0000 | [diff] [blame] | 486 | bool isUserDefined() const { return userDefined; } |
alokp@chromium.org | b19403a | 2010-09-08 17:56:26 +0000 | [diff] [blame] | 487 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 488 | void setOptimize(bool o) { optimize = o; } |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 489 | bool getOptimize() { return optimize; } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 490 | void setDebug(bool d) { debug = d; } |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 491 | bool getDebug() { return debug; } |
alokp@chromium.org | 8b851c6 | 2012-06-15 16:25:11 +0000 | [diff] [blame] | 492 | |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 493 | void setEndLine(TSourceLoc line) { endLine = line; } |
| 494 | TSourceLoc getEndLine() const { return endLine; } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 495 | |
zmo@google.com | f420c42 | 2011-09-12 18:27:59 +0000 | [diff] [blame] | 496 | void setUseEmulatedFunction() { useEmulatedFunction = true; } |
| 497 | bool getUseEmulatedFunction() { return useEmulatedFunction; } |
| 498 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 499 | protected: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 500 | TIntermAggregate(const TIntermAggregate&); // disallow copy constructor |
| 501 | TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator |
| 502 | TIntermSequence sequence; |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 503 | TString name; |
| 504 | bool userDefined; // used for user defined function names |
alokp@chromium.org | b19403a | 2010-09-08 17:56:26 +0000 | [diff] [blame] | 505 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 506 | bool optimize; |
| 507 | bool debug; |
apatrick@chromium.org | 0f4cefe | 2011-01-26 19:30:57 +0000 | [diff] [blame] | 508 | TSourceLoc endLine; |
zmo@google.com | f420c42 | 2011-09-12 18:27:59 +0000 | [diff] [blame] | 509 | |
| 510 | // If set to true, replace the built-in function call with an emulated one |
| 511 | // to work around driver bugs. |
| 512 | bool useEmulatedFunction; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 513 | }; |
| 514 | |
| 515 | // |
| 516 | // For if tests. Simplified since there is no switch statement. |
| 517 | // |
| 518 | class TIntermSelection : public TIntermTyped { |
| 519 | public: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 520 | TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB) : |
daniel@transgaming.com | a5d7623 | 2010-05-17 09:58:47 +0000 | [diff] [blame] | 521 | TIntermTyped(TType(EbtVoid, EbpUndefined)), condition(cond), trueBlock(trueB), falseBlock(falseB) {} |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 522 | TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB, const TType& type) : |
| 523 | TIntermTyped(type), condition(cond), trueBlock(trueB), falseBlock(falseB) {} |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 524 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 525 | virtual void traverse(TIntermTraverser*); |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 526 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 527 | bool usesTernaryOperator() const { return getBasicType() != EbtVoid; } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 528 | TIntermNode* getCondition() const { return condition; } |
| 529 | TIntermNode* getTrueBlock() const { return trueBlock; } |
| 530 | TIntermNode* getFalseBlock() const { return falseBlock; } |
| 531 | TIntermSelection* getAsSelectionNode() { return this; } |
| 532 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 533 | protected: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 534 | TIntermTyped* condition; |
| 535 | TIntermNode* trueBlock; |
| 536 | TIntermNode* falseBlock; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 537 | }; |
| 538 | |
| 539 | enum Visit |
| 540 | { |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 541 | PreVisit, |
| 542 | InVisit, |
| 543 | PostVisit |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 544 | }; |
| 545 | |
| 546 | // |
| 547 | // For traversing the tree. User should derive from this, |
| 548 | // put their traversal specific data in it, and then pass |
| 549 | // it to a Traverse method. |
| 550 | // |
| 551 | // When using this, just fill in the methods for nodes you want visited. |
| 552 | // Return false from a pre-visit to skip visiting that node's subtree. |
| 553 | // |
| 554 | class TIntermTraverser |
| 555 | { |
| 556 | public: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 557 | POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 558 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 559 | TIntermTraverser(bool preVisit = true, bool inVisit = false, bool postVisit = false, bool rightToLeft = false) : |
| 560 | preVisit(preVisit), |
| 561 | inVisit(inVisit), |
| 562 | postVisit(postVisit), |
| 563 | rightToLeft(rightToLeft), |
| 564 | depth(0) {} |
maxvujovic@gmail.com | c6b3b3c | 2012-06-27 22:49:39 +0000 | [diff] [blame] | 565 | virtual ~TIntermTraverser() {}; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 566 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 567 | virtual void visitSymbol(TIntermSymbol*) {} |
| 568 | virtual void visitConstantUnion(TIntermConstantUnion*) {} |
| 569 | virtual bool visitBinary(Visit visit, TIntermBinary*) {return true;} |
| 570 | virtual bool visitUnary(Visit visit, TIntermUnary*) {return true;} |
| 571 | virtual bool visitSelection(Visit visit, TIntermSelection*) {return true;} |
| 572 | virtual bool visitAggregate(Visit visit, TIntermAggregate*) {return true;} |
| 573 | virtual bool visitLoop(Visit visit, TIntermLoop*) {return true;} |
| 574 | virtual bool visitBranch(Visit visit, TIntermBranch*) {return true;} |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 575 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 576 | void incrementDepth() {depth++;} |
| 577 | void decrementDepth() {depth--;} |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 578 | |
daniel@transgaming.com | 0aa3b5a | 2012-11-28 19:43:24 +0000 | [diff] [blame] | 579 | // Return the original name if hash function pointer is NULL; |
| 580 | // otherwise return the hashed name. |
| 581 | static TString hash(const TString& name, ShHashFunction64 hashFunction); |
| 582 | |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 583 | const bool preVisit; |
| 584 | const bool inVisit; |
| 585 | const bool postVisit; |
| 586 | const bool rightToLeft; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 587 | |
| 588 | protected: |
alokp@chromium.org | 2cf1771 | 2010-03-30 20:33:18 +0000 | [diff] [blame] | 589 | int depth; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 590 | }; |
| 591 | |
| 592 | #endif // __INTERMEDIATE_H |