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

SCM Repository

[diderot] View of /branches/vis12/src/compiler/high-to-mid/high-to-mid.sml
ViewVC logotype

View of /branches/vis12/src/compiler/high-to-mid/high-to-mid.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 334 - (download) (annotate)
Thu Aug 19 20:53:07 2010 UTC (9 years, 1 month ago) by jhr
Original Path: trunk/src/compiler/high-to-mid/high-to-mid.sml
File size: 1315 byte(s)
  Working on high to mid translation
(* high-to-mid.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

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