summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-peephole.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir-peephole.cpp')
-rw-r--r--source/slang/slang-ir-peephole.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/source/slang/slang-ir-peephole.cpp b/source/slang/slang-ir-peephole.cpp
index 66cde68de..21e17b546 100644
--- a/source/slang/slang-ir-peephole.cpp
+++ b/source/slang/slang-ir-peephole.cpp
@@ -241,16 +241,21 @@ struct PeepholeContext : InstPassBase
}
}
- bool processModule()
+ bool processFunc(IRInst* func)
{
SharedIRBuilder* sharedBuilder = &sharedBuilderStorage;
sharedBuilder->init(module);
sharedBuilderStorage.deduplicateAndRebuildGlobalNumberingMap();
changed = false;
- processAllInsts([this](IRInst* inst) { processInst(inst); });
+ processChildInsts(func, [this](IRInst* inst) { processInst(inst); });
return changed;
}
+
+ bool processModule()
+ {
+ return processFunc(module->getModuleInst());
+ }
};
bool peepholeOptimize(IRModule* module)
@@ -259,4 +264,10 @@ bool peepholeOptimize(IRModule* module)
return context.processModule();
}
+bool peepholeOptimize(IRInst* func)
+{
+ PeepholeContext context = PeepholeContext(func->getModule());
+ return context.processFunc(func);
+}
+
} // namespace Slang