mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user