]> granicus.if.org Git - clang/commitdiff
Pass the LLVM IR version of argument types down into computeInfo.
authorChris Lattner <sabre@nondot.org>
Tue, 29 Jun 2010 01:08:48 +0000 (01:08 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 29 Jun 2010 01:08:48 +0000 (01:08 +0000)
This is somewhat annoying to do this at this level, but it avoids
having ABIInfo know depend on CodeGenTypes for a hint.

Nothing is using this yet, so no functionality change.

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

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

index 1ab2f55295fa005a6ca9de7eb544708b902a8cc5..c1efd056c7b0ae2b660f9b0ba73636785e6e7112 100644 (file)
@@ -136,7 +136,11 @@ namespace clang {
 
     virtual void computeInfo(CodeGen::CGFunctionInfo &FI,
                              ASTContext &Ctx,
-                             llvm::LLVMContext &VMContext) const = 0;
+                             llvm::LLVMContext &VMContext,
+                             // 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;
 
     /// EmitVAArg - Emit the target dependent code to load a value of
     /// \arg Ty from the va_list pointed to by \arg VAListAddr.
index 7ade4272fa906a5442c1e542b51ab704cef4d5eb..d7a03c9bbfaba964ec74ad22710b8413bcd9a497 100644 (file)
@@ -244,8 +244,16 @@ const CGFunctionInfo &CodeGenTypes::getFunctionInfo(CanQualType ResTy,
                           ArgTys);
   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)
+    PreferredArgTypes.push_back(ConvertType(*I));
+
   // Compute ABI information.
-  getABIInfo().computeInfo(*FI, getContext(), TheModule.getContext());
+  getABIInfo().computeInfo(*FI, getContext(), TheModule.getContext(),
+                           PreferredArgTypes.data(), PreferredArgTypes.size());
 
   return *FI;
 }
index 80163b3772eb9cc529b6f2edb47bc22109b51623..3bdfbf641c234991aaac7ff226c5085c674836aa 100644 (file)
@@ -280,7 +280,9 @@ class DefaultABIInfo : public ABIInfo {
                                   llvm::LLVMContext &VMContext) const;
 
   virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
-                           llvm::LLVMContext &VMContext) const {
+                           llvm::LLVMContext &VMContext,
+                           const llvm::Type *const *PrefTypes,
+                           unsigned NumPrefTypes) const {
     FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context,
                                             VMContext);
     for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
@@ -347,7 +349,9 @@ public:
                                   llvm::LLVMContext &VMContext) const;
 
   virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
-                           llvm::LLVMContext &VMContext) const {
+                           llvm::LLVMContext &VMContext,
+                           const llvm::Type *const *PrefTypes,
+                           unsigned NumPrefTypes) const {
     FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context,
                                             VMContext);
     for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
@@ -747,7 +751,9 @@ class X86_64ABIInfo : public ABIInfo {
 
 public:
   virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
-                           llvm::LLVMContext &VMContext) const;
+                           llvm::LLVMContext &VMContext,
+                           const llvm::Type *const *PrefTypes,
+                           unsigned NumPrefTypes) const;
 
   virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
                                  CodeGenFunction &CGF) const;
@@ -1373,7 +1379,9 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType(QualType Ty, ASTContext &Context,
 }
 
 void X86_64ABIInfo::computeInfo(CGFunctionInfo &FI, ASTContext &Context,
-                                llvm::LLVMContext &VMContext) const {
+                                llvm::LLVMContext &VMContext,
+                                const llvm::Type *const *PrefTypes,
+                                unsigned NumPrefTypes) const {
   FI.getReturnInfo() = classifyReturnType(FI.getReturnType(),
                                           Context, VMContext);
 
@@ -1635,7 +1643,9 @@ class PIC16ABIInfo : public ABIInfo {
                                   llvm::LLVMContext &VMContext) const;
 
   virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
-                           llvm::LLVMContext &VMContext) const {
+                           llvm::LLVMContext &VMContext,
+                           const llvm::Type *const *PrefTypes,
+                           unsigned NumPrefTypes) const {
     FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context,
                                             VMContext);
     for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
@@ -1786,7 +1796,9 @@ private:
                                   llvm::LLVMContext &VMContext) const;
 
   virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
-                           llvm::LLVMContext &VMContext) const;
+                           llvm::LLVMContext &VMContext,
+                           const llvm::Type *const *PrefTypes,
+                           unsigned NumPrefTypes) const;
 
   virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
                                  CodeGenFunction &CGF) const;
@@ -1805,7 +1817,9 @@ public:
 }
 
 void ARMABIInfo::computeInfo(CGFunctionInfo &FI, ASTContext &Context,
-                             llvm::LLVMContext &VMContext) const {
+                             llvm::LLVMContext &VMContext,
+                             const llvm::Type *const *PrefTypes,
+                             unsigned NumPrefTypes) const {
   FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context,
                                           VMContext);
   for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
@@ -2088,7 +2102,9 @@ class SystemZABIInfo : public ABIInfo {
                                   llvm::LLVMContext &VMContext) const;
 
   virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
-                          llvm::LLVMContext &VMContext) const {
+                          llvm::LLVMContext &VMContext,
+                           const llvm::Type *const *PrefTypes,
+                           unsigned NumPrefTypes) const {
     FI.getReturnInfo() = classifyReturnType(FI.getReturnType(),
                                             Context, VMContext);
     for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();