summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-lower-generics.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-08-16 22:47:35 -0700
committerGitHub <noreply@github.com>2023-08-17 13:47:35 +0800
commit216fc18661fd6e05053b4cc864396e6017e85b04 (patch)
tree48dfd4aef767694f3063d3c79bcc0a1e3c184346 /source/slang/slang-ir-lower-generics.cpp
parenta0ee2bf671d61d1e2b561db3966e57ffc802040f (diff)
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 <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-lower-generics.cpp')
-rw-r--r--source/slang/slang-ir-lower-generics.cpp30
1 files changed, 30 insertions, 0 deletions
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<IRInst>();
+ 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