blob: 62b83030106b229ec3e4b49a213181d52aa4cebb [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"
Jim Grosbachbc6d8762008-10-28 18:25:49 +000018#include <map>
Evan Cheng148b6a42007-07-05 21:15:40 +000019
20namespace llvm {
21 class ARMTargetMachine;
22
23 class ARMJITInfo : public TargetJITInfo {
24 ARMTargetMachine &TM;
Jim Grosbachbc6d8762008-10-28 18:25:49 +000025 std::map<unsigned, intptr_t> CPIDtoAddressMap;
Evan Cheng148b6a42007-07-05 21:15:40 +000026 public:
Jim Grosbachbc6d8762008-10-28 18:25:49 +000027 explicit ARMJITInfo(ARMTargetMachine &tm) : TM(tm) { useGOT = false; }
Evan Cheng148b6a42007-07-05 21:15:40 +000028
29 /// replaceMachineCodeForFunction - Make it so that calling the function
30 /// whose machine code is at OLD turns into a call to NEW, perhaps by
31 /// overwriting OLD with a branch to NEW. This is used for self-modifying
32 /// code.
33 ///
34 virtual void replaceMachineCodeForFunction(void *Old, void *New);
35
36 /// emitFunctionStub - Use the specified MachineCodeEmitter object to emit a
37 /// small native function that simply calls the function at the specified
38 /// address.
Nicolas Geoffray51cc3c12008-04-16 20:46:05 +000039 virtual void *emitFunctionStub(const Function* F, void *Fn,
40 MachineCodeEmitter &MCE);
Evan Cheng148b6a42007-07-05 21:15:40 +000041
42 /// getLazyResolverFunction - Expose the lazy resolver to the JIT.
43 virtual LazyResolverFn getLazyResolverFunction(JITCompilerFn);
44
45 /// relocate - Before the JIT can run a block of code that has been emitted,
46 /// it must rewrite the code to contain the actual addresses of any
47 /// referenced global symbols.
48 virtual void relocate(void *Function, MachineRelocation *MR,
49 unsigned NumRelocs, unsigned char* GOTBase);
Jim Grosbachbc6d8762008-10-28 18:25:49 +000050
51 /// hasCustomConstantPool - Allows a target to specify that constant
52 /// pool address resolution is handled by the target.
53 virtual bool hasCustomConstantPool() const { return true; }
54
55 /// getCustomConstantPoolEntryAddress - The ARM target puts all constant
56 /// pool entries into constant islands. Resolve the constant pool index
57 /// into the address where the constant is stored.
58 virtual intptr_t getCustomConstantPoolEntryAddress(unsigned CPID) const
59 {
60 std::map<unsigned, intptr_t>::const_iterator elem;
61 elem = CPIDtoAddressMap.find(CPID);
62 assert (elem != CPIDtoAddressMap.end());
63 return elem->second;
64 }
65
66 /// mapCPIDtoAddress - Map a Constant Pool Index (CPID) to the address
67 /// where its associated value is stored. When relocations are processed,
68 /// this value will be used to resolve references to the constant.
69 void mapCPIDtoAddress(unsigned CPID, intptr_t address)
70 { CPIDtoAddressMap[CPID] = address; }
Evan Cheng148b6a42007-07-05 21:15:40 +000071 };
72}
73
74#endif