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

SCM Repository

[diderot] Annotation of /branches/charisee/src/compiler/tree-il/expandOp.sml
ViewVC logotype

Annotation of /branches/charisee/src/compiler/tree-il/expandOp.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2632 - (view) (download)

1 : cchiw 2624 (*This function transitions low-il operators to tree-il operators *)
2 : cchiw 2615 structure ExpOp = struct
3 :     local
4 :    
5 :     structure SrcOp = LowOps
6 :     structure DstOp = TreeOps
7 :     structure SrcTy = LowILTypes
8 :     structure DstTy = TreeILTypes
9 : cchiw 2620 structure T = TreeIL
10 : cchiw 2631 structure TS=tString
11 : cchiw 2615 in
12 :    
13 : cchiw 2628 val testing=0
14 :    
15 : jhr 2632 fun getLd(pieces, 0, rator, argsS, args, origTy)= let
16 :     fun createOps ([], _, code) = code
17 :     | createOps (vn::es, offset, code)=let
18 :     val args' = List.map (fn a => T.E_LoadVec(vn, origTy, a, T.E_Lit(Literal.Int offset))) args
19 :     val exp = T.E_Op(rator vn, argsS@args')
20 :     in
21 :     createOps (es, offset + IntInf.fromInt vn, code@[exp])
22 :     end
23 : cchiw 2620 in
24 : jhr 2632 createOps (pieces, 0, [])
25 : cchiw 2620 end
26 :    
27 : cchiw 2631 (*addSca function used for sumVec function *)
28 :     fun addSca [e1]=e1
29 :     | addSca(e1::e2::es)= addSca([T.E_Op(DstOp.addSca,[e1,e2])]@es)
30 : cchiw 2628
31 : cchiw 2631 fun creatLd(lhs,rator,n,origTy,pieces,argsS,args)= let
32 : cchiw 2628 val splitTy=DstTy.vectorLength pieces
33 : cchiw 2631 val code=getLd(pieces, 0,rator,[],args,origTy)
34 :     val exp=(case (rator n)
35 :     of DstOp.sumVec _ => addSca code
36 :     | _ =>T.E_mkVec(n,origTy,splitTy,code)
37 :     (*end case*))
38 : cchiw 2628 val _=(case testing
39 : cchiw 2631 of 1=>(print((TS.toStringEx exp)^"\n\n");1)
40 : cchiw 2628 |_ =>1)
41 : cchiw 2615 in
42 : cchiw 2628 [T.S_Assign([lhs],exp)]
43 : cchiw 2615 end
44 :    
45 : cchiw 2628
46 :    
47 :     (*Low-IL operators to Tree-IL operators*)
48 : cchiw 2623 fun expandOp rator=(case rator
49 : cchiw 2620 of SrcOp.IAdd => DstOp.IAdd
50 : cchiw 2615 | SrcOp.ISub => DstOp.ISub
51 :     | SrcOp.IMul => DstOp.IMul
52 :     | SrcOp.IDiv => DstOp.IDiv
53 :     | SrcOp.INeg => DstOp.INeg
54 :     | SrcOp.Abs ty => DstOp.Abs ty
55 : cchiw 2628 | SrcOp.LT ty => DstOp.LT ty
56 :     | SrcOp.LTE ty => DstOp.LTE ty
57 :     | SrcOp.EQ ty => DstOp.EQ ty
58 :     | SrcOp.NEQ ty => DstOp.NEQ ty
59 :     | SrcOp.GT ty => DstOp.GT ty
60 :     | SrcOp.GTE ty => DstOp.GTE ty
61 : jhr 2632 | SrcOp.Not => DstOp.Not
62 :     | SrcOp.Max => DstOp.Max
63 :     | SrcOp.Min => DstOp.Min
64 : cchiw 2628 | SrcOp.Clamp ty => DstOp.Clamp ty
65 :     | SrcOp.Lerp ty => DstOp.Lerp ty
66 :     | SrcOp.Norm ty => DstOp.Norm ty
67 : cchiw 2615 | SrcOp.Normalize d => DstOp.Normalize d
68 : cchiw 2628 | SrcOp.Zero ty => DstOp.Zero ty
69 :     | SrcOp.PrincipleEvec ty => DstOp.PrincipleEvec ty
70 : jhr 2632 | SrcOp.EigenVals2x2 => DstOp.EigenVals2x2
71 :     | SrcOp.EigenVals3x3 => DstOp.EigenVals3x3
72 : cchiw 2628 | SrcOp.Select(ty as SrcTy.TupleTy tys, i) => DstOp.Select( ty, i)
73 :     | SrcOp.Index (ty, i ) => DstOp.Index ( ty, i)
74 :     | SrcOp.Subscript ty => DstOp.Subscript ty
75 : jhr 2632 | SrcOp.Ceiling d => DstOp.Ceiling d
76 :     | SrcOp.Floor d => DstOp.Floor d
77 : cchiw 2615 | SrcOp.Round d => DstOp.Round d
78 : jhr 2632 | SrcOp.Trunc d => DstOp.Trunc d
79 :     | SrcOp.IntToReal => DstOp.IntToReal
80 :     | SrcOp.RealToInt d => DstOp.RealToInt d
81 : cchiw 2615 (*| SrcOp.VoxelAddress( info, offset) => expandVoxelAddress (y, info, offset, args')
82 :     | SrcOp.LoadVoxels (rty, d ) => DstOp.LoadVoxels( rty, d)*)
83 : jhr 2632 | SrcOp.Kernel h => DstOp.Kernel h
84 :     | SrcOp.LoadImage info => DstOp.LoadImage info
85 :     | SrcOp.Inside info => DstOp.Inside info
86 :     | SrcOp.Transform V=> DstOp.Transform V
87 : cchiw 2615 | SrcOp.Translate V=> DstOp.Translate V
88 :     | SrcOp.addSca =>DstOp.addSca
89 :     | SrcOp.subSca=>DstOp.subSca
90 :     | SrcOp.prodSca=>DstOp.prodSca
91 :     | SrcOp.divSca=>DstOp.divSca
92 : cchiw 2620
93 : cchiw 2628 (*Still need to sort *)
94 : cchiw 2631 | SrcOp.IndexTensor e=> DstOp.IndexTensor e
95 : cchiw 2615 | SrcOp.imgAddr(v,indexAt, dim)=>DstOp.imgAddr(v, indexAt, dim)
96 :     | SrcOp.imgLoad(v,dim,n)=>DstOp.imgLoad(v,dim,n)
97 : jhr 2632
98 : cchiw 2615 (*EigenVecs,mkDynamic, Append,Prepend, Concat,Length,ImageAddress,LoadVoxel,Inputs, and Pritns*)
99 :     | rator => raise Fail ("bogus operator " ^ SrcOp.toString rator)
100 :     (* end case *))
101 :     end;
102 :     end

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