1 //=== MachOWriter.h - Target-independent Mach-O writer support --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the MachOWriter class.
12 //===----------------------------------------------------------------------===//
17 #include "llvm/CodeGen/MachineFunctionPass.h"
18 #include "llvm/Target/TargetMachine.h"
27 /// MachOWriter - This class implements the common target-independent code for
28 /// writing Mach-O files. Targets should derive a class from this to
29 /// parameterize the output format.
31 class MachOWriter : public MachineFunctionPass {
35 /// Output stream to send the resultant object file to.
37 formatted_raw_ostream &O;
39 /// Target machine description.
43 /// Target Asm Printer information.
47 /// MCCE - The MCCodeEmitter object that we are exposing to emit machine
48 /// code for functions to the .o file.
51 /// OutContext - This is the context for the output file that we are
52 /// streaming. This owns all of the global MC-related objects for the
53 /// generated translation unit.
54 MCContext &OutContext;
56 /// OutStreamer - This is the MCStreamer object for the file we are
57 /// generating. This contains the transient state for the current
58 /// translation unit that we are generating (such as the current section
60 MCStreamer &OutStreamer;
62 /// Name-mangler for global names.
66 /// doInitialization - Emit the file header and all of the global variables
67 /// for the module to the Mach-O file.
68 bool doInitialization(Module &M);
70 /// doFinalization - Now that the module has been completely processed, emit
71 /// the Mach-O file to 'O'.
72 bool doFinalization(Module &M);
74 bool runOnMachineFunction(MachineFunction &MF);
77 explicit MachOWriter(formatted_raw_ostream &O, TargetMachine &TM,
78 const MCAsmInfo *T, MCCodeEmitter *MCE);
80 virtual ~MachOWriter();
82 virtual const char *getPassName() const {
83 return "Mach-O Writer";