From 55a2facbf92a3e683f4713b9c924de4a638f79d4 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 8 Feb 2007 01:35:27 +0000 Subject: [PATCH] Add function to create a file writer. llvm-svn: 34031 --- lib/CodeGen/ELFWriter.cpp | 16 +++++++++++++++- lib/CodeGen/MachOWriter.cpp | 15 +++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp index 5b39ab0540a..5fd3dcc1d6c 100644 --- a/lib/CodeGen/ELFWriter.cpp +++ b/lib/CodeGen/ELFWriter.cpp @@ -31,18 +31,32 @@ // //===----------------------------------------------------------------------===// -#include "llvm/CodeGen/ELFWriter.h" +#include "ELFWriter.h" #include "llvm/Module.h" +#include "llvm/PassManager.h" +#include "llvm/CodeGen/FileWriters.h" #include "llvm/CodeGen/MachineCodeEmitter.h" #include "llvm/CodeGen/MachineConstantPool.h" +#include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetELFWriterInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/OutputBuffer.h" #include "llvm/Support/Streams.h" +#include using namespace llvm; +/// AddELFWriter - Concrete function to add the ELF writer to the function pass +/// manager. +MachineCodeEmitter *llvm::AddELFWriter(FunctionPassManager &FPM, + std::ostream &O, + TargetMachine &TM) { + ELFWriter *EW = new ELFWriter(O, TM); + FPM.add(EW); + return &EW->getMachineCodeEmitter(); +} + //===----------------------------------------------------------------------===// // ELFCodeEmitter Implementation //===----------------------------------------------------------------------===// diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp index e6cfedab57f..3beb11a25f2 100644 --- a/lib/CodeGen/MachOWriter.cpp +++ b/lib/CodeGen/MachOWriter.cpp @@ -22,13 +22,15 @@ // //===----------------------------------------------------------------------===// +#include "MachOWriter.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" +#include "llvm/PassManager.h" +#include "llvm/CodeGen/FileWriters.h" #include "llvm/CodeGen/MachineCodeEmitter.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" -#include "llvm/CodeGen/MachOWriter.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/Target/TargetAsmInfo.h" #include "llvm/Target/TargetJITInfo.h" @@ -37,9 +39,18 @@ #include "llvm/Support/OutputBuffer.h" #include "llvm/Support/Streams.h" #include - using namespace llvm; +/// AddMachOWriter - Concrete function to add the Mach-O writer to the function +/// pass manager. +MachineCodeEmitter *llvm::AddMachOWriter(FunctionPassManager &FPM, + std::ostream &O, + TargetMachine &TM) { + MachOWriter *MOW = new MachOWriter(O, TM); + FPM.add(MOW); + return &MOW->getMachineCodeEmitter(); +} + //===----------------------------------------------------------------------===// // MachOCodeEmitter Implementation //===----------------------------------------------------------------------===//