[llvm] [NewPM][CodeGen] add TargetPassConfig like API (PR #70906)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 19 01:10:48 PST 2023
================
@@ -224,38 +268,55 @@ template <typename DerivedT> class CodeGenPassBuilder {
AddMachinePass(MachineFunctionPassManager &PM) : PM(PM) {}
template <typename PassT> void operator()(PassT &&Pass) {
- static_assert(
- is_detected<has_key_t, PassT>::value,
- "Machine function pass must define a static member variable `Key`.");
for (auto &C : BeforeCallbacks)
- if (!C(&PassT::Key))
+ if (!C(PassT::ID()))
return;
PM.addPass(std::forward<PassT>(Pass));
for (auto &C : AfterCallbacks)
- C(&PassT::Key);
- }
-
- template <typename PassT> void insertPass(AnalysisKey *ID, PassT Pass) {
- AfterCallbacks.emplace_back(
- [this, ID, Pass = std::move(Pass)](AnalysisKey *PassID) {
- if (PassID == ID)
- this->PM.addPass(std::move(Pass));
- });
+ C(PassT::ID(), PassT::name());
}
- void disablePass(AnalysisKey *ID) {
- BeforeCallbacks.emplace_back(
- [ID](AnalysisKey *PassID) { return PassID != ID; });
+ template <typename PassT> void insertPass(MachinePassKey *ID, PassT Pass) {
+ AfterCallbacks.emplace_back([this, ID, Pass = std::move(Pass)](
----------------
paperchalice wrote:
Currently not. I checked backends codes, seems only `insertPass`, `disablePass` and substitute some specific passes (in fact,
only `PostRAScheduler`) are needed but add some call backs are ok.
https://github.com/llvm/llvm-project/pull/70906
More information about the llvm-commits
mailing list