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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/mid-to-low/helper.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/mid-to-low/helper.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2870, Wed Feb 25 21:47:43 2015 UTC revision 3138, Thu Mar 26 16:27:35 2015 UTC
# Line 12  Line 12 
12      structure E = Ein      structure E = Ein
13      structure LowToS= LowToString      structure LowToS= LowToString
14      structure FL=FloatLit      structure FL=FloatLit
15        structure IMap = IntRedBlackMap
16      in      in
17    
18      val testing=0      val testing=0
# Line 22  Line 22 
22      val intTy=DstTy.intTy      val intTy=DstTy.intTy
23      fun iTos e1=Int.toString e1      fun iTos e1=Int.toString e1
24      fun iToss es=String.concat(List.map iTos es)      fun iToss es=String.concat(List.map iTos es)
     fun lookup k d = d k  
25      fun testp n= (case testing      fun testp n= (case testing
26          of 0=> 0          of 0=> 0
27          | _ =>((print (String.concat n));1)          | _ =>((print (String.concat n));1)
28          (*end case*))          (*end case*))
29    
30      fun insert (key, value) d =fn s =>      val empty = IMap.empty
31          if s = key then SOME value      fun lookup k d = IMap.find(d, k)
32          else d s      fun insert (k, v) d = IMap.insert(d, k, v)
33        fun find (v, mapp) = (case IMap.find(mapp, v)
34      fun find(v, mapp)=(case (lookup v mapp)             of NONE => raise Fail(concat["Outside Bound(", Int.toString v, ")"])
         of NONE=> raise Fail ("Outside Bound("^Int.toString(v)^")")  
35          |SOME s => s          |SOME s => s
36          (*end case*))            (* end *))
37    
38      (*mapIndex:E.mu * dict-> int      (*mapIndex:E.mu * dict-> int
39      * lookup      * lookup
# Line 106  Line 104 
104      * ->Var*LowIL.ASSGN list      * ->Var*LowIL.ASSGN list
105      * Index Tensor at specific indices to give a scalar result      * Index Tensor at specific indices to give a scalar result
106      *)      *)
107      fun indexTensor(_,(_,_,args,id, [],ty)) = (List.nth(args,id),[])      fun indexTensor(_,(_,_,args,id, [],ty)) =
108            (List.nth(args,id),[])
109        | indexTensor(mapp,(lhs,params,args,id,ix,ty))= let        | indexTensor(mapp,(lhs,params,args,id,ix,ty))= let
110          val nU=List.nth(args,id)          val nU=List.nth(args,id)
111          val ixx=(List.map (fn (e1)=> mapIndex(e1,mapp)) ix)          val ixx=(List.map (fn (e1)=> mapIndex(e1,mapp)) ix)
# Line 135  Line 134 
134              assgn(opp,[nU],name,vecTy)              assgn(opp,[nU],name,vecTy)
135          end          end
136    
   
137      fun mkSqrt(nU,code)= let      fun mkSqrt(nU,code)= let
138          val opp=DstOp.Sqrt          val opp=DstOp.Sqrt
139          val name=String.concat["_Sqrt_"]          val name=String.concat["_Sqrt_"]
# Line 144  Line 142 
142              (vA,code@A)              (vA,code@A)
143          end          end
144    
145        fun mkCosine(nU,code)= let
146            val opp=DstOp.Cosine
147            val name=String.concat["_Cosine_"]
148            val (vA,A)=assgn(opp,[nU],name,realTy)
149            in
150                (vA,code@A)
151            end
152    
153        fun mkArcCosine(nU,code)= let
154            val opp=DstOp.ArcCosine
155            val name=String.concat["_ArcCosine_"]
156            val (vA,A)=assgn(opp,[nU],name,realTy)
157            in
158            (vA,code@A)
159            end
160    
161        fun mkSine(nU,code)= let
162            val opp=DstOp.Sine
163            val name=String.concat["_Sine_"]
164            val (vA,A)=assgn(opp,[nU],name,realTy)
165            in
166                (vA,code@A)
167            end
168    
169        fun mkArcSine(nU,code)= let
170            val opp=DstOp.ArcSine
171            val name=String.concat["_ArcSine_"]
172            val (vA,A)=assgn(opp,[nU],name,realTy)
173            in
174                (vA,code@A)
175            end
176    
177    
178      fun mkPowInt((nU,code),n)= let      fun mkPowInt((nU,code),n)= let
179          val opp=DstOp.powInt          val opp=DstOp.powInt

Legend:
Removed from v.2870  
changed lines
  Added in v.3138

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