From 0cc640e6c8af9c3e48d5d6a497f24d454bb7b910 Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Tue, 27 May 2003 21:45:05 +0000 Subject: [PATCH] Broke out class definition from SparcV9CodeEmitter, and added ability to take a MachineCodeEmitter to make a pass-through debugger -- output to memory and to std::cerr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6363 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/SparcV9/SparcV9CodeEmitter.cpp | 27 ++----------------- lib/Target/SparcV9/SparcV9CodeEmitter.h | 33 +++++++++++++++++++++++ 2 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 lib/Target/SparcV9/SparcV9CodeEmitter.h diff --git a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp index 4f779904779..1985da221a4 100644 --- a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp +++ b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp @@ -3,37 +3,14 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" #include "SparcInternals.h" - -namespace { - class SparcV9CodeEmitter : public MachineFunctionPass { - MachineCodeEmitter &MCE; - - public: - SparcV9CodeEmitter(MachineCodeEmitter &M) : MCE(M) {} - - bool runOnMachineFunction(MachineFunction &F); - - private: - int64_t getMachineOpValue(MachineOperand &MO); - unsigned getValueBit(int64_t Val, unsigned bit); - - void emitConstant(unsigned Val, unsigned Size); - - void emitBasicBlock(MachineBasicBlock &MBB); - void emitInstruction(MachineInstr &MI); - - /// Function generated by the CodeEmitterGenerator using TableGen - /// - unsigned getBinaryCodeForInstr(MachineInstr &MI); - }; -} +#include "SparcV9CodeEmitter.h" bool UltraSparc::addPassesToEmitMachineCode(PassManager &PM, MachineCodeEmitter &MCE) { //PM.add(new SparcV9CodeEmitter(MCE)); //MachineCodeEmitter *M = MachineCodeEmitter::createDebugMachineCodeEmitter(); MachineCodeEmitter *M = - MachineCodeEmitter::createFilePrinterMachineCodeEmitter(); + MachineCodeEmitter::createFilePrinterMachineCodeEmitter(MCE); PM.add(new SparcV9CodeEmitter(*M)); return false; } diff --git a/lib/Target/SparcV9/SparcV9CodeEmitter.h b/lib/Target/SparcV9/SparcV9CodeEmitter.h new file mode 100644 index 00000000000..ea1c8790eea --- /dev/null +++ b/lib/Target/SparcV9/SparcV9CodeEmitter.h @@ -0,0 +1,33 @@ + + +#ifndef SPARCV9CODEEMITTER_H +#define SPARCV9CODEEMITTER_H + +#include "llvm/CodeGen/MachineCodeEmitter.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineInstr.h" + +class SparcV9CodeEmitter : public MachineFunctionPass { + MachineCodeEmitter &MCE; + +public: + SparcV9CodeEmitter(MachineCodeEmitter &M) : MCE(M) {} + + bool runOnMachineFunction(MachineFunction &F); + + /// Function generated by the CodeEmitterGenerator using TableGen + /// + static unsigned getBinaryCodeForInstr(MachineInstr &MI); + +private: + static int64_t getMachineOpValue(MachineOperand &MO); + static unsigned getValueBit(int64_t Val, unsigned bit); + + void emitConstant(unsigned Val, unsigned Size); + + void emitBasicBlock(MachineBasicBlock &MBB); + void emitInstruction(MachineInstr &MI); + +}; + +#endif