1 //===- ARMJITInfo.h - ARM 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 declaration of the ARMJITInfo class.
12 //===----------------------------------------------------------------------===//
17 #include "llvm/Target/TargetJITInfo.h"
18 #include "llvm/ADT/SmallVector.h"
21 class ARMTargetMachine;
23 class ARMJITInfo : public TargetJITInfo {
26 // ConstPoolId2AddrMap - A map from constant pool ids to the corresponding
27 // CONSTPOOL_ENTRY addresses.
28 SmallVector<intptr_t, 32> ConstPoolId2AddrMap;
31 explicit ARMJITInfo(ARMTargetMachine &tm) : TM(tm) { useGOT = false; }
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 virtual void replaceMachineCodeForFunction(void *Old, void *New);
40 /// emitFunctionStub - Use the specified MachineCodeEmitter object to emit a
41 /// small native function that simply calls the function at the specified
43 virtual void *emitFunctionStub(const Function* F, void *Fn,
44 MachineCodeEmitter &MCE);
46 /// getLazyResolverFunction - Expose the lazy resolver to the JIT.
47 virtual LazyResolverFn getLazyResolverFunction(JITCompilerFn);
49 /// relocate - Before the JIT can run a block of code that has been emitted,
50 /// it must rewrite the code to contain the actual addresses of any
51 /// referenced global symbols.
52 virtual void relocate(void *Function, MachineRelocation *MR,
53 unsigned NumRelocs, unsigned char* GOTBase);
55 /// hasCustomConstantPool - Allows a target to specify that constant
56 /// pool address resolution is handled by the target.
57 virtual bool hasCustomConstantPool() const { return true; }
59 /// ResizeConstPoolMap - Resize constant pool ids to CONSTPOOL_ENTRY
61 void ResizeConstPoolMap(unsigned Size) {
62 ConstPoolId2AddrMap.resize(Size);
65 /// getConstantPoolEntryAddr - The ARM target puts all constant
66 /// pool entries into constant islands. Resolve the constant pool index
67 /// into the address where the constant is stored.
68 intptr_t getConstantPoolEntryAddr(unsigned CPI) const {
69 assert(CPI < ConstPoolId2AddrMap.size());
70 return ConstPoolId2AddrMap[CPI];
73 /// addConstantPoolEntryAddr - Map a Constant Pool Index (CPI) to the address
74 /// where its associated value is stored. When relocations are processed,
75 /// this value will be used to resolve references to the constant.
76 void addConstantPoolEntryAddr(unsigned CPI, intptr_t Addr) {
77 assert(CPI < ConstPoolId2AddrMap.size());
78 ConstPoolId2AddrMap[CPI] = Addr;