diff options
Diffstat (limited to 'source/slang/slang-ir-util.cpp')
| -rw-r--r-- | source/slang/slang-ir-util.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp index 551a72fc7..12e37f42a 100644 --- a/source/slang/slang-ir-util.cpp +++ b/source/slang/slang-ir-util.cpp @@ -2744,4 +2744,23 @@ bool isPointerToImmutableLocation(IRInst* loc) } return false; } + +bool isGenericParameter(IRInst* inst) +{ + // The generic parameter must be in the first block + bool isParam = inst->getOp() == kIROp_Param; + bool isGeneric = false; + if (auto irBlock = as<IRBlock>(inst->parent)) + { + isGeneric = as<IRGeneric>(irBlock->getParent()) != nullptr; + } + return isParam && isGeneric; +} + +bool canRelaxInstOrderRule(IRInst* inst, IRInst* useOfInst) +{ + bool isSameBlock = (inst->getParent() == useOfInst->getParent()); + return isSameBlock && isGenericParameter(useOfInst) && (useOfInst->getDataType() == inst); +} + } // namespace Slang |
