diff options
| author | Yong He <yonghe@outlook.com> | 2024-02-08 18:29:32 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-08 18:29:32 -0800 |
| commit | f44da6cc5c0f211c13bd1eb0743d79c7861ea64e (patch) | |
| tree | 3ad4edb5e7806c41003280ebf60fd6419a742105 /source/slang/slang-ir-util.cpp | |
| parent | a16f712bb99e426519c9a556b17b54bcc4d1d22d (diff) | |
Support pointers in SPIRV. (#3561)
* Support pointers in SPIRV.
* Fix test.
* Enhance test.
* Fix test.
* Cleanup.
Diffstat (limited to 'source/slang/slang-ir-util.cpp')
| -rw-r--r-- | source/slang/slang-ir-util.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp index d859f86a6..f514fea1d 100644 --- a/source/slang/slang-ir-util.cpp +++ b/source/slang/slang-ir-util.cpp @@ -1030,6 +1030,26 @@ IRInst* getInstInBlock(IRInst* inst) return getInstInBlock(inst->getParent()); } +ShortList<IRInst*> getPhiArgs(IRInst* phiParam) +{ + ShortList<IRInst*> result; + auto block = cast<IRBlock>(phiParam->getParent()); + UInt paramIndex = 0; + for (auto p = block->getFirstParam(); p; p = p->getNextParam()) + { + if (p == phiParam) + break; + paramIndex++; + } + for (auto predBlock : block->getPredecessors()) + { + auto termInst = as<IRUnconditionalBranch>(predBlock->getTerminator()); + SLANG_ASSERT(paramIndex < termInst->getArgCount()); + result.add(termInst->getArg(paramIndex)); + } + return result; +} + void removePhiArgs(IRInst* phiParam) { auto block = cast<IRBlock>(phiParam->getParent()); |
