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

SCM Repository

[diderot] View of /trunk/src/compiler/codegen/target-sig.sml
ViewVC logotype

View of /trunk/src/compiler/codegen/target-sig.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1301 - (download) (annotate)
Thu Jun 9 23:58:40 2011 UTC (8 years, 1 month ago) by jhr
File size: 3548 byte(s)
  Added support for hest-based command-line arguments to trunk.  Also switched
  output filename to prog.txt (from mip.txt)
(* target-sig.sml
 *
 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *
 * Support for generating C-like code (e.g., C, OpenCL, or CUDA)
 *)

signature TARGET =
  sig

    type program
    type strand
    type var
    type exp
    type stm

  (* environment for mapping from TreeIL variables to target variables.  It is also used to
   * track the translation context (e.g., global initialization vs. strand initialization, etc.
   *)
    type env

  (* the supprted widths of vectors of reals on the target.  This value takes into
   * account the actual size of reals (i.e., 32 or 64 bits).
   *)
    val vectorWidths : unit -> int list

  (* tests for whether various expression forms can appear inline *)
    val inlineCons : int -> bool	(* can n'th-order tensor construction appear inline *)
    val inlineMatrixExp : bool		(* can matrix-valued expressions appear inline? *)

  (* TreeIL to target translations *)
    structure Tr : sig
	val fragment : env * TreeIL.block -> env * stm list
	val block : env * TreeIL.block -> stm
	val exp : env * TreeIL.exp -> exp
      end

  (* variables *)
    structure Var : sig
	val name : var -> string
	val global : program * string * TreeIL.Ty.ty -> var (* global variables *)
	val param : TreeIL.var -> var			(* strand parameters *)
	val state : strand * TreeIL.var -> var		(* strand state variables *)
      end

  (* environments *)
    structure Env : sig
      (* create a new environment *)
	val new : program -> env
      (* define the current translation context *)
	val scopeGlobal : env -> env			(* global initialization *)
	val scopeInitially : env -> env			(* initial strand creation *)
	val scopeStrand : env * TreeIL.var list -> env	(* strand initialization; the vars are *)
							(* all of the state vars *)
	val scopeMethod : env * TreeIL.var list -> env	(* method body; the vars are just the *)
							(* varying state variables *)
      (* bind a TreeIL variable to a target variable *)
	val bind : env * TreeIL.var * var -> env
      end

  (* programs *)
    structure Program : sig
	val new : {
		name : string,		(* stem of source file *)
		double : bool,		(* true for double-precision support *)
		parallel : bool,	(* true for multithreaded (or multi-GPU) target *)
		debug : bool		(* true for debug support in executable *)
	      } -> program
	val inputs : program * stm -> unit	(* register options for input-variables *)
	val init : program * stm -> unit	(* initialization of program globals *)
      (* register the initially code for a program *)
	val initially : {
		prog : program,
		isArray : bool,
		iterPrefix : stm list,
		iters : (var * exp * exp) list,
		createPrefix : stm list,
		strand : Atom.atom,
		args : exp list
	      } -> unit
      (* output the code to a file.  The string is the basename of the file, the extension
       * is provided by the target.
       *)
	val generate : string * program -> unit
      end

  (* strands *)
    structure Strand : sig
      (* define a strand with the given name *)
	val define : program * Atom.atom -> strand
      (* return the strand with the given name *)
	val lookup : program * Atom.atom -> strand
      (* register the strand-state initialization code.  The variables are the strand
       * parameters.
       *)
	val init : strand * var list * stm -> unit
      (* register a strand method *)
	val method : strand * string * stm -> unit
      (* register the strand's output *)
	val output : strand * TreeIL.Ty.ty * var -> unit
      end

  end

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