1 //===- Target/TargetJITInfo.h - Target Information for JIT ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file exposes an abstract interface used by the Just-In-Time code
11 // generator to perform target-specific activities, such as emitting stubs. If
12 // a TargetMachine supports JIT code generation, it should provide one of these
13 // objects through the getJITInfo() method.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_TARGET_TARGETJITINFO_H
18 #define LLVM_TARGET_TARGETJITINFO_H
24 class FunctionPassManager;
25 class MachineCodeEmitter;
26 class MachineRelocation;
28 /// TargetJITInfo - Target specific information required by the Just-In-Time
32 virtual ~TargetJITInfo() {}
34 /// addPassesToJITCompile - Add passes to the specified pass manager to
35 /// implement a fast code generator for this target.
37 virtual void addPassesToJITCompile(FunctionPassManager &PM) = 0;
39 /// replaceMachineCodeForFunction - Make it so that calling the function
40 /// whose machine code is at OLD turns into a call to NEW, perhaps by
41 /// overwriting OLD with a branch to NEW. This is used for self-modifying
44 virtual void replaceMachineCodeForFunction (void *Old, void *New) = 0;
46 /// getJITStubForFunction - Create or return a stub for the specified
47 /// function. This stub acts just like the specified function, except that
48 /// it allows the "address" of the function to be taken without having to
49 /// generate code for it. Targets do not need to implement this method, but
50 /// doing so will allow for faster startup of the JIT.
52 virtual void *getJITStubForFunction(Function *F, MachineCodeEmitter &MCE) {
56 /// relocate - Before the JIT can run a block of code that has been emitted,
57 /// it must rewrite the code to contain the actual addresses of any
58 /// referenced global symbols.
59 virtual void relocate(void *Function, MachineRelocation *MR,
61 assert(NumRelocs == 0 && "This target does not have relocations!");
64 } // End llvm namespace