diff options
author | Akira Hatanaka <ahatanaka@mips.com> | 2012-01-10 23:12:19 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@mips.com> | 2012-01-10 23:12:19 +0000 |
commit | 6d1080fd1851f18bd40bb46fa074aa1252b13e8e (patch) | |
tree | 074886085210559647f2290f025f0ea0770ce1ab /lib/CodeGen/TargetInfo.cpp | |
parent | 9659d59ec368933050684af573b6d32ab5714332 (diff) |
Flatten float complex arguments. N32/64 requires float complex arguments be
passed in floating point registers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147892 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TargetInfo.cpp')
-rw-r--r-- | lib/CodeGen/TargetInfo.cpp | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index 87c04eabda..128bb44bb5 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -3040,7 +3040,8 @@ namespace { class MipsABIInfo : public ABIInfo { bool IsO32; unsigned MinABIStackAlignInBytes; - llvm::Type* HandleStructTy(QualType Ty) const; + llvm::Type* GetFloatingPointTy(const BuiltinType *BT) const; + llvm::Type* HandleAggregates(QualType Ty) const; llvm::Type* returnAggregateInRegs(QualType RetTy, uint64_t Size) const; llvm::Type* getPaddingType(uint64_t Align, uint64_t Offset) const; public: @@ -3074,12 +3075,36 @@ public: }; } +llvm::Type *MipsABIInfo::GetFloatingPointTy(const BuiltinType *BT) const { + switch (BT->getKind()) { + case BuiltinType::Float: + return llvm::Type::getFloatTy(getVMContext()); + case BuiltinType::Double: + return llvm::Type::getDoubleTy(getVMContext()); + case BuiltinType::LongDouble: + return llvm::Type::getFP128Ty(getVMContext()); + default: + assert(false && "Unexpected floating point type."); + return 0; + } +} + // In N32/64, an aligned double precision floating point field is passed in // a register. -llvm::Type* MipsABIInfo::HandleStructTy(QualType Ty) const { +llvm::Type* MipsABIInfo::HandleAggregates(QualType Ty) const { if (IsO32) return 0; + SmallVector<llvm::Type*, 8> ArgList; + + if (Ty->isComplexType()) { + const ComplexType *CT = Ty->getAs<ComplexType>(); + const BuiltinType *BT = CT->getElementType()->getAs<BuiltinType>(); + llvm::Type *FT = GetFloatingPointTy(BT); + ArgList.append(2, FT); + return llvm::StructType::get(getVMContext(), ArgList); + } + const RecordType *RT = Ty->getAsStructureType(); if (!RT) @@ -3090,7 +3115,6 @@ llvm::Type* MipsABIInfo::HandleStructTy(QualType Ty) const { uint64_t StructSize = getContext().getTypeSize(Ty); assert(!(StructSize % 8) && "Size of structure must be multiple of 8."); - SmallVector<llvm::Type*, 8> ArgList; uint64_t LastOffset = 0; unsigned idx = 0; llvm::IntegerType *I64 = llvm::IntegerType::get(getVMContext(), 64); @@ -3168,7 +3192,7 @@ MipsABIInfo::classifyArgumentType(QualType Ty, uint64_t &Offset) const { // byval pointer or directly by coercing to another structure type. In the // latter case, padding is inserted if the offset of the aggregate is // unaligned. - llvm::Type *ResType = HandleStructTy(Ty); + llvm::Type *ResType = HandleAggregates(Ty); if (!ResType) return ABIArgInfo::getIndirect(0); |