Debian Codegraph @

lib/mlrisc-lib/MLRISC/IR/mlrisc-cfg-gen2.sml

raw
1 (*
2 * This module builds a CFG from a stream of instructions.
3 * We use the FLOWGRPAH_GEN interface here, which is the
4 * default interface used by the core MLRISC.
5 *
6 * -- Allen
7 *)
8
9 functor CFGGen
10 (structure CFG : CONTROL_FLOW_GRAPH
11 structure InsnProps : INSN_PROPERTIES
12 structure MLTree : MLTREE
13 sharing CFG.I = InsnProps.I
14 sharing MLTree.Constant = InsnProps.I.Constant
15 sharing MLTree.PseudoOp = CFG.P
16 ) : FLOWGRAPH_GEN =
17 struct
18
19 structure I = CFG.I
20 structure C = I.C
21 structure S = MLTree.Stream
22 structure T = MLTree
23 structure P = CFG.P
24 structure Builder = ControlFlowGraphGen
25 (structure CFG = CFG
26 structure Stream = S
27 structure InsnProps = InsnProps
28 )
29
30 type flowgraph = CFG.cfg
31
32 fun newStream{compile,flowgraph} =
33 let val cfg = ref(case flowgraph of
34 NONE => CFG.new()
35 | SOME cfg => cfg
36 )
37 val {stream,next} = Builder.builder(!cfg)
38 val S.STREAM{beginCluster,endCluster,pseudoOp,emit,exitBlock,
39 getAnnotations,comment,annotation,
40 defineLabel,entryLabel,...}
41 = stream
42 fun endCFG a =
43 let val _ = endCluster a
44 val oldCFG = !cfg
45 val newCFG = CFG.new()
46 in cfg := newCFG;
47 next newCFG;
48 compile oldCFG
49 end
50
51 in S.STREAM{beginCluster = beginCluster,
52 endCluster = endCFG,
53 pseudoOp = pseudoOp,
54 emit = emit,
55 exitBlock = exitBlock,
56 comment = comment,
57 annotation = annotation,
58 getAnnotations = getAnnotations,
59 defineLabel = defineLabel,
60 entryLabel = entryLabel
61 }
62 end
63
64 end
65