llvm-6502/lib/CodeGen/MachOCodeEmitter.h
Bruno Cardoso Lopes ac57e6e498 Add the Object Code Emitter class. Original patch by Aaron Gray, I did some
cleanup, removed some #includes and moved Object Code Emitter out-of-line.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74813 91177308-0d34-0410-b5e6-96231b3b80d8
2009-07-06 05:09:34 +00:00

72 lines
1.9 KiB
C++

//===-- 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
#include "MachOWriter.h"
namespace llvm {
/// MachOCodeEmitter - This class is used by the MachOWriter to emit the code
/// for functions to the Mach-O file.
class MachOCodeEmitter : public ObjectCodeEmitter {
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;
const TargetAsmInfo *TAI;
/// Relocations - These are the relocations that the function needs, as
/// emitted.
std::vector<MachineRelocation> Relocations;
std::map<uint64_t, uintptr_t> Labels;
public:
MachOCodeEmitter(MachOWriter &mow, MachOSection &mos) :
ObjectCodeEmitter(&mos), MOW(mow), TM(MOW.TM) {
is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
isLittleEndian = TM.getTargetData()->isLittleEndian();
TAI = TM.getTargetAsmInfo();
}
virtual void startFunction(MachineFunction &MF);
virtual bool finishFunction(MachineFunction &MF);
virtual void addRelocation(const MachineRelocation &MR) {
Relocations.push_back(MR);
}
void emitConstantPool(MachineConstantPool *MCP);
void emitJumpTables(MachineJumpTableInfo *MJTI);
virtual void emitLabel(uint64_t LabelID) {
Labels[LabelID] = getCurrentPCOffset();
}
virtual uintptr_t getLabelAddress(uint64_t Label) const {
return Labels.find(Label)->second;
}
virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) { }
}; // end class MachOCodeEmitter
} // end namespace llvm
#endif