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

SCM Repository

[diderot] View of /branches/pure-cfg/src/compiler/mid-il/mid-il-types.sml
ViewVC logotype

View of /branches/pure-cfg/src/compiler/mid-il/mid-il-types.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 548 - (download) (annotate)
Thu Feb 17 22:41:53 2011 UTC (9 years, 1 month ago) by jhr
File size: 1539 byte(s)
  Lots of changes to push image info through to the code generator.
(* mid-il-types.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * Types for the MidIL.
 *)

structure MidILTypes =
  struct

    datatype ty
      = BoolTy | StringTy
      | IVecTy of int		(* integers; both scalars and vectors *)
      | VecTy of int		(* reals; both scalars and vectors *)
      | AddrTy of ImageInfo.info (* voxel address *)
      | ImageTy of ImageInfo.info

    val intTy = IVecTy 1
    val realTy = VecTy 1

    fun same (BoolTy, BoolTy) = true
      | same (StringTy, StringTy) = true
      | same (IVecTy n1, IVecTy n2) = (n1 = n2)
      | same (VecTy n1, VecTy n2) = (n1 = n2)
      | same (AddrTy info1, AddrTy info2) = ImageInfo.same(info1, info2)
      | same (ImageTy info1, ImageTy info2) = ImageInfo.same(info1, info2)
      | same _ = false

    fun hash BoolTy = 0w1
      | hash StringTy = 0w2
      | hash (IVecTy d) = 0w7 * Word.fromInt d + 0w3
      | hash (VecTy d) = 0w11 * Word.fromInt d + 0w4
      | hash (AddrTy info) = 0w5 + ImageInfo.hash info
      | hash (ImageTy info) = 0w13 * ImageInfo.hash info + 0w6

    fun toString BoolTy = "bool"
      | toString StringTy = "string"
      | toString (IVecTy 1) = "int"
      | toString (IVecTy d) = "int" ^ Int.toString d
      | toString (VecTy 1) = "real"
      | toString (VecTy d) = "real" ^ Int.toString d
      | toString (AddrTy info) = concat["addr(", ImageInfo.toString info, ")"]
      | toString (ImageTy info) = concat["image(", ImageInfo.toString info, ")"]

  end

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