clang 24.0.0git
ARM.cpp File Reference
#include "ABIInfo.h"
#include "CGBuiltin.h"
#include "CGDebugInfo.h"
#include "TargetInfo.h"
#include "clang/Basic/AArch64CodeGenUtils.h"
#include "clang/Basic/TargetBuiltins.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/IntrinsicsAArch64.h"
#include "llvm/IR/IntrinsicsARM.h"
#include "llvm/IR/IntrinsicsBPF.h"
#include "llvm/Support/AArch64MemoryHints.h"
#include "llvm/TargetParser/AArch64TargetParser.h"
#include <numeric>
#include "clang/Basic/arm_sve_builtin_cg.inc"
#include "clang/Basic/BuiltinsAArch64NeonSVEBridge_cg.def"
#include "clang/Basic/arm_sme_builtin_cg.inc"
#include "clang/Basic/arm_fp16.inc"
#include "clang/Basic/arm_neon.inc"
#include "clang/Basic/arm_mve_builtin_cg.inc"
#include "clang/Basic/arm_cde_builtin_cg.inc"

Go to the source code of this file.

Macros

#define SVEMAP1(NameBase, LLVMIntrinsic, TypeModifier)
#define SVEMAP2(NameBase, TypeModifier)
#define GET_SVE_LLVM_INTRINSIC_MAP
#define SMEMAP1(NameBase, LLVMIntrinsic, TypeModifier)
#define SMEMAP2(NameBase, TypeModifier)
#define GET_SME_LLVM_INTRINSIC_MAP
#define GET_NEON_OVERLOAD_CHECK

Enumerations

enum  SpecialRegisterAccessKind { NormalRead , VolatileRead , Write }

Functions

static std::optional< CodeGenFunction::MSVCIntrin > translateAarch64ToMsvcIntrin (unsigned BuiltinID)
static std::optional< CodeGenFunction::MSVCIntrin > translateArmToMsvcIntrin (unsigned BuiltinID)
static Value * emitCallMaybeConstrainedFPBuiltin (CodeGenFunction &CGF, unsigned IntrinsicID, unsigned ConstrainedIntrinsicID, llvm::Type *Ty, ArrayRef< Value * > Args)
static llvm::FixedVectorType * GetNeonType (CodeGenFunction *CGF, NeonTypeFlags TypeFlags, bool HasFastHalfType=true, bool V1Ty=false, bool AllowBFloatArgsAndRet=true)
static llvm::VectorType * GetFloatNeonType (CodeGenFunction *CGF, NeonTypeFlags IntTypeFlags)
template<typename IntrinsicInfo>
static const IntrinsicInfo * findARMVectorIntrinsicInMap (ArrayRef< IntrinsicInfo > IntrinsicMap, unsigned BuiltinID, bool &MapProvenSorted)
static Value * EmitCommonNeonSISDBuiltinExpr (CodeGenFunction &CGF, const ARMNeonVectorIntrinsicInfo &SISDInfo, SmallVectorImpl< Value * > &Ops, const CallExpr *E)
static Value * packTBLDVectorList (CodeGenFunction &CGF, ArrayRef< Value * > Ops, Value *ExtOp, Value *IndexOp, llvm::Type *ResTy, unsigned IntID, const char *Name)
static Value * EmitSpecialRegisterBuiltin (CodeGenFunction &CGF, const CallExpr *E, llvm::Type *RegisterType, llvm::Type *ValueType, SpecialRegisterAccessKind AccessKind, StringRef SysReg="")
static Value * EmitRangePrefetchBuiltin (CodeGenFunction &CGF, unsigned BuiltinID, const CallExpr *E)
static Value * EmitAtomicStoreWithHintBuiltin (CodeGenFunction &CGF, unsigned BuiltinID, const CallExpr *E)
static bool HasExtraNeonArgument (unsigned BuiltinID)
 Return true if BuiltinID is an overloaded Neon intrinsic with an extra argument that specifies the vector type.
