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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2662 - (download) (annotate)
Fri May 30 16:55:05 2014 UTC (5 years, 2 months ago) by cchiw
File size: 4499 byte(s)
moved getTypes and getOpr functions to the target
(* 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
    val isHwVec :  int -> bool
    val isVecTy : int -> bool
    val getPieces : int -> int list 

    val getOpr:program*TreeFunc.oprator list ->int 
    val prntOpr:program -> string 
    val getTypes: program*TreeIL.Ty.ty list ->int
    val prntTypes:program -> string


  (* does the target support printing?  Note that if the target is parallel, then printing
   * will not be supported.
   *)
    val supportsPrinting : bool

  (* 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
        (*val allTypes:TreeIL.Ty.ty list ->CLang.ty list
        val allOpr:TreeFunc.oprator list ->CLang.decl list*)
      end

  (* variables *)
    structure Var : sig
        val name : var -> string
        val global : program * string * TreeIL.Ty.ty -> var	(* global variables *)
        val param : env * TreeIL.var -> var			(* strand parameters *)
      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 -> env                    (* strand initialization; the vars are *)
                                                        (* all of the state vars *)
        val scopeMethod : env * StrandUtil.method_name -> 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 * TreeIL.state_var list -> 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 * StrandUtil.method_name * stm -> unit
      end

  end

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