10#include "TargetInfo.h"
20 static const int NumArgGPRs = 4;
21 static const int NumArgFPRs = 4;
23 static const unsigned XLen = 32;
27 CSKYABIInfo(CodeGen::CodeGenTypes &CGT,
unsigned FLen)
28 : DefaultABIInfo(CGT), FLen(FLen) {}
30 void computeInfo(CGFunctionInfo &FI)
const override;
33 bool isReturnType =
false)
const;
36 RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
37 AggValueSlot Slot)
const override;
52 int ArgGPRsLeft = IsRetIndirect ? NumArgGPRs - 1 : NumArgGPRs;
53 int ArgFPRsLeft = FLen ? NumArgFPRs : 0;
60RValue CSKYABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
61 QualType Ty, AggValueSlot Slot)
const {
68 auto TInfo = getContext().getTypeInfoInChars(Ty);
74ABIArgInfo CSKYABIInfo::classifyArgumentType(QualType Ty,
int &ArgGPRsLeft,
76 bool isReturnType)
const {
77 assert(ArgGPRsLeft <= NumArgGPRs &&
"Arg GPR tracking underflow");
85 return getNaturalAlignIndirect(
86 Ty, getDataLayout().getAllocaAddrSpace(),
109 QualType EltTy = Ty->
castAs<ComplexType>()->getElementType();
110 if (getContext().getTypeSize(EltTy) <= FLen) {
119 Ty = ED->getIntegerType();
123 if (Size < XLen && Ty->isIntegralOrEnumerationType())
126 if (
const auto *EIT = Ty->
getAs<BitIntType>()) {
127 if (EIT->getNumBits() < XLen)
139 if (!isReturnType || (isReturnType && Size <= 2 * XLen)) {
142 llvm::IntegerType::get(getVMContext(), XLen));
145 llvm::IntegerType::get(getVMContext(), XLen), (Size + 31) / XLen));
148 return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
152ABIArgInfo CSKYABIInfo::classifyReturnType(QualType RetTy)
const {
157 int ArgFPRsLeft = FLen ? 1 : 0;
165class CSKYTargetCodeGenInfo :
public TargetCodeGenInfo {
167 CSKYTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT,
unsigned FLen)
168 : TargetCodeGenInfo(std::make_unique<CSKYABIInfo>(CGT, FLen)) {}
172std::unique_ptr<TargetCodeGenInfo>
174 return std::make_unique<CSKYTargetCodeGenInfo>(CGM.
getTypes(), FLen);
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)
@ Indirect
Indirect - Pass the argument indirectly via a hidden pointer with the specified alignment (0 indicate...
static ABIArgInfo getExtend(QualType Ty, llvm::Type *T=nullptr)
RecordArgABI
Specify how one should pass an argument of a record type.
@ RAA_DirectInMemory
Pass it on the stack using its defined layout.
CGFunctionInfo - Class to encapsulate the information about a function definition.
ABIArgInfo & getReturnInfo()
CanQualType getReturnType() 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.
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
EnumDecl * getAsEnumDecl() const
Retrieves the EnumDecl this type refers to.
bool isFloatingType() const
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)
RValue emitVoidPtrVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType ValueTy, bool IsIndirect, TypeInfoChars ValueInfo, CharUnits SlotSizeAndAlign, bool AllowHigherAlign, AggValueSlot Slot, bool ForceRightAdjust=false)
Emit va_arg for a platform using the common void* representation, where arguments are simply emitted ...
bool isAggregateTypeForABI(QualType T)
const Type * isSingleElementStruct(QualType T, ASTContext &Context)
isSingleElementStruct - Determine if a structure is a "singleelement struct", i.e.
QualType useFirstFieldIfTransparentUnion(QualType Ty)
Pass transparent unions as if they were the type of the first element.
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 > createCSKYTargetCodeGenInfo(CodeGenModule &CGM, unsigned FLen)
The JSON file list parser is used to communicate input to InstallAPI.
@ Type
The name was classified as a type.