29 return Opts.CompatInfo;
38 unsigned NSRN = 0, NPRN = 0;
40 const bool IsNamedArg =
43 I.Info = classifyArgumentType(
I.ABIType, FI.
isVariadic(), IsNamedArg,
51 ArgInfo classifyReturnType(
const Type *RetTy,
bool IsVariadicFn)
const;
52 ArgInfo classifyArgumentType(
const Type *Ty,
bool IsVariadicFn,
53 bool IsNamedArg,
unsigned CallingConvention,
54 unsigned &NSRN,
unsigned &NPRN)
const;
60 convertFixedToScalableVectorType(
const VectorType *VT)
const;
62 ArgInfo coerceIllegalVector(
const VectorType *VT,
unsigned &NSRN,
63 unsigned &NPRN)
const;
65 bool isIllegalVectorType(
const Type *Ty)
const;
67 bool passAsAggregateType(
const Type *Ty)
const;
69 bool isHomogeneousAggregateBaseType(
const Type *Ty)
const override;
70 bool isHomogeneousAggregateSmallEnough(
const Type *
Base,
73 bool isPermittedToBeHomogeneousAggregate(
const RecordType *RT)
const override;
76std::unique_ptr<TargetInfo>
78 return std::make_unique<AArch64TargetInfo>(TB, Opts);
84 <<
" is not yet implemented for AArch64 in the LLVM ABI library.\n";
87ArgInfo AArch64TargetInfo::classifyReturnType(
const Type *RetTy,
88 bool IsVariadicFn)
const {
93 if (VT->isFixedLengthSVEData() || VT->isFixedLengthSVEPredicate()) {
94 unsigned NSRN = 0, NPRN = 0;
95 return coerceIllegalVector(VT, NSRN, NPRN);
99 if (VT->getABISizeInBits() > 128)
103 if (!passAsAggregateType(RetTy)) {
105 if (IntTy->isBitInt())
106 if (RetTy->getSizeInBits().getFixedValue() > 128)
118 if (!RetTy->isSVESizelessType() && (RetTy->isEmptyRecord() ||
Size == 0))
124 !(Opts.IsILP32 && IsVariadicFn)) {
129 reportNYI(
"Aggregate return type handling");
133ArgInfo AArch64TargetInfo::classifyArgumentType(
134 const Type *Ty,
bool IsVariadicFn,
bool IsNamedArg,
135 unsigned CallingConvention,
unsigned &NSRN,
unsigned &NPRN)
const {
140 if (IsVariadicFn && Opts.IsWindowsArm64EC) {
141 reportNYI(
"Arm64EC variadic argument handling");
146 if (isIllegalVectorType(Ty))
149 if (!passAsAggregateType(Ty)) {
151 if (IntTy->isBitInt())
152 if (Ty->getSizeInBits().getFixedValue() > 128)
165 if (VT->isSVEPredicate() || VT->isSVECount())
166 NPRN = std::min(NPRN + 1, 4u);
168 NSRN = std::min(NSRN + 1, 8u);
170 if (
TT->getVectorType()->isSVEPredicate())
171 NPRN = std::min(NPRN +
TT->getNumVectors(), 4u);
173 NSRN = std::min(NSRN +
TT->getNumVectors(), 8u);
174 }
else if (Ty->isFloat()) {
175 NSRN = std::min(NSRN + 1, 8u);
193 if (!Ty->isSVESizelessType() && (Ty->isEmptyRecord() ||
Size == 0)) {
197 if (!Opts.IsCXX || isDarwinPCS())
212 bool IsWinVariadic = IsWin64 && IsVariadicFn;
216 NSRN = std::min(NSRN + Members,
uint64_t(8));
217 uint64_t BaseAllocSizeInBits =
Base->getTypeAllocSize().getFixedValue() * 8;
218 const Type *CoerceTy =
219 TB.getArrayType(
Base, Members, Members * BaseAllocSizeInBits);
225 unsigned TyAlign = Ty->getUnadjustedAlignment().value();
226 TyAlign = (TyAlign >= 16) ? 16 : 8;
230 reportNYI(
"Aggregate argument type handling");
234bool AArch64TargetInfo::passAsAggregateType(
const Type *Ty)
const {
239 assert((!TupleTy || TupleTy->getNumVectors() > 1) &&
240 "unexpected single vector tuple");
241 return TupleTy && !TupleTy->getVectorType()->isSVECount();
250const VectorType *AArch64TargetInfo::convertFixedToScalableVectorType(
255 if (VT->isFixedLengthSVEPredicate())
256 return TB.getScalablePredicateOrCountVectorType(
Align(2),
259 assert(VT->isFixedLengthSVEData() &&
"expected a fixed-length SVE vector!");
261 const Type *EltTy = VT->getElementType();
262 uint64_t EltBits = EltTy->getSizeInBits().getFixedValue();
264 "unexpected element type for SVE data vector!");
272 unsigned &NPRN)
const {
273 if (VT->isFixedLengthSVEPredicate()) {
278 VT->getElementType()->getSizeInBits().getFixedValue() == 8 &&
279 "unexpected element type for SVE predicate!");
280 NPRN = std::min(NPRN + 1, 4u);
285 if (VT->isFixedLengthSVEData()) {
286 NSRN = std::min(NSRN + 1, 8u);
292 if (Opts.IsAndroidOrOHOS && (
Size <= 16)) {
293 auto *ResType =
TB.getIntegerType(16, llvm::Align(2),
false);
296 const Type *
I32 =
TB.getIntegerType(32, llvm::Align(4),
false);
300 NSRN = std::min(NSRN + 1, 8u);
305 NSRN = std::min(NSRN + 1, 8u);
313bool AArch64TargetInfo::isIllegalVectorType(
const Type *Ty)
const {
318 if (VT->isFixedLengthSVEData() || VT->isFixedLengthSVEPredicate())
322 if (VT->isScalable())
326 unsigned NumElements = VT->getNumElements().getFixedValue();
334 if (Opts.IsILP32 && Opts.IsMachO)
337 return Size != 64 && (
Size != 128 || NumElements == 1);
342bool AArch64TargetInfo::isHomogeneousAggregateBaseType(
const Type *Ty)
const {
353 if (VT->isScalable() || VT->isSVEData() || VT->isSVEPredicate())
357 if (VecSize == 64 || VecSize == 128)
363bool AArch64TargetInfo::isHomogeneousAggregateSmallEnough(
375bool AArch64TargetInfo::isPermittedToBeHomogeneousAggregate(
377 if (Opts.IsMicrosoftCXXABI && RT->isCXXRecord()) {
380 reportNYI(
"MicrosoftCXXABI homogeneous record classification");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
FunctionLoweringInfo::StatepointRelocationRecord RecordType
Target-specific ABI information and factory functions.
static constexpr ElementCount getScalable(ScalarTy MinVal)
static constexpr ElementCount getFixed(ScalarTy MinVal)
Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI raw_ostream & warning()
Convenience method for printing "warning: " to stderr.
AArch64TargetInfo(TypeBuilder &TB, const AArch64ABIOptions &Opts)
void computeInfo(FunctionInfo &FI) const override
Populate FI with the target's ABI-lowering decisions for each argument and return value.
const ABICompatInfo & getABICompatInfo() const override
Return this target's ABI compatibility flags.
Helper class to encapsulate information about how a specific type should be passed to or returned fro...
static ArgInfo getIgnore()
static ArgInfo getExtend(const Type *T)
static ArgInfo getDirect(const Type *T=nullptr, unsigned Offset=0, MaybeAlign Align=std::nullopt, bool CanBeFlattened=true)
ArrayRef< ArgEntry > arguments() const
unsigned getNumRequiredArgs() const
CallingConv::ID getCallingConvention() const
ArgInfo & getReturnInfo()
const Type * getReturnType() const
virtual unsigned getAllocaAddrSpace() const
Address space in which indirect arguments are allocated (the target's alloca/stack space).
LLVM_ABI bool isHomogeneousAggregate(const Type *Ty, const Type *&Base, uint64_t &Members) const
Return true if Ty is an ELFv2-style homogeneous aggregate.
LLVM_ABI bool isPromotableInteger(const IntegerType *IT) const
virtual bool isZeroLengthBitfieldPermittedInHomogeneousAggregate() const
Return true if zero-length bitfields should be ignored when deciding whether an aggregate is homogene...
TargetInfo(TypeBuilder &Builder)
LLVM_ABI bool maybeCommonClassifyReturnType(FunctionInfo &FI) const
Apply rules for classifying return types that are common to all targets.
LLVM_ABI bool isAggregateTypeForABI(const Type *Ty) const
LLVM_ABI const Type * useFirstFieldIfTransparentUnion(const Type *Ty) const
If Ty is a transparent union, return its first field type; otherwise return Ty unchanged.
LLVM_ABI ArgInfo getNaturalAlignIndirect(const Type *Ty, unsigned AddrSpace, bool ByVal=true) const
LLVM_ABI RecordArgABI getRecordArgABI(const RecordType *RT) const
TypeBuilder manages the lifecycle of ABI types using bump pointer allocation.
Represents the ABI-specific view of a type in LLVM.
This file defines the type system for the LLVMABI library, which mirrors ABI-relevant aspects of fron...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
@ Win64
The C convention as implemented on Windows/x86-64 and AArch64.
static void reportNYI(StringRef Feature)
@ SVEPredicate
An AArch64 SVE predicate vector, such as svbool_t.
@ SVEData
An AArch64 SVE data vector, such as svint32_t.
@ RAA_DirectInMemory
Pass it on the stack using its defined layout.
LLVM_ABI std::unique_ptr< TargetInfo > createAArch64TargetInfo(TypeBuilder &TB, const AArch64ABIOptions &Opts)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Helper struct shared between Function Specialization and SCCP Solver.
Target / language flags that affect AArch64 ABI classification.
Flags controlling ABI compatibility behaviour that applies to every target.