clang 22.0.0git
Macros | Functions
CGBuiltin.cpp File Reference
#include "CGBuiltin.h"
#include "ABIInfo.h"
#include "CGCUDARuntime.h"
#include "CGCXXABI.h"
#include "CGDebugInfo.h"
#include "CGObjCRuntime.h"
#include "CGOpenCLRuntime.h"
#include "CGRecordLayout.h"
#include "CGValue.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "ConstantEmitter.h"
#include "PatternInit.h"
#include "TargetInfo.h"
#include "clang/AST/OSLog.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/FrontendDiagnostic.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/IntrinsicsX86.h"
#include "llvm/IR/MatrixBuilder.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/ScopedPrinter.h"
#include <optional>
#include <utility>

Go to the source code of this file.

Macros

#define MUTATE_LDBL(func)
 

Functions

static bool shouldEmitBuiltinAsIR (unsigned BuiltinID, const Builtin::Context &BI, const CodeGenFunction &CGF)
 Some builtins do not have library implementation on some targets and are instead emitted as LLVM IRs by some target builtin emitters.
 
static ValueEmitTargetArchBuiltinExpr (CodeGenFunction *CGF, unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue, llvm::Triple::ArchType Arch)
 
static void initializeAlloca (CodeGenFunction &CGF, AllocaInst *AI, Value *Size, Align AlignmentInBytes)
 
ValueEmitToInt (CodeGenFunction &CGF, llvm::Value *V, QualType T, llvm::IntegerType *IntType)
 Emit the conversions required to turn the given value into an integer of the given size.
 
ValueEmitFromInt (CodeGenFunction &CGF, llvm::Value *V, QualType T, llvm::Type *ResultType)
 
Address CheckAtomicAlignment (CodeGenFunction &CGF, const CallExpr *E)
 
ValueMakeBinaryAtomicValue (CodeGenFunction &CGF, llvm::AtomicRMWInst::BinOp Kind, const CallExpr *E, AtomicOrdering Ordering)
 Utility to insert an atomic instruction based on Intrinsic::ID and the expression node.
 
static ValueEmitNontemporalStore (CodeGenFunction &CGF, const CallExpr *E)
 
static ValueEmitNontemporalLoad (CodeGenFunction &CGF, const CallExpr *E)
 
static RValue EmitBinaryAtomic (CodeGenFunction &CGF, llvm::AtomicRMWInst::BinOp Kind, const CallExpr *E)
 
static RValue EmitBinaryAtomicPost (CodeGenFunction &CGF, llvm::AtomicRMWInst::BinOp Kind, const CallExpr *E, Instruction::BinaryOps Op, bool Invert=false)
 Utility to insert an atomic instruction based Intrinsic::ID and the expression node, where the return value is the result of the operation.
 
ValueMakeAtomicCmpXchgValue (CodeGenFunction &CGF, const CallExpr *E, bool ReturnBool)
 Utility to insert an atomic cmpxchg instruction.
 
static ValueEmitAtomicCmpXchgForMSIntrin (CodeGenFunction &CGF, const CallExpr *E, AtomicOrdering SuccessOrdering=AtomicOrdering::SequentiallyConsistent)
 This function should be invoked to emit atomic cmpxchg for Microsoft's _InterlockedCompareExchange* intrinsics which have the following signature: T _InterlockedCompareExchange(T volatile *Destination, T Exchange, T Comparand);.
 
static ValueEmitAtomicCmpXchg128ForMSIntrin (CodeGenFunction &CGF, const CallExpr *E, AtomicOrdering SuccessOrdering)
 
static ValueEmitAtomicIncrementValue (CodeGenFunction &CGF, const CallExpr *E, AtomicOrdering Ordering=AtomicOrdering::SequentiallyConsistent)
 
static ValueEmitAtomicDecrementValue (CodeGenFunction &CGF, const CallExpr *E, AtomicOrdering Ordering=AtomicOrdering::SequentiallyConsistent)
 
static ValueEmitISOVolatileLoad (CodeGenFunction &CGF, const CallExpr *E)
 
