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

SCM Repository

[diderot] Annotation of /branches/vis15/src/compiler/simplify/util.sml
ViewVC logotype

Annotation of /branches/vis15/src/compiler/simplify/util.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3464 - (view) (download)

1 : jhr 3464 (* util.sml
2 :     *
3 :     * Utility code for Simplification.
4 :     *
5 :     * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
6 :     *
7 :     * COPYRIGHT (c) 2015 The University of Chicago
8 :     * All rights reserved.
9 :     *)
10 :    
11 :     structure Util : sig
12 :    
13 :     (* return information about a reduction operator *)
14 :     val reductionInfo : Var.t -> {
15 :     rator : Var.t, (* primitive operator *)
16 :     init : Literal.t, (* identity element to use for initialization *)
17 :     mvs : SimpleTypes.meta_arg list (* meta-variable arguments for primitive application *)
18 :     }
19 :    
20 :     end = struct
21 :    
22 :     structure BV = BasisVars
23 :     structure L = Literal
24 :     structure R = RealLit
25 :    
26 :     fun reductionInfo rator =
27 :     if Var.same(BV.red_all, rator)
28 :     then {rator = BV.op_and, init = L.Bool true, mvs = []}
29 :     else if Var.same(BV.red_exists, rator)
30 :     then {rator = BV.op_or, init = L.Bool false, mvs = []}
31 :     else if Var.same(BV.red_max, rator)
32 :     then {rator = BV.fn_max, init = L.Real R.negInf, mvs = []}
33 :     else if Var.same(BV.red_mean, rator)
34 :     then raise Fail "FIXME: 'mean' reduction not yet supported"
35 :     else if Var.same(BV.red_min, rator)
36 :     then {rator = BV.fn_min, init = L.Real R.posInf, mvs = []}
37 :     else if Var.same(BV.red_product, rator)
38 :     then {rator = BV.mul_rr, init = L.Real R.one, mvs = []}
39 :     else if Var.same(BV.red_sum, rator)
40 :     then {rator = BV.add_tt, init = L.Real R.one, mvs = [SimpleTypes.SHAPE[]]}
41 :     else if Var.same(BV.red_variance, rator)
42 :     then raise Fail "FIXME: 'variance' reduction not yet supported"
43 :     else raise Fail(Var.uniqueNameOf rator ^ " is not a reduction operator")
44 :    
45 :     end

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