blob: ecda3101a0031b668731414b7e258b0a541b45cc [file] [log] [blame]
Jia Liu8f5e8c12012-02-17 01:23:50 +00001//===- MipsJITInfo.h - Mips Implementation of the JIT Interface -*- C++ -*-===//
Bruno Cardoso Lopesdca6cdd2011-07-21 16:28:51 +00002//
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 declaration of the MipsJITInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef MIPSJITINFO_H
15#define MIPSJITINFO_H
16
17#include "MipsMachineFunction.h"
18#include "llvm/CodeGen/MachineConstantPool.h"
19#include "llvm/CodeGen/MachineFunction.h"
20#include "llvm/CodeGen/MachineJumpTableInfo.h"
21#include "llvm/Target/TargetJITInfo.h"
Bruno Cardoso Lopesdca6cdd2011-07-21 16:28:51 +000022
23namespace llvm {
24class MipsTargetMachine;
25
26class MipsJITInfo : public TargetJITInfo {
27
28 bool IsPIC;
Akira Hatanakaff0b2cf2012-12-03 23:11:12 +000029 bool IsLittleEndian;
Bruno Cardoso Lopesdca6cdd2011-07-21 16:28:51 +000030
31 public:
32 explicit MipsJITInfo() :
Akira Hatanakaff0b2cf2012-12-03 23:11:12 +000033 IsPIC(false), IsLittleEndian(true) {}
Bruno Cardoso Lopesdca6cdd2011-07-21 16:28:51 +000034
35 /// replaceMachineCodeForFunction - Make it so that calling the function
36 /// whose machine code is at OLD turns into a call to NEW, perhaps by
37 /// overwriting OLD with a branch to NEW. This is used for self-modifying
38 /// code.
39 ///
40 virtual void replaceMachineCodeForFunction(void *Old, void *New);
41
42 // getStubLayout - Returns the size and alignment of the largest call stub
43 // on Mips.
44 virtual StubLayout getStubLayout();
45
46 /// emitFunctionStub - Use the specified JITCodeEmitter object to emit a
47 /// small native function that simply calls the function at the specified
48 /// address.
Akira Hatanaka864f6602012-06-14 21:10:56 +000049 virtual void *emitFunctionStub(const Function *F, void *Fn,
50 JITCodeEmitter &JCE);
Bruno Cardoso Lopesdca6cdd2011-07-21 16:28:51 +000051
52 /// getLazyResolverFunction - Expose the lazy resolver to the JIT.
53 virtual LazyResolverFn getLazyResolverFunction(JITCompilerFn);
54
55 /// relocate - Before the JIT can run a block of code that has been emitted,
56 /// it must rewrite the code to contain the actual addresses of any
57 /// referenced global symbols.
58 virtual void relocate(void *Function, MachineRelocation *MR,
Akira Hatanaka864f6602012-06-14 21:10:56 +000059 unsigned NumRelocs, unsigned char *GOTBase);
Bruno Cardoso Lopesdca6cdd2011-07-21 16:28:51 +000060
61 /// Initialize - Initialize internal stage for the function being JITted.
Akira Hatanakaff0b2cf2012-12-03 23:11:12 +000062 void Initialize(const MachineFunction &MF, bool isPIC,
63 bool isLittleEndian) {
Bruno Cardoso Lopesdca6cdd2011-07-21 16:28:51 +000064 IsPIC = isPIC;
Akira Hatanakaff0b2cf2012-12-03 23:11:12 +000065 IsLittleEndian = isLittleEndian;
Bruno Cardoso Lopesdca6cdd2011-07-21 16:28:51 +000066 }
67
68};
69}
70
71#endif