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

SCM Repository

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

View of /branches/pure-cfg/src/compiler/codegen/target-sig.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 839 - (download) (annotate)
Mon Apr 18 16:50:47 2011 UTC (8 years, 5 months ago) by jhr
File size: 2963 byte(s)
  Working on refactoring code generation
(* 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 block : env * TreeIL.block -> stm
	val exp : env * TreeIL.exp -> exp
      end

  (* variables *)
    structure Var : sig
	val global : program * TreeIL.var -> var	(* global variables *)
	val param : TreeIL.var -> var
	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 * strand -> env		(* strand initialization *)
	val scopeMethod : env * TreeIL.var list -> env	(* method body *)
      (* bind a TreeIL varaiable to a target variable *)
	val bind : env * TreeIL.var * var -> env
      end

  (* programs *)
    structure Program : sig
	val new : unit -> program
	val init : program * stm -> unit	(* global initialization *)
      (* register the initially code for a program *)
	val initially : {
		prog : program,
		isArray : bool,
		iterPrefix : stm,
		iters : (var * exp * exp) list,
		createPrefix : stm,
		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 * var -> unit
      end

  end

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