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/trunk/src/compiler/CodeGen/main/machine-gen.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 838 - (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 : blume 773 structure Ext : SMLNJ_MLTREE_EXT
10 : monnier 427 structure CpsRegs : CPSREGS (* CPS registers *)
11 :     where T.Region=CPSRegions
12 : george 717 and T.Constant=SMLNJConstant
13 :     and T.PseudoOp=PseudoOps
14 : blume 773 and T.Extension=Ext
15 : monnier 427 structure InsnProps : INSN_PROPERTIES (* instruction properties *)
16 :     where I.Constant = CpsRegs.T.Constant
17 :     structure MLTreeComp : MLTREECOMP (* instruction selection *)
18 :     where T = CpsRegs.T
19 : george 717 and I = InsnProps.I
20 : monnier 427 structure Asm : INSTRUCTION_EMITTER (* assembly *)
21 :     where S = MLTreeComp.T.Stream
22 : george 717 and P = PseudoOps
23 :     and I = MLTreeComp.I
24 : george 555 structure Shuffle : SHUFFLE (* shuffling copies *)
25 :     where I = MLTreeComp.I
26 : monnier 427 structure BackPatch : BBSCHED (* machine code emitter *)
27 :     where F.P = PseudoOps
28 : george 717 and F.I = Asm.I
29 : blume 773 structure RA : CLUSTER_OPTIMIZATION (* register allocator *)
30 : monnier 427 where F = BackPatch.F
31 : blume 773 structure CCalls : C_CALLS (* native C call generator *)
32 :     where T = CpsRegs.T
33 : george 823 structure OmitFramePtr : OMIT_FRAME_POINTER where F=BackPatch.F
34 : monnier 427 ) : MACHINE_GEN =
35 :     struct
36 :    
37 :     structure F = BackPatch.F
38 :     structure P = InsnProps
39 :     structure I = F.I
40 :     structure Cells = I.C
41 :     structure T = MLTreeComp.T
42 :     structure S = T.Stream
43 :     structure Asm = Asm
44 : george 555 structure Shuffle = Shuffle
45 : monnier 427 structure MachSpec = MachSpec
46 :     structure MLTreeComp= MLTreeComp
47 :    
48 : george 823 fun omitFramePointer(cluster as F.CLUSTER{annotations, ...}) =
49 :     if #contains MLRiscAnnotations.USES_VIRTUAL_FRAME_POINTER (!annotations) then
50 : blume 838 (OmitFramePtr.omitframeptr
51 :     {vfp=CpsRegs.vfp, cl=cluster, idelta=SOME 0:Int32.int option};
52 : george 823 cluster)
53 :     else cluster
54 :    
55 : george 555 type mlriscPhase = string * (F.cluster -> F.cluster)
56 : monnier 427
57 :     fun phase x = Stats.doPhase (Stats.makePhase x)
58 : george 555 fun makePhase(name,f) = (name, phase name f)
59 : monnier 427
60 : george 555 val mc = phase "MLRISC BackPatch.bbsched" BackPatch.bbsched
61 :     val finish = phase "MLRISC BackPatch.finish" BackPatch.finish
62 : leunga 744 val ra = phase "MLRISC ra" RA.run
63 : george 823 val omitfp = phase "MLRISC omit frame pointer" omitFramePointer
64 : monnier 427
65 : george 555 val raPhase = ("ra",ra)
66 :    
67 : george 823
68 :     val optimizerHook =
69 :     ref [("ra", ra),
70 :     ("omitfp", omitfp)
71 :     ]
72 :    
73 :    
74 : monnier 427 (* Flowgraph generation *)
75 :     structure FlowGraphGen =
76 :     ClusterGen(structure Flowgraph = F
77 :     structure InsnProps = InsnProps
78 :     structure MLTree = T
79 :     )
80 :    
81 :     (* GC Invocation *)
82 :     structure InvokeGC =
83 :     InvokeGC(structure Cells = Cells
84 :     structure C = CpsRegs
85 :     structure MS = MachSpec
86 :     )
87 :    
88 : george 823 fun compile cluster =
89 : george 555 let fun runPhases([],cluster) = cluster
90 :     | runPhases((_,f)::phases,cluster) = runPhases(phases,f cluster)
91 :     in mc(runPhases(!optimizerHook,cluster))
92 : george 823 end
93 : monnier 498
94 : monnier 427 (* compilation of CPS to MLRISC *)
95 :     structure MLTreeGen =
96 :     MLRiscGen(structure MachineSpec=MachSpec
97 :     structure MLTreeComp=MLTreeComp
98 :     structure Cells=Cells
99 : blume 773 structure Ext = Ext
100 : monnier 427 structure C=CpsRegs
101 :     structure InvokeGC=InvokeGC
102 :     structure PseudoOp=PseudoOps
103 :     structure Flowgen=FlowGraphGen
104 : blume 773 structure CCalls = CCalls
105 : monnier 498 val compile = compile
106 : monnier 427 )
107 : george 823
108 : monnier 498
109 : monnier 427 val gen = phase "MLRISC MLTreeGen.codegen" MLTreeGen.codegen
110 :    
111 :     fun codegen x =
112 :     (* initialize all hidden states first *)
113 :     (Label.reset();
114 :     InvokeGC.init();
115 :     BackPatch.cleanUp();
116 :     gen x
117 :     )
118 :    
119 :     end

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