Add support for marking a _specialize attribute as SPI

```
  @_specialize(exported: true, spi: SPIGroupName, where T == Int)
  public func myFunc() { }
```

The specialized entry point is only visible for modules that import
using `_spi(SPIGroupName) import ModuleDefiningMyFunc `.

rdar://64993425
This commit is contained in:
Arnold Schwaighofer
2020-10-09 07:34:05 -07:00
parent b994bf3191
commit 2a2cf91dcd
25 changed files with 509 additions and 81 deletions

View File

@@ -33,20 +33,22 @@ using namespace Lowering;
SILSpecializeAttr::SILSpecializeAttr(bool exported, SpecializationKind kind,
GenericSignature specializedSig,
SILFunction *target)
SILFunction *target, Identifier spiGroup,
const ModuleDecl *spiModule)
: kind(kind), exported(exported), specializedSignature(specializedSig),
targetFunction(target) {
if (targetFunction)
targetFunction->incrementRefCount();
}
spiGroup(spiGroup), spiModule(spiModule), targetFunction(target) {
if (targetFunction)
targetFunction->incrementRefCount();
}
SILSpecializeAttr *SILSpecializeAttr::create(SILModule &M,
GenericSignature specializedSig,
bool exported,
SpecializationKind kind,
SILFunction *target) {
SILSpecializeAttr *
SILSpecializeAttr::create(SILModule &M, GenericSignature specializedSig,
bool exported, SpecializationKind kind,
SILFunction *target, Identifier spiGroup,
const ModuleDecl *spiModule) {
void *buf = M.allocate(sizeof(SILSpecializeAttr), alignof(SILSpecializeAttr));
return ::new (buf) SILSpecializeAttr(exported, kind, specializedSig, target);
return ::new (buf) SILSpecializeAttr(exported, kind, specializedSig, target,
spiGroup, spiModule);
}
void SILFunction::addSpecializeAttr(SILSpecializeAttr *Attr) {