15f757f3fSDimitry Andric //===--- ExprConstShared.h - Shared consetxpr functionality ----*- C++ -*-===// 25f757f3fSDimitry Andric // 35f757f3fSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 45f757f3fSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 55f757f3fSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 65f757f3fSDimitry Andric // 75f757f3fSDimitry Andric //===----------------------------------------------------------------------===// 85f757f3fSDimitry Andric // 95f757f3fSDimitry Andric // Shared functionality between the new constant expression 105f757f3fSDimitry Andric // interpreter (AST/Interp/) and the current one (ExprConstant.cpp). 115f757f3fSDimitry Andric // 125f757f3fSDimitry Andric //===----------------------------------------------------------------------===// 135f757f3fSDimitry Andric 145f757f3fSDimitry Andric #ifndef LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H 155f757f3fSDimitry Andric #define LLVM_CLANG_LIB_AST_EXPRCONSTSHARED_H 165f757f3fSDimitry Andric 17*0fca6ea1SDimitry Andric namespace llvm { 18*0fca6ea1SDimitry Andric class APFloat; 19*0fca6ea1SDimitry Andric } 205f757f3fSDimitry Andric namespace clang { 215f757f3fSDimitry Andric class QualType; 225f757f3fSDimitry Andric class LangOptions; 235f757f3fSDimitry Andric } // namespace clang 245f757f3fSDimitry Andric using namespace clang; 255f757f3fSDimitry Andric /// Values returned by __builtin_classify_type, chosen to match the values 265f757f3fSDimitry Andric /// produced by GCC's builtin. 275f757f3fSDimitry Andric enum class GCCTypeClass { 285f757f3fSDimitry Andric None = -1, 295f757f3fSDimitry Andric Void = 0, 305f757f3fSDimitry Andric Integer = 1, 315f757f3fSDimitry Andric // GCC reserves 2 for character types, but instead classifies them as 325f757f3fSDimitry Andric // integers. 335f757f3fSDimitry Andric Enum = 3, 345f757f3fSDimitry Andric Bool = 4, 355f757f3fSDimitry Andric Pointer = 5, 365f757f3fSDimitry Andric // GCC reserves 6 for references, but appears to never use it (because 375f757f3fSDimitry Andric // expressions never have reference type, presumably). 385f757f3fSDimitry Andric PointerToDataMember = 7, 395f757f3fSDimitry Andric RealFloat = 8, 405f757f3fSDimitry Andric Complex = 9, 415f757f3fSDimitry Andric // GCC reserves 10 for functions, but does not use it since GCC version 6 due 425f757f3fSDimitry Andric // to decay to pointer. (Prior to version 6 it was only used in C++ mode). 435f757f3fSDimitry Andric // GCC claims to reserve 11 for pointers to member functions, but *actually* 445f757f3fSDimitry Andric // uses 12 for that purpose, same as for a class or struct. Maybe it 455f757f3fSDimitry Andric // internally implements a pointer to member as a struct? Who knows. 465f757f3fSDimitry Andric PointerToMemberFunction = 12, // Not a bug, see above. 475f757f3fSDimitry Andric ClassOrStruct = 12, 485f757f3fSDimitry Andric Union = 13, 495f757f3fSDimitry Andric // GCC reserves 14 for arrays, but does not use it since GCC version 6 due to 505f757f3fSDimitry Andric // decay to pointer. (Prior to version 6 it was only used in C++ mode). 515f757f3fSDimitry Andric // GCC reserves 15 for strings, but actually uses 5 (pointer) for string 525f757f3fSDimitry Andric // literals. 535f757f3fSDimitry Andric // Lang = 16, 545f757f3fSDimitry Andric // OpaqueType = 17, 555f757f3fSDimitry Andric BitInt = 18, 565f757f3fSDimitry Andric Vector = 19 575f757f3fSDimitry Andric }; 585f757f3fSDimitry Andric 595f757f3fSDimitry Andric GCCTypeClass EvaluateBuiltinClassifyType(QualType T, 605f757f3fSDimitry Andric const LangOptions &LangOpts); 615f757f3fSDimitry Andric 62*0fca6ea1SDimitry Andric void HandleComplexComplexMul(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C, 63*0fca6ea1SDimitry Andric llvm::APFloat D, llvm::APFloat &ResR, 64*0fca6ea1SDimitry Andric llvm::APFloat &ResI); 65*0fca6ea1SDimitry Andric void HandleComplexComplexDiv(llvm::APFloat A, llvm::APFloat B, llvm::APFloat C, 66*0fca6ea1SDimitry Andric llvm::APFloat D, llvm::APFloat &ResR, 67*0fca6ea1SDimitry Andric llvm::APFloat &ResI); 68*0fca6ea1SDimitry Andric 695f757f3fSDimitry Andric #endif 70