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 358 - (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 : jhr 334 structure SrcOp = HighOps
17 : jhr 280 structure DstIL = MidIL
18 : jhr 334 structure DstOp = MidOps
19 : jhr 280 structure VMap = SrcIL.Var.Map
20 :    
21 : jhr 334 fun lookupVar (env, x) = (case VMap.find(env, x)
22 :     of SOME x' => x'
23 :     | NONE => raise Fail("unknown variable "^SrcIL.Var.toString x)
24 :     (* end case *))
25 :    
26 : jhr 280 (* expand the field Inside operator into a image-space test *)
27 :     fun expandInside (env, result, pos, fld) = let
28 :     val pos' = lookupVar (env, pos)
29 : jhr 349 val fld = (case fld
30 : jhr 280 of SrcIL.OP(SrcOp.Field fld, []) => fld
31 :     | _ => raise Fail "bogus field binding"
32 :     (* end case *))
33 : jhr 328 fun expand (FieldDef.CONV(_, img, _)) = let
34 : jhr 334 val imgPos = DstIL.Var.new "x"
35 : jhr 280 in [
36 :     (imgPos, DstIL.OP(DstOp.Transform img, [pos'])),
37 :     (result, DstIL.OP(DstOp.Inside img, [imgPos]))
38 :     ] end
39 : jhr 328 | expand (FieldDef.NEG fld) = expand fld
40 :     | expand (FieldDef.SUM(fld1, dlf2)) = raise Fail "expandInside: SUM"
41 : jhr 280 in
42 :     expand fld
43 :     end
44 :    
45 : jhr 358 fun expandProbe (env, result, fld, pos) = let
46 :     val pos' = lookupVar (env, pos)
47 :     val fld = (case fld
48 :     of SrcIL.OP(SrcOp.Field fld, []) => fld
49 :     | _ => raise Fail "bogus field binding"
50 :     (* end case *))
51 :     in
52 :     Probe.expand (result, fld, pos')
53 :     end
54 : jhr 334
55 : jhr 328 fun translate prog = raise Fail "FIXME"
56 : jhr 314
57 : jhr 280 end

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