SCM Repository
View of /branches/pure-cfg/src/compiler/codegen/target-sig.sml
Parent Directory
|
Revision Log
Revision 528 -
(download)
(annotate)
Sun Feb 13 03:05:35 2011 UTC (11 years, 4 months ago) by jhr
File size: 3455 byte(s)
Sun Feb 13 03:05:35 2011 UTC (11 years, 4 months ago) by jhr
File size: 3455 byte(s)
More work on 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 type method type ty (* the maximum width of a vector of reals on the target. This value takes into * account the actual size of reals (i.e., 32 or 64 bits). *) val vectorWidth : unit -> int (* target types *) val boolTy : ty val intTy : ty val realTy : ty val vecTy : int -> ty val ivecTy : int -> ty val newProgram : unit -> program (* 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 val defineStrand : program * string -> strand structure Var : sig val global : program * ty * string -> var val state : strand * ty * string -> var val tmp : ty -> var end (* expression construction *) structure Expr : sig (* variable references *) val global : var -> exp val getState : var -> exp val param : var -> exp val var : var -> exp (* literals *) val intLit : IntegerLit.integer -> exp val floatLit : FloatLit.float -> exp val stringLit : string -> exp val boolLit : bool -> exp (* vector construction *) val vector : exp list -> exp (* select from a vector *) val select : int * exp -> exp (* vector (and scalar) arithmetic *) val add : exp * exp -> exp val mul : exp * exp -> exp val sub : exp * exp -> exp val divide : exp * exp -> exp val neg : exp -> exp val abs : exp -> exp val dot : exp * exp -> exp (* dot product *) val cross : exp * exp -> exp (* cross product *) val length : exp -> exp (* vector length *) val normalize : exp -> exp (* normalize vector *) (* comparisons *) val lt : exp * exp -> exp val lte : exp * exp -> exp val equ : exp * exp -> exp val neq : exp * exp -> exp val gte : exp * exp -> exp val gt : exp * exp -> exp (* logical connectives *) val not : exp -> exp val && : exp * exp -> exp val || : exp * exp -> exp (* misc functions *) val min : exp * exp -> exp val max : exp * exp -> exp (* math functions *) val pow : exp * exp -> exp val sin : exp -> exp val cos : exp -> exp val sqrt : exp -> exp (* rounding *) val trunc : exp -> exp (* truncate real to integral real *) val round : exp -> exp (* round real to integral real *) val floor : exp -> exp (* real to integral real floor *) val ceil : exp -> exp (* real to integral real ceiling *) (* conversions *) val toReal : exp -> exp (* integer to real *) val truncToInt : exp -> exp (* truncate real to inte *) val roundToInt : exp -> exp (* round real to int *) val ceilToInt : exp -> exp (* ceiling of real to int *) val floorToInt : exp -> exp (* floor of real to int *) (* runtime system hooks *) val imageAddr : exp -> exp (* based address of image data *) end (* statement construction *) structure Stmt : sig val comment : string list -> stm val assignState : var * exp -> stm val decl : var * exp option -> stm (* local variable declaration *) val assign : var * exp -> stm val block : stm list -> stm val ifthenelse : exp * stm * stm -> stm val die : unit -> stm val stabilize : unit -> stm end end
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |