llvm.org GIT mirror llvm / e483441
[Kaleidoscope][BuildingAJIT] Fix code-block indents. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270782 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames 3 years ago
1 changed file(s) with 40 addition(s) and 40 deletion(s). Raw diff Collapse all Expand all
7575
7676 .. code-block:: c++
7777
78 std::unique_ptr M = buildModule();
79 JIT J;
80 Handle H = J.addModule(*M);
81 int (*Main)(int, char*[]) =
82 (int(*)(int, char*[])J.findSymbol("main").getAddress();
83 int Result = Main();
84 J.removeModule(H);
78 std::unique_ptr M = buildModule();
79 JIT J;
80 Handle H = J.addModule(*M);
81 int (*Main)(int, char*[]) =
82 (int(*)(int, char*[])J.findSymbol("main").getAddress();
83 int Result = Main();
84 J.removeModule(H);
8585
8686 The APIs that we build in these tutorials will all be variations on this simple
8787 theme. Behind the API we will refine the implementation of the JIT to add
111111
112112 .. code-block:: c++
113113
114 #ifndef LLVM_EXECUTIONENGINE_ORC_KALEIDOSCOPEJIT_H
115 #define LLVM_EXECUTIONENGINE_ORC_KALEIDOSCOPEJIT_H
116
117 #include "llvm/ExecutionEngine/ExecutionEngine.h"
118 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
119 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
120 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
121 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
122 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
123 #include "llvm/IR/Mangler.h"
124 #include "llvm/Support/DynamicLibrary.h"
125
126 namespace llvm {
127 namespace orc {
128
129 class KaleidoscopeJIT {
130 private:
131
132 std::unique_ptr TM;
133 const DataLayout DL;
134 ObjectLinkingLayer<> ObjectLayer;
135 IRCompileLayer CompileLayer;
136
137 public:
138
139 typedef decltype(CompileLayer)::ModuleSetHandleT ModuleHandleT;
114 #ifndef LLVM_EXECUTIONENGINE_ORC_KALEIDOSCOPEJIT_H
115 #define LLVM_EXECUTIONENGINE_ORC_KALEIDOSCOPEJIT_H
116
117 #include "llvm/ExecutionEngine/ExecutionEngine.h"
118 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
119 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
120 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
121 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
122 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
123 #include "llvm/IR/Mangler.h"
124 #include "llvm/Support/DynamicLibrary.h"
125
126 namespace llvm {
127 namespace orc {
128
129 class KaleidoscopeJIT {
130 private:
131
132 std::unique_ptr TM;
133 const DataLayout DL;
134 ObjectLinkingLayer<> ObjectLayer;
135 IRCompileLayer CompileLayer;
136
137 public:
138
139 typedef decltype(CompileLayer)::ModuleSetHandleT ModuleHandleT;
140140
141141 Our class begins with four members: A TargetMachine, TM, which will be used
142142 to build our LLVM compiler instance; A DataLayout, DL, which will be used for
161161
162162 .. code-block:: c++
163163
164 KaleidoscopeJIT()
165 : TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
166 CompileLayer(ObjectLayer, SimpleCompiler(*TM)) {
167 llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
168 }
169
170 TargetMachine &getTargetMachine() { return *TM; }
164 KaleidoscopeJIT()
165 : TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
166 CompileLayer(ObjectLayer, SimpleCompiler(*TM)) {
167 llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
168 }
169
170 TargetMachine &getTargetMachine() { return *TM; }
171171
172172 Next up we have our class constructor. We begin by initializing TM using the
173173 EngineBuilder::selectTarget helper method, which constructs a TargetMachine for