blob: 5f0ee8d9f26fdc1724f4de81b5e7625500b174a9 [file] [log] [blame]
Evan Cheng148b6a42007-07-05 21:15:40 +00001//===- ARMJITInfo.h - ARM implementation of the JIT interface --*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Cheng148b6a42007-07-05 21:15:40 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the declaration of the ARMJITInfo class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef ARMJITINFO_H
15#define ARMJITINFO_H
16
17#include "llvm/Target/TargetJITInfo.h"
Evan Cheng938b9d82008-10-31 19:55:13 +000018#include "llvm/ADT/SmallVector.h"
Evan Cheng148b6a42007-07-05 21:15:40 +000019
20namespace llvm {
21 class ARMTargetMachine;
22
23 class ARMJITInfo : public TargetJITInfo {
24 ARMTargetMachine &TM;
Evan Cheng0f282432008-10-29 23:55:43 +000025
26 // ConstPoolId2AddrMap - A map from constant pool ids to the corresponding
27 // CONSTPOOL_ENTRY addresses.
Evan Cheng938b9d82008-10-31 19:55:13 +000028 SmallVector<intptr_t, 32> ConstPoolId2AddrMap;
Evan Cheng0f282432008-10-29 23:55:43 +000029
Evan Cheng148b6a42007-07-05 21:15:40 +000030 public:
Jim Grosbachbc6d8762008-10-28 18:25:49 +000031 explicit ARMJITInfo(ARMTargetMachine &tm) : TM(tm) { useGOT = false; }
Evan Cheng148b6a42007-07-05 21:15:40 +000032
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
36 /// code.
37 ///
38 virtual void replaceMachineCodeForFunction(void *Old, void *New);
39
40 /// emitFunctionStub - Use the specified MachineCodeEmitter object to emit a
41 /// small native function that simply calls the function at the specified
42 /// address.
Nicolas Geoffray51cc3c12008-04-16 20:46:05 +000043 virtual void *emitFunctionStub(const Function* F, void *Fn,
44 MachineCodeEmitter &MCE);
Evan Cheng148b6a42007-07-05 21:15:40 +000045
46 /// getLazyResolverFunction - Expose the lazy resolver to the JIT.
47 virtual LazyResolverFn getLazyResolverFunction(JITCompilerFn);
48
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);
Jim Grosbachbc6d8762008-10-28 18:25:49 +000054
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; }
58
Evan Cheng938b9d82008-10-31 19:55:13 +000059 void ResizeConstPoolMap(unsigned Size) {
60 ConstPoolId2AddrMap.resize(Size);
61 }
62
Evan Cheng0f282432008-10-29 23:55:43 +000063 /// getConstantPoolEntryAddr - The ARM target puts all constant
Jim Grosbachbc6d8762008-10-28 18:25:49 +000064 /// pool entries into constant islands. Resolve the constant pool index
65 /// into the address where the constant is stored.
Evan Cheng938b9d82008-10-31 19:55:13 +000066 intptr_t getConstantPoolEntryAddr(unsigned CPI) const {
67 assert(CPI < ConstPoolId2AddrMap.size());
68 return ConstPoolId2AddrMap[CPI];
Evan Cheng0f282432008-10-29 23:55:43 +000069 }
Jim Grosbachbc6d8762008-10-28 18:25:49 +000070
Evan Cheng938b9d82008-10-31 19:55:13 +000071 /// addConstantPoolEntryAddr - Map a Constant Pool Index (CPI) to the address
Jim Grosbachbc6d8762008-10-28 18:25:49 +000072 /// where its associated value is stored. When relocations are processed,
73 /// this value will be used to resolve references to the constant.
Evan Cheng938b9d82008-10-31 19:55:13 +000074 void addConstantPoolEntryAddr(unsigned CPI, intptr_t Addr) {
75 assert(CPI < ConstPoolId2AddrMap.size());
76 ConstPoolId2AddrMap[CPI] = Addr;
Evan Cheng0f282432008-10-29 23:55:43 +000077 }
Evan Cheng148b6a42007-07-05 21:15:40 +000078 };
79}
80
81#endif