diff options
author | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-03-09 03:34:53 +0000 |
---|---|---|
committer | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-03-09 03:34:53 +0000 |
commit | 39c2005b7082367457a1e6b833bf7e39a03a3b71 (patch) | |
tree | 9386914041f5d5ae8082d07495bec4f1e43f272c /lib | |
parent | f6e8156008656a1ac69763c70cc87bd3e1533d40 (diff) | |
download | external_llvm-39c2005b7082367457a1e6b833bf7e39a03a3b71.zip external_llvm-39c2005b7082367457a1e6b833bf7e39a03a3b71.tar.gz external_llvm-39c2005b7082367457a1e6b833bf7e39a03a3b71.tar.bz2 |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/X86/X86CodeEmitter.cpp | 16 | ||||
-rw-r--r-- | 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 99e63eb..29607da 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<const BasicBlock*, unsigned> BasicBlockAddrs; std::vector<std::pair<const BasicBlock*, unsigned> > 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 de85f95..05b7414 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 |