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

SCM Repository

[diderot] View of /branches/vis15/src/compiler/high-to-mid/translate-ofield.sml
ViewVC logotype

View of /branches/vis15/src/compiler/high-to-mid/translate-ofield.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5570 - (download) (annotate)
Wed May 30 22:09:45 2018 UTC (2 years, 3 months ago) by jhr
File size: 1479 byte(s)
merging changes from GitHub
(* translate-ofield.sml
 *
 * Translation for EIN Terms that represent other fields (E.OField)
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2016 The University of Chicago
 * All rights reserved.
 *)

structure TranslateOField : sig

    val transform : MidIR.assign -> MidIR.assign list

  end = struct

    structure IR = MidIR
    structure V = IR.Var
    structure Ty = MidTypes
    structure E = Ein
    structure IMap = IntRedBlackMap
    structure ISet = IntRedBlackSet

    fun mkEin(body, index, params) = Ein.EIN{body = body, index = index, params = params}

    fun wrapCFExp(sx, y, ein as E.EIN{index,...}, args) = let
          val (args, params, body)  = TranslateCFExp.transform_CFExp (y, ein, args)
        (* Add summation wrapper back to ein expression *)
          val body = (case sx
                 of [] => body
                  | _ => E.Sum(sx, body)
                (* end case *))
          val ein = mkEin(body, index, params)
          in
            [(y, IR.EINAPP(ein, args))]
          end

    fun transform (y, IR.EINAPP(ein as E.EIN{body,index, params}, args)) = (case body
           of E.Probe(E.OField _, _) => wrapCFExp ([], y, ein, args)
            | E.Sum(sx, p as E.Probe(E.OField _,  _)) =>
                wrapCFExp (sx, y, mkEin(p, index, params), args)
            | _ => [(y, IR.EINAPP(ein, args))]
         (* end case *))
      | transform (y, e) =  [(y, e)]

  end

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