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

SCM Repository

[diderot] View of /branches/vis15/src/compiler/cxx-util/cxx-names.sml
ViewVC logotype

View of /branches/vis15/src/compiler/cxx-util/cxx-names.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4071 - (download) (annotate)
Tue Jun 28 13:31:31 2016 UTC (3 years, 1 month ago) by jhr
File size: 3762 byte(s)
  Working on merge: initializing image and sequence inputs
(* cxx-names.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.
 *)

structure CxxNames : sig

 (* the base type of the world struct *)
    val worldBaseTyName : string

  (* the world type *)
    val worldTyName : string
    val worldPtrTy : CLang.ty

  (* the global variables struct *)
    val globalTyName : string
    val globalPtrTy : CLang.ty

  (* the pointer to the command-line options struct *)
    val optionsPtrTy : CodeGenEnv.t -> CLang.ty

  (* standard names for accessing globals and state variables *)
    val worldVar     : CLang.var
    val worldParam   : CLang.param
    val globalsVar   : CLang.var
    val globalsParam : CLang.param
    val selfVar      : CLang.var
    val selfInVar    : CLang.var
    val selfOutVar   : CLang.var

    val inputsTyName : string
    val inputsPtrTy : CLang.ty

  (* image type names *)
    val imageTyName  : int -> string
    val qImageTyName : int -> string

  (* wrapper struct for tensor types (to enable overload resolution) *)
    val tensorStruct    : int list -> string
    val tensorTy        : int list -> CLang.ty
    val tensorRefStruct : int list -> string
    val tensorRefTy     : int list -> CLang.ty

  (* vector related names *)
    val vecTyName : int -> string
    val vecTy     : int -> CLang.ty
    val vscale    : int -> string
    val vsum      : int -> string
    val vdot      : int -> string
    val vclamp    : int -> string
    val vlerp     : int -> string
    val vceiling  : int -> string
    val vfloor    : int -> string
    val vround    : int -> string
    val vtrunc    : int -> string
    val vtoi      : int -> string
    val vcons     : int -> string
    val vload     : int -> string
    val vpack     : int -> string

  end = struct

    structure CL = CLang
    structure Env = CodeGenEnv

    val diderotNS = "diderot::"

  (* the base type of the world struct *)
    val worldBaseTyName = "world_base"

  (* the world type *)
    val worldTyName = "world"
    val worldPtrTy = CL.T_Ptr(CL.T_Named worldTyName)

  (* the global variables struct *)
    val globalTyName = "globals"
    val globalPtrTy = CL.T_Ptr(CL.T_Named globalTyName)

  (* the pointer to the command-line options struct *)
    fun optionsPtrTy env =
	  CL.T_Ptr(CL.T_Template("diderot::options", [Env.realTy env, Env.intTy env]))

    val worldVar     = "wrld"
    val worldParam   = CL.PARAM([], worldPtrTy, "wrld")
    val globalsVar   = "glob"
    val globalsParam = CL.PARAM([], globalPtrTy, globalsVar)
    val selfVar      = "self"
    val selfInVar    = "selfIn"
    val selfOutVar   = "selfOut"

    val inputsTyName = "cmd_line_inputs"
    val inputsPtrTy  = CL.T_Ptr(CL.T_Named inputsTyName)

    fun imageTyName d = String.concat["image", Int.toString d, "d"]
    fun qImageTyName d = String.concat[diderotNS, "image", Int.toString d, "d"]

    fun tensorStruct shape = "tensor_" ^ String.concatWithMap "_" Int.toString shape
    fun tensorTy shape = CL.T_Named(tensorStruct shape)
    fun tensorRefStruct shape = "tensor_ref_" ^ String.concatWithMap "_" Int.toString shape
    fun tensorRefTy shape = CL.T_Named(tensorRefStruct shape)

    fun vName name w = name ^ Int.toString w
    val vecTyName = vName "vec"
    fun vecTy w = CL.T_Named(vecTyName w)
    val vscale = vName "vscale"
    val vsum = vName "vsum"
    val vdot = vName "vdot"
    val vclamp = vName "vclamp"
    val vlerp = vName "vlerp"
    val vceiling = vName "vceiling"
    val vfloor = vName "vfloor"
    val vround = vName "vround"
    val vtrunc = vName "vtrunc"
    val vtoi = vName "vtoi"
    val vcons = vName "vcons"
    val vload = vName "vload"
    val vpack = vName "vpack"

  end

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