llvm.org GIT mirror llvm / d6a9e4a
[docs] NFC: Fix links in the tutorial r274441 introduced Chapter 10 of "Implementing a Language with LLVM" tutorial, which caused all files in the tutorial to start using two digit numbering. But many links were not changed and therefore appear to be broken. This patch addresses described issue. As a result, following command does not produce any output anymore: $ grep -nR '<LangImpl[0-9].html>' ./docs/tutorial/ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307525 91177308-0d34-0410-b5e6-96231b3b80d8 Kirill Bobyrev 2 years ago
8 changed file(s) with 16 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
1111 tutorial runs through the implementation of a JIT compiler using LLVM's
1212 On-Request-Compilation (ORC) APIs. It begins with a simplified version of the
1313 KaleidoscopeJIT class used in the
14 `Implementing a language with LLVM 1.html>`_ tutorials and then
14 `Implementing a language with LLVM 01.html>`_ tutorials and then
1515 introduces new features like optimization, lazy compilation and remote
1616 execution.
1717
4040 a remote process with reduced privileges using the JIT Remote APIs.
4141
4242 To provide input for our JIT we will use the Kaleidoscope REPL from
43 `Chapter 7 7.html>`_ of the "Implementing a language in LLVM tutorial",
43 `Chapter 7 07.html>`_ of the "Implementing a language in LLVM tutorial",
4444 with one minor modification: We will remove the FunctionPassManager from the
4545 code for that chapter and replace it with optimization support in our JIT class
4646 in Chapter #2.
9090
9191 In the previous section we described our API, now we examine a simple
9292 implementation of it: The KaleidoscopeJIT class [1]_ that was used in the
93 `Implementing a language with LLVM `_ tutorials. We will use
94 the REPL code from `Chapter 7 `_ of that tutorial to supply the
93 `Implementing a language with LLVM `_ tutorials. We will use
94 the REPL code from `Chapter 7 `_ of that tutorial to supply the
9595 input for our JIT: Each time the user enters an expression the REPL will add a
9696 new IR module containing the code for that expression to the JIT. If the
9797 expression is a top-level expression like '1+1' or 'sin(x)', the REPL will also
2424 Optimizing Modules using the IRTransformLayer
2525 =============================================
2626
27 In `Chapter 4 4.html>`_ of the "Implementing a language with LLVM"
27 In `Chapter 4 04.html>`_ of the "Implementing a language with LLVM"
2828 tutorial series the llvm *FunctionPassManager* is introduced as a means for
2929 optimizing LLVM IR. Interested readers may read that chapter for details, but
3030 in short: to optimize a Module we create an llvm::FunctionPassManager
147147 *optimizeModule*. This function sets up a FunctionPassManager, adds some passes
148148 to it, runs it over every function in the module, and then returns the mutated
149149 module. The specific optimizations are the same ones used in
150 `Chapter 4 4.html>`_ of the "Implementing a language with LLVM"
150 `Chapter 4 04.html>`_ of the "Implementing a language with LLVM"
151151 tutorial series. Readers may visit that chapter for a more in-depth
152152 discussion of these, and of IR optimization in general.
153153
99
1010 Welcome to Chapter 2 of the "`Implementing a language with
1111 LLVM `_" tutorial. This chapter shows you how to use the
12 lexer, built in `Chapter 1 1.html>`_, to build a full
12 lexer, built in `Chapter 1 01.html>`_, to build a full
1313 `parser `_ for our Kaleidoscope
1414 language. Once we have a parser, we'll define and build an `Abstract
1515 Syntax Tree `_ (AST).
99
1010 Welcome to Chapter 3 of the "`Implementing a language with
1111 LLVM `_" tutorial. This chapter shows you how to transform
12 the `Abstract Syntax Tree 2.html>`_, built in Chapter 2, into
12 the `Abstract Syntax Tree 02.html>`_, built in Chapter 2, into
1313 LLVM IR. This will teach you a little bit about how LLVM does things, as
1414 well as demonstrate how easy it is to use. It's much more work to build
1515 a lexer and parser than it is to generate LLVM IR code. :)
361361 of functions that define the `Control Flow
362362 Graph `_. Since we
363363 don't have any control flow, our functions will only contain one block
364 at this point. We'll fix this in `Chapter 5 5.html>`_ :).
364 at this point. We'll fix this in `Chapter 5 05.html>`_ :).
365365
366366 Next we add the function arguments to the NamedValues map (after first clearing
367367 it out) so that they're accessible to ``VariableExprAST`` nodes.
539539
540540 This wraps up the third chapter of the Kaleidoscope tutorial. Up next,
541541 we'll describe how to `add JIT codegen and optimizer
542 support 4.html>`_ to this so we can actually start running
542 support 04.html>`_ to this so we can actually start running
543543 code!
544544
545545 Full Code Listing
621621 tutorial. At this point, we can compile a non-Turing-complete
622622 programming language, optimize and JIT compile it in a user-driven way.
623623 Next up we'll look into `extending the language with control flow
624 constructs 5.html>`_, tackling some interesting LLVM IR issues
624 constructs 05.html>`_, tackling some interesting LLVM IR issues
625625 along the way.
626626
627627 Full Code Listing
268268 #. Values that are implicit in the structure of your AST, such as the
269269 Phi node in this case.
270270
271 In `Chapter 7 7.html>`_ of this tutorial ("mutable variables"),
271 In `Chapter 7 07.html>`_ of this tutorial ("mutable variables"),
272272 we'll talk about #1 in depth. For now, just believe me that you don't
273273 need SSA construction to handle this case. For #2, you have the choice
274274 of using the techniques that we will describe for #1, or you can insert
789789 and used them to motivate a couple of aspects of the LLVM IR that are
790790 important for front-end implementors to know. In the next chapter of our
791791 saga, we will get a bit crazier and add `user-defined
792 operators 6.html>`_ to our poor innocent language.
792 operators 06.html>`_ to our poor innocent language.
793793
794794 Full Code Listing
795795 =================
4040 is to show the power and flexibility of using a hand-written parser.
4141 Thus far, the parser we have been implementing uses recursive descent
4242 for most parts of the grammar and operator precedence parsing for the
43 expressions. See `Chapter 2 2.html>`_ for details. By
43 expressions. See `Chapter 2 02.html>`_ for details. By
4444 using operator precedence parsing, it is very easy to allow
4545 the programmer to introduce new operators into the grammar: the grammar
4646 is dynamically extensible as the JIT runs.
733733
734734 Strikingly, variable mutation is an important feature of some languages,
735735 and it is not at all obvious how to `add support for mutable
736 variables 7.html>`_ without having to add an "SSA construction"
736 variables 07.html>`_ without having to add an "SSA construction"
737737 phase to your front-end. In the next chapter, we will describe how you
738738 can add variable mutation without building SSA in your front-end.
739739
257257 let then_bb = append_block context "then" the_function in
258258 position_at_end then_bb builder;
259259
260 As opposed to the `C++ tutorial 5.html>`_, we have to build our
260 As opposed to the `C++ tutorial 05.html>`_, we have to build our
261261 basic blocks bottom up since we can't have dangling BasicBlocks. We
262262 start off by saving a pointer to the first block (which might not be the
263263 entry block), which we'll need to build a conditional branch later. We