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

SCM Repository

[diderot] Annotation of /branches/charisee/src/compiler/translate/translate-basis.sml
ViewVC logotype

Annotation of /branches/charisee/src/compiler/translate/translate-basis.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 180 - (view) (download)
Original Path: trunk/src/compiler/translate/translate-basis.sml

1 : jhr 180 (* translate-basis.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *
6 :     * Translation for basis operations in Simple AST to HighIL code
7 :     *)
8 :    
9 :     structure TranslateBasis : sig
10 :    
11 :     val translate : (HighIL.var * Var.var * Types.meta_var list * HighIL.var list)
12 :     -> HighIL.simple_stmt list
13 :    
14 :     end = struct
15 :    
16 :     structure IL = HighIL
17 :     structure Op = HighOps
18 :    
19 :     fun simpleOP rator (y, [], xs) = [IL.ASSIGN(y, IL.OP(rator, xs))]
20 :    
21 :     val tbl = let
22 :     val tbl = Var.Tbl.mkTable (128, Fail "Tanslate table")
23 :     in
24 :     List.app (Var.Tbl.insert tbl) [
25 :     (add_ii, simpleOp(OP.Add OP.IntTy)),
26 :     (add_tt, fn (y, [SK], xs) => ??),
27 :     (sub_ii, simpleOp(OP.Sub OP.IntTy)),
28 :     (sub_tt, fn (y, [SK], xs) => ??),
29 :     (mul_ii, simpleOp(OP.Mul OP.IntTy)),
30 :     (mul_rr, simpleOp(OP.Mul(OP.TensorTy[]))),
31 :     (mul_rt, fn (y, [SK], xs) => ??),
32 :     (mul_tr, fn (y, [SK], xs) => ??),
33 :     (div_ii, simpleOp(OP.Div OP.IntTy)),
34 :     (div_rr, simpleOp(OP.Div(OP.TensorTy[]))),
35 :     (div_tr, fn (y, [SK], xs) => ??),
36 :     (lt_ii, simpleOp(OP.LT OP.IntTy)),
37 :     (lt_rr, simpleOp(OP.LT(OP.TensorTy[]))),
38 :     (lte_ii, simpleOp(OP.LTE OP.IntTy)),
39 :     (lte_rr, simpleOp(OP.LTE(OP.TensorTy[]))),
40 :     (gte_ii, simpleOp(OP.GTE OP.IntTy)),
41 :     (gte_rr, simpleOp(OP.GTE(OP.TensorTy[]))),
42 :     (gt_ii, simpleOp(OP.GT OP.IntTy)),
43 :     (gt_rr, simpleOp(OP.GT(OP.TensorTy[]))),
44 :     (equ_bb, simpleOp(OP.EQ OP.BoolTy)),
45 :     (equ_ii, simpleOp(OP.EQ OP.IntTy)),
46 :     (equ_ss, simpleOp(OP.EQ OP.StringTy)),
47 :     (equ_rr, simpleOp(OP.EQ(OP.TensorTy[]))),
48 :     (neq_bb, simpleOp(OP.NEQ OP.BoolTy)),
49 :     (neq_ii, simpleOp(OP.NEQ OP.IntTy)),
50 :     (neq_ss, simpleOp(OP.NEQ OP.StringTy)),
51 :     (neq_rr, simpleOp(OP.NEQ(OP.TensorTy[]))),
52 :     (neg_i, simpleOp(OP.Neg OP.IntTy)),
53 :     (neg_t, fn (y, [SK], xs) => ??),
54 :     (neg_f, fn (y, [DK, NK, SK], xs) => ??),
55 :     (op_at, fn (y, [DK, NK, SK], xs) => ??),
56 :     (op_D, fn (y, [DK, NK, SK], xs) => ??),
57 :     (op_norm, fn (y, [SK], xs) => ??),
58 :     (op_not, simpleOp OP.Not),
59 :     (op_subscript, fn (y, [SK, NK], xs) => ??),
60 :     (fn_CL, fn (y, [N3, N3], xs) => ??),
61 :     (fn_convolve, fn (y, [DK, NK, SK], xs) => ??),
62 :     (fn_cos, simpleOp OP.Cos),
63 :     (fn_dot, fn (y, [NK], xs) => ??),
64 :     (fn_inside, fn (y, [DK, NK, SK], xs) => ??),
65 :     (fn_load, fn (y, [NK, SK], xs) => ??),
66 :     (fn_max, simpleOp Op.Min),
67 :     (fn_min, simpleOp OP.Max),
68 :     (fn_modulate, fn (y, [NK], xs) => ??),
69 :     (fn_pow, simpleOp OP.Pow),
70 :     (fn_principleEvec, fn (y, [NK], xs) => ??),
71 :     (fn_sin, simpleOp OP.Sin),
72 :     (kn_bspln3, fn (y, [], xs) => ??,
73 :     (kn_bspln5, fn (y, [], xs) => ??,
74 :     (kn_ctmr, fn (y, [], xs) => ??,
75 :     (kn_tent, fn (y, [], xs) => ??,
76 :     (i2r, fn (y, [], xs) => ??,
77 :     (input, fn (y, [TK], xs) => ??)
78 :     ];
79 :     tbl
80 :     end
81 :    
82 :     fun translate (y, f, mvs, xs) = (case Var.Tbl.find tbl f
83 :     of SOME transFn => transFn(mvs, xs)
84 :     | NONE => raise Fail("TranslateBasis.translate: unknown function " ^ Var.toString f)
85 :     (* end case *))
86 :    
87 :     end

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