From e6819aeee0ccd91d71397c7872aa86b228b6db84 Mon Sep 17 00:00:00 2001
From: Chris Lattner
Date: Tue, 6 Nov 2007 01:39:12 +0000
Subject: [PATCH] fixes from Ryan Brown.
llvm-svn: 43747
---
llvm/docs/tutorial/LangImpl1.html | 2 +-
llvm/docs/tutorial/LangImpl2.html | 36 +++++++++++++++++--------------
llvm/docs/tutorial/LangImpl3.html | 22 ++++++++++---------
llvm/docs/tutorial/LangImpl4.html | 20 +++++++++--------
llvm/docs/tutorial/LangImpl5.html | 11 +++++-----
llvm/docs/tutorial/LangImpl6.html | 4 ++--
llvm/docs/tutorial/LangImpl7.html | 14 ++++++------
7 files changed, 59 insertions(+), 50 deletions(-)
diff --git a/llvm/docs/tutorial/LangImpl1.html b/llvm/docs/tutorial/LangImpl1.html
index f57848b8e33d..2ce59b98ebd9 100644
--- a/llvm/docs/tutorial/LangImpl1.html
+++ b/llvm/docs/tutorial/LangImpl1.html
@@ -232,7 +232,7 @@ if you typed in "1.23". Feel free to extend it :). Next we handle comments:
-We handle comments by skipping to the end of the line and then returning the
+
We handle comments by skipping to the end of the line and then return the
next comment. Finally, if the input doesn't match one of the above cases, it is
either an operator character like '+' or the end of the file. These are handled with
this code:
diff --git a/llvm/docs/tutorial/LangImpl2.html b/llvm/docs/tutorial/LangImpl2.html
index 7eed8d644b29..b8b611288416 100644
--- a/llvm/docs/tutorial/LangImpl2.html
+++ b/llvm/docs/tutorial/LangImpl2.html
@@ -325,16 +325,18 @@ static ExprAST *ParseIdentifierExpr() {
// Call.
getNextToken(); // eat (
std::vector<ExprAST*> Args;
- while (1) {
- ExprAST *Arg = ParseExpression();
- if (!Arg) return 0;
- Args.push_back(Arg);
+ if (CurTok != ')') {
+ while (1) {
+ ExprAST *Arg = ParseExpression();
+ if (!Arg) return 0;
+ Args.push_back(Arg);
- if (CurTok == ')') break;
+ if (CurTok == ')') break;
- if (CurTok != ',')
- return Error("Expected ')'");
- getNextToken();
+ if (CurTok != ',')
+ return Error("Expected ')'");
+ getNextToken();
+ }
}
// Eat the ')'.
@@ -985,16 +987,18 @@ static ExprAST *ParseIdentifierExpr() {
// Call.
getNextToken(); // eat (
std::vector<ExprAST*> Args;
- while (1) {
- ExprAST *Arg = ParseExpression();
- if (!Arg) return 0;
- Args.push_back(Arg);
+ if (CurTok != ')') {
+ while (1) {
+ ExprAST *Arg = ParseExpression();
+ if (!Arg) return 0;
+ Args.push_back(Arg);
- if (CurTok == ')') break;
+ if (CurTok == ')') break;
- if (CurTok != ',')
- return Error("Expected ')'");
- getNextToken();
+ if (CurTok != ',')
+ return Error("Expected ')'");
+ getNextToken();
+ }
}
// Eat the ')'.
diff --git a/llvm/docs/tutorial/LangImpl3.html b/llvm/docs/tutorial/LangImpl3.html
index 22987e552bf4..5e6d2c82f75c 100644
--- a/llvm/docs/tutorial/LangImpl3.html
+++ b/llvm/docs/tutorial/LangImpl3.html
@@ -192,7 +192,7 @@ Value *BinaryExprAST::Codegen() {
case '-': return Builder.CreateSub(L, R, "subtmp");
case '*': return Builder.CreateMul(L, R, "multmp");
case '<':
- L = Builder.CreateFCmpULT(L, R, "multmp");
+ L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
default: return ErrorV("invalid binary operator");
@@ -860,16 +860,18 @@ static ExprAST *ParseIdentifierExpr() {
// Call.
getNextToken(); // eat (
std::vector<ExprAST*> Args;
- while (1) {
- ExprAST *Arg = ParseExpression();
- if (!Arg) return 0;
- Args.push_back(Arg);
+ if (CurTok != ')') {
+ while (1) {
+ ExprAST *Arg = ParseExpression();
+ if (!Arg) return 0;
+ Args.push_back(Arg);
- if (CurTok == ')') break;
+ if (CurTok == ')') break;
- if (CurTok != ',')
- return Error("Expected ')'");
- getNextToken();
+ if (CurTok != ',')
+ return Error("Expected ')'");
+ getNextToken();
+ }
}
// Eat the ')'.
@@ -1034,7 +1036,7 @@ Value *BinaryExprAST::Codegen() {
case '-': return Builder.CreateSub(L, R, "subtmp");
case '*': return Builder.CreateMul(L, R, "multmp");
case '<':
- L = Builder.CreateFCmpULT(L, R, "multmp");
+ L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
default: return ErrorV("invalid binary operator");
diff --git a/llvm/docs/tutorial/LangImpl4.html b/llvm/docs/tutorial/LangImpl4.html
index 7b02faa6141d..11a6cc0177f7 100644
--- a/llvm/docs/tutorial/LangImpl4.html
+++ b/llvm/docs/tutorial/LangImpl4.html
@@ -715,16 +715,18 @@ static ExprAST *ParseIdentifierExpr() {
// Call.
getNextToken(); // eat (
std::vector<ExprAST*> Args;
- while (1) {
- ExprAST *Arg = ParseExpression();
- if (!Arg) return 0;
- Args.push_back(Arg);
+ if (CurTok != ')') {
+ while (1) {
+ ExprAST *Arg = ParseExpression();
+ if (!Arg) return 0;
+ Args.push_back(Arg);
- if (CurTok == ')') break;
+ if (CurTok == ')') break;
- if (CurTok != ',')
- return Error("Expected ')'");
- getNextToken();
+ if (CurTok != ',')
+ return Error("Expected ')'");
+ getNextToken();
+ }
}
// Eat the ')'.
@@ -890,7 +892,7 @@ Value *BinaryExprAST::Codegen() {
case '-': return Builder.CreateSub(L, R, "subtmp");
case '*': return Builder.CreateMul(L, R, "multmp");
case '<':
- L = Builder.CreateFCmpULT(L, R, "multmp");
+ L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
default: return ErrorV("invalid binary operator");
diff --git a/llvm/docs/tutorial/LangImpl5.html b/llvm/docs/tutorial/LangImpl5.html
index acd60456c816..be82b2dab567 100644
--- a/llvm/docs/tutorial/LangImpl5.html
+++ b/llvm/docs/tutorial/LangImpl5.html
@@ -319,7 +319,7 @@ block. In this case, if control comes in from the "then" block, it gets the
value of "calltmp". If control comes from the "else" block, it gets the value
of "calltmp1".
-At this point, you are probably starting to think "on no! this means my
+
At this point, you are probably starting to think "oh no! this means my
simple and elegant front-end will have to start generating SSA form in order to
use LLVM!". Fortunately, this is not the case, and we strongly advise
not implementing an SSA construction algorithm in your front-end
@@ -679,8 +679,8 @@ loop: ; preds = %loop, %entry
%nextvar = add double %i, 1.000000e+00
; termination test
- %multmp = fcmp ult double %i, %n
- %booltmp = uitofp i1 %multmp to double
+ %cmptmp = fcmp ult double %i, %n
+ %booltmp = uitofp i1 %cmptmp to double
%loopcond = fcmp one double %booltmp, 0.000000e+00
br i1 %loopcond, label %loop, label %afterloop
@@ -871,7 +871,8 @@ that is what we return from ForExprAST::Codegen.
the tutorial. We added two control flow constructs, and used them to motivate
a couple of aspects of the LLVM IR that are important for front-end implementors
to know. In the next chapter of our saga, we will get a bit crazier and add
-operator overloading to our poor innocent language.
+user-defined operators to our poor innocent
+language.
@@ -1378,7 +1379,7 @@ Value *BinaryExprAST::Codegen() {
case '-': return Builder.CreateSub(L, R, "subtmp");
case '*': return Builder.CreateMul(L, R, "multmp");
case '<':
- L = Builder.CreateFCmpULT(L, R, "multmp");
+ L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
default: return ErrorV("invalid binary operator");
diff --git a/llvm/docs/tutorial/LangImpl6.html b/llvm/docs/tutorial/LangImpl6.html
index b113afc3640b..8976acf50e74 100644
--- a/llvm/docs/tutorial/LangImpl6.html
+++ b/llvm/docs/tutorial/LangImpl6.html
@@ -280,7 +280,7 @@ Value *BinaryExprAST::Codegen() {
case '-': return Builder.CreateSub(L, R, "subtmp");
case '*': return Builder.CreateMul(L, R, "multmp");
case '<':
- L = Builder.CreateFCmpULT(L, R, "multmp");
+ L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
default: break;
@@ -1396,7 +1396,7 @@ Value *BinaryExprAST::Codegen() {
case '-': return Builder.CreateSub(L, R, "subtmp");
case '*': return Builder.CreateMul(L, R, "multmp");
case '<':
- L = Builder.CreateFCmpULT(L, R, "multmp");
+ L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
default: break;
diff --git a/llvm/docs/tutorial/LangImpl7.html b/llvm/docs/tutorial/LangImpl7.html
index 1a506767e576..9aa65d3b6e12 100644
--- a/llvm/docs/tutorial/LangImpl7.html
+++ b/llvm/docs/tutorial/LangImpl7.html
@@ -546,8 +546,8 @@ entry:
%x1 = alloca double
store double %x, double* %x1
%x2 = load double* %x1
- %multmp = fcmp ult double %x2, 3.000000e+00
- %booltmp = uitofp i1 %multmp to double
+ %cmptmp = fcmp ult double %x2, 3.000000e+00
+ %booltmp = uitofp i1 %cmptmp to double
%ifcond = fcmp one double %booltmp, 0.000000e+00
br i1 %ifcond, label %then, label %else
@@ -585,8 +585,8 @@ PHI node for it, so we still just make the PHI.
define double @fib(double %x) {
entry:
- %multmp = fcmp ult double %x, 3.000000e+00
- %booltmp = uitofp i1 %multmp to double
+ %cmptmp = fcmp ult double %x, 3.000000e+00
+ %booltmp = uitofp i1 %cmptmp to double
%ifcond = fcmp one double %booltmp, 0.000000e+00
br i1 %ifcond, label %then, label %else
@@ -618,8 +618,8 @@ such blatent inefficiencies :).
define double @fib(double %x) {
entry:
- %multmp = fcmp ult double %x, 3.000000e+00
- %booltmp = uitofp i1 %multmp to double
+ %cmptmp = fcmp ult double %x, 3.000000e+00
+ %booltmp = uitofp i1 %cmptmp to double
%ifcond = fcmp ueq double %booltmp, 0.000000e+00
br i1 %ifcond, label %else, label %ifcont
@@ -1674,7 +1674,7 @@ Value *BinaryExprAST::Codegen() {
case '-': return Builder.CreateSub(L, R, "subtmp");
case '*': return Builder.CreateMul(L, R, "multmp");
case '<':
- L = Builder.CreateFCmpULT(L, R, "multmp");
+ L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
default: break;