LLVM API Documentation
00001 //===- X86JITInfo.h - X86 implementation of the JIT interface --*- 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 contains the X86 implementation of the TargetJITInfo class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef X86JITINFO_H 00015 #define X86JITINFO_H 00016 00017 #include "llvm/Function.h" 00018 #include "llvm/CodeGen/JITCodeEmitter.h" 00019 #include "llvm/Target/TargetJITInfo.h" 00020 00021 namespace llvm { 00022 class X86TargetMachine; 00023 00024 class X86JITInfo : public TargetJITInfo { 00025 X86TargetMachine &TM; 00026 uintptr_t PICBase; 00027 char* TLSOffset; 00028 public: 00029 explicit X86JITInfo(X86TargetMachine &tm) : TM(tm) { 00030 useGOT = 0; 00031 TLSOffset = 0; 00032 } 00033 00034 /// replaceMachineCodeForFunction - Make it so that calling the function 00035 /// whose machine code is at OLD turns into a call to NEW, perhaps by 00036 /// overwriting OLD with a branch to NEW. This is used for self-modifying 00037 /// code. 00038 /// 00039 virtual void replaceMachineCodeForFunction(void *Old, void *New); 00040 00041 /// emitGlobalValueIndirectSym - Use the specified JITCodeEmitter object 00042 /// to emit an indirect symbol which contains the address of the specified 00043 /// ptr. 00044 virtual void *emitGlobalValueIndirectSym(const GlobalValue* GV, void *ptr, 00045 JITCodeEmitter &JCE); 00046 00047 /// emitFunctionStub - Use the specified JITCodeEmitter object to emit a 00048 /// small native function that simply calls the function at the specified 00049 /// address. 00050 virtual void *emitFunctionStub(const Function* F, void *Fn, 00051 JITCodeEmitter &JCE); 00052 00053 /// emitFunctionStubAtAddr - Use the specified JITCodeEmitter object to 00054 /// emit a small native function that simply calls Fn. Emit the stub into 00055 /// the supplied buffer. 00056 virtual void emitFunctionStubAtAddr(const Function* F, void *Fn, 00057 void *Buffer, JITCodeEmitter &JCE); 00058 00059 /// getPICJumpTableEntry - Returns the value of the jumptable entry for the 00060 /// specific basic block. 00061 virtual uintptr_t getPICJumpTableEntry(uintptr_t BB, uintptr_t JTBase); 00062 00063 /// getLazyResolverFunction - Expose the lazy resolver to the JIT. 00064 virtual LazyResolverFn getLazyResolverFunction(JITCompilerFn); 00065 00066 /// relocate - Before the JIT can run a block of code that has been emitted, 00067 /// it must rewrite the code to contain the actual addresses of any 00068 /// referenced global symbols. 00069 virtual void relocate(void *Function, MachineRelocation *MR, 00070 unsigned NumRelocs, unsigned char* GOTBase); 00071 00072 /// allocateThreadLocalMemory - Each target has its own way of 00073 /// handling thread local variables. This method returns a value only 00074 /// meaningful to the target. 00075 virtual char* allocateThreadLocalMemory(size_t size); 00076 00077 /// setPICBase / getPICBase - Getter / setter of PICBase, used to compute 00078 /// PIC jumptable entry. 00079 void setPICBase(uintptr_t Base) { PICBase = Base; } 00080 uintptr_t getPICBase() const { return PICBase; } 00081 }; 00082 } 00083 00084 #endif