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

SCM Repository

[diderot] Annotation of /branches/lamont/src/compiler/codegen/target-util.sml
ViewVC logotype

Annotation of /branches/lamont/src/compiler/codegen/target-util.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2078 - (view) (download)
Original Path: branches/vis12/src/compiler/codegen/target-util.sml

1 : jhr 1232 (* target-util.sml
2 :     *
3 : jhr 1704 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 : jhr 1232 * All rights reserved.
5 :     *
6 :     * Utility support for target selection, etc.
7 :     *)
8 :    
9 :     structure TargetUtil =
10 :     struct
11 :    
12 :     datatype target
13 :     = TARGET_C (* C code *)
14 :     | TARGET_CL (* C + OpenCL *)
15 :     | TARGET_CUDA (* C + CUDA *)
16 :    
17 : jhr 1705 (* the target descriptor collects together the information specified on the Diderot
18 :     * compiler's command-line.
19 :     *)
20 : jhr 1232 type target_desc = {
21 : jhr 1705 srcFile : string, (* source filename *)
22 :     outDir : string, (* directory to put output *)
23 :     outBase : string, (* basename for output or name of executable *)
24 :     exec : bool, (* generate standalone executable? *)
25 : jhr 1912 snapshot : bool, (* generate functions to get snapshot *)
26 : jhr 1705 target : target, (* target platform *)
27 : jhr 1713 namespace : string, (* optional namespace prefix *)
28 : jhr 1705 parallel : bool, (* parallel components *)
29 :     double : bool, (* true for double-precision candidates *)
30 : jhr 1706 longint : bool, (* true for 64-bit integers (not currently used) *)
31 : jhr 2078 debug : bool, (* true if debugging of the target is enabled *)
32 :     bsp : bool (* true if BSP style execution should always be used *)
33 : jhr 1232 }
34 :    
35 :     (* convert a target specification to the name of the runtime library *)
36 : jhr 1706 fun runtimeName (tgt : target_desc) = let
37 :     val l = if #debug tgt then ["-debug.o"] else [".o"]
38 :     val l = if #parallel tgt then "-par"::l else l
39 :     val p = if #double tgt then "-d" else "-f"
40 :     val t = (case #target tgt
41 : jhr 1704 of TARGET_C => "-c"
42 :     | TARGET_CL => "-cl"
43 :     | TARGET_CUDA => "-cuda"
44 : jhr 1232 (* end case *))
45 :     in
46 :     OS.Path.concat(
47 :     Paths.diderotLib,
48 : jhr 1730 String.concat("diderot-rt" :: t :: p :: l))
49 : jhr 1232 end
50 :    
51 : jhr 1706 (* return the CPP floating-point precision definition for the target *)
52 :     fun floatPrecisionDef (tgt : target_desc) = if #double tgt
53 :     then "DIDEROT_DOUBLE_PRECISION"
54 :     else "DIDEROT_SINGLE_PRECISION"
55 :    
56 :     (* return the CPP integer precision definition for the target *)
57 :     fun intPrecisionDef (tgt : target_desc) = if #longint tgt
58 :     then "DIDEROT_LONGINT"
59 :     else "DIDEROT_INT"
60 :    
61 :     (* return the CPP target definition for the target *)
62 :     fun targetDef (tgt : target_desc) = (case #target tgt
63 :     of TARGET_C => if #parallel tgt
64 :     then "DIDEROT_TARGET_PARALLEL"
65 :     else "DIDEROT_TARGET_C"
66 :     | TARGET_CL => "DIDEROT_TARGET_CL"
67 :     | TARGET_CUDA => "DIDEROT_TARGET_CUDA"
68 :     (* end case *))
69 :    
70 : jhr 1232 end

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