Skip to content

Commit 9e95cde

Browse files
committed
machinebackend pass test
1 parent 222ff18 commit 9e95cde

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include "X86.h"
2+
#include "llvm/CodeGen/MachineFunctionPass.h"
3+
#include "llvm/CodeGen/MachineInstr.h"
4+
#include "llvm/CodeGen/MachineRegisterInfo.h"
5+
#include "llvm/Support/Debug.h"
6+
#include "llvm/Support/raw_ostream.h"
7+
8+
9+
using namespace llvm;
10+
11+
namespace {
12+
class X86MatchJumptablePass : public MachineFunctionPass {
13+
public:
14+
static char ID;
15+
16+
X86MatchJumptablePass() : MachineFunctionPass(ID) {}
17+
18+
bool runOnMachineFunction(MachineFunction &MF) override {
19+
LLVM_DEBUG(dbgs() << "Running X86MyBackendPass on function: "
20+
<< MF.getName() << "\n");
21+
22+
// Example: Iterate through instructions
23+
for (auto &MBB : MF) {
24+
for (auto &MI : MBB) {
25+
// Process instructions here
26+
LLVM_DEBUG(dbgs() << "Instruction: " << MI << "\n");
27+
}
28+
}
29+
30+
return false; // Return true if the pass modifies the function
31+
}
32+
33+
StringRef getPassName() const override {
34+
return "X86 My Backend Pass";
35+
}
36+
};
37+
}
38+
39+
char X86MatchJumptablePass::ID = 0;
40+
41+
// Register the pass
42+
FunctionPass *llvm::createX86MatchJumptablePass() {
43+
return new X86MatchJumptablePass();
44+
}

llvm/lib/Target/X86/X86MatchJumptablePass.h

Whitespace-only changes.

0 commit comments

Comments
 (0)