diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2011-04-23 00:30:22 +0000 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2011-04-23 00:30:22 +0000 |
commit | f5af6ada3b0570db1afc19029cad8fb8320676ef (patch) | |
tree | 4df12ad7fe5c5902fd8601d164291a94fa078f10 /docs/tutorial | |
parent | 624dc1d4abf26a3ccd474f85a39058a99a9053ca (diff) | |
download | external_llvm-f5af6ada3b0570db1afc19029cad8fb8320676ef.zip external_llvm-f5af6ada3b0570db1afc19029cad8fb8320676ef.tar.gz external_llvm-f5af6ada3b0570db1afc19029cad8fb8320676ef.tar.bz2 |
docs: Introduce cascading style <div> and <p> continued on <h[2-5]>.
<h2>Section Example</h2>
<div> <!-- h2+div is applied -->
<p>Section preamble.</p>
<h3>Subsection Example</h3>
<p> <!-- h3+p is applied -->
Subsection body
</p>
<!-- End of section body -->
</div>
FIXME: Care H5 better.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130040 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/tutorial')
-rw-r--r-- | docs/tutorial/LangImpl1.html | 6 | ||||
-rw-r--r-- | docs/tutorial/LangImpl2.html | 18 | ||||
-rw-r--r-- | docs/tutorial/LangImpl3.html | 12 | ||||
-rw-r--r-- | docs/tutorial/LangImpl4.html | 10 | ||||
-rw-r--r-- | docs/tutorial/LangImpl5.html | 36 | ||||
-rw-r--r-- | docs/tutorial/LangImpl6.html | 12 | ||||
-rw-r--r-- | docs/tutorial/LangImpl7.html | 16 | ||||
-rw-r--r-- | docs/tutorial/LangImpl8.html | 24 | ||||
-rw-r--r-- | docs/tutorial/OCamlLangImpl1.html | 6 | ||||
-rw-r--r-- | docs/tutorial/OCamlLangImpl2.html | 18 | ||||
-rw-r--r-- | docs/tutorial/OCamlLangImpl3.html | 12 | ||||
-rw-r--r-- | docs/tutorial/OCamlLangImpl4.html | 10 | ||||
-rw-r--r-- | docs/tutorial/OCamlLangImpl5.html | 36 | ||||
-rw-r--r-- | docs/tutorial/OCamlLangImpl6.html | 12 | ||||
-rw-r--r-- | docs/tutorial/OCamlLangImpl7.html | 16 | ||||
-rw-r--r-- | docs/tutorial/OCamlLangImpl8.html | 24 |
16 files changed, 134 insertions, 134 deletions
diff --git a/docs/tutorial/LangImpl1.html b/docs/tutorial/LangImpl1.html index cc2fa97..2e1746f 100644 --- a/docs/tutorial/LangImpl1.html +++ b/docs/tutorial/LangImpl1.html @@ -33,7 +33,7 @@ <h2><a name="intro">Tutorial Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to the "Implementing a language with LLVM" tutorial. This tutorial runs through the implementation of a simple language, showing how fun and @@ -126,7 +126,7 @@ languages!</p> <h2><a name="language">The Basic Language</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>This tutorial will be illustrated with a toy language that we'll call "<a href="http://en.wikipedia.org/wiki/Kaleidoscope">Kaleidoscope</a>" (derived @@ -184,7 +184,7 @@ a Mandelbrot Set</a> at various levels of magnification.</p> <h2><a name="lexer">The Lexer</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>When it comes to implementing a language, the first thing needed is the ability to process a text file and recognize what it says. The traditional diff --git a/docs/tutorial/LangImpl2.html b/docs/tutorial/LangImpl2.html index bfe8d3f..acccd20 100644 --- a/docs/tutorial/LangImpl2.html +++ b/docs/tutorial/LangImpl2.html @@ -39,7 +39,7 @@ <h2><a name="intro">Chapter 2 Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to Chapter 2 of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. This chapter shows you how to use the lexer, built in @@ -64,7 +64,7 @@ Tree.</p> <h2><a name="ast">The Abstract Syntax Tree (AST)</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>The AST for a program captures its behavior in such a way that it is easy for later stages of the compiler (e.g. code generation) to interpret. We basically @@ -181,7 +181,7 @@ bodies in Kaleidoscope.</p> <h2><a name="parserbasics">Parser Basics</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Now that we have an AST to build, we need to define the parser code to build it. The idea here is that we want to parse something like "x+y" (which is @@ -242,7 +242,7 @@ piece of our grammar: numeric literals.</p> <h2><a name="parserprimexprs">Basic Expression Parsing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>We start with numeric literals, because they are the simplest to process. For each production in our grammar, we'll define a function which parses that @@ -396,7 +396,7 @@ They are a bit more complex.</p> <h2><a name="parserbinops">Binary Expression Parsing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Binary expressions are significantly harder to parse because they are often ambiguous. For example, when given the string "x+y*z", the parser can choose @@ -618,7 +618,7 @@ handle function definitions, etc.</p> <h2><a name="parsertop">Parsing the Rest</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> The next thing missing is handling of function prototypes. In Kaleidoscope, @@ -715,7 +715,7 @@ actually <em>execute</em> this code we've built!</p> <h2><a name="driver">The Driver</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>The driver for this simply invokes all of the parsing pieces with a top-level dispatch loop. There isn't much interesting here, so I'll just include the @@ -754,7 +754,7 @@ type "4+5;", and the parser will know you are done.</p> <h2><a name="conclusions">Conclusions</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>With just under 400 lines of commented code (240 lines of non-comment, non-blank code), we fully defined our minimal language, including a lexer, @@ -791,7 +791,7 @@ Representation (IR) from the AST.</p> <h2><a name="code">Full Code Listing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Here is the complete code listing for this and the previous chapter. diff --git a/docs/tutorial/LangImpl3.html b/docs/tutorial/LangImpl3.html index 468a1bf..c9f4cee 100644 --- a/docs/tutorial/LangImpl3.html +++ b/docs/tutorial/LangImpl3.html @@ -37,7 +37,7 @@ Support</li> <h2><a name="intro">Chapter 3 Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to Chapter 3 of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. This chapter shows you how to transform the <a @@ -60,7 +60,7 @@ releases page</a>.</p> <h2><a name="basics">Code Generation Setup</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> In order to generate LLVM IR, we want some simple setup to get started. First @@ -150,7 +150,7 @@ has already been done, and we'll just use it to emit code. <h2><a name="exprs">Expression Code Generation</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Generating LLVM code for expression nodes is very straightforward: less than 45 lines of commented code for all four of our expression nodes. First @@ -296,7 +296,7 @@ basic framework.</p> <h2><a name="funcs">Function Code Generation</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Code generation for prototypes and functions must handle a number of details, which make their code less beautiful than expression code @@ -518,7 +518,7 @@ def bar() foo(1, 2); # error, unknown function "foo" <h2><a name="driver">Driver Changes and Closing Thoughts</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> For now, code generation to LLVM doesn't really get us much, except that we can @@ -659,7 +659,7 @@ support</a> to this so we can actually start running code!</p> <h2><a name="code">Full Code Listing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Here is the complete code listing for our running example, enhanced with the diff --git a/docs/tutorial/LangImpl4.html b/docs/tutorial/LangImpl4.html index d73f8a3..fe54fb5 100644 --- a/docs/tutorial/LangImpl4.html +++ b/docs/tutorial/LangImpl4.html @@ -36,7 +36,7 @@ Flow</li> <h2><a name="intro">Chapter 4 Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to Chapter 4 of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. Chapters 1-3 described the implementation of a simple @@ -51,7 +51,7 @@ for the Kaleidoscope language.</p> <h2><a name="trivialconstfold">Trivial Constant Folding</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Our demonstration for Chapter 3 is elegant and easy to extend. Unfortunately, @@ -136,7 +136,7 @@ range of optimizations that you can use, in the form of "passes".</p> <h2><a name="optimizerpasses">LLVM Optimization Passes</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>LLVM provides many optimization passes, which do many different sorts of things and have different tradeoffs. Unlike other systems, LLVM doesn't hold @@ -267,7 +267,7 @@ executing it!</p> <h2><a name="jit">Adding a JIT Compiler</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Code that is available in LLVM IR can have a wide variety of tools applied to it. For example, you can run optimizations on it (as we did above), @@ -475,7 +475,7 @@ tackling some interesting LLVM IR issues along the way.</p> <h2><a name="code">Full Code Listing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Here is the complete code listing for our running example, enhanced with the diff --git a/docs/tutorial/LangImpl5.html b/docs/tutorial/LangImpl5.html index 4fbf7be..e46ded1 100644 --- a/docs/tutorial/LangImpl5.html +++ b/docs/tutorial/LangImpl5.html @@ -51,7 +51,7 @@ User-defined Operators</li> <h2><a name="intro">Chapter 5 Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to Chapter 5 of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. Parts 1-4 described the implementation of the simple @@ -68,7 +68,7 @@ have an if/then/else expression plus a simple 'for' loop.</p> <h2><a name="ifthen">If/Then/Else</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Extending Kaleidoscope to support if/then/else is quite straightforward. It @@ -108,14 +108,12 @@ Since Kaleidoscope allows side-effects, this behavior is important to nail down. <p>Now that we know what we "want", lets break this down into its constituent pieces.</p> -</div> - <!-- ======================================================================= --> <h4><a name="iflexer">Lexer Extensions for If/Then/Else</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>The lexer extensions are straightforward. First we add new enum values for the relevant tokens:</p> @@ -148,7 +146,7 @@ stuff:</p> <h4><a name="ifast">AST Extensions for If/Then/Else</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>To represent the new expression we add a new AST node for it:</p> @@ -173,7 +171,7 @@ public: <h4><a name="ifparser">Parser Extensions for If/Then/Else</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>Now that we have the relevant tokens coming from the lexer and we have the AST node to build, our parsing logic is relatively straightforward. First we @@ -231,7 +229,7 @@ static ExprAST *ParsePrimary() { <h4><a name="ifir">LLVM IR for If/Then/Else</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>Now that we have it parsing and building the AST, the final piece is adding LLVM code generation support. This is the most interesting part of the @@ -347,7 +345,7 @@ directly.</p> <h4><a name="ifcodegen">Code Generation for If/Then/Else</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>In order to generate code for this, we implement the <tt>Codegen</tt> method for <tt>IfExprAST</tt>:</p> @@ -496,11 +494,13 @@ another useful expression that is familiar from non-functional languages...</p> </div> +</div> + <!-- *********************************************************************** --> <h2><a name="for">'for' Loop Expression</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Now that we know how to add basic control flow constructs to the language, we have the tools to add more powerful things. Lets add something more @@ -529,13 +529,11 @@ variables, it will get more useful.</p> <p>As before, lets talk about the changes that we need to Kaleidoscope to support this.</p> -</div> - <!-- ======================================================================= --> <h4><a name="forlexer">Lexer Extensions for the 'for' Loop</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>The lexer extensions are the same sort of thing as for if/then/else:</p> @@ -564,7 +562,7 @@ support this.</p> <h4><a name="forast">AST Extensions for the 'for' Loop</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>The AST node is just as simple. It basically boils down to capturing the variable name and the constituent expressions in the node.</p> @@ -590,7 +588,7 @@ public: <h4><a name="forparser">Parser Extensions for the 'for' Loop</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>The parser code is also fairly standard. The only interesting thing here is handling of the optional step value. The parser code handles it by checking to @@ -649,7 +647,7 @@ static ExprAST *ParseForExpr() { <h4><a name="forir">LLVM IR for the 'for' Loop</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>Now we get to the good part: the LLVM IR we want to generate for this thing. With the simple example above, we get this LLVM IR (note that this dump is @@ -694,7 +692,7 @@ expressions, and some basic blocks. Lets see how this fits together.</p> <h4><a name="forcodegen">Code Generation for the 'for' Loop</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>The first part of Codegen is very simple: we just output the start expression for the loop value:</p> @@ -867,11 +865,13 @@ language.</p> </div> +</div> + <!-- *********************************************************************** --> <h2><a name="code">Full Code Listing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Here is the complete code listing for our running example, enhanced with the diff --git a/docs/tutorial/LangImpl6.html b/docs/tutorial/LangImpl6.html index 510d9dd..39264cf 100644 --- a/docs/tutorial/LangImpl6.html +++ b/docs/tutorial/LangImpl6.html @@ -37,7 +37,7 @@ Variables / SSA Construction</li> <h2><a name="intro">Chapter 6 Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to Chapter 6 of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. At this point in our tutorial, we now have a fully @@ -63,7 +63,7 @@ an example of what you can build with Kaleidoscope and its feature set.</p> <h2><a name="idea">User-defined Operators: the Idea</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> The "operator overloading" that we will add to Kaleidoscope is more general than @@ -128,7 +128,7 @@ operators.</p> <h2><a name="binary">User-defined Binary Operators</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Adding support for user-defined binary operators is pretty simple with our current framework. We'll first add support for the unary/binary keywords:</p> @@ -345,7 +345,7 @@ see what it takes.</p> <h2><a name="unary">User-defined Unary Operators</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Since we don't currently support unary operators in the Kaleidoscope language, we'll need to add everything to support them. Above, we added simple @@ -494,7 +494,7 @@ is simpler primarily because it doesn't need to handle any predefined operators. <h2><a name="example">Kicking the Tires</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>It is somewhat hard to believe, but with a few simple extensions we've covered in the last chapters, we have grown a real-ish language. With this, we @@ -799,7 +799,7 @@ add variable mutation without building SSA in your front-end.</p> <h2><a name="code">Full Code Listing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Here is the complete code listing for our running example, enhanced with the diff --git a/docs/tutorial/LangImpl7.html b/docs/tutorial/LangImpl7.html index fc49d07..b2b26bd 100644 --- a/docs/tutorial/LangImpl7.html +++ b/docs/tutorial/LangImpl7.html @@ -41,7 +41,7 @@ <h2><a name="intro">Chapter 7 Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to Chapter 7 of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. In chapters 1 through 6, we've built a very @@ -69,7 +69,7 @@ support for this, though the way it works is a bit unexpected for some.</p> <h2><a name="why">Why is this a hard problem?</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> To understand why mutable variables cause complexities in SSA construction, @@ -143,7 +143,7 @@ logic.</p> <h2><a name="memory">Memory in LLVM</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>The 'trick' here is that while LLVM does require all register values to be in SSA form, it does not require (or permit) memory objects to be in SSA form. @@ -324,7 +324,7 @@ variables now! <h2><a name="kalvars">Mutable Variables in Kaleidoscope</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Now that we know the sort of problem we want to tackle, lets see what this looks like in the context of our little Kaleidoscope language. We're going to @@ -380,7 +380,7 @@ Kaleidoscope to support new variable definitions. <h2><a name="adjustments">Adjusting Existing Variables for Mutation</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> The symbol table in Kaleidoscope is managed at code generation time by the @@ -649,7 +649,7 @@ we'll add the assignment operator.</p> <h2><a name="assignment">New Assignment Operator</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>With our current framework, adding a new assignment operator is really simple. We will parse it just like any other binary operator, but handle it @@ -746,7 +746,7 @@ add this next! <h2><a name="localvars">User-defined Local Variables</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Adding var/in is just like any other other extensions we made to Kaleidoscope: we extend the lexer, the parser, the AST and the code generator. @@ -979,7 +979,7 @@ anywhere in sight.</p> <h2><a name="code">Full Code Listing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Here is the complete code listing for our running example, enhanced with mutable diff --git a/docs/tutorial/LangImpl8.html b/docs/tutorial/LangImpl8.html index 449ac70..eed8c03 100644 --- a/docs/tutorial/LangImpl8.html +++ b/docs/tutorial/LangImpl8.html @@ -45,7 +45,7 @@ <h2><a name="conclusion">Tutorial Conclusion</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to the the final chapter of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. In the course of this tutorial, we have grown @@ -156,18 +156,16 @@ are very useful if you want to take advantage of LLVM's capabilities.</p> <h2><a name="llvmirproperties">Properties of the LLVM IR</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>We have a couple common questions about code in the LLVM IR form - lets just get these out of the way right now, shall we?</p> -</div> - <!-- ======================================================================= --> <h4><a name="targetindep">Target Independence</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>Kaleidoscope is an example of a "portable language": any program written in Kaleidoscope will work the same way on any target that it runs on. Many other @@ -221,7 +219,7 @@ in-kernel language.</p> <h4><a name="safety">Safety Guarantees</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>Many of the languages above are also "safe" languages: it is impossible for a program written in Java to corrupt its address space and crash the process @@ -243,7 +241,7 @@ list</a> if you are interested in more details.</p> <h4><a name="langspecific">Language-Specific Optimizations</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>One thing about LLVM that turns off many people is that it does not solve all the world's problems in one system (sorry 'world hunger', someone else will have @@ -293,23 +291,23 @@ language-specific AST. </div> +</div> + <!-- *********************************************************************** --> <h2><a name="tipsandtricks">Tips and Tricks</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>There is a variety of useful tips and tricks that you come to know after working on/with LLVM that aren't obvious at first glance. Instead of letting everyone rediscover them, this section talks about some of these issues.</p> -</div> - <!-- ======================================================================= --> <h4><a name="offsetofsizeof">Implementing portable offsetof/sizeof</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>One interesting thing that comes up, if you are trying to keep the code generated by your compiler "target independent", is that you often need to know @@ -329,7 +327,7 @@ in a portable way.</p> <h4><a name="gcstack">Garbage Collected Stack Frames</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>Some languages want to explicitly manage their stack frames, often so that they are garbage collected or to allow easy implementation of closures. There @@ -343,6 +341,8 @@ Passing Style</a> and the use of tail calls (which LLVM also supports).</p> </div> +</div> + <!-- *********************************************************************** --> <hr> <address> diff --git a/docs/tutorial/OCamlLangImpl1.html b/docs/tutorial/OCamlLangImpl1.html index 5446b7a..aa2bd87 100644 --- a/docs/tutorial/OCamlLangImpl1.html +++ b/docs/tutorial/OCamlLangImpl1.html @@ -38,7 +38,7 @@ AST</li> <h2><a name="intro">Tutorial Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to the "Implementing a language with LLVM" tutorial. This tutorial runs through the implementation of a simple language, showing how fun and @@ -133,7 +133,7 @@ languages!</p> <h2><a name="language">The Basic Language</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>This tutorial will be illustrated with a toy language that we'll call "<a href="http://en.wikipedia.org/wiki/Kaleidoscope">Kaleidoscope</a>" (derived @@ -191,7 +191,7 @@ a Mandelbrot Set</a> at various levels of magnification.</p> <h2><a name="lexer">The Lexer</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>When it comes to implementing a language, the first thing needed is the ability to process a text file and recognize what it says. The traditional diff --git a/docs/tutorial/OCamlLangImpl2.html b/docs/tutorial/OCamlLangImpl2.html index deb592e..20e006d 100644 --- a/docs/tutorial/OCamlLangImpl2.html +++ b/docs/tutorial/OCamlLangImpl2.html @@ -43,7 +43,7 @@ <h2><a name="intro">Chapter 2 Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to Chapter 2 of the "<a href="index.html">Implementing a language with LLVM in Objective Caml</a>" tutorial. This chapter shows you how to use @@ -68,7 +68,7 @@ Tree.</p> <h2><a name="ast">The Abstract Syntax Tree (AST)</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>The AST for a program captures its behavior in such a way that it is easy for later stages of the compiler (e.g. code generation) to interpret. We basically @@ -149,7 +149,7 @@ bodies in Kaleidoscope.</p> <h2><a name="parserbasics">Parser Basics</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Now that we have an AST to build, we need to define the parser code to build it. The idea here is that we want to parse something like "x+y" (which is @@ -184,7 +184,7 @@ piece of our grammar: numeric literals.</p> <h2><a name="parserprimexprs">Basic Expression Parsing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>We start with numeric literals, because they are the simplest to process. For each production in our grammar, we'll define a function which parses that @@ -305,7 +305,7 @@ They are a bit more complex.</p> <h2><a name="parserbinops">Binary Expression Parsing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Binary expressions are significantly harder to parse because they are often ambiguous. For example, when given the string "x+y*z", the parser can choose @@ -518,7 +518,7 @@ handle function definitions, etc.</p> <h2><a name="parsertop">Parsing the Rest</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> The next thing missing is handling of function prototypes. In Kaleidoscope, @@ -597,7 +597,7 @@ actually <em>execute</em> this code we've built!</p> <h2><a name="driver">The Driver</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>The driver for this simply invokes all of the parsing pieces with a top-level dispatch loop. There isn't much interesting here, so I'll just include the @@ -653,7 +653,7 @@ type "4+5;", and the parser will know you are done.</p> <h2><a name="conclusions">Conclusions</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>With just under 300 lines of commented code (240 lines of non-comment, non-blank code), we fully defined our minimal language, including a lexer, @@ -690,7 +690,7 @@ Representation (IR) from the AST.</p> <h2><a name="code">Full Code Listing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Here is the complete code listing for this and the previous chapter. diff --git a/docs/tutorial/OCamlLangImpl3.html b/docs/tutorial/OCamlLangImpl3.html index cf5afe9..45ee6e9 100644 --- a/docs/tutorial/OCamlLangImpl3.html +++ b/docs/tutorial/OCamlLangImpl3.html @@ -41,7 +41,7 @@ Support</li> <h2><a name="intro">Chapter 3 Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to Chapter 3 of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. This chapter shows you how to transform the <a @@ -60,7 +60,7 @@ LLVM SVN to work. LLVM 2.2 and before will not work with it.</p> <h2><a name="basics">Code Generation Setup</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> In order to generate LLVM IR, we want some simple setup to get started. First @@ -131,7 +131,7 @@ that this has already been done, and we'll just use it to emit code.</p> <h2><a name="exprs">Expression Code Generation</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Generating LLVM code for expression nodes is very straightforward: less than 30 lines of commented code for all four of our expression nodes. First @@ -266,7 +266,7 @@ basic framework.</p> <h2><a name="funcs">Function Code Generation</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Code generation for prototypes and functions must handle a number of details, which make their code less beautiful than expression code @@ -469,7 +469,7 @@ def bar() foo(1, 2); # error, unknown function "foo" <h2><a name="driver">Driver Changes and Closing Thoughts</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> For now, code generation to LLVM doesn't really get us much, except that we can @@ -609,7 +609,7 @@ support</a> to this so we can actually start running code!</p> <h2><a name="code">Full Code Listing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Here is the complete code listing for our running example, enhanced with the diff --git a/docs/tutorial/OCamlLangImpl4.html b/docs/tutorial/OCamlLangImpl4.html index e424045..fd2b5ad 100644 --- a/docs/tutorial/OCamlLangImpl4.html +++ b/docs/tutorial/OCamlLangImpl4.html @@ -40,7 +40,7 @@ Flow</li> <h2><a name="intro">Chapter 4 Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to Chapter 4 of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. Chapters 1-3 described the implementation of a simple @@ -55,7 +55,7 @@ for the Kaleidoscope language.</p> <h2><a name="trivialconstfold">Trivial Constant Folding</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p><b>Note:</b> the default <tt>IRBuilder</tt> now always includes the constant folding optimisations below.<p> @@ -150,7 +150,7 @@ range of optimizations that you can use, in the form of "passes".</p> <h2><a name="optimizerpasses">LLVM Optimization Passes</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>LLVM provides many optimization passes, which do many different sorts of things and have different tradeoffs. Unlike other systems, LLVM doesn't hold @@ -284,7 +284,7 @@ executing it!</p> <h2><a name="jit">Adding a JIT Compiler</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Code that is available in LLVM IR can have a wide variety of tools applied to it. For example, you can run optimizations on it (as we did above), @@ -487,7 +487,7 @@ constructs</a>, tackling some interesting LLVM IR issues along the way.</p> <h2><a name="code">Full Code Listing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Here is the complete code listing for our running example, enhanced with the diff --git a/docs/tutorial/OCamlLangImpl5.html b/docs/tutorial/OCamlLangImpl5.html index 59c1749..d356f12 100644 --- a/docs/tutorial/OCamlLangImpl5.html +++ b/docs/tutorial/OCamlLangImpl5.html @@ -55,7 +55,7 @@ User-defined Operators</li> <h2><a name="intro">Chapter 5 Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to Chapter 5 of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. Parts 1-4 described the implementation of the simple @@ -72,7 +72,7 @@ have an if/then/else expression plus a simple 'for' loop.</p> <h2><a name="ifthen">If/Then/Else</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Extending Kaleidoscope to support if/then/else is quite straightforward. It @@ -112,14 +112,12 @@ Since Kaleidoscope allows side-effects, this behavior is important to nail down. <p>Now that we know what we "want", lets break this down into its constituent pieces.</p> -</div> - <!-- ======================================================================= --> <h4><a name="iflexer">Lexer Extensions for If/Then/Else</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>The lexer extensions are straightforward. First we add new variants for the relevant tokens:</p> @@ -155,7 +153,7 @@ stuff:</p> <h4><a name="ifast">AST Extensions for If/Then/Else</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>To represent the new expression we add a new AST variant for it:</p> @@ -176,7 +174,7 @@ type expr = <h4><a name="ifparser">Parser Extensions for If/Then/Else</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>Now that we have the relevant tokens coming from the lexer and we have the AST node to build, our parsing logic is relatively straightforward. First we @@ -214,7 +212,7 @@ let rec parse_primary = parser <h4><a name="ifir">LLVM IR for If/Then/Else</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>Now that we have it parsing and building the AST, the final piece is adding LLVM code generation support. This is the most interesting part of the @@ -331,7 +329,7 @@ directly.</p> <h4><a name="ifcodegen">Code Generation for If/Then/Else</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>In order to generate code for this, we implement the <tt>Codegen</tt> method for <tt>IfExprAST</tt>:</p> @@ -488,11 +486,13 @@ another useful expression that is familiar from non-functional languages...</p> </div> +</div> + <!-- *********************************************************************** --> <h2><a name="for">'for' Loop Expression</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Now that we know how to add basic control flow constructs to the language, we have the tools to add more powerful things. Lets add something more @@ -521,13 +521,11 @@ variables, it will get more useful.</p> <p>As before, lets talk about the changes that we need to Kaleidoscope to support this.</p> -</div> - <!-- ======================================================================= --> <h4><a name="forlexer">Lexer Extensions for the 'for' Loop</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>The lexer extensions are the same sort of thing as for if/then/else:</p> @@ -557,7 +555,7 @@ support this.</p> <h4><a name="forast">AST Extensions for the 'for' Loop</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>The AST variant is just as simple. It basically boils down to capturing the variable name and the constituent expressions in the node.</p> @@ -577,7 +575,7 @@ type expr = <h4><a name="forparser">Parser Extensions for the 'for' Loop</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>The parser code is also fairly standard. The only interesting thing here is handling of the optional step value. The parser code handles it by checking to @@ -624,7 +622,7 @@ let rec parse_primary = parser <h4><a name="forir">LLVM IR for the 'for' Loop</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>Now we get to the good part: the LLVM IR we want to generate for this thing. With the simple example above, we get this LLVM IR (note that this dump is @@ -669,7 +667,7 @@ expressions, and some basic blocks. Lets see how this fits together.</p> <h4><a name="forcodegen">Code Generation for the 'for' Loop</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>The first part of Codegen is very simple: we just output the start expression for the loop value:</p> @@ -842,11 +840,13 @@ to our poor innocent language.</p> </div> +</div> + <!-- *********************************************************************** --> <h2><a name="code">Full Code Listing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Here is the complete code listing for our running example, enhanced with the diff --git a/docs/tutorial/OCamlLangImpl6.html b/docs/tutorial/OCamlLangImpl6.html index 693aafc..480aab3 100644 --- a/docs/tutorial/OCamlLangImpl6.html +++ b/docs/tutorial/OCamlLangImpl6.html @@ -41,7 +41,7 @@ Variables / SSA Construction</li> <h2><a name="intro">Chapter 6 Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to Chapter 6 of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. At this point in our tutorial, we now have a fully @@ -67,7 +67,7 @@ an example of what you can build with Kaleidoscope and its feature set.</p> <h2><a name="idea">User-defined Operators: the Idea</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> The "operator overloading" that we will add to Kaleidoscope is more general than @@ -132,7 +132,7 @@ operators.</p> <h2><a name="binary">User-defined Binary Operators</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Adding support for user-defined binary operators is pretty simple with our current framework. We'll first add support for the unary/binary keywords:</p> @@ -323,7 +323,7 @@ see what it takes.</p> <h2><a name="unary">User-defined Unary Operators</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Since we don't currently support unary operators in the Kaleidoscope language, we'll need to add everything to support them. Above, we added simple @@ -475,7 +475,7 @@ is simpler primarily because it doesn't need to handle any predefined operators. <h2><a name="example">Kicking the Tires</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>It is somewhat hard to believe, but with a few simple extensions we've covered in the last chapters, we have grown a real-ish language. With this, we @@ -781,7 +781,7 @@ add variable mutation without building SSA in your front-end.</p> <h2><a name="code">Full Code Listing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Here is the complete code listing for our running example, enhanced with the diff --git a/docs/tutorial/OCamlLangImpl7.html b/docs/tutorial/OCamlLangImpl7.html index aebc81c..51986b5 100644 --- a/docs/tutorial/OCamlLangImpl7.html +++ b/docs/tutorial/OCamlLangImpl7.html @@ -45,7 +45,7 @@ <h2><a name="intro">Chapter 7 Introduction</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to Chapter 7 of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. In chapters 1 through 6, we've built a very @@ -73,7 +73,7 @@ support for this, though the way it works is a bit unexpected for some.</p> <h2><a name="why">Why is this a hard problem?</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> To understand why mutable variables cause complexities in SSA construction, @@ -147,7 +147,7 @@ logic.</p> <h2><a name="memory">Memory in LLVM</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>The 'trick' here is that while LLVM does require all register values to be in SSA form, it does not require (or permit) memory objects to be in SSA form. @@ -328,7 +328,7 @@ variables now! <h2><a name="kalvars">Mutable Variables in Kaleidoscope</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Now that we know the sort of problem we want to tackle, lets see what this looks like in the context of our little Kaleidoscope language. We're going to @@ -384,7 +384,7 @@ Kaleidoscope to support new variable definitions. <h2><a name="adjustments">Adjusting Existing Variables for Mutation</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> The symbol table in Kaleidoscope is managed at code generation time by the @@ -673,7 +673,7 @@ we'll add the assignment operator.</p> <h2><a name="assignment">New Assignment Operator</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>With our current framework, adding a new assignment operator is really simple. We will parse it just like any other binary operator, but handle it @@ -774,7 +774,7 @@ add this next! <h2><a name="localvars">User-defined Local Variables</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Adding var/in is just like any other other extensions we made to Kaleidoscope: we extend the lexer, the parser, the AST and the code generator. @@ -956,7 +956,7 @@ anywhere in sight.</p> <h2><a name="code">Full Code Listing</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p> Here is the complete code listing for our running example, enhanced with mutable diff --git a/docs/tutorial/OCamlLangImpl8.html b/docs/tutorial/OCamlLangImpl8.html index 449ac70..eed8c03 100644 --- a/docs/tutorial/OCamlLangImpl8.html +++ b/docs/tutorial/OCamlLangImpl8.html @@ -45,7 +45,7 @@ <h2><a name="conclusion">Tutorial Conclusion</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>Welcome to the the final chapter of the "<a href="index.html">Implementing a language with LLVM</a>" tutorial. In the course of this tutorial, we have grown @@ -156,18 +156,16 @@ are very useful if you want to take advantage of LLVM's capabilities.</p> <h2><a name="llvmirproperties">Properties of the LLVM IR</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>We have a couple common questions about code in the LLVM IR form - lets just get these out of the way right now, shall we?</p> -</div> - <!-- ======================================================================= --> <h4><a name="targetindep">Target Independence</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>Kaleidoscope is an example of a "portable language": any program written in Kaleidoscope will work the same way on any target that it runs on. Many other @@ -221,7 +219,7 @@ in-kernel language.</p> <h4><a name="safety">Safety Guarantees</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>Many of the languages above are also "safe" languages: it is impossible for a program written in Java to corrupt its address space and crash the process @@ -243,7 +241,7 @@ list</a> if you are interested in more details.</p> <h4><a name="langspecific">Language-Specific Optimizations</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>One thing about LLVM that turns off many people is that it does not solve all the world's problems in one system (sorry 'world hunger', someone else will have @@ -293,23 +291,23 @@ language-specific AST. </div> +</div> + <!-- *********************************************************************** --> <h2><a name="tipsandtricks">Tips and Tricks</a></h2> <!-- *********************************************************************** --> -<div class="doc_text"> +<div> <p>There is a variety of useful tips and tricks that you come to know after working on/with LLVM that aren't obvious at first glance. Instead of letting everyone rediscover them, this section talks about some of these issues.</p> -</div> - <!-- ======================================================================= --> <h4><a name="offsetofsizeof">Implementing portable offsetof/sizeof</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>One interesting thing that comes up, if you are trying to keep the code generated by your compiler "target independent", is that you often need to know @@ -329,7 +327,7 @@ in a portable way.</p> <h4><a name="gcstack">Garbage Collected Stack Frames</a></h4> <!-- ======================================================================= --> -<div class="doc_text"> +<div> <p>Some languages want to explicitly manage their stack frames, often so that they are garbage collected or to allow easy implementation of closures. There @@ -343,6 +341,8 @@ Passing Style</a> and the use of tail calls (which LLVM also supports).</p> </div> +</div> + <!-- *********************************************************************** --> <hr> <address> |