LLVM 24.0.0git
DefaultTargetInfo.cpp
Go to the documentation of this file.
1//===- DefaultTargetInfo.cpp - Default ABI classification -----------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11
12using namespace llvm::abi;
13using llvm::dyn_cast;
14
17
18 if (isAggregateTypeForABI(Ty)) {
19 // Records with non-trivial destructors/copy-constructors should not be
20 // passed by value.
21 if (RecordArgABI RAA = getRecordArgABI(Ty))
23 /*ByVal=*/RAA == RAA_DirectInMemory);
25 }
26
27 if (const auto *IT = dyn_cast<IntegerType>(Ty)) {
28 // A _BitInt too wide for the largest integer register goes indirect.
29 if (IT->isBitInt() &&
30 IT->getSizeInBits().getFixedValue() > getBitIntRegThreshold())
33 return ArgInfo::getExtend(Ty);
34 }
35
36 return ArgInfo::getDirect();
37}
38
40 if (RetTy->isVoid())
41 return ArgInfo::getIgnore();
42
43 if (isAggregateTypeForABI(RetTy))
45
46 if (const auto *IT = dyn_cast<IntegerType>(RetTy)) {
47 // A _BitInt too wide for the largest integer register goes indirect.
48 if (IT->isBitInt() &&
49 IT->getSizeInBits().getFixedValue() > getBitIntRegThreshold())
52 return ArgInfo::getExtend(RetTy);
53 }
54
55 return ArgInfo::getDirect();
56}
57
61 for (auto &I : FI.arguments())
62 I.Info = classifyArgumentType(I.ABIType);
63}
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
Default ABI classification shared by targets without special rules.
#define I(x, y, z)
Definition MD5.cpp:57
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)
ArgInfo classifyArgumentType(const Type *Ty) const
void computeInfo(FunctionInfo &FI) const override
Populate FI with the target's ABI-lowering decisions for each argument and return value.
ArgInfo classifyReturnType(const Type *RetTy) const
ArrayRef< ArgEntry > arguments() const
const Type * getReturnType() const
unsigned getBitIntRegThreshold() const
Bit width above which a _BitInt cannot stay in registers.
Definition TargetInfo.h:99
virtual unsigned getAllocaAddrSpace() const
Address space in which indirect arguments are allocated (the target's alloca/stack space).
Definition TargetInfo.h:85
LLVM_ABI bool isPromotableInteger(const IntegerType *IT) const
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
Represents the ABI-specific view of a type in LLVM.
Definition Types.h:46
bool isVoid() const
Definition Types.h:92
@ RAA_DirectInMemory
Pass it on the stack using its defined layout.
Definition TargetInfo.h:34
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643