[PATCH] D88138: [NPM] Add target specific hook to add passes for New Pass Manager
Ankit via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 22:18:30 PDT 2020
quic_aankit updated this revision to Diff 294227.
quic_aankit added a comment.
Herald added a subscriber: hiraditya.
Add HexagonVectorLoopCarriedReusePass using registerPassBuilderCallbacks
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88138/new/
https://reviews.llvm.org/D88138
Files:
llvm/include/llvm/Target/TargetMachine.h
llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
llvm/lib/Target/Hexagon/HexagonTargetMachine.h
Index: llvm/lib/Target/Hexagon/HexagonTargetMachine.h
===================================================================
--- llvm/lib/Target/Hexagon/HexagonTargetMachine.h
+++ llvm/lib/Target/Hexagon/HexagonTargetMachine.h
@@ -37,6 +37,7 @@
static unsigned getModuleMatchQuality(const Module &M);
void adjustPassManager(PassManagerBuilder &PMB) override;
+ void registerPassBuilderCallbacks(PassBuilder &PB) override;
TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
TargetTransformInfo getTargetTransformInfo(const Function &F) override;
Index: llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
===================================================================
--- llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
+++ llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
@@ -22,6 +22,7 @@
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
+#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
@@ -273,6 +274,19 @@
});
}
+void HexagonTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
+ PB.registerOptimizerLastEPCallback([](ModulePassManager &mpm,
+ PassBuilder::OptimizationLevel Level) {
+ LoopPassManager lpm(false);
+ FunctionPassManager fpm(false);
+ lpm.addPass(HexagonVectorLoopCarriedReusePass());
+ fpm.addPass(LoopSimplifyPass());
+ fpm.addPass(LCSSAPass());
+ fpm.addPass(createFunctionToLoopPassAdaptor(std::move(lpm), false, false));
+ mpm.addPass(createModuleToFunctionPassAdaptor(std::move(fpm)));
+ });
+}
+
TargetTransformInfo
HexagonTargetMachine::getTargetTransformInfo(const Function &F) {
return TargetTransformInfo(HexagonTTIImpl(this, F));
Index: llvm/include/llvm/Target/TargetMachine.h
===================================================================
--- llvm/include/llvm/Target/TargetMachine.h
+++ llvm/include/llvm/Target/TargetMachine.h
@@ -34,6 +34,7 @@
class MCSubtargetInfo;
class MCSymbol;
class raw_pwrite_stream;
+class PassBuilder;
class PassManagerBuilder;
struct PerFunctionMIParsingState;
class SMDiagnostic;
@@ -293,6 +294,10 @@
/// PassManagerBuilder::addExtension.
virtual void adjustPassManager(PassManagerBuilder &) {}
+ /// Allow the target to modify the pass pipeline with New Pass Manager
+ /// (similar to adjustPassManager for Legacy Pass manager).
+ virtual void registerPassBuilderCallbacks(PassBuilder &) {}
+
/// Add passes to the specified pass manager to get the specified file
/// emitted. Typically this will involve several steps of code generation.
/// This method should return true if emission of this file type is not
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88138.294227.patch
Type: text/x-patch
Size: 2813 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200925/4321b65f/attachment.bin>
More information about the llvm-commits
mailing list