Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/branches/SMLNJ/src/compiler/CodeGen/main/machine-gen.sml
ViewVC logotype

Annotation of /sml/branches/SMLNJ/src/compiler/CodeGen/main/machine-gen.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 469 - (view) (download)

1 : monnier 427 (*
2 :     * This is a generic functor that hooks everything together
3 :     * into an MLRISC backend.
4 :     *)
5 :    
6 :     functor MachineGen
7 :     (structure MachSpec : MACH_SPEC (* machine specifications *)
8 :     structure PseudoOps : SMLNJ_PSEUDO_OP_TYPE (* pseudo ops *)
9 :     structure CpsRegs : CPSREGS (* CPS registers *)
10 :     where T.Region=CPSRegions
11 :     where T.Constant=SMLNJConstant
12 :     where T.PseudoOp=PseudoOps
13 :     structure InsnProps : INSN_PROPERTIES (* instruction properties *)
14 :     where I.Constant = CpsRegs.T.Constant
15 :     structure MLTreeComp : MLTREECOMP (* instruction selection *)
16 :     where T = CpsRegs.T
17 :     where I = InsnProps.I
18 :     structure Asm : INSTRUCTION_EMITTER (* assembly *)
19 :     where S = MLTreeComp.T.Stream
20 :     where P = PseudoOps
21 :     where I = MLTreeComp.I
22 :     structure BackPatch : BBSCHED (* machine code emitter *)
23 :     where F.P = PseudoOps
24 :     where F.I = Asm.I
25 :     structure RA : REGALLOC (* register allocator *)
26 :     where F = BackPatch.F
27 :     ) : MACHINE_GEN =
28 :     struct
29 :    
30 :     structure F = BackPatch.F
31 :     structure P = InsnProps
32 :     structure I = F.I
33 :     structure Cells = I.C
34 :     structure T = MLTreeComp.T
35 :     structure S = T.Stream
36 :     structure Asm = Asm
37 :     structure MachSpec = MachSpec
38 :     structure MLTreeComp= MLTreeComp
39 :    
40 :     val optimizerHook : (F.cluster -> F.cluster) option ref = ref NONE
41 :    
42 :     fun phase x = Stats.doPhase (Stats.makePhase x)
43 :    
44 :     fun opt cluster =
45 :     case !optimizerHook of
46 :     SOME f => f cluster
47 :     | NONE => cluster
48 :    
49 :     val ra = phase "MLRISC ra" RA.ra
50 :     val opt = phase "MLRISC optimization" opt
51 :     val bbsched = phase "MLRISC BackPatch.bbsched" BackPatch.bbsched
52 :     val finish = phase "MLRISC BackPatch.finish" BackPatch.finish
53 :    
54 :     fun compile cluster =
55 :     let val cluster = opt cluster
56 :     val cluster = ra cluster
57 :     in bbsched cluster end
58 :    
59 :     (* Flowgraph generation *)
60 :     structure FlowGraphGen =
61 :     ClusterGen(structure Flowgraph = F
62 :     structure InsnProps = InsnProps
63 :     structure MLTree = T
64 :     val output = compile
65 :     )
66 :    
67 :     (* GC Invocation *)
68 :     structure InvokeGC =
69 :     InvokeGC(structure Cells = Cells
70 :     structure C = CpsRegs
71 :     structure MS = MachSpec
72 :     )
73 :    
74 :     (* compilation of CPS to MLRISC *)
75 :     structure MLTreeGen =
76 :     MLRiscGen(structure MachineSpec=MachSpec
77 :     structure MLTreeComp=MLTreeComp
78 :     structure Cells=Cells
79 :     structure C=CpsRegs
80 :     structure InvokeGC=InvokeGC
81 :     structure PseudoOp=PseudoOps
82 :     structure CpsTreeify=CpsTreeify
83 :     structure Flowgen=FlowGraphGen
84 :     )
85 :     val gen = phase "MLRISC MLTreeGen.codegen" MLTreeGen.codegen
86 :    
87 :     fun codegen x =
88 :     (* initialize all hidden states first *)
89 :     (Label.reset();
90 :     InvokeGC.init();
91 :     BackPatch.cleanUp();
92 :     gen x
93 :     )
94 :     val copyProp = RA.cp
95 :    
96 :     end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0