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 3919 - (download) (annotate)
Mon May 30 06:53:48 2016 UTC (3 years ago) by jhr
File size: 3117 byte(s)
working on merge: code generation
(* 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

  (* Run-time system functions for dynamic sequences *)
    val loadDynSeq : APITypes.t -> string
    val loadDynSeqFromFile : APITypes.t -> string

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

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

  (* vector related names *)
    val vecTyName : int -> string
    val vecTy     : int -> CLang.ty
    val vcons     : int -> string
    val vload     : int -> string

  end = struct

    structure CL = CLang
    structure Env = CodeGenEnv

  (* 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]))

  (* Run-time system functions for dynamic sequences *)
(* FIXME: should these be DynSeqLoad<ty>? *)
    fun loadDynSeq ty = (case ty
           of APITypes.BoolTy => "diderot::DynSeqLoadBool"
            | APITypes.IntTy => "diderot::DynSeqLoadInt"
            | APITypes.TensorTy _ => "diderot::DynSeqLoadReal"
            | ty => raise Fail("unsupported sequence type " ^ APITypes.toString ty)
          (* end case *))

    fun loadDynSeqFromFile ty = (case ty
           of APITypes.BoolTy => "diderot::DynSeqLoadBoolFromFile"
            | APITypes.IntTy => "diderot::DynSeqLoadIntFromFile"
            | APITypes.TensorTy _ => "diderot::DynSeqLoadRealFromFile"
            | ty => raise Fail("unsupported sequence type " ^ APITypes.toString ty)
          (* end case *))

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

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

    fun vecTyName w = "vec" ^ Int.toString w
    fun vecTy w = CL.T_Named(vecTyName w)
    fun vcons w = "vcons" ^ Int.toString w
    fun vload w = "vload" ^ Int.toString w

  end

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