diff options
| author | cheneym2 <acheney@nvidia.com> | 2024-09-05 14:59:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-05 11:59:28 -0700 |
| commit | 313677160a186efebf83fab4df7d08dd119a5cd2 (patch) | |
| tree | e12e159846f0b7b0e3567d028ad4a57cd9f001aa /source/slang/slang-ir-redundancy-removal.cpp | |
| parent | 33e8bfd43f66613f6f834fb0e1816ef43071f2e4 (diff) | |
Initial -embed-spirv support (#4974)
* Initial -embed-spirv support
Add support for SPIR-V precompilation using the framework
established for DXIL.
Work on #4883
* SLANG_UNUSED
* Add linkage attributes to exported spirv functions
* Combine DXIL and SPIRV paths
* Whitespace fix
* Merge remaining precompiled spirv/dxil paths
* Change inst accessors to return codegentarget
* Add unit test for precompiled spirv
---------
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 | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/source/slang/slang-ir-redundancy-removal.cpp b/source/slang/slang-ir-redundancy-removal.cpp index 038412fbf..79b88ebcf 100644 --- a/source/slang/slang-ir-redundancy-removal.cpp +++ b/source/slang/slang-ir-redundancy-removal.cpp @@ -159,26 +159,29 @@ bool removeRedundancyInFunc(IRGlobalValueWithCode* func) return result; } -// Remove IR definitions from all [AvailableInDXIL] functions when compiling DXIL, -// as these functions are already defined in the embedded precompiled DXIL library. -void removeAvailableInDownstreamModuleDecorations(IRModule* module) +// Remove IR definitions from all AvailableInDownstreamIR functions where the +// languages match what we're currently targetting, as these functions are +// already defined in the embedded precompiled library. +void removeAvailableInDownstreamModuleDecorations(CodeGenTarget target, IRModule* module) { List<IRInst*> toRemove; for (auto globalInst : module->getGlobalInsts()) { - auto funcInst = as<IRFunc>(globalInst); - if (!funcInst) + if (auto funcInst = as<IRFunc>(globalInst)) { - continue; - } - if (globalInst->findDecoration<IRAvailableInDXILDecoration>()) - { - // Gut the function definition, turning it into a declaration - for (auto inst : funcInst->getChildren()) + if (auto dec = globalInst->findDecoration<IRAvailableInDownstreamIRDecoration>()) { - if (inst->getOp() == kIROp_Block) + if ((dec->getTarget() == CodeGenTarget::DXIL && target == CodeGenTarget::HLSL) || + (dec->getTarget() == target)) { - toRemove.add(inst); + // Gut the function definition, turning it into a declaration + for (auto inst : funcInst->getChildren()) + { + if (inst->getOp() == kIROp_Block) + { + toRemove.add(inst); + } + } } } } |
