From: Chris Lattner Date: Thu, 29 Jul 2010 02:31:05 +0000 (+0000) Subject: dissolve some more complexity: make the x86-64 abi lowering code X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee5dcd064a811edc90f6c1fb31a837b6c961fed7;p=clang dissolve some more complexity: make the x86-64 abi lowering code 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 --- diff --git a/lib/CodeGen/ABIInfo.h b/lib/CodeGen/ABIInfo.h index 7ce7c45010..30f99c31e3 100644 --- a/lib/CodeGen/ABIInfo.h +++ b/lib/CodeGen/ABIInfo.h @@ -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. diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index acdec4646b..f0e107973c 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -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 PreferredArgTypes; - for (llvm::SmallVectorImpl::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 Handles(PreferredArgTypes.begin(), - PreferredArgTypes.end()); + if (!IsRecursive && !PointersToResolve.empty()) HandleLateResolvedPointers(); - PreferredArgTypes.clear(); - PreferredArgTypes.append(Handles.begin(), Handles.end()); - } - return *FI; } diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index a36f9a5579..bba239e205 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -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)