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

SCM Repository

[diderot] Annotation of /branches/vis15/src/compiler/mid-to-low/mk-low-ir.sml
ViewVC logotype

Annotation of /branches/vis15/src/compiler/mid-to-low/mk-low-ir.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3648 - (view) (download)

1 : jhr 3648 (* mk-low-ir.sml
2 :     *
3 :     * Helper code to build LowIR assigments using the AvailRHS infrastructure.
4 :     *
5 :     * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
6 :     *
7 :     * COPYRIGHT (c) 2016 The University of Chicago
8 :     * All rights reserved.
9 :     *)
10 :    
11 :     structure MkLowIR : sig
12 :    
13 :     (* make "x := <int-literal>" *)
14 :     val intLit : AvailRHS.t * IntLit.t -> LowIR.var
15 :     (* make "x := <real-literal>" *)
16 :     val realLit : AvailRHS.t * RealLit.t -> LowIR.var
17 :     (* make "x := <real-literal>", where the real literal is specified as an integer *)
18 :     val intToRealLit : AvailRHS.t * int -> LowIR.var
19 :     (* make "x := [args]" *)
20 :     val cons : AvailRHS.t * int list * LowIR.var list -> LowIR.var
21 :    
22 :     end = struct
23 :    
24 :     structure IR = LowIR
25 :     structure V = IR.Var
26 :     structure Ty = LowTypes
27 :     structure Op = LowOps
28 :    
29 :     fun mk (avail, name, ty, rhs) = let
30 :     val lhs = V.new (name, ty)
31 :     in
32 :     AvailRHS.addAssign avail (lhs, rhs)
33 :     end
34 :    
35 :     fun intLit (avail, n) = mk (avail, "intLit", Ty.intTy, IR.LIT(Literal.Int n))
36 :     fun realLit (avail, r) = mk (avail, "realLit", Ty.realTy, IR.LIT(Literal.Real r))
37 :     fun intToRealLit (avail, n) = realLit (avail, RealLit.fromInt(IntInf.fromInt n))
38 :     fun cons (avail, shp, args) = mk (avail, "tensor", Ty.TensorTy shp, IR.CONS(args, Ty.TensorTy shp))
39 :    
40 :     end

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