summaryrefslogtreecommitdiff
path: root/include/llvm/ExecutionEngine/JITEventListener.h
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2009-06-25 02:04:04 +0000
committerJeffrey Yasskin <jyasskin@google.com>2009-06-25 02:04:04 +0000
commitdf5a7daff9c7664bff8b713e8ed5155319bc6041 (patch)
treed0a7b2a265916b1e0e36ef6423b56749d3429c9a /include/llvm/ExecutionEngine/JITEventListener.h
parentb6c29d55123f6b8c3f9e4d56e4be653a1fd2a472 (diff)
downloadllvm-df5a7daff9c7664bff8b713e8ed5155319bc6041.tar.gz
llvm-df5a7daff9c7664bff8b713e8ed5155319bc6041.tar.bz2
llvm-df5a7daff9c7664bff8b713e8ed5155319bc6041.tar.xz
Add a JITEventListener interface that gets called back when a new function is
emitted or the machine code for a function is freed. Chris mentioned that we may also want a notification when a stub is emitted, but that'll be a future change. I intend to use this to tell oprofile where functions are emitted and what lines correspond to what addresses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74157 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ExecutionEngine/JITEventListener.h')
-rw-r--r--include/llvm/ExecutionEngine/JITEventListener.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/include/llvm/ExecutionEngine/JITEventListener.h b/include/llvm/ExecutionEngine/JITEventListener.h
new file mode 100644
index 0000000000..dd76f26c87
--- /dev/null
+++ b/include/llvm/ExecutionEngine/JITEventListener.h
@@ -0,0 +1,59 @@
+//===- JITEventListener.h - Exposes events from JIT compilation -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the JITEventListener interface, which lets users get
+// callbacks when significant events happen during the JIT compilation process.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_EXECUTION_ENGINE_JIT_EVENTLISTENER_H
+#define LLVM_EXECUTION_ENGINE_JIT_EVENTLISTENER_H
+
+#include "llvm/Support/DataTypes.h"
+
+namespace llvm {
+class Function;
+
+/// Empty for now, but this object will contain all details about the
+/// generated machine code that a Listener might care about.
+struct JITEvent_EmittedFunctionDetails {
+};
+
+/// JITEventListener - This interface is used by the JIT to notify clients about
+/// significant events during compilation. For example, we could have
+/// implementations for profilers and debuggers that need to know where
+/// functions have been emitted.
+///
+/// Each method defaults to doing nothing, so you only need to override the ones
+/// you care about.
+class JITEventListener {
+public:
+ JITEventListener() {}
+ virtual ~JITEventListener(); // Defined in JIT.cpp.
+
+ typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails;
+ /// NotifyFunctionEmitted - Called after a function has been successfully
+ /// emitted to memory. The function still has its MachineFunction attached,
+ /// if you should happen to need that.
+ virtual void NotifyFunctionEmitted(const Function &F,
+ void *Code, size_t Size,
+ const EmittedFunctionDetails &Details) {}
+
+ /// NotifyFreeingMachineCode - This is called inside of
+ /// freeMachineCodeForFunction(), after the global mapping is removed, but
+ /// before the machine code is returned to the allocator. OldPtr is the
+ /// address of the machine code.
+ virtual void NotifyFreeingMachineCode(const Function &F, void *OldPtr) {}
+};
+
+JITEventListener *createMacOSJITEventListener();
+
+} // end namespace llvm.
+
+#endif