blob: 308e8b7775c580ccc07d85d6c273b63fc2ebba9b [file] [log] [blame]
Nate Begemaneb883af2006-08-23 21:08:52 +00001//===-- 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"
Chris Lattnera4f0b3a2006-08-27 12:54:02 +000018#include "llvm/Support/Compiler.h"
Nate Begemaneb883af2006-08-23 21:08:52 +000019using namespace llvm;
20
21namespace {
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///
36void 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}