diff options
| author | cheneym2 <acheney@nvidia.com> | 2024-10-29 16:42:18 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 16:42:18 -0400 |
| commit | 613a29affe272772dfe0c463d866fb0b8c1d42ee (patch) | |
| tree | b4428cdae50e085cf8c7111ea28e8e679590da68 /source/slang/slang-ir-redundancy-removal.cpp | |
| parent | 99c728f8b3144b1cdfb5e868b304ad2a147d9cc3 (diff) | |
Precompiled SPIR-V import support (#5048)
* Precompiled SPIR-V import support
Adds appropriate linkage and function declaration syntax
for SPIR-V functions that are declared, to be imported
from another SPIR-V module.
Unlike DXIL, stripping the Slang IR for a function down
to a declaration requires retaining a block of parameters,
as the function declaration must be emitted to SPIR-V
with the same parameters as a definition. Because that
thwarts the logic in Slang to tell the difference between
a declaration and definition, and explicit decoration is
introduced to explicitly mark functions which need to be
treated as declarations during emit phase.
Fixes #4992
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-ir-redundancy-removal.cpp')
| -rw-r--r-- | source/slang/slang-ir-redundancy-removal.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/source/slang/slang-ir-redundancy-removal.cpp b/source/slang/slang-ir-redundancy-removal.cpp index 230f356a4..b90a8705d 100644 --- a/source/slang/slang-ir-redundancy-removal.cpp +++ b/source/slang/slang-ir-redundancy-removal.cpp @@ -171,6 +171,7 @@ bool removeRedundancyInFunc(IRGlobalValueWithCode* func) void removeAvailableInDownstreamModuleDecorations(CodeGenTarget target, IRModule* module) { List<IRInst*> toRemove; + auto builder = IRBuilder(module); for (auto globalInst : module->getGlobalInsts()) { if (auto funcInst = as<IRFunc>(globalInst)) @@ -181,13 +182,11 @@ void removeAvailableInDownstreamModuleDecorations(CodeGenTarget target, IRModule (dec->getTarget() == target)) { // Gut the function definition, turning it into a declaration - for (auto inst : funcInst->getChildren()) + for (auto block : funcInst->getBlocks()) { - if (inst->getOp() == kIROp_Block) - { - toRemove.add(inst); - } + toRemove.add(block); } + builder.addDecoration(funcInst, kIROp_DownstreamModuleImportDecoration); } } } |