static ValueEmitISOVolatileStore (CodeGenFunction &CGF, const CallExpr *E)
 
ValueemitUnaryMaybeConstrainedFPBuiltin (CodeGenFunction &CGF, const CallExpr *E, unsigned IntrinsicID, unsigned ConstrainedIntrinsicID)
 
static ValueemitBinaryMaybeConstrainedFPBuiltin (CodeGenFunction &CGF, const CallExpr *E, unsigned IntrinsicID, unsigned ConstrainedIntrinsicID)
 
static ValueemitBinaryExpMaybeConstrainedFPBuiltin (CodeGenFunction &CGF, const CallExpr *E, Intrinsic::ID IntrinsicID, Intrinsic::ID ConstrainedIntrinsicID)
 
static ValueemitTernaryMaybeConstrainedFPBuiltin (CodeGenFunction &CGF, const CallExpr *E, unsigned IntrinsicID, unsigned ConstrainedIntrinsicID)
 
static ValueemitMaybeConstrainedFPToIntRoundBuiltin (CodeGenFunction &CGF, const CallExpr *E, unsigned IntrinsicID, unsigned ConstrainedIntrinsicID)
 
static ValueemitFrexpBuiltin (CodeGenFunction &CGF, const CallExpr *E, Intrinsic::ID IntrinsicID)
 
static void emitSincosBuiltin (CodeGenFunction &CGF, const CallExpr *E, Intrinsic::ID IntrinsicID)
 
static llvm::ValueemitModfBuiltin (CodeGenFunction &CGF, const CallExpr *E, Intrinsic::ID IntrinsicID)
 
static ValueEmitFAbs (CodeGenFunction &CGF, Value *V)
 EmitFAbs - Emit a call to @llvm.fabs().
 
static ValueEmitSignBit (CodeGenFunction &CGF, Value *V)
 Emit the computation of the sign bit for a floating point value.
 
