Created
January 26, 2017 19:45
-
-
Save RadhikaG/605c1c34247e4992676967598413aa91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "X86.h" | |
#include "X86InstrInfo.h" | |
#include "llvm/CodeGen/MachineFunctionPass.h" | |
#include "llvm/CodeGen/MachineInstrBuilder.h" | |
#include "llvm/Target/TargetRegisterInfo.h" | |
using namespace llvm; | |
#define X86_MACHINEINSTR_PRINTER_PASS_NAME "Dummy X86 machineinstr printer pass" | |
namespace { | |
class X86MachineInstrPrinter : public MachineFunctionPass { | |
public: | |
static char ID; | |
X86MachineInstrPrinter() : MachineFunctionPass(ID) { | |
initializeX86MachineInstrPrinterPass(*PassRegistry::getPassRegistry()); | |
} | |
bool runOnMachineFunction(MachineFunction &MF) override; | |
StringRef getPassName() const override { return X86_MACHINEINSTR_PRINTER_PASS_NAME; } | |
}; | |
char X86MachineInstrPrinter::ID = 0; | |
bool X86MachineInstrPrinter::runOnMachineFunction(MachineFunction &MF) { | |
for (auto &MBB : MF) { | |
outs() << "Contents of MachineBasicBlock:\n"; | |
outs() << MBB << "\n"; | |
const BasicBlock *BB = MBB.getBasicBlock(); | |
outs() << "Contents of BasicBlock corresponding to MachineBasicBlock:\n"; | |
outs() << BB << "\n"; | |
} | |
return false; | |
} | |
} // end of anonymous namespace | |
INITIALIZE_PASS(X86MachineInstrPrinter, "x86-machineinstr-printer", | |
X86_MACHINEINSTR_PRINTER_PASS_NAME, | |
true, // is CFG only? | |
true // is analysis? | |
) | |
namespace llvm { | |
FunctionPass *createX86MachineInstrPrinterPass() { return new X86MachineInstrPrinter(); } | |
} |
also the header "llvm/Target/TargetRegisterInfo.h" seemed to move to "llvm/CodeGen/TargetRegisterInfo.h"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
createX86MachineInstrPrinterPass should be createX86MachineInstrPrinter at end, no?