mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
several improvements suggested by Dan, thanks!
llvm-svn: 43237
This commit is contained in:
parent
252d9ddb4d
commit
0705dd275a
@ -65,7 +65,7 @@ public:
|
|||||||
class NumberExprAST : public ExprAST {
|
class NumberExprAST : public ExprAST {
|
||||||
double Val;
|
double Val;
|
||||||
public:
|
public:
|
||||||
NumberExprAST(double val) : Val(val) {}
|
explicit NumberExprAST(double val) : Val(val) {}
|
||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
@ -87,7 +87,7 @@ in the basic form of the Kaleidoscope language.
|
|||||||
class VariableExprAST : public ExprAST {
|
class VariableExprAST : public ExprAST {
|
||||||
std::string Name;
|
std::string Name;
|
||||||
public:
|
public:
|
||||||
VariableExprAST(const std::string &name) : Name(name) {}
|
explicit VariableExprAST(const std::string &name) : Name(name) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// BinaryExprAST - Expression class for a binary operator.
|
/// BinaryExprAST - Expression class for a binary operator.
|
||||||
@ -850,14 +850,14 @@ public:
|
|||||||
class NumberExprAST : public ExprAST {
|
class NumberExprAST : public ExprAST {
|
||||||
double Val;
|
double Val;
|
||||||
public:
|
public:
|
||||||
NumberExprAST(double val) : Val(val) {}
|
explicit NumberExprAST(double val) : Val(val) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// VariableExprAST - Expression class for referencing a variable, like "a".
|
/// VariableExprAST - Expression class for referencing a variable, like "a".
|
||||||
class VariableExprAST : public ExprAST {
|
class VariableExprAST : public ExprAST {
|
||||||
std::string Name;
|
std::string Name;
|
||||||
public:
|
public:
|
||||||
VariableExprAST(const std::string &name) : Name(name) {}
|
explicit VariableExprAST(const std::string &name) : Name(name) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// BinaryExprAST - Expression class for a binary operator.
|
/// BinaryExprAST - Expression class for a binary operator.
|
||||||
|
@ -56,15 +56,26 @@ public:
|
|||||||
class NumberExprAST : public ExprAST {
|
class NumberExprAST : public ExprAST {
|
||||||
double Val;
|
double Val;
|
||||||
public:
|
public:
|
||||||
NumberExprAST(double val) : Val(val) {}
|
explicit NumberExprAST(double val) : Val(val) {}
|
||||||
virtual Value *Codegen();
|
virtual Value *Codegen();
|
||||||
};
|
};
|
||||||
...
|
...
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>"Value" is the class used to represent a "register" in LLVM. The Codegen()
|
<p>The Codegen() method says to emit IR for that AST node and all things it
|
||||||
method says to emit IR for that AST node and all things it depends on. The
|
depends on, and they all return an LLVM Value object.
|
||||||
|
"Value" is the class used to represent a "<a
|
||||||
|
href="http://en.wikipedia.org/wiki/Static_single_assignment_form">Static Single
|
||||||
|
Assignment (SSA)</a> register" or "SSA value" in LLVM. The most distinct aspect
|
||||||
|
of SSA values is that their value is computed as the related instruction
|
||||||
|
executes, and it does not get a new value until (and if) the instruction
|
||||||
|
re-executes. In order words, there is no way to "change" an SSA value. For
|
||||||
|
more information, please read up on <a
|
||||||
|
href="http://en.wikipedia.org/wiki/Static_single_assignment_form">Static Single
|
||||||
|
Assignment</a> - the concepts are really quite natural once you grok them.</p>
|
||||||
|
|
||||||
|
<p>The
|
||||||
second thing we want is an "Error" method like we used for parser, which will
|
second thing we want is an "Error" method like we used for parser, which will
|
||||||
be used to report errors found during code generation (for example, use of an
|
be used to report errors found during code generation (for example, use of an
|
||||||
undeclared parameter):</p>
|
undeclared parameter):</p>
|
||||||
@ -299,7 +310,7 @@ public:
|
|||||||
class NumberExprAST : public ExprAST {
|
class NumberExprAST : public ExprAST {
|
||||||
double Val;
|
double Val;
|
||||||
public:
|
public:
|
||||||
NumberExprAST(double val) : Val(val) {}
|
explicit NumberExprAST(double val) : Val(val) {}
|
||||||
virtual Value *Codegen();
|
virtual Value *Codegen();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -307,7 +318,7 @@ public:
|
|||||||
class VariableExprAST : public ExprAST {
|
class VariableExprAST : public ExprAST {
|
||||||
std::string Name;
|
std::string Name;
|
||||||
public:
|
public:
|
||||||
VariableExprAST(const std::string &name) : Name(name) {}
|
explicit VariableExprAST(const std::string &name) : Name(name) {}
|
||||||
virtual Value *Codegen();
|
virtual Value *Codegen();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user