source: proto/pebble/trunk/src/ast/transforms/readme.txt @ 1242

Last change on this file since 1242 was 1242, checked in by shermer, 8 years ago

Pebble v0.6.0 initial commit

  • Property svn:mime-type set to text/plain
File size: 3.2 KB
Line 
1Package ast.transforms
2----------------------
3
4
5------------------
6Contents
7------------------
8
9This package contains classes that perform transformations of the AST.
10They are all based on ASTVisitor.
11
12        Simplifier              Given assumptions in the form of an ASTN, Simplifier
13                                        will traverse a given subtree and try to simplify the
14                                        tree based on the assumptions.  It uses a bottom-up
15                                        approach, so it does not do flow-based simplification
16                                        such as constant propagation, copy propagation, or
17                                        dead code elimination.  These optimizations are left
18                                        for a later stage to perform; perhaps this will be
19                                        done in incode or in the C++ back end. 
20
21        AssumptionIncorporator
22                                        This traverses the entire AST and finds the nodes that
23                                        have assumptions on them.  It then feeds these nodes
24                                        one-at-a-time to the Simplifier.  After running this
25                                        transformation, there will be no assumptions in the
26                                        tree.
27                                       
28        AssumptionDeletor
29                                        This transform merely deletes all assumptions from the
30                                        tree.  It is currently not used in the pebble compiler.
31
32        ASTtoIncode             This converts an AST into a fragment (set of BasicBlocks)
33                                        of incode.  It is the intermediate code generator for
34                                        pebble.
35
36        MacroTableBuilder
37                                        This goes through the AST and pulls out all macro definitions,
38                                        placing them into a table indexed by name.
39       
40        MacroTable              The table built by MacroTableBuilder.
41       
42        MacroExpander   Runs MacroTableBuilder and then finds each expandStatement in
43                                        the AST and replaces it with the proper macro.
44                                               
45
46See also ast/readme.txt for an overview of the AST package.
47
48
49------------------
50Terminology
51------------------
52
53------------------
54Normal operation
55------------------
56
57Transformations are intended to be run in this order:
58        Macro expander (calls Macro table builder)
59                Removes those ExecutionBlocks that have the macro flag set.
60                Replaces "expand" statements with the proper expanded macro.
61                (no ExecutionBlocks w/macro, expand remain in AST after)
62               
63        MoveLexDefsToBranchStarts (in package lexicalStream)
64                Moves lexical expression (sequence & char-class) to beginnings
65                of branches, then replaces them with their definition.
66                (no Sequence, CharClass remain in AST after)
67               
68        Assumption incorporator (which calls Simplifier)
69                (No Assumptions remain in AST after)
70               
71        ASTtoIncode
72                Converts AST to incode.
73       
74
75------------------
76Architecture notes
77------------------
78
79Not all ASTVisitor subclasses reside in this package.
80
81If ASTVisitors can nest, then AssumptionIncorporator can be simplified.  It
82probably should be, but this involves testing and verifying.
83
84The macro facility does not yet support macro arguments, but that would
85be fairly straightforward to include; simply run a visitor on the expanded
86macro and replace each occurrence of a parameter name with that parameter's
87expansion.  This gives a C-preprocessor-like solution, where argument expressions
88may get evaluated multiple times.  A more inline-like solution would put code to
89evaluate the arguments at the beginning of the macro, then replace parameter name
90with the name associated with the computed value of the corresponding argument.
91
Note: See TracBrowser for help on using the repository browser.