From 4dbc74a953ae1b34ce64a4eaef3aa7feb73663b9 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 13 Feb 2023 10:38:14 -0800 Subject: Add Loop Unrolling Pass. (#2644) Co-authored-by: Yong He --- source/slang/slang-ir-util.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source/slang/slang-ir-util.cpp') diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp index 942c8f2f8..0448eb649 100644 --- a/source/slang/slang-ir-util.cpp +++ b/source/slang/slang-ir-util.cpp @@ -443,6 +443,27 @@ bool canInstHaveSideEffectAtAddress(IRGlobalValueWithCode* func, IRInst* inst, I return false; } +IRInst* getUndefInst(IRBuilder builder, IRModule* module) +{ + IRInst* undefInst = nullptr; + + for (auto inst : module->getModuleInst()->getChildren()) + { + if (inst->getOp() == kIROp_undefined && inst->getDataType() && inst->getDataType()->getOp() == kIROp_VoidType) + { + undefInst = inst; + break; + } + } + if (!undefInst) + { + auto voidType = builder.getVoidType(); + builder.setInsertAfter(voidType); + undefInst = builder.emitUndefined(voidType); + } + return undefInst; +} + bool isPureFunctionalCall(IRCall* call) { auto callee = getResolvedInstForDecorations(call->getCallee()); -- cgit v1.2.3