From 39c2005b7082367457a1e6b833bf7e39a03a3b71 Mon Sep 17 00:00:00 2001 From: Alkis Evlogimenos Date: Tue, 9 Mar 2004 03:34:53 +0000 Subject: [PATCH] Add emitInstruction() API so that we can get the bytes of a simple instruction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12252 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86CodeEmitter.cpp | 16 +++++++++++++--- lib/Target/X86/X86TargetMachine.h | 7 +++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp index 99e63eb3aac..29607daf447 100644 --- a/lib/Target/X86/X86CodeEmitter.cpp +++ b/lib/Target/X86/X86CodeEmitter.cpp @@ -168,7 +168,6 @@ unsigned JITResolver::emitStubForFunction(Function *F) { } - namespace { class Emitter : public MachineFunctionPass { const X86InstrInfo *II; @@ -176,7 +175,9 @@ namespace { std::map BasicBlockAddrs; std::vector > BBRefs; public: - Emitter(MachineCodeEmitter &mce) : II(0), MCE(mce) {} + explicit Emitter(MachineCodeEmitter &mce) : II(0), MCE(mce) {} + Emitter(MachineCodeEmitter &mce, const X86InstrInfo& ii) + : II(&ii), MCE(mce) {} bool runOnMachineFunction(MachineFunction &MF); @@ -184,9 +185,10 @@ namespace { return "X86 Machine Code Emitter"; } + void emitInstruction(const MachineInstr &MI); + private: void emitBasicBlock(const MachineBasicBlock &MBB); - void emitInstruction(const MachineInstr &MI); void emitPCRelativeBlockAddress(const BasicBlock *BB); void emitMaybePCRelativeValue(unsigned Address, bool isPCRelative); @@ -203,6 +205,14 @@ namespace { }; } +// This function is required by Printer.cpp to workaround gas bugs +void llvm::X86::emitInstruction(MachineCodeEmitter& mce, + const X86InstrInfo& ii, + const MachineInstr& mi) +{ + Emitter(mce, ii).emitInstruction(mi); +} + /// addPassesToEmitMachineCode - Add passes to the specified pass manager to get /// machine code emitted. This uses a MachineCodeEmitter object to handle /// actually outputting the machine code and resolving things like the address diff --git a/lib/Target/X86/X86TargetMachine.h b/lib/Target/X86/X86TargetMachine.h index de85f95f73a..05b74140935 100644 --- a/lib/Target/X86/X86TargetMachine.h +++ b/lib/Target/X86/X86TargetMachine.h @@ -53,6 +53,13 @@ public: virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out); }; + // this is implemented in X86CodeEmitter.cpp + namespace X86 { + void emitInstruction(MachineCodeEmitter& mce, + const X86InstrInfo& ii, + const MachineInstr& MI); + } + } // End llvm namespace #endif