]> granicus.if.org Git - clang/commitdiff
IRgen/x86-32: Factor out getIndirectResult(), to match x86-64 factoring.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 21 Apr 2010 19:10:51 +0000 (19:10 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 21 Apr 2010 19:10:51 +0000 (19:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102015 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetInfo.cpp

index ff38e77e1bdc8061aff20440b8124e4a2cfbc5eb..c6cc31b7b0a19b888a549576b514fb95fdb6ff74 100644 (file)
@@ -43,7 +43,8 @@ void ABIArgInfo::dump() const {
     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 @@ ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty,
                                           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 @@ class X86_32ABIInfo : public ABIInfo {
   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 @@ unsigned X86_32ABIInfo::getIndirectArgumentAlignment(QualType Ty,
   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 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
       // 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 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
         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 @@ class X86_64ABIInfo : public ABIInfo {
 
   /// 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,