Move DataTypes.h to include/llvm/System, update all users. This breaks the last
[oota-llvm.git] / include / llvm / ExecutionEngine / JITEventListener.h
1 //===- JITEventListener.h - Exposes events from JIT compilation -*- C++ -*-===//
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 the JITEventListener interface, which lets users get
11 // callbacks when significant events happen during the JIT compilation process.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_EXECUTION_ENGINE_JIT_EVENTLISTENER_H
16 #define LLVM_EXECUTION_ENGINE_JIT_EVENTLISTENER_H
17
18 #include "llvm/System/DataTypes.h"
19 #include "llvm/Support/DebugLoc.h"
20
21 #include <vector>
22
23 namespace llvm {
24 class Function;
25 class MachineFunction;
26
27 /// Empty for now, but this object will contain all details about the
28 /// generated machine code that a Listener might care about.
29 struct JITEvent_EmittedFunctionDetails {
30   const MachineFunction *MF;
31
32   struct LineStart {
33     // The address at which the current line changes.
34     uintptr_t Address;
35     // The new location information.  These can be translated to
36     // DebugLocTuples using MF->getDebugLocTuple().
37     DebugLoc Loc;
38   };
39   // This holds line boundary information sorted by address.
40   std::vector<LineStart> LineStarts;
41 };
42
43 /// JITEventListener - This interface is used by the JIT to notify clients about
44 /// significant events during compilation.  For example, we could have
45 /// implementations for profilers and debuggers that need to know where
46 /// functions have been emitted.
47 ///
48 /// Each method defaults to doing nothing, so you only need to override the ones
49 /// you care about.
50 class JITEventListener {
51 public:
52   JITEventListener() {}
53   virtual ~JITEventListener();  // Defined in JIT.cpp.
54
55   typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails;
56   /// NotifyFunctionEmitted - Called after a function has been successfully
57   /// emitted to memory.  The function still has its MachineFunction attached,
58   /// if you should happen to need that.
59   virtual void NotifyFunctionEmitted(const Function &F,
60                                      void *Code, size_t Size,
61                                      const EmittedFunctionDetails &Details) {}
62
63   /// NotifyFreeingMachineCode - This is called inside of
64   /// freeMachineCodeForFunction(), after the global mapping is removed, but
65   /// before the machine code is returned to the allocator.  OldPtr is the
66   /// address of the machine code.
67   virtual void NotifyFreeingMachineCode(const Function &F, void *OldPtr) {}
68 };
69
70 // This returns NULL if support isn't available.
71 JITEventListener *createOProfileJITEventListener();
72
73 } // end namespace llvm.
74
75 #endif