[InstCombine] Signed saturation patterns
[llvm-complete.git] / include / llvm / ExecutionEngine / JITEventListener.h
blob606b6f7cc1284116407d2ab531083481aa633168
1 //===- JITEventListener.h - Exposes events from JIT compilation -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the JITEventListener interface, which lets users get
10 // callbacks when significant events happen during the JIT compilation process.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
15 #define LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
17 #include "llvm-c/ExecutionEngine.h"
18 #include "llvm/Config/llvm-config.h"
19 #include "llvm/ExecutionEngine/RuntimeDyld.h"
20 #include "llvm/IR/DebugLoc.h"
21 #include "llvm/Support/CBindingWrapping.h"
22 #include <cstdint>
23 #include <vector>
25 namespace llvm {
27 class IntelJITEventsWrapper;
28 class MachineFunction;
29 class OProfileWrapper;
31 namespace object {
33 class ObjectFile;
35 } // end namespace object
37 /// JITEventListener - Abstract interface for use by the JIT to notify clients
38 /// about significant events during compilation. For example, to notify
39 /// profilers and debuggers that need to know where functions have been emitted.
40 ///
41 /// The default implementation of each method does nothing.
42 class JITEventListener {
43 public:
44 using ObjectKey = uint64_t;
46 JITEventListener() = default;
47 virtual ~JITEventListener() = default;
49 /// notifyObjectLoaded - Called after an object has had its sections allocated
50 /// and addresses assigned to all symbols. Note: Section memory will not have
51 /// been relocated yet. notifyFunctionLoaded will not be called for
52 /// individual functions in the object.
53 ///
54 /// ELF-specific information
55 /// The ObjectImage contains the generated object image
56 /// with section headers updated to reflect the address at which sections
57 /// were loaded and with relocations performed in-place on debug sections.
58 virtual void notifyObjectLoaded(ObjectKey K, const object::ObjectFile &Obj,
59 const RuntimeDyld::LoadedObjectInfo &L) {}
61 /// notifyFreeingObject - Called just before the memory associated with
62 /// a previously emitted object is released.
63 virtual void notifyFreeingObject(ObjectKey K) {}
65 // Get a pointe to the GDB debugger registration listener.
66 static JITEventListener *createGDBRegistrationListener();
68 #if LLVM_USE_INTEL_JITEVENTS
69 // Construct an IntelJITEventListener
70 static JITEventListener *createIntelJITEventListener();
72 // Construct an IntelJITEventListener with a test Intel JIT API implementation
73 static JITEventListener *createIntelJITEventListener(
74 IntelJITEventsWrapper* AlternativeImpl);
75 #else
76 static JITEventListener *createIntelJITEventListener() { return nullptr; }
78 static JITEventListener *createIntelJITEventListener(
79 IntelJITEventsWrapper* AlternativeImpl) {
80 return nullptr;
82 #endif // USE_INTEL_JITEVENTS
84 #if LLVM_USE_OPROFILE
85 // Construct an OProfileJITEventListener
86 static JITEventListener *createOProfileJITEventListener();
88 // Construct an OProfileJITEventListener with a test opagent implementation
89 static JITEventListener *createOProfileJITEventListener(
90 OProfileWrapper* AlternativeImpl);
91 #else
92 static JITEventListener *createOProfileJITEventListener() { return nullptr; }
94 static JITEventListener *createOProfileJITEventListener(
95 OProfileWrapper* AlternativeImpl) {
96 return nullptr;
98 #endif // USE_OPROFILE
100 #if LLVM_USE_PERF
101 static JITEventListener *createPerfJITEventListener();
102 #else
103 static JITEventListener *createPerfJITEventListener()
105 return nullptr;
107 #endif // USE_PERF
109 private:
110 virtual void anchor();
113 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(JITEventListener, LLVMJITEventListenerRef)
115 } // end namespace llvm
117 #endif // LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H