2006-08-23 23:08:52 +02:00
|
|
|
//=== MachOWriter.h - Target-independent Mach-O writer support --*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:36:04 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-08-23 23:08:52 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the MachOWriter class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-02-08 02:30:50 +01:00
|
|
|
#ifndef MACHOWRITER_H
|
|
|
|
#define MACHOWRITER_H
|
2006-08-23 23:08:52 +02:00
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2010-01-15 19:51:18 +01:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2006-08-23 23:08:52 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class GlobalVariable;
|
|
|
|
class Mangler;
|
2010-01-15 19:51:18 +01:00
|
|
|
class MCCodeEmitter;
|
|
|
|
class MCContext;
|
|
|
|
class MCStreamer;
|
|
|
|
|
2006-08-23 23:08:52 +02:00
|
|
|
/// MachOWriter - This class implements the common target-independent code for
|
|
|
|
/// writing Mach-O files. Targets should derive a class from this to
|
|
|
|
/// parameterize the output format.
|
|
|
|
///
|
|
|
|
class MachOWriter : public MachineFunctionPass {
|
2007-05-03 03:11:54 +02:00
|
|
|
static char ID;
|
2009-07-06 07:09:34 +02:00
|
|
|
|
2006-08-23 23:08:52 +02:00
|
|
|
protected:
|
|
|
|
/// Output stream to send the resultant object file to.
|
|
|
|
///
|
2010-01-15 19:51:18 +01:00
|
|
|
formatted_raw_ostream &O;
|
2006-08-23 23:08:52 +02:00
|
|
|
|
|
|
|
/// Target machine description.
|
|
|
|
///
|
|
|
|
TargetMachine &TM;
|
|
|
|
|
2010-01-15 19:51:18 +01:00
|
|
|
/// Target Asm Printer information.
|
2006-08-23 23:08:52 +02:00
|
|
|
///
|
2009-08-22 23:43:10 +02:00
|
|
|
const MCAsmInfo *MAI;
|
2010-01-15 19:51:18 +01:00
|
|
|
|
|
|
|
/// MCCE - The MCCodeEmitter object that we are exposing to emit machine
|
|
|
|
/// code for functions to the .o file.
|
|
|
|
MCCodeEmitter *MCCE;
|
|
|
|
|
|
|
|
/// OutContext - This is the context for the output file that we are
|
|
|
|
/// streaming. This owns all of the global MC-related objects for the
|
|
|
|
/// generated translation unit.
|
|
|
|
MCContext &OutContext;
|
|
|
|
|
|
|
|
/// OutStreamer - This is the MCStreamer object for the file we are
|
|
|
|
/// generating. This contains the transient state for the current
|
|
|
|
/// translation unit that we are generating (such as the current section
|
|
|
|
/// etc).
|
|
|
|
MCStreamer &OutStreamer;
|
|
|
|
|
|
|
|
/// Name-mangler for global names.
|
|
|
|
///
|
|
|
|
Mangler *Mang;
|
|
|
|
|
2009-06-03 05:43:31 +02:00
|
|
|
/// doInitialization - Emit the file header and all of the global variables
|
|
|
|
/// for the module to the Mach-O file.
|
|
|
|
bool doInitialization(Module &M);
|
2006-09-11 01:03:44 +02:00
|
|
|
|
2009-06-03 05:43:31 +02:00
|
|
|
/// doFinalization - Now that the module has been completely processed, emit
|
|
|
|
/// the Mach-O file to 'O'.
|
|
|
|
bool doFinalization(Module &M);
|
2006-08-23 23:08:52 +02:00
|
|
|
|
2010-01-15 19:51:18 +01:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF);
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit MachOWriter(formatted_raw_ostream &O, TargetMachine &TM,
|
|
|
|
const MCAsmInfo *T, MCCodeEmitter *MCE);
|
|
|
|
|
|
|
|
virtual ~MachOWriter();
|
|
|
|
|
|
|
|
virtual const char *getPassName() const {
|
|
|
|
return "Mach-O Writer";
|
2006-08-25 08:36:58 +02:00
|
|
|
}
|
2006-08-23 23:08:52 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|