summaryrefslogtreecommitdiffstats
path: root/include/llvm/ExecutionEngine
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/ExecutionEngine')
-rw-r--r--include/llvm/ExecutionEngine/ExecutionEngine.h16
-rw-r--r--include/llvm/ExecutionEngine/Interpreter.h6
-rw-r--r--include/llvm/ExecutionEngine/JIT.h6
-rw-r--r--include/llvm/ExecutionEngine/JITEventListener.h59
4 files changed, 75 insertions, 12 deletions
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h
index 170e184..613adb5 100644
--- a/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -29,13 +29,14 @@ class Constant;
class Function;
class GlobalVariable;
class GlobalValue;
+class JITEventListener;
+class JITMemoryManager;
+class MachineCodeInfo;
class Module;
class ModuleProvider;
+class MutexGuard;
class TargetData;
class Type;
-class MutexGuard;
-class JITMemoryManager;
-class MachineCodeInfo;
class ExecutionEngineState {
private:
@@ -276,7 +277,14 @@ public:
virtual void *getOrEmitGlobalVariable(const GlobalVariable *GV) {
return getPointerToGlobal((GlobalValue*)GV);
}
-
+
+ /// Registers a listener to be called back on various events within
+ /// the JIT. See JITEventListener.h for more details. Does not
+ /// take ownership of the argument. The argument may be NULL, in
+ /// which case these functions do nothing.
+ virtual void RegisterJITEventListener(JITEventListener *L) {}
+ virtual void UnregisterJITEventListener(JITEventListener *L) {}
+
/// DisableLazyCompilation - If called, the JIT will abort if lazy compilation
/// is ever attempted.
void DisableLazyCompilation(bool Disabled = true) {
diff --git a/include/llvm/ExecutionEngine/Interpreter.h b/include/llvm/ExecutionEngine/Interpreter.h
index b2b0464..7425cdb 100644
--- a/include/llvm/ExecutionEngine/Interpreter.h
+++ b/include/llvm/ExecutionEngine/Interpreter.h
@@ -18,9 +18,7 @@
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include <cstdlib>
-namespace llvm {
- extern void LinkInInterpreter();
-}
+extern "C" void LLVMLinkInInterpreter();
namespace {
struct ForceInterpreterLinking {
@@ -32,7 +30,7 @@ namespace {
if (std::getenv("bar") != (char*) -1)
return;
- llvm::LinkInInterpreter();
+ LLVMLinkInInterpreter();
}
} ForceInterpreterLinking;
}
diff --git a/include/llvm/ExecutionEngine/JIT.h b/include/llvm/ExecutionEngine/JIT.h
index d4d1e73..6013db4 100644
--- a/include/llvm/ExecutionEngine/JIT.h
+++ b/include/llvm/ExecutionEngine/JIT.h
@@ -18,9 +18,7 @@
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include <cstdlib>
-namespace llvm {
- extern void LinkInJIT();
-}
+extern "C" void LLVMLinkInJIT();
namespace {
struct ForceJITLinking {
@@ -32,7 +30,7 @@ namespace {
if (std::getenv("bar") != (char*) -1)
return;
- llvm::LinkInJIT();
+ LLVMLinkInJIT();
}
} ForceJITLinking;
}
diff --git a/include/llvm/ExecutionEngine/JITEventListener.h b/include/llvm/ExecutionEngine/JITEventListener.h
new file mode 100644
index 0000000..dd76f26
--- /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
OpenPOWER on IntegriCloud