This section is for those technical minds who would like to read the SML# Compiler Source code.
We believe that the following two tables are sufficient for you to get started with the source code. If you would like to know any particular aspect of the compiler, please contact Atsushi Ohori (ohori at riec dot tohoku dot ac dot jp).
Language | Structure Name | Directory |
---|---|---|
Abstract Syntax Trees | Absyn | compiler/absyn |
Untyped Pattern Expressions (1) | PatternCalc | compile/patterncalc |
Untyped Pattern Expressions (2) | PatternCalcWithTvars | compile/patterncalcWithTvars| |
Typed Pattern Expressions(1) | TypedCalc | compile/typedcalc |
Typed Pattern Expressions(2) | TypedFlatCalc | compile/typedflatcalc |
Polymorphic Record Calculus | RecordCalc | compile/recordcalc |
Typed Lambda Calculs | TypedLambda | compile/typedlambda |
Lambda Calculs with Static Annotation | AnnotatedCalc | compile/annotatedcalc |
Multiple Value Calculs | MultipleValueCalc | compile/multiplevaluecalc |
Cluster Calculs | ClusterCalc | compile/clustercalc |
Record/Bitmap-Passing Calculus | RBUCCalc | compile/rbucalc |
Typed A-Normal Form | ANormal | compile/anormal |
SML# Symbolict Instruction Set | SymbolicInstructions | compile/symbolicinstructions |
SML# Instruction | Instructions | instructions/compile/instructions |
SML# Bytecode Language | Instructions.cc(definitions in C) | instructions/runtime/instructions |
Step | description | compile module | directory | input | output |
---|---|---|---|---|---|
the compiler top level | Top | compile/toplevel | |||
1. | Parsing | Parser | compile/parse | the source program | Absyn |
2. | Elaboration | Elaborator | compile/elaborate | Absyn | PattarnCalc |
3. | function definition optimization | VALREC_Optimizer | compile/valrecoptimization | PatternCalc | PatternCalc |
4. | simple function declaration elaboration (without uncurrying optimization) | TransFundecl | compile/valrecoptimization | PatternCalc | PatternCalc |
5. | user type variable evaluation | SetTVars | compile/settvars | PatternCalc | PatternCalcWithTvars |
6. | type inference | TypeInferencer | compile/typeinference | PatternCalcWithTvars | TypedCalc |
7. | uncurrying optimization | UncurryFundecl | compile/typeinference | TypedCalc | TypedCalc |
8. | printer code generation | PrinterGenerator | compile/printergeneration | TypedCalc | TypedCalc |
9. | module conpilation | ModuleCompiler | compile/modulecompilation | TypedCalc | TypedFlatCalc |
10. | match compilation | MatchCompiler | compile/matchcompilation | TypedFlatCalc | RecordCalc |
11. | Typed Lambda Normalization | TLNormalization | compile/tlnormalization | RecordCalc | TypedLambda |
12. | Type Check | compile/typedlambda | TypedLambda | TypedLambda | |
13. | Static Analysis | compile/staticanalysis | TypedLambda | AnnotatedCalc | |
14. | Record Unboxing | RecordUnboxing | compile/recordunboxing | AnnotatedCalc | MultipleValueCalc |
15. | Reference Elimination | ReferenceElimination | compile/mvoptimization | MultipleValueCalc | MultipleValueCalc |
16. | Useless Code Elimination | UselessCodeElimination | compile/mvoptimization | MultipleValueCalc | MultipleValueCalc |
17. | Type Check | MVTypeCheck | compile/multiplevaluecalc | MultipleValueCalc | _ |
18. | Clustering | Clustering | compiler/clustering | MultipleValueCalc | ClusterCalc |
19. | Record/Bitmap/unbox/closure conversion | RBUTransformation | compile/rbutransformation | ClusterCalc | RBUCalc |
20. | A-normalization | ANormalTranslator | compile/anormaltransform | RBUCalc | ANormal |
21. | generate intermediate language | ILTransformation | compile/iltransformation | ANormal | IntermediateLanguage |
22. | symbolic code generation | Linearizer | compile/linearize | ANormal | SymbolicInstructions |
23. | stack slot optimization | Reallocater | compile/sioptimization | SymbolicInstructions | SymbolicInstructions |
24. | assemble | Assembler | compile/assemble | SymbolicInstructions | Instructions |
25. | code emmition | ExecutableSerializer | instructions/compiler | Instructions | (bytecode in binary form) |