Mercurial > hg > Members > tobaru > cbc > CbC_llvm
comparison lib/ExecutionEngine/IntelJITEvents/IntelJITEventsWrapper.h @ 0:95c75e76d11b
LLVM 3.4
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 12 Dec 2013 13:56:28 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:95c75e76d11b |
---|---|
1 //===-- IntelJITEventsWrapper.h - Intel JIT Events API Wrapper --*- 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 a wrapper for the Intel JIT Events API. It allows for the | |
11 // implementation of the jitprofiling library to be swapped with an alternative | |
12 // implementation (for testing). To include this file, you must have the | |
13 // jitprofiling.h header available; it is available in Intel(R) VTune(TM) | |
14 // Amplifier XE 2011. | |
15 // | |
16 //===----------------------------------------------------------------------===// | |
17 | |
18 #ifndef INTEL_JIT_EVENTS_WRAPPER_H | |
19 #define INTEL_JIT_EVENTS_WRAPPER_H | |
20 | |
21 #include "jitprofiling.h" | |
22 | |
23 namespace llvm { | |
24 | |
25 class IntelJITEventsWrapper { | |
26 // Function pointer types for testing implementation of Intel jitprofiling | |
27 // library | |
28 typedef int (*NotifyEventPtr)(iJIT_JVM_EVENT, void*); | |
29 typedef void (*RegisterCallbackExPtr)(void *, iJIT_ModeChangedEx ); | |
30 typedef iJIT_IsProfilingActiveFlags (*IsProfilingActivePtr)(void); | |
31 typedef void (*FinalizeThreadPtr)(void); | |
32 typedef void (*FinalizeProcessPtr)(void); | |
33 typedef unsigned int (*GetNewMethodIDPtr)(void); | |
34 | |
35 NotifyEventPtr NotifyEventFunc; | |
36 RegisterCallbackExPtr RegisterCallbackExFunc; | |
37 IsProfilingActivePtr IsProfilingActiveFunc; | |
38 GetNewMethodIDPtr GetNewMethodIDFunc; | |
39 | |
40 public: | |
41 bool isAmplifierRunning() { | |
42 return iJIT_IsProfilingActive() == iJIT_SAMPLING_ON; | |
43 } | |
44 | |
45 IntelJITEventsWrapper() | |
46 : NotifyEventFunc(::iJIT_NotifyEvent), | |
47 RegisterCallbackExFunc(::iJIT_RegisterCallbackEx), | |
48 IsProfilingActiveFunc(::iJIT_IsProfilingActive), | |
49 GetNewMethodIDFunc(::iJIT_GetNewMethodID) { | |
50 } | |
51 | |
52 IntelJITEventsWrapper(NotifyEventPtr NotifyEventImpl, | |
53 RegisterCallbackExPtr RegisterCallbackExImpl, | |
54 IsProfilingActivePtr IsProfilingActiveImpl, | |
55 FinalizeThreadPtr FinalizeThreadImpl, | |
56 FinalizeProcessPtr FinalizeProcessImpl, | |
57 GetNewMethodIDPtr GetNewMethodIDImpl) | |
58 : NotifyEventFunc(NotifyEventImpl), | |
59 RegisterCallbackExFunc(RegisterCallbackExImpl), | |
60 IsProfilingActiveFunc(IsProfilingActiveImpl), | |
61 GetNewMethodIDFunc(GetNewMethodIDImpl) { | |
62 } | |
63 | |
64 // Sends an event announcing that a function has been emitted | |
65 // return values are event-specific. See Intel documentation for details. | |
66 int iJIT_NotifyEvent(iJIT_JVM_EVENT EventType, void *EventSpecificData) { | |
67 if (!NotifyEventFunc) | |
68 return -1; | |
69 return NotifyEventFunc(EventType, EventSpecificData); | |
70 } | |
71 | |
72 // Registers a callback function to receive notice of profiling state changes | |
73 void iJIT_RegisterCallbackEx(void *UserData, | |
74 iJIT_ModeChangedEx NewModeCallBackFuncEx) { | |
75 if (RegisterCallbackExFunc) | |
76 RegisterCallbackExFunc(UserData, NewModeCallBackFuncEx); | |
77 } | |
78 | |
79 // Returns the current profiler mode | |
80 iJIT_IsProfilingActiveFlags iJIT_IsProfilingActive(void) { | |
81 if (!IsProfilingActiveFunc) | |
82 return iJIT_NOTHING_RUNNING; | |
83 return IsProfilingActiveFunc(); | |
84 } | |
85 | |
86 // Generates a locally unique method ID for use in code registration | |
87 unsigned int iJIT_GetNewMethodID(void) { | |
88 if (!GetNewMethodIDFunc) | |
89 return -1; | |
90 return GetNewMethodIDFunc(); | |
91 } | |
92 }; | |
93 | |
94 } //namespace llvm | |
95 | |
96 #endif //INTEL_JIT_EVENTS_WRAPPER_H |