LLVM API Documentation
00001 //===- JITEventListener.h - Exposes events from JIT compilation -*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the JITEventListener interface, which lets users get 00011 // callbacks when significant events happen during the JIT compilation process. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_EXECUTION_ENGINE_JIT_EVENTLISTENER_H 00016 #define LLVM_EXECUTION_ENGINE_JIT_EVENTLISTENER_H 00017 00018 #include "llvm/Support/DataTypes.h" 00019 #include "llvm/Support/DebugLoc.h" 00020 00021 #include <vector> 00022 00023 namespace llvm { 00024 class Function; 00025 class MachineFunction; 00026 00027 /// Empty for now, but this object will contain all details about the 00028 /// generated machine code that a Listener might care about. 00029 struct JITEvent_EmittedFunctionDetails { 00030 const MachineFunction *MF; 00031 00032 struct LineStart { 00033 // The address at which the current line changes. 00034 uintptr_t Address; 00035 // The new location information. These can be translated to 00036 // DebugLocTuples using MF->getDebugLocTuple(). 00037 DebugLoc Loc; 00038 }; 00039 // This holds line boundary information sorted by address. 00040 std::vector<LineStart> LineStarts; 00041 }; 00042 00043 /// JITEventListener - This interface is used by the JIT to notify clients about 00044 /// significant events during compilation. For example, we could have 00045 /// implementations for profilers and debuggers that need to know where 00046 /// functions have been emitted. 00047 /// 00048 /// Each method defaults to doing nothing, so you only need to override the ones 00049 /// you care about. 00050 class JITEventListener { 00051 public: 00052 JITEventListener() {} 00053 virtual ~JITEventListener(); // Defined in JIT.cpp. 00054 00055 typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails; 00056 /// NotifyFunctionEmitted - Called after a function has been successfully 00057 /// emitted to memory. The function still has its MachineFunction attached, 00058 /// if you should happen to need that. 00059 virtual void NotifyFunctionEmitted(const Function &F, 00060 void *Code, size_t Size, 00061 const EmittedFunctionDetails &Details) {} 00062 00063 /// NotifyFreeingMachineCode - This is called inside of 00064 /// freeMachineCodeForFunction(), after the global mapping is removed, but 00065 /// before the machine code is returned to the allocator. OldPtr is the 00066 /// address of the machine code. 00067 virtual void NotifyFreeingMachineCode(const Function &F, void *OldPtr) {} 00068 }; 00069 00070 // These return NULL if support isn't available. 00071 JITEventListener *createMacOSJITEventListener(); 00072 JITEventListener *createOProfileJITEventListener(); 00073 00074 } // end namespace llvm. 00075 00076 #endif