Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /trunk/src/compiler/IL/ssa-check-fn.sml
ViewVC logotype

Annotation of /trunk/src/compiler/IL/ssa-check-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3349 - (view) (download)

1 : jhr 198 (* ssa-check-fn.sml
2 :     *
3 : jhr 3349 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     *
5 :     * COPYRIGHT (c) 2015 The University of Chicago
6 : jhr 198 * All rights reserved.
7 :     *
8 :     * Consistency checking for SSA representation
9 :     *)
10 :    
11 :     functor SSACheckFn (IL : SSA) : sig
12 :    
13 :     end = struct
14 :    
15 :     (* things to check:
16 :     * 1) SSA property
17 :     * 2) variable usage counts
18 :     * 3) successor/predecessor matching in CFG
19 :     * 4) arity of operators
20 :     *)
21 :    
22 : jhr 265 fun checkRHS (OP(rator, args)) =
23 :     (* check operator arity *)
24 :     if Op.arity rator <> List.length args
25 :     then (* error *)
26 :     else ()
27 :     | checkRHS _ = ()
28 :    
29 :     fun checkNode (node as IL.ND{kind, ...}) = let
30 :     val preds = IL.Node.preds nd
31 :     val succs = IL.Node.succs nd
32 :     val inList = List.exists (fn nd => IL.Node.same(node, nd))
33 :     in
34 :     if List.all (fn nd => inList(IL.Node.succs nd)) (IL.Node.preds nd)
35 :     then ()
36 :     else (* error: predecessor/successor mismatch *);
37 :     if List.all (fn nd => inList(IL.Node.preds nd)) (IL.Node.succs nd)
38 :     then ()
39 :     else (* error: successor/predecessor mismatch *);
40 :     case kind
41 :     of NULL => (* error: unexpected NULL *)
42 :     | JOIN{phis, ...} =>
43 :     | BLOCK{body, ...} =>
44 :     | _ => ()
45 :     (* end case *))
46 :     end
47 :    
48 : jhr 198 end

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