[cfe-commits] r63619 - in /cfe/trunk/lib/CodeGen: ABIInfo.h CGCall.cpp
Daniel Dunbar
daniel at zuster.org
Mon Feb 2 22:51:18 PST 2009
Author: ddunbar
Date: Tue Feb 3 00:51:18 2009
New Revision: 63619
URL: http://llvm.org/viewvc/llvm-project?rev=63619&view=rev
Log:
Change ABIInfo to compute information for a full signature at a time
(the main point of this restructing).
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=63619&r1=63618&r2=63619&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ABIInfo.h (original)
+++ cfe/trunk/lib/CodeGen/ABIInfo.h Tue Feb 3 00:51:18 2009
@@ -15,6 +15,14 @@
}
namespace clang {
+ class ASTContext;
+
+ // FIXME: This is a layering issue if we want to move ABIInfo
+ // down. Fortunately CGFunctionInfo has no real tie to CodeGen.
+ namespace CodeGen {
+ class CGFunctionInfo;
+ }
+
/* FIXME: All of this stuff should be part of the target interface
somehow. It is currently here because it is not clear how to factor
the targets to support this, since the Targets currently live in a
@@ -112,12 +120,9 @@
class ABIInfo {
public:
virtual ~ABIInfo();
-
- virtual ABIArgInfo classifyReturnType(QualType RetTy,
- ASTContext &Context) const = 0;
-
- virtual ABIArgInfo classifyArgumentType(QualType Ty,
- ASTContext &Context) const = 0;
+
+ virtual void computeInfo(CodeGen::CGFunctionInfo &FI,
+ ASTContext &Ctx) const = 0;
};
} // end namespace clang
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=63619&r1=63618&r2=63619&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Feb 3 00:51:18 2009
@@ -87,9 +87,6 @@
return getFunctionInfo(ResTy, ArgTys);
}
-static ABIArgInfo getABIReturnInfo(QualType Ty, CodeGenTypes &CGT);
-static ABIArgInfo getABIArgumentInfo(QualType Ty, CodeGenTypes &CGT);
-
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(QualType ResTy,
const llvm::SmallVector<QualType, 16> &ArgTys) {
// Lookup or create unique function info.
@@ -106,10 +103,7 @@
FunctionInfos.InsertNode(FI, InsertPos);
// Compute ABI information.
- FI->getReturnInfo() = getABIReturnInfo(ResTy, *this);
- for (CGFunctionInfo::arg_iterator it = FI->arg_begin(), ie = FI->arg_end();
- it != ie; ++it)
- it->info = getABIArgumentInfo(it->type, *this);
+ getABIInfo().computeInfo(*FI, getContext());
return *FI;
}
@@ -207,24 +201,38 @@
namespace {
/// DefaultABIInfo - The default implementation for ABI specific
/// details. This implementation provides information which results in
-/// sensible LLVM IR generation, but does not conform to any
-/// particular ABI.
+/// self-consistent and sensible LLVM IR generation, but does not
+/// conform to any particular ABI.
class DefaultABIInfo : public ABIInfo {
- virtual ABIArgInfo classifyReturnType(QualType RetTy,
- ASTContext &Context) const;
+ ABIArgInfo classifyReturnType(QualType RetTy,
+ ASTContext &Context) const;
+
+ ABIArgInfo classifyArgumentType(QualType RetTy,
+ ASTContext &Context) const;
- virtual ABIArgInfo classifyArgumentType(QualType RetTy,
- ASTContext &Context) const;
+ virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context) const {
+ FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context);
+ for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
+ it != ie; ++it)
+ it->info = classifyArgumentType(it->type, Context);
+ }
};
/// X86_32ABIInfo - The X86-32 ABI information.
class X86_32ABIInfo : public ABIInfo {
public:
- virtual ABIArgInfo classifyReturnType(QualType RetTy,
- ASTContext &Context) const;
+ ABIArgInfo classifyReturnType(QualType RetTy,
+ ASTContext &Context) const;
- virtual ABIArgInfo classifyArgumentType(QualType RetTy,
- ASTContext &Context) const;
+ ABIArgInfo classifyArgumentType(QualType RetTy,
+ ASTContext &Context) const;
+
+ virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context) const {
+ FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context);
+ for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
+ it != ie; ++it)
+ it->info = classifyArgumentType(it->type, Context);
+ }
};
}
@@ -353,11 +361,18 @@
Class &Lo, Class &Hi) const;
public:
- virtual ABIArgInfo classifyReturnType(QualType RetTy,
- ASTContext &Context) const;
-
- virtual ABIArgInfo classifyArgumentType(QualType RetTy,
- ASTContext &Context) const;
+ ABIArgInfo classifyReturnType(QualType RetTy,
+ ASTContext &Context) const;
+
+ ABIArgInfo classifyArgumentType(QualType RetTy,
+ ASTContext &Context) const;
+
+ virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context) const {
+ FI.getReturnInfo() = classifyReturnType(FI.getReturnType(), Context);
+ for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
+ it != ie; ++it)
+ it->info = classifyArgumentType(it->type, Context);
+ }
};
}
@@ -706,24 +721,6 @@
return *(TheABIInfo = new DefaultABIInfo);
}
-// getABIReturnInfo - Wrap the ABIInfo getABIReturnInfo, altering
-// "default" types to StructRet when appropriate for simplicity.
-static ABIArgInfo getABIReturnInfo(QualType Ty, CodeGenTypes &CGT) {
- assert(!Ty->isArrayType() &&
- "Array types cannot be passed directly.");
- ABIArgInfo Info = CGT.getABIInfo().classifyReturnType(Ty, CGT.getContext());
- return Info;
-}
-
-// getABIArgumentInfo - Wrap the ABIInfo getABIReturnInfo, altering
-// "default" types to ByVal when appropriate for simplicity.
-static ABIArgInfo getABIArgumentInfo(QualType Ty, CodeGenTypes &CGT) {
- assert(!Ty->isArrayType() &&
- "Array types cannot be passed directly.");
- ABIArgInfo Info = CGT.getABIInfo().classifyArgumentType(Ty, CGT.getContext());
- return Info;
-}
-
/***/
CGFunctionInfo::CGFunctionInfo(QualType ResTy,
More information about the cfe-commits
mailing list