llvm.org GIT mirror llvm / 38ccacb
[Examples] Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes. Differential revision: https://reviews.llvm.org/D26433 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287384 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 4 years ago
18 changed file(s) with 216 addition(s) and 56 deletion(s). Raw diff Collapse all Expand all
9292 void removeModule(ModuleHandle H) {
9393 CompileLayer.removeModuleSet(H);
9494 }
95
9695 };
9796
9897 } // end namespace orc
66 #include "llvm/IR/Instructions.h"
77 #include "llvm/IR/IRBuilder.h"
88 #include "llvm/IR/LLVMContext.h"
9 #include "llvm/IR/LegacyPassManager.h"
109 #include "llvm/IR/Module.h"
1110 #include "llvm/IR/Type.h"
1211 #include "llvm/IR/Verifier.h"
1312 #include "llvm/Support/TargetSelect.h"
1413 #include "llvm/Target/TargetMachine.h"
15 #include "llvm/Transforms/Scalar.h"
16 #include "llvm/Transforms/Scalar/GVN.h"
1714 #include "KaleidoscopeJIT.h"
15 #include
1816 #include
1917 #include
2018 #include
134132 //===----------------------------------------------------------------------===//
135133 // Abstract Syntax Tree (aka Parse Tree)
136134 //===----------------------------------------------------------------------===//
135
137136 namespace {
137
138138 /// ExprAST - Base class for all expression nodes.
139139 class ExprAST {
140140 public:
141 virtual ~ExprAST() {}
141 virtual ~ExprAST() = default;
142
142143 virtual Value *codegen() = 0;
143144 };
144145
148149
149150 public:
150151 NumberExprAST(double Val) : Val(Val) {}
152
151153 Value *codegen() override;
152154 };
153155
157159
158160 public:
159161 VariableExprAST(const std::string &Name) : Name(Name) {}
162
163 Value *codegen() override;
160164 const std::string &getName() const { return Name; }
161 Value *codegen() override;
162165 };
163166
164167 /// UnaryExprAST - Expression class for a unary operator.
169172 public:
170173 UnaryExprAST(char Opcode, std::unique_ptr Operand)
171174 : Opcode(Opcode), Operand(std::move(Operand)) {}
175
172176 Value *codegen() override;
173177 };
174178
181185 BinaryExprAST(char Op, std::unique_ptr LHS,
182186 std::unique_ptr RHS)
183187 : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
188
184189 Value *codegen() override;
185190 };
186191
193198 CallExprAST(const std::string &Callee,
194199 std::vector> Args)
195200 : Callee(Callee), Args(std::move(Args)) {}
201
196202 Value *codegen() override;
197203 };
198204
204210 IfExprAST(std::unique_ptr Cond, std::unique_ptr Then,
205211 std::unique_ptr Else)
206212 : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
213
207214 Value *codegen() override;
208215 };
209216
218225 std::unique_ptr Body)
219226 : VarName(VarName), Start(std::move(Start)), End(std::move(End)),
220227 Step(std::move(Step)), Body(std::move(Body)) {}
228
221229 Value *codegen() override;
222230 };
223231
231239 std::vector>> VarNames,
232240 std::unique_ptr Body)
233241 : VarNames(std::move(VarNames)), Body(std::move(Body)) {}
242
234243 Value *codegen() override;
235244 };
236245
248257 bool IsOperator = false, unsigned Prec = 0)
249258 : Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
250259 Precedence(Prec) {}
260
251261 Function *codegen();
252262 const std::string &getName() const { return Name; }
253263
271281 FunctionAST(std::unique_ptr Proto,
272282 std::unique_ptr Body)
273283 : Proto(std::move(Proto)), Body(std::move(Body)) {}
284
274285 Function *codegen();
275286 };
287
276288 } // end anonymous namespace
277289
278290 //===----------------------------------------------------------------------===//
2424 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
2525 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
2626 #include "llvm/IR/DataLayout.h"
27 #include "llvm/IR/LegacyPassManager.h"
2728 #include "llvm/IR/Mangler.h"
2829 #include "llvm/Support/DynamicLibrary.h"
30 #include "llvm/Target/TargetMachine.h"
2931 #include "llvm/Support/raw_ostream.h"
30 #include "llvm/Target/TargetMachine.h"
32 #include "llvm/Transforms/Scalar.h"
33 #include "llvm/Transforms/Scalar/GVN.h"
3134 #include
3235 #include
3336 #include
104107 }
105108
106109 private:
107
108110 std::unique_ptr optimizeModule(std::unique_ptr M) {
109111 // Create a function pass manager.
110112 auto FPM = llvm::make_unique(M.get());
123125
124126 return M;
125127 }
126
127128 };
128129
129130 } // end namespace orc
66 #include "llvm/IR/Instructions.h"
77 #include "llvm/IR/IRBuilder.h"
88 #include "llvm/IR/LLVMContext.h"
9 #include "llvm/IR/LegacyPassManager.h"
109 #include "llvm/IR/Module.h"
1110 #include "llvm/IR/Type.h"
1211 #include "llvm/IR/Verifier.h"
1312 #include "llvm/Support/TargetSelect.h"
1413 #include "llvm/Target/TargetMachine.h"
15 #include "llvm/Transforms/Scalar.h"
16 #include "llvm/Transforms/Scalar/GVN.h"
1714 #include "KaleidoscopeJIT.h"
15 #include
1816 #include
1917 #include
2018 #include
134132 //===----------------------------------------------------------------------===//
135133 // Abstract Syntax Tree (aka Parse Tree)
136134 //===----------------------------------------------------------------------===//
135
137136 namespace {
137
138138 /// ExprAST - Base class for all expression nodes.
139139 class ExprAST {
140140 public:
141 virtual ~ExprAST() {}
141 virtual ~ExprAST() = default;
142
142143 virtual Value *codegen() = 0;
143144 };
144145
148149
149150 public:
150151 NumberExprAST(double Val) : Val(Val) {}
152
151153 Value *codegen() override;
152154 };
153155
157159
158160 public:
159161 VariableExprAST(const std::string &Name) : Name(Name) {}
162
163 Value *codegen() override;
160164 const std::string &getName() const { return Name; }
161 Value *codegen() override;
162165 };
163166
164167 /// UnaryExprAST - Expression class for a unary operator.
169172 public:
170173 UnaryExprAST(char Opcode, std::unique_ptr Operand)
171174 : Opcode(Opcode), Operand(std::move(Operand)) {}
175
172176 Value *codegen() override;
173177 };
174178
181185 BinaryExprAST(char Op, std::unique_ptr LHS,
182186 std::unique_ptr RHS)
183187 : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
188
184189 Value *codegen() override;
185190 };
186191
193198 CallExprAST(const std::string &Callee,
194199 std::vector> Args)
195200 : Callee(Callee), Args(std::move(Args)) {}
201
196202 Value *codegen() override;
197203 };
198204
204210 IfExprAST(std::unique_ptr Cond, std::unique_ptr Then,
205211 std::unique_ptr Else)
206212 : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
213
207214 Value *codegen() override;
208215 };
209216
218225 std::unique_ptr Body)
219226 : VarName(VarName), Start(std::move(Start)), End(std::move(End)),
220227 Step(std::move(Step)), Body(std::move(Body)) {}
228
221229 Value *codegen() override;
222230 };
223231
231239 std::vector>> VarNames,
232240 std::unique_ptr Body)
233241 : VarNames(std::move(VarNames)), Body(std::move(Body)) {}
242
234243 Value *codegen() override;
235244 };
236245
248257 bool IsOperator = false, unsigned Prec = 0)
249258 : Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
250259 Precedence(Prec) {}
260
251261 Function *codegen();
252262 const std::string &getName() const { return Name; }
253263
271281 FunctionAST(std::unique_ptr Proto,
272282 std::unique_ptr Body)
273283 : Proto(std::move(Proto)), Body(std::move(Body)) {}
284
274285 Function *codegen();
275286 };
287
276288 } // end anonymous namespace
277289
278290 //===----------------------------------------------------------------------===//
2525 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
2626 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
2727 #include "llvm/IR/DataLayout.h"
28 #include "llvm/IR/LegacyPassManager.h"
2829 #include "llvm/IR/Mangler.h"
2930 #include "llvm/Support/DynamicLibrary.h"
3031 #include "llvm/Support/raw_ostream.h"
3132 #include "llvm/Target/TargetMachine.h"
33 #include "llvm/Transforms/Scalar.h"
34 #include "llvm/Transforms/Scalar/GVN.h"
3235 #include
3336 #include
37 #include
3438 #include
3539 #include
3640
115119 }
116120
117121 private:
118
119122 std::unique_ptr optimizeModule(std::unique_ptr M) {
120123 // Create a function pass manager.
121124 auto FPM = llvm::make_unique(M.get());
134137
135138 return M;
136139 }
137
138140 };
139141
140142 } // end namespace orc
66 #include "llvm/IR/Instructions.h"
77 #include "llvm/IR/IRBuilder.h"
88 #include "llvm/IR/LLVMContext.h"
9 #include "llvm/IR/LegacyPassManager.h"
109 #include "llvm/IR/Module.h"
1110 #include "llvm/IR/Type.h"
1211 #include "llvm/IR/Verifier.h"
1312 #include "llvm/Support/TargetSelect.h"
1413 #include "llvm/Target/TargetMachine.h"
15 #include "llvm/Transforms/Scalar.h"
16 #include "llvm/Transforms/Scalar/GVN.h"
1714 #include "KaleidoscopeJIT.h"
15 #include
1816 #include
1917 #include
2018 #include
134132 //===----------------------------------------------------------------------===//
135133 // Abstract Syntax Tree (aka Parse Tree)
136134 //===----------------------------------------------------------------------===//
135
137136 namespace {
137
138138 /// ExprAST - Base class for all expression nodes.
139139 class ExprAST {
140140 public:
141 virtual ~ExprAST() {}
141 virtual ~ExprAST() = default;
142
142143 virtual Value *codegen() = 0;
143144 };
144145
148149
149150 public:
150151 NumberExprAST(double Val) : Val(Val) {}
152
151153 Value *codegen() override;
152154 };
153155
157159
158160 public:
159161 VariableExprAST(const std::string &Name) : Name(Name) {}
162
163 Value *codegen() override;
160164 const std::string &getName() const { return Name; }
161 Value *codegen() override;
162165 };
163166
164167 /// UnaryExprAST - Expression class for a unary operator.
169172 public:
170173 UnaryExprAST(char Opcode, std::unique_ptr Operand)
171174 : Opcode(Opcode), Operand(std::move(Operand)) {}
175
172176 Value *codegen() override;
173177 };
174178
181185 BinaryExprAST(char Op, std::unique_ptr LHS,
182186 std::unique_ptr RHS)
183187 : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
188
184189 Value *codegen() override;
185190 };
186191
193198 CallExprAST(const std::string &Callee,
194199 std::vector> Args)
195200 : Callee(Callee), Args(std::move(Args)) {}
201
196202 Value *codegen() override;
197203 };
198204
204210 IfExprAST(std::unique_ptr Cond, std::unique_ptr Then,
205211 std::unique_ptr Else)
206212 : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
213
207214 Value *codegen() override;
208215 };
209216
218225 std::unique_ptr Body)
219226 : VarName(VarName), Start(std::move(Start)), End(std::move(End)),
220227 Step(std::move(Step)), Body(std::move(Body)) {}
228
221229 Value *codegen() override;
222230 };
223231
231239 std::vector>> VarNames,
232240 std::unique_ptr Body)
233241 : VarNames(std::move(VarNames)), Body(std::move(Body)) {}
242
234243 Value *codegen() override;
235244 };
236245
248257 bool IsOperator = false, unsigned Prec = 0)
249258 : Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
250259 Precedence(Prec) {}
260
251261 Function *codegen();
252262 const std::string &getName() const { return Name; }
253263
271281 FunctionAST(std::unique_ptr Proto,
272282 std::unique_ptr Body)
273283 : Proto(std::move(Proto)), Body(std::move(Body)) {}
284
274285 Function *codegen();
275286 };
287
276288 } // end anonymous namespace
277289
278290 //===----------------------------------------------------------------------===//
2525 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
2626 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
2727 #include "llvm/IR/DataLayout.h"
28 #include "llvm/IR/LegacyPassManager.h"
2829 #include "llvm/IR/Mangler.h"
2930 #include "llvm/Support/DynamicLibrary.h"
31 #include "llvm/Support/Error.h"
3032 #include "llvm/Support/raw_ostream.h"
3133 #include "llvm/Target/TargetMachine.h"
34 #include "llvm/Transforms/Scalar.h"
35 #include "llvm/Transforms/Scalar/GVN.h"
3236 #include
37 #include
38 #include
3339 #include
3440 #include
3541 #include
4652 FunctionAST(std::unique_ptr Proto,
4753 std::unique_ptr Body)
4854 : Proto(std::move(Proto)), Body(std::move(Body)) {}
55
4956 const PrototypeAST& getProto() const;
5057 const std::string& getName() const;
5158 llvm::Function *codegen();
196203 }
197204
198205 private:
199
200206 std::string mangle(const std::string &Name) {
201207 std::string MangledName;
202208 raw_string_ostream MangledNameStream(MangledName);
222228
223229 return M;
224230 }
225
226231 };
227232
228233 } // end namespace orc
66 #include "llvm/IR/Instructions.h"
77 #include "llvm/IR/IRBuilder.h"
88 #include "llvm/IR/LLVMContext.h"
9 #include "llvm/IR/LegacyPassManager.h"
109 #include "llvm/IR/Module.h"
1110 #include "llvm/IR/Type.h"
1211 #include "llvm/IR/Verifier.h"
1312 #include "llvm/Support/Error.h"
13 #include "llvm/Support/ErrorHandling.h"
1414 #include "llvm/Support/TargetSelect.h"
1515 #include "llvm/Target/TargetMachine.h"
16 #include "llvm/Transforms/Scalar.h"
17 #include "llvm/Transforms/Scalar/GVN.h"
1816 #include "KaleidoscopeJIT.h"
17 #include
1918 #include
2019 #include
2120 #include
139138 /// ExprAST - Base class for all expression nodes.
140139 class ExprAST {
141140 public:
142 virtual ~ExprAST() {}
141 virtual ~ExprAST() = default;
142
143143 virtual Value *codegen() = 0;
144144 };
145145
149149
150150 public:
151151 NumberExprAST(double Val) : Val(Val) {}
152
152153 Value *codegen() override;
153154 };
154155
158159
159160 public:
160161 VariableExprAST(const std::string &Name) : Name(Name) {}
162
163 Value *codegen() override;
161164 const std::string &getName() const { return Name; }
162 Value *codegen() override;
163165 };
164166
165167 /// UnaryExprAST - Expression class for a unary operator.
170172 public:
171173 UnaryExprAST(char Opcode, std::unique_ptr Operand)
172174 : Opcode(Opcode), Operand(std::move(Operand)) {}
175
173176 Value *codegen() override;
174177 };
175178
182185 BinaryExprAST(char Op, std::unique_ptr LHS,
183186 std::unique_ptr RHS)
184187 : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
188
185189 Value *codegen() override;
186190 };
187191
194198 CallExprAST(const std::string &Callee,
195199 std::vector> Args)
196200 : Callee(Callee), Args(std::move(Args)) {}
201
197202 Value *codegen() override;
198203 };
199204
205210 IfExprAST(std::unique_ptr Cond, std::unique_ptr Then,
206211 std::unique_ptr Else)
207212 : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
213
208214 Value *codegen() override;
209215 };
210216
219225 std::unique_ptr Body)
220226 : VarName(VarName), Start(std::move(Start)), End(std::move(End)),
221227 Step(std::move(Step)), Body(std::move(Body)) {}
228
222229 Value *codegen() override;
223230 };
224231
232239 std::vector>> VarNames,
233240 std::unique_ptr Body)
234241 : VarNames(std::move(VarNames)), Body(std::move(Body)) {}
242
235243 Value *codegen() override;
236244 };
237245
249257 bool IsOperator = false, unsigned Prec = 0)
250258 : Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
251259 Precedence(Prec) {}
260
252261 Function *codegen();
253262 const std::string &getName() const { return Name; }
254263
1414 #define LLVM_EXECUTIONENGINE_ORC_KALEIDOSCOPEJIT_H
1515
1616 #include "RemoteJITUtils.h"
17 #include "llvm/ADT/SmallVector.h"
1718 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/ADT/Triple.h"
1820 #include "llvm/ExecutionEngine/ExecutionEngine.h"
1921 #include "llvm/ExecutionEngine/JITSymbol.h"
2022 #include "llvm/ExecutionEngine/RuntimeDyld.h"
21 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
2223 #include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
2324 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
2425 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
2728 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
2829 #include "llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h"
2930 #include "llvm/IR/DataLayout.h"
31 #include "llvm/IR/LegacyPassManager.h"
3032 #include "llvm/IR/Mangler.h"
3133 #include "llvm/Support/DynamicLibrary.h"
34 #include "llvm/Support/Error.h"
3235 #include "llvm/Support/raw_ostream.h"
3336 #include "llvm/Target/TargetMachine.h"
37 #include "llvm/Transforms/Scalar.h"
38 #include "llvm/Transforms/Scalar/GVN.h"
3439 #include
40 #include
41 #include
3542 #include
3643 #include
3744 #include
4855 FunctionAST(std::unique_ptr Proto,
4956 std::unique_ptr Body)
5057 : Proto(std::move(Proto)), Body(std::move(Body)) {}
58
5159 const PrototypeAST& getProto() const;
5260 const std::string& getName() const;
5361 llvm::Function *codegen();
228236 }
229237
230238 private:
231
232239 std::string mangle(const std::string &Name) {
233240 std::string MangledName;
234241 raw_string_ostream MangledNameStream(MangledName);
254261
255262 return M;
256263 }
257
258264 };
259265
260266 } // end namespace orc
1414 #define LLVM_TOOLS_LLI_REMOTEJITUTILS_H
1515
1616 #include "llvm/ExecutionEngine/Orc/RawByteChannel.h"
17 #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
18 #include
17 #include "llvm/Support/Error.h"
18 #include
19 #include
20 #include
1921
2022 #if !defined(_MSC_VER) && !defined(__MINGW32__)
2123 #include
7072 int InFD, OutFD;
7173 };
7274
73 #endif
75 #endif // LLVM_TOOLS_LLI_REMOTEJITUTILS_H
66 #include "llvm/IR/Instructions.h"
77 #include "llvm/IR/IRBuilder.h"
88 #include "llvm/IR/LLVMContext.h"
9 #include "llvm/IR/LegacyPassManager.h"
109 #include "llvm/IR/Module.h"
1110 #include "llvm/IR/Type.h"
1211 #include "llvm/IR/Verifier.h"
12 #include "llvm/Support/CommandLine.h"
1313 #include "llvm/Support/Error.h"
14 #include "llvm/Support/ErrorHandling.h"
15 #include "llvm/Support/raw_ostream.h"
1416 #include "llvm/Support/TargetSelect.h"
1517 #include "llvm/Target/TargetMachine.h"
16 #include "llvm/Transforms/Scalar.h"
17 #include "llvm/Transforms/Scalar/GVN.h"
1818 #include "KaleidoscopeJIT.h"
19 #include "RemoteJITUtils.h"
20 #include
1921 #include
2022 #include
2123 #include
2224 #include
2325 #include
26 #include
2427 #include
2528 #include
2629 #include
2730 #include
2831 #include
29
3032 #include
31 #include
3233 #include
3334 #include
3435
154155 /// ExprAST - Base class for all expression nodes.
155156 class ExprAST {
156157 public:
157 virtual ~ExprAST() {}
158 virtual ~ExprAST() = default;
159
158160 virtual Value *codegen() = 0;
159161 };
160162
164166
165167 public:
166168 NumberExprAST(double Val) : Val(Val) {}
169
167170 Value *codegen() override;
168171 };
169172
173176
174177 public:
175178 VariableExprAST(const std::string &Name) : Name(Name) {}
179
180 Value *codegen() override;
176181 const std::string &getName() const { return Name; }
177 Value *codegen() override;
178182 };
179183
180184 /// UnaryExprAST - Expression class for a unary operator.
185189 public:
186190 UnaryExprAST(char Opcode, std::unique_ptr Operand)
187191 : Opcode(Opcode), Operand(std::move(Operand)) {}
192
188193 Value *codegen() override;
189194 };
190195
197202 BinaryExprAST(char Op, std::unique_ptr LHS,
198203 std::unique_ptr RHS)
199204 : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
205
200206 Value *codegen() override;
201207 };
202208
209215 CallExprAST(const std::string &Callee,
210216 std::vector> Args)
211217 : Callee(Callee), Args(std::move(Args)) {}
218
212219 Value *codegen() override;
213220 };
214221
220227 IfExprAST(std::unique_ptr Cond, std::unique_ptr Then,
221228 std::unique_ptr Else)
222229 : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
230
223231 Value *codegen() override;
224232 };
225233
234242 std::unique_ptr Body)
235243 : VarName(VarName), Start(std::move(Start)), End(std::move(End)),
236244 Step(std::move(Step)), Body(std::move(Body)) {}
245
237246 Value *codegen() override;
238247 };
239248
247256 std::vector>> VarNames,
248257 std::unique_ptr Body)
249258 : VarNames(std::move(VarNames)), Body(std::move(Body)) {}
259
250260 Value *codegen() override;
251261 };
252262
264274 bool IsOperator = false, unsigned Prec = 0)
265275 : Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
266276 Precedence(Prec) {}
277
267278 Function *codegen();
268279 const std::string &getName() const { return Name; }
269280
12281239 }
12291240
12301241 sockaddr_in servAddr;
1231 bzero(&servAddr, sizeof(servAddr));
1242 memset(&servAddr, 0, sizeof(servAddr));
12321243 servAddr.sin_family = PF_INET;
1233 bcopy(server->h_addr, &servAddr.sin_addr.s_addr, server->h_length);
1244 memcpy(&servAddr.sin_addr.s_addr, server->h_addr, server->h_length);
12341245 servAddr.sin_port = htons(Port);
12351246 if (connect(sockfd, reinterpret_cast(&servAddr),
12361247 sizeof(servAddr)) < 0) {
0 #include "llvm/ADT/STLExtras.h"
1 #include
12 #include
23 #include
34 #include
8182 //===----------------------------------------------------------------------===//
8283 // Abstract Syntax Tree (aka Parse Tree)
8384 //===----------------------------------------------------------------------===//
85
8486 namespace {
87
8588 /// ExprAST - Base class for all expression nodes.
8689 class ExprAST {
8790 public:
88 virtual ~ExprAST() {}
91 virtual ~ExprAST() = default;
8992 };
9093
9194 /// NumberExprAST - Expression class for numeric literals like "1.0".
148151 std::unique_ptr Body)
149152 : Proto(std::move(Proto)), Body(std::move(Body)) {}
150153 };
154
151155 } // end anonymous namespace
152156
153157 //===----------------------------------------------------------------------===//
88 #include "llvm/IR/Module.h"
99 #include "llvm/IR/Type.h"
1010 #include "llvm/IR/Verifier.h"
11 #include
1112 #include
1213 #include
1314 #include
9394 //===----------------------------------------------------------------------===//
9495 // Abstract Syntax Tree (aka Parse Tree)
9596 //===----------------------------------------------------------------------===//
97
9698 namespace {
99
97100 /// ExprAST - Base class for all expression nodes.
98101 class ExprAST {
99102 public:
100 virtual ~ExprAST() {}
103 virtual ~ExprAST() = default;
104
101105 virtual Value *codegen() = 0;
102106 };
103107
107111
108112 public:
109113 NumberExprAST(double Val) : Val(Val) {}
114
110115 Value *codegen() override;
111116 };
112117
116121
117122 public:
118123 VariableExprAST(const std::string &Name) : Name(Name) {}
124
119125 Value *codegen() override;
120126 };
121127
128134 BinaryExprAST(char Op, std::unique_ptr LHS,
129135 std::unique_ptr RHS)
130136 : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
137
131138 Value *codegen() override;
132139 };
133140
140147 CallExprAST(const std::string &Callee,
141148 std::vector> Args)
142149 : Callee(Callee), Args(std::move(Args)) {}
150
143151 Value *codegen() override;
144152 };
145153
153161 public:
154162 PrototypeAST(const std::string &Name, std::vector Args)
155163 : Name(Name), Args(std::move(Args)) {}
164
156165 Function *codegen();
157166 const std::string &getName() const { return Name; }
158167 };
166175 FunctionAST(std::unique_ptr Proto,
167176 std::unique_ptr Body)
168177 : Proto(std::move(Proto)), Body(std::move(Body)) {}
178
169179 Function *codegen();
170180 };
181
171182 } // end anonymous namespace
172183
173184 //===----------------------------------------------------------------------===//
1414 #include "llvm/Transforms/Scalar.h"
1515 #include "llvm/Transforms/Scalar/GVN.h"
1616 #include "../include/KaleidoscopeJIT.h"
17 #include
1718 #include
1819 #include
1920 #include
102103 //===----------------------------------------------------------------------===//
103104 // Abstract Syntax Tree (aka Parse Tree)
104105 //===----------------------------------------------------------------------===//
106
105107 namespace {
108
106109 /// ExprAST - Base class for all expression nodes.
107110 class ExprAST {
108111 public:
109 virtual ~ExprAST() {}
112 virtual ~ExprAST() = default;
113
110114 virtual Value *codegen() = 0;
111115 };
112116
116120
117121 public:
118122 NumberExprAST(double Val) : Val(Val) {}
123
119124 Value *codegen() override;
120125 };
121126
125130
126131 public:
127132 VariableExprAST(const std::string &Name) : Name(Name) {}
133
128134 Value *codegen() override;
129135 };
130136
137143 BinaryExprAST(char Op, std::unique_ptr LHS,
138144 std::unique_ptr RHS)
139145 : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
146
140147 Value *codegen() override;
141148 };
142149
149156 CallExprAST(const std::string &Callee,
150157 std::vector> Args)
151158 : Callee(Callee), Args(std::move(Args)) {}
159
152160 Value *codegen() override;
153161 };
154162
162170 public:
163171 PrototypeAST(const std::string &Name, std::vector Args)
164172 : Name(Name), Args(std::move(Args)) {}
173
165174 Function *codegen();
166175 const std::string &getName() const { return Name; }
167176 };
175184 FunctionAST(std::unique_ptr Proto,
176185 std::unique_ptr Body)
177186 : Proto(std::move(Proto)), Body(std::move(Body)) {}
187
178188 Function *codegen();
179189 };
190
180191 } // end anonymous namespace
181192
182193 //===----------------------------------------------------------------------===//
1515 #include "llvm/Transforms/Scalar.h"
1616 #include "llvm/Transforms/Scalar/GVN.h"
1717 #include "../include/KaleidoscopeJIT.h"
18 #include
1819 #include
1920 #include
2021 #include
120121 //===----------------------------------------------------------------------===//
121122 // Abstract Syntax Tree (aka Parse Tree)
122123 //===----------------------------------------------------------------------===//
124
123125 namespace {
126
124127 /// ExprAST - Base class for all expression nodes.
125128 class ExprAST {
126129 public:
127 virtual ~ExprAST() {}
130 virtual ~ExprAST() = default;
131
128132 virtual Value *codegen() = 0;
129133 };
130134
134138
135139 public:
136140 NumberExprAST(double Val) : Val(Val) {}
141
137142 Value *codegen() override;
138143 };
139144
143148
144149 public:
145150 VariableExprAST(const std::string &Name) : Name(Name) {}
151
146152 Value *codegen() override;
147153 };
148154
155161 BinaryExprAST(char Op, std::unique_ptr LHS,
156162 std::unique_ptr RHS)
157163 : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
164
158165 Value *codegen() override;
159166 };
160167
167174 CallExprAST(const std::string &Callee,
168175 std::vector> Args)
169176 : Callee(Callee), Args(std::move(Args)) {}
177
170178 Value *codegen() override;
171179 };
172180
178186 IfExprAST(std::unique_ptr Cond, std::unique_ptr Then,
179187 std::unique_ptr Else)
180188 : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
189
181190 Value *codegen() override;
182191 };
183192
192201 std::unique_ptr Body)
193202 : VarName(VarName), Start(std::move(Start)), End(std::move(End)),
194203 Step(std::move(Step)), Body(std::move(Body)) {}
204
195205 Value *codegen() override;
196206 };
197207
205215 public:
206216 PrototypeAST(const std::string &Name, std::vector Args)
207217 : Name(Name), Args(std::move(Args)) {}
218
208219 Function *codegen();
209220 const std::string &getName() const { return Name; }
210221 };
218229 FunctionAST(std::unique_ptr Proto,
219230 std::unique_ptr Body)
220231 : Proto(std::move(Proto)), Body(std::move(Body)) {}
232
221233 Function *codegen();
222234 };
235
223236 } // end anonymous namespace
224237
225238 //===----------------------------------------------------------------------===//
1515 #include "llvm/Transforms/Scalar.h"
1616 #include "llvm/Transforms/Scalar/GVN.h"
1717 #include "../include/KaleidoscopeJIT.h"
18 #include
1819 #include
1920 #include
2021 #include
128129 //===----------------------------------------------------------------------===//
129130 // Abstract Syntax Tree (aka Parse Tree)
130131 //===----------------------------------------------------------------------===//
132
131133 namespace {
134
132135 /// ExprAST - Base class for all expression nodes.
133136 class ExprAST {
134137 public:
135 virtual ~ExprAST() {}
138 virtual ~ExprAST() = default;
139
136140 virtual Value *codegen() = 0;
137141 };
138142
142146
143147 public:
144148 NumberExprAST(double Val) : Val(Val) {}
149
145150 Value *codegen() override;
146151 };
147152
151156
152157 public:
153158 VariableExprAST(const std::string &Name) : Name(Name) {}
159
154160 Value *codegen() override;
155161 };
156162
162168 public:
163169 UnaryExprAST(char Opcode, std::unique_ptr Operand)
164170 : Opcode(Opcode), Operand(std::move(Operand)) {}
171
165172 Value *codegen() override;
166173 };
167174
174181 BinaryExprAST(char Op, std::unique_ptr LHS,
175182 std::unique_ptr RHS)
176183 : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
184
177185 Value *codegen() override;
178186 };
179187
186194 CallExprAST(const std::string &Callee,
187195 std::vector> Args)
188196 : Callee(Callee), Args(std::move(Args)) {}
197
189198 Value *codegen() override;
190199 };
191200
197206 IfExprAST(std::unique_ptr Cond, std::unique_ptr Then,
198207 std::unique_ptr Else)
199208 : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
209
200210 Value *codegen() override;
201211 };
202212
211221 std::unique_ptr Body)
212222 : VarName(VarName), Start(std::move(Start)), End(std::move(End)),
213223 Step(std::move(Step)), Body(std::move(Body)) {}
224
214225 Value *codegen() override;
215226 };
216227
228239 bool IsOperator = false, unsigned Prec = 0)
229240 : Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
230241 Precedence(Prec) {}
242
231243 Function *codegen();
232244 const std::string &getName() const { return Name; }
233245
251263 FunctionAST(std::unique_ptr Proto,
252264 std::unique_ptr Body)
253265 : Proto(std::move(Proto)), Body(std::move(Body)) {}
266
254267 Function *codegen();
255268 };
269
256270 } // end anonymous namespace
257271
258272 //===----------------------------------------------------------------------===//
1515 #include "llvm/Transforms/Scalar.h"
1616 #include "llvm/Transforms/Scalar/GVN.h"
1717 #include "../include/KaleidoscopeJIT.h"
18 #include
1819 #include
1920 #include
2021 #include
134135 //===----------------------------------------------------------------------===//
135136 // Abstract Syntax Tree (aka Parse Tree)
136137 //===----------------------------------------------------------------------===//
138
137139 namespace {
140
138141 /// ExprAST - Base class for all expression nodes.
139142 class ExprAST {
140143 public:
141 virtual ~ExprAST() {}
144 virtual ~ExprAST() = default;
145
142146 virtual Value *codegen() = 0;
143147 };
144148
148152
149153 public:
150154 NumberExprAST(double Val) : Val(Val) {}
155
151156 Value *codegen() override;
152157 };
153158
157162
158163 public:
159164 VariableExprAST(const std::string &Name) : Name(Name) {}
165
166 Value *codegen() override;
160167 const std::string &getName() const { return Name; }
161 Value *codegen() override;
162168 };
163169
164170 /// UnaryExprAST - Expression class for a unary operator.
169175 public:
170176 UnaryExprAST(char Opcode, std::unique_ptr Operand)
171177 : Opcode(Opcode), Operand(std::move(Operand)) {}
178
172179 Value *codegen() override;
173180 };
174181
181188 BinaryExprAST(char Op, std::unique_ptr LHS,
182189 std::unique_ptr RHS)
183190 : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
191
184192 Value *codegen() override;
185193 };
186194
193201 CallExprAST(const std::string &Callee,
194202 std::vector> Args)
195203 : Callee(Callee), Args(std::move(Args)) {}
204
196205 Value *codegen() override;
197206 };
198207
204213 IfExprAST(std::unique_ptr Cond, std::unique_ptr Then,
205214 std::unique_ptr Else)
206215 : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
216
207217 Value *codegen() override;
208218 };
209219
218228 std::unique_ptr Body)
219229 : VarName(VarName), Start(std::move(Start)), End(std::move(End)),
220230 Step(std::move(Step)), Body(std::move(Body)) {}
231
221232 Value *codegen() override;
222233 };
223234
231242 std::vector>> VarNames,
232243 std::unique_ptr Body)
233244 : VarNames(std::move(VarNames)), Body(std::move(Body)) {}
245
234246 Value *codegen() override;
235247 };
236248
248260 bool IsOperator = false, unsigned Prec = 0)
249261 : Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
250262 Precedence(Prec) {}
263
251264 Function *codegen();
252265 const std::string &getName() const { return Name; }
253266
271284 FunctionAST(std::unique_ptr Proto,
272285 std::unique_ptr Body)
273286 : Proto(std::move(Proto)), Body(std::move(Body)) {}
287
274288 Function *codegen();
275289 };
290
276291 } // end anonymous namespace
277292
278293 //===----------------------------------------------------------------------===//
0 #include "llvm/ADT/APFloat.h"
1 #include "llvm/ADT/Optional.h"
12 #include "llvm/ADT/STLExtras.h"
2 #include "llvm/ADT/SmallVector.h"
3 #include "llvm/Analysis/Passes.h"
3 #include "llvm/IR/BasicBlock.h"
4 #include "llvm/IR/Constants.h"
5 #include "llvm/IR/DerivedTypes.h"
6 #include "llvm/IR/Function.h"
7 #include "llvm/IR/Instructions.h"
48 #include "llvm/IR/IRBuilder.h"
59 #include "llvm/IR/LLVMContext.h"
610 #include "llvm/IR/LegacyPassManager.h"
7 #include "llvm/IR/Metadata.h"
811 #include "llvm/IR/Module.h"
912 #include "llvm/IR/Type.h"
1013 #include "llvm/IR/Verifier.h"
1114 #include "llvm/Support/FileSystem.h"
15 #include "llvm/Support/Host.h"
16 #include "llvm/Support/raw_ostream.h"
1217 #include "llvm/Support/TargetRegistry.h"
1318 #include "llvm/Support/TargetSelect.h"
1419 #include "llvm/Target/TargetMachine.h"
1520 #include "llvm/Target/TargetOptions.h"
16 #include "llvm/Transforms/Scalar.h"
21 #include
22 #include
1723 #include
1824 #include
1925 #include
2026 #include
2127 #include
2228 #include
29 #include
2330 #include
2431 #include
2532
131138 //===----------------------------------------------------------------------===//
132139 // Abstract Syntax Tree (aka Parse Tree)
133140 //===----------------------------------------------------------------------===//
141
134142 namespace {
143
135144 /// ExprAST - Base class for all expression nodes.
136145 class ExprAST {
137146 public:
138 virtual ~ExprAST() {}
147 virtual ~ExprAST() = default;
148
139149 virtual Value *codegen() = 0;
140150 };
141151
145155
146156 public:
147157 NumberExprAST(double Val) : Val(Val) {}
158
148159 Value *codegen() override;
149160 };
150161
154165
155166 public:
156167 VariableExprAST(const std::string &Name) : Name(Name) {}
168
169 Value *codegen() override;
157170 const std::string &getName() const { return Name; }
158 Value *codegen() override;
159171 };
160172
161173 /// UnaryExprAST - Expression class for a unary operator.
166178 public:
167179 UnaryExprAST(char Opcode, std::unique_ptr Operand)
168180 : Opcode(Opcode), Operand(std::move(Operand)) {}
181
169182 Value *codegen() override;
170183 };
171184
178191 BinaryExprAST(char Op, std::unique_ptr LHS,
179192 std::unique_ptr RHS)
180193 : Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
194
181195 Value *codegen() override;
182196 };
183197
190204 CallExprAST(const std::string &Callee,
191205 std::vector> Args)
192206 : Callee(Callee), Args(std::move(Args)) {}
207
193208 Value *codegen() override;
194209 };
195210
201216 IfExprAST(std::unique_ptr Cond, std::unique_ptr Then,
202217 std::unique_ptr Else)
203218 : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
219
204220 Value *codegen() override;
205221 };
206222
215231 std::unique_ptr Body)
216232 : VarName(VarName), Start(std::move(Start)), End(std::move(End)),
217233 Step(std::move(Step)), Body(std::move(Body)) {}
234
218235 Value *codegen() override;
219236 };
220237
228245 std::vector>> VarNames,
229246 std::unique_ptr Body)
230247 : VarNames(std::move(VarNames)), Body(std::move(Body)) {}
248
231249 Value *codegen() override;
232250 };
233251
245263 bool IsOperator = false, unsigned Prec = 0)
246264 : Name(Name), Args(std::move(Args)), IsOperator(IsOperator),
247265 Precedence(Prec) {}
266
248267 Function *codegen();
249268 const std::string &getName() const { return Name; }
250269
268287 FunctionAST(std::unique_ptr Proto,
269288 std::unique_ptr Body)
270289 : Proto(std::move(Proto)), Body(std::move(Body)) {}
290
271291 Function *codegen();
272292 };
293
273294 } // end anonymous namespace
274295
275296 //===----------------------------------------------------------------------===//