diff --git a/lib/Target/X86/MachineCodeEmitter.cpp b/lib/Target/X86/MachineCodeEmitter.cpp new file mode 100644 index 00000000000..ba82503e495 --- /dev/null +++ b/lib/Target/X86/MachineCodeEmitter.cpp @@ -0,0 +1,36 @@ +//===-- X86/MachineCodeEmitter.cpp - Convert X86 code to machine code -----===// +// +// This file contains the pass that transforms the X86 machine instructions into +// actual executable machine code. +// +//===----------------------------------------------------------------------===// + +#include "X86TargetMachine.h" +#include "llvm/PassManager.h" +#include "llvm/CodeGen/MachineCodeEmitter.h" + +namespace { + struct Emitter : public FunctionPass { + TargetMachine &TM; + MachineCodeEmitter &MCE; + + Emitter(TargetMachine &tm, MachineCodeEmitter &mce) : TM(tm), MCE(mce) {} + ~Emitter() { + } + + bool runOnFunction(Function &F) { return false; } + }; +} + + +/// 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 +/// of functions. This method should returns true if machine code emission is +/// not supported. +/// +bool X86TargetMachine::addPassesToEmitMachineCode(PassManager &PM, + MachineCodeEmitter &MCE) { + PM.add(new Emitter(*this, MCE)); + return false; +} diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp new file mode 100644 index 00000000000..ba82503e495 --- /dev/null +++ b/lib/Target/X86/X86CodeEmitter.cpp @@ -0,0 +1,36 @@ +//===-- X86/MachineCodeEmitter.cpp - Convert X86 code to machine code -----===// +// +// This file contains the pass that transforms the X86 machine instructions into +// actual executable machine code. +// +//===----------------------------------------------------------------------===// + +#include "X86TargetMachine.h" +#include "llvm/PassManager.h" +#include "llvm/CodeGen/MachineCodeEmitter.h" + +namespace { + struct Emitter : public FunctionPass { + TargetMachine &TM; + MachineCodeEmitter &MCE; + + Emitter(TargetMachine &tm, MachineCodeEmitter &mce) : TM(tm), MCE(mce) {} + ~Emitter() { + } + + bool runOnFunction(Function &F) { return false; } + }; +} + + +/// 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 +/// of functions. This method should returns true if machine code emission is +/// not supported. +/// +bool X86TargetMachine::addPassesToEmitMachineCode(PassManager &PM, + MachineCodeEmitter &MCE) { + PM.add(new Emitter(*this, MCE)); + return false; +} diff --git a/lib/Target/X86/X86TargetMachine.h b/lib/Target/X86/X86TargetMachine.h index 9db8375d8df..065fd368a21 100644 --- a/lib/Target/X86/X86TargetMachine.h +++ b/lib/Target/X86/X86TargetMachine.h @@ -30,6 +30,15 @@ public: /// not supported for this target. /// virtual bool addPassesToJITCompile(PassManager &PM); + + /// 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 + /// of functions. This method should returns true if machine code emission is + /// not supported. + /// + virtual bool addPassesToEmitMachineCode(PassManager &PM, + MachineCodeEmitter &MCE); }; #endif