template<typename Integer>
static Integer GetIntegerConstantValue (const Expr *E, ASTContext &Context)
static llvm::Value * SignOrZeroExtend (CGBuilderTy &Builder, llvm::Value *V, llvm::Type *T, bool Unsigned)
static llvm::Value * MVEImmediateShr (CGBuilderTy &Builder, llvm::Value *V, uint32_t Shift, bool Unsigned)
static llvm::Value * ARMMVEVectorSplat (CGBuilderTy &Builder, llvm::Value *V)
static llvm::Value * ARMMVEVectorReinterpret (CGBuilderTy &Builder, CodeGenFunction *CGF, llvm::Value *V, llvm::Type *DestType)
static llvm::Value * VectorUnzip (CGBuilderTy &Builder, llvm::Value *V, bool Odd)
static llvm::Value * VectorZip (CGBuilderTy &Builder, llvm::Value *V0, llvm::Value *V1)
template<unsigned HighBit, unsigned OtherBits>
static llvm::Value * ARMMVEConstantSplat (CGBuilderTy &Builder, llvm::Type *VT)
static llvm::Value * ARMMVEVectorElementReverse (CGBuilderTy &Builder, llvm::Value *V, unsigned ReverseWidth)
static llvm::Value * ARMMVECreateSIToFP (CGBuilderTy &Builder, CodeGenFunction *CGF, llvm::Value *V, llvm::Type *Ty)
static llvm::Value * ARMMVECreateUIToFP (CGBuilderTy &Builder, CodeGenFunction *CGF, llvm::Value *V, llvm::Type *Ty)
static llvm::Value * ARMMVECreateFPToSI (CGBuilderTy &Builder, CodeGenFunction *CGF, llvm::Value *V, llvm::Type *Ty)
static llvm::Value * ARMMVECreateFPToUI (CGBuilderTy &Builder, CodeGenFunction *CGF, llvm::Value *V, llvm::Type *Ty)
static Value * EmitAArch64TblBuiltinExpr (CodeGenFunction &CGF, unsigned BuiltinID, const CallExpr *E, SmallVectorImpl< Value * > &Ops, llvm::Triple::ArchType Arch)
static llvm::ScalableVectorType * getSVEVectorForElementType (llvm::Type *EltTy)
static void InsertExplicitZeroOperand (CGBuilderTy &Builder, llvm::Type *Ty, SmallVectorImpl< Value * > &Ops)
static void InsertExplicitUndefOperand (CGBuilderTy &Builder, llvm::Type *Ty, SmallVectorImpl< Value * > &Ops)
static void swapCommutativeSMEOperands (unsigned BuiltinID, SmallVectorImpl< Value * > &Ops)
Value * readX18AsPtr (CodeGenFunction &CGF)
 Helper for the read/write/add/inc X18 builtins: read the X18 register and return it as an i8 pointer.

Variables

static const ARMNeonVectorIntrinsicInfo ARMSIMDIntrinsicMap []
static const std::pair< unsigned, unsigned > NEONEquivalentIntrinsicMap []
static const AArch64SVEAndSMEVectorIntrinsicInfo AArch64SVEIntrinsicMap []
static const AArch64SVEAndSMEVectorIntrinsicInfo AArch64SMEIntrinsicMap []
static bool NEONSIMDIntrinsicsProvenSorted = false
static bool AArch64SIMDIntrinsicsProvenSorted = false
static bool AArch64SISDIntrinsicsProvenSorted = false
static bool AArch64SVEIntrinsicsProvenSorted = false
static bool AArch64SMEIntrinsicsProvenSorted = false
constexpr unsigned SVEBitsPerBlock = 128

Macro Definition Documentation

◆ GET_NEON_OVERLOAD_CHECK

#define GET_NEON_OVERLOAD_CHECK

◆ GET_SME_LLVM_INTRINSIC_MAP

#define GET_SME_LLVM_INTRINSIC_MAP

◆ GET_SVE_LLVM_INTRINSIC_MAP

#define GET_SVE_LLVM_INTRINSIC_MAP

◆ SMEMAP1

