@@ -389,6 +389,11 @@ class LinkEntity {
389389 // / The pointer is an AbstractFunctionDecl*.
390390 AsyncFunctionPointerAST,
391391
392+ // / The same as CoroFunctionPointer but with a different stored value, for
393+ // / use by TBDGen.
394+ // / The pointer is an AbstractFunctionDecl*.
395+ CoroFunctionPointerAST,
396+
392397 // / The pointer is a SILFunction*.
393398 DynamicallyReplaceableFunctionKey,
394399
@@ -551,6 +556,39 @@ class LinkEntity {
551556 // / Pointer is the (generalized) existential type.
552557 // / SecondaryPointer is the GenericSignatureImpl*.
553558 ExtendedExistentialTypeShape,
559+
560+ // / A global struct containing a relative pointer to the single-yield
561+ // / coroutine ramp function and the fixed-size to be allocated in the
562+ // / caller.
563+ // / The pointer is a SILFunction*.
564+ CoroFunctionPointer,
565+
566+ // / An coro function pointer for a method dispatch thunk. The pointer is
567+ // / a FuncDecl* inside a protocol or a class.
568+ DispatchThunkCoroFunctionPointer,
569+
570+ // / An coro function pointer for a method dispatch thunk for an
571+ // / initializing constructor. The pointer is a ConstructorDecl* inside a
572+ // / class.
573+ DispatchThunkInitializerCoroFunctionPointer,
574+
575+ // / An coro function pointer for a method dispatch thunk for an allocating
576+ // / constructor. The pointer is a ConstructorDecl* inside a protocol or
577+ // / a class.
578+ DispatchThunkAllocatorCoroFunctionPointer,
579+
580+ // / An coro function pointer for a distributed thunk.
581+ // / The pointer is a FuncDecl* inside an actor (class).
582+ DistributedThunkCoroFunctionPointer,
583+
584+ // / An coro function pointer to a partial apply forwarder.
585+ // / The pointer is the llvm::Function* for a partial apply forwarder.
586+ PartialApplyForwarderCoroFunctionPointer,
587+
588+ // / An coro function pointer for a distributed accessor (method or
589+ // / property).
590+ // / The pointer is a SILFunction*.
591+ DistributedAccessorCoroFunctionPointer,
554592 };
555593 friend struct llvm ::DenseMapInfo<LinkEntity>;
556594
@@ -572,9 +610,7 @@ class LinkEntity {
572610 return !(LHS == RHS);
573611 }
574612
575- static bool isDeclKind (Kind k) {
576- return k <= Kind::AsyncFunctionPointerAST;
577- }
613+ static bool isDeclKind (Kind k) { return k <= Kind::CoroFunctionPointerAST; }
578614 static bool isTypeKind (Kind k) {
579615 return k >= Kind::ProtocolWitnessTableLazyAccessFunction;
580616 }
@@ -1457,6 +1493,109 @@ class LinkEntity {
14571493 return entity;
14581494 }
14591495
1496+ static LinkEntity forCoroFunctionPointer (LinkEntity other) {
1497+ LinkEntity entity;
1498+ entity.Pointer = other.Pointer ;
1499+ entity.SecondaryPointer = nullptr ;
1500+
1501+ switch (other.getKind ()) {
1502+ case LinkEntity::Kind::SILFunction:
1503+ entity.Data = LINKENTITY_SET_FIELD (
1504+ Kind, unsigned (LinkEntity::Kind::CoroFunctionPointer));
1505+ break ;
1506+
1507+ case LinkEntity::Kind::DispatchThunk:
1508+ entity.Data = LINKENTITY_SET_FIELD (
1509+ Kind, unsigned (LinkEntity::Kind::DispatchThunkCoroFunctionPointer));
1510+ break ;
1511+
1512+ case LinkEntity::Kind::DispatchThunkInitializer:
1513+ entity.Data = LINKENTITY_SET_FIELD (
1514+ Kind,
1515+ unsigned (
1516+ LinkEntity::Kind::DispatchThunkInitializerCoroFunctionPointer));
1517+ break ;
1518+
1519+ case LinkEntity::Kind::DispatchThunkAllocator:
1520+ entity.Data = LINKENTITY_SET_FIELD (
1521+ Kind,
1522+ unsigned (
1523+ LinkEntity::Kind::DispatchThunkAllocatorCoroFunctionPointer));
1524+ break ;
1525+ case LinkEntity::Kind::PartialApplyForwarder:
1526+ entity.Data = LINKENTITY_SET_FIELD (
1527+ Kind,
1528+ unsigned (LinkEntity::Kind::PartialApplyForwarderCoroFunctionPointer));
1529+ break ;
1530+
1531+ case LinkEntity::Kind::DistributedAccessor: {
1532+ entity.Data = LINKENTITY_SET_FIELD (
1533+ Kind,
1534+ unsigned (LinkEntity::Kind::DistributedAccessorCoroFunctionPointer));
1535+ break ;
1536+ }
1537+
1538+ default :
1539+ llvm_unreachable (" Link entity kind cannot have an coro function pointer" );
1540+ }
1541+
1542+ return entity;
1543+ }
1544+
1545+ static LinkEntity forCoroFunctionPointer (SILDeclRef declRef) {
1546+ LinkEntity entity;
1547+ entity.setForDecl (declRef.isDistributedThunk ()
1548+ ? Kind::DistributedThunkCoroFunctionPointer
1549+ : Kind::CoroFunctionPointerAST,
1550+ declRef.getAbstractFunctionDecl ());
1551+ entity.SecondaryPointer =
1552+ reinterpret_cast <void *>(static_cast <uintptr_t >(declRef.kind ));
1553+ return entity;
1554+ }
1555+
1556+ LinkEntity getUnderlyingEntityForCoroFunctionPointer () const {
1557+ LinkEntity entity;
1558+ entity.Pointer = Pointer;
1559+ entity.SecondaryPointer = nullptr ;
1560+
1561+ switch (getKind ()) {
1562+ case LinkEntity::Kind::CoroFunctionPointer:
1563+ entity.Data =
1564+ LINKENTITY_SET_FIELD (Kind, unsigned (LinkEntity::Kind::SILFunction));
1565+ break ;
1566+
1567+ case LinkEntity::Kind::DispatchThunkCoroFunctionPointer:
1568+ entity.Data =
1569+ LINKENTITY_SET_FIELD (Kind, unsigned (LinkEntity::Kind::DispatchThunk));
1570+ break ;
1571+
1572+ case LinkEntity::Kind::DispatchThunkInitializerCoroFunctionPointer:
1573+ entity.Data = LINKENTITY_SET_FIELD (
1574+ Kind, unsigned (LinkEntity::Kind::DispatchThunkInitializer));
1575+ break ;
1576+
1577+ case LinkEntity::Kind::DispatchThunkAllocatorCoroFunctionPointer:
1578+ entity.Data = LINKENTITY_SET_FIELD (
1579+ Kind, unsigned (LinkEntity::Kind::DispatchThunkAllocator));
1580+ break ;
1581+
1582+ case LinkEntity::Kind::PartialApplyForwarderCoroFunctionPointer:
1583+ entity.Data = LINKENTITY_SET_FIELD (
1584+ Kind, unsigned (LinkEntity::Kind::PartialApplyForwarder));
1585+ break ;
1586+
1587+ case LinkEntity::Kind::DistributedAccessorCoroFunctionPointer:
1588+ entity.Data = LINKENTITY_SET_FIELD (
1589+ Kind, unsigned (LinkEntity::Kind::DistributedAccessor));
1590+ break ;
1591+
1592+ default :
1593+ llvm_unreachable (" Link entity is not an coro function pointer" );
1594+ }
1595+
1596+ return entity;
1597+ }
1598+
14601599 void mangle (ASTContext &Ctx, llvm::raw_ostream &out) const ;
14611600 void mangle (ASTContext &Ctx, SmallVectorImpl<char > &buffer) const ;
14621601 std::string mangleAsString (ASTContext &Ctx) const ;
0 commit comments