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

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