summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-02-03 05:31:23 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-02-03 05:31:23 +0000
commit313321ea23acb5681b265f10a0a9bc8516ff6d30 (patch)
tree4e29d556545dc3f13fd5ec677e945122fb473129 /clang/lib/CodeGen
parent12a130bd06ac94c20e1cf60c2ed9592c056c5e04 (diff)
downloadbcm5719-llvm-313321ea23acb5681b265f10a0a9bc8516ff6d30.tar.gz
bcm5719-llvm-313321ea23acb5681b265f10a0a9bc8516ff6d30.zip
Move ABIArgInfo into CGFunctionInfo, computed on creation.
- Still have to convert some consumers over. llvm-svn: 63610
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/ABIInfo.h6
-rw-r--r--clang/lib/CodeGen/CGCall.cpp56
-rw-r--r--clang/lib/CodeGen/CGCall.h32
3 files changed, 62 insertions, 32 deletions
diff --git a/clang/lib/CodeGen/ABIInfo.h b/clang/lib/CodeGen/ABIInfo.h
index 4b33c4e8065..e0917f77e0e 100644
--- a/clang/lib/CodeGen/ABIInfo.h
+++ b/clang/lib/CodeGen/ABIInfo.h
@@ -10,6 +10,10 @@
#ifndef CLANG_CODEGEN_ABIINFO_H
#define CLANG_CODEGEN_ABIINFO_H
+namespace llvm {
+ class Type;
+}
+
namespace clang {
/* 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
@@ -59,6 +63,8 @@ namespace clang {
TypeData(TD),
UIntData(0) {}
public:
+ ABIArgInfo() : TheKind(Default), TypeData(0), UIntData(0) {}
+
static ABIArgInfo getDefault() {
return ABIArgInfo(Default);
}
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index c6e804ea0bb..dfbd7bfce0b 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -87,6 +87,9 @@ const CGFunctionInfo &CodeGenTypes::getFunctionInfo(QualType ResTy,
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.
@@ -98,25 +101,17 @@ const CGFunctionInfo &CodeGenTypes::getFunctionInfo(QualType ResTy,
if (FI)
return *FI;
+ // Construct the function info.
FI = new CGFunctionInfo(ResTy, ArgTys);
FunctionInfos.InsertNode(FI, InsertPos);
- return *FI;
-}
-/***/
+ // 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);
-CGFunctionInfo::CGFunctionInfo(QualType ResTy,
- const llvm::SmallVector<QualType, 16> &ArgTys) {
- ArgTypes.push_back(ResTy);
- ArgTypes.insert(ArgTypes.end(), ArgTys.begin(), ArgTys.end());
-}
-
-CGFunctionInfo::arg_iterator CGFunctionInfo::arg_begin() const {
- return ArgTypes.begin()+1;
-}
-
-CGFunctionInfo::arg_iterator CGFunctionInfo::arg_end() const {
- return ArgTypes.end();
+ return *FI;
}
/***/
@@ -721,6 +716,17 @@ static ABIArgInfo getABIArgumentInfo(QualType Ty, CodeGenTypes &CGT) {
/***/
+CGFunctionInfo::CGFunctionInfo(QualType ResTy,
+ const llvm::SmallVector<QualType, 16> &ArgTys) {
+ NumArgs = ArgTys.size();
+ Args = new ArgInfo[1 + NumArgs];
+ Args[0].type = ResTy;
+ for (unsigned i = 0; i < NumArgs; ++i)
+ Args[1 + i].type = ArgTys[i];
+}
+
+/***/
+
void CodeGenTypes::GetExpandedTypes(QualType Ty,
std::vector<const llvm::Type*> &ArgTys) {
const RecordType *RT = Ty->getAsStructureType();
@@ -846,7 +852,7 @@ static void CreateCoercedStore(llvm::Value *Src,
uint64_t SrcSize = CGF.CGM.getTargetData().getTypePaddedSize(SrcTy);
uint64_t DstSize = CGF.CGM.getTargetData().getTypePaddedSize(DstTy);
- // If store is legal, just bitcase the src pointer.
+ // If store is legal, just bitcast the src pointer.
if (SrcSize == DstSize) {
llvm::Value *Casted =
CGF.Builder.CreateBitCast(DstPtr, llvm::PointerType::getUnqual(SrcTy));
@@ -907,10 +913,10 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic) {
break;
}
- for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
- it != ie; ++it) {
- ABIArgInfo AI = getABIArgumentInfo(*it, *this);
- const llvm::Type *Ty = ConvertType(*it);
+ for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
+ ie = FI.arg_end(); it != ie; ++it) {
+ const ABIArgInfo &AI = it->info;
+ const llvm::Type *Ty = ConvertType(it->type);
switch (AI.getKind()) {
case ABIArgInfo::Ignore:
@@ -931,7 +937,7 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic) {
break;
case ABIArgInfo::Expand:
- GetExpandedTypes(*it, ArgTys);
+ GetExpandedTypes(it->type, ArgTys);
break;
}
}
@@ -988,11 +994,11 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
if (RetAttrs)
PAL.push_back(llvm::AttributeWithIndex::get(0, RetAttrs));
- for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
- it != ie; ++it) {
- QualType ParamType = *it;
+ for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
+ ie = FI.arg_end(); it != ie; ++it) {
+ QualType ParamType = it->type;
+ const ABIArgInfo &AI = it->info;
unsigned Attributes = 0;
- ABIArgInfo AI = getABIArgumentInfo(ParamType, getTypes());
switch (AI.getKind()) {
case ABIArgInfo::StructRet:
diff --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h
index 611304900f6..95e561d6f9a 100644
--- a/clang/lib/CodeGen/CGCall.h
+++ b/clang/lib/CodeGen/CGCall.h
@@ -20,9 +20,13 @@
#include "CGValue.h"
+// FIXME: Restructure so we don't have to expose so much stuff.
+#include "ABIInfo.h"
+
namespace llvm {
- class Function;
struct AttributeWithIndex;
+ class Function;
+ class Type;
class Value;
template<typename T, unsigned> class SmallVector;
@@ -51,21 +55,35 @@ namespace CodeGen {
/// CGFunctionInfo - Class to encapsulate the information about a
/// function definition.
class CGFunctionInfo : public llvm::FoldingSetNode {
- llvm::SmallVector<QualType, 16> ArgTypes;
+ struct ArgInfo {
+ QualType type;
+ ABIArgInfo info;
+ };
+
+ unsigned NumArgs;
+ ArgInfo *Args;
public:
- typedef llvm::SmallVector<QualType, 16>::const_iterator arg_iterator;
+ typedef const ArgInfo *const_arg_iterator;
+ typedef ArgInfo *arg_iterator;
CGFunctionInfo(QualType ResTy,
const llvm::SmallVector<QualType, 16> &ArgTys);
+ ~CGFunctionInfo() { delete[] Args; }
+
+ const_arg_iterator arg_begin() const { return Args + 1; }
+ const_arg_iterator arg_end() const { return Args + 1 + NumArgs; }
+ arg_iterator arg_begin() { return Args + 1; }
+ arg_iterator arg_end() { return Args + 1 + NumArgs; }
- arg_iterator arg_begin() const;
- arg_iterator arg_end() const;
+ QualType getReturnType() const { return Args[0].type; }
- QualType getReturnType() const { return ArgTypes[0]; }
+ ABIArgInfo &getReturnInfo() { return Args[0].info; }
+ const ABIArgInfo &getReturnInfo() const { return Args[0].info; }
void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, getReturnType(), arg_begin(), arg_end());
+ for (arg_iterator it = arg_begin(), ie = arg_end(); it != ie; ++it)
+ it->type.Profile(ID);
}
template<class Iterator>
static void Profile(llvm::FoldingSetNodeID &ID,
OpenPOWER on IntegriCloud