1//===--- ExprConstShared.h - Shared consetxpr functionality ----*- 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// Shared functionality between the new constant expression
10// interpreter (AST/Interp/) and the current one (ExprConstant.cpp).
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H
15#define LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H
16
17namespace llvm {
18class APFloat;
19}
20namespace clang {
21class QualType;
22class LangOptions;
23} // namespace clang
24using namespace clang;
25/// Values returned by __builtin_classify_type, chosen to match the values
26/// produced by GCC's builtin.
27enum class GCCTypeClass {
28 None = -1,
29 Void = 0,
30 Integer = 1,
31 // GCC reserves 2 for character types, but instead classifies them as
32 // integers.
33 Enum = 3,
34 Bool = 4,
35 Pointer = 5,
36 // GCC reserves 6 for references, but appears to never use it (because
37 // expressions never have reference type, presumably).
38 PointerToDataMember = 7,
39 RealFloat = 8,
40 Complex = 9,
41 // GCC reserves 10 for functions, but does not use it since GCC version 6 due
42 // to decay to pointer. (Prior to version 6 it was only used in C++ mode).
43 // GCC claims to reserve 11 for pointers to member functions, but *actually*
44 // uses 12 for that purpose, same as for a class or struct. Maybe it
45 // internally implements a pointer to member as a struct? Who knows.
46 PointerToMemberFunction = 12, // Not a bug, see above.
47 ClassOrStruct = 12,
48 Union = 13,
49 // GCC reserves 14 for arrays, but does not use it since GCC version 6 due to
50 // decay to pointer. (Prior to version 6 it was only used in C++ mode).
51 // GCC reserves 15 for strings, but actually uses 5 (pointer) for string
52 // literals.
53 // Lang = 16,
54 // OpaqueType = 17,
55 BitInt = 18,
56 Vector = 19
57};
58
59GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
60 const LangOptions &LangOpts);
61
62void HandleComplexComplexMul(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C,
63 llvm::APFloat D, llvm::APFloat &ResR,
64 llvm::APFloat &ResI);
65void HandleComplexComplexDiv(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C,
66 llvm::APFloat D, llvm::APFloat &ResR,
67 llvm::APFloat &ResI);
68
69#endif
70