Extend SILModule with an API for linking of SILFunctions by their SILDeclRef.

Before, providing a full SILFunction declaration object with a proper SILType was the only way to link a function. And constructing such a SILFunction declaration by hand using low-level SIL APIs is very annoying and requires a lot of code to be written. This new linkFunction API allows for a lookup using SILDeclRef and essentially performs linking of a SILFunction by its mangled name (assuming this name is unique), which is much easier to invoke. The new API is useful, e.g. when you need to link a well-known function from a standard library.

Swift SVN r26252
This commit is contained in:
Roman Levenstein
2015-03-18 06:11:22 +00:00
parent 02f542c2d0
commit 1f875b9bcb
7 changed files with 62 additions and 1 deletions

View File

@@ -370,6 +370,13 @@ public:
bool linkFunction(SILFunction *Fun,
LinkingMode LinkAll=LinkingMode::LinkNormal);
/// Attempt to link a function by declaration. Returns true if linking
/// succeeded, false otherwise.
///
/// \return false if the linking failed.
bool linkFunction(SILDeclRef Decl,
LinkingMode LinkAll=LinkingMode::LinkNormal);
/// Link in all Witness Tables in the module.
void linkAllWitnessTables();