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

SCM Repository

[diderot] View of /trunk/src/compiler/high-il/check-ops.sml
ViewVC logotype

View of /trunk/src/compiler/high-il/check-ops.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 404 - (download) (annotate)
Thu Oct 14 22:11:38 2010 UTC (8 years, 7 months ago) by jhr
File size: 2442 byte(s)
  Started to work on checking code for HighIL
(* check-ops.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
 * All rights reserved.
 *)

structure CheckOps : sig

    val sign : HighOps.rator -> HighILTypes.ty * HighILTypes.ty list

  end = struct

    structure Op = HighOps
    structure Ty = HighILTypes

    fun sign rator = (case rator
	   of Op.Add ty => (ty, [ty, ty])
	    | Op.Sub ty => (ty, [ty, ty])
	    | Op.Mul ty => (ty, [ty, ty])
	    | Op.Div ty => (ty, [ty, ty])
	    | Op.Neg ty => (ty, [ty])
	    | Op.LT ty => (Ty.BoolTy, [ty, ty])
	    | Op.LTE ty => (Ty.BoolTy, [ty, ty])
	    | Op.EQ ty => (Ty.BoolTy, [ty, ty])
	    | Op.NEQ ty => (Ty.BoolTy, [ty, ty])
	    | Op.GT ty => (Ty.BoolTy, [ty, ty])
	    | Op.GTE ty => (Ty.BoolTy, [ty, ty])
	    | Op.Max => (Ty.realTy, [Ty.realTy, Ty.realTy])
	    | Op.Min => (Ty.realTy, [Ty.realTy, Ty.realTy])
	    | Op.Sin => (Ty.realTy, [Ty.realTy])
	    | Op.Cos => (Ty.realTy, [Ty.realTy])
	    | Op.Pow => (Ty.realTy, [Ty.realTy, Ty.realTy])
	    | Op.Not => (Ty.BoolTy, [Ty.BoolTy])
	    | Op.Dot ty => (Ty.realTy, [ty, ty])
	    | Op.Cross => (Ty.vec3Ty, [Ty.vec3Ty, Ty.vec3Ty])
	    | Op.Norm => (Ty.realTy, [ty])
	    | Op.Scale ty => (ty, [Ty.realTy, ty])
	    | Op.InvScale ty => (ty, [ty, Ty.realTy])
	    | Op.CL => 
	    | Op.PrincipleEvec ty => (Ty.realTy, [ty])
	    | Op.Slice(ty as Ty.Tensor dd, m) => let
		val (resDims, idxDims) = let
		      fun f (d, false, (rds, ids)) = (d::rds, ids)
			| f (_, true, (rds, ids)) = (rds, Ty.IntTy::ids)
		      in
			ListPair.foldr f ([], []) (dd, mask)
		      end
		in
		  (Ty.Tensor rds, ty::idxDims)
		end
	    | Op.Subscript(ty as Ty.Tensor dd) =>
		(Ty.realTy, ty :: List.map (fn _ => Ty.IntTy) dd)
	    | Op.IntToReal => (Ty.realTy, [Ty.IntTy])
	    | Op.TruncToInt => (Ty.IntTy, [Ty.realTy])
	    | Op.RoundToInt => (Ty.IntTy, [Ty.realTy])
	    | Op.CeilToInt => (Ty.IntTy, [Ty.realTy])
	    | Op.FloorToInt => (Ty.IntTy, [Ty.realTy])
	    | Op.Kernel _ => (Ty.KernelTy, [])
	    | Op.LoadImage _ => (Ty.ImageTy, [])
	    | Op.Convolve => 
	    | Op.Inside => 
	    | Op.Field _ => (Ty.FieldTy, [])
	    | Op.AddField =>  (Ty.FieldTy, [Ty.FieldTy, Ty.FieldTy])
	    | Op.ScaleField => (Ty.FieldTy, [Ty.realTy, Ty.FieldTy])
	    | Op.NegField => (Ty.FieldTy, [Ty.FieldTy])
	    | Op.DiffField => (Ty.FieldTy, [Ty.FieldTy])
	    | Op.Probe => ??
	    | Op.Input of string
	    | Op.InputWithDefault of string
	  (* end case *))

  end

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