[cfe-commits] r147892 - /cfe/trunk/lib/CodeGen/TargetInfo.cpp

Akira Hatanaka ahatanaka at mips.com
Tue Jan 10 15:12:19 PST 2012


Author: ahatanak
Date: Tue Jan 10 17:12:19 2012
New Revision: 147892

URL: http://llvm.org/viewvc/llvm-project?rev=147892&view=rev
Log:
Flatten float complex arguments. N32/64 requires float complex arguments be
passed in floating point registers.


Modified:
    cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=147892&r1=147891&r2=147892&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Jan 10 17:12:19 2012
@@ -3040,7 +3040,8 @@
 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 @@
 };
 }
 
+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 @@
   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 @@
     // 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);





More information about the cfe-commits mailing list