1 //===-- MachOEmitter.h - Target-independent Mach-O Emitter class ----------===//
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 #ifndef MACHOCODEEMITTER_H
11 #define MACHOCODEEMITTER_H
13 #include "llvm/CodeGen/ObjectCodeEmitter.h"
20 /// MachOCodeEmitter - This class is used by the MachOWriter to emit the code
21 /// for functions to the Mach-O file.
23 class MachOCodeEmitter
: public ObjectCodeEmitter
{
26 /// Target machine description.
29 /// is64Bit/isLittleEndian - This information is inferred from the target
30 /// machine directly, indicating what header values and flags to set.
31 bool is64Bit
, isLittleEndian
;
33 const TargetAsmInfo
*TAI
;
35 /// Relocations - These are the relocations that the function needs, as
37 std::vector
<MachineRelocation
> Relocations
;
39 std::map
<uint64_t, uintptr_t> Labels
;
42 MachOCodeEmitter(MachOWriter
&mow
, MachOSection
&mos
);
44 virtual void startFunction(MachineFunction
&MF
);
45 virtual bool finishFunction(MachineFunction
&MF
);
47 virtual void addRelocation(const MachineRelocation
&MR
) {
48 Relocations
.push_back(MR
);
51 void emitConstantPool(MachineConstantPool
*MCP
);
52 void emitJumpTables(MachineJumpTableInfo
*MJTI
);
54 virtual void emitLabel(uint64_t LabelID
) {
55 Labels
[LabelID
] = getCurrentPCOffset();
58 virtual uintptr_t getLabelAddress(uint64_t Label
) const {
59 return Labels
.find(Label
)->second
;
62 virtual void setModuleInfo(llvm::MachineModuleInfo
* MMI
) { }
64 }; // end class MachOCodeEmitter
66 } // end namespace llvm