• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2002 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     EOpFma,
143 
144     EOpFloatBitsToInt,
145     EOpFloatBitsToUint,
146     EOpIntBitsToFloat,
147     EOpUintBitsToFloat,
148 
149     EOpFrexp,
150     EOpLdexp,
151 
152     EOpPackSnorm2x16,
153     EOpPackUnorm2x16,
154     EOpPackHalf2x16,
155     EOpUnpackSnorm2x16,
156     EOpUnpackUnorm2x16,
157     EOpUnpackHalf2x16,
158 
159     EOpPackUnorm4x8,
160     EOpPackSnorm4x8,
161     EOpUnpackUnorm4x8,
162     EOpUnpackSnorm4x8,
163 
164     EOpLength,
165     EOpDistance,
166     EOpDot,
167     EOpCross,
168     EOpNormalize,
169     EOpFaceforward,
170     EOpReflect,
171     EOpRefract,
172 
173     EOpDFdx,    // Fragment only, OES_standard_derivatives extension
174     EOpDFdy,    // Fragment only, OES_standard_derivatives extension
175     EOpFwidth,  // Fragment only, OES_standard_derivatives extension
176 
177     EOpMulMatrixComponentWise,
178     EOpOuterProduct,
179     EOpTranspose,
180     EOpDeterminant,
181     EOpInverse,
182 
183     EOpAny,
184     EOpAll,
185     EOpLogicalNotComponentWise,
186 
187     EOpBitfieldExtract,
188     EOpBitfieldInsert,
189     EOpBitfieldReverse,
190     EOpBitCount,
191     EOpFindLSB,
192     EOpFindMSB,
193     EOpUaddCarry,
194     EOpUsubBorrow,
195     EOpUmulExtended,
196     EOpImulExtended,
197 
198     //
199     // Branch
200     //
201 
202     EOpKill,  // Fragment only
203     EOpReturn,
204     EOpBreak,
205     EOpContinue,
206 
207     //
208     // Constructor
209     //
210 
211     EOpConstruct,
212 
213     //
214     // moves
215     //
216 
217     EOpAssign,
218     EOpInitialize,
219     EOpAddAssign,
220     EOpSubAssign,
221 
222     EOpMulAssign,
223     EOpVectorTimesMatrixAssign,
224     EOpVectorTimesScalarAssign,
225     EOpMatrixTimesScalarAssign,
226     EOpMatrixTimesMatrixAssign,
227 
228     EOpDivAssign,
229     EOpIModAssign,
230     EOpBitShiftLeftAssign,
231     EOpBitShiftRightAssign,
232     EOpBitwiseAndAssign,
233     EOpBitwiseXorAssign,
234     EOpBitwiseOrAssign,
235 
236     // barriers
237     EOpBarrier,
238     EOpMemoryBarrier,
239     EOpMemoryBarrierAtomicCounter,
240     EOpMemoryBarrierBuffer,
241     EOpMemoryBarrierImage,
242     EOpMemoryBarrierShared,
243     EOpGroupMemoryBarrier,
244 
245     // Atomic functions
246     EOpAtomicAdd,
247     EOpAtomicMin,
248     EOpAtomicMax,
249     EOpAtomicAnd,
250     EOpAtomicOr,
251     EOpAtomicXor,
252     EOpAtomicExchange,
253     EOpAtomicCompSwap,
254 
255     // Geometry only
256     EOpEmitVertex,
257     EOpEndPrimitive,
258 
259     // Desktop GLSL functions
260     EOpFTransform,
261     EOpPackDouble2x32,
262     EOpUnpackDouble2x32,
263 };
264 
265 // Returns the string corresponding to the operator in GLSL
266 const char *GetOperatorString(TOperator op);
267 
268 // Say whether or not a binary or unary operation changes the value of a variable.
269 bool IsAssignment(TOperator op);
270 
271 // Say whether or not an operator represents an atomic function.
272 bool IsAtomicFunction(TOperator op);
273 
274 #endif  // COMPILER_TRANSLATOR_OPERATOR_H_
275