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

SCM Repository

[diderot] View of /branches/vis15/src/compiler/tree-ir/tree-ir.sml
ViewVC logotype

View of /branches/vis15/src/compiler/tree-ir/tree-ir.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3835 - (download) (annotate)
Sun May 8 13:10:17 2016 UTC (3 years, 1 month ago) by jhr
File size: 3832 byte(s)
  working on merge
(* tree-ir.sml
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2016 The University of Chicago
 * All rights reserved.
 *
 * This representation restores the block structure and nested expression syntax
 * of the source language.
 *)

structure TreeIR =
  struct

    structure Op = TreeOps
    structure Ty = TreeTypes

    datatype program = Program of {
        props : Properties.t list,
        consts : global_var list,       (* large constant variables *)
        inputs : input list,            (* global input variables *)
        constInit : block,              (* code that initializes constants and inputs *)
        globals : global_var list,      (* other global variables *)
        globalInit : block,             (* CFG to initialize other globals (if any) *)
        strand : strand,                (* the strand definition *)
        create : create,                (* initial strand creation *)
        update : block option           (* optional update code. *)
      }

    and strand = Strand of {
        name : Atom.atom,
        params : var list,
        state : state_var list,
        stateInit : block,
        initM : block option,
        updateM : block,
        stabilizeM : block option
      }

    and create = Create of {
        dim : int option,               (* grid dimension; NONE for collections *)
        code : block                    (* the loop nest for creating the strands *)
      }

    and block = Block of {
        locals : var list,
        body : stm list
      }

    and stm
      = S_Comment of string list
      | S_Unpack of var list * exp	(* unpack vector pieces into local variables *)
      | S_Assign of var * exp
      | S_GAssign of global_var * exp
      | S_IfThen of exp * block
      | S_IfThenElse of exp * block * block
      | S_Foreach of var * exp * block
    (* special Diderot forms *)
      | S_LoadNrrd of var * string
      | S_Input of global_var * string * string option * exp option (* get input *)
      | S_InputNrrd of global_var * string * string option * string option (* get image/seq input *)
      | S_New of Atom.atom * exp list   (* new strand creation *)
      | S_Save of state_var * exp  (* save strand state *)
      | S_Exit
      | S_Print of Ty.t list * exp list
    (* return functions for methods *)
      | S_Active
      | S_Stabilize
      | S_Die

    and exp
      = E_Global of global_var
      | E_State of state_var
      | E_Var of var
      | E_Lit of Literal.t
      | E_Op of Op.rator * exp list
      | E_Cons of exp list * Ty.t
      | E_Seq of exp list * Ty.t
      | E_Pack of exp list		(* pack vector pieces into composite vector value *)
      | E_Select of exp * int		(* select vector piece of composite vector value *)

    and global_var = GV of {
        name : string,                  (* name (should be unique) *)
        ty : Ty.t,                      (* type *)
	xty : APITypes.t option,	(* external type (for inputs and outputs) *)
        input : bool,                   (* is an input variable *)
        output : bool,                  (* is the output value of the strand *)
        varying : bool                  (* varies over the execution of the program *)
      }

    and state_var = SV of {
        name : string,                  (* name (should be unique) *)
        ty : Ty.t,                      (* type *)
	xty : APITypes.t option,	(* external type (for outputs) *)
        varying : bool                  (* varies over the lifetime of the strand *)
      }

    and var = V of {
        name : string,                  (* name (should be unique) *)
        id : Stamp.stamp,               (* unique ID *)
        ty : Ty.t                       (* type *)
      }

    withtype input = global_var Inputs.input

  end

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