| 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/ByteCode/) 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 |
|
| 17 |
#include "clang/Basic/TypeTraits.h" |
| 18 |
#include <cstdint> |
| 19 |
|
| 20 |
namespace llvm { |
| 21 |
class APFloat; |
| 22 |
class APInt; |
| 23 |
class APSInt; |
| 24 |
} |
| 25 |
namespace clang { |
| 26 |
class QualType; |
| 27 |
class LangOptions; |
| 28 |
class ASTContext; |
| 29 |
class CharUnits; |
| 30 |
class Expr; |
| 31 |
} // namespace clang |
| 32 |
using namespace clang; |
| 33 |
/// Values returned by __builtin_classify_type, chosen to match the values |
| 34 |
/// produced by GCC's builtin. |
| 35 |
enum class GCCTypeClass { |
| 36 |
None = -1, |
| 37 |
Void = 0, |
| 38 |
Integer = 1, |
| 39 |
// GCC reserves 2 for character types, but instead classifies them as |
| 40 |
// integers. |
| 41 |
Enum = 3, |
| 42 |
Bool = 4, |
| 43 |
Pointer = 5, |
| 44 |
// GCC reserves 6 for references, but appears to never use it (because |
| 45 |
// expressions never have reference type, presumably). |
| 46 |
PointerToDataMember = 7, |
| 47 |
RealFloat = 8, |
| 48 |
Complex = 9, |
| 49 |
// GCC reserves 10 for functions, but does not use it since GCC version 6 due |
| 50 |
// to decay to pointer. (Prior to version 6 it was only used in C++ mode). |
| 51 |
// GCC claims to reserve 11 for pointers to member functions, but *actually* |
| 52 |
// uses 12 for that purpose, same as for a class or struct. Maybe it |
| 53 |
// internally implements a pointer to member as a struct? Who knows. |
| 54 |
PointerToMemberFunction = 12, // Not a bug, see above. |
| 55 |
ClassOrStruct = 12, |
| 56 |
Union = 13, |
| 57 |
// GCC reserves 14 for arrays, but does not use it since GCC version 6 due to |
| 58 |
// decay to pointer. (Prior to version 6 it was only used in C++ mode). |
| 59 |
// GCC reserves 15 for strings, but actually uses 5 (pointer) for string |
| 60 |
// literals. |
| 61 |
// Lang = 16, |
| 62 |
// OpaqueType = 17, |
| 63 |
BitInt = 18, |
| 64 |
Vector = 19 |
| 65 |
}; |
| 66 |
|
| 67 |
GCCTypeClass EvaluateBuiltinClassifyType(QualType T, |
| 68 |
const LangOptions &LangOpts); |
| 69 |
|
| 70 |
void HandleComplexComplexMul(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C, |
| 71 |
llvm::APFloat D, llvm::APFloat &ResR, |
| 72 |
llvm::APFloat &ResI); |
| 73 |
void HandleComplexComplexDiv(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C, |
| 74 |
llvm::APFloat D, llvm::APFloat &ResR, |
| 75 |
llvm::APFloat &ResI); |
| 76 |
|
| 77 |
CharUnits GetAlignOfExpr(const ASTContext &Ctx, const Expr *E, |
| 78 |
UnaryExprOrTypeTrait ExprKind); |
| 79 |
|
| 80 |
uint8_t GFNIMultiplicativeInverse(uint8_t Byte); |
| 81 |
uint8_t GFNIMul(uint8_t AByte, uint8_t BByte); |
| 82 |
uint8_t GFNIAffine(uint8_t XByte, const llvm::APInt &AQword, |
| 83 |
const llvm::APSInt &Imm, bool Inverse = false); |
| 84 |
|
| 85 |
#endif |