#define SMEMAP1 ( NameBase,
LLVMIntrinsic,
TypeModifier )
Value:
{SME::BI__builtin_sme_##NameBase, Intrinsic::LLVMIntrinsic, TypeModifier}

Definition at line 970 of file ARM.cpp.

◆ SMEMAP2

#define SMEMAP2 ( NameBase,
TypeModifier )
Value:
{SME::BI__builtin_sme_##NameBase, 0, TypeModifier}

Definition at line 973 of file ARM.cpp.

◆ SVEMAP1

#define SVEMAP1 ( NameBase,
LLVMIntrinsic,
TypeModifier )
Value:
{SVE::BI__builtin_sve_##NameBase, Intrinsic::LLVMIntrinsic, TypeModifier}

Definition at line 955 of file ARM.cpp.

◆ SVEMAP2

#define SVEMAP2 ( NameBase,
TypeModifier )
Value:
{SVE::BI__builtin_sve_##NameBase, 0, TypeModifier}

Definition at line 958 of file ARM.cpp.

Enumeration Type Documentation

◆ SpecialRegisterAccessKind

Enumerator
NormalRead 
VolatileRead 
Write 

Definition at line 1944 of file ARM.cpp.

Function Documentation

◆ ARMMVEConstantSplat()

template<unsigned HighBit, unsigned OtherBits>
llvm::Value * ARMMVEConstantSplat ( CGBuilderTy & Builder,
llvm::Type * VT )
static

Definition at line 2941 of file ARM.cpp.

References ARMMVEVectorSplat(), clang::cast(), clang::T, and uint32_t.

◆ ARMMVECreateFPToSI()

llvm::Value * ARMMVECreateFPToSI ( CGBuilderTy & Builder,
CodeGenFunction * CGF,
llvm::Value * V,
llvm::Type * Ty )
static

◆ ARMMVECreateFPToUI()

llvm::Value * ARMMVECreateFPToUI ( CGBuilderTy & Builder,
CodeGenFunction * CGF,
llvm::Value * V,
llvm::Type * Ty )
static

◆ ARMMVECreateSIToFP()

llvm::Value * ARMMVECreateSIToFP ( CGBuilderTy & Builder,
CodeGenFunction * CGF,
llvm::Value * V,
llvm::Type * Ty )
static

◆ ARMMVECreateUIToFP()

llvm::Value * ARMMVECreateUIToFP ( CGBuilderTy & Builder,
CodeGenFunction * CGF,
llvm::Value * V,
llvm::Type * Ty )
static

◆ ARMMVEVectorElementReverse()

llvm::Value * ARMMVEVectorElementReverse ( CGBuilderTy & Builder,
llvm::Value * V,
unsigned ReverseWidth )
static

Definition at line 2953 of file ARM.cpp.

References V.

◆ ARMMVEVectorReinterpret()

◆ ARMMVEVectorSplat()

llvm::Value * ARMMVEVectorSplat ( CGBuilderTy & Builder,
llvm::Value * V )
static

Definition at line 2881 of file ARM.cpp.

References V.

Referenced by ARMMVEConstantSplat().

◆ EmitAArch64TblBuiltinExpr()

◆ EmitAtomicStoreWithHintBuiltin()

◆ emitCallMaybeConstrainedFPBuiltin()

Value * emitCallMaybeConstrainedFPBuiltin ( CodeGenFunction & CGF,
unsigned IntrinsicID,
unsigned ConstrainedIntrinsicID,
llvm::Type * Ty,
ArrayRef< Value * > Args )
static

◆ EmitCommonNeonSISDBuiltinExpr()

◆ EmitRangePrefetchBuiltin()

◆ EmitSpecialRegisterBuiltin()

◆ findARMVectorIntrinsicInMap()

template<typename IntrinsicInfo>
const IntrinsicInfo * findARMVectorIntrinsicInMap ( ArrayRef< IntrinsicInfo > IntrinsicMap,
unsigned BuiltinID,
bool & MapProvenSorted )
static

Definition at line 995 of file ARM.cpp.

◆ GetFloatNeonType()

◆ GetIntegerConstantValue()

template<typename Integer>
Integer GetIntegerConstantValue ( const Expr * E,
ASTContext & Context )
static

◆ GetNeonType()

◆ getSVEVectorForElementType()

llvm::ScalableVectorType * getSVEVectorForElementType ( llvm::Type * EltTy)
static

Definition at line 3393 of file ARM.cpp.

References SVEBitsPerBlock.

◆ HasExtraNeonArgument()

bool HasExtraNeonArgument ( unsigned BuiltinID)
static

Return true if BuiltinID is an overloaded Neon intrinsic with an extra argument that specifies the vector type.

The additional argument is meant for Sema checking (see CheckNeonBuiltinFunctionCall) and this function should be kept consistent with the logic in Sema. TODO: Make this return false for SISD builtins.

Definition at line 2135 of file ARM.cpp.

Referenced by clang::CodeGen::CodeGenFunction::EmitAArch64BuiltinExpr(), and clang::CodeGen::CodeGenFunction::EmitARMBuiltinExpr().

◆ InsertExplicitUndefOperand()

void InsertExplicitUndefOperand ( CGBuilderTy & Builder,
llvm::Type * Ty,
SmallVectorImpl< Value * > & Ops )
static

◆ InsertExplicitZeroOperand()

void InsertExplicitZeroOperand ( CGBuilderTy & Builder,
llvm::Type * Ty,
SmallVectorImpl< Value * > & Ops )
static

◆ MVEImmediateShr()

llvm::Value * MVEImmediateShr ( CGBuilderTy & Builder,
llvm::Value * V,
uint32_t Shift,
bool Unsigned )
static

Definition at line 2859 of file ARM.cpp.

References clang::cast(), uint32_t, clang::Unsigned, and V.

◆ packTBLDVectorList()

Value * packTBLDVectorList ( CodeGenFunction & CGF,
ArrayRef< Value * > Ops,
Value * ExtOp,
Value * IndexOp,
llvm::Type * ResTy,
unsigned IntID,
const char * Name )
static

◆ readX18AsPtr()

◆ SignOrZeroExtend()

llvm::Value * SignOrZeroExtend ( CGBuilderTy & Builder,
llvm::Value * V,
llvm::Type * T,
bool Unsigned )
static

Definition at line 2852 of file ARM.cpp.

References clang::T, clang::Unsigned, and V.

◆ swapCommutativeSMEOperands()

void swapCommutativeSMEOperands ( unsigned BuiltinID,
SmallVectorImpl< Value * > & Ops )
static

◆ translateAarch64ToMsvcIntrin()

std::optional< CodeGenFunction::MSVCIntrin > translateAarch64ToMsvcIntrin ( unsigned BuiltinID)
static

Definition at line 34 of file ARM.cpp.

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

◆ translateArmToMsvcIntrin()

std::optional< CodeGenFunction::MSVCIntrin > translateArmToMsvcIntrin ( unsigned BuiltinID)
static

Definition at line 193 of file ARM.cpp.

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

◆ VectorUnzip()

llvm::Value * VectorUnzip ( CGBuilderTy & Builder,
llvm::Value * V,
bool Odd )
static

Definition at line 2915 of file ARM.cpp.

References clang::cast(), and V.

◆ VectorZip()

llvm::Value * VectorZip ( CGBuilderTy & Builder,
llvm::Value * V0,
llvm::Value * V1 )
static

Definition at line 2926 of file ARM.cpp.

References clang::cast().

Variable Documentation

◆ AArch64SIMDIntrinsicsProvenSorted

bool AArch64SIMDIntrinsicsProvenSorted = false
static

Definition at line 986 of file ARM.cpp.

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

◆ AArch64SISDIntrinsicsProvenSorted

bool AArch64SISDIntrinsicsProvenSorted = false
static

Definition at line 987 of file ARM.cpp.

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

◆ AArch64SMEIntrinsicMap

const AArch64SVEAndSMEVectorIntrinsicInfo AArch64SMEIntrinsicMap[]
static
Initial value:
= {
#define GET_SME_LLVM_INTRINSIC_MAP
}

Definition at line 975 of file ARM.cpp.

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

◆ AArch64SMEIntrinsicsProvenSorted

bool AArch64SMEIntrinsicsProvenSorted = false
static

Definition at line 989 of file ARM.cpp.

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

◆ AArch64SVEIntrinsicMap

const AArch64SVEAndSMEVectorIntrinsicInfo AArch64SVEIntrinsicMap[]
static
Initial value:
= {
#define GET_SVE_LLVM_INTRINSIC_MAP
}

Definition at line 960 of file ARM.cpp.

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

◆ AArch64SVEIntrinsicsProvenSorted

bool AArch64SVEIntrinsicsProvenSorted = false
static

Definition at line 988 of file ARM.cpp.

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

◆ ARMSIMDIntrinsicMap

const ARMNeonVectorIntrinsicInfo ARMSIMDIntrinsicMap[]
static

Definition at line 541 of file ARM.cpp.

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

◆ NEONEquivalentIntrinsicMap

const std::pair<unsigned, unsigned> NEONEquivalentIntrinsicMap[]
static

◆ NEONSIMDIntrinsicsProvenSorted

bool NEONSIMDIntrinsicsProvenSorted = false
static

Definition at line 984 of file ARM.cpp.

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

◆ SVEBitsPerBlock

unsigned SVEBitsPerBlock = 128
constexpr