Removed extraneous header code
This commit is contained in:
parent
f452b7f27c
commit
a5c892de72
6 changed files with 41 additions and 41 deletions
|
|
@ -94,7 +94,7 @@ play with languages!
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
The Basic Language # {#language}
|
The Basic Language
|
||||||
================================
|
================================
|
||||||
|
|
||||||
This tutorial will be illustrated with a toy language that we'll call
|
This tutorial will be illustrated with a toy language that we'll call
|
||||||
|
|
@ -152,7 +152,7 @@ Lets dive into the implementation of this language!
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
The Lexer # {#lexer}
|
The Lexer
|
||||||
====================
|
====================
|
||||||
|
|
||||||
When it comes to implementing a language, the first thing needed is the
|
When it comes to implementing a language, the first thing needed is the
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ Chapter 3: Code generation to LLVM IR
|
||||||
Written by `Chris Lattner <mailto:sabre@nondot.org>`_ and `Max
|
Written by `Chris Lattner <mailto:sabre@nondot.org>`_ and `Max
|
||||||
Shawabkeh <http://max99x.com>`_
|
Shawabkeh <http://max99x.com>`_
|
||||||
|
|
||||||
Introduction # {#intro}
|
Introduction
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
Welcome to Chapter 3 of the `Implementing a language with
|
Welcome to Chapter 3 of the `Implementing a language with
|
||||||
|
|
@ -25,7 +25,7 @@ page <http://www.mdevan.org/llvmpy/examples.html>`_
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Code Generation Setup # {#basics}
|
Code Generation Setup
|
||||||
=================================
|
=================================
|
||||||
|
|
||||||
In order to generate LLVM IR, we want some simple setup to get started.
|
In order to generate LLVM IR, we want some simple setup to get started.
|
||||||
|
|
@ -107,7 +107,7 @@ that this has already been done, and we'll just use it to emit code.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Expression Code Generation # {#exprs}
|
Expression Code Generation
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
Generating LLVM code for expression nodes is very straightforward: less
|
Generating LLVM code for expression nodes is very straightforward: less
|
||||||
|
|
@ -254,7 +254,7 @@ basic framework.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Function Code Generation # {#funcs}
|
Function Code Generation
|
||||||
===================================
|
===================================
|
||||||
|
|
||||||
Code generation for prototypes and functions must handle a number of
|
Code generation for prototypes and functions must handle a number of
|
||||||
|
|
@ -479,7 +479,7 @@ this bug; see what you can come up with! Here is a testcase:
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Driver Changes and Closing Thoughts # {#driver}
|
Driver Changes and Closing Thoughts
|
||||||
===============================================
|
===============================================
|
||||||
|
|
||||||
For now, code generation to LLVM doesn't really get us much, except that
|
For now, code generation to LLVM doesn't really get us much, except that
|
||||||
|
|
@ -584,7 +584,7 @@ running code!
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Full Code Listing # {#code}
|
Full Code Listing
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
Here is the complete code listing for our running example, enhanced with
|
Here is the complete code listing for our running example, enhanced with
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ Chapter 4: Adding JIT and Optimizer Support
|
||||||
Written by `Chris Lattner <mailto:sabre@nondot.org>`_ and `Max
|
Written by `Chris Lattner <mailto:sabre@nondot.org>`_ and `Max
|
||||||
Shawabkeh <http://max99x.com>`_
|
Shawabkeh <http://max99x.com>`_
|
||||||
|
|
||||||
Introduction # {#intro}
|
Introduction
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
Welcome to Chapter 4 of the `Implementing a language with
|
Welcome to Chapter 4 of the `Implementing a language with
|
||||||
|
|
@ -18,7 +18,7 @@ code for the Kaleidoscope language.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Trivial Constant Folding # {#trivialconstfold}
|
Trivial Constant Folding
|
||||||
==============================================
|
==============================================
|
||||||
|
|
||||||
Our demonstration for Chapter 3 is elegant and easy to extend.
|
Our demonstration for Chapter 3 is elegant and easy to extend.
|
||||||
|
|
@ -92,7 +92,7 @@ use, in the form of "passes".
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
LLVM Optimization Passes # {#optimizerpasses}
|
LLVM Optimization Passes
|
||||||
=============================================
|
=============================================
|
||||||
|
|
||||||
LLVM provides many optimization passes, which do many different sorts of
|
LLVM provides many optimization passes, which do many different sorts of
|
||||||
|
|
@ -216,7 +216,7 @@ about executing it!
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Adding a JIT Compiler # {#jit}
|
Adding a JIT Compiler
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
Code that is available in LLVM IR can have a wide variety of tools
|
Code that is available in LLVM IR can have a wide variety of tools
|
||||||
|
|
@ -388,7 +388,7 @@ issues along the way.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Full Code Listing # {#code}
|
Full Code Listing
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
Here is the complete code listing for our running example, enhanced with
|
Here is the complete code listing for our running example, enhanced with
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ Chapter 5: Extending the Language: Control Flow
|
||||||
Written by `Chris Lattner <mailto:sabre@nondot.org>`_ and `Max
|
Written by `Chris Lattner <mailto:sabre@nondot.org>`_ and `Max
|
||||||
Shawabkeh <http://max99x.com>`_
|
Shawabkeh <http://max99x.com>`_
|
||||||
|
|
||||||
Introduction # {#intro}
|
Introduction
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
Welcome to Chapter 5 of the `Implementing a language with
|
Welcome to Chapter 5 of the `Implementing a language with
|
||||||
|
|
@ -21,7 +21,7 @@ extend Kaleidoscope to have an if/then/else expression plus a simple
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
If/Then/Else # {#ifthen}
|
If/Then/Else
|
||||||
========================
|
========================
|
||||||
|
|
||||||
Extending Kaleidoscope to support if/then/else is quite straightforward.
|
Extending Kaleidoscope to support if/then/else is quite straightforward.
|
||||||
|
|
@ -60,7 +60,7 @@ down.
|
||||||
Now that we know what we "want", let's break this down into its
|
Now that we know what we "want", let's break this down into its
|
||||||
constituent pieces.
|
constituent pieces.
|
||||||
|
|
||||||
Lexer Extensions for If/Then/Else ## {#iflexer}
|
Lexer Extensions for If/Then/Else
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
|
|
||||||
The lexer extensions are straightforward. First we add new token classes
|
The lexer extensions are straightforward. First we add new token classes
|
||||||
|
|
@ -88,7 +88,7 @@ pretty simple stuff:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AST Extensions for If/Then/Else ## {#ifast}
|
AST Extensions for If/Then/Else
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
|
|
||||||
To represent the new expression we add a new AST node for it:
|
To represent the new expression we add a new AST node for it:
|
||||||
|
|
@ -109,7 +109,7 @@ To represent the new expression we add a new AST node for it:
|
||||||
|
|
||||||
The AST node just has pointers to the various subexpressions.
|
The AST node just has pointers to the various subexpressions.
|
||||||
|
|
||||||
Parser Extensions for If/Then/Else ## {#ifparser}
|
Parser Extensions for If/Then/Else
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
Now that we have the relevant tokens coming from the lexer and we have
|
Now that we have the relevant tokens coming from the lexer and we have
|
||||||
|
|
@ -160,7 +160,7 @@ Next we hook it up as a primary expression:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LLVM IR for If/Then/Else ## {#ifir}
|
LLVM IR for If/Then/Else
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
Now that we have it parsing and building the AST, the final piece is
|
Now that we have it parsing and building the AST, the final piece is
|
||||||
|
|
@ -260,7 +260,7 @@ really easy to generate the Phi node, so we choose to do it directly.
|
||||||
|
|
||||||
Okay, enough of the motivation and overview, lets generate code!
|
Okay, enough of the motivation and overview, lets generate code!
|
||||||
|
|
||||||
Code Generation for If/Then/Else ## {#ifcodegen}
|
Code Generation for If/Then/Else
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
|
||||||
In order to generate code for this, we implement the ``Codegen`` method
|
In order to generate code for this, we implement the ``Codegen`` method
|
||||||
|
|
@ -423,7 +423,7 @@ languages...
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
'for' Loop Expression # {#for}
|
'for' Loop Expression
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
Now that we know how to add basic control flow constructs to the
|
Now that we know how to add basic control flow constructs to the
|
||||||
|
|
@ -456,7 +456,7 @@ the future when we have mutable variables, it will get more useful.
|
||||||
As before, lets talk about the changes that we need to Kaleidoscope to
|
As before, lets talk about the changes that we need to Kaleidoscope to
|
||||||
support this.
|
support this.
|
||||||
|
|
||||||
Lexer Extensions for the 'for' Loop ## {#forlexer}
|
Lexer Extensions for the 'for' Loop
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
The lexer extensions are the same sort of thing as for if/then/else:
|
The lexer extensions are the same sort of thing as for if/then/else:
|
||||||
|
|
@ -490,7 +490,7 @@ The lexer extensions are the same sort of thing as for if/then/else:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AST Extensions for the 'for' Loop ## {#forast}
|
AST Extensions for the 'for' Loop
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
|
||||||
The AST node is just as simple. It basically boils down to capturing the
|
The AST node is just as simple. It basically boils down to capturing the
|
||||||
|
|
@ -510,7 +510,7 @@ variable name and the constituent expressions in the node.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Parser Extensions for the 'for' Loop ## {#forparser}
|
Parser Extensions for the 'for' Loop
|
||||||
----------------------------------------------------
|
----------------------------------------------------
|
||||||
|
|
||||||
The parser code is also fairly standard. The only interesting thing here
|
The parser code is also fairly standard. The only interesting thing here
|
||||||
|
|
@ -564,7 +564,7 @@ value to null in the AST node:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LLVM IR for the 'for' Loop ## {#forir}
|
LLVM IR for the 'for' Loop
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
|
|
||||||
Now we get to the good part: the LLVM IR we want to generate for this
|
Now we get to the good part: the LLVM IR we want to generate for this
|
||||||
|
|
@ -591,7 +591,7 @@ This loop contains all the same constructs we saw before: a phi node,
|
||||||
several expressions, and some basic blocks. Lets see how this fits
|
several expressions, and some basic blocks. Lets see how this fits
|
||||||
together.
|
together.
|
||||||
|
|
||||||
Code Generation for the 'for' Loop ## {#forcodegen}
|
Code Generation for the 'for' Loop
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
The first part of Codegen is very simple: we just output the start
|
The first part of Codegen is very simple: we just output the start
|
||||||
|
|
@ -788,7 +788,7 @@ operators <PythonLangImpl6.html>`_ to our poor innocent language.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Full Code Listing # {#code}
|
Full Code Listing
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
Here is the complete code listing for our running example, enhanced with
|
Here is the complete code listing for our running example, enhanced with
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ Chapter 6: Extending the Language: User-defined Operators
|
||||||
Written by `Chris Lattner <mailto:sabre@nondot.org>`_ and `Max
|
Written by `Chris Lattner <mailto:sabre@nondot.org>`_ and `Max
|
||||||
Shawabkeh <http://max99x.com>`_
|
Shawabkeh <http://max99x.com>`_
|
||||||
|
|
||||||
Introduction # {#intro}
|
Introduction
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
Welcome to Chapter 6 of the `Implementing a language with
|
Welcome to Chapter 6 of the `Implementing a language with
|
||||||
|
|
@ -27,7 +27,7 @@ At the end of this tutorial, we'll run through an example Kaleidoscope
|
||||||
application that `renders the Mandelbrot set <#example>`_. This gives an
|
application that `renders the Mandelbrot set <#example>`_. This gives an
|
||||||
example of what you can build with Kaleidoscope and its feature set.
|
example of what you can build with Kaleidoscope and its feature set.
|
||||||
|
|
||||||
User-defined Operators: the Idea # {#idea}
|
User-defined Operators: the Idea
|
||||||
==========================================
|
==========================================
|
||||||
|
|
||||||
The "operator overloading" that we will add to Kaleidoscope is more
|
The "operator overloading" that we will add to Kaleidoscope is more
|
||||||
|
|
@ -77,7 +77,7 @@ operators.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
User-defined Binary Operators # {#binary}
|
User-defined Binary Operators
|
||||||
=========================================
|
=========================================
|
||||||
|
|
||||||
Adding support for user-defined binary operators is pretty simple with
|
Adding support for user-defined binary operators is pretty simple with
|
||||||
|
|
@ -266,7 +266,7 @@ the previous framework we built for other operators. Adding unary
|
||||||
operators is a bit more challenging, because we don't have any framework
|
operators is a bit more challenging, because we don't have any framework
|
||||||
for it yet - let's see what it takes.
|
for it yet - let's see what it takes.
|
||||||
|
|
||||||
User-defined Unary Operators # {#unary}
|
User-defined Unary Operators
|
||||||
=======================================
|
=======================================
|
||||||
|
|
||||||
Since we don't currently support unary operators in the Kaleidoscope
|
Since we don't currently support unary operators in the Kaleidoscope
|
||||||
|
|
@ -386,7 +386,7 @@ predefined operators.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Kicking the Tires # {#example}
|
Kicking the Tires
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
It is somewhat hard to believe, but with a few simple extensions we've
|
It is somewhat hard to believe, but with a few simple extensions we've
|
||||||
|
|
@ -674,7 +674,7 @@ front-end.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Full Code Listing # {#code}
|
Full Code Listing
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
Here is the complete code listing for our running example, enhanced with
|
Here is the complete code listing for our running example, enhanced with
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ Chapter 7: Extending the Language: Mutable Variables / SSA construction
|
||||||
Written by `Chris Lattner <mailto:sabre@nondot.org>`_ and `Max
|
Written by `Chris Lattner <mailto:sabre@nondot.org>`_ and `Max
|
||||||
Shawabkeh <http://max99x.com>`_
|
Shawabkeh <http://max99x.com>`_
|
||||||
|
|
||||||
Introduction # {#intro}
|
Introduction
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
Welcome to Chapter 7 of the `Implementing a language with
|
Welcome to Chapter 7 of the `Implementing a language with
|
||||||
|
|
@ -31,7 +31,7 @@ for your front-end to build SSA form: LLVM provides highly tuned and
|
||||||
well tested support for this, though the way it works is a bit
|
well tested support for this, though the way it works is a bit
|
||||||
unexpected for some.
|
unexpected for some.
|
||||||
|
|
||||||
Why is this a hard problem? # {#why}
|
Why is this a hard problem?
|
||||||
====================================
|
====================================
|
||||||
|
|
||||||
To understand why mutable variables cause complexities in SSA
|
To understand why mutable variables cause complexities in SSA
|
||||||
|
|
@ -80,7 +80,7 @@ it. However, SSA construction requires non-trivial algorithms and data
|
||||||
structures, so it is inconvenient and wasteful for every front-end to
|
structures, so it is inconvenient and wasteful for every front-end to
|
||||||
have to reproduce this logic.
|
have to reproduce this logic.
|
||||||
|
|
||||||
Memory in LLVM # {#memory}
|
Memory in LLVM
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
The 'trick' here is that while LLVM does require all register values to
|
The 'trick' here is that while LLVM does require all register values to
|
||||||
|
|
@ -258,7 +258,7 @@ mutable variables now!
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Mutable Variables in Kaleidoscope # {#kalvars}
|
Mutable Variables in Kaleidoscope
|
||||||
==============================================
|
==============================================
|
||||||
|
|
||||||
Now that we know the sort of problem we want to tackle, lets see what
|
Now that we know the sort of problem we want to tackle, lets see what
|
||||||
|
|
@ -299,7 +299,7 @@ operator, then extend Kaleidoscope to support new variable definitions.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Adjusting Existing Variables for Mutation # {#adjustments}
|
Adjusting Existing Variables for Mutation
|
||||||
==========================================================
|
==========================================================
|
||||||
|
|
||||||
The symbol table in Kaleidoscope is managed at code generation time by
|
The symbol table in Kaleidoscope is managed at code generation time by
|
||||||
|
|
@ -503,7 +503,7 @@ we'll add the assignment operator.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
New Assignment Operator # {#assignment}
|
New Assignment Operator
|
||||||
=======================================
|
=======================================
|
||||||
|
|
||||||
With our current framework, adding a new assignment operator is really
|
With our current framework, adding a new assignment operator is really
|
||||||
|
|
@ -587,7 +587,7 @@ own local variables. Let's add this next!
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
User-defined Local Variables # {#localvars}
|
User-defined Local Variables
|
||||||
===========================================
|
===========================================
|
||||||
|
|
||||||
Adding var/in is just like any other other extensions we made to
|
Adding var/in is just like any other other extensions we made to
|
||||||
|
|
@ -802,7 +802,7 @@ dominance frontier" computation anywhere in sight.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Full Code Listing # {#code}
|
Full Code Listing
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
Here is the complete code listing for our running example, enhanced with
|
Here is the complete code listing for our running example, enhanced with
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue