LLVM 23.0.0git
TargetInfo.cpp
Go to the documentation of this file.
1//===- TargetInfo.cpp - Target ABI information ----------------------------===//
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
10
11using namespace llvm::abi;
12
14 // Check for fundamental scalar types.
15 if (Ty->isInteger() || Ty->isFloat() || Ty->isPointer() || Ty->isVector())
16 return false;
17
18 // Everything else is treated as aggregate.
19 return true;
20}
21
23 // TODO: The threshold should be the target's int size rather than a
24 // hardcoded 32.
25 unsigned BitWidth = IT->getSizeInBits().getFixedValue();
26 return BitWidth < 32;
27}
28
29ArgInfo TargetInfo::getNaturalAlignIndirect(const Type *Ty, bool ByVal) const {
30 return ArgInfo::getIndirect(Ty->getAlignment(), ByVal);
31}
32
34 if (RT && !RT->canPassInRegisters())
35 return RAA_Indirect;
36 return RAA_Default;
37}
38
40 // TODO: When Microsoft ABI is supported, CXX records may need different
41 // handling here (see MicrosoftCXXABI::getRecordArgABI in Clang).
42 const RecordType *RT = dyn_cast<RecordType>(Ty);
43 if (!RT)
44 return RAA_Default;
45 return getRecordArgABI(RT);
46}
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")))
Target-specific ABI information and factory functions.
Helper class to encapsulate information about how a specific type should be passed to or returned fro...
static ArgInfo getIndirect(Align Align, bool ByVal, unsigned AddrSpace=0, bool Realign=false)
Realign: the caller couldn't guarantee sufficient alignment - the callee must copy the argument to a ...
bool canPassInRegisters() const
Definition Types.h:291
ArgInfo getNaturalAlignIndirect(const Type *Ty, bool ByVal=true) const
bool isPromotableInteger(const IntegerType *IT) const
bool isAggregateTypeForABI(const Type *Ty) const
RecordArgABI getRecordArgABI(const RecordType *RT) const
Represents the ABI-specific view of a type in LLVM.
Definition Types.h:43
@ RAA_Indirect
Pass it as a pointer to temporary memory.
Definition TargetInfo.h:35
@ RAA_Default
Pass it using the normal C aggregate rules for the ABI, potentially introducing extra copies and pass...
Definition TargetInfo.h:27
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
constexpr unsigned BitWidth