SCM Repository
Annotation of /branches/charisee/src/compiler/tree-il/functionToString.sml
Parent Directory
|
Revision Log
Revision 2631 - (view) (download)
1 : | cchiw | 2631 | (* Exp to Function name *) |
2 : | |||
3 : | structure fnNames= struct | ||
4 : | |||
5 : | structure Op = TreeOps | ||
6 : | structure Ty = TreeILTypes | ||
7 : | structure IL=TreeIL | ||
8 : | structure CE=clangEin | ||
9 : | |||
10 : | val default=[] | ||
11 : | val defaultExp="Exp-default" | ||
12 : | fun q n=Int.toString n | ||
13 : | |||
14 : | |||
15 : | |||
16 : | |||
17 : | (*Returns names for functions*) | ||
18 : | fun OptoCString rator = (case rator | ||
19 : | of Op.prodScaV n => CE.applyfn(CE.rtnVec n,CE.scale n,CE. Sconcat [CE.argReal,CE.argVec n]) | ||
20 : | | Op.sumVec n => CE.applyfn(CE.rtnReal, CE.sum n,CE.argVec n) | ||
21 : | | Op.imgAddr _ => default | ||
22 : | | Op.imgLoad _ => default | ||
23 : | | _ => default | ||
24 : | (* end case *)) | ||
25 : | |||
26 : | |||
27 : | fun flat [] = [] | ||
28 : | | flat (l::ls) = l @ flat ls; | ||
29 : | |||
30 : | (*return:resultTy and fnName*) | ||
31 : | fun ExptoCString2 exp=(case exp | ||
32 : | of IL.E_Op(Op, exps) =>let | ||
33 : | val fnName = OptoCString Op | ||
34 : | val argName=flat(List.map ExptoCString2 exps) | ||
35 : | in | ||
36 : | fnName@argName | ||
37 : | end | ||
38 : | |||
39 : | | IL.E_LoadVec(fullTy, origTy,offset,exp) =>let | ||
40 : | val fnName=CE.loadVec(fullTy,origTy) | ||
41 : | (* [IL.E_Lit( offset)*) | ||
42 : | |||
43 : | val m= String.concat[CE.argInt,",",CE.argVec origTy] | ||
44 : | in | ||
45 : | CE.applyfn(CE.rtnVec fullTy ,fnName,m)@(ExptoCString2 exp) | ||
46 : | end | ||
47 : | |||
48 : | | IL.E_mkVec(fullTy,origTy,Ty.vectorLength peices,exps) =>let | ||
49 : | val fnName=CE.mkVec(origTy,fullTy) | ||
50 : | val argName= flat(List.map ExptoCString2 exps) | ||
51 : | val m=String.concatWith "," (List.map CE.argVec peices) | ||
52 : | in | ||
53 : | CE.applyfn(CE.rtnVec origTy,fnName,m)@argName | ||
54 : | end | ||
55 : | | IL.E_Cons _ => [] | ||
56 : | | IL.E_Var _ => [] | ||
57 : | | IL.E_Lit _ => [] | ||
58 : | | _=>[defaultExp] | ||
59 : | |||
60 : | (*end case*)) | ||
61 : | |||
62 : | |||
63 : | fun ExptoCStringPnt(IL.S_Assign (_,exp))= let | ||
64 : | val a= ExptoCString2 exp | ||
65 : | |||
66 : | val _=print("\n \t Function names:\n \t\t ") | ||
67 : | val _=print (String.concatWith"\n\t\t" a) | ||
68 : | in a | ||
69 : | end | ||
70 : | |||
71 : | fun ExptoCString(IL.S_Assign (_,exp))= ExptoCString2 exp | ||
72 : | |||
73 : | |||
74 : | |||
75 : | |||
76 : | (*Filter Types, Just one of each *) | ||
77 : | fun m([],rest)=rest | ||
78 : | | m (e1::es, rest)=(case (List.find(fn x=> (x=e1)) rest) | ||
79 : | of NONE=> m (es, rest@[e1]) | ||
80 : | | _ => m (es, rest) | ||
81 : | (*end case*)) | ||
82 : | |||
83 : | |||
84 : | |||
85 : | fun gotFiltered []= (print(String.concat["\n \t No Function Name"]);1) | ||
86 : | | gotFiltered fnName= let | ||
87 : | val names=m (fnName,[]) | ||
88 : | |||
89 : | val pnstr= print(String.concat[" Final function Calls:\n ",String.concatWith "\n\t\t" names,"\n\n "]) | ||
90 : | in 1 | ||
91 : | end | ||
92 : | |||
93 : | |||
94 : | end |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |