10#include "TargetInfo.h"
26 LanaiABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
28 bool shouldUseInReg(QualType Ty, CCState &State)
const;
30 void computeInfo(CGFunctionInfo &FI)
const override {
46 ABIArgInfo getIndirectResult(QualType Ty,
bool ByVal, CCState &State)
const;
51bool LanaiABIInfo::shouldUseInReg(
QualType Ty, CCState &State)
const {
52 unsigned Size = getContext().getTypeSize(Ty);
53 unsigned SizeInRegs = llvm::alignTo(Size, 32U) / 32U;
58 if (SizeInRegs > State.FreeRegs) {
63 State.FreeRegs -= SizeInRegs;
68ABIArgInfo LanaiABIInfo::getIndirectResult(QualType Ty,
bool ByVal,
69 CCState &State)
const {
73 return getNaturalAlignIndirectInReg(Ty);
75 return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
80 const unsigned MinABIStackAlignInBytes = 4;
81 unsigned TypeAlign = getContext().getTypeAlign(Ty) / 8;
84 getDataLayout().getAllocaAddrSpace(),
true,
85 TypeAlign > MinABIStackAlignInBytes);
88ABIArgInfo LanaiABIInfo::classifyArgumentType(QualType Ty,
89 CCState &State)
const {
95 return getIndirectResult(Ty,
false, State);
97 return getNaturalAlignIndirect(
98 Ty, getDataLayout().getAllocaAddrSpace(),
106 RT->getOriginalDecl()->getDefinitionOrSelf()->hasFlexibleArrayMember())
107 return getIndirectResult(Ty,
true, State);
113 llvm::LLVMContext &LLVMContext = getVMContext();
114 unsigned SizeInRegs = (getContext().getTypeSize(Ty) + 31) / 32;
115 if (SizeInRegs <= State.FreeRegs) {
116 llvm::IntegerType *
Int32 = llvm::Type::getInt32Ty(LLVMContext);
117 SmallVector<llvm::Type *, 3> Elements(SizeInRegs, Int32);
118 llvm::Type *
Result = llvm::StructType::get(LLVMContext, Elements);
119 State.FreeRegs -= SizeInRegs;
124 return getIndirectResult(Ty,
true, State);
129 Ty = ED->getIntegerType();
131 bool InReg = shouldUseInReg(Ty, State);
134 if (
const auto *EIT = Ty->
getAs<BitIntType>())
135 if (EIT->getNumBits() > 64)
136 return getIndirectResult(Ty,
true, State);
138 if (isPromotableIntegerTypeForABI(Ty)) {
149class LanaiTargetCodeGenInfo :
public TargetCodeGenInfo {
151 LanaiTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
152 : TargetCodeGenInfo(std::make_unique<LanaiABIInfo>(CGT)) {}
156std::unique_ptr<TargetCodeGenInfo>
158 return std::make_unique<LanaiTargetCodeGenInfo>(CGM.
getTypes());
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
static ABIArgInfo getIgnore()
static ABIArgInfo getDirect(llvm::Type *T=nullptr, unsigned Offset=0, llvm::Type *Padding=nullptr, bool CanBeFlattened=true, unsigned Align=0)
static ABIArgInfo getIndirect(CharUnits Alignment, unsigned AddrSpace, bool ByVal=true, bool Realign=false, llvm::Type *Padding=nullptr)
static ABIArgInfo getExtend(QualType Ty, llvm::Type *T=nullptr)
static ABIArgInfo getDirectInReg(llvm::Type *T=nullptr)
RecordArgABI
Specify how one should pass an argument of a record type.
@ RAA_Indirect
Pass it as a pointer to temporary memory.
@ RAA_DirectInMemory
Pass it on the stack using its defined layout.
ABIArgInfo & getReturnInfo()
unsigned getRegParm() const
CanQualType getReturnType() const
bool getHasRegParm() const
MutableArrayRef< ArgInfo > arguments()
This class organizes the cross-function state that is used while generating LLVM code.
CodeGenTypes & getTypes()
DefaultABIInfo - The default implementation for ABI specific details.
A (possibly-)qualified type.
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
const T * getAs() const
Member-template getAs<specific type>'.
ABIArgInfo classifyArgumentType(CodeGenModule &CGM, CanQualType type)
Classify the rules for how to pass a particular type.
CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT, CGCXXABI &CXXABI)
bool classifyReturnType(const CGCXXABI &CXXABI, CGFunctionInfo &FI, const ABIInfo &Info)
bool isAggregateTypeForABI(QualType T)
bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays, bool AsIfNoUniqueAddr=false)
isEmptyRecord - Return true iff a structure contains only empty fields.
std::unique_ptr< TargetCodeGenInfo > createLanaiTargetCodeGenInfo(CodeGenModule &CGM)
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.