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

SCM Repository

[diderot] View of /branches/vis12/src/compiler/simplify/inliner.sml
ViewVC logotype

View of /branches/vis12/src/compiler/simplify/inliner.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2136 - (download) (annotate)
Mon Feb 11 20:33:59 2013 UTC (6 years, 9 months ago) by jhr
File size: 1967 byte(s)
  starting work on inliner
(* inliner.sml
 *
 * COPYRIGHT (c) 2013 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * This pass eliminates the function definitions by inlining them.
 *)

structure Inliner : sig

    val transform : Simple.program -> Simple.program

  end = struct

    structure S = Simple

  (* create a fresh copy of a function body while mapping the parameters to
   * arguments.
   *)
    fun beta (S.Func{f, params, body}, args) = let
          fun doBlock (env, S.Block stms) = let
                fun f (stm, (env, stms)) = let
                        val (env, stm) = doStmt (env, stm)
                        in
                          (env, stm::stms)
                        end
                val (_, stms) = List.foldl f (env, []) stms
                in
                  (env, S.Block(List.rev stms))
                end
          and doStmt (env, stm) = (case stm
                 of S.S_Var x => (* define new x' *)
                  | S.S_Assign(x, e) =>
                  | S.S_IfThenElse(x, b1, b2) =>
                  | S.S_New(strnd, xs) =>
                  | S.S_Die => (env, stm)
                  | S.S_Stabilize => (env, stm)
                  | S.S_Return x =>
                  | S.S_Print xs =>
                (* end case *))
          and doExp env exp = (case exp
                 of S.E_Var of var
                  | S.E_Lit _ => exp
                  | S.E_Tuple of var list
                  | S.E_Apply of var * Types.meta_var list * var list * Types.ty
                  | S.E_Cons of var list
                  | S.E_Seq of var list
                  | S.E_Slice of var * var option list * Types.ty		(* tensor slicing *)
                  | S.E_Coerce of {srcTy : Types.ty, dstTy : Types.ty, x : var}
                  | S.E_LoadSeq of Types.ty * string
                  | S.E_LoadImage of Types.ty * string * ImageInfo.info
                (* end case *))
          in
          end

  end

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