[llvm] 2aa5bae - [NewPM][BPF] Add BPFPassRegistry.def NFCI (#86241)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 22 21:53:29 PDT 2024
Author: paperchalice
Date: 2024-03-23T12:53:26+08:00
New Revision: 2aa5bae0c03f1f857d0ae2a881b223c4a521853f
URL: https://github.com/llvm/llvm-project/commit/2aa5bae0c03f1f857d0ae2a881b223c4a521853f
DIFF: https://github.com/llvm/llvm-project/commit/2aa5bae0c03f1f857d0ae2a881b223c4a521853f.diff
LOG: [NewPM][BPF] Add BPFPassRegistry.def NFCI (#86241)
Prepare migration for dag-isel.
Added:
llvm/lib/Target/BPF/BPFPassRegistry.def
Modified:
llvm/lib/Target/BPF/BPFTargetMachine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/BPF/BPFPassRegistry.def b/llvm/lib/Target/BPF/BPFPassRegistry.def
new file mode 100644
index 00000000000000..73a8ef2f95bf3c
--- /dev/null
+++ b/llvm/lib/Target/BPF/BPFPassRegistry.def
@@ -0,0 +1,32 @@
+//===- BPFPassRegistry.def - Registry of BPF passes -------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is used as the registry of passes that are part of the
+// BPF backend.
+//
+//===----------------------------------------------------------------------===//
+
+// NOTE: NO INCLUDE GUARD DESIRED!
+
+#ifndef FUNCTION_PASS
+#define FUNCTION_PASS(NAME, CREATE_PASS)
+#endif
+FUNCTION_PASS("bpf-aspace-simplify", BPFASpaceCastSimplifyPass())
+FUNCTION_PASS("bpf-ir-peephole", BPFIRPeepholePass())
+#undef FUNCTION_PASS
+
+#ifndef FUNCTION_PASS_WITH_PARAMS
+#define FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS)
+#endif
+FUNCTION_PASS_WITH_PARAMS(
+ "bpf-preserve-static-offset", "BPFPreserveStaticOffsetPass",
+ [=](bool AllowPartial) {
+ return BPFPreserveStaticOffsetPass(AllowPartial);
+ },
+ parseBPFPreserveStaticOffsetOptions, "allow-partial")
+#undef FUNCTION_PASS_WITH_PARAMS
diff --git a/llvm/lib/Target/BPF/BPFTargetMachine.cpp b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
index 5f26bec2e390c8..a7bed69b0f2ab6 100644
--- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp
+++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp
@@ -108,25 +108,16 @@ TargetPassConfig *BPFTargetMachine::createPassConfig(PassManagerBase &PM) {
return new BPFPassConfig(*this, PM);
}
+static Expected<bool> parseBPFPreserveStaticOffsetOptions(StringRef Params) {
+ return PassBuilder::parseSinglePassOption(Params, "allow-partial",
+ "BPFPreserveStaticOffsetPass");
+}
+
void BPFTargetMachine::registerPassBuilderCallbacks(
PassBuilder &PB, bool PopulateClassToPassNames) {
- PB.registerPipelineParsingCallback(
- [](StringRef PassName, FunctionPassManager &FPM,
- ArrayRef<PassBuilder::PipelineElement>) {
- if (PassName == "bpf-ir-peephole") {
- FPM.addPass(BPFIRPeepholePass());
- return true;
- }
- if (PassName == "bpf-preserve-static-offset") {
- FPM.addPass(BPFPreserveStaticOffsetPass(false));
- return true;
- }
- if (PassName == "bpf-aspace-simplify") {
- FPM.addPass(BPFASpaceCastSimplifyPass());
- return true;
- }
- return false;
- });
+#define GET_PASS_REGISTRY "BPFPassRegistry.def"
+#include "llvm/Passes/TargetPassRegistry.inc"
+
PB.registerPipelineStartEPCallback(
[=](ModulePassManager &MPM, OptimizationLevel) {
FunctionPassManager FPM;
More information about the llvm-commits
mailing list