]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/ExecutionEngine/JITEventListener.h
Upgrade to Bzip2 version 1.0.7.
[FreeBSD/FreeBSD.git] / contrib / llvm / 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_EXECUTIONENGINE_JITEVENTLISTENER_H
16 #define LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
17
18 #include "llvm-c/ExecutionEngine.h"
19 #include "llvm/Config/llvm-config.h"
20 #include "llvm/ExecutionEngine/RuntimeDyld.h"
21 #include "llvm/IR/DebugLoc.h"
22 #include "llvm/Support/CBindingWrapping.h"
23 #include <cstdint>
24 #include <vector>
25
26 namespace llvm {
27
28 class IntelJITEventsWrapper;
29 class MachineFunction;
30 class OProfileWrapper;
31
32 namespace object {
33
34 class ObjectFile;
35
36 } // end namespace object
37
38 /// JITEventListener - Abstract interface for use by the JIT to notify clients
39 /// about significant events during compilation. For example, to notify
40 /// profilers and debuggers that need to know where functions have been emitted.
41 ///
42 /// The default implementation of each method does nothing.
43 class JITEventListener {
44 public:
45   using ObjectKey = uint64_t;
46
47   JITEventListener() = default;
48   virtual ~JITEventListener() = default;
49
50   /// notifyObjectLoaded - Called after an object has had its sections allocated
51   /// and addresses assigned to all symbols. Note: Section memory will not have
52   /// been relocated yet. notifyFunctionLoaded will not be called for
53   /// individual functions in the object.
54   ///
55   /// ELF-specific information
56   /// The ObjectImage contains the generated object image
57   /// with section headers updated to reflect the address at which sections
58   /// were loaded and with relocations performed in-place on debug sections.
59   virtual void notifyObjectLoaded(ObjectKey K, const object::ObjectFile &Obj,
60                                   const RuntimeDyld::LoadedObjectInfo &L) {}
61
62   /// notifyFreeingObject - Called just before the memory associated with
63   /// a previously emitted object is released.
64   virtual void notifyFreeingObject(ObjectKey K) {}
65
66   // Get a pointe to the GDB debugger registration listener.
67   static JITEventListener *createGDBRegistrationListener();
68
69 #if LLVM_USE_INTEL_JITEVENTS
70   // Construct an IntelJITEventListener
71   static JITEventListener *createIntelJITEventListener();
72
73   // Construct an IntelJITEventListener with a test Intel JIT API implementation
74   static JITEventListener *createIntelJITEventListener(
75                                       IntelJITEventsWrapper* AlternativeImpl);
76 #else
77   static JITEventListener *createIntelJITEventListener() { return nullptr; }
78
79   static JITEventListener *createIntelJITEventListener(
80                                       IntelJITEventsWrapper* AlternativeImpl) {
81     return nullptr;
82   }
83 #endif // USE_INTEL_JITEVENTS
84
85 #if LLVM_USE_OPROFILE
86   // Construct an OProfileJITEventListener
87   static JITEventListener *createOProfileJITEventListener();
88
89   // Construct an OProfileJITEventListener with a test opagent implementation
90   static JITEventListener *createOProfileJITEventListener(
91                                       OProfileWrapper* AlternativeImpl);
92 #else
93   static JITEventListener *createOProfileJITEventListener() { return nullptr; }
94
95   static JITEventListener *createOProfileJITEventListener(
96                                       OProfileWrapper* AlternativeImpl) {
97     return nullptr;
98   }
99 #endif // USE_OPROFILE
100
101 #if LLVM_USE_PERF
102   static JITEventListener *createPerfJITEventListener();
103 #else
104   static JITEventListener *createPerfJITEventListener()
105   {
106     return nullptr;
107   }
108 #endif // USE_PERF
109
110 private:
111   virtual void anchor();
112 };
113
114 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(JITEventListener, LLVMJITEventListenerRef)
115
116 } // end namespace llvm
117
118 #endif // LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H