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

SCM Repository

[diderot] View of /trunk/src/compiler/IL/types.sml
ViewVC logotype

View of /trunk/src/compiler/IL/types.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (download) (annotate)
Fri Jan 8 20:44:57 2010 UTC (9 years, 9 months ago) by jhr
Original Path: trunk/src/IL/types.sml
File size: 1651 byte(s)
  Starting to work on internal-language representation of types.
(* types.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
 * All rights reserved.
 *)

structure Types : TYPES =
  sig

  (* kinds for type variables *)
    datatype kind
      = TK_DIM		(* ranges over dimensions (1, 2, ...) *)
      | TK_INT		(* ranges over integer types *)
      | TK_FLT		(* ranges over floating-point types *)
      | TK_RAW		(* ranges over raw (scalar) types *)

    datatype raw_ty
      = Int8 | UInt8
      | Int16 | UInt16
      | Int32 | UInt32
      | Int64 | UInt64
      | Float | Double

    datatype ty
      = T_Var of var
      | T_Bool
    (* scalars, vectors, matrices, etc. *)
      | T_Tensor of {order : dim list, ty : raw_ty}
    (* data sets from NNRD *)
      | T_Data of {
	  dim : dim,		(* 2D or 3D data set *)
	  order : dim list,	(* tensor order/dimension info *)
	  rep_ty : ty		(* representation type of elements (raw kind) *)
	}
    (* continuous field reconstructed from a data set *)
      | T_Field of {
	  dim : dim,		(* 2D or 3D field *)
	  order : dim list,	(* tensor order/dimension info *)
	  rep_ty : ty,		(* representation type of elements (raw kind) *)
	  ty : ty		(* type of samples (float kind) *)
	}

    and dim = DIM of word | DIMVAR of var

  (* type variables *)
    and var = TV of {
	  stamp : Stamp.stamp,
	  kind : kind
	}

  (* given a dataset or field type, return the element type, which will be
   * a tensor type.
   *)
    fun elemTypeOf (T_Data{order, rep_ty, ...}) = T_Tensor{order=order, ty=rep_ty}
      | elemTypeOf (T_Field{order, ty, ...}) = T_Tensor{order=order, ty=ty}
      | elemTypeOf _ = raise Fail "not a dataset/field"

  end

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