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     EOpFunctionCall,
17     EOpParameters,      // an aggregate listing the parameters to a function
18 
19     EOpInvariantDeclaration, // Specialized declarations for attributing invariance
20     EOpPrototype,
21 
22     //
23     // Unary operators
24     //
25 
26     EOpNegative,
27     EOpPositive,
28     EOpLogicalNot,
29     EOpVectorLogicalNot,
30     EOpBitwiseNot,
31 
32     EOpPostIncrement,
33     EOpPostDecrement,
34     EOpPreIncrement,
35     EOpPreDecrement,
36 
37     //
38     // binary operations
39     //
40 
41     EOpAdd,
42     EOpSub,
43     EOpMul,
44     EOpDiv,
45     EOpIMod,
46     EOpEqual,
47     EOpNotEqual,
48     EOpVectorEqual,
49     EOpVectorNotEqual,
50     EOpLessThan,
51     EOpGreaterThan,
52     EOpLessThanEqual,
53     EOpGreaterThanEqual,
54     EOpComma,
55 
56     EOpVectorTimesScalar,
57     EOpVectorTimesMatrix,
58     EOpMatrixTimesVector,
59     EOpMatrixTimesScalar,
60 
61     EOpLogicalOr,
62     EOpLogicalXor,
63     EOpLogicalAnd,
64 
65     EOpBitShiftLeft,
66     EOpBitShiftRight,
67 
68     EOpBitwiseAnd,
69     EOpBitwiseXor,
70     EOpBitwiseOr,
71 
72     EOpIndexDirect,
73     EOpIndexIndirect,
74     EOpIndexDirectStruct,
75     EOpIndexDirectInterfaceBlock,
76 
77     //
78     // Built-in functions potentially mapped to operators
79     //
80 
81     EOpRadians,
82     EOpDegrees,
83     EOpSin,
84     EOpCos,
85     EOpTan,
86     EOpAsin,
87     EOpAcos,
88     EOpAtan,
89 
90     EOpSinh,
91     EOpCosh,
92     EOpTanh,
93     EOpAsinh,
94     EOpAcosh,
95     EOpAtanh,
96 
97     EOpPow,
98     EOpExp,
99     EOpLog,
100     EOpExp2,
101     EOpLog2,
102     EOpSqrt,
103     EOpInverseSqrt,
104 
105     EOpAbs,
106     EOpSign,
107     EOpFloor,
108     EOpTrunc,
109     EOpRound,
110     EOpRoundEven,
111     EOpCeil,
112     EOpFract,
113     EOpMod,
114     EOpModf,
115     EOpMin,
116     EOpMax,
117     EOpClamp,
118     EOpMix,
119     EOpStep,
120     EOpSmoothStep,
121     EOpIsNan,
122     EOpIsInf,
123 
124     EOpFloatBitsToInt,
125     EOpFloatBitsToUint,
126     EOpIntBitsToFloat,
127     EOpUintBitsToFloat,
128 
129     EOpPackSnorm2x16,
130     EOpPackUnorm2x16,
131     EOpPackHalf2x16,
132     EOpUnpackSnorm2x16,
133     EOpUnpackUnorm2x16,
134     EOpUnpackHalf2x16,
135 
136     EOpLength,
137     EOpDistance,
138     EOpDot,
139     EOpCross,
140     EOpNormalize,
141     EOpFaceForward,
142     EOpReflect,
143     EOpRefract,
144 
145     EOpDFdx,            // Fragment only, OES_standard_derivatives extension
146     EOpDFdy,            // Fragment only, OES_standard_derivatives extension
147     EOpFwidth,          // Fragment only, OES_standard_derivatives extension
148 
149     EOpMatrixTimesMatrix,
150 
151     EOpOuterProduct,
152     EOpTranspose,
153     EOpDeterminant,
154     EOpInverse,
155 
156     EOpAny,
157     EOpAll,
158 
159     //
160     // Branch
161     //
162 
163     EOpKill,            // Fragment only
164     EOpReturn,
165     EOpBreak,
166     EOpContinue,
167 
168     //
169     // Constructors
170     //
171 
172     EOpConstructInt,
173     EOpConstructUInt,
174     EOpConstructBool,
175     EOpConstructFloat,
176     EOpConstructVec2,
177     EOpConstructVec3,
178     EOpConstructVec4,
179     EOpConstructBVec2,
180     EOpConstructBVec3,
181     EOpConstructBVec4,
182     EOpConstructIVec2,
183     EOpConstructIVec3,
184     EOpConstructIVec4,
185     EOpConstructUVec2,
186     EOpConstructUVec3,
187     EOpConstructUVec4,
188     EOpConstructMat2,
189     EOpConstructMat2x3,
190     EOpConstructMat2x4,
191     EOpConstructMat3x2,
192     EOpConstructMat3,
193     EOpConstructMat3x4,
194     EOpConstructMat4x2,
195     EOpConstructMat4x3,
196     EOpConstructMat4,
197     EOpConstructStruct,
198 
199     //
200     // moves
201     //
202 
203     EOpAssign,
204     EOpInitialize,
205     EOpAddAssign,
206     EOpSubAssign,
207 
208     EOpMulAssign,
209     EOpVectorTimesMatrixAssign,
210     EOpVectorTimesScalarAssign,
211     EOpMatrixTimesScalarAssign,
212     EOpMatrixTimesMatrixAssign,
213 
214     EOpDivAssign,
215     EOpIModAssign,
216     EOpBitShiftLeftAssign,
217     EOpBitShiftRightAssign,
218     EOpBitwiseAndAssign,
219     EOpBitwiseXorAssign,
220     EOpBitwiseOrAssign
221 };
222 
223 // Returns the string corresponding to the operator in GLSL
224 const char* GetOperatorString(TOperator op);
225 
226 // Say whether or not a binary or unary operation changes the value of a variable.
227 bool IsAssignment(TOperator op);
228 
229 #endif  // COMPILER_TRANSLATOR_OPERATOR_H_
230