clang 22.0.0git
ExprConstShared.h
Go to the documentation of this file.
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
18#include <cstdint>
19
20namespace llvm {
21class APFloat;
22class APInt;
23class APSInt;
24}
25namespace clang {
26class QualType;
27class LangOptions;
28class ASTContext;
29class CharUnits;
30class Expr;
31} // namespace clang
32using namespace clang;
33/// Values returned by __builtin_classify_type, chosen to match the values
34/// produced by GCC's builtin.
35enum class GCCTypeClass {
36 None = -1,
37 Void = 0,
39 // GCC reserves 2 for character types, but instead classifies them as
40 // integers.
41 Enum = 3,
42 Bool = 4,
44 // GCC reserves 6 for references, but appears to never use it (because
45 // expressions never have reference type, presumably).
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.
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
68 const LangOptions &LangOpts);
69
70void HandleComplexComplexMul(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C,
71 llvm::APFloat D, llvm::APFloat &ResR,
72 llvm::APFloat &ResI);
73void HandleComplexComplexDiv(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C,
74 llvm::APFloat D, llvm::APFloat &ResR,
75 llvm::APFloat &ResI);
76
77CharUnits GetAlignOfExpr(const ASTContext &Ctx, const Expr *E,
78 UnaryExprOrTypeTrait ExprKind);
79
80uint8_t GFNIMultiplicativeInverse(uint8_t Byte);
81uint8_t GFNIMul(uint8_t AByte, uint8_t BByte);
82uint8_t GFNIAffine(uint8_t XByte, const llvm::APInt &AQword,
83 const llvm::APSInt &Imm, bool Inverse = false);
84
85#endif
llvm::APSInt APSInt
Definition Compiler.cpp:24
uint8_t GFNIAffine(uint8_t XByte, const llvm::APInt &AQword, const llvm::APSInt &Imm, bool Inverse=false)
CharUnits GetAlignOfExpr(const ASTContext &Ctx, const Expr *E, UnaryExprOrTypeTrait ExprKind)
GCCTypeClass EvaluateBuiltinClassifyType(QualType T, const LangOptions &LangOpts)
EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way as GCC.
void HandleComplexComplexMul(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C, llvm::APFloat D, llvm::APFloat &ResR, llvm::APFloat &ResI)
GCCTypeClass
Values returned by __builtin_classify_type, chosen to match the values produced by GCC's builtin.
uint8_t GFNIMul(uint8_t AByte, uint8_t BByte)
void HandleComplexComplexDiv(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C, llvm::APFloat D, llvm::APFloat &ResR, llvm::APFloat &ResI)
uint8_t GFNIMultiplicativeInverse(uint8_t Byte)
Defines enumerations for the type traits support.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:220
CharUnits - This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
This represents one expression.
Definition Expr.h:112
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A (possibly-)qualified type.
Definition TypeBase.h:937
llvm::APFloat APFloat
Definition Floating.h:27
llvm::APInt APInt
Definition FixedPoint.h:19
The JSON file list parser is used to communicate input to InstallAPI.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition TypeTraits.h:51
const FunctionProtoType * T
@ None
The alignment was not explicit in code.
Definition ASTContext.h:178
@ Union
The "union" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5876
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5882
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30