SCM Repository
View of /branches/vis15/src/compiler/simplify/simplify-vars.sml
Parent Directory
|
Revision Log
Revision 3458 -
(download)
(annotate)
Mon Nov 23 18:11:33 2015 UTC (5 years, 1 month ago) by jhr
File size: 1994 byte(s)
Mon Nov 23 18:11:33 2015 UTC (5 years, 1 month ago) by jhr
File size: 1994 byte(s)
working on merge
(* simplify-vars.sml * * This module analyses the use of variables in the Simple AST and rationalizes * their use in the following ways: * * -- for any strand parameter that is used in a method, we create a shadow state * variable * * -- unused constant and global variables are elminated * * -- unused strand state variables are eliminated * * -- unused local variables are eliminated * * -- strand-invariant state variables (except outputs) and expressions are * lifted to global scope * * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu) * * COPYRIGHT (c) 2015 The University of Chicago * All rights reserved. *) structure SimplifyVars : sig val transform : Simple.program -> Simple.program end = struct structure S = Simple (* analyze an expression using the `doVar` and `doFld` * functions to analyze variable uses. *) fun analyzeExp doVar doFld = let fun anal (env, e) = (case e of S.E_Var x => doVar(x, env) | S.E_Lit _ => env | S.E_Select(x, fld) => doFld (fld, doVar(x, env)) | S.E_Apply(f, xs, _) => List.foldl doVar env (f::xs) | S.E_Prim(_, _, xs, _) => List.foldl doVar env xs | S.E_Tensor(xs, _) => List.foldl doVar env xs | S.E_Seq(xs, _) => List.foldl doVar env xs | S.E_Slice(x, indices, _) => let fun doIndex (NONE, env) = env | doIndex (SOME ix, env) = doVar(ix, env) in doVar (x, List.foldl doIndex env indices) end | S.E_Coerce{x, ...} => doVar(x, env) | S.E_LoadSeq _ => () | S.E_LoadImage _ => () (* end case *)) in anal end (* transform a strand definition. This includes introducing shadow state variables for * parameters, eliminating unused state variables, and identifying and lifting invariant * computations. *) fun doStrand (S.Strand{name, params, state, stateInit, initM, updateM, stabilizeM}) = let in () end fun transform prog = prog end
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |