diff python/doc/compiler.rst @ 273:6b3a874edd6e

Added some docs
author Windel Bouwman
date Mon, 02 Sep 2013 17:40:21 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/doc/compiler.rst	Mon Sep 02 17:40:21 2013 +0200
@@ -0,0 +1,91 @@
+
+
+Compiler
+========
+
+This chapter describes the design of the compiler.
+
+
+Overview
+--------
+
+The compiler consists a frontend, mid-end and back-end. The frontend deals with
+source file parsing and semantics checking. The mid-end performs optimizations.
+This is optional. The back-end generates machine code. The front-end produces
+intermediate code. This is a simple representation of the source. The back-end
+can accept this kind of representation. This way the compiler is portable and
+a front end can be constructed without having to do the rest.
+
+.. graphviz::
+
+  
+   digraph x {
+   rankdir="LR"
+   1 [label="c3 source file"]
+   10 [label="c3 front end" ]
+   11 [label="language X front end" ]
+   20 [label="mid end" ]
+   30 [label="back end for X86" ]
+   31 [label="back end for ARM" ]
+   40 [label="object file"]
+   1 -> 10
+   10 -> 20 [label="IR-code"]
+   11 -> 20 [label="IR-code"]
+   20 -> 30 [label="IR-code"]
+   20 -> 31 [label="IR-code"]
+   30 -> 40
+   }
+
+IR-code
+-------
+The IR-code is implemented in the ir package.
+
+.. autoclass:: ir.Module
+   :members:
+
+.. autoclass:: ir.Function
+   :members:
+
+.. autoclass:: ir.Block
+   :members:
+
+.. autoclass:: ir.Statement
+   :members:
+
+.. autoclass:: ir.Expression
+   :members:
+
+.. # .. inheritance-diagram:: ir.Statement
+
+Front-end
+---------
+
+For the front-end a recursive descent parser is created for the c3 language.
+This is a subset of the C language with some additional features.
+
+.. automodule:: c3
+   :members:
+   :undoc-members:
+
+.. autoclass:: c3.Parser
+    :members:
+
+.. autoclass:: c3.Builder
+    :members:
+
+.. autoclass:: c3.CodeGenerator
+    :members:
+
+Back-end
+--------
+
+The back-end is more complicated. There are several steps to be taken here.
+
+1. Instruction selection
+2. register allocation
+3. Peep hole optimization?
+4. real code generation
+
+.. automodule:: codegenarm
+   :members:
+