blob: e81e7c7d3477084bc3ec6fd53a485af7e9d37683 [file] [log] [blame]
Daniel Dunbar6aec2982010-11-17 16:06:43 +00001//===-- MCJIT.h - Class definition for the MCJIT ----------------*- C++ -*-===//
2//
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#ifndef LLVM_LIB_EXECUTIONENGINE_MCJIT_H
11#define LLVM_LIB_EXECUTIONENGINE_MCJIT_H
12
Jim Grosbach31649e62011-03-18 22:48:41 +000013#include "llvm/PassManager.h"
Daniel Dunbar6aec2982010-11-17 16:06:43 +000014#include "llvm/ExecutionEngine/ExecutionEngine.h"
Jim Grosbach31649e62011-03-18 22:48:41 +000015#include "llvm/ADT/SmallVector.h"
16#include "llvm/Support/raw_ostream.h"
Daniel Dunbar6aec2982010-11-17 16:06:43 +000017
18namespace llvm {
19
Jim Grosbach31649e62011-03-18 22:48:41 +000020// FIXME: This makes all kinds of horrible assumptions for the time being,
21// like only having one module, not needing to worry about multi-threading,
22// blah blah. Purely in get-it-up-and-limping mode for now.
23
Daniel Dunbar6aec2982010-11-17 16:06:43 +000024class MCJIT : public ExecutionEngine {
Jim Grosbach31649e62011-03-18 22:48:41 +000025 MCJIT(Module *M, TargetMachine *tm, TargetJITInfo &tji,
Daniel Dunbar6aec2982010-11-17 16:06:43 +000026 JITMemoryManager *JMM, CodeGenOpt::Level OptLevel,
27 bool AllocateGVsWithCode);
Jim Grosbach31649e62011-03-18 22:48:41 +000028
29 TargetMachine *TM;
30 MCContext *Ctx;
31
32 // FIXME: These may need moved to a separate 'jitstate' member like the
33 // non-MC JIT does for multithreading and such. Just keep them here for now.
34 PassManager PM;
35 Module *M;
36 // FIXME: This really doesn't belong here.
37 SmallVector<char, 4096> Buffer; // Working buffer into which we JIT.
38 raw_svector_ostream OS;
39
Daniel Dunbar6aec2982010-11-17 16:06:43 +000040public:
41 ~MCJIT();
42
43 /// @name ExecutionEngine interface implementation
44 /// @{
45
46 virtual void *getPointerToBasicBlock(BasicBlock *BB);
47
48 virtual void *getPointerToFunction(Function *F);
49
50 virtual void *recompileAndRelinkFunction(Function *F);
51
52 virtual void freeMachineCodeForFunction(Function *F);
53
54 virtual GenericValue runFunction(Function *F,
55 const std::vector<GenericValue> &ArgValues);
56
57 /// @}
58 /// @name (Private) Registration Interfaces
59 /// @{
60
61 static void Register() {
62 MCJITCtor = createJIT;
63 }
64
65 // FIXME: This routine is scheduled for termination. Do not use it.
66 static TargetMachine *selectTarget(Module *M,
67 StringRef MArch,
68 StringRef MCPU,
69 const SmallVectorImpl<std::string>& MAttrs,
70 std::string *Err);
71
72 static ExecutionEngine *createJIT(Module *M,
73 std::string *ErrorStr,
74 JITMemoryManager *JMM,
75 CodeGenOpt::Level OptLevel,
76 bool GVsWithCode,
77 CodeModel::Model CMM,
78 StringRef MArch,
79 StringRef MCPU,
80 const SmallVectorImpl<std::string>& MAttrs);
81
82 // @}
83};
84
85} // End llvm namespace
86
87#endif