blob: 564343ffa3fa3e4b9f69e3bfbb9fb778d2adcee0 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- X86JITInfo.h - X86 implementation of the JIT interface --*- C++ -*-===//
Misha Brukmanc88330a2005-04-21 23:38:14 +00002//
Chris Lattner833c3c22003-12-20 01:22:19 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmanc88330a2005-04-21 23:38:14 +00007//
Chris Lattner833c3c22003-12-20 01:22:19 +00008//===----------------------------------------------------------------------===//
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 Lopesa194c3a2009-05-30 20:51:52 +000017#include "llvm/CodeGen/JITCodeEmitter.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000018#include "llvm/IR/Function.h"
Chris Lattner833c3c22003-12-20 01:22:19 +000019#include "llvm/Target/TargetJITInfo.h"
20
21namespace llvm {
Evan Cheng47455a72009-09-03 04:37:05 +000022 class X86Subtarget;
Chris Lattnerc45a0332003-12-28 09:47:19 +000023
Chris Lattner833c3c22003-12-20 01:22:19 +000024 class X86JITInfo : public TargetJITInfo {
Evan Cheng0b773192008-12-10 02:32:19 +000025 uintptr_t PICBase;
Eric Christophera08f30b2014-06-09 17:08:19 +000026 char *TLSOffset;
Eric Christopher28783da2014-06-06 23:26:48 +000027 bool useSSE;
Chris Lattner833c3c22003-12-20 01:22:19 +000028 public:
Eric Christopher28783da2014-06-06 23:26:48 +000029 explicit X86JITInfo(bool UseSSE);
Chris Lattner833c3c22003-12-20 01:22:19 +000030
Chris Lattner833c3c22003-12-20 01:22:19 +000031 /// 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 Topper2d9361e2014-03-09 07:44:38 +000036 void replaceMachineCodeForFunction(void *Old, void *New) override;
Misha Brukmanc88330a2005-04-21 23:38:14 +000037
Bruno Cardoso Lopesa194c3a2009-05-30 20:51:52 +000038 /// emitGlobalValueIndirectSym - Use the specified JITCodeEmitter object
Evan Cheng9f3058f2008-11-10 01:08:07 +000039 /// to emit an indirect symbol which contains the address of the specified
40 /// ptr.
Craig Topper2d9361e2014-03-09 07:44:38 +000041 void *emitGlobalValueIndirectSym(const GlobalValue* GV, void *ptr,
42 JITCodeEmitter &JCE) override;
Evan Cheng49ff8ec2008-01-04 10:46:51 +000043
Jeffrey Yasskinf2ad5712009-11-23 23:35:19 +000044 // getStubLayout - Returns the size and alignment of the largest call stub
45 // on X86.
Craig Topper2d9361e2014-03-09 07:44:38 +000046 StubLayout getStubLayout() override;
Jeffrey Yasskinf2ad5712009-11-23 23:35:19 +000047
Bruno Cardoso Lopesa194c3a2009-05-30 20:51:52 +000048 /// emitFunctionStub - Use the specified JITCodeEmitter object to emit a
Chris Lattner8c645ec2004-11-20 23:53:56 +000049 /// small native function that simply calls the function at the specified
50 /// address.
Craig Topper2d9361e2014-03-09 07:44:38 +000051 void *emitFunctionStub(const Function* F, void *Target,
52 JITCodeEmitter &JCE) override;
Chris Lattner8c645ec2004-11-20 23:53:56 +000053
Evan Cheng880b0802008-01-05 02:26:58 +000054 /// getPICJumpTableEntry - Returns the value of the jumptable entry for the
55 /// specific basic block.
Craig Topper2d9361e2014-03-09 07:44:38 +000056 uintptr_t getPICJumpTableEntry(uintptr_t BB, uintptr_t JTBase) override;
Evan Cheng880b0802008-01-05 02:26:58 +000057
Chris Lattner8c645ec2004-11-20 23:53:56 +000058 /// getLazyResolverFunction - Expose the lazy resolver to the JIT.
Craig Topper2d9361e2014-03-09 07:44:38 +000059 LazyResolverFn getLazyResolverFunction(JITCompilerFn) override;
Chris Lattner8c645ec2004-11-20 23:53:56 +000060
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 Topper2d9361e2014-03-09 07:44:38 +000064 void relocate(void *Function, MachineRelocation *MR,
65 unsigned NumRelocs, unsigned char* GOTBase) override;
Chad Rosier24c19d22012-08-01 18:39:17 +000066
Nicolas Geoffray5457ce92008-10-25 15:41:43 +000067 /// 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 Topper2d9361e2014-03-09 07:44:38 +000070 char* allocateThreadLocalMemory(size_t size) override;
Evan Cheng880b0802008-01-05 02:26:58 +000071
72 /// setPICBase / getPICBase - Getter / setter of PICBase, used to compute
73 /// PIC jumptable entry.
Evan Cheng0b773192008-12-10 02:32:19 +000074 void setPICBase(uintptr_t Base) { PICBase = Base; }
75 uintptr_t getPICBase() const { return PICBase; }
Chris Lattner833c3c22003-12-20 01:22:19 +000076 };
77}
78
79#endif