LLVM 20.0.0git
IntelJITEventsWrapper.h
Go to the documentation of this file.
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.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef INTEL_JIT_EVENTS_WRAPPER_H
18#define INTEL_JIT_EVENTS_WRAPPER_H
19
20#include "jitprofiling.h"
21
22namespace llvm {
23
24typedef enum {
30
32 // Function pointer types for testing implementation of Intel jitprofiling
33 // library
34 typedef int (*NotifyEventPtr)(iJIT_JVM_EVENT, void*);
35 typedef int (*IttnotifyInfoPtr)(IttEventType, const char *, unsigned int);
36 typedef void (*RegisterCallbackExPtr)(void *, iJIT_ModeChangedEx );
37 typedef iJIT_IsProfilingActiveFlags (*IsProfilingActivePtr)(void);
38 typedef void (*FinalizeThreadPtr)(void);
39 typedef void (*FinalizeProcessPtr)(void);
40 typedef unsigned int (*GetNewMethodIDPtr)(void);
41
42 NotifyEventPtr NotifyEventFunc;
43 IttnotifyInfoPtr IttnotifyInfoFunc;
44 RegisterCallbackExPtr RegisterCallbackExFunc;
45 IsProfilingActivePtr IsProfilingActiveFunc;
46 GetNewMethodIDPtr GetNewMethodIDFunc;
47
48public:
51 }
52
54 : NotifyEventFunc(::iJIT_NotifyEvent), IttnotifyInfoFunc(0),
55 RegisterCallbackExFunc(::iJIT_RegisterCallbackEx),
56 IsProfilingActiveFunc(::iJIT_IsProfilingActive),
57 GetNewMethodIDFunc(::iJIT_GetNewMethodID) {}
58
59 IntelJITEventsWrapper(NotifyEventPtr NotifyEventImpl,
60 IttnotifyInfoPtr IttnotifyInfoImpl,
61 RegisterCallbackExPtr RegisterCallbackExImpl,
62 IsProfilingActivePtr IsProfilingActiveImpl,
63 FinalizeThreadPtr FinalizeThreadImpl,
64 FinalizeProcessPtr FinalizeProcessImpl,
65 GetNewMethodIDPtr GetNewMethodIDImpl)
66 : NotifyEventFunc(NotifyEventImpl), IttnotifyInfoFunc(IttnotifyInfoImpl),
67 RegisterCallbackExFunc(RegisterCallbackExImpl),
68 IsProfilingActiveFunc(IsProfilingActiveImpl),
69 GetNewMethodIDFunc(GetNewMethodIDImpl) {}
70
71 // Sends an event announcing that a function has been emitted
72 // return values are event-specific. See Intel documentation for details.
73 int iJIT_NotifyEvent(iJIT_JVM_EVENT EventType, void *EventSpecificData) {
74 if (!NotifyEventFunc)
75 return -1;
76 return NotifyEventFunc(EventType, EventSpecificData);
77 }
78
79 int iJitIttNotifyInfo(IttEventType EventType, const char *Name,
80 unsigned int Size) {
81 if (!IttnotifyInfoFunc)
82 return -1;
83 return IttnotifyInfoFunc(EventType, Name, Size);
84 }
85
86 // Registers a callback function to receive notice of profiling state changes
87 void iJIT_RegisterCallbackEx(void *UserData,
88 iJIT_ModeChangedEx NewModeCallBackFuncEx) {
89 if (RegisterCallbackExFunc)
90 RegisterCallbackExFunc(UserData, NewModeCallBackFuncEx);
91 }
92
93 // Returns the current profiler mode
95 if (!IsProfilingActiveFunc)
97 return IsProfilingActiveFunc();
98 }
99
100 // Generates a locally unique method ID for use in code registration
101 unsigned int iJIT_GetNewMethodID(void) {
102 if (!GetNewMethodIDFunc)
103 return -1;
104 return GetNewMethodIDFunc();
105 }
106};
107
108} // namespace llvm
109
110#endif //INTEL_JIT_EVENTS_WRAPPER_H
std::string Name
uint64_t Size
void iJIT_RegisterCallbackEx(void *UserData, iJIT_ModeChangedEx NewModeCallBackFuncEx)
int iJitIttNotifyInfo(IttEventType EventType, const char *Name, unsigned int Size)
IntelJITEventsWrapper(NotifyEventPtr NotifyEventImpl, IttnotifyInfoPtr IttnotifyInfoImpl, RegisterCallbackExPtr RegisterCallbackExImpl, IsProfilingActivePtr IsProfilingActiveImpl, FinalizeThreadPtr FinalizeThreadImpl, FinalizeProcessPtr FinalizeProcessImpl, GetNewMethodIDPtr GetNewMethodIDImpl)
unsigned int iJIT_GetNewMethodID(void)
iJIT_IsProfilingActiveFlags iJIT_IsProfilingActive(void)
int iJIT_NotifyEvent(iJIT_JVM_EVENT EventType, void *EventSpecificData)
void(* iJIT_ModeChangedEx)(void *UserData, iJIT_ModeFlags Flags)
Definition: jitprofiling.h:238
@ iJIT_NOTHING_RUNNING
Definition: jitprofiling.h:106
@ iJIT_SAMPLING_ON
Definition: jitprofiling.h:111
enum iJIT_jvm_event iJIT_JVM_EVENT
enum _iJIT_IsProfilingActiveFlags iJIT_IsProfilingActiveFlags
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18