diff options
author | Pirama Arumuga Nainar <pirama@google.com> | 2015-05-06 11:46:36 -0700 |
---|---|---|
committer | Pirama Arumuga Nainar <pirama@google.com> | 2015-05-18 10:52:30 -0700 |
commit | 2c3e0051c31c3f5b2328b447eadf1cf9c4427442 (patch) | |
tree | c0104029af14e9f47c2ef58ca60e6137691f3c9b /examples/Kaleidoscope/Chapter8 | |
parent | e1bc145815f4334641be19f1c45ecf85d25b6e5a (diff) | |
download | external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.zip external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.tar.gz external_llvm-2c3e0051c31c3f5b2328b447eadf1cf9c4427442.tar.bz2 |
Update aosp/master LLVM for rebase to r235153
Change-Id: I9bf53792f9fc30570e81a8d80d296c681d005ea7
(cherry picked from commit 0c7f116bb6950ef819323d855415b2f2b0aad987)
Diffstat (limited to 'examples/Kaleidoscope/Chapter8')
-rw-r--r-- | examples/Kaleidoscope/Chapter8/CMakeLists.txt | 3 | ||||
-rw-r--r-- | examples/Kaleidoscope/Chapter8/toy.cpp | 62 |
2 files changed, 34 insertions, 31 deletions
diff --git a/examples/Kaleidoscope/Chapter8/CMakeLists.txt b/examples/Kaleidoscope/Chapter8/CMakeLists.txt index 42882e9..90c79c0 100644 --- a/examples/Kaleidoscope/Chapter8/CMakeLists.txt +++ b/examples/Kaleidoscope/Chapter8/CMakeLists.txt @@ -2,12 +2,15 @@ set(LLVM_LINK_COMPONENTS Core ExecutionEngine MCJIT + RuntimeDyld Support native ) set(LLVM_REQUIRES_RTTI 1) +set(LLVM_BUILD_EXAMPLES OFF) + add_kaleidoscope_chapter(Kaleidoscope-Ch8 toy.cpp ) diff --git a/examples/Kaleidoscope/Chapter8/toy.cpp b/examples/Kaleidoscope/Chapter8/toy.cpp index 39b6a65..c7e096c 100644 --- a/examples/Kaleidoscope/Chapter8/toy.cpp +++ b/examples/Kaleidoscope/Chapter8/toy.cpp @@ -221,10 +221,10 @@ class NumberExprAST : public ExprAST { public: NumberExprAST(double val) : Val(val) {} - virtual std::ostream &dump(std::ostream &out, int ind) { + std::ostream &dump(std::ostream &out, int ind) override { return ExprAST::dump(out << Val, ind); } - virtual Value *Codegen(); + Value *Codegen() override; }; /// VariableExprAST - Expression class for referencing a variable, like "a". @@ -235,10 +235,10 @@ public: VariableExprAST(SourceLocation Loc, const std::string &name) : ExprAST(Loc), Name(name) {} const std::string &getName() const { return Name; } - virtual std::ostream &dump(std::ostream &out, int ind) { + std::ostream &dump(std::ostream &out, int ind) override { return ExprAST::dump(out << Name, ind); } - virtual Value *Codegen(); + Value *Codegen() override; }; /// UnaryExprAST - Expression class for a unary operator. @@ -249,12 +249,12 @@ class UnaryExprAST : public ExprAST { public: UnaryExprAST(char opcode, ExprAST *operand) : Opcode(opcode), Operand(operand) {} - virtual std::ostream &dump(std::ostream &out, int ind) { + std::ostream &dump(std::ostream &out, int ind) override { ExprAST::dump(out << "unary" << Opcode, ind); Operand->dump(out, ind + 1); return out; } - virtual Value *Codegen(); + Value *Codegen() override; }; /// BinaryExprAST - Expression class for a binary operator. @@ -265,13 +265,13 @@ class BinaryExprAST : public ExprAST { public: BinaryExprAST(SourceLocation Loc, char op, ExprAST *lhs, ExprAST *rhs) : ExprAST(Loc), Op(op), LHS(lhs), RHS(rhs) {} - virtual std::ostream &dump(std::ostream &out, int ind) { + std::ostream &dump(std::ostream &out, int ind) override { ExprAST::dump(out << "binary" << Op, ind); LHS->dump(indent(out, ind) << "LHS:", ind + 1); RHS->dump(indent(out, ind) << "RHS:", ind + 1); return out; } - virtual Value *Codegen(); + Value *Codegen() override; }; /// CallExprAST - Expression class for function calls. @@ -283,13 +283,13 @@ public: CallExprAST(SourceLocation Loc, const std::string &callee, std::vector<ExprAST *> &args) : ExprAST(Loc), Callee(callee), Args(args) {} - virtual std::ostream &dump(std::ostream &out, int ind) { + std::ostream &dump(std::ostream &out, int ind) override { ExprAST::dump(out << "call " << Callee, ind); for (ExprAST *Arg : Args) Arg->dump(indent(out, ind + 1), ind + 1); return out; } - virtual Value *Codegen(); + Value *Codegen() override; }; /// IfExprAST - Expression class for if/then/else. @@ -299,14 +299,14 @@ class IfExprAST : public ExprAST { public: IfExprAST(SourceLocation Loc, ExprAST *cond, ExprAST *then, ExprAST *_else) : ExprAST(Loc), Cond(cond), Then(then), Else(_else) {} - virtual std::ostream &dump(std::ostream &out, int ind) { + std::ostream &dump(std::ostream &out, int ind) override { ExprAST::dump(out << "if", ind); Cond->dump(indent(out, ind) << "Cond:", ind + 1); Then->dump(indent(out, ind) << "Then:", ind + 1); Else->dump(indent(out, ind) << "Else:", ind + 1); return out; } - virtual Value *Codegen(); + Value *Codegen() override; }; /// ForExprAST - Expression class for for/in. @@ -318,7 +318,7 @@ public: ForExprAST(const std::string &varname, ExprAST *start, ExprAST *end, ExprAST *step, ExprAST *body) : VarName(varname), Start(start), End(end), Step(step), Body(body) {} - virtual std::ostream &dump(std::ostream &out, int ind) { + std::ostream &dump(std::ostream &out, int ind) override { ExprAST::dump(out << "for", ind); Start->dump(indent(out, ind) << "Cond:", ind + 1); End->dump(indent(out, ind) << "End:", ind + 1); @@ -326,7 +326,7 @@ public: Body->dump(indent(out, ind) << "Body:", ind + 1); return out; } - virtual Value *Codegen(); + Value *Codegen() override; }; /// VarExprAST - Expression class for var/in @@ -339,14 +339,14 @@ public: ExprAST *body) : VarNames(varnames), Body(body) {} - virtual std::ostream &dump(std::ostream &out, int ind) { + std::ostream &dump(std::ostream &out, int ind) override { ExprAST::dump(out << "var", ind); for (const auto &NamedVar : VarNames) NamedVar.second->dump(indent(out, ind) << NamedVar.first << ':', ind + 1); Body->dump(indent(out, ind) << "Body:", ind + 1); return out; } - virtual Value *Codegen(); + Value *Codegen() override; }; /// PrototypeAST - This class represents the "prototype" for a function, @@ -817,7 +817,7 @@ static PrototypeAST *ParseExtern() { static DIBuilder *DBuilder; DIType DebugInfo::getDoubleTy() { - if (DblTy.isValid()) + if (DblTy) return DblTy; DblTy = DBuilder->createBasicType("double", 64, 64, dwarf::DW_ATE_float); @@ -827,16 +827,16 @@ DIType DebugInfo::getDoubleTy() { void DebugInfo::emitLocation(ExprAST *AST) { if (!AST) return Builder.SetCurrentDebugLocation(DebugLoc()); - DIScope *Scope; + MDScope *Scope; if (LexicalBlocks.empty()) - Scope = &TheCU; + Scope = TheCU; else - Scope = LexicalBlocks.back(); + Scope = *LexicalBlocks.back(); Builder.SetCurrentDebugLocation( - DebugLoc::get(AST->getLine(), AST->getCol(), DIScope(*Scope))); + DebugLoc::get(AST->getLine(), AST->getCol(), Scope)); } -static DICompositeType CreateFunctionType(unsigned NumArgs, DIFile Unit) { +static MDSubroutineType *CreateFunctionType(unsigned NumArgs, DIFile Unit) { SmallVector<Metadata *, 8> EltTys; DIType DblTy = KSDbgInfo.getDoubleTy(); @@ -1224,15 +1224,15 @@ Function *PrototypeAST::Codegen() { AI->setName(Args[Idx]); // Create a subprogram DIE for this function. - DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(), - KSDbgInfo.TheCU.getDirectory()); - DIDescriptor FContext(Unit); + DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU->getFilename(), + KSDbgInfo.TheCU->getDirectory()); + MDScope *FContext = Unit; unsigned LineNo = Line; unsigned ScopeLine = Line; DISubprogram SP = DBuilder->createFunction( FContext, Name, StringRef(), Unit, LineNo, CreateFunctionType(Args.size(), Unit), false /* internal linkage */, - true /* definition */, ScopeLine, DIDescriptor::FlagPrototyped, false, F); + true /* definition */, ScopeLine, DebugNode::FlagPrototyped, false, F); KSDbgInfo.FnScopeMap[this] = SP; return F; @@ -1248,15 +1248,15 @@ void PrototypeAST::CreateArgumentAllocas(Function *F) { // Create a debug descriptor for the variable. DIScope *Scope = KSDbgInfo.LexicalBlocks.back(); - DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(), - KSDbgInfo.TheCU.getDirectory()); + DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU->getFilename(), + KSDbgInfo.TheCU->getDirectory()); DIVariable D = DBuilder->createLocalVariable(dwarf::DW_TAG_arg_variable, *Scope, Args[Idx], Unit, Line, KSDbgInfo.getDoubleTy(), Idx); - Instruction *Call = DBuilder->insertDeclare( - Alloca, D, DBuilder->createExpression(), Builder.GetInsertBlock()); - Call->setDebugLoc(DebugLoc::get(Line, 0, *Scope)); + DBuilder->insertDeclare(Alloca, D, DBuilder->createExpression(), + DebugLoc::get(Line, 0, *Scope), + Builder.GetInsertBlock()); // Store the initial value into the alloca. Builder.CreateStore(AI, Alloca); |