clang 22.0.0git
InterpBuiltinBitCast.cpp File Reference
#include "InterpBuiltinBitCast.h"
#include "BitcastBuffer.h"
#include "Boolean.h"
#include "Context.h"
#include "Floating.h"
#include "Integral.h"
#include "InterpState.h"
#include "MemberPointer.h"
#include "Pointer.h"
#include "Record.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecordLayout.h"
#include "clang/Basic/TargetInfo.h"
#include <variant>

Go to the source code of this file.

Macros

#define BITCAST_TYPE_SWITCH(Expr, B)
#define BITCAST_TYPE_SWITCH_FIXED_SIZE(Expr, B)

Typedefs

using DataFunc
 Implement __builtin_bit_cast and related operations.
using PrimTypeVariant

Functions

static bool enumerateData (const Pointer &P, const Context &Ctx, Bits Offset, Bits BitsToRead, DataFunc F)
 We use this to recursively iterate over all fields and elements of a pointer and extract relevant data for a bitcast.
static bool enumeratePointerFields (const Pointer &P, const Context &Ctx, Bits BitsToRead, DataFunc F)
static bool CheckBitcastType (InterpState &S, CodePtr OpPC, QualType T, bool IsToType)

Macro Definition Documentation

◆ BITCAST_TYPE_SWITCH

#define BITCAST_TYPE_SWITCH ( Expr,
B )
Value:
do { \
switch (Expr) { \
TYPE_SWITCH_CASE(PT_Sint8, B) \
TYPE_SWITCH_CASE(PT_Uint8, B) \
TYPE_SWITCH_CASE(PT_Sint16, B) \
TYPE_SWITCH_CASE(PT_Uint16, B) \
TYPE_SWITCH_CASE(PT_Sint32, B) \
TYPE_SWITCH_CASE(PT_Uint32, B) \
TYPE_SWITCH_CASE(PT_Sint64, B) \
TYPE_SWITCH_CASE(PT_Uint64, B) \
TYPE_SWITCH_CASE(PT_IntAP, B) \
TYPE_SWITCH_CASE(PT_IntAPS, B) \
TYPE_SWITCH_CASE(PT_Bool, B) \
default: \
llvm_unreachable("Unhandled bitcast type"); \
} \
} while (0)
This represents one expression.
Definition Expr.h:112

Definition at line 42 of file InterpBuiltinBitCast.cpp.

Referenced by clang::interp::readPointerToBuffer().

◆ BITCAST_TYPE_SWITCH_FIXED_SIZE

#define BITCAST_TYPE_SWITCH_FIXED_SIZE ( Expr,
B )
Value:
do { \
switch (Expr) { \
TYPE_SWITCH_CASE(PT_Sint8, B) \
TYPE_SWITCH_CASE(PT_Uint8, B) \
TYPE_SWITCH_CASE(PT_Sint16, B) \
TYPE_SWITCH_CASE(PT_Uint16, B) \
TYPE_SWITCH_CASE(PT_Sint32, B) \
TYPE_SWITCH_CASE(PT_Uint32, B) \
TYPE_SWITCH_CASE(PT_Sint64, B) \
TYPE_SWITCH_CASE(PT_Uint64, B) \
TYPE_SWITCH_CASE(PT_Bool, B) \
default: \
llvm_unreachable("Unhandled bitcast type"); \
} \
} while (0)

Definition at line 61 of file InterpBuiltinBitCast.cpp.

Referenced by clang::interp::DoBitCastPtr().

Typedef Documentation

◆ DataFunc

using DataFunc
Initial value:
llvm::function_ref<bool(const Pointer &P, PrimType Ty, Bits BitOffset,
Bits FullBitWidth, bool PackedBools)>
A pointer to a memory block, live or dead.
Definition Pointer.h:90
#define bool
Definition gpuintrin.h:32
PrimType
Enumeration of the primitive types of the VM.
Definition PrimType.h:34
A quantity in bits.

Implement __builtin_bit_cast and related operations.

Since our internal representation for data is more complex than something we can simply memcpy or memcmp, we first bitcast all the data into a buffer, which we then later use to copy the data into the target. Used to iterate over pointer fields.

Definition at line 38 of file InterpBuiltinBitCast.cpp.

◆ PrimTypeVariant

Initial value:
Wrapper around boolean types.
Definition Boolean.h:25
Wrapper around fixed point types.
Definition FixedPoint.h:23
If a Floating is constructed from Memory, it DOES NOT OWN THAT MEMORY.
Definition Floating.h:35
If an IntegralAP is constructed from Memory, it DOES NOT OWN THAT MEMORY.
Definition IntegralAP.h:36
Wrapper around numeric types.
Definition Integral.h:66

Definition at line 458 of file InterpBuiltinBitCast.cpp.

Function Documentation

◆ CheckBitcastType()

◆ enumerateData()

◆ enumeratePointerFields()

bool enumeratePointerFields ( const Pointer & P,
const Context & Ctx,
Bits BitsToRead,
DataFunc F )
static