From 313677160a186efebf83fab4df7d08dd119a5cd2 Mon Sep 17 00:00:00 2001 From: cheneym2 Date: Thu, 5 Sep 2024 14:59:28 -0400 Subject: 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 --- source/slang/slang-ir-redundancy-removal.cpp | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'source/slang/slang-ir-redundancy-removal.cpp') 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 toRemove; for (auto globalInst : module->getGlobalInsts()) { - auto funcInst = as(globalInst); - if (!funcInst) + if (auto funcInst = as(globalInst)) { - continue; - } - if (globalInst->findDecoration()) - { - // Gut the function definition, turning it into a declaration - for (auto inst : funcInst->getChildren()) + if (auto dec = globalInst->findDecoration()) { - 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); + } + } } } } -- cgit v1.2.3