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

SCM Repository

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

View of /branches/staging/src/compiler/mid-il/mid-il.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 435 - (download) (annotate)
Tue Oct 19 13:14:20 2010 UTC (9 years, 1 month ago) by jhr
Original Path: trunk/src/compiler/mid-il/mid-il.sml
File size: 9568 byte(s)
  Upated URL in header to diderot-language.cs.uchicago.edu
(* mid-il.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * Middle-level version of the Diderot IL.
 *
 * Note: this file is generated from gen/mid-il.spec and gen/mid-il.in.
 *)

structure MidOps =
  struct

    type ty = MidILTypes.ty

    val samety = MidILTypes.same
    val hashty = MidILTypes.hash
    val tyToString = MidILTypes.toString

    fun sameint (i1 : int, i2) = (i1 = i2)
    fun hashint i = Word.fromInt i
    fun intToString i = Int.toString i

    fun samestring (s1 : string, s2) = (s1 = s2)
    val hashstring = HashString.hashString
    fun stringToString s = String.concat["\"", s, "\""]

    datatype rator
      = Add of ty
      | Sub of ty
      | Mul of ty
      | Div of ty
      | Neg of ty
      | LT of ty
      | LTE of ty
      | EQ of ty
      | NEQ of ty
      | GT of ty
      | GTE of ty
      | Not
      | Max
      | Min
      | Sin
      | Cos
      | Pow
      | Dot of int
      | Cross
      | Select of ty * int
      | Norm of int
      | Scale of int
      | InvScale of int
      | CL
      | PrincipleEvec of ty
      | Subscript of ty
      | Floor of int
      | IntToReal
      | TruncToInt of int
      | RoundToInt of int
      | CeilToInt of int
      | FloorToInt of int
      | VoxelAddress of ImageInfo.info
      | LoadVoxels of RawTypes.ty * int
      | Transform of ImageInfo.info
      | EvalKernel of int * Kernel.kernel * int
      | LoadImage of ImageInfo.info
      | Inside of ImageInfo.info
      | Input of ty * string
      | InputWithDefault of ty * string

    fun arity (Add _) = 2
      | arity (Sub _) = 2
      | arity (Mul _) = 2
      | arity (Div _) = 2
      | arity (Neg _) = 1
      | arity (LT _) = 2
      | arity (LTE _) = 2
      | arity (EQ _) = 2
      | arity (NEQ _) = 2
      | arity (GT _) = 2
      | arity (GTE _) = 2
      | arity Not = 1
      | arity Max = 2
      | arity Min = 2
      | arity Sin = 1
      | arity Cos = 1
      | arity Pow = 2
      | arity (Dot _) = 2
      | arity Cross = 2
      | arity (Select _) = 1
      | arity (Norm _) = 1
      | arity (Scale _) = 2
      | arity (InvScale _) = 2
      | arity CL = 1
      | arity (PrincipleEvec _) = 2
      | arity (Subscript _) = 2
      | arity (Floor _) = 1
      | arity IntToReal = 1
      | arity (TruncToInt _) = 1
      | arity (RoundToInt _) = 1
      | arity (CeilToInt _) = 1
      | arity (FloorToInt _) = 1
      | arity (VoxelAddress _) = ~1
      | arity (LoadVoxels _) = 1
      | arity (Transform _) = 1
      | arity (EvalKernel _) = 1
      | arity (LoadImage _) = 0
      | arity (Inside _) = 1
      | arity (Input _) = 0
      | arity (InputWithDefault _) = 1

    fun same (Add(a0), Add(b0)) = samety(a0, b0)
      | same (Sub(a0), Sub(b0)) = samety(a0, b0)
      | same (Mul(a0), Mul(b0)) = samety(a0, b0)
      | same (Div(a0), Div(b0)) = samety(a0, b0)
      | same (Neg(a0), Neg(b0)) = samety(a0, b0)
      | same (LT(a0), LT(b0)) = samety(a0, b0)
      | same (LTE(a0), LTE(b0)) = samety(a0, b0)
      | same (EQ(a0), EQ(b0)) = samety(a0, b0)
      | same (NEQ(a0), NEQ(b0)) = samety(a0, b0)
      | same (GT(a0), GT(b0)) = samety(a0, b0)
      | same (GTE(a0), GTE(b0)) = samety(a0, b0)
      | same (Not, Not) = true
      | same (Max, Max) = true
      | same (Min, Min) = true
      | same (Sin, Sin) = true
      | same (Cos, Cos) = true
      | same (Pow, Pow) = true
      | same (Dot(a0), Dot(b0)) = sameint(a0, b0)
      | same (Cross, Cross) = true
      | same (Select(a0,a1), Select(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1)
      | same (Norm(a0), Norm(b0)) = sameint(a0, b0)
      | same (Scale(a0), Scale(b0)) = sameint(a0, b0)
      | same (InvScale(a0), InvScale(b0)) = sameint(a0, b0)
      | same (CL, CL) = true
      | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0)
      | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
      | same (Floor(a0), Floor(b0)) = sameint(a0, b0)
      | same (IntToReal, IntToReal) = true
      | same (TruncToInt(a0), TruncToInt(b0)) = sameint(a0, b0)
      | same (RoundToInt(a0), RoundToInt(b0)) = sameint(a0, b0)
      | same (CeilToInt(a0), CeilToInt(b0)) = sameint(a0, b0)
      | same (FloorToInt(a0), FloorToInt(b0)) = sameint(a0, b0)
      | same (VoxelAddress(a0), VoxelAddress(b0)) = ImageInfo.same(a0, b0)
      | same (LoadVoxels(a0,a1), LoadVoxels(b0,b1)) = RawTypes.same(a0, b0) andalso sameint(a1, b1)
      | same (Transform(a0), Transform(b0)) = ImageInfo.same(a0, b0)
      | same (EvalKernel(a0,a1,a2), EvalKernel(b0,b1,b2)) = sameint(a0, b0) andalso Kernel.same(a1, b1) andalso sameint(a2, b2)
      | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0)
      | same (Inside(a0), Inside(b0)) = ImageInfo.same(a0, b0)
      | same (Input(a0,a1), Input(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
      | same (InputWithDefault(a0,a1), InputWithDefault(b0,b1)) = samety(a0, b0) andalso samestring(a1, b1)
      | same _ = false

    fun hash (Add(a0)) = 0w3 + hashty a0
      | hash (Sub(a0)) = 0w5 + hashty a0
      | hash (Mul(a0)) = 0w7 + hashty a0
      | hash (Div(a0)) = 0w11 + hashty a0
      | hash (Neg(a0)) = 0w13 + hashty a0
      | hash (LT(a0)) = 0w17 + hashty a0
      | hash (LTE(a0)) = 0w19 + hashty a0
      | hash (EQ(a0)) = 0w23 + hashty a0
      | hash (NEQ(a0)) = 0w29 + hashty a0
      | hash (GT(a0)) = 0w31 + hashty a0
      | hash (GTE(a0)) = 0w37 + hashty a0
      | hash Not = 0w41
      | hash Max = 0w43
      | hash Min = 0w47
      | hash Sin = 0w53
      | hash Cos = 0w59
      | hash Pow = 0w61
      | hash (Dot(a0)) = 0w67 + hashint a0
      | hash Cross = 0w71
      | hash (Select(a0,a1)) = 0w73 + hashty a0 + hashint a1
      | hash (Norm(a0)) = 0w79 + hashint a0
      | hash (Scale(a0)) = 0w83 + hashint a0
      | hash (InvScale(a0)) = 0w89 + hashint a0
      | hash CL = 0w97
      | hash (PrincipleEvec(a0)) = 0w101 + hashty a0
      | hash (Subscript(a0)) = 0w103 + hashty a0
      | hash (Floor(a0)) = 0w107 + hashint a0
      | hash IntToReal = 0w109
      | hash (TruncToInt(a0)) = 0w113 + hashint a0
      | hash (RoundToInt(a0)) = 0w127 + hashint a0
      | hash (CeilToInt(a0)) = 0w131 + hashint a0
      | hash (FloorToInt(a0)) = 0w137 + hashint a0
      | hash (VoxelAddress(a0)) = 0w139 + ImageInfo.hash a0
      | hash (LoadVoxels(a0,a1)) = 0w149 + RawTypes.hash a0 + hashint a1
      | hash (Transform(a0)) = 0w151 + ImageInfo.hash a0
      | hash (EvalKernel(a0,a1,a2)) = 0w157 + hashint a0 + Kernel.hash a1 + hashint a2
      | hash (LoadImage(a0)) = 0w163 + ImageInfo.hash a0
      | hash (Inside(a0)) = 0w167 + ImageInfo.hash a0
      | hash (Input(a0,a1)) = 0w173 + hashty a0 + hashstring a1
      | hash (InputWithDefault(a0,a1)) = 0w179 + hashty a0 + hashstring a1

    fun toString (Add(a0)) = concat["Add<", tyToString a0, ">"]
      | toString (Sub(a0)) = concat["Sub<", tyToString a0, ">"]
      | toString (Mul(a0)) = concat["Mul<", tyToString a0, ">"]
      | toString (Div(a0)) = concat["Div<", tyToString a0, ">"]
      | toString (Neg(a0)) = concat["Neg<", tyToString a0, ">"]
      | toString (LT(a0)) = concat["LT<", tyToString a0, ">"]
      | toString (LTE(a0)) = concat["LTE<", tyToString a0, ">"]
      | toString (EQ(a0)) = concat["EQ<", tyToString a0, ">"]
      | toString (NEQ(a0)) = concat["NEQ<", tyToString a0, ">"]
      | toString (GT(a0)) = concat["GT<", tyToString a0, ">"]
      | toString (GTE(a0)) = concat["GTE<", tyToString a0, ">"]
      | toString Not = "Not"
      | toString Max = "Max"
      | toString Min = "Min"
      | toString Sin = "Sin"
      | toString Cos = "Cos"
      | toString Pow = "Pow"
      | toString (Dot(a0)) = concat["Dot<", intToString a0, ">"]
      | toString Cross = "Cross"
      | toString (Select(a0,a1)) = concat["Select<", tyToString a0, ",", intToString a1, ">"]
      | toString (Norm(a0)) = concat["Norm<", intToString a0, ">"]
      | toString (Scale(a0)) = concat["Scale<", intToString a0, ">"]
      | toString (InvScale(a0)) = concat["InvScale<", intToString a0, ">"]
      | toString CL = "CL"
      | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"]
      | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
      | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"]
      | toString IntToReal = "IntToReal"
      | toString (TruncToInt(a0)) = concat["TruncToInt<", intToString a0, ">"]
      | toString (RoundToInt(a0)) = concat["RoundToInt<", intToString a0, ">"]
      | toString (CeilToInt(a0)) = concat["CeilToInt<", intToString a0, ">"]
      | toString (FloorToInt(a0)) = concat["FloorToInt<", intToString a0, ">"]
      | toString (VoxelAddress(a0)) = concat["VoxelAddress<", ImageInfo.toString a0, ">"]
      | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", RawTypes.toString a0, ",", intToString a1, ">"]
      | toString (Transform(a0)) = concat["Transform<", ImageInfo.toString a0, ">"]
      | toString (EvalKernel(a0,a1,a2)) = concat["EvalKernel<", intToString a0, ",", Kernel.toString a1, ",", intToString a2, ">"]
      | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"]
      | toString (Inside(a0)) = concat["Inside<", ImageInfo.toString a0, ">"]
      | toString (Input(a0,a1)) = concat["Input<", tyToString a0, ",", stringToString a1, ">"]
      | toString (InputWithDefault(a0,a1)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ">"]

  end

structure MidIL = SSAFn(
  structure Ty = MidILTypes
  structure Op = MidOps)

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