clang 22.0.0git
InterpBuiltin.cpp File Reference
#include "../ExprConstShared.h"
#include "Boolean.h"
#include "EvalEmitter.h"
#include "Interp.h"
#include "InterpBuiltinBitCast.h"
#include "PrimType.h"
#include "clang/AST/OSLog.h"
#include "clang/AST/RecordLayout.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/SipHash.h"

Go to the source code of this file.

Namespaces

namespace  clang
 The JSON file list parser is used to communicate input to InstallAPI.
namespace  clang::interp

Functions

static LLVM_ATTRIBUTE_UNUSED bool clang::interp::isNoopBuiltin (unsigned ID)
static void clang::interp::discard (InterpStack &Stk, PrimType T)
static APSInt clang::interp::popToAPSInt (InterpStack &Stk, PrimType T)
static void clang::interp::pushInteger (InterpState &S, const APSInt &Val, QualType QT)
 Pushes Val on the stack as the type given by QT.
template<typename T>
static void clang::interp::pushInteger (InterpState &S, T Val, QualType QT)
static void clang::interp::assignInteger (InterpState &S, const Pointer &Dest, PrimType ValueT, const APSInt &Value)
static QualType clang::interp::getElemType (const Pointer &P)
static void clang::interp::diagnoseNonConstexprBuiltin (InterpState &S, CodePtr OpPC, unsigned ID)
static llvm::APSInt clang::interp::convertBoolVectorToInt (const Pointer &Val)
static bool clang::interp::interp__builtin_is_constant_evaluated (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_assume (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_strcmp (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned ID)
static bool clang::interp::interp__builtin_strlen (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned ID)
static bool clang::interp::interp__builtin_nan (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, bool Signaling)
static bool clang::interp::interp__builtin_inf (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_copysign (InterpState &S, CodePtr OpPC, const InterpFrame *Frame)
static bool clang::interp::interp__builtin_fmin (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, bool IsNumBuiltin)
static bool clang::interp::interp__builtin_fmax (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, bool IsNumBuiltin)
static bool clang::interp::interp__builtin_isnan (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
 Defined as __builtin_isnan(...), to accommodate the fact that it can take a float, double, long double, etc.
static bool clang::interp::interp__builtin_issignaling (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_isinf (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, bool CheckSign, const CallExpr *Call)
static bool clang::interp::interp__builtin_isfinite (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_isnormal (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_issubnormal (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_iszero (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_signbit (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp_floating_comparison (InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned ID)
static bool clang::interp::interp__builtin_isfpclass (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
 First parameter to __builtin_isfpclass is the floating value, the second one is an integral value.
static bool clang::interp::interp__builtin_fpclassify (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
 Five int values followed by one floating value.
static Floating clang::interp::abs (InterpState &S, const Floating &In)
static bool clang::interp::interp__builtin_fabs (InterpState &S, CodePtr OpPC, const InterpFrame *Frame)
static bool clang::interp::interp__builtin_abs (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_popcount (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_parity (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_clrsb (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_bitreverse (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_classify_type (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_expect (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_rotate (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, bool Right)
 rotateleft(value, amount)
static bool clang::interp::interp__builtin_ffs (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_addressof (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_move (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_eh_return_data_regno (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_overflowop (InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned BuiltinOp)
static bool clang::interp::interp__builtin_carryop (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinOp)
 Three integral values followed by a pointer (lhs, rhs, carry, carryOut).
static bool clang::interp::interp__builtin_clz (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinOp)
static bool clang::interp::interp__builtin_ctz (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinID)
static bool clang::interp::interp__builtin_bswap (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_atomic_lock_free (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinOp)
 bool __atomic_always_lock_free(size_t, void const volatile*) bool __atomic_is_lock_free(size_t, void const volatile*)
static bool clang::interp::interp__builtin_c11_atomic_is_lock_free (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
 bool __c11_atomic_is_lock_free(size_t)
static bool clang::interp::interp__builtin_complex (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
 __builtin_complex(Float A, float B);
static bool clang::interp::interp__builtin_is_aligned_up_down (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinOp)
 __builtin_is_aligned() __builtin_align_up() __builtin_align_down() The first parameter is either an integer or a pointer.
static bool clang::interp::interp__builtin_assume_aligned (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
 __builtin_assume_aligned(Ptr, Alignment[, ExtraOffset])
static bool clang::interp::interp__builtin_ia32_bextr (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_ia32_bzhi (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_ia32_lzcnt (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_ia32_tzcnt (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_ia32_pdep (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_ia32_pext (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_ia32_addcarry_subborrow (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinOp)
 (CarryIn, LHS, RHS, Result)
static bool clang::interp::interp__builtin_os_log_format_buffer_size (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_ptrauth_string_discriminator (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_operator_new (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_operator_delete (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_arithmetic_fence (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_vector_reduce (InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned ID)
static bool clang::interp::interp__builtin_elementwise_abs (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinID)
static bool clang::interp::interp__builtin_elementwise_popcount (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinID)
 Can be called with an integer or vector as the first and only parameter.
static bool clang::interp::interp__builtin_elementwise_countzeroes (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned BuiltinID)
 Can be called with an integer or vector as the first and only parameter.
static bool clang::interp::interp__builtin_memcpy (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned ID)
static bool clang::interp::isOneByteCharacterType (QualType T)
 Determine if T is a character type for which we guarantee that sizeof(T) == 1.
static bool clang::interp::interp__builtin_memcmp (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call, unsigned ID)
static bool clang::interp::interp__builtin_memchr (InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned ID)
static std::optional< unsignedclang::interp::computeFullDescSize (const ASTContext &ASTCtx, const Descriptor *Desc)
static unsigned clang::interp::computePointerOffset (const ASTContext &ASTCtx, const Pointer &Ptr)
 Compute the byte offset of Ptr in the full declaration.
static bool clang::interp::pointsToLastObject (const Pointer &Ptr)
 Does Ptr point to the last subobject?
static bool clang::interp::isUserWritingOffTheEnd (const ASTContext &Ctx, const Pointer &Ptr)
 Does Ptr point to the last object AND to a flexible array member?
static bool clang::interp::interp__builtin_object_size (InterpState &S, CodePtr OpPC, const InterpFrame *Frame, const CallExpr *Call)
static bool clang::interp::interp__builtin_is_within_lifetime (InterpState &S, CodePtr OpPC, const CallExpr *Call)
static bool clang::interp::interp__builtin_elementwise_int_binop (InterpState &S, CodePtr OpPC, const CallExpr *Call, llvm::function_ref< APInt(const APSInt &, const APSInt &)> Fn)
static bool clang::interp::interp__builtin_elementwise_maxmin (InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned BuiltinID)
static bool clang::interp::interp__builtin_ia32_pmul (InterpState &S, CodePtr OpPC, const CallExpr *Call, unsigned BuiltinID)
static bool clang::interp::interp__builtin_elementwise_triop_fp (InterpState &S, CodePtr OpPC, const CallExpr *Call, llvm::function_ref< APFloat(const APFloat &, const APFloat &, const APFloat &, llvm::RoundingMode)> Fn)
static bool clang::interp::interp__builtin_select (InterpState &S, CodePtr OpPC, const CallExpr *Call)
 AVX512 predicated move: "Result = Mask[] ? LHS[] : RHS[]".
static bool clang::interp::interp__builtin_blend (InterpState &S, CodePtr OpPC, const CallExpr *Call)
static bool clang::interp::interp__builtin_elementwise_triop (InterpState &S, CodePtr OpPC, const CallExpr *Call, llvm::function_ref< APInt(const APSInt &, const APSInt &, const APSInt &)> Fn)
bool clang::interp::InterpretBuiltin (InterpState &S, CodePtr OpPC, const CallExpr *Call, uint32_t BuiltinID)
 Interpret a builtin function.
bool clang::interp::InterpretOffsetOf (InterpState &S, CodePtr OpPC, const OffsetOfExpr *E, ArrayRef< int64_t > ArrayIndices, int64_t &Result)
 Interpret an offsetof operation.
bool clang::interp::SetThreeWayComparisonField (InterpState &S, CodePtr OpPC, const Pointer &Ptr, const APSInt &IntValue)
 Sets the given integral value to the pointer, which is of a std::{weak,partial,strong}_ordering type.
static void clang::interp::zeroAll (Pointer &Dest)
static bool clang::interp::copyComposite (InterpState &S, CodePtr OpPC, const Pointer &Src, Pointer &Dest, bool Activate)
static bool clang::interp::copyRecord (InterpState &S, CodePtr OpPC, const Pointer &Src, Pointer &Dest, bool Activate=false)
bool clang::interp::DoMemcpy (InterpState &S, CodePtr OpPC, const Pointer &Src, Pointer &Dest)
 Copy the contents of Src into Dest.