Debian Codegraph @

lib/mlrisc-lib/MLRISC/Tools/MDL/mdl-gen.sml

raw
1 (*
2 * Generate machine code modules from machine description
3 *)
4 functor MDLGen
5 (structure Comp : MDL_COMPILE
6 structure Parser : MDL_PARSER_DRIVER
7 structure Cells : MDL_GEN_MODULE
8 structure Shuffle : MDL_GEN_MODULE
9 structure Instr : MDL_GEN_MODULE
10 structure Asm : MDL_GEN_MODULE
11 structure MC : MDL_GEN_MODULE
12 structure RTLComp : MDL_RTL_COMP
13 structure Jumps : MDL_GEN_MODULE
14 structure Dasm : MDL_GEN_MODULE
15 structure Props : MDL_GEN_MODULE2
16 structure Rewrite : MDL_GEN_MODULE2
17 structure RTLProps : MDL_GEN_MODULE2
18 structure SSAProps : MDL_GEN_MODULE2
19 (*structure DelaySlots : MD_GEN_MODULE
20 structure SchedProps : MD_GEN_MODULE2 *)
21 sharing Comp =
22 Cells.Comp =
23 Shuffle.Comp =
24 Instr.Comp =
25 Asm.Comp =
26 MC.Comp =
27 Dasm.Comp =
28 Props.Comp =
29 Jumps.Comp =
30 Rewrite.Comp =
31 RTLComp.Comp =
32 RTLProps.Comp (* =
33 DelaySlots.Comp =
34 SSAProps.Comp =
35 SchedProps.Comp*)
36 sharing Parser.Ast = Comp.Ast
37 sharing RTLComp = Rewrite.RTLComp =
38 RTLProps.RTLComp = SSAProps.RTLComp = Props.RTLComp
39 ) : MDL_GEN =
40 struct
41
42 fun doIt f x =
43 if !Comp.Error.errorCount = 0 then
44 (f x handle Comp.Error.Error => ())
45 else ()
46
47 (* Generate code! *)
48 fun codegen md =
49 (Comp.Error.openLogFile(Comp.pathName md "" ".log");
50 Cells.gen md;
51 Instr.gen md;
52 Shuffle.gen md;
53 Asm.gen md;
54 MC.gen md;
55 Dasm.gen md;
56 Jumps.gen md;
57 (* DelaySlots.gen md; *)
58 (*
59 let val compiled_rtls = RTLComp.compile md
60 in doIt RTLComp.gen compiled_rtls;
61 doIt Rewrite.gen compiled_rtls;
62 doIt Props.gen compiled_rtls;
63 doIt RTLProps.gen compiled_rtls;
64 doIt SSAProps.gen compiled_rtls;
65 doIt SchedProps.gen compiled_rtls;
66 RTLComp.dumpLog compiled_rtls
67 end; *)
68 Comp.Error.log(Comp.Error.status());
69 Comp.Error.closeLogFile()
70 )
71
72 fun gen file =
73 (print("[Processing "^file^"]\n");
74 Comp.Error.init();
75 codegen(Comp.compile(file,Parser.load file)) (* build ast *)
76 )
77
78 fun exit() = if !Comp.Error.errorCount > 0 then
79 OS.Process.failure
80 else OS.Process.success
81
82 end