Skip to content

Conversation

@Ryan-hub-bit
Copy link

No description provided.

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Jan 10, 2025

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-backend-x86

Author: Kun Liu (Ryan-hub-bit)

Changes

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 --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

@RKSimon RKSimon marked this pull request as draft January 11, 2025 16:47
@RKSimon
Copy link
Collaborator

RKSimon commented Jan 11, 2025

@Ryan-hub-bit its better to only raise a PR once a patch branch is complete and ready for review - although if you're after early feedback its fine to make this a draft (as I've just done).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants