JITEventListener.h revision 218893
1195098Sed//===- JITEventListener.h - Exposes events from JIT compilation -*- C++ -*-===// 2195098Sed// 3195098Sed// The LLVM Compiler Infrastructure 4195098Sed// 5195098Sed// This file is distributed under the University of Illinois Open Source 6195098Sed// License. See LICENSE.TXT for details. 7195098Sed// 8195098Sed//===----------------------------------------------------------------------===// 9195098Sed// 10195098Sed// This file defines the JITEventListener interface, which lets users get 11195098Sed// callbacks when significant events happen during the JIT compilation process. 12195098Sed// 13195098Sed//===----------------------------------------------------------------------===// 14195098Sed 15195098Sed#ifndef LLVM_EXECUTION_ENGINE_JIT_EVENTLISTENER_H 16195098Sed#define LLVM_EXECUTION_ENGINE_JIT_EVENTLISTENER_H 17195098Sed 18218893Sdim#include "llvm/Support/DataTypes.h" 19198090Srdivacky#include "llvm/Support/DebugLoc.h" 20195098Sed 21198090Srdivacky#include <vector> 22198090Srdivacky 23195098Sednamespace llvm { 24195098Sedclass Function; 25198090Srdivackyclass MachineFunction; 26195098Sed 27218893Sdim/// JITEvent_EmittedFunctionDetails - Helper struct for containing information 28218893Sdim/// about a generated machine code function. 29195098Sedstruct JITEvent_EmittedFunctionDetails { 30198090Srdivacky struct LineStart { 31218893Sdim /// The address at which the current line changes. 32198090Srdivacky uintptr_t Address; 33218893Sdim 34218893Sdim /// The new location information. These can be translated to DebugLocTuples 35218893Sdim /// using MF->getDebugLocTuple(). 36198090Srdivacky DebugLoc Loc; 37198090Srdivacky }; 38218893Sdim 39218893Sdim /// The machine function the struct contains information for. 40218893Sdim const MachineFunction *MF; 41218893Sdim 42218893Sdim /// The list of line boundary information, sorted by address. 43198090Srdivacky std::vector<LineStart> LineStarts; 44195098Sed}; 45195098Sed 46218893Sdim/// JITEventListener - Abstract interface for use by the JIT to notify clients 47218893Sdim/// about significant events during compilation. For example, to notify 48218893Sdim/// profilers and debuggers that need to know where functions have been emitted. 49195098Sed/// 50218893Sdim/// The default implementation of each method does nothing. 51195098Sedclass JITEventListener { 52195098Sedpublic: 53218893Sdim typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails; 54218893Sdim 55218893Sdimpublic: 56195098Sed JITEventListener() {} 57218893Sdim virtual ~JITEventListener(); 58195098Sed 59195098Sed /// NotifyFunctionEmitted - Called after a function has been successfully 60195098Sed /// emitted to memory. The function still has its MachineFunction attached, 61195098Sed /// if you should happen to need that. 62195098Sed virtual void NotifyFunctionEmitted(const Function &F, 63195098Sed void *Code, size_t Size, 64195098Sed const EmittedFunctionDetails &Details) {} 65195098Sed 66218893Sdim /// NotifyFreeingMachineCode - Called from freeMachineCodeForFunction(), after 67218893Sdim /// the global mapping is removed, but before the machine code is returned to 68218893Sdim /// the allocator. 69218893Sdim /// 70218893Sdim /// OldPtr is the address of the machine code and will be the same as the Code 71218893Sdim /// parameter to a previous NotifyFunctionEmitted call. The Function passed 72218893Sdim /// to NotifyFunctionEmitted may have been destroyed by the time of the 73218893Sdim /// matching NotifyFreeingMachineCode call. 74198892Srdivacky virtual void NotifyFreeingMachineCode(void *OldPtr) {} 75195098Sed}; 76195098Sed 77198396Srdivacky// This returns NULL if support isn't available. 78198090SrdivackyJITEventListener *createOProfileJITEventListener(); 79195098Sed 80195098Sed} // end namespace llvm. 81195098Sed 82195098Sed#endif 83