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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1628 - (view) (download)

1 : jhr 433 (* target-sig.sml
2 :     *
3 : jhr 435 * COPYRIGHT (c) 2010 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 : jhr 433 * All rights reserved.
5 :     *
6 :     * Support for generating C-like code (e.g., C, OpenCL, or CUDA)
7 :     *)
8 :    
9 :     signature TARGET =
10 :     sig
11 :    
12 : jhr 451 type program
13 : jhr 499 type strand
14 : jhr 514 type var
15 : jhr 454 type exp
16 :     type stm
17 : jhr 451
18 : jhr 839 (* environment for mapping from TreeIL variables to target variables. It is also used to
19 :     * track the translation context (e.g., global initialization vs. strand initialization, etc.
20 :     *)
21 :     type env
22 :    
23 : jhr 837 (* the supprted widths of vectors of reals on the target. This value takes into
24 : jhr 518 * account the actual size of reals (i.e., 32 or 64 bits).
25 :     *)
26 : jhr 837 val vectorWidths : unit -> int list
27 : jhr 518
28 : jhr 1628 (* does the target support printing? Note that if the target is parallel, then printing
29 :     * will not be supported.
30 :     *)
31 :     val supportsPrinting : bool
32 :    
33 : jhr 837 (* tests for whether various expression forms can appear inline *)
34 : jhr 1514 val inlineCons : int -> bool (* can n'th-order tensor construction appear inline *)
35 :     val inlineMatrixExp : bool (* can matrix-valued expressions appear inline? *)
36 : jhr 837
37 : jhr 839 (* TreeIL to target translations *)
38 :     structure Tr : sig
39 : jhr 1514 val fragment : env * TreeIL.block -> env * stm list
40 :     val block : env * TreeIL.block -> stm
41 :     val exp : env * TreeIL.exp -> exp
42 : jhr 839 end
43 : jhr 518
44 : jhr 839 (* variables *)
45 : jhr 514 structure Var : sig
46 : jhr 1514 val name : var -> string
47 :     val global : program * string * TreeIL.Ty.ty -> var (* global variables *)
48 :     val param : TreeIL.var -> var (* strand parameters *)
49 : jhr 514 end
50 :    
51 : jhr 839 (* environments *)
52 :     structure Env : sig
53 :     (* create a new environment *)
54 : jhr 1514 val new : program -> env
55 : jhr 839 (* define the current translation context *)
56 : jhr 1514 val scopeGlobal : env -> env (* global initialization *)
57 :     val scopeInitially : env -> env (* initial strand creation *)
58 :     val scopeStrand : env -> env (* strand initialization; the vars are *)
59 :     (* all of the state vars *)
60 :     val scopeMethod : env * StrandUtil.method_name -> env (* method body; the vars are just the *)
61 :     (* varying state variables *)
62 : jhr 920 (* bind a TreeIL variable to a target variable *)
63 : jhr 1514 val bind : env * TreeIL.var * var -> env
64 : jhr 451 end
65 :    
66 : jhr 839 (* programs *)
67 :     structure Program : sig
68 : jhr 1514 val new : {
69 :     name : string, (* stem of source file *)
70 :     double : bool, (* true for double-precision support *)
71 :     parallel : bool, (* true for multithreaded (or multi-GPU) target *)
72 :     debug : bool (* true for debug support in executable *)
73 :     } -> program
74 :     val inputs : program * stm -> unit (* register options for input-variables *)
75 :     val init : program * stm -> unit (* initialization of program globals *)
76 : jhr 839 (* register the initially code for a program *)
77 : jhr 1514 val initially : {
78 :     prog : program,
79 :     isArray : bool,
80 :     iterPrefix : stm list,
81 :     iters : (var * exp * exp) list,
82 :     createPrefix : stm list,
83 :     strand : Atom.atom,
84 :     args : exp list
85 :     } -> unit
86 : jhr 839 (* output the code to a file. The string is the basename of the file, the extension
87 :     * is provided by the target.
88 :     *)
89 : jhr 1514 val generate : string * program -> unit
90 : jhr 451 end
91 :    
92 : jhr 544 (* strands *)
93 :     structure Strand : sig
94 :     (* define a strand with the given name *)
95 : jhr 1514 val define : program * Atom.atom * TreeIL.state_var list -> strand
96 : jhr 624 (* return the strand with the given name *)
97 : jhr 1514 val lookup : program * Atom.atom -> strand
98 : jhr 544 (* register the strand-state initialization code. The variables are the strand
99 :     * parameters.
100 :     *)
101 : jhr 1514 val init : strand * var list * stm -> unit
102 : jhr 547 (* register a strand method *)
103 : jhr 1514 val method : strand * StrandUtil.method_name * stm -> unit
104 : jhr 544 end
105 :    
106 : jhr 433 end

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