[llvm] [NewPM][CodeGen] add TargetPassConfig like API (PR #70906)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 18 23:40:25 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)](
----------------
aeubanks wrote:
I realize that you didn't add this, but is it possible to do something like PassBuilder extension point callbacks? This seems very ad-hoc.
https://github.com/llvm/llvm-project/pull/70906
More information about the llvm-commits
mailing list