Debian Codegraph @

lib/mlrisc-lib/MLRISC/ir-archive/reducibility.sml

raw
1 (*
2 * This module tests for reducibility of a loop
3 *
4 * -- Allen
5 *)
6 functor Reducibility(Loop : LOOP_STRUCTURE) : REDUCIBILITY =
7 struct
8 structure Loop = Loop
9 structure Dom = Loop.Dom
10 structure G = Graph
11
12 structure Derived = DerivedGraph(Dom)
13
14 fun is_reducible(Loop) =
15 let val Dom = Loop.dom Loop
16 val headers = Loop.header Loop
17 val Derived as G.GRAPH derived = Derived.derived_graph Dom
18 val N = #capacity derived ()
19 val irreducible = BitSet.create N
20 fun markIrreducible([_],_) = () (* simple cycles are reducible *)
21 | markIrreducible(cycle,_) =
22 app (fn n => BitSet.set(irreducible,n)) cycle
23 val _ = GraphSCC.scc Derived markIrreducible ()
24 fun isReducible n =
25 let val h = Array.sub(headers,n)
26 in not(BitSet.contains(irreducible,n)) end
27 in isReducible
28 end
29 end