SCM Repository
View of /trunk/src/compiler/mid-il/mid-il.sml
Parent Directory
|
Revision Log
Revision 3349 -
(download)
(annotate)
Tue Oct 27 15:16:36 2015 UTC (5 years, 2 months ago) by jhr
File size: 17106 byte(s)
Tue Oct 27 15:16:36 2015 UTC (5 years, 2 months ago) by jhr
File size: 17106 byte(s)
making copyrights consistent for all code in the repository
(* mid-il.sml * * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu) * * COPYRIGHT (c) 2015 The University of Chicago * 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 (* required helper functions for types *) type ty = MidILTypes.ty val samety = MidILTypes.same val hashty = MidILTypes.hash val tyToString = MidILTypes.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 input type *) type input = ty Inputs.input val sameinput = Inputs.same val hashinput = Inputs.hash val inputToString = Inputs.toString 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 | Not | Max | Min | Clamp of ty | Lerp of ty | Dot of int | MulVecMat of int * int | MulMatVec of int * int | MulMatMat of int * int * int | MulVecTen3 of int * int * int | MulTen3Vec of int * int * int | ColonMul of ty * ty | Cross | Norm of ty | Normalize of int | Scale of ty | PrincipleEvec of ty | EigenVecs2x2 | EigenVecs3x3 | EigenVals2x2 | EigenVals3x3 | Identity of int | Zero of ty | Trace of int | Transpose of int * int | Select of ty * int | Index of ty * int | Subscript of ty | Ceiling of int | Floor of int | Round of int | Trunc of int | IntToReal | RealToInt of int | VoxelAddress of ImageInfo.info * int | LoadVoxels of ImageInfo.info * int | PosToImgSpace of ImageInfo.info | TensorToWorldSpace of ImageInfo.info * ty | EvalKernel of int * Kernel.kernel * int | Inside of ImageInfo.info * int | LoadImage of ty * string * ImageInfo.info | Input of input | 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 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 (MulVecTen3 _) = 1 | resultArity (MulTen3Vec _) = 1 | resultArity (ColonMul _) = 1 | resultArity Cross = 1 | resultArity (Norm _) = 1 | resultArity (Normalize _) = 1 | resultArity (Scale _) = 1 | resultArity (PrincipleEvec _) = 1 | resultArity EigenVecs2x2 = 1 | resultArity EigenVecs3x3 = 1 | resultArity EigenVals2x2 = 1 | resultArity EigenVals3x3 = 1 | resultArity (Identity _) = 1 | resultArity (Zero _) = 1 | resultArity (Trace _) = 1 | resultArity (Transpose _) = 1 | resultArity (Select _) = 1 | resultArity (Index _) = 1 | resultArity (Subscript _) = 1 | resultArity (Ceiling _) = 1 | resultArity (Floor _) = 1 | resultArity (Round _) = 1 | resultArity (Trunc _) = 1 | resultArity IntToReal = 1 | resultArity (RealToInt _) = 1 | resultArity (VoxelAddress _) = 1 | resultArity (LoadVoxels _) = 1 | resultArity (PosToImgSpace _) = 1 | resultArity (TensorToWorldSpace _) = 1 | resultArity (EvalKernel _) = 1 | resultArity (Inside _) = 1 | resultArity (LoadImage _) = 1 | resultArity (Input _) = 0 | 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 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 (MulVecTen3 _) = 2 | arity (MulTen3Vec _) = 2 | arity (ColonMul _) = 2 | arity Cross = 2 | arity (Norm _) = 1 | arity (Normalize _) = 1 | arity (Scale _) = 2 | arity (PrincipleEvec _) = 2 | arity EigenVecs2x2 = 1 | arity EigenVecs3x3 = 1 | arity EigenVals2x2 = 1 | arity EigenVals3x3 = 1 | arity (Identity _) = 0 | arity (Zero _) = 0 | arity (Trace _) = 1 | arity (Transpose _) = 1 | arity (Select _) = 1 | arity (Index _) = 1 | arity (Subscript _) = 2 | arity (Ceiling _) = 1 | arity (Floor _) = 1 | arity (Round _) = 1 | arity (Trunc _) = 1 | arity IntToReal = 1 | arity (RealToInt _) = 1 | arity (VoxelAddress _) = ~1 | arity (LoadVoxels _) = 1 | arity (PosToImgSpace _) = 2 | arity (TensorToWorldSpace _) = 2 | arity (EvalKernel _) = 1 | arity (Inside _) = 2 | arity (LoadImage _) = 0 | arity (Input _) = 0 | arity (Print _) = ~1 fun isPure (Input _) = false | isPure (Print _) = false | isPure _ = true 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 (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)) = sameint(a0, b0) | same (MulVecMat(a0,a1), MulVecMat(b0,b1)) = sameint(a0, b0) andalso sameint(a1, b1) | same (MulMatVec(a0,a1), MulMatVec(b0,b1)) = sameint(a0, b0) andalso sameint(a1, b1) | same (MulMatMat(a0,a1,a2), MulMatMat(b0,b1,b2)) = sameint(a0, b0) andalso sameint(a1, b1) andalso sameint(a2, b2) | same (MulVecTen3(a0,a1,a2), MulVecTen3(b0,b1,b2)) = sameint(a0, b0) andalso sameint(a1, b1) andalso sameint(a2, b2) | same (MulTen3Vec(a0,a1,a2), MulTen3Vec(b0,b1,b2)) = sameint(a0, b0) andalso sameint(a1, b1) andalso sameint(a2, b2) | same (ColonMul(a0,a1), ColonMul(b0,b1)) = samety(a0, b0) andalso samety(a1, b1) | same (Cross, Cross) = true | same (Norm(a0), Norm(b0)) = samety(a0, b0) | same (Normalize(a0), Normalize(b0)) = sameint(a0, b0) | same (Scale(a0), Scale(b0)) = samety(a0, b0) | same (PrincipleEvec(a0), PrincipleEvec(b0)) = samety(a0, b0) | same (EigenVecs2x2, EigenVecs2x2) = true | same (EigenVecs3x3, EigenVecs3x3) = true | same (EigenVals2x2, EigenVals2x2) = true | same (EigenVals3x3, EigenVals3x3) = true | same (Identity(a0), Identity(b0)) = sameint(a0, b0) | same (Zero(a0), Zero(b0)) = samety(a0, b0) | same (Trace(a0), Trace(b0)) = sameint(a0, b0) | same (Transpose(a0,a1), Transpose(b0,b1)) = sameint(a0, b0) andalso sameint(a1, b1) | same (Select(a0,a1), Select(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1) | same (Index(a0,a1), Index(b0,b1)) = samety(a0, b0) andalso sameint(a1, b1) | same (Subscript(a0), Subscript(b0)) = samety(a0, b0) | same (Ceiling(a0), Ceiling(b0)) = sameint(a0, b0) | same (Floor(a0), Floor(b0)) = sameint(a0, b0) | same (Round(a0), Round(b0)) = sameint(a0, b0) | same (Trunc(a0), Trunc(b0)) = sameint(a0, b0) | same (IntToReal, IntToReal) = true | same (RealToInt(a0), RealToInt(b0)) = sameint(a0, b0) | same (VoxelAddress(a0,a1), VoxelAddress(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1) | same (LoadVoxels(a0,a1), LoadVoxels(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1) | same (PosToImgSpace(a0), PosToImgSpace(b0)) = ImageInfo.same(a0, b0) | same (TensorToWorldSpace(a0,a1), TensorToWorldSpace(b0,b1)) = ImageInfo.same(a0, b0) andalso samety(a1, b1) | same (EvalKernel(a0,a1,a2), EvalKernel(b0,b1,b2)) = sameint(a0, b0) andalso Kernel.same(a1, b1) andalso sameint(a2, b2) | same (Inside(a0,a1), Inside(b0,b1)) = ImageInfo.same(a0, b0) andalso sameint(a1, b1) | same (LoadImage(a0,a1,a2), LoadImage(b0,b1,b2)) = samety(a0, b0) andalso samestring(a1, b1) andalso ImageInfo.same(a2, b2) | same (Input(a0), Input(b0)) = sameinput(a0, b0) | 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 Not = 0w43 | hash Max = 0w47 | hash Min = 0w53 | hash (Clamp(a0)) = 0w59 + hashty a0 | hash (Lerp(a0)) = 0w61 + hashty a0 | hash (Dot(a0)) = 0w67 + hashint a0 | hash (MulVecMat(a0,a1)) = 0w71 + hashint a0 + hashint a1 | hash (MulMatVec(a0,a1)) = 0w73 + hashint a0 + hashint a1 | hash (MulMatMat(a0,a1,a2)) = 0w79 + hashint a0 + hashint a1 + hashint a2 | hash (MulVecTen3(a0,a1,a2)) = 0w83 + hashint a0 + hashint a1 + hashint a2 | hash (MulTen3Vec(a0,a1,a2)) = 0w89 + hashint a0 + hashint a1 + hashint a2 | hash (ColonMul(a0,a1)) = 0w97 + hashty a0 + hashty a1 | hash Cross = 0w101 | hash (Norm(a0)) = 0w103 + hashty a0 | hash (Normalize(a0)) = 0w107 + hashint a0 | hash (Scale(a0)) = 0w109 + hashty a0 | hash (PrincipleEvec(a0)) = 0w113 + hashty a0 | hash EigenVecs2x2 = 0w127 | hash EigenVecs3x3 = 0w131 | hash EigenVals2x2 = 0w137 | hash EigenVals3x3 = 0w139 | hash (Identity(a0)) = 0w149 + hashint a0 | hash (Zero(a0)) = 0w151 + hashty a0 | hash (Trace(a0)) = 0w157 + hashint a0 | hash (Transpose(a0,a1)) = 0w163 + hashint a0 + hashint a1 | hash (Select(a0,a1)) = 0w167 + hashty a0 + hashint a1 | hash (Index(a0,a1)) = 0w173 + hashty a0 + hashint a1 | hash (Subscript(a0)) = 0w179 + hashty a0 | hash (Ceiling(a0)) = 0w181 + hashint a0 | hash (Floor(a0)) = 0w191 + hashint a0 | hash (Round(a0)) = 0w193 + hashint a0 | hash (Trunc(a0)) = 0w197 + hashint a0 | hash IntToReal = 0w199 | hash (RealToInt(a0)) = 0w211 + hashint a0 | hash (VoxelAddress(a0,a1)) = 0w223 + ImageInfo.hash a0 + hashint a1 | hash (LoadVoxels(a0,a1)) = 0w227 + ImageInfo.hash a0 + hashint a1 | hash (PosToImgSpace(a0)) = 0w229 + ImageInfo.hash a0 | hash (TensorToWorldSpace(a0,a1)) = 0w233 + ImageInfo.hash a0 + hashty a1 | hash (EvalKernel(a0,a1,a2)) = 0w239 + hashint a0 + Kernel.hash a1 + hashint a2 | hash (Inside(a0,a1)) = 0w241 + ImageInfo.hash a0 + hashint a1 | hash (LoadImage(a0,a1,a2)) = 0w251 + hashty a0 + hashstring a1 + ImageInfo.hash a2 | hash (Input(a0)) = 0w257 + hashinput a0 | 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 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<", intToString a0, ">"] | toString (MulVecMat(a0,a1)) = concat["MulVecMat<", intToString a0, ",", intToString a1, ">"] | toString (MulMatVec(a0,a1)) = concat["MulMatVec<", intToString a0, ",", intToString a1, ">"] | toString (MulMatMat(a0,a1,a2)) = concat["MulMatMat<", intToString a0, ",", intToString a1, ",", intToString a2, ">"] | toString (MulVecTen3(a0,a1,a2)) = concat["MulVecTen3<", intToString a0, ",", intToString a1, ",", intToString a2, ">"] | toString (MulTen3Vec(a0,a1,a2)) = concat["MulTen3Vec<", intToString a0, ",", intToString a1, ",", intToString a2, ">"] | toString (ColonMul(a0,a1)) = concat["ColonMul<", tyToString a0, ",", tyToString a1, ">"] | toString Cross = "Cross" | toString (Norm(a0)) = concat["Norm<", tyToString a0, ">"] | toString (Normalize(a0)) = concat["Normalize<", intToString a0, ">"] | toString (Scale(a0)) = concat["Scale<", tyToString a0, ">"] | toString (PrincipleEvec(a0)) = concat["PrincipleEvec<", tyToString a0, ">"] | toString EigenVecs2x2 = "EigenVecs2x2" | toString EigenVecs3x3 = "EigenVecs3x3" | toString EigenVals2x2 = "EigenVals2x2" | toString EigenVals3x3 = "EigenVals3x3" | toString (Identity(a0)) = concat["Identity<", intToString a0, ">"] | toString (Zero(a0)) = concat["Zero<", tyToString a0, ">"] | toString (Trace(a0)) = concat["Trace<", intToString a0, ">"] | toString (Transpose(a0,a1)) = concat["Transpose<", intToString a0, ",", intToString a1, ">"] | toString (Select(a0,a1)) = concat["Select<", tyToString a0, ",", intToString a1, ">"] | toString (Index(a0,a1)) = concat["Index<", tyToString a0, ",", intToString a1, ">"] | toString (Subscript(a0)) = concat["Subscript<", tyToString a0, ">"] | toString (Ceiling(a0)) = concat["Ceiling<", intToString a0, ">"] | toString (Floor(a0)) = concat["Floor<", intToString a0, ">"] | toString (Round(a0)) = concat["Round<", intToString a0, ">"] | toString (Trunc(a0)) = concat["Trunc<", intToString a0, ">"] | toString IntToReal = "IntToReal" | toString (RealToInt(a0)) = concat["RealToInt<", intToString a0, ">"] | toString (VoxelAddress(a0,a1)) = concat["VoxelAddress<", ImageInfo.toString a0, ",", intToString a1, ">"] | toString (LoadVoxels(a0,a1)) = concat["LoadVoxels<", ImageInfo.toString a0, ",", intToString a1, ">"] | toString (PosToImgSpace(a0)) = concat["PosToImgSpace<", ImageInfo.toString a0, ">"] | toString (TensorToWorldSpace(a0,a1)) = concat["TensorToWorldSpace<", ImageInfo.toString a0, ",", tyToString a1, ">"] | toString (EvalKernel(a0,a1,a2)) = concat["EvalKernel<", intToString a0, ",", Kernel.toString a1, ",", intToString a2, ">"] | toString (Inside(a0,a1)) = concat["Inside<", ImageInfo.toString a0, ",", intToString a1, ">"] | toString (LoadImage(a0,a1,a2)) = concat["LoadImage<", tyToString a0, ",", stringToString a1, ",", ImageInfo.toString a2, ">"] | toString (Input(a0)) = concat["Input<", inputToString a0, ">"] | toString (Print(a0)) = concat["Print<", tysToString a0, ">"] end structure MidIL = SSAFn( val ilName = "mid-il" structure Ty = MidILTypes structure Op = MidOps) structure MidILCensus = CensusFn(MidIL)
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |