summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2012-08-20 00:22:47 -0400
committerOri Bernstein <ori@eigenstate.org>2012-08-20 00:22:47 -0400
commit2d4a3c9fb38f76aba6110eab656c0980d674a135 (patch)
tree48d9abe53758930856cedce085845216efe3a97f /doc
parent72ae53f0e02ffc1be882560fbe3bbb13fbc854f6 (diff)
downloadmc-2d4a3c9fb38f76aba6110eab656c0980d674a135.tar.gz
More docs.
Diffstat (limited to 'doc')
-rw-r--r--doc/compiler.txt39
1 files changed, 37 insertions, 2 deletions
diff --git a/doc/compiler.txt b/doc/compiler.txt
index 83d886d..e0763e2 100644
--- a/doc/compiler.txt
+++ b/doc/compiler.txt
@@ -227,20 +227,55 @@ TABLE OF CONTENTS:
cjmp cond .loop .end
.end:
- Boolean expressions are simplified as described in section 8.4 of the
- Dragon book[1]
+ Boolean expressions are simplified to a location to jump to, as
+ described in section 8.4 of the Dragon book[1].
3.2. Complex Expressions:
+ Complex expressions such as copying types larger than a single machine
+ word, pulling members out of structures, emulated multiplication and
+ division for larger integers sizes, and similar operations are reduced
+ to trees that are expressible in terms of simple machine operations.
+
+ By the end of the simplification pass, the following operators should
+ not be present in the trees:
+
+ Obad Oret Opreinc Opostinc Opredec Opostdec Olor Oland Oaddeq
+ Osubeq Omuleq Odiveq Omodeq Oboreq Obandeq Obxoreq Obsleq
+ Obsreq Omemb Oslice Oidx Osize Numops Oucon Ouget Otup Oarr
+ Oslbase Osllen Ocast
+
+
4. OPTIMIZATION:
+ Currently, there is virtually no optimization done on the trees after
+ flattening. The only optimization that is done is constant folding.
+
4.1. Constant Folding:
+ Expressions with constant values are simplified algebraically. For
+ example, the expression 'x*1' is simplified to simply 'x', '0/n' is
+ simplified to '0', and so on.
+
+
5. CODE GENERATION:
5.1. Instruction Selection:
+
+ Instruction selection is done via a simple hand written bottom up pass
+ over the tree. Common patterns such as scaled or offset indexing are
+ recognized by the patterns, but no attempts at finding an optimal
+ tiling are made.
+
5.2. Register Allocation:
+ Register allocation is done via the algorithm described in "Iterated
+ Regster Coalescing", by Appel and George. As of the time of this
+ writing, the register allocator does not yet implement overlapping
+ register classes. This will be done as described in "A generalized
+ algorithm for graph-coloring register allocation", by Smith, Ramsey,
+ and Holloway.
+
6: TUTORIAL: ADDING A STATEMENT:
6.1. Stubbing in the node types: