| Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- X86JITInfo.h - X86 implementation of the JIT interface --*- C++ -*-===// |
| Misha Brukman | c88330a | 2005-04-21 23:38:14 +0000 | [diff] [blame] | 2 | // |
| Chris Lattner | 833c3c2 | 2003-12-20 01:22:19 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| Misha Brukman | c88330a | 2005-04-21 23:38:14 +0000 | [diff] [blame] | 7 | // |
| Chris Lattner | 833c3c2 | 2003-12-20 01:22:19 +0000 | [diff] [blame] | 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 | |
| Bruno Cardoso Lopes | a194c3a | 2009-05-30 20:51:52 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/JITCodeEmitter.h" |
| Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 18 | #include "llvm/IR/Function.h" |
| Chris Lattner | 833c3c2 | 2003-12-20 01:22:19 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetJITInfo.h" |
| 20 | |
| 21 | namespace llvm { |
| Evan Cheng | 47455a7 | 2009-09-03 04:37:05 +0000 | [diff] [blame] | 22 | class X86Subtarget; |
| Chris Lattner | c45a033 | 2003-12-28 09:47:19 +0000 | [diff] [blame] | 23 | |
| Chris Lattner | 833c3c2 | 2003-12-20 01:22:19 +0000 | [diff] [blame] | 24 | class X86JITInfo : public TargetJITInfo { |
| Evan Cheng | 0b77319 | 2008-12-10 02:32:19 +0000 | [diff] [blame] | 25 | uintptr_t PICBase; |
| Eric Christopher | a08f30b | 2014-06-09 17:08:19 +0000 | [diff] [blame] | 26 | char *TLSOffset; |
| Eric Christopher | 28783da | 2014-06-06 23:26:48 +0000 | [diff] [blame] | 27 | bool useSSE; |
| Chris Lattner | 833c3c2 | 2003-12-20 01:22:19 +0000 | [diff] [blame] | 28 | public: |
| Eric Christopher | 28783da | 2014-06-06 23:26:48 +0000 | [diff] [blame] | 29 | explicit X86JITInfo(bool UseSSE); |
| Chris Lattner | 833c3c2 | 2003-12-20 01:22:19 +0000 | [diff] [blame] | 30 | |
| Chris Lattner | 833c3c2 | 2003-12-20 01:22:19 +0000 | [diff] [blame] | 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 | /// |
| Craig Topper | 2d9361e | 2014-03-09 07:44:38 +0000 | [diff] [blame] | 36 | void replaceMachineCodeForFunction(void *Old, void *New) override; |
| Misha Brukman | c88330a | 2005-04-21 23:38:14 +0000 | [diff] [blame] | 37 | |
| Bruno Cardoso Lopes | a194c3a | 2009-05-30 20:51:52 +0000 | [diff] [blame] | 38 | /// emitGlobalValueIndirectSym - Use the specified JITCodeEmitter object |
| Evan Cheng | 9f3058f | 2008-11-10 01:08:07 +0000 | [diff] [blame] | 39 | /// to emit an indirect symbol which contains the address of the specified |
| 40 | /// ptr. |
| Craig Topper | 2d9361e | 2014-03-09 07:44:38 +0000 | [diff] [blame] | 41 | void *emitGlobalValueIndirectSym(const GlobalValue* GV, void *ptr, |
| 42 | JITCodeEmitter &JCE) override; |
| Evan Cheng | 49ff8ec | 2008-01-04 10:46:51 +0000 | [diff] [blame] | 43 | |
| Jeffrey Yasskin | f2ad571 | 2009-11-23 23:35:19 +0000 | [diff] [blame] | 44 | // getStubLayout - Returns the size and alignment of the largest call stub |
| 45 | // on X86. |
| Craig Topper | 2d9361e | 2014-03-09 07:44:38 +0000 | [diff] [blame] | 46 | StubLayout getStubLayout() override; |
| Jeffrey Yasskin | f2ad571 | 2009-11-23 23:35:19 +0000 | [diff] [blame] | 47 | |
| Bruno Cardoso Lopes | a194c3a | 2009-05-30 20:51:52 +0000 | [diff] [blame] | 48 | /// emitFunctionStub - Use the specified JITCodeEmitter object to emit a |
| Chris Lattner | 8c645ec | 2004-11-20 23:53:56 +0000 | [diff] [blame] | 49 | /// small native function that simply calls the function at the specified |
| 50 | /// address. |
| Craig Topper | 2d9361e | 2014-03-09 07:44:38 +0000 | [diff] [blame] | 51 | void *emitFunctionStub(const Function* F, void *Target, |
| 52 | JITCodeEmitter &JCE) override; |
| Chris Lattner | 8c645ec | 2004-11-20 23:53:56 +0000 | [diff] [blame] | 53 | |
| Evan Cheng | 880b080 | 2008-01-05 02:26:58 +0000 | [diff] [blame] | 54 | /// getPICJumpTableEntry - Returns the value of the jumptable entry for the |
| 55 | /// specific basic block. |
| Craig Topper | 2d9361e | 2014-03-09 07:44:38 +0000 | [diff] [blame] | 56 | uintptr_t getPICJumpTableEntry(uintptr_t BB, uintptr_t JTBase) override; |
| Evan Cheng | 880b080 | 2008-01-05 02:26:58 +0000 | [diff] [blame] | 57 | |
| Chris Lattner | 8c645ec | 2004-11-20 23:53:56 +0000 | [diff] [blame] | 58 | /// getLazyResolverFunction - Expose the lazy resolver to the JIT. |
| Craig Topper | 2d9361e | 2014-03-09 07:44:38 +0000 | [diff] [blame] | 59 | LazyResolverFn getLazyResolverFunction(JITCompilerFn) override; |
| Chris Lattner | 8c645ec | 2004-11-20 23:53:56 +0000 | [diff] [blame] | 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. |
| Craig Topper | 2d9361e | 2014-03-09 07:44:38 +0000 | [diff] [blame] | 64 | void relocate(void *Function, MachineRelocation *MR, |
| 65 | unsigned NumRelocs, unsigned char* GOTBase) override; |
| Chad Rosier | 24c19d2 | 2012-08-01 18:39:17 +0000 | [diff] [blame] | 66 | |
| Nicolas Geoffray | 5457ce9 | 2008-10-25 15:41:43 +0000 | [diff] [blame] | 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. |
| Craig Topper | 2d9361e | 2014-03-09 07:44:38 +0000 | [diff] [blame] | 70 | char* allocateThreadLocalMemory(size_t size) override; |
| Evan Cheng | 880b080 | 2008-01-05 02:26:58 +0000 | [diff] [blame] | 71 | |
| 72 | /// setPICBase / getPICBase - Getter / setter of PICBase, used to compute |
| 73 | /// PIC jumptable entry. |
| Evan Cheng | 0b77319 | 2008-12-10 02:32:19 +0000 | [diff] [blame] | 74 | void setPICBase(uintptr_t Base) { PICBase = Base; } |
| 75 | uintptr_t getPICBase() const { return PICBase; } |
| Chris Lattner | 833c3c2 | 2003-12-20 01:22:19 +0000 | [diff] [blame] | 76 | }; |
| 77 | } |
| 78 | |
| 79 | #endif |