Debian Codegraph @

lib/mlrisc-lib/MLRISC/emit/cfgEmit.sml

raw
1 (* cfgEmit.sml
2 *
3 * COPYRIGHT (c) 2001 Bell Labs, Lucent Technologies
4 *
5 * This module takes a flowgraph and an assembly emitter module and
6 * ties them together into one. The output is sent to AsmStream.
7 * --Allen
8 *
9 * TODO: Need to check for the REORDER/NOREORDER annotation on
10 * blocks and call P.Client.AsmPseudoOps.toString function to
11 * print out the appropriate assembler directive. -- Lal.
12 *)
13
14 functor CFGEmit
15 (structure E : INSTRUCTION_EMITTER
16 structure CFG : CONTROL_FLOW_GRAPH (* where I = E.I and P = E.S.P *)
17 where type I.addressing_mode = E.I.addressing_mode
18 and type I.ea = E.I.ea
19 and type I.instr = E.I.instr
20 and type I.instruction = E.I.instruction
21 and type I.operand = E.I.operand
22 where type P.Client.pseudo_op = E.S.P.Client.pseudo_op
23 and type P.T.Basis.cond = E.S.P.T.Basis.cond
24 and type P.T.Basis.div_rounding_mode = E.S.P.T.Basis.div_rounding_mode
25 and type P.T.Basis.ext = E.S.P.T.Basis.ext
26 and type P.T.Basis.fcond = E.S.P.T.Basis.fcond
27 and type P.T.Basis.rounding_mode = E.S.P.T.Basis.rounding_mode
28 and type P.T.Constant.const = E.S.P.T.Constant.const
29 and type ('s,'r,'f,'c) P.T.Extension.ccx = ('s,'r,'f,'c) E.S.P.T.Extension.ccx
30 and type ('s,'r,'f,'c) P.T.Extension.fx = ('s,'r,'f,'c) E.S.P.T.Extension.fx
31 and type ('s,'r,'f,'c) P.T.Extension.rx = ('s,'r,'f,'c) E.S.P.T.Extension.rx
32 and type ('s,'r,'f,'c) P.T.Extension.sx = ('s,'r,'f,'c) E.S.P.T.Extension.sx
33 and type P.T.I.div_rounding_mode = E.S.P.T.I.div_rounding_mode
34 and type P.T.Region.region = E.S.P.T.Region.region
35 and type P.T.ccexp = E.S.P.T.ccexp
36 and type P.T.fexp = E.S.P.T.fexp
37 (* and type P.T.labexp = E.S.P.T.labexp *)
38 and type P.T.mlrisc = E.S.P.T.mlrisc
39 and type P.T.oper = E.S.P.T.oper
40 and type P.T.rep = E.S.P.T.rep
41 and type P.T.rexp = E.S.P.T.rexp
42 and type P.T.stm = E.S.P.T.stm
43 ) : ASSEMBLY_EMITTER =
44 struct
45 structure CFG = CFG
46
47 fun asmEmit (Graph.GRAPH graph, blocks) = let
48 val CFG.INFO{annotations=an, data, decls, ...} = #graph_info graph
49 val E.S.STREAM{pseudoOp,defineLabel,emit,annotation,comment,...} =
50 E.makeStream (!an)
51 fun emitIt (id, CFG.BLOCK{labels, annotations=a, align, insns, ...}) = (
52 case !align of NONE => () | SOME p => (pseudoOp p);
53 List.app defineLabel (!labels);
54 List.app emitAn (!a);
55 List.app emit (rev (!insns)))
56 and emitAn a = if Annotations.toString a = "" then () else annotation(a)
57 in
58 List.app emitAn (!an);
59 List.app pseudoOp (rev (!decls));
60 pseudoOp(PseudoOpsBasisTyp.TEXT);
61 List.app emitIt blocks;
62 List.app pseudoOp (rev (!data))
63
64 end
65 end
66
67
68
69
70
71
72
73
74
75