diff options
| author | Nate Begeman <natebegeman@mac.com> | 2006-08-23 21:08:52 +0000 |
|---|---|---|
| committer | Nate Begeman <natebegeman@mac.com> | 2006-08-23 21:08:52 +0000 |
| commit | eb883af3903286ac20f5bbf549c555c9ef961e14 (patch) | |
| tree | 876fc716e1d1cfc6c0341ffd7a5a750b17c4d136 /lib/Target/PowerPC/PPCMachOWriter.cpp | |
| parent | 81bc5088dd783421456c298b5fcc741c45acbea0 (diff) | |
Initial checkin of the Mach-O emitter. There's plenty of fixmes, but it
does emit linkable .o files in very simple cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29850 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCMachOWriter.cpp')
| -rw-r--r-- | lib/Target/PowerPC/PPCMachOWriter.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/Target/PowerPC/PPCMachOWriter.cpp b/lib/Target/PowerPC/PPCMachOWriter.cpp new file mode 100644 index 0000000000..29f823829d --- /dev/null +++ b/lib/Target/PowerPC/PPCMachOWriter.cpp @@ -0,0 +1,41 @@ +//===-- PPCMachOWriter.cpp - Emit a Mach-O file for the PowerPC backend ---===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Nate Begeman and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements a Mach-O writer for the PowerPC backend. The public +// interface to this file is the createPPCMachOObjectWriterPass function. +// +//===----------------------------------------------------------------------===// + +#include "PPCTargetMachine.h" +#include "llvm/PassManager.h" +#include "llvm/CodeGen/MachOWriter.h" +#include "llvm/Support/Visibility.h" +using namespace llvm; + +namespace { + class VISIBILITY_HIDDEN PPCMachOWriter : public MachOWriter { + public: + PPCMachOWriter(std::ostream &O, PPCTargetMachine &TM) : MachOWriter(O, TM) { + // FIMXE: choose ppc64 when appropriate + Header.cputype = MachOHeader::CPU_TYPE_POWERPC; + Header.cpusubtype = MachOHeader::CPU_SUBTYPE_POWERPC_ALL; + } + + }; +} + +/// addPPCMachOObjectWriterPass - Returns a pass that outputs the generated code +/// as a Mach-O object file. +/// +void llvm::addPPCMachOObjectWriterPass(PassManager &FPM, + std::ostream &O, PPCTargetMachine &TM) { + PPCMachOWriter *EW = new PPCMachOWriter(O, TM); + FPM.add(EW); + FPM.add(createPPCCodeEmitterPass(TM, EW->getMachineCodeEmitter())); +} |
