Debian Codegraph @

lib/mlrisc-lib/MLRISC/SSA/ssa-gen.sml

raw
1 (*
2 * This module can be used to build a stripped down SSA graph directly from
3 * an MLTREE stream.
4 *)
5 functor SSAGen
6 (structure MLTree : MLTREE
7 structure CFG : CONTROL_FLOW_GRAPH
8 structure InsnProps : INSN_PROPERTIES
9 structure SSA : SSA
10 where CFG = CFG
11 where I.Constant = MLTree.Constant
12 sharing InsnProps.I = CFG.I
13 sharing MLTree.Stream.P = CFG.P
14 ) : FLOWGRAPH_GEN =
15 struct
16 structure T = MLTree
17 structure I = SSA.I
18 structure C = I.C
19 structure S = T.Stream
20 structure Builder = ControlFlowGraphGen
21 (structure CFG = CFG
22 structure Stream = S
23 structure InsnProps = InsnProps
24 )
25
26 type flowgraph = CFG.cfg
27
28 fun error msg = MLRiscErrorMsg.error("SSAGen",msg)
29
30 fun newStream{compile, flowgraph} =
31 let val cfg = case flowgraph of
32 SOME cfg => cfg
33 | NONE => CFG.new(C.regmap())
34 val {stream,next} = Builder.builder cfg
35 val S.STREAM{beginCluster,endCluster,pseudoOp,
36 emit,exitBlock,comment,annotation,defineLabel,
37 entryLabel,alias,...} = stream
38
39 fun endCFG a = (endCluster a;
40 next(CFG.new(C.regmap()));
41 compile cfg
42 )
43
44 fun phi _ = error "phi"
45 in S.STREAM{beginCluster= beginCluster,
46 endCluster = endCFG,
47 pseudoOp = pseudoOp,
48 emit = emit,
49 exitBlock = exitBlock,
50 comment = comment,
51 annotation = annotation,
52 defineLabel = defineLabel,
53 entryLabel = entryLabel,
54 alias = alias,
55 phi = phi
56 }
57 end
58 end
59