2009-06-03 05:43:31 +02:00
|
|
|
//===-- MachOEmitter.h - Target-independent Mach-O Emitter class ----------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef MACHOCODEEMITTER_H
|
|
|
|
#define MACHOCODEEMITTER_H
|
|
|
|
|
2009-07-06 08:40:51 +02:00
|
|
|
#include "llvm/CodeGen/ObjectCodeEmitter.h"
|
|
|
|
#include <map>
|
2009-06-03 05:43:31 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2009-07-06 08:40:51 +02:00
|
|
|
class MachOWriter;
|
|
|
|
|
2009-06-03 05:43:31 +02:00
|
|
|
/// MachOCodeEmitter - This class is used by the MachOWriter to emit the code
|
|
|
|
/// for functions to the Mach-O file.
|
|
|
|
|
2009-07-06 07:09:34 +02:00
|
|
|
class MachOCodeEmitter : public ObjectCodeEmitter {
|
2009-06-03 05:43:31 +02:00
|
|
|
MachOWriter &MOW;
|
|
|
|
|
|
|
|
/// Target machine description.
|
|
|
|
TargetMachine &TM;
|
|
|
|
|
|
|
|
/// is64Bit/isLittleEndian - This information is inferred from the target
|
|
|
|
/// machine directly, indicating what header values and flags to set.
|
|
|
|
bool is64Bit, isLittleEndian;
|
|
|
|
|
2009-08-22 23:43:10 +02:00
|
|
|
const MCAsmInfo *MAI;
|
2009-06-03 05:43:31 +02:00
|
|
|
|
|
|
|
/// Relocations - These are the relocations that the function needs, as
|
|
|
|
/// emitted.
|
|
|
|
std::vector<MachineRelocation> Relocations;
|
2009-07-06 07:09:34 +02:00
|
|
|
|
|
|
|
std::map<uint64_t, uintptr_t> Labels;
|
|
|
|
|
2009-06-03 05:43:31 +02:00
|
|
|
public:
|
2009-07-06 08:40:51 +02:00
|
|
|
MachOCodeEmitter(MachOWriter &mow, MachOSection &mos);
|
2009-06-03 05:43:31 +02:00
|
|
|
|
|
|
|
virtual void startFunction(MachineFunction &MF);
|
|
|
|
virtual bool finishFunction(MachineFunction &MF);
|
|
|
|
|
|
|
|
virtual void addRelocation(const MachineRelocation &MR) {
|
|
|
|
Relocations.push_back(MR);
|
|
|
|
}
|
2009-07-06 08:40:51 +02:00
|
|
|
|
2009-06-03 05:43:31 +02:00
|
|
|
void emitConstantPool(MachineConstantPool *MCP);
|
|
|
|
void emitJumpTables(MachineJumpTableInfo *MJTI);
|
|
|
|
|
2009-07-06 07:09:34 +02:00
|
|
|
virtual void emitLabel(uint64_t LabelID) {
|
|
|
|
Labels[LabelID] = getCurrentPCOffset();
|
2009-06-03 05:43:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual uintptr_t getLabelAddress(uint64_t Label) const {
|
2009-07-06 07:09:34 +02:00
|
|
|
return Labels.find(Label)->second;
|
2009-06-03 05:43:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) { }
|
|
|
|
|
|
|
|
}; // end class MachOCodeEmitter
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|