diff options
| author | Yong He <yonghe@outlook.com> | 2020-09-26 20:09:50 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-26 20:09:50 -0700 |
| commit | 94d3f2bd9c5557658751f73bc5fc443b41230d2c (patch) | |
| tree | a028c7f2a345e1e7af86aad6a63f6f0fddc74785 /slang.h | |
| parent | b72353ec3fe529237828cacbe710233d31eb4837 (diff) | |
Add API for whole program compilation. (#1562)
* Add API for whole program compilation.
This change exposes a new target flag: `SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM` that can be set on a target with `spSetTargetFlags`. When this flag is set, `spCompile` function generates target code for the entire input module instead of just the specified entrypoints. The resulting code will include all the entrypoints defined in the input source.
The resulting whole program code can be retrieved with two new functions: `spGetTargetCodeBlob` and `spGetTargetHostCallable`.
This change also cleans up the unnecessary `entryPointIndices` parameter of `TargetProgram::getOrCreateWholeProgramResult`, and modifies the `cpu-hello-world` example to make use of the new whole-program compilation API to simplify its logic.
* Update comments.
Diffstat (limited to 'slang.h')
| -rw-r--r-- | slang.h | 36 |
1 files changed, 34 insertions, 2 deletions
@@ -584,6 +584,12 @@ extern "C" @deprecated This behavior is now enabled unconditionally. */ SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES = 1 << 4, + + /* When set, will generate target code that contains all entrypoints defined + in the input source or specified via the `spAddEntryPoint` function in a + single output module (library/source file). + */ + SLANG_TARGET_FLAG_GENERATE_WHOLE_PROGRAM = 1 << 8 }; /*! @@ -1632,8 +1638,6 @@ extern "C" @param targetIndex The index of the target to get code for (default: zero). @param outBlob A pointer that will receive the blob of code @returns A `SlangResult` to indicate success or failure. - - The lifetime of the output pointer is the same as `request`. */ SLANG_API SlangResult spGetEntryPointCodeBlob( SlangCompileRequest* request, @@ -1659,6 +1663,34 @@ extern "C" int targetIndex, ISlangSharedLibrary** outSharedLibrary); + /** Get the output code associated with a specific target. + + @param request The request + @param targetIndex The index of the target to get code for (default: zero). + @param outBlob A pointer that will receive the blob of code + @returns A `SlangResult` to indicate success or failure. + */ + SLANG_API SlangResult spGetTargetCodeBlob( + SlangCompileRequest* request, + int targetIndex, + ISlangBlob** outBlob); + + /** Get 'callable' functions for a target accessible through the ISlangSharedLibrary interface. + + That the functions remain in scope as long as the ISlangSharedLibrary interface is in scope. + + NOTE! Requires a compilation target of SLANG_HOST_CALLABLE. + + @param request The request + @param targetIndex The index of the target to get code for (default: zero). + @param outSharedLibrary A pointer to a ISharedLibrary interface which functions can be queried on. + @returns A `SlangResult` to indicate success or failure. + */ + SLANG_API SlangResult spGetTargetHostCallable( + SlangCompileRequest* request, + int targetIndex, + ISlangSharedLibrary** outSharedLibrary); + /** Get the output bytecode associated with an entire compile request. The lifetime of the output pointer is the same as `request` and the last spCompile. |
