SCM Repository
View of /trunk/src/compiler/high-il/high-il.sml
Parent Directory
|
Revision Log
Revision 1640 -
(download)
(annotate)
Wed Nov 16 02:19:51 2011 UTC (9 years, 2 months ago) by jhr
File size: 15140 byte(s)
Wed Nov 16 02:19:51 2011 UTC (9 years, 2 months ago) by jhr
File size: 15140 byte(s)
Merging in changes from pure-cfg branch.
(* high-il.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.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 (* required helper functions for types *) type ty = HighILTypes.ty val samety = HighILTypes.same val hashty = HighILTypes.hash val tyToString = HighILTypes.toString (* required helper functions for type lists *) type tys = ty list fun sametys (tys1, tys2) = ListPair.allEq samety (tys1, tys2) fun hashtys tys = List.foldl (fn (ty, s) => hashty ty + 0w3 * s) 0w0 tys fun tysToString tys = String.concat["[", String.concatWith "," (List.map tyToString tys), "]" ] (* required helper functions for the int type *) fun sameint (i1 : int, i2) = (i1 = i2) fun hashint i = Word.fromInt i fun intToString i = Int.toString i (* required helper functions for the string type *) fun samestring (s1 : string, s2) = (s1 = s2) val hashstring = HashString.hashString fun stringToString s = String.concat["\"", s, "\""] (* required helper functions for the mask type *) type mask = bool list val samemask : (mask * mask -> bool) = (op =) fun hashmask m = List.foldl (fn (false, w) => w+w | (true, w) => w+w+0w1) (Word.fromInt(List.length m)) m fun maskToString m = String.concat(List.map (fn true => "_" | false => ":") m) datatype rator = Add of ty | Sub of ty | Mul of ty | Div of ty | Neg of ty | Abs of ty | LT of ty | LTE of ty | EQ of ty | NEQ of ty | GT of ty | GTE of ty | Power | Not | Max | Min | Clamp of ty | Lerp of ty | Dot of ty | MulVecMat of ty | MulMatVec of ty | MulMatMat of ty * ty | Cross | Outer of ty | Norm of ty | Normalize of ty | Scale of ty | PrincipleEvec of ty | Eigen2x2 | Eigen3x3 | Identity of int | Zero of ty | Trace of ty | Slice of ty * mask | TensorSub of ty | Select of ty * int | SeqSub of ty | IntToReal | TruncToInt | RoundToInt | CeilToInt | FloorToInt | Kernel of Kernel.kernel * int | LoadImage of ImageInfo.info | Inside of int | Field of int | Probe of ty * ty | AddField | SubField | ScaleField | NegField | DiffField | Input of ty * string * string | InputWithDefault of ty * string * string | Print of tys fun resultArity (Add _) = 1 | resultArity (Sub _) = 1 | resultArity (Mul _) = 1 | resultArity (Div _) = 1 | resultArity (Neg _) = 1 | resultArity (Abs _) = 1 | resultArity (LT _) = 1 | resultArity (LTE _) = 1 | resultArity (EQ _) = 1 | resultArity (NEQ _) = 1 | resultArity (GT _) = 1 | resultArity (GTE _) = 1 | resultArity Power = 1 | resultArity Not = 1 | resultArity Max = 1 | resultArity Min = 1 | resultArity (Clamp _) = 1 | resultArity (Lerp _) = 1 | resultArity (Dot _) = 1 | resultArity (MulVecMat _) = 1 | resultArity (MulMatVec _) = 1 | resultArity (MulMatMat _) = 1 | resultArity Cross = 1 | resultArity (Outer _) = 1 | resultArity (Norm _) = 1 | resultArity (Normalize _) = 1 | resultArity (Scale _) = 1 | resultArity (PrincipleEvec _) = 1 | resultArity Eigen2x2 = 1 | resultArity Eigen3x3 = 1 | resultArity (Identity _) = 1 | resultArity (Zero _) = 1 | resultArity (Trace _) = 1 | resultArity (Slice _) = 1 | resultArity (TensorSub _) = 1 | resultArity (Select _) = 1 | resultArity (SeqSub _) = 1 | resultArity IntToReal = 1 | resultArity TruncToInt = 1 | resultArity RoundToInt = 1 | resultArity CeilToInt = 1 | resultArity FloorToInt = 1 | resultArity (Kernel _) = 1 | resultArity (LoadImage _) = 1 | resultArity (Inside _) = 1 | resultArity (Field _) = 1 | resultArity (Probe _) = 1 | resultArity AddField = 1 | resultArity SubField = 1 | resultArity ScaleField = 1 | resultArity NegField = 1 | resultArity DiffField = 1 | resultArity (Input _) = 1 | resultArity (InputWithDefault _) = 1 | resultArity (Print _) = 0 fun arity (Add _) = 2 | arity (Sub _) = 2 | arity (Mul _) = 2 | arity (Div _) = 2 | arity (Neg _) = 1 | arity (Abs _) = 1 | arity (LT _) = 2 | arity (LTE _) = 2 | arity (EQ _) = 2 | arity (NEQ _) = 2 | arity (GT _) = 2 | arity (GTE _) = 2 | arity Power = 2 | arity Not = 1 | arity Max = 2 | arity Min = 2 | arity (Clamp _) = 3 | arity (Lerp _) = 3 | arity (Dot _) = 2 | arity (MulVecMat _) = 2 | arity (MulMatVec _) = 2 | arity (MulMatMat _) = 2 | arity Cross = 2 | arity (Outer _) = 2 | arity (Norm _) = 1 | arity (Normalize _) = 1 | arity (Scale _) = 2 | arity (PrincipleEvec _) = 2 | arity Eigen2x2 = 1 | arity Eigen3x3 = 1 | arity (Identity _) = 0 | arity (Zero _) = 0 | arity (Trace _) = 1 | arity (Slice _) = 1 | arity (TensorSub _) = ~1 | arity (Select _) = 1 | arity (SeqSub _) = 2 | arity IntToReal = 1 | arity TruncToInt = 1 | arity RoundToInt = 1 | arity CeilToInt = 1 | arity FloorToInt = 1 | arity (Kernel _) = 0 | arity (LoadImage _) = 1 | arity (Inside _) = 2 | arity (Field _) = 2 | arity (Probe _) = 2 | arity AddField = 2 | arity SubField = 2 | arity ScaleField = 2 | arity NegField = 1 | arity DiffField = 1 | arity (Input _) = 0 | arity (InputWithDefault _) = 1 | arity (Print _) = ~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 (Abs(a0), Abs(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 (Power, Power) = true | same (Not, Not) = true | same (Max, Max) = true | same (Min, Min) = true | same (Clamp(a0), Clamp(b0)) = samety(a0, b0) | same (Lerp(a0), Lerp(b0)) = samety(a0, b0) | same (Dot(a0), Dot(b0)) = samety(a0, b0) | same (MulVecMat(a0), MulVecMat(b0)) = samety(a0, b0) | same (MulMatVec(a0), MulMatVec(b0)) = samety(a0, b0) | same (MulMatMat(a0,a1), MulMatMat(b0,b1)) = samety(a0, b0) andalso samety(a1, b1) | same (Cross, Cross) = true | same (Outer(a0), Outer(b0)) = samety(a0, b0) | same (Norm(a0), Norm(b0)) = samety(a0, b0) | same (Normalize(a0), Normalize(b0)) = samety(a0, b0) | same (Scale(a0), Scale(b0)) = samety(a0, b0) | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0) | same (Eigen2x2, Eigen2x2) = true | same (Eigen3x3, Eigen3x3) = true | same (Identity(a0), Identity(b0)) = sameint(a0, b0) | same (Zero(a0), Zero(b0)) = samety(a0, b0) | same (Trace(a0), Trace(b0)) = samety(a0, b0) | same (Slice(a0,a1), Slice(b0,b1)) = samety(a0, b0) andalso samemask(a1, b1) | same (TensorSub(a0), TensorSub(b0)) = samety(a0, b0) | same (Select(a0,a1), Select(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1) | same (SeqSub(a0), SeqSub(b0)) = samety(a0, b0) | same (IntToReal, IntToReal) = true | same (TruncToInt, TruncToInt) = true | same (RoundToInt, RoundToInt) = true | same (CeilToInt, CeilToInt) = true | same (FloorToInt, FloorToInt) = true | same (Kernel(a0,a1), Kernel(b0,b1)) = Kernel.same(a0, b0) andalso sameint(a1, b1) | same (LoadImage(a0), LoadImage(b0)) = ImageInfo.same(a0, b0) | same (Inside(a0), Inside(b0)) = sameint(a0, b0) | same (Field(a0), Field(b0)) = sameint(a0, b0) | same (Probe(a0,a1), Probe(b0,b1)) = samety(a0, b0) andalso samety(a1, b1) | same (AddField, AddField) = true | same (SubField, SubField) = true | same (ScaleField, ScaleField) = true | same (NegField, NegField) = true | same (DiffField, DiffField) = true | same (Input(a0,a1,a2), Input(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2) | same (InputWithDefault(a0,a1,a2), InputWithDefault(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso samestring(a2, b2) | same (Print(a0), Print(b0)) = sametys(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 (Abs(a0)) = 0w17 + hashty a0 | hash (LT(a0)) = 0w19 + hashty a0 | hash (LTE(a0)) = 0w23 + hashty a0 | hash (EQ(a0)) = 0w29 + hashty a0 | hash (NEQ(a0)) = 0w31 + hashty a0 | hash (GT(a0)) = 0w37 + hashty a0 | hash (GTE(a0)) = 0w41 + hashty a0 | hash Power = 0w43 | hash Not = 0w47 | hash Max = 0w53 | hash Min = 0w59 | hash (Clamp(a0)) = 0w61 + hashty a0 | hash (Lerp(a0)) = 0w67 + hashty a0 | hash (Dot(a0)) = 0w71 + hashty a0 | hash (MulVecMat(a0)) = 0w73 + hashty a0 | hash (MulMatVec(a0)) = 0w79 + hashty a0 | hash (MulMatMat(a0,a1)) = 0w83 + hashty a0 + hashty a1 | hash Cross = 0w89 | hash (Outer(a0)) = 0w97 + hashty a0 | hash (Norm(a0)) = 0w101 + hashty a0 | hash (Normalize(a0)) = 0w103 + hashty a0 | hash (Scale(a0)) = 0w107 + hashty a0 | hash (PrincipleEvec(a0)) = 0w109 + hashty a0 | hash Eigen2x2 = 0w113 | hash Eigen3x3 = 0w127 | hash (Identity(a0)) = 0w131 + hashint a0 | hash (Zero(a0)) = 0w137 + hashty a0 | hash (Trace(a0)) = 0w139 + hashty a0 | hash (Slice(a0,a1)) = 0w149 + hashty a0 + hashmask a1 | hash (TensorSub(a0)) = 0w151 + hashty a0 | hash (Select(a0,a1)) = 0w157 + hashty a0 + hashint a1 | hash (SeqSub(a0)) = 0w163 + hashty a0 | hash IntToReal = 0w167 | hash TruncToInt = 0w173 | hash RoundToInt = 0w179 | hash CeilToInt = 0w181 | hash FloorToInt = 0w191 | hash (Kernel(a0,a1)) = 0w193 + Kernel.hash a0 + hashint a1 | hash (LoadImage(a0)) = 0w197 + ImageInfo.hash a0 | hash (Inside(a0)) = 0w199 + hashint a0 | hash (Field(a0)) = 0w211 + hashint a0 | hash (Probe(a0,a1)) = 0w223 + hashty a0 + hashty a1 | hash AddField = 0w227 | hash SubField = 0w229 | hash ScaleField = 0w233 | hash NegField = 0w239 | hash DiffField = 0w241 | hash (Input(a0,a1,a2)) = 0w251 + hashty a0 + hashstring a1 + hashstring a2 | hash (InputWithDefault(a0,a1,a2)) = 0w257 + hashty a0 + hashstring a1 + hashstring a2 | hash (Print(a0)) = 0w263 + hashtys 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 (Abs(a0)) = concat["Abs<", 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 Power = "Power" | toString Not = "Not" | toString Max = "Max" | toString Min = "Min" | toString (Clamp(a0)) = concat["Clamp<", tyToString a0, ">"] | toString (Lerp(a0)) = concat["Lerp<", tyToString a0, ">"] | toString (Dot(a0)) = concat["Dot<", tyToString a0, ">"] | toString (MulVecMat(a0)) = concat["MulVecMat<", tyToString a0, ">"] | toString (MulMatVec(a0)) = concat["MulMatVec<", tyToString a0, ">"] | toString (MulMatMat(a0,a1)) = concat["MulMatMat<", tyToString a0, ",", tyToString a1, ">"] | toString Cross = "Cross" | toString (Outer(a0)) = concat["Outer<", tyToString a0, ">"] | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"] | toString (Normalize(a0)) = concat["Normalize<", tyToString a0, ">"] | toString (Scale(a0)) = concat["Scale<", tyToString a0, ">"] | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"] | toString Eigen2x2 = "Eigen2x2" | toString Eigen3x3 = "Eigen3x3" | toString (Identity(a0)) = concat["Identity<", intToString a0, ">"] | toString (Zero(a0)) = concat["Zero<", tyToString a0, ">"] | toString (Trace(a0)) = concat["Trace<", tyToString a0, ">"] | toString (Slice(a0,a1)) = concat["Slice<", tyToString a0, ",", maskToString a1, ">"] | toString (TensorSub(a0)) = concat["TensorSub<", tyToString a0, ">"] | toString (Select(a0,a1)) = concat["Select<", tyToString a0, ",", intToString a1, ">"] | toString (SeqSub(a0)) = concat["SeqSub<", tyToString a0, ">"] | toString IntToReal = "IntToReal" | toString TruncToInt = "TruncToInt" | toString RoundToInt = "RoundToInt" | toString CeilToInt = "CeilToInt" | toString FloorToInt = "FloorToInt" | toString (Kernel(a0,a1)) = concat["Kernel<", Kernel.toString a0, ",", intToString a1, ">"] | toString (LoadImage(a0)) = concat["LoadImage<", ImageInfo.toString a0, ">"] | toString (Inside(a0)) = concat["Inside<", intToString a0, ">"] | toString (Field(a0)) = concat["Field<", intToString a0, ">"] | toString (Probe(a0,a1)) = concat["Probe<", tyToString a0, ",", tyToString a1, ">"] | toString AddField = "AddField" | toString SubField = "SubField" | toString ScaleField = "ScaleField" | toString NegField = "NegField" | toString DiffField = "DiffField" | toString (Input(a0,a1,a2)) = concat["Input<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"] | toString (InputWithDefault(a0,a1,a2)) = concat["InputWithDefault<", tyToString a0, ",", stringToString a1, ",", stringToString a2, ">"] | toString (Print(a0)) = concat["Print<", tysToString a0, ">"] end structure HighIL = SSAFn( val ilName = "high-il" structure Ty = HighILTypes structure Op = HighOps) structure HighILCensus = CensusFn(HighIL)
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |