From 216fc18661fd6e05053b4cc864396e6017e85b04 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 16 Aug 2023 22:47:35 -0700 Subject: Create storage types of different layouts for SPIRV emit. (#3116) * Create storage types of different layouts for SPIRV emit. * Fix. * Fix. * Fix. * Update expected failure list. --------- Co-authored-by: Yong He --- source/slang/slang-ir-lower-generics.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'source/slang/slang-ir-lower-generics.cpp') diff --git a/source/slang/slang-ir-lower-generics.cpp b/source/slang/slang-ir-lower-generics.cpp index a7c0f51e6..f535b97d2 100644 --- a/source/slang/slang-ir-lower-generics.cpp +++ b/source/slang/slang-ir-lower-generics.cpp @@ -176,6 +176,30 @@ namespace Slang }); } + void stripWrapExistential(IRModule* module) + { + auto& workList = *module->getContainerPool().getList(); + workList.add(module->getModuleInst()); + for (Index i = 0; i < workList.getCount(); i++) + { + auto inst = workList[i]; + switch (inst->getOp()) + { + case kIROp_WrapExistential: + { + auto operand = inst->getOperand(0); + inst->replaceUsesWith(operand); + inst->removeAndDeallocate(); + } + break; + default: + for (auto child : inst->getChildren()) + workList.add(child); + break; + } + } + } + void lowerGenerics( TargetRequest* targetReq, IRModule* module, @@ -234,5 +258,11 @@ namespace Slang generateAnyValueMarshallingFunctions(&sharedContext); if (sink->getErrorCount() != 0) return; + + // At this point, we should no longer need to care any `WrapExistential` insts, + // although they could still exist in the IR in order to call generic stdlib functions, + // e.g. RWStucturedBuffer.Load(WrapExistential(sbuffer, type), index). + // We should remove them now. + stripWrapExistential(module); } } // namespace Slang -- cgit v1.2.3