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

SCM Repository

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

View of /trunk/src/compiler/mid-il/mid-il.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 314 - (download) (annotate)
Tue Aug 17 21:49:25 2010 UTC (9 years ago) by jhr
File size: 9028 byte(s)
  Working on compiler
(* mid-il.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.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

    datatype ty = BoolTy | StringTy | IntTy | VecTy of int

    fun samety (ty1 : ty, ty2) = (ty1 = ty2)
    fun hashty BoolTy = 0w1
      | hashty StringTy = 0w2
      | hashty IntTy = 0w3
      | hashty (VecTy d) = Word.fromInt d + 0w4
    fun tyToString BoolTy = "bool"
      | tyToString StringTy = "string"
      | tyToString IntTy = "int"
      | tyToString (VecTy 0) = "real"
      | tyToString (VecTy d) = "vec" ^ Int.toString d

    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
      | Dot of ty
      | Cross
      | Select of int
      | Norm of ty
      | Scale of ty
      | InvScale of ty
      | CL
      | PrincipleEvec of ty
      | Subscript of ty
      | Max
      | Min
      | Sin
      | Cos
      | Pow
      | Not
      | IntToReal
      | TruncToInt
      | RoundToInt
      | CeilToInt
      | FloorToInt
      | VoxelAddress of ImageInfo.info
      | LoadVoxels of RawTypes.ty * int
      | Transform of ImageInfo.info
      | Kernel of Kernel.kernel
      | DiffKernel
      | EvalKernel of int
      | LoadImage of ImageInfo.info
      | Inside
      | Input of string
      | InputWithDefault of 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 (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 Max = 2
      | arity Min = 2
      | arity Sin = 1
      | arity Cos = 1
      | arity Pow = 2
      | arity Not = 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 (Kernel _) = 0
      | arity DiffKernel = 1
      | arity (EvalKernel _) = 2
      | arity (LoadImage _) = 0
      | arity Inside = 2
      | 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 (Dot(a0), Dot(b0)) = samety(a0, b0)
      | same (Cross, Cross) = true
      | same (Select(a0), Select(b0)) = sameint(a0, b0)
      | same (Norm(a0), Norm(b0)) = samety(a0, b0)
      | same (Scale(a0), Scale(b0)) = samety(a0, b0)
      | same (InvScale(a0), InvScale(b0)) = samety(a0, b0)
      | same (CL, CL) = true
      | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0)
      | same (Subscript(a0), Subscript(b0)) = samety(a0, b0)
      | same (Max, Max) = true
      | same (Min, Min) = true
      | same (Sin, Sin) = true
      | same (Cos, Cos) = true
      | same (Pow, Pow) = true
      | same (Not, Not) = true
      | same (IntToReal, IntToReal) = true
      | same (TruncToInt, TruncToInt) = true
      | same (RoundToInt, RoundToInt) = true
      | same (CeilToInt, CeilToInt) = true
      | same (FloorToInt, FloorToInt) = true
      | 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 (Kernel(a0), Kernel(b0)) = Kernel.same(a0, b0)
      | same (DiffKernel, DiffKernel) = true
      | same (EvalKernel(a0), EvalKernel(b0)) = sameint(a0, b0)
      | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0)
      | same (Inside, Inside) = true
      | same (Input(a0), Input(b0)) = samestring(a0, b0)
      | same (InputWithDefault(a0), InputWithDefault(b0)) = samestring(a0, b0)
      | 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 (Dot(a0)) = 0w41 + hashty a0
      | hash Cross = 0w43
      | hash (Select(a0)) = 0w47 + hashint a0
      | hash (Norm(a0)) = 0w53 + hashty a0
      | hash (Scale(a0)) = 0w59 + hashty a0
      | hash (InvScale(a0)) = 0w61 + hashty a0
      | hash CL = 0w67
      | hash (PrincipleEvec(a0)) = 0w71 + hashty a0
      | hash (Subscript(a0)) = 0w73 + hashty a0
      | hash Max = 0w79
      | hash Min = 0w83
      | hash Sin = 0w89
      | hash Cos = 0w97
      | hash Pow = 0w101
      | hash Not = 0w103
      | hash IntToReal = 0w107
      | hash TruncToInt = 0w109
      | hash RoundToInt = 0w113
      | hash CeilToInt = 0w127
      | hash FloorToInt = 0w131
      | hash (VoxelAddress(a0)) = 0w137 + ImageInfo.hash a0
      | hash (LoadVoxels(a0,a1)) = 0w139 + RawTypes.hash a0 + hashint a1
      | hash (Transform(a0)) = 0w149 + ImageInfo.hash a0
      | hash (Kernel(a0)) = 0w151 + Kernel.hash a0
      | hash DiffKernel = 0w157
      | hash (EvalKernel(a0)) = 0w163 + hashint a0
      | hash (LoadImage(a0)) = 0w167 + ImageInfo.hash a0
      | hash Inside = 0w173
      | hash (Input(a0)) = 0w179 + hashstring a0
      | hash (InputWithDefault(a0)) = 0w181 + hashstring a0

    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 (Dot(a0)) = concat["Dot<", tyToString a0, ">"]
      | toString Cross = "Cross"
      | toString (Select(a0)) = concat["Select<", intToString a0, ">"]
      | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"]
      | toString (Scale(a0)) = concat["Scale<", tyToString a0, ">"]
      | toString (InvScale(a0)) = concat["InvScale<", tyToString a0, ">"]
      | toString CL = "CL"
      | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"]
      | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"]
      | toString Max = "Max"
      | toString Min = "Min"
      | toString Sin = "Sin"
      | toString Cos = "Cos"
      | toString Pow = "Pow"
      | toString Not = "Not"
      | toString IntToReal = "IntToReal"
      | toString TruncToInt = "TruncToInt"
      | toString RoundToInt = "RoundToInt"
      | toString CeilToInt = "CeilToInt"
      | toString FloorToInt = "FloorToInt"
      | toString (VoxelAddress(a0)) = concat["VoxelAddress<", ImageInfo.toString a0, ">"]
      | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", RawTypes.toString a0",", intToString a0, ">"]
      | toString (Transform(a0)) = concat["Transform<", ImageInfo.toString a0, ">"]
      | toString (Kernel(a0)) = concat["Kernel<", Kernel.toString a0, ">"]
      | toString DiffKernel = "DiffKernel"
      | toString (EvalKernel(a0)) = concat["EvalKernel<", intToString a0, ">"]
      | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"]
      | toString Inside = "Inside"
      | toString (Input(a0)) = concat["Input<", stringToString a0, ">"]
      | toString (InputWithDefault(a0)) = concat["InputWithDefault<", stringToString a0, ">"]

  end

structure MidIL = SSAFn(MidOps)

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