llvm.org GIT mirror llvm / efac554
Fix some Clang-tidy modernize-use-bool-literals and Include What You Use warnings in examples; other minor fixes. Differential revision: http://reviews.llvm.org/D20397 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270008 91177308-0d34-0410-b5e6-96231b3b80d8 Eugene Zelenko 3 years ago
11 changed file(s) with 245 addition(s) and 96 deletion(s). Raw diff Collapse all Expand all
0 #include
11 #include
2 #include
23 #include
34 #include
45 #include
1415 make_unique(Args &&... args) {
1516 return std::unique_ptr(new T(std::forward(args)...));
1617 }
17 }
18 } // end namespace helper
1819
1920 //===----------------------------------------------------------------------===//
2021 // Lexer
233234 getNextToken(); // eat (
234235 std::vector> Args;
235236 if (CurTok != ')') {
236 while (1) {
237 while (true) {
237238 if (auto Arg = ParseExpression())
238239 Args.push_back(std::move(Arg));
239240 else
276277 static std::unique_ptr ParseBinOpRHS(int ExprPrec,
277278 std::unique_ptr LHS) {
278279 // If this is a binop, find its precedence.
279 while (1) {
280 while (true) {
280281 int TokPrec = GetTokPrecedence();
281282
282283 // If this is a binop that binds at least as tightly as the current binop,
406407
407408 /// top ::= definition | external | expression | ';'
408409 static void MainLoop() {
409 while (1) {
410 while (true) {
410411 fprintf(stderr, "ready> ");
411412 switch (CurTok) {
412413 case tok_eof:
0 #include "llvm/ADT/APFloat.h"
1 #include "llvm/ADT/STLExtras.h"
2 #include "llvm/IR/BasicBlock.h"
3 #include "llvm/IR/Constants.h"
4 #include "llvm/IR/DerivedTypes.h"
5 #include "llvm/IR/Function.h"
16 #include "llvm/IR/IRBuilder.h"
27 #include "llvm/IR/LLVMContext.h"
38 #include "llvm/IR/Module.h"
9 #include "llvm/IR/Type.h"
410 #include "llvm/IR/Verifier.h"
511 #include
612 #include
13 #include
714 #include
15 #include
816 #include
917 #include
1018
236244 getNextToken(); // eat (
237245 std::vector> Args;
238246 if (CurTok != ')') {
239 while (1) {
247 while (true) {
240248 if (auto Arg = ParseExpression())
241249 Args.push_back(std::move(Arg));
242250 else
279287 static std::unique_ptr ParseBinOpRHS(int ExprPrec,
280288 std::unique_ptr LHS) {
281289 // If this is a binop, find its precedence.
282 while (1) {
290 while (true) {
283291 int TokPrec = GetTokPrecedence();
284292
285293 // If this is a binop that binds at least as tightly as the current binop,
537545
538546 /// top ::= definition | external | expression | ';'
539547 static void MainLoop() {
540 while (1) {
548 while (true) {
541549 fprintf(stderr, "ready> ");
542550 switch (CurTok) {
543551 case tok_eof:
0 #include "llvm/ADT/APFloat.h"
1 #include "llvm/ADT/STLExtras.h"
1 #include "llvm/Analysis/Passes.h"
2 #include "llvm/IR/BasicBlock.h"
3 #include "llvm/IR/Constants.h"
4 #include "llvm/IR/DerivedTypes.h"
5 #include "llvm/IR/Function.h"
26 #include "llvm/IR/IRBuilder.h"
37 #include "llvm/IR/LLVMContext.h"
48 #include "llvm/IR/LegacyPassManager.h"
59 #include "llvm/IR/Module.h"
10 #include "llvm/IR/Type.h"
611 #include "llvm/IR/Verifier.h"
712 #include "llvm/Support/TargetSelect.h"
13 #include "llvm/Target/TargetMachine.h"
814 #include "llvm/Transforms/Scalar.h"
915 #include "llvm/Transforms/Scalar/GVN.h"
16 #include "../include/KaleidoscopeJIT.h"
17 #include
1018 #include
19 #include
1120 #include
21 #include
1222 #include
23 #include
1324 #include
1425 #include
15 #include "../include/KaleidoscopeJIT.h"
1626
1727 using namespace llvm;
1828 using namespace llvm::orc;
243253 getNextToken(); // eat (
244254 std::vector> Args;
245255 if (CurTok != ')') {
246 while (1) {
256 while (true) {
247257 if (auto Arg = ParseExpression())
248258 Args.push_back(std::move(Arg));
249259 else
286296 static std::unique_ptr ParseBinOpRHS(int ExprPrec,
287297 std::unique_ptr LHS) {
288298 // If this is a binop, find its precedence.
289 while (1) {
299 while (true) {
290300 int TokPrec = GetTokPrecedence();
291301
292302 // If this is a binop that binds at least as tightly as the current binop,
576586 // Evaluate a top-level expression into an anonymous function.
577587 if (auto FnAST = ParseTopLevelExpr()) {
578588 if (FnAST->codegen()) {
579
580589 // JIT the module containing the anonymous expression, keeping a handle so
581590 // we can free it later.
582591 auto H = TheJIT->addModule(std::move(TheModule));
602611
603612 /// top ::= definition | external | expression | ';'
604613 static void MainLoop() {
605 while (1) {
614 while (true) {
606615 fprintf(stderr, "ready> ");
607616 switch (CurTok) {
608617 case tok_eof:
0 #include "llvm/ADT/APFloat.h"
1 #include "llvm/ADT/STLExtras.h"
1 #include "llvm/Analysis/Passes.h"
2 #include "llvm/IR/BasicBlock.h"
3 #include "llvm/IR/Constants.h"
4 #include "llvm/IR/DerivedTypes.h"
5 #include "llvm/IR/Function.h"
6 #include "llvm/IR/Instructions.h"
27 #include "llvm/IR/IRBuilder.h"
38 #include "llvm/IR/LLVMContext.h"
49 #include "llvm/IR/LegacyPassManager.h"
510 #include "llvm/IR/Module.h"
11 #include "llvm/IR/Type.h"
612 #include "llvm/IR/Verifier.h"
713 #include "llvm/Support/TargetSelect.h"
14 #include "llvm/Target/TargetMachine.h"
815 #include "llvm/Transforms/Scalar.h"
916 #include "llvm/Transforms/Scalar/GVN.h"
17 #include "../include/KaleidoscopeJIT.h"
18 #include
1019 #include
20 #include
1121 #include
22 #include
1223 #include
24 #include
1325 #include
1426 #include
15 #include "../include/KaleidoscopeJIT.h"
1627
1728 using namespace llvm;
1829 using namespace llvm::orc;
285296 getNextToken(); // eat (
286297 std::vector> Args;
287298 if (CurTok != ')') {
288 while (1) {
299 while (true) {
289300 if (auto Arg = ParseExpression())
290301 Args.push_back(std::move(Arg));
291302 else
410421 static std::unique_ptr ParseBinOpRHS(int ExprPrec,
411422 std::unique_ptr LHS) {
412423 // If this is a binop, find its precedence.
413 while (1) {
424 while (true) {
414425 int TokPrec = GetTokPrecedence();
415426
416427 // If this is a binop that binds at least as tightly as the current binop,
679690
680691 // Start the PHI node with an entry for Start.
681692 PHINode *Variable =
682 Builder.CreatePHI(Type::getDoubleTy(TheContext), 2, VarName.c_str());
693 Builder.CreatePHI(Type::getDoubleTy(TheContext), 2, VarName);
683694 Variable->addIncoming(StartVal, PreheaderBB);
684695
685696 // Within the loop, the variable is defined equal to the PHI node. If it
847858 // Evaluate a top-level expression into an anonymous function.
848859 if (auto FnAST = ParseTopLevelExpr()) {
849860 if (FnAST->codegen()) {
850
851861 // JIT the module containing the anonymous expression, keeping a handle so
852862 // we can free it later.
853863 auto H = TheJIT->addModule(std::move(TheModule));
873883
874884 /// top ::= definition | external | expression | ';'
875885 static void MainLoop() {
876 while (1) {
886 while (true) {
877887 fprintf(stderr, "ready> ");
878888 switch (CurTok) {
879889 case tok_eof:
0 #include "llvm/ADT/APFloat.h"
1 #include "llvm/ADT/STLExtras.h"
1 #include "llvm/Analysis/Passes.h"
2 #include "llvm/IR/BasicBlock.h"
3 #include "llvm/IR/Constants.h"
4 #include "llvm/IR/DerivedTypes.h"
5 #include "llvm/IR/Function.h"
6 #include "llvm/IR/Instructions.h"
27 #include "llvm/IR/IRBuilder.h"
38 #include "llvm/IR/LLVMContext.h"
49 #include "llvm/IR/LegacyPassManager.h"
510 #include "llvm/IR/Module.h"
11 #include "llvm/IR/Type.h"
612 #include "llvm/IR/Verifier.h"
713 #include "llvm/Support/TargetSelect.h"
14 #include "llvm/Target/TargetMachine.h"
815 #include "llvm/Transforms/Scalar.h"
916 #include "llvm/Transforms/Scalar/GVN.h"
17 #include "../include/KaleidoscopeJIT.h"
18 #include
1019 #include
20 #include
1121 #include
22 #include
1223 #include
24 #include
1325 #include
1426 #include
15 #include "../include/KaleidoscopeJIT.h"
1627
1728 using namespace llvm;
1829 using namespace llvm::orc;
318329 getNextToken(); // eat (
319330 std::vector> Args;
320331 if (CurTok != ')') {
321 while (1) {
332 while (true) {
322333 if (auto Arg = ParseExpression())
323334 Args.push_back(std::move(Arg));
324335 else
459470 static std::unique_ptr ParseBinOpRHS(int ExprPrec,
460471 std::unique_ptr LHS) {
461472 // If this is a binop, find its precedence.
462 while (1) {
473 while (true) {
463474 int TokPrec = GetTokPrecedence();
464475
465476 // If this is a binop that binds at least as tightly as the current binop,
790801
791802 // Start the PHI node with an entry for Start.
792803 PHINode *Variable =
793 Builder.CreatePHI(Type::getDoubleTy(TheContext), 2, VarName.c_str());
804 Builder.CreatePHI(Type::getDoubleTy(TheContext), 2, VarName);
794805 Variable->addIncoming(StartVal, PreheaderBB);
795806
796807 // Within the loop, the variable is defined equal to the PHI node. If it
965976 // Evaluate a top-level expression into an anonymous function.
966977 if (auto FnAST = ParseTopLevelExpr()) {
967978 if (FnAST->codegen()) {
968
969979 // JIT the module containing the anonymous expression, keeping a handle so
970980 // we can free it later.
971981 auto H = TheJIT->addModule(std::move(TheModule));
9911001
9921002 /// top ::= definition | external | expression | ';'
9931003 static void MainLoop() {
994 while (1) {
1004 while (true) {
9951005 fprintf(stderr, "ready> ");
9961006 switch (CurTok) {
9971007 case tok_eof:
0 #include "llvm/ADT/APFloat.h"
1 #include "llvm/ADT/STLExtras.h"
1 #include "llvm/Analysis/Passes.h"
2 #include "llvm/IR/BasicBlock.h"
3 #include "llvm/IR/Constants.h"
4 #include "llvm/IR/DerivedTypes.h"
5 #include "llvm/IR/Function.h"
6 #include "llvm/IR/Instructions.h"
27 #include "llvm/IR/IRBuilder.h"
38 #include "llvm/IR/LLVMContext.h"
49 #include "llvm/IR/LegacyPassManager.h"
510 #include "llvm/IR/Module.h"
11 #include "llvm/IR/Type.h"
612 #include "llvm/IR/Verifier.h"
713 #include "llvm/Support/TargetSelect.h"
14 #include "llvm/Target/TargetMachine.h"
815 #include "llvm/Transforms/Scalar.h"
916 #include "llvm/Transforms/Scalar/GVN.h"
17 #include "../include/KaleidoscopeJIT.h"
18 #include
1019 #include
20 #include
1121 #include
22 #include
1223 #include
24 #include
1325 #include
26 #include
1427 #include
15 #include "../include/KaleidoscopeJIT.h"
1628
1729 using namespace llvm;
1830 using namespace llvm::orc;
337349 getNextToken(); // eat (
338350 std::vector> Args;
339351 if (CurTok != ')') {
340 while (1) {
352 while (true) {
341353 if (auto Arg = ParseExpression())
342354 Args.push_back(std::move(Arg));
343355 else
445457 if (CurTok != tok_identifier)
446458 return LogError("expected identifier after var");
447459
448 while (1) {
460 while (true) {
449461 std::string Name = IdentifierStr;
450462 getNextToken(); // eat identifier.
451463
529541 static std::unique_ptr ParseBinOpRHS(int ExprPrec,
530542 std::unique_ptr LHS) {
531543 // If this is a binop, find its precedence.
532 while (1) {
544 while (true) {
533545 int TokPrec = GetTokPrecedence();
534546
535547 // If this is a binop that binds at least as tightly as the current binop,
705717 const std::string &VarName) {
706718 IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
707719 TheFunction->getEntryBlock().begin());
708 return TmpB.CreateAlloca(Type::getDoubleTy(TheContext), nullptr,
709 VarName.c_str());
720 return TmpB.CreateAlloca(Type::getDoubleTy(TheContext), nullptr, VarName);
710721 }
711722
712723 Value *NumberExprAST::codegen() {
11311142 // Evaluate a top-level expression into an anonymous function.
11321143 if (auto FnAST = ParseTopLevelExpr()) {
11331144 if (FnAST->codegen()) {
1134
11351145 // JIT the module containing the anonymous expression, keeping a handle so
11361146 // we can free it later.
11371147 auto H = TheJIT->addModule(std::move(TheModule));
11571167
11581168 /// top ::= definition | external | expression | ';'
11591169 static void MainLoop() {
1160 while (1) {
1170 while (true) {
11611171 fprintf(stderr, "ready> ");
11621172 switch (CurTok) {
11631173 case tok_eof:
0 #include "llvm/ADT/APFloat.h"
1 #include "llvm/ADT/SmallVector.h"
2 #include "llvm/ADT/STLExtras.h"
1 #include "llvm/Analysis/BasicAliasAnalysis.h"
2 #include "llvm/Analysis/Passes.h"
3 #include "llvm/ADT/StringRef.h"
4 #include "llvm/ADT/Triple.h"
5 #include "llvm/IR/BasicBlock.h"
6 #include "llvm/IR/Constants.h"
7 #include "llvm/IR/DebugInfoMetadata.h"
8 #include "llvm/IR/DebugLoc.h"
9 #include "llvm/IR/DerivedTypes.h"
310 #include "llvm/IR/DIBuilder.h"
11 #include "llvm/IR/Function.h"
12 #include "llvm/IR/Instructions.h"
413 #include "llvm/IR/IRBuilder.h"
514 #include "llvm/IR/LLVMContext.h"
6 #include "llvm/IR/LegacyPassManager.h"
15 #include "llvm/IR/Metadata.h"
716 #include "llvm/IR/Module.h"
17 #include "llvm/IR/Type.h"
818 #include "llvm/IR/Verifier.h"
19 #include "llvm/Support/Host.h"
20 #include "llvm/Support/raw_ostream.h"
921 #include "llvm/Support/TargetSelect.h"
10 #include "llvm/Transforms/Scalar.h"
22 #include "llvm/Target/TargetMachine.h"
23 #include "../include/KaleidoscopeJIT.h"
24 #include
1125 #include
1226 #include
27 #include
1328 #include
29 #include
1430 #include
31 #include
1532 #include
16 #include "../include/KaleidoscopeJIT.h"
1733
1834 using namespace llvm;
1935 using namespace llvm::orc;
8399 }
84100
85101 namespace {
86 class PrototypeAST;
87102 class ExprAST;
88 }
103 } // end anonymous namespace
104
89105 static LLVMContext TheContext;
90106 static IRBuilder<> Builder(TheContext);
91107 struct DebugInfo {
206222 virtual Value *codegen() = 0;
207223 int getLine() const { return Loc.Line; }
208224 int getCol() const { return Loc.Col; }
225
209226 virtual raw_ostream &dump(raw_ostream &out, int ind) {
210227 return out << ':' << getLine() << ':' << getCol() << '\n';
211228 }
217234
218235 public:
219236 NumberExprAST(double Val) : Val(Val) {}
237 Value *codegen() override;
238
220239 raw_ostream &dump(raw_ostream &out, int ind) override {
221240 return ExprAST::dump(out << Val, ind);
222241 }
223 Value *codegen() override;
224242 };
225243
226244 /// VariableExprAST - Expression class for referencing a variable, like "a".
232250 : ExprAST(Loc), Name(Name) {}
233251 const std::string &getName() const { return Name; }
234252 Value *codegen() override;
253
235254 raw_ostream &dump(raw_ostream &out, int ind) override {
236255 return ExprAST::dump(out << Name, ind);
237256 }
246265 UnaryExprAST(char Opcode, std::unique_ptr Operand)
247266 : Opcode(Opcode), Operand(std::move(Operand)) {}
248267 Value *codegen() override;
268
249269 raw_ostream &dump(raw_ostream &out, int ind) override {
250270 ExprAST::dump(out << "unary" << Opcode, ind);
251271 Operand->dump(out, ind + 1);
263283 std::unique_ptr RHS)
264284 : ExprAST(Loc), Op(Op), LHS(std::move(LHS)), RHS(std::move(RHS)) {}
265285 Value *codegen() override;
286
266287 raw_ostream &dump(raw_ostream &out, int ind) override {
267288 ExprAST::dump(out << "binary" << Op, ind);
268289 LHS->dump(indent(out, ind) << "LHS:", ind + 1);
281302 std::vector> Args)
282303 : ExprAST(Loc), Callee(Callee), Args(std::move(Args)) {}
283304 Value *codegen() override;
305
284306 raw_ostream &dump(raw_ostream &out, int ind) override {
285307 ExprAST::dump(out << "call " << Callee, ind);
286308 for (const auto &Arg : Args)
299321 : ExprAST(Loc), Cond(std::move(Cond)), Then(std::move(Then)),
300322 Else(std::move(Else)) {}
301323 Value *codegen() override;
324
302325 raw_ostream &dump(raw_ostream &out, int ind) override {
303326 ExprAST::dump(out << "if", ind);
304327 Cond->dump(indent(out, ind) << "Cond:", ind + 1);
320343 : VarName(VarName), Start(std::move(Start)), End(std::move(End)),
321344 Step(std::move(Step)), Body(std::move(Body)) {}
322345 Value *codegen() override;
346
323347 raw_ostream &dump(raw_ostream &out, int ind) override {
324348 ExprAST::dump(out << "for", ind);
325349 Start->dump(indent(out, ind) << "Cond:", ind + 1);
341365 std::unique_ptr Body)
342366 : VarNames(std::move(VarNames)), Body(std::move(Body)) {}
343367 Value *codegen() override;
368
344369 raw_ostream &dump(raw_ostream &out, int ind) override {
345370 ExprAST::dump(out << "var", ind);
346371 for (const auto &NamedVar : VarNames)
391416 std::unique_ptr Body)
392417 : Proto(std::move(Proto)), Body(std::move(Body)) {}
393418 Function *codegen();
419
394420 raw_ostream &dump(raw_ostream &out, int ind) {
395421 indent(out, ind) << "FunctionAST\n";
396422 ++ind;
476502 getNextToken(); // eat (
477503 std::vector> Args;
478504 if (CurTok != ')') {
479 while (1) {
505 while (true) {
480506 if (auto Arg = ParseExpression())
481507 Args.push_back(std::move(Arg));
482508 else
586612 if (CurTok != tok_identifier)
587613 return LogError("expected identifier after var");
588614
589 while (1) {
615 while (true) {
590616 std::string Name = IdentifierStr;
591617 getNextToken(); // eat identifier.
592618
670696 static std::unique_ptr ParseBinOpRHS(int ExprPrec,
671697 std::unique_ptr LHS) {
672698 // If this is a binop, find its precedence.
673 while (1) {
699 while (true) {
674700 int TokPrec = GetTokPrecedence();
675701
676702 // If this is a binop that binds at least as tightly as the current binop,
886912 const std::string &VarName) {
887913 IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
888914 TheFunction->getEntryBlock().begin());
889 return TmpB.CreateAlloca(Type::getDoubleTy(TheContext), nullptr,
890 VarName.c_str());
915 return TmpB.CreateAlloca(Type::getDoubleTy(TheContext), nullptr, VarName);
891916 }
892917
893918 Value *NumberExprAST::codegen() {
13541379
13551380 /// top ::= definition | external | expression | ';'
13561381 static void MainLoop() {
1357 while (1) {
1382 while (true) {
13581383 switch (CurTok) {
13591384 case tok_eof:
13601385 return;
14291454 // Currently down as "fib.ks" as a filename since we're redirecting stdin
14301455 // but we'd like actual source locations.
14311456 KSDbgInfo.TheCU = DBuilder->createCompileUnit(
1432 dwarf::DW_LANG_C, "fib.ks", ".", "Kaleidoscope Compiler", 0, "", 0);
1457 dwarf::DW_LANG_C, "fib.ks", ".", "Kaleidoscope Compiler", false, "", 0);
14331458
14341459 // Run the main "interpreter loop" now.
14351460 MainLoop();
None #include "llvm/Analysis/Passes.h"
0 #include "llvm/ADT/APFloat.h"
1 #include "llvm/ADT/STLExtras.h"
2 #include "llvm/ExecutionEngine/ExecutionEngine.h"
3 #include "llvm/ExecutionEngine/RuntimeDyld.h"
4 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
15 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
6 #include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
27 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
8 #include "llvm/ExecutionEngine/Orc/JITSymbol.h"
39 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
410 #include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
511 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
612 #include "llvm/ExecutionEngine/Orc/OrcABISupport.h"
7 #include "llvm/IR/DataLayout.h"
13 #include "llvm/IR/BasicBlock.h"
14 #include "llvm/IR/Constant.h"
15 #include "llvm/IR/Constants.h"
816 #include "llvm/IR/DerivedTypes.h"
17 #include "llvm/IR/Function.h"
18 #include "llvm/IR/GlobalVariable.h"
19 #include "llvm/IR/Instructions.h"
920 #include "llvm/IR/IRBuilder.h"
10 #include "llvm/IR/LegacyPassManager.h"
1121 #include "llvm/IR/LLVMContext.h"
22 #include "llvm/IR/Mangler.h"
1223 #include "llvm/IR/Module.h"
24 #include "llvm/IR/Type.h"
1325 #include "llvm/IR/Verifier.h"
26 #include "llvm/Support/raw_ostream.h"
1427 #include "llvm/Support/TargetSelect.h"
15 #include "llvm/Transforms/Scalar.h"
28 #include "llvm/Target/TargetMachine.h"
29 #include
1630 #include
31 #include
32 #include
33 #include
1734 #include
1835 #include
1936 #include
37 #include
2038 #include
2139 #include
40 #include
2241 #include
2342
2443 using namespace llvm;
303322 getNextToken(); // eat (
304323 std::vector> Args;
305324 if (CurTok != ')') {
306 while (1) {
325 while (true) {
307326 auto Arg = ParseExpression();
308327 if (!Arg) return nullptr;
309328 Args.push_back(std::move(Arg));
429448 if (CurTok != tok_identifier)
430449 return ErrorU("expected identifier after var");
431450
432 while (1) {
451 while (true) {
433452 std::string Name = IdentifierStr;
434453 getNextToken(); // eat identifier.
435454
505524 static std::unique_ptr ParseBinOpRHS(int ExprPrec,
506525 std::unique_ptr LHS) {
507526 // If this is a binop, find its precedence.
508 while (1) {
527 while (true) {
509528 int TokPrec = GetTokPrecedence();
510529
511530 // If this is a binop that binds at least as tightly as the current binop,
687706 TargetMachine& getTarget() { return *TM; }
688707 void addPrototypeAST(std::unique_ptr P);
689708 PrototypeAST* getPrototypeAST(const std::string &Name);
709
690710 private:
691711 typedef std::map> PrototypeMap;
692712
709729
710730 class IRGenContext {
711731 public:
712
713732 IRGenContext(SessionContext &S)
714733 : Session(S),
715734 M(new Module(GenerateUniqueName("jit_module_"),
726745 Function* getPrototype(const std::string &Name);
727746
728747 std::map NamedValues;
748
729749 private:
730750 SessionContext &Session;
731751 std::unique_ptr M;
745765 static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
746766 const std::string &VarName) {
747767 IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
748 TheFunction->getEntryBlock().begin());
768 TheFunction->getEntryBlock().begin());
749769 return TmpB.CreateAlloca(Type::getDoubleTy(TheFunction->getContext()),
750 nullptr, VarName.c_str());
770 nullptr, VarName);
751771 }
752772
753773 Value *NumberExprAST::IRGen(IRGenContext &C) const {
12261246 }
12271247
12281248 private:
1229
12301249 // This method searches the FunctionDefs map for a definition of 'Name'. If it
12311250 // finds one it generates a stub for it and returns the address of the stub.
12321251 RuntimeDyld::SymbolInfo searchFunctionASTs(const std::string &Name) {
13701389 SessionContext S(TheContext);
13711390 KaleidoscopeJIT J(S);
13721391
1373 while (1) {
1392 while (true) {
13741393 switch (CurTok) {
13751394 case tok_eof: return;
13761395 case ';': getNextToken(); continue; // ignore top-level semicolons.
None #include "llvm/Analysis/Passes.h"
0 #include "llvm/ADT/APFloat.h"
1 #include "llvm/ADT/STLExtras.h"
2 #include "llvm/ExecutionEngine/ExecutionEngine.h"
3 #include "llvm/ExecutionEngine/RuntimeDyld.h"
4 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
15 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
26 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
7 #include "llvm/ExecutionEngine/Orc/JITSymbol.h"
38 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
4 #include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
59 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
10 #include "llvm/IR/BasicBlock.h"
11 #include "llvm/IR/Constant.h"
12 #include "llvm/IR/Constants.h"
613 #include "llvm/IR/DataLayout.h"
714 #include "llvm/IR/DerivedTypes.h"
15 #include "llvm/IR/Function.h"
16 #include "llvm/IR/Instructions.h"
817 #include "llvm/IR/IRBuilder.h"
9 #include "llvm/IR/LegacyPassManager.h"
1018 #include "llvm/IR/LLVMContext.h"
19 #include "llvm/IR/Mangler.h"
1120 #include "llvm/IR/Module.h"
21 #include "llvm/IR/Type.h"
1222 #include "llvm/IR/Verifier.h"
23 #include "llvm/Support/raw_ostream.h"
1324 #include "llvm/Support/TargetSelect.h"
14 #include "llvm/Transforms/Scalar.h"
25 #include "llvm/Target/TargetMachine.h"
26 #include
1527 #include
28 #include
29 #include
30 #include
1631 #include
1732 #include
1833 #include
34 #include
1935 #include
2036 #include
37 #include
2138 #include
2239
2340 using namespace llvm;
176193 IfExprAST(std::unique_ptr Cond, std::unique_ptr Then,
177194 std::unique_ptr Else)
178195 : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
196
179197 Value *IRGen(IRGenContext &C) const override;
180198
181199 std::unique_ptr Cond, Then, Else;
302320 getNextToken(); // eat (
303321 std::vector> Args;
304322 if (CurTok != ')') {
305 while (1) {
323 while (true) {
306324 auto Arg = ParseExpression();
307325 if (!Arg) return nullptr;
308326 Args.push_back(std::move(Arg));
428446 if (CurTok != tok_identifier)
429447 return ErrorU("expected identifier after var");
430448
431 while (1) {
449 while (true) {
432450 std::string Name = IdentifierStr;
433451 getNextToken(); // eat identifier.
434452
504522 static std::unique_ptr ParseBinOpRHS(int ExprPrec,
505523 std::unique_ptr LHS) {
506524 // If this is a binop, find its precedence.
507 while (1) {
525 while (true) {
508526 int TokPrec = GetTokPrecedence();
509527
510528 // If this is a binop that binds at least as tightly as the current binop,
686704 TargetMachine& getTarget() { return *TM; }
687705 void addPrototypeAST(std::unique_ptr P);
688706 PrototypeAST* getPrototypeAST(const std::string &Name);
707
689708 private:
690709 typedef std::map> PrototypeMap;
691710
708727
709728 class IRGenContext {
710729 public:
711
712730 IRGenContext(SessionContext &S)
713731 : Session(S),
714732 M(new Module(GenerateUniqueName("jit_module_"),
725743 Function* getPrototype(const std::string &Name);
726744
727745 std::map NamedValues;
746
728747 private:
729748 SessionContext &Session;
730749 std::unique_ptr M;
744763 static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
745764 const std::string &VarName) {
746765 IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
747 TheFunction->getEntryBlock().begin());
766 TheFunction->getEntryBlock().begin());
748767 return TmpB.CreateAlloca(Type::getDoubleTy(TheFunction->getContext()),
749 nullptr, VarName.c_str());
768 nullptr, VarName);
750769 }
751770
752771 Value *NumberExprAST::IRGen(IRGenContext &C) const {
12651284 SessionContext S(TheContext);
12661285 KaleidoscopeJIT J(S);
12671286
1268 while (1) {
1287 while (true) {
12691288 switch (CurTok) {
12701289 case tok_eof: return;
12711290 case ';': getNextToken(); continue; // ignore top-level semicolons.
None #include "llvm/Analysis/Passes.h"
0 #include "llvm/ADT/APFloat.h"
1 #include "llvm/ADT/STLExtras.h"
2 #include "llvm/ExecutionEngine/ExecutionEngine.h"
3 #include "llvm/ExecutionEngine/RuntimeDyld.h"
4 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
15 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
26 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
7 #include "llvm/ExecutionEngine/Orc/JITSymbol.h"
38 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
49 #include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
510 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
11 #include "llvm/IR/BasicBlock.h"
12 #include "llvm/IR/Constant.h"
13 #include "llvm/IR/Constants.h"
614 #include "llvm/IR/DataLayout.h"
715 #include "llvm/IR/DerivedTypes.h"
16 #include "llvm/IR/Function.h"
17 #include "llvm/IR/Instructions.h"
818 #include "llvm/IR/IRBuilder.h"
9 #include "llvm/IR/LegacyPassManager.h"
1019 #include "llvm/IR/LLVMContext.h"
20 #include "llvm/IR/Mangler.h"
1121 #include "llvm/IR/Module.h"
22 #include "llvm/IR/Type.h"
1223 #include "llvm/IR/Verifier.h"
24 #include "llvm/Support/raw_ostream.h"
1325 #include "llvm/Support/TargetSelect.h"
14 #include "llvm/Transforms/Scalar.h"
26 #include "llvm/Target/TargetMachine.h"
27 #include
1528 #include
29 #include
30 #include
31 #include
1632 #include
1733 #include
1834 #include
35 #include
1936 #include
2037 #include
38 #include
2139 #include
2240
2341 using namespace llvm;
176194 IfExprAST(std::unique_ptr Cond, std::unique_ptr Then,
177195 std::unique_ptr Else)
178196 : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
197
179198 Value *IRGen(IRGenContext &C) const override;
180199
181200 std::unique_ptr Cond, Then, Else;
302321 getNextToken(); // eat (
303322 std::vector> Args;
304323 if (CurTok != ')') {
305 while (1) {
324 while (true) {
306325 auto Arg = ParseExpression();
307326 if (!Arg) return nullptr;
308327 Args.push_back(std::move(Arg));
428447 if (CurTok != tok_identifier)
429448 return ErrorU("expected identifier after var");
430449
431 while (1) {
450 while (true) {
432451 std::string Name = IdentifierStr;
433452 getNextToken(); // eat identifier.
434453
504523 static std::unique_ptr ParseBinOpRHS(int ExprPrec,
505524 std::unique_ptr LHS) {
506525 // If this is a binop, find its precedence.
507 while (1) {
526 while (true) {
508527 int TokPrec = GetTokPrecedence();
509528
510529 // If this is a binop that binds at least as tightly as the current binop,
686705 TargetMachine& getTarget() { return *TM; }
687706 void addPrototypeAST(std::unique_ptr P);
688707 PrototypeAST* getPrototypeAST(const std::string &Name);
708
689709 private:
690710 typedef std::map> PrototypeMap;
691711
708728
709729 class IRGenContext {
710730 public:
711
712731 IRGenContext(SessionContext &S)
713732 : Session(S),
714733 M(new Module(GenerateUniqueName("jit_module_"),
725744 Function* getPrototype(const std::string &Name);
726745
727746 std::map NamedValues;
747
728748 private:
729749 SessionContext &Session;
730750 std::unique_ptr M;
744764 static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
745765 const std::string &VarName) {
746766 IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
747 TheFunction->getEntryBlock().begin());
767 TheFunction->getEntryBlock().begin());
748768 return TmpB.CreateAlloca(Type::getDoubleTy(TheFunction->getContext()),
749 nullptr, VarName.c_str());
769 nullptr, VarName);
750770 }
751771
752772 Value *NumberExprAST::IRGen(IRGenContext &C) const {
12691289 SessionContext S(TheContext);
12701290 KaleidoscopeJIT J(S);
12711291
1272 while (1) {
1292 while (true) {
12731293 switch (CurTok) {
12741294 case tok_eof: return;
12751295 case ';': getNextToken(); continue; // ignore top-level semicolons.
None #include "llvm/Analysis/Passes.h"
0 #include "llvm/ADT/APFloat.h"
1 #include "llvm/ADT/STLExtras.h"
2 #include "llvm/ExecutionEngine/ExecutionEngine.h"
3 #include "llvm/ExecutionEngine/RuntimeDyld.h"
4 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
15 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
26 #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
7 #include "llvm/ExecutionEngine/Orc/JITSymbol.h"
38 #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
49 #include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
510 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
6 #include "llvm/IR/DataLayout.h"
11 #include "llvm/IR/BasicBlock.h"
12 #include "llvm/IR/Constant.h"
13 #include "llvm/IR/Constants.h"
714 #include "llvm/IR/DerivedTypes.h"
15 #include "llvm/IR/Function.h"
16 #include "llvm/IR/Instructions.h"
817 #include "llvm/IR/IRBuilder.h"
9 #include "llvm/IR/LegacyPassManager.h"
1018 #include "llvm/IR/LLVMContext.h"
19 #include "llvm/IR/Mangler.h"
1120 #include "llvm/IR/Module.h"
21 #include "llvm/IR/Type.h"
1222 #include "llvm/IR/Verifier.h"
23 #include "llvm/Support/raw_ostream.h"
1324 #include "llvm/Support/TargetSelect.h"
14 #include "llvm/Transforms/Scalar.h"
25 #include "llvm/Target/TargetMachine.h"
26 #include
1527 #include
28 #include
29 #include
30 #include
1631 #include
1732 #include
1833 #include
34 #include
1935 #include
2036 #include
37 #include
2138 #include
2239
2340 using namespace llvm;
176193 IfExprAST(std::unique_ptr Cond, std::unique_ptr Then,
177194 std::unique_ptr Else)
178195 : Cond(std::move(Cond)), Then(std::move(Then)), Else(std::move(Else)) {}
196
179197 Value *IRGen(IRGenContext &C) const override;
180198
181199 std::unique_ptr Cond, Then, Else;
302320 getNextToken(); // eat (
303321 std::vector> Args;
304322 if (CurTok != ')') {
305 while (1) {
323 while (true) {
306324 auto Arg = ParseExpression();
307325 if (!Arg) return nullptr;
308326 Args.push_back(std::move(Arg));
428446 if (CurTok != tok_identifier)
429447 return ErrorU("expected identifier after var");
430448
431 while (1) {
449 while (true) {
432450 std::string Name = IdentifierStr;
433451 getNextToken(); // eat identifier.
434452
504522 static std::unique_ptr ParseBinOpRHS(int ExprPrec,
505523 std::unique_ptr LHS) {
506524 // If this is a binop, find its precedence.
507 while (1) {
525 while (true) {
508526 int TokPrec = GetTokPrecedence();
509527
510528 // If this is a binop that binds at least as tightly as the current binop,
686704 TargetMachine& getTarget() { return *TM; }
687705 void addPrototypeAST(std::unique_ptr P);
688706 PrototypeAST* getPrototypeAST(const std::string &Name);
707
689708 private:
690709 typedef std::map> PrototypeMap;
691710
708727
709728 class IRGenContext {
710729 public:
711
712730 IRGenContext(SessionContext &S)
713731 : Session(S),
714732 M(new Module(GenerateUniqueName("jit_module_"),
725743 Function* getPrototype(const std::string &Name);
726744
727745 std::map NamedValues;
746
728747 private:
729748 SessionContext &Session;
730749 std::unique_ptr M;
744763 static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
745764 const std::string &VarName) {
746765 IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
747 TheFunction->getEntryBlock().begin());
766 TheFunction->getEntryBlock().begin());
748767 return TmpB.CreateAlloca(Type::getDoubleTy(TheFunction->getContext()),
749 nullptr, VarName.c_str());
768 nullptr, VarName);
750769 }
751770
752771 Value *NumberExprAST::IRGen(IRGenContext &C) const {
12151234 }
12161235
12171236 private:
1218
12191237 // This method searches the FunctionDefs map for a definition of 'Name'. If it
12201238 // finds one it generates a stub for it and returns the address of the stub.
12211239 RuntimeDyld::SymbolInfo searchFunctionASTs(const std::string &Name) {
13001318 SessionContext S(TheContext);
13011319 KaleidoscopeJIT J(S);
13021320
1303 while (1) {
1321 while (true) {
13041322 switch (CurTok) {
13051323 case tok_eof: return;
13061324 case ';': getNextToken(); continue; // ignore top-level semicolons.