static bool HasNoIndirectArgumentsOrResults (CGFunctionInfo const &FnInfo)
 Checks no arguments or results are passed indirectly in the ABI (i.e.
 
static RValue emitLibraryCall (CodeGenFunction &CGF, const FunctionDecl *FD, const CallExpr *E, llvm::Constant *calleeValue)
 
llvm::ValueEmitOverflowIntrinsic (CodeGenFunction &CGF, const Intrinsic::ID IntrinsicID, llvm::Value *X, llvm::Value *Y, llvm::Value *&Carry)
 Emit a call to llvm.
 
static WidthAndSignedness getIntegerWidthAndSignedness (const clang::ASTContext &context, const clang::QualType Type)
 
static struct WidthAndSignedness EncompassingIntegerType (ArrayRef< struct WidthAndSignedness > Types)
 
static bool areBOSTypesCompatible (int From, int To)
 Checks if using the result of __builtin_object_size(p, From) in place of __builtin_object_size(p, To) is correct.
 
static llvm::ValuegetDefaultBuiltinObjectSizeResult (unsigned Type, llvm::IntegerType *ResType)
 
static const FieldDeclFindFlexibleArrayMemberField (CodeGenFunction &CGF, ASTContext &Ctx, const RecordDecl *RD)
 Find a struct's flexible array member.
 
static bool GetFieldOffset (ASTContext &Ctx, const RecordDecl *RD, const FieldDecl *FD, int64_t &Offset)
 Calculate the offset of a struct field.
 
static std::optional< int64_t > GetFieldOffset (ASTContext &Ctx, const RecordDecl *RD, const FieldDecl *FD)
 
static llvm::ValueEmitPositiveResultOrZero (CodeGenFunction &CGF, llvm::Value *Res, llvm::Value *Index, llvm::IntegerType *ResType, bool IsSigned)
 
static std::pair< llvm::Value *, llvm::Value * > GetCountFieldAndIndex (CodeGenFunction &CGF, const MemberExpr *ME, const FieldDecl *ArrayFD, const FieldDecl *CountFD, const Expr *Idx, llvm::IntegerType *ResType, bool IsSigned)
 
static char bitActionToX86BTCode (BitTest::ActionKind A)
 
static llvm::ValueEmitX86BitTestIntrinsic (CodeGenFunction &CGF, BitTest BT, const CallExpr *E, Value *BitBase, Value *BitPos)
 
static llvm::AtomicOrdering getBitTestAtomicOrdering (BitTest::InterlockingKind I)
 
static llvm::ValueEmitBitCountExpr (CodeGenFunction &CGF, const Expr *E)
 
static llvm::ValueEmitBitTestIntrinsic (CodeGenFunction &CGF, unsigned BuiltinID, const CallExpr *E)
 Emit a _bittest* intrinsic.
 
static RValue EmitMSVCRTSetJmp (CodeGenFunction &CGF, MSVCSetJmpKind SJKind, const CallExpr *E)
 MSVC handles setjmp a bit differently on different platforms.
 
static ValueEmitAbs (CodeGenFunction &CGF, Value *ArgValue, bool HasNSW)
 
static ValueEmitOverflowCheckedAbs (CodeGenFunction &CGF, const CallExpr *E, bool SanitizeOverflow)
 
static CanQualType getOSLogArgType (ASTContext &C, int Size)
 Get the argument type for arguments to os_log_helper.
 
static bool isSpecialUnsignedMultiplySignedResult (unsigned BuiltinID, WidthAndSignedness Op1Info, WidthAndSignedness Op2Info, WidthAndSignedness ResultInfo)
 
static RValue EmitCheckedUnsignedMultiplySignedResult (CodeGenFunction &CGF, const clang::Expr *Op1, WidthAndSignedness Op1Info, const clang::Expr *Op2, WidthAndSignedness Op2Info, const clang::Expr *ResultArg, QualType ResultQTy, WidthAndSignedness ResultInfo)
 
static bool isSpecialMixedSignMultiply (unsigned BuiltinID, WidthAndSignedness Op1Info, WidthAndSignedness Op2Info, WidthAndSignedness ResultInfo)
 Determine if a binop is a checked mixed-sign multiply we can specialize.
 
static RValue EmitCheckedMixedSignMultiply (CodeGenFunction &CGF, const clang::Expr *Op1, WidthAndSignedness Op1Info, const clang::Expr *Op2, WidthAndSignedness Op2Info, const clang::Expr *ResultArg, QualType ResultQTy, WidthAndSignedness ResultInfo)
 Emit a checked mixed-sign multiply.
 
static bool TypeRequiresBuiltinLaunderImp (const ASTContext &Ctx, QualType Ty, llvm::SmallPtrSetImpl< const Decl * > &Seen)
 
static bool TypeRequiresBuiltinLaunder (CodeGenModule &CGM, QualType Ty)
 Determine if the specified type requires laundering by checking if it is a dynamic class type or contains a subobject which is a dynamic class type.
 
static unsigned mutateLongDoubleBuiltin (unsigned BuiltinID)
 
static ValuetryUseTestFPKind (CodeGenFunction &CGF, unsigned BuiltinID, Value *V)
 
static RValue EmitHipStdParUnsupportedBuiltin (CodeGenFunction *CGF, const FunctionDecl *FD)
 

Macro Definition Documentation

◆ MUTATE_LDBL

#define MUTATE_LDBL (   func)
Value:
case Builtin::BI__builtin_##func##l: \
return Builtin::BI__builtin_##func##f128;

Function Documentation

◆ areBOSTypesCompatible()

static bool areBOSTypesCompatible ( int  From,
int  To 
)
static

Checks if using the result of __builtin_object_size(p, From) in place of __builtin_object_size(p, To) is correct.

Definition at line 908 of file CGBuiltin.cpp.

◆ bitActionToX86BTCode()

static char bitActionToX86BTCode ( BitTest::ActionKind  A)
static

Definition at line 1638 of file CGBuiltin.cpp.

Referenced by EmitX86BitTestIntrinsic().

◆ CheckAtomicAlignment()

Address CheckAtomicAlignment ( CodeGenFunction CGF,
const CallExpr E 
)

◆ EmitAbs()

static Value * EmitAbs ( CodeGenFunction CGF,
Value ArgValue,
bool  HasNSW 
)
static

◆ EmitAtomicCmpXchg128ForMSIntrin()

static Value * EmitAtomicCmpXchg128ForMSIntrin ( CodeGenFunction CGF,
const CallExpr E,
AtomicOrdering  SuccessOrdering 
)
static

◆ EmitAtomicCmpXchgForMSIntrin()

static Value * EmitAtomicCmpXchgForMSIntrin ( CodeGenFunction CGF,
const CallExpr E,
AtomicOrdering  SuccessOrdering = AtomicOrdering::SequentiallyConsistent 
)
static

This function should be invoked to emit atomic cmpxchg for Microsoft's _InterlockedCompareExchange* intrinsics which have the following signature: T _InterlockedCompareExchange(T volatile *Destination, T Exchange, T Comparand);.

Whereas the llvm 'cmpxchg' instruction has the following syntax: cmpxchg *Destination, Comparand, Exchange. So we need to swap Comparand and Exchange when invoking CreateAtomicCmpXchg. That is the reason we could not use the above utility function MakeAtomicCmpXchgValue since it expects the arguments to be already swapped.

Definition at line 430 of file CGBuiltin.cpp.

References clang::CodeGen::CodeGenFunction::Builder, CheckAtomicAlignment(), clang::CodeGen::CGBuilderTy::CreateAtomicCmpXchg(), E, clang::CodeGen::CodeGenFunction::EmitScalarExpr(), clang::CodeGen::CodeGenFunction::getContext(), clang::Type::getPointeeType(), clang::Expr::getType(), clang::ASTContext::hasSameUnqualifiedType(), clang::CodeGen::CodeGenTypeCache::IntPtrTy, clang::Type::isPointerType(), and clang::Result.

Referenced by clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(), and clang::CodeGen::CodeGenFunction::EmitMSVCBuiltinExpr().

◆ EmitAtomicDecrementValue()

static Value * EmitAtomicDecrementValue ( CodeGenFunction CGF,
const CallExpr E,
AtomicOrdering  Ordering = AtomicOrdering::SequentiallyConsistent 
)
static

◆ EmitAtomicIncrementValue()

static Value * EmitAtomicIncrementValue ( CodeGenFunction CGF,
const CallExpr E,
AtomicOrdering  Ordering = AtomicOrdering::SequentiallyConsistent 
)
static

◆ EmitBinaryAtomic()

static RValue EmitBinaryAtomic ( CodeGenFunction CGF,
llvm::AtomicRMWInst::BinOp  Kind,
const CallExpr E 
)
static

◆ EmitBinaryAtomicPost()

static RValue EmitBinaryAtomicPost ( CodeGenFunction CGF,
llvm::AtomicRMWInst::BinOp  Kind,
const CallExpr E,
Instruction::BinaryOps  Op,
bool  Invert = false 
)
static

◆ emitBinaryExpMaybeConstrainedFPBuiltin()

static Value * emitBinaryExpMaybeConstrainedFPBuiltin ( CodeGenFunction CGF,
const CallExpr E,
Intrinsic::ID  IntrinsicID,
Intrinsic::ID  ConstrainedIntrinsicID 
)
static

◆ emitBinaryMaybeConstrainedFPBuiltin()

static Value * emitBinaryMaybeConstrainedFPBuiltin ( CodeGenFunction CGF,
const CallExpr E,
unsigned  IntrinsicID,
unsigned  ConstrainedIntrinsicID 
)
static

◆ EmitBitCountExpr()

static llvm::Value * EmitBitCountExpr ( CodeGenFunction CGF,
const Expr E 
)
static

◆ EmitBitTestIntrinsic()

static llvm::Value * EmitBitTestIntrinsic ( CodeGenFunction CGF,
unsigned  BuiltinID,
const CallExpr E 
)
static

Emit a _bittest* intrinsic.

These intrinsics take a pointer to an array of bits and a bit position and read and optionally modify the bit at that position. The position index can be arbitrarily large, i.e. it can be larger than 31 or 63, so we need an indexed load in the general case.

Definition at line 1716 of file CGBuiltin.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CGBuilderTy::CreateAtomicRMW(), clang::CodeGen::CGBuilderTy::CreateInBoundsGEP(), clang::CodeGen::CGBuilderTy::CreateLoad(), clang::CodeGen::CGBuilderTy::CreateStore(), E, clang::CodeGen::CodeGenFunction::EmitScalarExpr(), EmitX86BitTestIntrinsic(), getBitTestAtomicOrdering(), clang::CodeGen::CodeGenFunction::getTarget(), clang::TargetInfo::getTriple(), clang::Value::getType(), clang::CodeGen::CodeGenTypeCache::Int8Ty, and clang::CharUnits::One().

Referenced by clang::CodeGen::CodeGenFunction::EmitBuiltinExpr().

◆ EmitCheckedMixedSignMultiply()

static RValue EmitCheckedMixedSignMultiply ( CodeGenFunction CGF,
const clang::Expr Op1,
WidthAndSignedness  Op1Info,
const clang::Expr Op2,
WidthAndSignedness  Op2Info,
const clang::Expr ResultArg,
QualType  ResultQTy,
WidthAndSignedness  ResultInfo 
)
static

◆ EmitCheckedUnsignedMultiplySignedResult()

static RValue EmitCheckedUnsignedMultiplySignedResult ( CodeGenFunction CGF,
const clang::Expr Op1,
WidthAndSignedness  Op1Info,
const clang::Expr Op2,
WidthAndSignedness  Op2Info,
const clang::Expr ResultArg,
QualType  ResultQTy,
WidthAndSignedness  ResultInfo 
)
static

◆ EmitFAbs()

static Value * EmitFAbs ( CodeGenFunction CGF,
Value V 
)
static

◆ emitFrexpBuiltin()

static Value * emitFrexpBuiltin ( CodeGenFunction CGF,
const CallExpr E,
Intrinsic::ID  IntrinsicID 
)
static

◆ EmitFromInt()

Value * EmitFromInt ( CodeGenFunction CGF,
llvm::Value V,
QualType  T,
llvm::Type ResultType 
)

◆ EmitHipStdParUnsupportedBuiltin()

static RValue EmitHipStdParUnsupportedBuiltin ( CodeGenFunction CGF,
const FunctionDecl FD 
)
static

◆ EmitISOVolatileLoad()

static Value * EmitISOVolatileLoad ( CodeGenFunction CGF,
const CallExpr E 
)
static

◆ EmitISOVolatileStore()

static Value * EmitISOVolatileStore ( CodeGenFunction CGF,
const CallExpr E 
)
static

◆ emitLibraryCall()

static RValue emitLibraryCall ( CodeGenFunction CGF,
const FunctionDecl FD,
const CallExpr E,
llvm::Constant *  calleeValue 
)
static

◆ emitMaybeConstrainedFPToIntRoundBuiltin()

static Value * emitMaybeConstrainedFPToIntRoundBuiltin ( CodeGenFunction CGF,
const CallExpr E,
unsigned  IntrinsicID,
unsigned  ConstrainedIntrinsicID 
)
static

◆ emitModfBuiltin()

static llvm::Value * emitModfBuiltin ( CodeGenFunction CGF,
const CallExpr E,
Intrinsic::ID  IntrinsicID 
)
static

◆ EmitMSVCRTSetJmp()

static RValue EmitMSVCRTSetJmp ( CodeGenFunction CGF,
MSVCSetJmpKind  SJKind,
const CallExpr E 
)
static

◆ EmitNontemporalLoad()

static Value * EmitNontemporalLoad ( CodeGenFunction CGF,
const CallExpr E 
)
static

◆ EmitNontemporalStore()

static Value * EmitNontemporalStore ( CodeGenFunction CGF,
const CallExpr E 
)
static

◆ EmitOverflowCheckedAbs()

static Value * EmitOverflowCheckedAbs ( CodeGenFunction CGF,
const CallExpr E,
bool  SanitizeOverflow 
)
static

◆ EmitOverflowIntrinsic()

llvm::Value * EmitOverflowIntrinsic ( CodeGenFunction CGF,
const Intrinsic::ID  IntrinsicID,
llvm::Value X,
llvm::Value Y,
llvm::Value *&  Carry 
)

Emit a call to llvm.

{sadd,uadd,ssub,usub,smul,umul}.with.overflow.* depending on IntrinsicID.

  • CGF The current codegen function.
  • IntrinsicID The ID for the Intrinsic we wish to generate.
  • X The first argument to the llvm.*.with.overflow.*.
  • Y The second argument to the llvm.*.with.overflow.*.
  • Carry The carry returned by the llvm.*.with.overflow.*.
    Returns
    The result (i.e. sum/product) returned by the intrinsic.

Definition at line 841 of file CGBuiltin.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::CGM, clang::Function, clang::CodeGen::CodeGenModule::getIntrinsic(), and X.

Referenced by clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(), EmitCheckedMixedSignMultiply(), EmitCheckedUnsignedMultiplySignedResult(), and clang::CodeGen::CodeGenFunction::EmitHLSLBuiltinExpr().

◆ EmitPositiveResultOrZero()

static llvm::Value * EmitPositiveResultOrZero ( CodeGenFunction CGF,
llvm::Value Res,
llvm::Value Index,
llvm::IntegerType *  ResType,
bool  IsSigned 
)
static

Definition at line 1109 of file CGBuiltin.cpp.

References clang::CodeGen::CodeGenFunction::Builder.

◆ EmitSignBit()

static Value * EmitSignBit ( CodeGenFunction CGF,
Value V 
)
static

◆ emitSincosBuiltin()

static void emitSincosBuiltin ( CodeGenFunction CGF,
const CallExpr E,
Intrinsic::ID  IntrinsicID 
)
static

◆ EmitTargetArchBuiltinExpr()

static Value * EmitTargetArchBuiltinExpr ( CodeGenFunction CGF,
unsigned  BuiltinID,
const CallExpr E,
ReturnValueSlot  ReturnValue,
llvm::Triple::ArchType  Arch 
)
static

◆ emitTernaryMaybeConstrainedFPBuiltin()

static Value * emitTernaryMaybeConstrainedFPBuiltin ( CodeGenFunction CGF,
const CallExpr E,
unsigned  IntrinsicID,
unsigned  ConstrainedIntrinsicID 
)
static

◆ EmitToInt()

Value * EmitToInt ( CodeGenFunction CGF,
llvm::Value V,
QualType  T,
llvm::IntegerType *  IntType 
)

Emit the conversions required to turn the given value into an integer of the given size.

Definition at line 252 of file CGBuiltin.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::EmitToMemory(), clang::T, and V.

Referenced by EmitBinaryAtomicPost(), MakeAtomicCmpXchgValue(), and MakeBinaryAtomicValue().

◆ emitUnaryMaybeConstrainedFPBuiltin()

Value * emitUnaryMaybeConstrainedFPBuiltin ( CodeGenFunction CGF,
const CallExpr E,
unsigned  IntrinsicID,
unsigned  ConstrainedIntrinsicID 
)

◆ EmitX86BitTestIntrinsic()

static llvm::Value * EmitX86BitTestIntrinsic ( CodeGenFunction CGF,
BitTest  BT,
const CallExpr E,
Value BitBase,
Value BitPos 
)
static

◆ EncompassingIntegerType()

static struct WidthAndSignedness EncompassingIntegerType ( ArrayRef< struct WidthAndSignedness >  Types)
static

Definition at line 876 of file CGBuiltin.cpp.

References clang::Signed.

Referenced by clang::CodeGen::CodeGenFunction::EmitBuiltinExpr().

◆ FindFlexibleArrayMemberField()

static const FieldDecl * FindFlexibleArrayMemberField ( CodeGenFunction CGF,
ASTContext Ctx,
const RecordDecl RD 
)
static

Find a struct's flexible array member.

It may be embedded inside multiple sub-structs, but must still be the last field.

Definition at line 985 of file CGBuiltin.cpp.

References clang::RecordDecl::fields(), FindFlexibleArrayMemberField(), clang::CodeGen::CodeGenFunction::getLangOpts(), clang::Decl::isFlexibleArrayMemberLike(), and clang::Decl::isImplicit().

Referenced by FindFlexibleArrayMemberField().

◆ getBitTestAtomicOrdering()

static llvm::AtomicOrdering getBitTestAtomicOrdering ( BitTest::InterlockingKind  I)
static

Definition at line 1684 of file CGBuiltin.cpp.

Referenced by EmitBitTestIntrinsic().

◆ GetCountFieldAndIndex()

static std::pair< llvm::Value *, llvm::Value * > GetCountFieldAndIndex ( CodeGenFunction CGF,
const MemberExpr ME,
const FieldDecl ArrayFD,
const FieldDecl CountFD,
const Expr Idx,
llvm::IntegerType *  ResType,
bool  IsSigned 
)
static

◆ getDefaultBuiltinObjectSizeResult()

static llvm::Value * getDefaultBuiltinObjectSizeResult ( unsigned  Type,
llvm::IntegerType *  ResType 
)
static

Definition at line 916 of file CGBuiltin.cpp.

◆ GetFieldOffset() [1/2]

static std::optional< int64_t > GetFieldOffset ( ASTContext Ctx,
const RecordDecl RD,
const FieldDecl FD 
)
static

Definition at line 1042 of file CGBuiltin.cpp.

References GetFieldOffset().

◆ GetFieldOffset() [2/2]

static bool GetFieldOffset ( ASTContext Ctx,
const RecordDecl RD,
const FieldDecl FD,
int64_t &  Offset 
)
static

Calculate the offset of a struct field.

It may be embedded inside multiple sub-structs.

Definition at line 1010 of file CGBuiltin.cpp.

References clang::RecordDecl::fields(), clang::ASTContext::getASTRecordLayout(), GetFieldOffset(), clang::ASTRecordLayout::getFieldOffset(), clang::Decl::isImplicit(), and clang::TagDecl::isUnion().

Referenced by GetFieldOffset().

◆ getIntegerWidthAndSignedness()

static WidthAndSignedness getIntegerWidthAndSignedness ( const clang::ASTContext context,
const clang::QualType  Type 
)
static

◆ getOSLogArgType()

static CanQualType getOSLogArgType ( ASTContext C,
int  Size 
)
static

Get the argument type for arguments to os_log_helper.

Definition at line 2119 of file CGBuiltin.cpp.

References clang::C.

Referenced by clang::CodeGen::CodeGenFunction::emitBuiltinOSLogFormat(), and clang::CodeGen::CodeGenFunction::generateBuiltinOSLogHelperFunction().

◆ HasNoIndirectArgumentsOrResults()

static bool HasNoIndirectArgumentsOrResults ( CGFunctionInfo const &  FnInfo)
static

Checks no arguments or results are passed indirectly in the ABI (i.e.

via a hidden pointer). This is used to check annotating FP libcalls (that could set errno) with "int" TBAA metadata is safe. If any floating-point arguments are passed indirectly, setup for the call could be incorrectly optimized out.

Definition at line 792 of file CGBuiltin.cpp.

References clang::CodeGen::CGFunctionInfo::arguments(), and clang::CodeGen::CGFunctionInfo::getReturnInfo().

Referenced by emitLibraryCall().

◆ initializeAlloca()

static void initializeAlloca ( CodeGenFunction CGF,
AllocaInst *  AI,
Value Size,
Align  AlignmentInBytes 
)
static

◆ isSpecialMixedSignMultiply()

static bool isSpecialMixedSignMultiply ( unsigned  BuiltinID,
WidthAndSignedness  Op1Info,
WidthAndSignedness  Op2Info,
WidthAndSignedness  ResultInfo 
)
static

Determine if a binop is a checked mixed-sign multiply we can specialize.

Definition at line 2353 of file CGBuiltin.cpp.

Referenced by clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(), and EmitCheckedMixedSignMultiply().

◆ isSpecialUnsignedMultiplySignedResult()

static bool isSpecialUnsignedMultiplySignedResult ( unsigned  BuiltinID,
WidthAndSignedness  Op1Info,
WidthAndSignedness  Op2Info,
WidthAndSignedness  ResultInfo 
)
static

◆ MakeAtomicCmpXchgValue()

Value * MakeAtomicCmpXchgValue ( CodeGenFunction CGF,
const CallExpr E,
bool  ReturnBool 
)

Utility to insert an atomic cmpxchg instruction.

Parameters
CGFThe current codegen function.
EBuiltin call expression to convert to cmpxchg. arg0 - address to operate on arg1 - value to compare with arg2 - new value
ReturnBoolSpecifies whether to return success flag of cmpxchg result or the old value.
Returns
result of cmpxchg, according to ReturnBool

Note: In order to lower Microsoft's _InterlockedCompareExchange* intrinsics invoke the function EmitAtomicCmpXchgForMSIntrin.

Definition at line 390 of file CGBuiltin.cpp.

References clang::CodeGen::CodeGenFunction::Builder, CheckAtomicAlignment(), clang::CodeGen::CodeGenFunction::ConvertType(), clang::CodeGen::CGBuilderTy::CreateAtomicCmpXchg(), E, EmitFromInt(), clang::CodeGen::CodeGenFunction::EmitScalarExpr(), EmitToInt(), clang::CodeGen::CodeGenFunction::getContext(), clang::CodeGen::CodeGenFunction::getLLVMContext(), clang::Expr::getType(), clang::ASTContext::getTypeSize(), New, and clang::T.

Referenced by clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(), and clang::CodeGen::CodeGenFunction::EmitNVPTXBuiltinExpr().

◆ MakeBinaryAtomicValue()

Value * MakeBinaryAtomicValue ( CodeGenFunction CGF,
llvm::AtomicRMWInst::BinOp  Kind,
const CallExpr E,
AtomicOrdering  Ordering 
)

◆ mutateLongDoubleBuiltin()

static unsigned mutateLongDoubleBuiltin ( unsigned  BuiltinID)
static

◆ shouldEmitBuiltinAsIR()

static bool shouldEmitBuiltinAsIR ( unsigned  BuiltinID,
const Builtin::Context BI,
const CodeGenFunction CGF 
)
static

Some builtins do not have library implementation on some targets and are instead emitted as LLVM IRs by some target builtin emitters.

FIXME: Remove this when library support is added

Definition at line 48 of file CGBuiltin.cpp.

References clang::CodeGen::CodeGenFunction::CGM, clang::CodeGen::CodeGenFunction::CurFPFeatures, clang::FPOptions::getExceptionMode(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::CodeGen::CodeGenModule::getTargetCodeGenInfo(), and clang::CodeGen::TargetCodeGenInfo::supportsLibCall().

Referenced by clang::CodeGen::CodeGenFunction::EmitBuiltinExpr().

◆ tryUseTestFPKind()

static Value * tryUseTestFPKind ( CodeGenFunction CGF,
unsigned  BuiltinID,
Value V 
)
static

◆ TypeRequiresBuiltinLaunder()

static bool TypeRequiresBuiltinLaunder ( CodeGenModule CGM,
QualType  Ty 
)
static

Determine if the specified type requires laundering by checking if it is a dynamic class type or contains a subobject which is a dynamic class type.

Definition at line 2481 of file CGBuiltin.cpp.

References clang::CodeGen::CodeGenModule::getCodeGenOpts(), clang::CodeGen::CodeGenModule::getContext(), and TypeRequiresBuiltinLaunderImp().

Referenced by clang::CodeGen::CodeGenFunction::EmitBuiltinExpr().

◆ TypeRequiresBuiltinLaunderImp()

static bool TypeRequiresBuiltinLaunderImp ( const ASTContext Ctx,
QualType  Ty,
llvm::SmallPtrSetImpl< const Decl * > &  Seen 
)
static