|
@@ -9,19 +9,74 @@ Revising the architecture to better match Dybvig's P523 compiler
|
|
|
|
|
|
* to do: insert type checking
|
|
|
|
|
|
+
|
|
|
+R1:
|
|
|
+ exp ::= x | n | (op exp*) | (let ([x exp]) exp)
|
|
|
+ R1 ::= (program exp)
|
|
|
+
|
|
|
+flatten (uncover-locals, remove-let, remove-complex-opera*)
|
|
|
+|
|
|
|
+V
|
|
|
+C0:
|
|
|
+ arg ::= x | n
|
|
|
+ exp ::= arg | (op arg*)
|
|
|
+ stmt ::= (assign x exp)
|
|
|
+ tail ::= (return exp) | (block stmt* tail)
|
|
|
+ C0 ::= (program (x*) tail)
|
|
|
+
|
|
|
+select-instructions
|
|
|
+|
|
|
|
+V
|
|
|
+
|
|
|
+assign-homes
|
|
|
+|
|
|
|
+V
|
|
|
+
|
|
|
+patch-instructions
|
|
|
+|
|
|
|
+V
|
|
|
+
|
|
|
+print-x86
|
|
|
+|
|
|
|
+V
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+--------------------------------------------------------------------------------
|
|
|
+
|
|
|
R2:
|
|
|
|
|
|
exp ::= x | n | #t | #f | (op exp*) | (let ([x exp]) exp) | (if exp exp exp)
|
|
|
R2 ::= (program exp)
|
|
|
|
|
|
-flatten (uncover-locals, remove-let, remove-complex-opera*)
|
|
|
+
|
|
|
+remove-complex-opera* (rco)
|
|
|
|
|
|
|
V
|
|
|
|
|
|
arg ::= x | n | #t | #f
|
|
|
- exp ::= arg | (if exp exp exp) | (op arg*) | (begin stmt* exp)
|
|
|
- stmt ::= (set! x exp) | (if exp stmt stmt) | (begin stmt* stmt)
|
|
|
- C2 ::= (program (x*) stmt)
|
|
|
+ exp ::= arg | (op arg*) | (let ([x exp]) exp) | (if exp exp exp)
|
|
|
+ R2 ::= (program exp)
|
|
|
+
|
|
|
+create-CFG
|
|
|
+|
|
|
|
+V
|
|
|
+
|
|
|
+ arg ::= x | n | #t | #f
|
|
|
+ exp ::= arg | (op arg*)
|
|
|
+ tail ::= (jump label) | (if (rel-op exp*) label label) | (return exp)
|
|
|
+ stmt ::= (assign x exp)
|
|
|
+ CFG ::= (program ([label . (block stmt* tail)] tail)
|
|
|
+
|
|
|
+flatten (uncover-locals, remove-let, remove-complex-opera*)
|
|
|
+|
|
|
|
+V
|
|
|
+C1:
|
|
|
+ arg ::= x | n | #t | #f
|
|
|
+ stmt ::= (assign x arg) | (assign (op arg*))
|
|
|
+ pred ::= #t | #f | (pred-op val*) | (if pred pred pred) | (begin stmt* pred)
|
|
|
+ tail ::= (return exp) | (block stmt* tail)
|
|
|
+ C1 ::= (program (x*) tail)
|
|
|
|
|
|
select-instructions
|
|
|
|
|
|
@@ -49,6 +104,7 @@ expose-basic-blocks (create-cfg)
|
|
|
|
|
|
|
V
|
|
|
|
|
|
+ inst ::= ...
|
|
|
stmt ::= (jump label) | (if (pre-op arg*) label label) | (begin instr* stmt)
|
|
|
cfg-x86 ::= (program ([label . stmt]*) stmt)
|
|
|
|