[cfe-commits] r63617 - in /cfe/trunk/lib/CodeGen: ABIInfo.h CGCall.cpp

Daniel Dunbar daniel at zuster.org
Mon Feb 2 22:30:18 PST 2009


Author: ddunbar
Date: Tue Feb  3 00:30:17 2009
New Revision: 63617

URL: http://llvm.org/viewvc/llvm-project?rev=63617&view=rev
Log:
Remove ABIArgInfo::Default kind, ABI is now responsible for specifying
acceptable kind with more precise semantics.

Modified:
    cfe/trunk/lib/CodeGen/ABIInfo.h
    cfe/trunk/lib/CodeGen/CGCall.cpp

Modified: cfe/trunk/lib/CodeGen/ABIInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ABIInfo.h?rev=63617&r1=63616&r2=63617&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/ABIInfo.h (original)
+++ cfe/trunk/lib/CodeGen/ABIInfo.h Tue Feb  3 00:30:17 2009
@@ -26,8 +26,6 @@
   class ABIArgInfo {
   public:
     enum Kind {
-      Default,
-      
       Direct,    /// Pass the argument directly using the normal
                  /// converted LLVM type.
 
@@ -54,7 +52,7 @@
                  /// are all scalar types or are themselves expandable
                  /// types.
   
-      KindFirst=Default, KindLast=Expand
+      KindFirst=Direct, KindLast=Expand
     };
   
   private:
@@ -67,11 +65,8 @@
                                 TypeData(TD),
                                 UIntData(0) {}
   public:
-    ABIArgInfo() : TheKind(Default), TypeData(0), UIntData(0) {}
+    ABIArgInfo() : TheKind(Direct), TypeData(0), UIntData(0) {}
 
-    static ABIArgInfo getDefault() { 
-      return ABIArgInfo(Default); 
-    }
     static ABIArgInfo getDirect() { 
       return ABIArgInfo(Direct); 
     }
@@ -92,7 +87,6 @@
     }
   
     Kind getKind() const { return TheKind; }
-    bool isDefault() const { return TheKind == Default; }
     bool isDirect() const { return TheKind == Direct; }
     bool isStructRet() const { return TheKind == StructRet; }
     bool isIgnore() const { return TheKind == Ignore; }

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=63617&r1=63616&r2=63617&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Feb  3 00:30:17 2009
@@ -230,7 +230,9 @@
 
 ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy,
                                             ASTContext &Context) const {
-  if (CodeGenFunction::hasAggregateLLVMType(RetTy)) {
+  if (RetTy->isVoidType()) {
+    return ABIArgInfo::getIgnore();
+  } else if (CodeGenFunction::hasAggregateLLVMType(RetTy)) {
     // Classify "single element" structs as their element type.
     const FieldDecl *SeltFD = isSingleElementStruct(RetTy);
     if (SeltFD) {
@@ -269,7 +271,7 @@
       return ABIArgInfo::getStructRet();
     }
   } else {
-    return ABIArgInfo::getDefault();
+    return ABIArgInfo::getDirect();
   }
 }
 
@@ -297,7 +299,7 @@
 
     return ABIArgInfo::getByVal(0);
   } else {
-    return ABIArgInfo::getDefault();
+    return ABIArgInfo::getDirect();
   }
 }
 
@@ -658,17 +660,31 @@
 
 ABIArgInfo X86_64ABIInfo::classifyArgumentType(QualType Ty,
                                               ASTContext &Context) const {
-  return ABIArgInfo::getDefault();
+  if (CodeGenFunction::hasAggregateLLVMType(Ty)) {
+    return ABIArgInfo::getByVal(0);
+  } else {
+    return ABIArgInfo::getDirect();
+  }
 }
 
 ABIArgInfo DefaultABIInfo::classifyReturnType(QualType RetTy,
                                             ASTContext &Context) const {
-  return ABIArgInfo::getDefault();
+  if (RetTy->isVoidType()) {
+    return ABIArgInfo::getIgnore();
+  } else if (CodeGenFunction::hasAggregateLLVMType(RetTy)) {
+    return ABIArgInfo::getStructRet();
+  } else {
+    return ABIArgInfo::getDirect();
+  }
 }
 
 ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty,
                                               ASTContext &Context) const {
-  return ABIArgInfo::getDefault();
+  if (CodeGenFunction::hasAggregateLLVMType(Ty)) {
+    return ABIArgInfo::getByVal(0);
+  } else {
+    return ABIArgInfo::getDirect();
+  }
 }
 
 const ABIInfo &CodeGenTypes::getABIInfo() const {
@@ -696,9 +712,6 @@
   assert(!Ty->isArrayType() && 
          "Array types cannot be passed directly.");
   ABIArgInfo Info = CGT.getABIInfo().classifyReturnType(Ty, CGT.getContext());
-  // Ensure default on aggregate types is StructRet.
-  if (Info.isDefault() && CodeGenFunction::hasAggregateLLVMType(Ty))
-    return ABIArgInfo::getStructRet();
   return Info;
 }
 
