]> granicus.if.org Git - clang/commitdiff
dissolve some more complexity: make the x86-64 abi lowering code
authorChris Lattner <sabre@nondot.org>
Thu, 29 Jul 2010 02:31:05 +0000 (02:31 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 29 Jul 2010 02:31:05 +0000 (02:31 +0000)
compute its own preferred types instead of having CGT compute
them then pass them (circuituously) down into ABIInfo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109726 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/ABIInfo.h
lib/CodeGen/CGCall.cpp
lib/CodeGen/TargetInfo.cpp

index 7ce7c450107ae5006c750c3d23d463112026123a..30f99c31e3df66b6cbb2751194f25c44a4727f2a 100644 (file)
@@ -139,11 +139,7 @@ namespace clang {
     llvm::LLVMContext &getVMContext() const;
     const llvm::TargetData &getTargetData() const;
 
-    virtual void computeInfo(CodeGen::CGFunctionInfo &FI,
-                             // This is the preferred type for argument lowering
-                             // which can be used to generate better IR.
-                             const llvm::Type *const *PrefTypes = 0,
-                             unsigned NumPrefTypes = 0) const = 0;
+    virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
 
     /// EmitVAArg - Emit the target dependent code to load a value of
     /// \arg Ty from the va_list pointed to by \arg VAListAddr.
index acdec4646bf1ad44d84331c21664d505eb2c3d33..f0e107973c1938a5728887b852ce4d43015ec97b 100644 (file)
@@ -243,34 +243,14 @@ const CGFunctionInfo &CodeGenTypes::getFunctionInfo(CanQualType ResTy,
                           ArgTys.data(), ArgTys.size());
   FunctionInfos.InsertNode(FI, InsertPos);
 
-  // ABI lowering wants to know what our preferred type for the argument is in
-  // various situations, pass it in.
-  llvm::SmallVector<const llvm::Type *, 8> PreferredArgTypes;
-  for (llvm::SmallVectorImpl<CanQualType>::const_iterator
-       I = ArgTys.begin(), E = ArgTys.end(); I != E; ++I) {
-    // If this is being called from the guts of the ConvertType loop, make sure
-    // to call ConvertTypeRecursive so we don't get into issues with cyclic
-    // pointer type structures.
-    PreferredArgTypes.push_back(ConvertTypeRecursive(*I));
-  }
-  
   // Compute ABI information.
-  getABIInfo().computeInfo(*FI, PreferredArgTypes.data(),
-                           PreferredArgTypes.size());
+  getABIInfo().computeInfo(*FI);
 
   // If this is a top-level call and ConvertTypeRecursive hit unresolved pointer
   // types, resolve them now.  These pointers may point to this function, which
   // we *just* filled in the FunctionInfo for.
-  if (!IsRecursive && !PointersToResolve.empty()) {
-    // Use PATypeHolder's so that our preferred types don't dangle under
-    // refinement.
-    llvm::SmallVector<llvm::PATypeHolder, 8> Handles(PreferredArgTypes.begin(),
-                                                     PreferredArgTypes.end());
+  if (!IsRecursive && !PointersToResolve.empty())
     HandleLateResolvedPointers();
-    PreferredArgTypes.clear();
-    PreferredArgTypes.append(Handles.begin(), Handles.end());
-  }
-  
   
   return *FI;
 }
index a36f9a5579656fb05c2604ec9142b7d95b76d98a..bba239e2059f4cb5deb74495393d072d3daf328a 100644 (file)
@@ -291,9 +291,7 @@ public:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
   ABIArgInfo classifyArgumentType(QualType RetTy) const;
 
-  virtual void computeInfo(CGFunctionInfo &FI,
-                           const llvm::Type *const *PrefTypes,
-                           unsigned NumPrefTypes) const {
+  virtual void computeInfo(CGFunctionInfo &FI) const {
     FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
     for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
          it != ie; ++it)
@@ -351,9 +349,7 @@ public:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
   ABIArgInfo classifyArgumentType(QualType RetTy) const;
 
-  virtual void computeInfo(CGFunctionInfo &FI,
-                           const llvm::Type *const *PrefTypes,
-                           unsigned NumPrefTypes) const {
+  virtual void computeInfo(CGFunctionInfo &FI) const {
     FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
     for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
          it != ie; ++it)
@@ -756,9 +752,7 @@ class X86_64ABIInfo : public ABIInfo {
 public:
   X86_64ABIInfo(CodeGen::CodeGenTypes &CGT) : ABIInfo(CGT) {}
 
-  virtual void computeInfo(CGFunctionInfo &FI, 
-                           const llvm::Type *const *PrefTypes,
-                           unsigned NumPrefTypes) const;
+  virtual void computeInfo(CGFunctionInfo &FI) const;
 
   virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
                                  CodeGenFunction &CGF) const;
@@ -1452,9 +1446,7 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType(QualType Ty, unsigned &neededInt,
   return getCoerceResult(Ty, ResType);
 }
 
-void X86_64ABIInfo::computeInfo(CGFunctionInfo &FI, 
-                                const llvm::Type *const *PrefTypes,
-                                unsigned NumPrefTypes) const {
+void X86_64ABIInfo::computeInfo(CGFunctionInfo &FI) const {
   FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
 
   // Keep track of the number of assigned registers.
@@ -1469,13 +1461,9 @@ void X86_64ABIInfo::computeInfo(CGFunctionInfo &FI,
   // get assigned (in left-to-right order) for passing as follows...
   for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
        it != ie; ++it) {
-    // If the client specified a preferred IR type to use, pass it down to
+    // Determine the preferred IR type to use and pass it down to
     // classifyArgumentType.
-    const llvm::Type *PrefType = 0;
-    if (NumPrefTypes) {
-      PrefType = *PrefTypes++;
-      --NumPrefTypes;
-    }
+    const llvm::Type *PrefType = CGT.ConvertTypeRecursive(it->type);
       
     unsigned neededInt, neededSSE;
     it->info = classifyArgumentType(it->type, neededInt, neededSSE, PrefType);
@@ -1719,9 +1707,7 @@ public:
 
   ABIArgInfo classifyArgumentType(QualType RetTy) const;
 
-  virtual void computeInfo(CGFunctionInfo &FI, 
-                           const llvm::Type *const *PrefTypes,
-                           unsigned NumPrefTypes) const {
+  virtual void computeInfo(CGFunctionInfo &FI) const {
     FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
     for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
          it != ie; ++it)
@@ -1864,9 +1850,7 @@ private:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
   ABIArgInfo classifyArgumentType(QualType RetTy) const;
 
-  virtual void computeInfo(CGFunctionInfo &FI,
-                           const llvm::Type *const *PrefTypes,
-                           unsigned NumPrefTypes) const;
+  virtual void computeInfo(CGFunctionInfo &FI) const;
 
   virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
                                  CodeGenFunction &CGF) const;
@@ -1884,9 +1868,7 @@ public:
 
 }
 
-void ARMABIInfo::computeInfo(CGFunctionInfo &FI,
-                             const llvm::Type *const *PrefTypes,
-                             unsigned NumPrefTypes) const {
+void ARMABIInfo::computeInfo(CGFunctionInfo &FI) const {
   FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
   for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
        it != ie; ++it)
@@ -2160,9 +2142,7 @@ public:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
   ABIArgInfo classifyArgumentType(QualType RetTy) const;
 
-  virtual void computeInfo(CGFunctionInfo &FI,
-                           const llvm::Type *const *PrefTypes,
-                           unsigned NumPrefTypes) const {
+  virtual void computeInfo(CGFunctionInfo &FI) const {
     FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
     for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
          it != ie; ++it)