[llvm] machinebackend pass test (PR #122487)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 10 08:24:24 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-x86

Author: Kun Liu (Ryan-hub-bit)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/122487.diff


2 Files Affected:

- (added) llvm/lib/Target/X86/X86MatchJumptablePass.cpp (+44) 
- (added) llvm/lib/Target/X86/X86MatchJumptablePass.h () 


``````````diff
diff --git a/llvm/lib/Target/X86/X86MatchJumptablePass.cpp b/llvm/lib/Target/X86/X86MatchJumptablePass.cpp
new file mode 100644
index 00000000000000..bfb6b1b7f89f18
--- /dev/null
+++ b/llvm/lib/Target/X86/X86MatchJumptablePass.cpp
@@ -0,0 +1,44 @@
+#include "X86.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
+
+
+using namespace llvm;
+
+namespace {
+  class X86MatchJumptablePass : public MachineFunctionPass {
+  public:
+    static char ID;
+
+    X86MatchJumptablePass() : MachineFunctionPass(ID) {}
+
+    bool runOnMachineFunction(MachineFunction &MF) override {
+      LLVM_DEBUG(dbgs() << "Running X86MyBackendPass on function: "
+                        << MF.getName() << "\n");
+
+      // Example: Iterate through instructions
+      for (auto &MBB : MF) {
+        for (auto &MI : MBB) {
+          // Process instructions here
+          LLVM_DEBUG(dbgs() << "Instruction: " << MI << "\n");
+        }
+      }
+
+      return false; // Return true if the pass modifies the function
+    }
+
+    StringRef getPassName() const override {
+      return "X86 My Backend Pass";
+    }
+  };
+}
+
+char X86MatchJumptablePass::ID = 0;
+
+// Register the pass
+FunctionPass *llvm::createX86MatchJumptablePass() {
+  return new X86MatchJumptablePass();
+}
diff --git a/llvm/lib/Target/X86/X86MatchJumptablePass.h b/llvm/lib/Target/X86/X86MatchJumptablePass.h
new file mode 100644
index 00000000000000..e69de29bb2d1d6

``````````

</details>


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


More information about the llvm-commits mailing list