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

SCM Repository

[diderot] Annotation of /trunk/src/compiler/high-to-mid/high-to-mid.sml
ViewVC logotype

Annotation of /trunk/src/compiler/high-to-mid/high-to-mid.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (view) (download)

1 : jhr 280 (* high-to-mid.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *
6 :     * Translation from HighIL to MidIL representations.
7 :     *)
8 :    
9 :     structure HighToMid : sig
10 :    
11 :     val translate : HighIL.program -> MidIL.program
12 :    
13 :     end = struct
14 :    
15 :     structure SrcIL = HighIL
16 :     structure SrcOp = SrcIL.Op
17 :     structure DstIL = MidIL
18 :     structure DstOp = DstIL.Op
19 :     structure VMap = SrcIL.Var.Map
20 :    
21 :     (* expand the field Inside operator into a image-space test *)
22 :     fun expandInside (env, result, pos, fld) = let
23 :     val pos' = lookupVar (env, pos)
24 :     val fld = (case valueOf fld
25 :     of SrcIL.OP(SrcOp.Field fld, []) => fld
26 :     | _ => raise Fail "bogus field binding"
27 :     (* end case *))
28 :     fun expand (FieldDef.CONV(_, img, _)) => let
29 :     val imgPos = newVar ??
30 :     in [
31 :     (imgPos, DstIL.OP(DstOp.Transform img, [pos'])),
32 :     (result, DstIL.OP(DstOp.Inside img, [imgPos]))
33 :     ] end
34 :     | expand (FieldDef.NEG fld) => expand fld
35 :     | expand (FieldDef.SUM(fld1, dlf2)) => raise Fail "expandInside: SUM"
36 :     in
37 :     expand fld
38 :     end
39 :    
40 :     fun expandProbe (env, result, fld, pos) = let
41 :     val pos' = lookupVar (env, pos)
42 :     val fld = (case valueOf fld
43 :     of SrcIL.OP(SrcOp.Field fld, []) => fld
44 :     | _ => raise Fail "bogus field binding"
45 :     (* end case *))
46 :     fun expand (result, FieldDef.CONV(0, img, h)) => let
47 :     val imgPos = newVar ??
48 :     val xformStm = (imgPos, DstIL.OP(DstOp.Transform img, [pos']))
49 :     (* generate samples based on kernel support and dimensionality of image *)
50 :     in
51 :     xformStm :: probeStms
52 :     end
53 :     | expand (FieldDef.CONV(k, img, h)) => ??
54 :     | expand (FieldDef.NEG fld) => let
55 :     val r = newVar ??
56 :     val stms = expand (r, fld)
57 :     in
58 :     (r, DstIL.OP(DstOp.Neg ty, [r])) :: stms
59 :     end
60 :     | expand (FieldDef.SUM(fld1, dlf2)) => raise Fail "expandInside: SUM"
61 :     in
62 :     List.rev (expand (result, fld))
63 :     end
64 :    
65 :     end

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