(* mid-to-low.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) * All rights reserved. * * Translation from HighIL to MidIL representations. *) structure HighToMid : sig val translate : HighIL.program -> MidIL.program end = struct structure SrcIL = HighIL structure SrcOp = HighOps structure DstIL = MidIL structure DstOp = MidOps structure VMap = SrcIL.Var.Map fun lookupVar (env, x) = (case VMap.find(env, x) of SOME x' => x' | NONE => raise Fail("unknown variable "^SrcIL.Var.toString x) (* end case *)) (* expand the field Inside operator into a image-space test *) fun expandInside (env, result, pos, fld) = let val pos' = lookupVar (env, pos) val fld = (case valueOf fld of SrcIL.OP(SrcOp.Field fld, []) => fld | _ => raise Fail "bogus field binding" (* end case *)) fun expand (FieldDef.CONV(_, img, _)) = let val imgPos = DstIL.Var.new "x" in [ (imgPos, DstIL.OP(DstOp.Transform img, [pos'])), (result, DstIL.OP(DstOp.Inside img, [imgPos])) ] end | expand (FieldDef.NEG fld) = expand fld | expand (FieldDef.SUM(fld1, dlf2)) = raise Fail "expandInside: SUM" in expand fld end val expandProbe = Probe.expand fun translate prog = raise Fail "FIXME" end