shoot a few more std::ostream print methods in the head.
[oota-llvm.git] / lib / CodeGen / MachOCodeEmitter.h
1 //===-- MachOEmitter.h - Target-independent Mach-O Emitter class ----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef MACHOCODEEMITTER_H
11 #define MACHOCODEEMITTER_H
12
13 #include "llvm/CodeGen/ObjectCodeEmitter.h"
14 #include <map>
15
16 namespace llvm {
17
18 class MachOWriter;
19
20 /// MachOCodeEmitter - This class is used by the MachOWriter to emit the code 
21 /// for functions to the Mach-O file.
22
23 class MachOCodeEmitter : public ObjectCodeEmitter {
24   MachOWriter &MOW;
25
26   /// Target machine description.
27   TargetMachine &TM;
28
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;
32
33   const MCAsmInfo *MAI;
34
35   /// Relocations - These are the relocations that the function needs, as
36   /// emitted.
37   std::vector<MachineRelocation> Relocations;
38
39   std::map<uint64_t, uintptr_t> Labels;
40
41 public:
42   MachOCodeEmitter(MachOWriter &mow, MachOSection &mos);
43
44   virtual void startFunction(MachineFunction &MF);
45   virtual bool finishFunction(MachineFunction &MF);
46
47   virtual void addRelocation(const MachineRelocation &MR) {
48     Relocations.push_back(MR);
49   }
50
51   void emitConstantPool(MachineConstantPool *MCP);
52   void emitJumpTables(MachineJumpTableInfo *MJTI);
53
54   virtual void emitLabel(uint64_t LabelID) {
55     Labels[LabelID] = getCurrentPCOffset();
56   }
57
58   virtual uintptr_t getLabelAddress(uint64_t Label) const {
59     return Labels.find(Label)->second;
60   }
61
62   virtual void setModuleInfo(llvm::MachineModuleInfo* MMI) { }
63
64 }; // end class MachOCodeEmitter
65
66 } // end namespace llvm
67
68 #endif
69