1 //===-- X86JITInfo.h - X86 implementation of the JIT interface --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the X86 implementation of the TargetJITInfo class.
12 //===----------------------------------------------------------------------===//
17 #include "llvm/CodeGen/JITCodeEmitter.h"
18 #include "llvm/IR/Function.h"
19 #include "llvm/Target/TargetJITInfo.h"
22 class X86TargetMachine;
25 class X86JITInfo : public TargetJITInfo {
27 const X86Subtarget *Subtarget;
31 explicit X86JITInfo(X86TargetMachine &tm);
33 /// replaceMachineCodeForFunction - Make it so that calling the function
34 /// whose machine code is at OLD turns into a call to NEW, perhaps by
35 /// overwriting OLD with a branch to NEW. This is used for self-modifying
38 void replaceMachineCodeForFunction(void *Old, void *New) override;
40 /// emitGlobalValueIndirectSym - Use the specified JITCodeEmitter object
41 /// to emit an indirect symbol which contains the address of the specified
43 void *emitGlobalValueIndirectSym(const GlobalValue* GV, void *ptr,
44 JITCodeEmitter &JCE) override;
46 // getStubLayout - Returns the size and alignment of the largest call stub
48 StubLayout getStubLayout() override;
50 /// emitFunctionStub - Use the specified JITCodeEmitter object to emit a
51 /// small native function that simply calls the function at the specified
53 void *emitFunctionStub(const Function* F, void *Target,
54 JITCodeEmitter &JCE) override;
56 /// getPICJumpTableEntry - Returns the value of the jumptable entry for the
57 /// specific basic block.
58 uintptr_t getPICJumpTableEntry(uintptr_t BB, uintptr_t JTBase) override;
60 /// getLazyResolverFunction - Expose the lazy resolver to the JIT.
61 LazyResolverFn getLazyResolverFunction(JITCompilerFn) override;
63 /// relocate - Before the JIT can run a block of code that has been emitted,
64 /// it must rewrite the code to contain the actual addresses of any
65 /// referenced global symbols.
66 void relocate(void *Function, MachineRelocation *MR,
67 unsigned NumRelocs, unsigned char* GOTBase) override;
69 /// allocateThreadLocalMemory - Each target has its own way of
70 /// handling thread local variables. This method returns a value only
71 /// meaningful to the target.
72 char* allocateThreadLocalMemory(size_t size) override;
74 /// setPICBase / getPICBase - Getter / setter of PICBase, used to compute
75 /// PIC jumptable entry.
76 void setPICBase(uintptr_t Base) { PICBase = Base; }
77 uintptr_t getPICBase() const { return PICBase; }