Enable jitting with a known memory size.
[oota-llvm.git] / lib / ExecutionEngine / JIT / JITDwarfEmitter.h
1 //===------ JITDwarfEmitter.h - Write dwarf tables into memory ------------===//
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 // This file defines a JITDwarfEmitter object that is used by the JIT to
11 // write dwarf tables to memory.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_EXECUTION_ENGINE_JIT_DWARFEMITTER_H
16 #define LLVM_EXECUTION_ENGINE_JIT_DWARFEMITTER_H
17
18 namespace llvm {
19
20 class Function;
21 class MachineCodeEmitter;
22 class MachineFunction;
23 class MachineModuleInfo;
24 class MachineMove;
25 class TargetData;
26 class TargetMachine;
27 class TargetRegisterInfo;
28
29 class JITDwarfEmitter {
30   const TargetData* TD;
31   MachineCodeEmitter* MCE;
32   const TargetRegisterInfo* RI;
33   MachineModuleInfo* MMI;
34   JIT& Jit;
35   bool needsIndirectEncoding;
36   bool stackGrowthDirection;
37   
38   unsigned char* EmitExceptionTable(MachineFunction* MF,
39                                     unsigned char* StartFunction, 
40                                     unsigned char* EndFunction);
41
42   void EmitFrameMoves(intptr_t BaseLabelPtr, 
43                       const std::vector<MachineMove> &Moves);
44     
45   unsigned char* EmitCommonEHFrame(const Function* Personality);
46
47   unsigned char* EmitEHFrame(const Function* Personality, 
48                              unsigned char* StartBufferPtr,
49                              unsigned char* StartFunction, 
50                              unsigned char* EndFunction,
51                              unsigned char* ExceptionTable);
52     
53   unsigned GetExceptionTableSize(MachineFunction* MF);
54   
55   unsigned GetFrameMovesSize(intptr_t BaseLabelPtr, 
56                              const std::vector<MachineMove> &Moves);
57     
58   unsigned GetCommonEHFrameSize(const Function* Personality);
59
60   unsigned GetEHFrameSize(const Function* Personality, 
61                           unsigned char* StartFunction); 
62     
63 public:
64   
65   JITDwarfEmitter(JIT& jit);
66   
67   unsigned char* EmitDwarfTable(MachineFunction& F, 
68                                 MachineCodeEmitter& MCE,
69                                 unsigned char* StartFunction,
70                                 unsigned char* EndFunction);
71   
72   
73   unsigned GetDwarfTableSize(MachineFunction& F, 
74                              MachineCodeEmitter& MCE,
75                              unsigned char* StartFunction,
76                              unsigned char* EndFunction);
77
78   void setModuleInfo(MachineModuleInfo* Info) {
79     MMI = Info;
80   }
81 };
82
83
84 } // end namespace llvm
85
86 #endif // LLVM_EXECUTION_ENGINE_JIT_DWARFEMITTER_H