[llvm] [RISCV][NewPM] Port RISCVCodeGenPrepare to the new pass manager (PR #168381)

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 17 10:55:23 PST 2025


================
@@ -33,36 +33,42 @@ using namespace llvm;
 #define PASS_NAME "RISC-V CodeGenPrepare"
 
 namespace {
-
-class RISCVCodeGenPrepare : public FunctionPass,
-                            public InstVisitor<RISCVCodeGenPrepare, bool> {
+class RISCVCodeGenPrepare : public InstVisitor<RISCVCodeGenPrepare, bool> {
+  Function &F;
   const DataLayout *DL;
   const DominatorTree *DT;
   const RISCVSubtarget *ST;
 
+public:
+  RISCVCodeGenPrepare(Function &F, const DominatorTree *DT,
+                      const RISCVSubtarget *ST)
+      : F(F), DL(&F.getDataLayout()), DT(DT), ST(ST) {}
+  bool run();
+  bool visitInstruction(Instruction &I) { return false; }
+  bool visitAnd(BinaryOperator &BO);
+  bool visitIntrinsicInst(IntrinsicInst &I);
+  bool expandVPStrideLoad(IntrinsicInst &I);
+  bool widenVPMerge(IntrinsicInst &I);
+};
+} // namespace
+
+namespace {
+class RISCVCodeGenPrepareLegacyPass : public FunctionPass {
----------------
asb wrote:

Or to put it another way - I agree that's a reasonable alternative. My feeling is that having the ugly auto-generated `initializeFooPassPass` is worth it for a more intuitive (IMHO) naming of the pass adapters. But If you feel otherwise, I'm happy to change.

https://github.com/llvm/llvm-project/pull/168381


More information about the llvm-commits mailing list