s|llvm/Support/Visibility.h|llvm/Support/Compiler.h|
[oota-llvm.git] / lib / Target / PowerPC / PPCMachOWriter.cpp
1 //===-- PPCMachOWriter.cpp - Emit a Mach-O file for the PowerPC backend ---===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Nate Begeman and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements a Mach-O writer for the PowerPC backend.  The public
11 // interface to this file is the createPPCMachOObjectWriterPass function.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "PPCTargetMachine.h"
16 #include "llvm/PassManager.h"
17 #include "llvm/CodeGen/MachOWriter.h"
18 #include "llvm/Support/Compiler.h"
19 using namespace llvm;
20
21 namespace {
22   class VISIBILITY_HIDDEN PPCMachOWriter : public MachOWriter {
23   public:
24     PPCMachOWriter(std::ostream &O, PPCTargetMachine &TM) : MachOWriter(O, TM) {
25       // FIMXE: choose ppc64 when appropriate
26       Header.cputype = MachOHeader::CPU_TYPE_POWERPC;
27       Header.cpusubtype = MachOHeader::CPU_SUBTYPE_POWERPC_ALL;
28     }
29
30   };
31 }
32
33 /// addPPCMachOObjectWriterPass - Returns a pass that outputs the generated code
34 /// as a Mach-O object file.
35 ///
36 void llvm::addPPCMachOObjectWriterPass(PassManager &FPM,
37                                        std::ostream &O, PPCTargetMachine &TM) {
38   PPCMachOWriter *EW = new PPCMachOWriter(O, TM);
39   FPM.add(EW);
40   FPM.add(createPPCCodeEmitterPass(TM, EW->getMachineCodeEmitter()));
41 }