@@ -708,9 +721,6 @@
   assert(!Ty->isArrayType() && 
          "Array types cannot be passed directly.");
   ABIArgInfo Info = CGT.getABIInfo().classifyArgumentType(Ty, CGT.getContext());
-  // Ensure default on aggregate types is ByVal.
-  if (Info.isDefault() && CodeGenFunction::hasAggregateLLVMType(Ty))
-    return ABIArgInfo::getByVal(0);
   return Info;  
 }
 
@@ -889,14 +899,6 @@
   case ABIArgInfo::Expand:
     assert(0 && "Invalid ABI kind for return argument");
 
-  case ABIArgInfo::Default:
-    if (RetTy->isVoidType()) {
-      ResultType = llvm::Type::VoidTy;
-    } else {
-      ResultType = ConvertType(RetTy);
-    }
-    break;
-
   case ABIArgInfo::Direct:
     ResultType = ConvertType(RetTy);
     break;
@@ -936,7 +938,6 @@
       assert(AI.getByValAlignment() == 0 && "FIXME: alignment unhandled");
       break;
       
-    case ABIArgInfo::Default:
     case ABIArgInfo::Direct:
       ArgTys.push_back(Ty);
       break;
@@ -971,7 +972,6 @@
   unsigned Index = 1;
   const ABIArgInfo &RetAI = FI.getReturnInfo();
   switch (RetAI.getKind()) {
-  case ABIArgInfo::Default:
   case ABIArgInfo::Direct:
     if (RetTy->isPromotableIntegerType()) {
       if (RetTy->isSignedIntegerType()) {
@@ -1016,7 +1016,6 @@
       assert(AI.getByValAlignment() == 0 && "FIXME: alignment unhandled");
       break;
       
-    case ABIArgInfo::Default:
     case ABIArgInfo::Direct:
       if (ParamType->isPromotableIntegerType()) {
         if (ParamType->isSignedIntegerType()) {
@@ -1075,7 +1074,6 @@
 
     switch (ArgI.getKind()) {
     case ABIArgInfo::ByVal: 
-    case ABIArgInfo::Default:
     case ABIArgInfo::Direct: {
       assert(AI != Fn->arg_end() && "Argument mismatch!");
       llvm::Value* V = AI;
@@ -1143,7 +1141,6 @@
       }
       break;
 
-    case ABIArgInfo::Default:
     case ABIArgInfo::Direct:
       RV = Builder.CreateLoad(ReturnValue);
       break;
@@ -1186,7 +1183,6 @@
     Args.push_back(CreateTempAlloca(ConvertType(RetTy)));
     break;
     
-  case ABIArgInfo::Default:
   case ABIArgInfo::Direct:
   case ABIArgInfo::Ignore:
   case ABIArgInfo::Coerce:
@@ -1204,8 +1200,7 @@
     RValue RV = I->first;
 
     switch (ArgInfo.getKind()) {
-    case ABIArgInfo::ByVal: // Default is byval
-    case ABIArgInfo::Default:      
+    case ABIArgInfo::ByVal: // Direct is byval
     case ABIArgInfo::Direct:
       if (RV.isScalar()) {
         Args.push_back(RV.getScalarVal());
@@ -1254,18 +1249,18 @@
     else 
       return RValue::get(Builder.CreateLoad(Args[0]));
 
-  case ABIArgInfo::Default:
-    return RValue::get(RetTy->isVoidType() ? 0 : CI);
-    
   case ABIArgInfo::Direct:
     assert((!RetTy->isAnyComplexType() &&
-            CodeGenFunction::hasAggregateLLVMType(RetTy)) &&
-           "FIXME: Implemented return for non-scalar direct types.");
+            !CodeGenFunction::hasAggregateLLVMType(RetTy)) &&
+           "FIXME: Implement return for non-scalar direct types.");
     return RValue::get(CI);
 
   case ABIArgInfo::Ignore:
     if (RetTy->isVoidType())
       return RValue::get(0);
+    
+    // If we are ignoring an argument that had a result, make sure to
+    // construct the appropriate return value for our caller.
     if (CodeGenFunction::hasAggregateLLVMType(RetTy)) {
       llvm::Value *Res =
         llvm::UndefValue::get(llvm::PointerType::getUnqual(ConvertType(RetTy)));





More information about the cfe-commits mailing list