2006-08-24 05:08:52 +08:00
|
|
|
//=== MachOWriter.h - Target-independent Mach-O writer support --*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-08-24 05:08:52 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the MachOWriter class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-02-08 09:30:50 +08:00
|
|
|
#ifndef MACHOWRITER_H
|
|
|
|
#define MACHOWRITER_H
|
2006-08-24 05:08:52 +08:00
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2010-01-16 02:51:18 +08:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2006-08-24 05:08:52 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class GlobalVariable;
|
|
|
|
class Mangler;
|
2010-01-16 02:51:18 +08:00
|
|
|
class MCCodeEmitter;
|
|
|
|
class MCContext;
|
|
|
|
class MCStreamer;
|
|
|
|
|
2006-08-24 05:08:52 +08: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 09:11:54 +08:00
|
|
|
static char ID;
|
2009-07-06 13:09:34 +08:00
|
|
|
|
2006-08-24 05:08:52 +08:00
|
|
|
protected:
|
|
|
|
/// Output stream to send the resultant object file to.
|
|
|
|
///
|
2010-01-16 02:51:18 +08:00
|
|
|
formatted_raw_ostream &O;
|
2006-08-24 05:08:52 +08:00
|
|
|
|
|
|
|
/// Target machine description.
|
|
|
|
///
|
|
|
|
TargetMachine &TM;
|
|
|
|
|
2010-01-16 02:51:18 +08:00
|
|
|
/// Target Asm Printer information.
|
2006-08-24 05:08:52 +08:00
|
|
|
///
|
2009-08-23 05:43:10 +08:00
|
|
|
const MCAsmInfo *MAI;
|
2010-01-16 02:51:18 +08: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 11:43:31 +08: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 07:03:44 +08:00
|
|
|
|
2009-06-03 11:43:31 +08:00
|
|
|
/// doFinalization - Now that the module has been completely processed, emit
|
|
|
|
/// the Mach-O file to 'O'.
|
|
|
|
bool doFinalization(Module &M);
|
2006-08-24 05:08:52 +08:00
|
|
|
|
2010-01-16 02:51:18 +08: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 14:36:58 +08:00
|
|
|
}
|
2006-08-24 05:08:52 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|