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