summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-peephole.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-12-19 11:47:19 -0800
committerGitHub <noreply@github.com>2022-12-19 11:47:19 -0800
commit216dfba0af66210a46ef0df18beb73d975fdf727 (patch)
treef397ea5bf8d47d7a5d90dc95edfb472f2e49d762 /source/slang/slang-ir-peephole.cpp
parent36220da1e29c891972fef32c8575c15f868b9959 (diff)
Separate primal computations from unzipped function into an explicit function. (#2569)
Co-authored-by: Yong He <yhe@nvidia.com>
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