More killing of std::vector.

llvm-svn: 131374
This commit is contained in:
John McCall 2011-05-15 02:19:42 +00:00
parent 9dc0db2192
commit 85dd2c5039
2 changed files with 41 additions and 40 deletions

View File

@ -309,10 +309,10 @@ CGFunctionInfo::CGFunctionInfo(unsigned _CallingConvention,
/***/
void CodeGenTypes::GetExpandedTypes(QualType Ty,
std::vector<const llvm::Type*> &ArgTys,
bool IsRecursive) {
const RecordType *RT = Ty->getAsStructureType();
void CodeGenTypes::GetExpandedTypes(QualType type,
llvm::SmallVectorImpl<const llvm::Type*> &expandedTypes,
bool isRecursive) {
const RecordType *RT = type->getAsStructureType();
assert(RT && "Can only expand structure types.");
const RecordDecl *RD = RT->getDecl();
assert(!RD->hasFlexibleArrayMember() &&
@ -324,11 +324,11 @@ void CodeGenTypes::GetExpandedTypes(QualType Ty,
assert(!FD->isBitField() &&
"Cannot expand structure with bit-field members.");
QualType FT = FD->getType();
if (CodeGenFunction::hasAggregateLLVMType(FT))
GetExpandedTypes(FT, ArgTys, IsRecursive);
QualType fieldType = FD->getType();
if (fieldType->isRecordType())
GetExpandedTypes(fieldType, expandedTypes, isRecursive);
else
ArgTys.push_back(ConvertType(FT, IsRecursive));
expandedTypes.push_back(ConvertType(fieldType, isRecursive));
}
}
@ -612,49 +612,49 @@ const llvm::FunctionType *CodeGenTypes::GetFunctionType(GlobalDecl GD) {
}
const llvm::FunctionType *
CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic,
bool IsRecursive) {
std::vector<const llvm::Type*> ArgTys;
CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool isVariadic,
bool isRecursive) {
llvm::SmallVector<const llvm::Type*, 8> argTypes;
const llvm::Type *resultType = 0;
const llvm::Type *ResultType = 0;
QualType RetTy = FI.getReturnType();
const ABIArgInfo &RetAI = FI.getReturnInfo();
switch (RetAI.getKind()) {
const ABIArgInfo &retAI = FI.getReturnInfo();
switch (retAI.getKind()) {
case ABIArgInfo::Expand:
assert(0 && "Invalid ABI kind for return argument");
llvm_unreachable("Invalid ABI kind for return argument");
case ABIArgInfo::Extend:
case ABIArgInfo::Direct:
ResultType = RetAI.getCoerceToType();
resultType = retAI.getCoerceToType();
break;
case ABIArgInfo::Indirect: {
assert(!RetAI.getIndirectAlign() && "Align unused on indirect return.");
ResultType = llvm::Type::getVoidTy(getLLVMContext());
const llvm::Type *STy = ConvertType(RetTy, IsRecursive);
unsigned AS = Context.getTargetAddressSpace(RetTy);
ArgTys.push_back(llvm::PointerType::get(STy, AS));
assert(!retAI.getIndirectAlign() && "Align unused on indirect return.");
resultType = llvm::Type::getVoidTy(getLLVMContext());
QualType ret = FI.getReturnType();
const llvm::Type *ty = ConvertType(ret, isRecursive);
unsigned addressSpace = Context.getTargetAddressSpace(ret);
argTypes.push_back(llvm::PointerType::get(ty, addressSpace));
break;
}
case ABIArgInfo::Ignore:
ResultType = llvm::Type::getVoidTy(getLLVMContext());
resultType = llvm::Type::getVoidTy(getLLVMContext());
break;
}
for (CGFunctionInfo::const_arg_iterator it = FI.arg_begin(),
ie = FI.arg_end(); it != ie; ++it) {
const ABIArgInfo &AI = it->info;
const ABIArgInfo &argAI = it->info;
switch (AI.getKind()) {
switch (argAI.getKind()) {
case ABIArgInfo::Ignore:
break;
case ABIArgInfo::Indirect: {
// indirect arguments are always on the stack, which is addr space #0.
const llvm::Type *LTy = ConvertTypeForMem(it->type, IsRecursive);
ArgTys.push_back(llvm::PointerType::getUnqual(LTy));
const llvm::Type *LTy = ConvertTypeForMem(it->type, isRecursive);
argTypes.push_back(LTy->getPointerTo());
break;
}
@ -663,23 +663,23 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI, bool IsVariadic,
// If the coerce-to type is a first class aggregate, flatten it. Either
// way is semantically identical, but fast-isel and the optimizer
// generally likes scalar values better than FCAs.
const llvm::Type *ArgTy = AI.getCoerceToType();
if (const llvm::StructType *STy = dyn_cast<llvm::StructType>(ArgTy)) {
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i)
ArgTys.push_back(STy->getElementType(i));
const llvm::Type *argType = argAI.getCoerceToType();
if (const llvm::StructType *st = dyn_cast<llvm::StructType>(argType)) {
for (unsigned i = 0, e = st->getNumElements(); i != e; ++i)
argTypes.push_back(st->getElementType(i));
} else {
ArgTys.push_back(ArgTy);
argTypes.push_back(argType);
}
break;
}
case ABIArgInfo::Expand:
GetExpandedTypes(it->type, ArgTys, IsRecursive);
GetExpandedTypes(it->type, argTypes, isRecursive);
break;
}
}
return llvm::FunctionType::get(ResultType, ArgTys, IsVariadic);
return llvm::FunctionType::get(resultType, argTypes, isVariadic);
}
const llvm::Type *CodeGenTypes::GetFunctionTypeForVTable(GlobalDecl GD) {
@ -822,12 +822,12 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
continue;
case ABIArgInfo::Expand: {
std::vector<const llvm::Type*> Tys;
llvm::SmallVector<const llvm::Type*, 8> types;
// FIXME: This is rather inefficient. Do we ever actually need to do
// anything here? The result should be just reconstructed on the other
// side, so extension should be a non-issue.
getTypes().GetExpandedTypes(ParamType, Tys, false);
Index += Tys.size();
getTypes().GetExpandedTypes(ParamType, types, false);
Index += types.size();
continue;
}
}

View File

@ -220,8 +220,9 @@ public: // These are internal details of CGT that shouldn't be used externally.
/// GetExpandedTypes - Expand the type \arg Ty into the LLVM
/// argument types it would be passed as on the provided vector \arg
/// ArgTys. See ABIArgInfo::Expand.
void GetExpandedTypes(QualType Ty, std::vector<const llvm::Type*> &ArgTys,
bool IsRecursive);
void GetExpandedTypes(QualType type,
llvm::SmallVectorImpl<const llvm::Type*> &expanded,
bool isRecursive);
/// IsZeroInitializable - Return whether a type can be
/// zero-initialized (in the C++ sense) with an LLVM zeroinitializer.