clang 20.0.0git
Macros | Typedefs | Functions
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"

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 = llvm::function_ref< bool(const Pointer &P, PrimType Ty, Bits BitOffset, Bits FullBitWidth, bool PackedBools)>
 Implement __builtin_bit_cast and related operations.
 

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,
 
)
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:110

Definition at line 40 of file InterpBuiltinBitCast.cpp.

◆ BITCAST_TYPE_SWITCH_FIXED_SIZE

#define BITCAST_TYPE_SWITCH_FIXED_SIZE (   Expr,
 
)
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 59 of file InterpBuiltinBitCast.cpp.

Typedef Documentation

◆ DataFunc

using DataFunc = llvm::function_ref<bool(const Pointer &P, PrimType Ty, Bits BitOffset, Bits FullBitWidth, bool PackedBools)>

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 36 of file InterpBuiltinBitCast.cpp.

Function Documentation

◆ CheckBitcastType()

static bool CheckBitcastType ( InterpState S,
CodePtr  OpPC,
QualType  T,
bool  IsToType 
)
static

◆ enumerateData()

static bool enumerateData ( const Pointer P,
const Context Ctx,
Bits  Offset,
Bits  BitsToRead,
DataFunc  F 
)
static

◆ enumeratePointerFields()

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