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

Daniel Dunbar daniel at zuster.org
Wed Apr 21 12:10:51 PDT 2010


Author: ddunbar
Date: Wed Apr 21 14:10:51 2010
New Revision: 102015

URL: http://llvm.org/viewvc/llvm-project?rev=102015&view=rev
Log:
IRgen/x86-32: Factor out getIndirectResult(), to match x86-64 factoring.

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=102015&r1=102014&r2=102015&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Apr 21 14:10:51 2010
@@ -43,7 +43,8 @@
     getCoerceToType()->print(OS);
     break;
   case Indirect:
-    OS << "Indirect Align=" << getIndirectAlign();
+    OS << "Indirect Align=" << getIndirectAlign()
+       << " Byal=" << getIndirectByVal();
     break;
   case Expand:
     OS << "Expand";
@@ -270,7 +271,7 @@
                                           llvm::LLVMContext &VMContext) const {
   if (CodeGenFunction::hasAggregateLLVMType(Ty))
     return ABIArgInfo::getIndirect(0);
-  
+
   // Treat an enum type as its underlying type.
   if (const EnumType *EnumTy = Ty->getAs<EnumType>())
     Ty = EnumTy->getDecl()->getIntegerType();
@@ -294,6 +295,11 @@
   static unsigned getIndirectArgumentAlignment(QualType Ty,
                                                ASTContext &Context);
 
+  /// getIndirectResult - Give a source type \arg Ty, return a suitable result
+  /// such that the argument will be passed in memory.
+  ABIArgInfo getIndirectResult(QualType Ty, ASTContext &Context,
+                               bool ByVal = true) const;
+
 public:
   ABIArgInfo classifyReturnType(QualType RetTy,
                                 ASTContext &Context,
@@ -500,6 +506,13 @@
   return 0;
 }
 
+ABIArgInfo X86_32ABIInfo::getIndirectResult(QualType Ty,
+                                            ASTContext &Context,
+                                            bool ByVal) const {
+  return ABIArgInfo::getIndirect(getIndirectArgumentAlignment(Ty, Context),
+                                 ByVal);
+}
+
 ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
                                                ASTContext &Context,
                                            llvm::LLVMContext &VMContext) const {
@@ -510,11 +523,10 @@
       // Structures with either a non-trivial destructor or a non-trivial
       // copy constructor are always indirect.
       if (hasNonTrivialDestructorOrCopyConstructor(RT))
-        return ABIArgInfo::getIndirect(0, /*ByVal=*/false);
-        
+        return getIndirectResult(Ty, Context, /*ByVal=*/false);
+
       if (RT->getDecl()->hasFlexibleArrayMember())
-        return ABIArgInfo::getIndirect(getIndirectArgumentAlignment(Ty,
-                                                                    Context));
+        return getIndirectResult(Ty, Context);
     }
 
     // Ignore empty structs.
@@ -529,7 +541,7 @@
         canExpandIndirectArgument(Ty, Context))
       return ABIArgInfo::getExpand();
 
-    return ABIArgInfo::getIndirect(getIndirectArgumentAlignment(Ty, Context));
+    return getIndirectResult(Ty, Context);
   } else {
     if (const EnumType *EnumTy = Ty->getAs<EnumType>())
       Ty = EnumTy->getDecl()->getIntegerType();
@@ -686,8 +698,7 @@
 
   /// getIndirectResult - Give a source type \arg Ty, return a suitable result
   /// such that the argument will be passed in memory.
-  ABIArgInfo getIndirectResult(QualType Ty,
-                               ASTContext &Context) const;
+  ABIArgInfo getIndirectResult(QualType Ty, ASTContext &Context) const;
 
   ABIArgInfo classifyReturnType(QualType RetTy,
                                 ASTContext &Context,





More information about the cfe-commits mailing list