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

SCM Repository

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

View of /trunk/src/compiler/IL/gen/high-il.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 186 - (download) (annotate)
Thu Jul 29 04:26:57 2010 UTC (9 years, 6 months ago) by jhr
File size: 12255 byte(s)
  Add generator for IL operator structures.
(* high-il.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
 * All rights reserved.
 *
 * High-level version of the Diderot IL.
 *
 * Note: this file is generated from gen/high-il.spec and gen/high-il.in.
 *)

structure HighOps =
  struct

    type ty = BoolTy | StringTy | IntTy | TensorTy of int list

    fun sameTy (ty1 : ty, ty2) = (ty1 = ty2)

    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
      | 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
      | LoadImage of ImageInfo.info
      | Inside
      | Field of FieldDef.field_def
      | Probe
      | Transform of ImageInfo.info

    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 (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 (LoadImage _) = 1
      | arity Inside = 2
      | arity (Field _) = 0
      | arity Probe = 2
      | arity (Transform _) = 1

    fun same (Add a, Add b) = samety(a, b)
      | same (Sub a, Sub b) = samety(a, b)
      | same (Mul a, Mul b) = samety(a, b)
      | same (Div a, Div b) = samety(a, b)
      | same (Neg a, Neg b) = samety(a, b)
      | same (LT a, LT b) = samety(a, b)
      | same (LTE a, LTE b) = samety(a, b)
      | same (EQ a, EQ b) = samety(a, b)
      | same (NEQ a, NEQ b) = samety(a, b)
      | same (GT a, GT b) = samety(a, b)
      | same (GTE a, GTE b) = samety(a, b)
      | same (Dot a, Dot b) = samety(a, b)
      | same (Cross, Cross) = true
      | same (Norm a, Norm b) = samety(a, b)
      | same (Scale a, Scale b) = samety(a, b)
      | same (InvScale a, InvScale b) = samety(a, b)
      | same (CL, CL) = true
      | same (PrincipleEvec a, PrincipleEvec b) = samety(a, b)
      | same (Subscript a, Subscript b) = samety(a, b)
      | 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 (LoadImage a, LoadImage b) = ImageInfo.same(a, b)
      | same (Inside, Inside) = true
      | same (Field a, Field b) = FieldDef.same(a, b)
      | same (Probe, Probe) = true
      | same (Transform a, Transform b) = ImageInfo.same(a, b)
      | same _ = false

    fun hash (Add a) = 0w3 + hashty a
      | hash (Sub a) = 0w5 + hashty a
      | hash (Mul a) = 0w7 + hashty a
      | hash (Div a) = 0w11 + hashty a
      | hash (Neg a) = 0w13 + hashty a
      | hash (LT a) = 0w17 + hashty a
      | hash (LTE a) = 0w19 + hashty a
      | hash (EQ a) = 0w23 + hashty a
      | hash (NEQ a) = 0w29 + hashty a
      | hash (GT a) = 0w31 + hashty a
      | hash (GTE a) = 0w37 + hashty a
      | hash (Dot a) = 0w41 + hashty a
      | hash Cross = 0w43
      | hash (Norm a) = 0w47 + hashty a
      | hash (Scale a) = 0w53 + hashty a
      | hash (InvScale a) = 0w59 + hashty a
      | hash CL = 0w61
      | hash (PrincipleEvec a) = 0w67 + hashty a
      | hash (Subscript a) = 0w71 + hashty a
      | hash Max = 0w73
      | hash Min = 0w79
      | hash Sin = 0w83
      | hash Cos = 0w89
      | hash Pow = 0w97
      | hash Not = 0w101
      | hash IntToReal = 0w103
      | hash TruncToInt = 0w107
      | hash RoundToInt = 0w109
      | hash CeilToInt = 0w113
      | hash FloorToInt = 0w127
      | hash (LoadImage a) = 0w131 + ImageInfo.hash a
      | hash Inside = 0w137
      | hash (Field a) = 0w139 + FieldDef.hash a
      | hash Probe = 0w149
      | hash (Transform a) = 0w151 + ImageInfo.hash a

    fun toString (Add a) = concat["Add(", tyToString a, ")"]
      | toString (Sub a) = concat["Sub(", tyToString a, ")"]
      | toString (Mul a) = concat["Mul(", tyToString a, ")"]
      | toString (Div a) = concat["Div(", tyToString a, ")"]
      | toString (Neg a) = concat["Neg(", tyToString a, ")"]
      | toString (LT a) = concat["LT(", tyToString a, ")"]
      | toString (LTE a) = concat["LTE(", tyToString a, ")"]
      | toString (EQ a) = concat["EQ(", tyToString a, ")"]
      | toString (NEQ a) = concat["NEQ(", tyToString a, ")"]
      | toString (GT a) = concat["GT(", tyToString a, ")"]
      | toString (GTE a) = concat["GTE(", tyToString a, ")"]
      | toString (Dot a) = concat["Dot(", tyToString a, ")"]
      | toString Cross = "Cross"
      | toString (Norm a) = concat["Norm(", tyToString a, ")"]
      | toString (Scale a) = concat["Scale(", tyToString a, ")"]
      | toString (InvScale a) = concat["InvScale(", tyToString a, ")"]
      | toString CL = "CL"
      | toString (PrincipleEvec a) = concat["PrincipleEvec(", tyToString a, ")"]
      | toString (Subscript a) = concat["Subscript(", tyToString a, ")"]
      | 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 (LoadImage a) = concat["LoadImage(", ImageInfo.toString a, ")"]
      | toString Inside = "Inside"
      | toString (Field a) = concat["Field(", FieldDef.toString a, ")"]
      | toString Probe = "Probe"
      | toString (Transform a) = concat["Transform(", ImageInfo.toString a, ")"]

  end

structure HighIL = SSAFn(HighOps)
 hash (Add a) = 0w587 + hash ty  a
      | hash (Add a) = 0w593 + hash ty  a
      | hash (Add a) = 0w599 + hash ty  a
      | hash (Add a) = 0w601 + hash ty  a
      | hash (Add a) = 0w607 + hash ty  a
      | hash (Add a) = 0w613 + hash ty  a
      | hash (Add a) = 0w617 + hash ty  a
      | hash (Add a) = 0w619 + hash ty  a
      | hash (Add a) = 0w631 + hash ty  a
      | hash (Add a) = 0w641 + hash ty  a
      | hash (Add a) = 0w643 + hash ty  a
      | hash (Add a) = 0w647 + hash ty  a
      | hash (Add a) = 0w653 + hash ty  a
      | hash (Add a) = 0w659 + hash ty  a
      | hash (Add a) = 0w661 + hash ty  a
      | hash (Add a) = 0w673 + hash ty  a
      | hash (Add a) = 0w677 + hash ty  a
      | hash (Add a) = 0w683 + hash ty  a
      | hash (Add a) = 0w691 + hash ty  a
      | hash (Add a) = 0w701 + hash ty  a
      | hash (Add a) = 0w709 + hash ty  a
      | hash (Add a) = 0w719 + hash ty  a
      | hash (Add a) = 0w727 + hash ty  a
      | hash (Add a) = 0w733 + hash ty  a
      | hash (Add a) = 0w739 + hash ty  a
      | hash (Add a) = 0w743 + hash ty  a
      | hash (Add a) = 0w751 + hash ty  a
      | hash (Add a) = 0w757 + hash ty  a
      | hash (Add a) = 0w761 + hash ty  a
      | hash (Add a) = 0w769 + hash ty  a
      | hash (Add a) = 0w773 + hash ty  a
      | hash (Add a) = 0w787 + hash ty  a
      | hash (Add a) = 0w797 + hash ty  a
      | hash (Add a) = 0w809 + hash ty  a
      | hash (Add a) = 0w811 + hash ty  a
      | hash (Add a) = 0w821 + hash ty  a
      | hash (Add a) = 0w823 + hash ty  a
      | hash (Add a) = 0w827 + hash ty  a
      | hash (Add a) = 0w829 + hash ty  a
      | hash (Add a) = 0w839 + hash ty  a
      | hash (Add a) = 0w853 + hash ty  a
      | hash (Add a) = 0w857 + hash ty  a
      | hash (Add a) = 0w859 + hash ty  a
      | hash (Add a) = 0w863 + hash ty  a
      | hash (Add a) = 0w877 + hash ty  a
      | hash (Add a) = 0w881 + hash ty  a
      | hash (Add a) = 0w883 + hash ty  a
      | hash (Add a) = 0w887 + hash ty  a
      | hash (Add a) = 0w907 + hash ty  a
      | hash (Add a) = 0w911 + hash ty  a
      | hash (Add a) = 0w919 + hash ty  a
      | hash (Add a) = 0w929 + hash ty  a
      | hash (Add a) = 0w937 + hash ty  a
      | hash (Add a) = 0w941 + hash ty  a
      | hash (Add a) = 0w947 + hash ty  a
      | hash (Add a) = 0w953 + hash ty  a
      | hash (Add a) = 0w967 + hash ty  a
      | hash (Add a) = 0w971 + hash ty  a
      | hash (Add a) = 0w977 + hash ty  a
      | hash (Add a) = 0w983 + hash ty  a
      | hash (Add a) = 0w991 + hash ty  a
      | hash (Add a) = 0w997 + hash ty  a
      | hash (Add a) = 0w1009 + hash ty  a
      | hash (Add a) = 0w1013 + hash ty  a
      | hash (Add a) = 0w1019 + hash ty  a
      | hash (Add a) = 0w1021 + hash ty  a
      | hash (Add a) = 0w1031 + hash ty  a
      | hash (Add a) = 0w1033 + hash ty  a
      | hash (Add a) = 0w1039 + hash ty  a
      | hash (Add a) = 0w1049 + hash ty  a
      | hash (Add a) = 0w1051 + hash ty  a
      | hash (Add a) = 0w1061 + hash ty  a
      | hash (Add a) = 0w1063 + hash ty  a
      | hash (Add a) = 0w1069 + hash ty  a
      | hash (Add a) = 0w1087 + hash ty  a
      | hash (Add a) = 0w1091 + hash ty  a
      | hash (Add a) = 0w1093 + hash ty  a
      | hash (Add a) = 0w1097 + hash ty  a
      | hash (Add a) = 0w1103 + hash ty  a
      | hash (Add a) = 0w1109 + hash ty  a
      | hash (Add a) = 0w1117 + hash ty  a
      | hash (Add a) = 0w1123 + hash ty  a
      | hash (Add a) = 0w1129 + hash ty  a
      | hash (Add a) = 0w1151 + hash ty  a
      | hash (Add a) = 0w1153 + hash ty  a
      | hash (Add a) = 0w1163 + hash ty  a
      | hash (Add a) = 0w1171 + hash ty  a
      | hash (Add a) = 0w1181 + hash ty  a
      | hash (Add a) = 0w1187 + hash ty  a
      | hash (Add a) = 0w1193 + hash ty  a
      | hash (Add a) = 0w1201 + hash ty  a
      | hash (Add a) = 0w1213 + hash ty  a
      | hash (Add a) = 0w1217 + hash ty  a
      | hash (Add a) = 0w1223 + hash ty  a
      | hash 

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