add a few "optimized" runtime entrypoints for swift_getTupleTypeMetadata

that handle the 2/3 element cases specially.  These are not actually
optimized at the moment (they just call into swift_getTupleTypeMetadata)
but this could be done at some point.

This is a win for a couple reasons: this reduces the amount of code generated
inline and it allows swift_getTupleTypeMetadata2/3 to be marked readnone,
enabling CSE.  As a driveby, optimize metadata refs of zero element tuples
to directly use _TMdT_, eliminating a branch from swift_getTupleTypeMetadata.



Swift SVN r5070
This commit is contained in:
Chris Lattner
2013-05-06 23:19:31 +00:00
parent a7ae6e2c06
commit ca0091a445
5 changed files with 144 additions and 33 deletions

View File

@@ -430,6 +430,15 @@ llvm::Constant *IRGenModule::getObjCTypeofFn() {
{ OpaquePtrTy, TypeMetadataPtrTy });
}
llvm::Constant *IRGenModule::getEmptyTupleMetadata() {
if (EmptyTupleMetadata)
return EmptyTupleMetadata;
return EmptyTupleMetadata =
Module.getOrInsertGlobal("_TMdT_",
TypeMetadataPtrTy->getPointerElementType());
}
llvm::Constant *IRGenModule::getGetTupleMetadataFn() {
// type_metadata_t *swift_getTupleMetadata(size_t numElements,
// type_metadata_t * const *pattern,
@@ -446,6 +455,42 @@ llvm::Constant *IRGenModule::getGetTupleMetadataFn() {
});
}
llvm::Constant *IRGenModule::getGetTupleMetadata2Fn() {
// type_metadata_t *swift_getTupleMetadata2(type_metadata_t *elt0,
// type_metadata_t *elt1,
// const char *labels,
// value_witness_table_t *proposed);
return getRuntimeFn(*this, GetTupleMetadata2Fn, "swift_getTupleTypeMetadata2",
createReadnoneRuntimeFunction,
{ TypeMetadataPtrTy },
{
TypeMetadataPtrTy,
TypeMetadataPtrTy,
Int8PtrTy,
WitnessTablePtrTy
});
}
llvm::Constant *IRGenModule::getGetTupleMetadata3Fn() {
// type_metadata_t *swift_getTupleMetadata3(type_metadata_t *elt0,
// type_metadata_t *elt1,
// type_metadata_t *elt2,
// type_metadata_t * const *pattern,
// const char *labels,
// value_witness_table_t *proposed);
return getRuntimeFn(*this, GetTupleMetadata3Fn, "swift_getTupleTypeMetadata3",
createReadnoneRuntimeFunction,
{ TypeMetadataPtrTy },
{
TypeMetadataPtrTy,
TypeMetadataPtrTy,
TypeMetadataPtrTy,
Int8PtrTy,
WitnessTablePtrTy
});
}
llvm::Constant *IRGenModule::getGetObjectClassFn() {
if (GetObjectClassFn) return GetObjectClassFn;