| 1 | // |
| 2 | // Copyright (c) 2002-2015 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 COMPILER_TRANSLATOR_OPERATOR_H_ |
| 8 | #define COMPILER_TRANSLATOR_OPERATOR_H_ |
| 9 | |
| 10 | // |
| 11 | // Operators used by the high-level (parse tree) representation. |
| 12 | // |
| 13 | enum TOperator |
| 14 | { |
| 15 | EOpNull, // if in a node, should only mean a node is still being built |
| 16 | |
| 17 | // Call a function defined in the AST. This might be a user-defined function or a function |
| 18 | // inserted by an AST transformation. |
| 19 | EOpCallFunctionInAST, |
| 20 | |
| 21 | // Call an internal helper function with a raw implementation - the implementation can't be |
| 22 | // subject to AST transformations. Raw functions have a few constraints to keep them compatible |
| 23 | // with AST traversers: |
| 24 | // * They should not return arrays. |
| 25 | // * They should not have out parameters. |
| 26 | EOpCallInternalRawFunction, |
| 27 | |
| 28 | // Call a built-in function like a texture or image function. |
| 29 | EOpCallBuiltInFunction, |
| 30 | |
| 31 | // |
| 32 | // Unary operators |
| 33 | // |
| 34 | |
| 35 | EOpNegative, |
| 36 | EOpPositive, |
| 37 | EOpLogicalNot, |
| 38 | EOpBitwiseNot, |
| 39 | |
| 40 | EOpPostIncrement, |
| 41 | EOpPostDecrement, |
| 42 | EOpPreIncrement, |
| 43 | EOpPreDecrement, |
| 44 | |
| 45 | EOpArrayLength, |
| 46 | |
| 47 | // |
| 48 | // binary operations (ones with special GLSL syntax are used in TIntermBinary nodes, others in |
| 49 | // TIntermAggregate nodes) |
| 50 | // |
| 51 | |
| 52 | EOpAdd, |
| 53 | EOpSub, |
| 54 | EOpMul, |
| 55 | EOpDiv, |
| 56 | EOpIMod, |
| 57 | |
| 58 | EOpEqual, |
| 59 | EOpNotEqual, |
| 60 | EOpLessThan, |
| 61 | EOpGreaterThan, |
| 62 | EOpLessThanEqual, |
| 63 | EOpGreaterThanEqual, |
| 64 | |
| 65 | EOpEqualComponentWise, |
| 66 | EOpNotEqualComponentWise, |
| 67 | EOpLessThanComponentWise, |
| 68 | EOpLessThanEqualComponentWise, |
| 69 | EOpGreaterThanComponentWise, |
| 70 | EOpGreaterThanEqualComponentWise, |
| 71 | |
| 72 | EOpComma, |
| 73 | |
| 74 | EOpVectorTimesScalar, |
| 75 | EOpVectorTimesMatrix, |
| 76 | EOpMatrixTimesVector, |
| 77 | EOpMatrixTimesScalar, |
| 78 | EOpMatrixTimesMatrix, |
| 79 | |
| 80 | EOpLogicalOr, |
| 81 | EOpLogicalXor, |
| 82 | EOpLogicalAnd, |
| 83 | |
| 84 | EOpBitShiftLeft, |
| 85 | EOpBitShiftRight, |
| 86 | |
| 87 | EOpBitwiseAnd, |
| 88 | EOpBitwiseXor, |
| 89 | EOpBitwiseOr, |
| 90 | |
| 91 | EOpIndexDirect, |
| 92 | EOpIndexIndirect, |
| 93 | EOpIndexDirectStruct, |
| 94 | EOpIndexDirectInterfaceBlock, |
| 95 | |
| 96 | // |
| 97 | // Built-in functions mapped to operators (either unary or with multiple parameters) |
| 98 | // |
| 99 | |
| 100 | EOpRadians, |
| 101 | EOpDegrees, |
| 102 | EOpSin, |
| 103 | EOpCos, |
| 104 | EOpTan, |
| 105 | EOpAsin, |
| 106 | EOpAcos, |
| 107 | EOpAtan, |
| 108 | |
| 109 | EOpSinh, |
| 110 | EOpCosh, |
| 111 | EOpTanh, |
| 112 | EOpAsinh, |
| 113 | EOpAcosh, |
| 114 | EOpAtanh, |
| 115 | |
| 116 | EOpPow, |
| 117 | EOpExp, |
| 118 | EOpLog, |
| 119 | EOpExp2, |
| 120 | EOpLog2, |
| 121 | EOpSqrt, |
| 122 | EOpInversesqrt, |
| 123 | |
| 124 | EOpAbs, |
| 125 | EOpSign, |
| 126 | EOpFloor, |
| 127 | EOpTrunc, |
| 128 | EOpRound, |
| 129 | EOpRoundEven, |
| 130 | EOpCeil, |
| 131 | EOpFract, |
| 132 | EOpMod, |
| 133 | EOpModf, |
| 134 | EOpMin, |
| 135 | EOpMax, |
| 136 | EOpClamp, |
| 137 | EOpMix, |
| 138 | EOpStep, |
| 139 | EOpSmoothstep, |
| 140 | EOpIsnan, |
| 141 | EOpIsinf, |
| 142 | |
| 143 | EOpFloatBitsToInt, |
| 144 | EOpFloatBitsToUint, |
| 145 | EOpIntBitsToFloat, |
| 146 | EOpUintBitsToFloat, |
| 147 | |
| 148 | EOpFrexp, |
| 149 | EOpLdexp, |
| 150 | |
| 151 | EOpPackSnorm2x16, |
| 152 | EOpPackUnorm2x16, |
| 153 | EOpPackHalf2x16, |
| 154 | EOpUnpackSnorm2x16, |
| 155 | EOpUnpackUnorm2x16, |
| 156 | EOpUnpackHalf2x16, |
| 157 | |
| 158 | EOpPackUnorm4x8, |
| 159 | EOpPackSnorm4x8, |
| 160 | EOpUnpackUnorm4x8, |
| 161 | EOpUnpackSnorm4x8, |
| 162 | |
| 163 | EOpLength, |
| 164 | EOpDistance, |
| 165 | EOpDot, |
| 166 | EOpCross, |
| 167 | EOpNormalize, |
| 168 | EOpFaceforward, |
| 169 | EOpReflect, |
| 170 | EOpRefract, |
| 171 | |
| 172 | EOpDFdx, // Fragment only, OES_standard_derivatives extension |
| 173 | EOpDFdy, // Fragment only, OES_standard_derivatives extension |
| 174 | EOpFwidth, // Fragment only, OES_standard_derivatives extension |
| 175 | |
| 176 | EOpMulMatrixComponentWise, |
| 177 | EOpOuterProduct, |
| 178 | EOpTranspose, |
| 179 | EOpDeterminant, |
| 180 | EOpInverse, |
| 181 | |
| 182 | EOpAny, |
| 183 | EOpAll, |
| 184 | EOpLogicalNotComponentWise, |
| 185 | |
| 186 | , |
| 187 | EOpBitfieldInsert, |
| 188 | EOpBitfieldReverse, |
| 189 | EOpBitCount, |
| 190 | EOpFindLSB, |
| 191 | EOpFindMSB, |
| 192 | EOpUaddCarry, |
| 193 | EOpUsubBorrow, |
| 194 | EOpUmulExtended, |
| 195 | EOpImulExtended, |
| 196 | |
| 197 | // |
| 198 | // Branch |
| 199 | // |
| 200 | |
| 201 | EOpKill, // Fragment only |
| 202 | EOpReturn, |
| 203 | EOpBreak, |
| 204 | EOpContinue, |
| 205 | |
| 206 | // |
| 207 | // Constructor |
| 208 | // |
| 209 | |
| 210 | EOpConstruct, |
| 211 | |
| 212 | // |
| 213 | // moves |
| 214 | // |
| 215 | |
| 216 | EOpAssign, |
| 217 | EOpInitialize, |
| 218 | EOpAddAssign, |
| 219 | EOpSubAssign, |
| 220 | |
| 221 | EOpMulAssign, |
| 222 | EOpVectorTimesMatrixAssign, |
| 223 | EOpVectorTimesScalarAssign, |
| 224 | EOpMatrixTimesScalarAssign, |
| 225 | EOpMatrixTimesMatrixAssign, |
| 226 | |
| 227 | EOpDivAssign, |
| 228 | EOpIModAssign, |
| 229 | EOpBitShiftLeftAssign, |
| 230 | EOpBitShiftRightAssign, |
| 231 | EOpBitwiseAndAssign, |
| 232 | EOpBitwiseXorAssign, |
| 233 | EOpBitwiseOrAssign, |
| 234 | |
| 235 | // barriers |
| 236 | EOpBarrier, |
| 237 | EOpMemoryBarrier, |
| 238 | EOpMemoryBarrierAtomicCounter, |
| 239 | EOpMemoryBarrierBuffer, |
| 240 | EOpMemoryBarrierImage, |
| 241 | EOpMemoryBarrierShared, |
| 242 | EOpGroupMemoryBarrier, |
| 243 | |
| 244 | // Atomic functions |
| 245 | EOpAtomicAdd, |
| 246 | EOpAtomicMin, |
| 247 | EOpAtomicMax, |
| 248 | EOpAtomicAnd, |
| 249 | EOpAtomicOr, |
| 250 | EOpAtomicXor, |
| 251 | EOpAtomicExchange, |
| 252 | EOpAtomicCompSwap, |
| 253 | |
| 254 | // Geometry only |
| 255 | EOpEmitVertex, |
| 256 | EOpEndPrimitive |
| 257 | }; |
| 258 | |
| 259 | // Returns the string corresponding to the operator in GLSL |
| 260 | const char *GetOperatorString(TOperator op); |
| 261 | |
| 262 | // Say whether or not a binary or unary operation changes the value of a variable. |
| 263 | bool IsAssignment(TOperator op); |
| 264 | |
| 265 | // Say whether or not an operator represents an atomic function. |
| 266 | bool IsAtomicFunction(TOperator op); |
| 267 | |
| 268 | #endif // COMPILER_TRANSLATOR_OPERATOR_H_ |
| 269 | |