]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/clang/include/clang/AST/OperationKinds.def
zfs: merge openzfs/zfs@92e0d9d18 (zfs-2.1-release) into stable/13
[FreeBSD/FreeBSD.git] / contrib / llvm-project / clang / include / clang / AST / OperationKinds.def
1 //===--- OperationKinds.def - Operations Database ---------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file enumerates the different kinds of operations that can be
10 // performed by various expressions.
11 //
12 //===----------------------------------------------------------------------===//
13 //
14 /// @file OperationKinds.def
15 ///
16 /// In this file, each of the C/C++ operations is enumerated CAST_OPERATION,
17 /// BINARY_OPERATION or UNARY_OPERATION macro, each of which can be specified by
18 /// the code including this file.
19 ///
20 /// Macros had one or two arguments:
21 ///
22 /// Name: The name of the operation. Name (prefixed with CK_, UO_ or BO_) will
23 /// be the name of the corresponding enumerator (see OperationsKinds.h).
24 ///
25 /// Spelling: A string that provides a canonical spelling for the operation.
26
27 #ifndef CAST_OPERATION
28 #  define CAST_OPERATION(Name)
29 #endif
30
31 #ifndef BINARY_OPERATION
32 #  define BINARY_OPERATION(Name, Spelling)
33 #endif
34
35 #ifndef UNARY_OPERATION
36 #  define UNARY_OPERATION(Name, Spelling)
37 #endif
38
39 //===- Cast Operations  ---------------------------------------------------===//
40
41 /// CK_Dependent - A conversion which cannot yet be analyzed because
42 /// either the expression or target type is dependent.  These are
43 /// created only for explicit casts; dependent ASTs aren't required
44 /// to even approximately type-check.
45 ///   (T*) malloc(sizeof(T))
46 ///   reinterpret_cast<intptr_t>(A<T>::alloc());
47 CAST_OPERATION(Dependent)
48
49 /// CK_BitCast - A conversion which causes a bit pattern of one type
50 /// to be reinterpreted as a bit pattern of another type.  Generally
51 /// the operands must have equivalent size and unrelated types.
52 ///
53 /// The pointer conversion char* -> int* is a bitcast.  A conversion
54 /// from any pointer type to a C pointer type is a bitcast unless
55 /// it's actually BaseToDerived or DerivedToBase.  A conversion to a
56 /// block pointer or ObjC pointer type is a bitcast only if the
57 /// operand has the same type kind; otherwise, it's one of the
58 /// specialized casts below.
59 ///
60 /// Vector coercions are bitcasts.
61 CAST_OPERATION(BitCast)
62
63 /// CK_LValueBitCast - A conversion which reinterprets the address of
64 /// an l-value as an l-value of a different kind.  Used for
65 /// reinterpret_casts of l-value expressions to reference types.
66 ///    bool b; reinterpret_cast<char&>(b) = 'a';
67 CAST_OPERATION(LValueBitCast)
68
69 /// CK_LValueToRValueBitCast - A conversion that causes us to reinterpret the
70 /// object representation of an lvalue as an rvalue. Created by
71 /// __builtin_bit_cast.
72 CAST_OPERATION(LValueToRValueBitCast)
73
74 /// CK_LValueToRValue - A conversion which causes the extraction of
75 /// an r-value from the operand gl-value.  The result of an r-value
76 /// conversion is always unqualified.
77 CAST_OPERATION(LValueToRValue)
78
79 /// CK_NoOp - A conversion which does not affect the type other than
80 /// (possibly) adding qualifiers or removing noexcept.
81 ///   int    -> int
82 ///   char** -> const char * const *
83 ///   void () noexcept -> void ()
84 CAST_OPERATION(NoOp)
85
86 /// CK_BaseToDerived - A conversion from a C++ class pointer/reference
87 /// to a derived class pointer/reference.
88 ///   B *b = static_cast<B*>(a);
89 CAST_OPERATION(BaseToDerived)
90
91 /// CK_DerivedToBase - A conversion from a C++ class pointer
92 /// to a base class pointer.
93 ///   A *a = new B();
94 CAST_OPERATION(DerivedToBase)
95
96 /// CK_UncheckedDerivedToBase - A conversion from a C++ class
97 /// pointer/reference to a base class that can assume that the
98 /// derived pointer is not null.
99 ///   const A &a = B();
100 ///   b->method_from_a();
101 CAST_OPERATION(UncheckedDerivedToBase)
102
103 /// CK_Dynamic - A C++ dynamic_cast.
104 CAST_OPERATION(Dynamic)
105
106 /// CK_ToUnion - The GCC cast-to-union extension.
107 ///   int   -> union { int x; float y; }
108 ///   float -> union { int x; float y; }
109 CAST_OPERATION(ToUnion)
110
111 /// CK_ArrayToPointerDecay - Array to pointer decay.
112 ///   int[10] -> int*
113 ///   char[5][6] -> char(*)[6]
114 CAST_OPERATION(ArrayToPointerDecay)
115
116 /// CK_FunctionToPointerDecay - Function to pointer decay.
117 ///   void(int) -> void(*)(int)
118 CAST_OPERATION(FunctionToPointerDecay)
119
120 /// CK_NullToPointer - Null pointer constant to pointer, ObjC
121 /// pointer, or block pointer.
122 ///   (void*) 0
123 ///   void (^block)() = 0;
124 CAST_OPERATION(NullToPointer)
125
126 /// CK_NullToMemberPointer - Null pointer constant to member pointer.
127 ///   int A::*mptr = 0;
128 ///   int (A::*fptr)(int) = nullptr;
129 CAST_OPERATION(NullToMemberPointer)
130
131 /// CK_BaseToDerivedMemberPointer - Member pointer in base class to
132 /// member pointer in derived class.
133 ///   int B::*mptr = &A::member;
134 CAST_OPERATION(BaseToDerivedMemberPointer)
135
136 /// CK_DerivedToBaseMemberPointer - Member pointer in derived class to
137 /// member pointer in base class.
138 ///   int A::*mptr = static_cast<int A::*>(&B::member);
139 CAST_OPERATION(DerivedToBaseMemberPointer)
140
141 /// CK_MemberPointerToBoolean - Member pointer to boolean.  A check
142 /// against the null member pointer.
143 CAST_OPERATION(MemberPointerToBoolean)
144
145 /// CK_ReinterpretMemberPointer - Reinterpret a member pointer as a
146 /// different kind of member pointer.  C++ forbids this from
147 /// crossing between function and object types, but otherwise does
148 /// not restrict it.  However, the only operation that is permitted
149 /// on a "punned" member pointer is casting it back to the original
150 /// type, which is required to be a lossless operation (although
151 /// many ABIs do not guarantee this on all possible intermediate types).
152 CAST_OPERATION(ReinterpretMemberPointer)
153
154 /// CK_UserDefinedConversion - Conversion using a user defined type
155 /// conversion function.
156 ///    struct A { operator int(); }; int i = int(A());
157 CAST_OPERATION(UserDefinedConversion)
158
159 /// CK_ConstructorConversion - Conversion by constructor.
160 ///    struct A { A(int); }; A a = A(10);
161 CAST_OPERATION(ConstructorConversion)
162
163 /// CK_IntegralToPointer - Integral to pointer.  A special kind of
164 /// reinterpreting conversion.  Applies to normal, ObjC, and block
165 /// pointers.
166 ///    (char*) 0x1001aab0
167 ///    reinterpret_cast<int*>(0)
168 CAST_OPERATION(IntegralToPointer)
169
170 /// CK_PointerToIntegral - Pointer to integral.  A special kind of
171 /// reinterpreting conversion.  Applies to normal, ObjC, and block
172 /// pointers.
173 ///    (intptr_t) "help!"
174 CAST_OPERATION(PointerToIntegral)
175
176 /// CK_PointerToBoolean - Pointer to boolean conversion.  A check
177 /// against null.  Applies to normal, ObjC, and block pointers.
178 CAST_OPERATION(PointerToBoolean)
179
180 /// CK_ToVoid - Cast to void, discarding the computed value.
181 ///    (void) malloc(2048)
182 CAST_OPERATION(ToVoid)
183
184 /// CK_MatrixCast - A cast between matrix types of the same dimensions.
185 CAST_OPERATION(MatrixCast)
186
187 /// CK_VectorSplat - A conversion from an arithmetic type to a
188 /// vector of that element type.  Fills all elements ("splats") with
189 /// the source value.
190 ///    __attribute__((ext_vector_type(4))) int v = 5;
191 CAST_OPERATION(VectorSplat)
192
193 /// CK_IntegralCast - A cast between integral types (other than to
194 /// boolean).  Variously a bitcast, a truncation, a sign-extension,
195 /// or a zero-extension.
196 ///    long l = 5;
197 ///    (unsigned) i
198 CAST_OPERATION(IntegralCast)
199
200 /// CK_IntegralToBoolean - Integral to boolean.  A check against zero.
201 ///    (bool) i
202 CAST_OPERATION(IntegralToBoolean)
203
204 /// CK_IntegralToFloating - Integral to floating point.
205 ///    float f = i;
206 CAST_OPERATION(IntegralToFloating)
207
208 /// CK_FloatingToFixedPoint - Floating to fixed point.
209 ///    _Accum a = f;
210 CAST_OPERATION(FloatingToFixedPoint)
211
212 /// CK_FixedPointToFloating - Fixed point to floating.
213 ///    (float) 2.5k
214 CAST_OPERATION(FixedPointToFloating)
215
216 /// CK_FixedPointCast - Fixed point to fixed point.
217 ///    (_Accum) 0.5r
218 CAST_OPERATION(FixedPointCast)
219
220 /// CK_FixedPointToIntegral - Fixed point to integral.
221 ///    (int) 2.0k
222 CAST_OPERATION(FixedPointToIntegral)
223
224 /// CK_IntegralToFixedPoint - Integral to a fixed point.
225 ///    (_Accum) 2
226 CAST_OPERATION(IntegralToFixedPoint)
227
228 /// CK_FixedPointToBoolean - Fixed point to boolean.
229 ///    (bool) 0.5r
230 CAST_OPERATION(FixedPointToBoolean)
231
232 /// CK_FloatingToIntegral - Floating point to integral.  Rounds
233 /// towards zero, discarding any fractional component.
234 ///    (int) f
235 CAST_OPERATION(FloatingToIntegral)
236
237 /// CK_FloatingToBoolean - Floating point to boolean.
238 ///    (bool) f
239 CAST_OPERATION(FloatingToBoolean)
240
241 // CK_BooleanToSignedIntegral - Convert a boolean to -1 or 0 for true and
242 // false, respectively.
243 CAST_OPERATION(BooleanToSignedIntegral)
244
245 /// CK_FloatingCast - Casting between floating types of different size.
246 ///    (double) f
247 ///    (float) ld
248 CAST_OPERATION(FloatingCast)
249
250 /// CK_CPointerToObjCPointerCast - Casting a C pointer kind to an
251 /// Objective-C pointer.
252 CAST_OPERATION(CPointerToObjCPointerCast)
253
254 /// CK_BlockPointerToObjCPointerCast - Casting a block pointer to an
255 /// ObjC pointer.
256 CAST_OPERATION(BlockPointerToObjCPointerCast)
257
258 /// CK_AnyPointerToBlockPointerCast - Casting any non-block pointer
259 /// to a block pointer.  Block-to-block casts are bitcasts.
260 CAST_OPERATION(AnyPointerToBlockPointerCast)
261
262 /// Converting between two Objective-C object types, which
263 /// can occur when performing reference binding to an Objective-C
264 /// object.
265 CAST_OPERATION(ObjCObjectLValueCast)
266
267 /// A conversion of a floating point real to a floating point
268 /// complex of the original type.  Injects the value as the real
269 /// component with a zero imaginary component.
270 ///   float -> _Complex float
271 CAST_OPERATION(FloatingRealToComplex)
272
273 /// Converts a floating point complex to floating point real
274 /// of the source's element type.  Just discards the imaginary
275 /// component.
276 ///   _Complex long double -> long double
277 CAST_OPERATION(FloatingComplexToReal)
278
279 /// Converts a floating point complex to bool by comparing
280 /// against 0+0i.
281 CAST_OPERATION(FloatingComplexToBoolean)
282
283 /// Converts between different floating point complex types.
284 ///   _Complex float -> _Complex double
285 CAST_OPERATION(FloatingComplexCast)
286
287 /// Converts from a floating complex to an integral complex.
288 ///   _Complex float -> _Complex int
289 CAST_OPERATION(FloatingComplexToIntegralComplex)
290
291 /// Converts from an integral real to an integral complex
292 /// whose element type matches the source.  Injects the value as
293 /// the real component with a zero imaginary component.
294 ///   long -> _Complex long
295 CAST_OPERATION(IntegralRealToComplex)
296
297 /// Converts an integral complex to an integral real of the
298 /// source's element type by discarding the imaginary component.
299 ///   _Complex short -> short
300 CAST_OPERATION(IntegralComplexToReal)
301
302 /// Converts an integral complex to bool by comparing against
303 /// 0+0i.
304 CAST_OPERATION(IntegralComplexToBoolean)
305
306 /// Converts between different integral complex types.
307 ///   _Complex char -> _Complex long long
308 ///   _Complex unsigned int -> _Complex signed int
309 CAST_OPERATION(IntegralComplexCast)
310
311 /// Converts from an integral complex to a floating complex.
312 ///   _Complex unsigned -> _Complex float
313 CAST_OPERATION(IntegralComplexToFloatingComplex)
314
315 /// [ARC] Produces a retainable object pointer so that it may
316 /// be consumed, e.g. by being passed to a consuming parameter.
317 /// Calls objc_retain.
318 CAST_OPERATION(ARCProduceObject)
319
320 /// [ARC] Consumes a retainable object pointer that has just
321 /// been produced, e.g. as the return value of a retaining call.
322 /// Enters a cleanup to call objc_release at some indefinite time.
323 CAST_OPERATION(ARCConsumeObject)
324
325 /// [ARC] Reclaim a retainable object pointer object that may
326 /// have been produced and autoreleased as part of a function return
327 /// sequence.
328 CAST_OPERATION(ARCReclaimReturnedObject)
329
330 /// [ARC] Causes a value of block type to be copied to the
331 /// heap, if it is not already there.  A number of other operations
332 /// in ARC cause blocks to be copied; this is for cases where that
333 /// would not otherwise be guaranteed, such as when casting to a
334 /// non-block pointer type.
335 CAST_OPERATION(ARCExtendBlockObject)
336
337 /// Converts from _Atomic(T) to T.
338 CAST_OPERATION(AtomicToNonAtomic)
339 /// Converts from T to _Atomic(T).
340 CAST_OPERATION(NonAtomicToAtomic)
341
342 /// Causes a block literal to by copied to the heap and then
343 /// autoreleased.
344 ///
345 /// This particular cast kind is used for the conversion from a C++11
346 /// lambda expression to a block pointer.
347 CAST_OPERATION(CopyAndAutoreleaseBlockObject)
348
349 // Convert a builtin function to a function pointer; only allowed in the
350 // callee of a call expression.
351 CAST_OPERATION(BuiltinFnToFnPtr)
352
353 // Convert a zero value for OpenCL opaque types initialization (event_t,
354 // queue_t, etc.)
355 CAST_OPERATION(ZeroToOCLOpaqueType)
356
357 // Convert a pointer to a different address space.
358 CAST_OPERATION(AddressSpaceConversion)
359
360 // Convert an integer initializer to an OpenCL sampler.
361 CAST_OPERATION(IntToOCLSampler)
362
363 //===- Binary Operations  -------------------------------------------------===//
364 // Operators listed in order of precedence.
365 // Note that additions to this should also update the StmtVisitor class and
366 // BinaryOperator::getOverloadedOperator.
367
368 // [C++ 5.5] Pointer-to-member operators.
369 BINARY_OPERATION(PtrMemD, ".*")
370 BINARY_OPERATION(PtrMemI, "->*")
371 // [C99 6.5.5] Multiplicative operators.
372 BINARY_OPERATION(Mul, "*")
373 BINARY_OPERATION(Div, "/")
374 BINARY_OPERATION(Rem, "%")
375 // [C99 6.5.6] Additive operators.
376 BINARY_OPERATION(Add, "+")
377 BINARY_OPERATION(Sub, "-")
378 // [C99 6.5.7] Bitwise shift operators.
379 BINARY_OPERATION(Shl, "<<")
380 BINARY_OPERATION(Shr, ">>")
381 // C++20 [expr.spaceship] Three-way comparison operator.
382 BINARY_OPERATION(Cmp, "<=>")
383 // [C99 6.5.8] Relational operators.
384 BINARY_OPERATION(LT, "<")
385 BINARY_OPERATION(GT, ">")
386 BINARY_OPERATION(LE, "<=")
387 BINARY_OPERATION(GE, ">=")
388 // [C99 6.5.9] Equality operators.
389 BINARY_OPERATION(EQ, "==")
390 BINARY_OPERATION(NE, "!=")
391 // [C99 6.5.10] Bitwise AND operator.
392 BINARY_OPERATION(And, "&")
393 // [C99 6.5.11] Bitwise XOR operator.
394 BINARY_OPERATION(Xor, "^")
395 // [C99 6.5.12] Bitwise OR operator.
396 BINARY_OPERATION(Or, "|")
397 // [C99 6.5.13] Logical AND operator.
398 BINARY_OPERATION(LAnd, "&&")
399 // [C99 6.5.14] Logical OR operator.
400 BINARY_OPERATION(LOr, "||")
401 // [C99 6.5.16] Assignment operators.
402 BINARY_OPERATION(Assign, "=")
403 BINARY_OPERATION(MulAssign, "*=")
404 BINARY_OPERATION(DivAssign, "/=")
405 BINARY_OPERATION(RemAssign, "%=")
406 BINARY_OPERATION(AddAssign, "+=")
407 BINARY_OPERATION(SubAssign, "-=")
408 BINARY_OPERATION(ShlAssign, "<<=")
409 BINARY_OPERATION(ShrAssign, ">>=")
410 BINARY_OPERATION(AndAssign, "&=")
411 BINARY_OPERATION(XorAssign, "^=")
412 BINARY_OPERATION(OrAssign, "|=")
413 // [C99 6.5.17] Comma operator.
414 BINARY_OPERATION(Comma, ",")
415
416
417 //===- Unary Operations ---------------------------------------------------===//
418 // Note that additions to this should also update the StmtVisitor class and
419 // UnaryOperator::getOverloadedOperator.
420
421 // [C99 6.5.2.4] Postfix increment and decrement
422 UNARY_OPERATION(PostInc, "++")
423 UNARY_OPERATION(PostDec, "--")
424 // [C99 6.5.3.1] Prefix increment and decrement
425 UNARY_OPERATION(PreInc, "++")
426 UNARY_OPERATION(PreDec, "--")
427 // [C99 6.5.3.2] Address and indirection
428 UNARY_OPERATION(AddrOf, "&")
429 UNARY_OPERATION(Deref, "*")
430 // [C99 6.5.3.3] Unary arithmetic
431 UNARY_OPERATION(Plus, "+")
432 UNARY_OPERATION(Minus, "-")
433 UNARY_OPERATION(Not, "~")
434 UNARY_OPERATION(LNot, "!")
435 // "__real expr"/"__imag expr" Extension.
436 UNARY_OPERATION(Real, "__real")
437 UNARY_OPERATION(Imag, "__imag")
438 // __extension__ marker.
439 UNARY_OPERATION(Extension, "__extension__")
440 // [C++ Coroutines] co_await operator
441 UNARY_OPERATION(Coawait, "co_await")
442
443 #undef CAST_OPERATION
444 #undef BINARY_OPERATION
445 #undef UNARY_OPERATION