X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2Ftutorial%2FLangImpl6.html;h=39febee653924252f130c6c32f0c64fb5df80ece;hb=6fa1c051dc515b6fd1f9a26ac12fed985469bff5;hp=33f4adbdebb016df1da2745bb538a48852a2cd8d;hpb=61ad449be85ad31c46206caedc4a914d82695ceb;p=oota-llvm.git diff --git a/docs/tutorial/LangImpl6.html b/docs/tutorial/LangImpl6.html index 33f4adbdebb..39febee6539 100644 --- a/docs/tutorial/LangImpl6.html +++ b/docs/tutorial/LangImpl6.html @@ -321,7 +321,7 @@ Function *FunctionAST::Codegen() { BinopPrecedence[Proto->getOperatorName()] = Proto->getBinaryPrecedence(); // Create a new basic block to start insertion into. - BasicBlock *BB = new BasicBlock("entry", TheFunction); + BasicBlock *BB = BasicBlock::Create("entry", TheFunction); Builder.SetInsertPoint(BB); if (Value *RetVal = Body->Codegen()) { @@ -827,7 +827,7 @@ if/then/else and for expressions.. To build this example, use: #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Scalar.h" -#include "llvm/Support/LLVMBuilder.h" +#include "llvm/Support/IRBuilder.h" #include <cstdio> #include <string> #include <map> @@ -899,7 +899,7 @@ static int gettok() { if (LastChar == '#') { // Comment until end of line. do LastChar = getchar(); - while (LastChar != EOF && LastChar != '\n' & LastChar != '\r'); + while (LastChar != EOF && LastChar != '\n' && LastChar != '\r'); if (LastChar != EOF) return gettok(); @@ -1085,7 +1085,7 @@ static ExprAST *ParseIdentifierExpr() { if (CurTok == ')') break; if (CurTok != ',') - return Error("Expected ')'"); + return Error("Expected ')' or ',' in argument list"); getNextToken(); } } @@ -1357,14 +1357,14 @@ static PrototypeAST *ParseExtern() { //===----------------------------------------------------------------------===// static Module *TheModule; -static LLVMFoldingBuilder Builder; +static IRBuilder Builder; static std::map<std::string, Value*> NamedValues; static FunctionPassManager *TheFPM; Value *ErrorV(const char *Str) { Error(Str); return 0; } Value *NumberExprAST::Codegen() { - return ConstantFP::get(Type::DoubleTy, APFloat(Val)); + return ConstantFP::get(APFloat(Val)); } Value *VariableExprAST::Codegen() { @@ -1435,16 +1435,16 @@ Value *IfExprAST::Codegen() { // Convert condition to a bool by comparing equal to 0.0. CondV = Builder.CreateFCmpONE(CondV, - ConstantFP::get(Type::DoubleTy, APFloat(0.0)), + ConstantFP::get(APFloat(0.0)), "ifcond"); Function *TheFunction = Builder.GetInsertBlock()->getParent(); // Create blocks for the then and else cases. Insert the 'then' block at the // end of the function. - BasicBlock *ThenBB = new BasicBlock("then", TheFunction); - BasicBlock *ElseBB = new BasicBlock("else"); - BasicBlock *MergeBB = new BasicBlock("ifcont"); + BasicBlock *ThenBB = BasicBlock::Create("then", TheFunction); + BasicBlock *ElseBB = BasicBlock::Create("else"); + BasicBlock *MergeBB = BasicBlock::Create("ifcont"); Builder.CreateCondBr(CondV, ThenBB, ElseBB); @@ -1504,7 +1504,7 @@ Value *ForExprAST::Codegen() { // block. Function *TheFunction = Builder.GetInsertBlock()->getParent(); BasicBlock *PreheaderBB = Builder.GetInsertBlock(); - BasicBlock *LoopBB = new BasicBlock("loop", TheFunction); + BasicBlock *LoopBB = BasicBlock::Create("loop", TheFunction); // Insert an explicit fall through from the current block to the LoopBB. Builder.CreateBr(LoopBB); @@ -1534,7 +1534,7 @@ Value *ForExprAST::Codegen() { if (StepVal == 0) return 0; } else { // If not specified, use 1.0. - StepVal = ConstantFP::get(Type::DoubleTy, APFloat(1.0)); + StepVal = ConstantFP::get(APFloat(1.0)); } Value *NextVar = Builder.CreateAdd(Variable, StepVal, "nextvar"); @@ -1545,12 +1545,12 @@ Value *ForExprAST::Codegen() { // Convert condition to a bool by comparing equal to 0.0. EndCond = Builder.CreateFCmpONE(EndCond, - ConstantFP::get(Type::DoubleTy, APFloat(0.0)), + ConstantFP::get(APFloat(0.0)), "loopcond"); // Create the "after loop" block and insert it. BasicBlock *LoopEndBB = Builder.GetInsertBlock(); - BasicBlock *AfterBB = new BasicBlock("afterloop", TheFunction); + BasicBlock *AfterBB = BasicBlock::Create("afterloop", TheFunction); // Insert the conditional branch into the end of LoopEndBB. Builder.CreateCondBr(EndCond, LoopBB, AfterBB); @@ -1577,7 +1577,7 @@ Function *PrototypeAST::Codegen() { std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false); - Function *F = new Function(FT, Function::ExternalLinkage, Name, TheModule); + Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); // If F conflicted, there was already something named 'Name'. If it has a // body, don't allow redefinition or reextern. @@ -1624,7 +1624,7 @@ Function *FunctionAST::Codegen() { BinopPrecedence[Proto->getOperatorName()] = Proto->getBinaryPrecedence(); // Create a new basic block to start insertion into. - BasicBlock *BB = new BasicBlock("entry", TheFunction); + BasicBlock *BB = BasicBlock::Create("entry", TheFunction); Builder.SetInsertPoint(BB); if (Value *RetVal = Body->Codegen()) { @@ -1774,16 +1774,17 @@ int main() { MainLoop(); TheFPM = 0; - } // Free module provider and pass manager. - - - // Print out all of the generated code. - TheModule->dump(); + + // Print out all of the generated code. + TheModule->dump(); + } // Free module provider (and thus the module) and pass manager. + return 0; } +Next: Extending the language: mutable variables / SSA construction