[MIPS GlobalISel] Select MSA vector generic and builtin add
[llvm-complete.git] / lib / ExecutionEngine / IntelJITEvents / IntelJITEventsWrapper.h
blob68699c6a2200c9057fcec576704a381bcda9b5b3
1 //===-- IntelJITEventsWrapper.h - Intel JIT Events API Wrapper --*- 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 a wrapper for the Intel JIT Events API. It allows for the
10 // implementation of the jitprofiling library to be swapped with an alternative
11 // implementation (for testing). To include this file, you must have the
12 // jitprofiling.h header available; it is available in Intel(R) VTune(TM)
13 // Amplifier XE 2011.
15 //===----------------------------------------------------------------------===//
17 #ifndef INTEL_JIT_EVENTS_WRAPPER_H
18 #define INTEL_JIT_EVENTS_WRAPPER_H
20 #include "jitprofiling.h"
22 namespace llvm {
24 class IntelJITEventsWrapper {
25 // Function pointer types for testing implementation of Intel jitprofiling
26 // library
27 typedef int (*NotifyEventPtr)(iJIT_JVM_EVENT, void*);
28 typedef void (*RegisterCallbackExPtr)(void *, iJIT_ModeChangedEx );
29 typedef iJIT_IsProfilingActiveFlags (*IsProfilingActivePtr)(void);
30 typedef void (*FinalizeThreadPtr)(void);
31 typedef void (*FinalizeProcessPtr)(void);
32 typedef unsigned int (*GetNewMethodIDPtr)(void);
34 NotifyEventPtr NotifyEventFunc;
35 RegisterCallbackExPtr RegisterCallbackExFunc;
36 IsProfilingActivePtr IsProfilingActiveFunc;
37 GetNewMethodIDPtr GetNewMethodIDFunc;
39 public:
40 bool isAmplifierRunning() {
41 return iJIT_IsProfilingActive() == iJIT_SAMPLING_ON;
44 IntelJITEventsWrapper()
45 : NotifyEventFunc(::iJIT_NotifyEvent),
46 RegisterCallbackExFunc(::iJIT_RegisterCallbackEx),
47 IsProfilingActiveFunc(::iJIT_IsProfilingActive),
48 GetNewMethodIDFunc(::iJIT_GetNewMethodID) {
51 IntelJITEventsWrapper(NotifyEventPtr NotifyEventImpl,
52 RegisterCallbackExPtr RegisterCallbackExImpl,
53 IsProfilingActivePtr IsProfilingActiveImpl,
54 FinalizeThreadPtr FinalizeThreadImpl,
55 FinalizeProcessPtr FinalizeProcessImpl,
56 GetNewMethodIDPtr GetNewMethodIDImpl)
57 : NotifyEventFunc(NotifyEventImpl),
58 RegisterCallbackExFunc(RegisterCallbackExImpl),
59 IsProfilingActiveFunc(IsProfilingActiveImpl),
60 GetNewMethodIDFunc(GetNewMethodIDImpl) {
63 // Sends an event announcing that a function has been emitted
64 // return values are event-specific. See Intel documentation for details.
65 int iJIT_NotifyEvent(iJIT_JVM_EVENT EventType, void *EventSpecificData) {
66 if (!NotifyEventFunc)
67 return -1;
68 return NotifyEventFunc(EventType, EventSpecificData);
71 // Registers a callback function to receive notice of profiling state changes
72 void iJIT_RegisterCallbackEx(void *UserData,
73 iJIT_ModeChangedEx NewModeCallBackFuncEx) {
74 if (RegisterCallbackExFunc)
75 RegisterCallbackExFunc(UserData, NewModeCallBackFuncEx);
78 // Returns the current profiler mode
79 iJIT_IsProfilingActiveFlags iJIT_IsProfilingActive(void) {
80 if (!IsProfilingActiveFunc)
81 return iJIT_NOTHING_RUNNING;
82 return IsProfilingActiveFunc();
85 // Generates a locally unique method ID for use in code registration
86 unsigned int iJIT_GetNewMethodID(void) {
87 if (!GetNewMethodIDFunc)
88 return -1;
89 return GetNewMethodIDFunc();
93 } //namespace llvm
95 #endif //INTEL_JIT_EVENTS_WRAPPER_H