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 1706 - (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 :     target : target, (* target platform *)
26 :     namespace : string option, (* optional namespace prefix *)
27 :     parallel : bool, (* parallel components *)
28 :     double : bool, (* true for double-precision candidates *)
29 : jhr 1706 longint : bool, (* true for 64-bit integers (not currently used) *)
30 : jhr 1705 debug : bool (* true if debugging of the target is enabled *)
31 : jhr 1232 }
32 :    
33 :     (* convert a target specification to the name of the runtime library *)
34 : jhr 1706 fun runtimeName (tgt : target_desc) = let
35 :     val l = if #debug tgt then ["-debug.o"] else [".o"]
36 :     val l = if #parallel tgt then "-par"::l else l
37 :     val p = if #double tgt then "-d" else "-f"
38 :     val t = (case #target tgt
39 : jhr 1704 of TARGET_C => "-c"
40 :     | TARGET_CL => "-cl"
41 :     | TARGET_CUDA => "-cuda"
42 : jhr 1232 (* end case *))
43 : jhr 1706 val lib = if #exec tgt then "-main" else "-rt"
44 : jhr 1232 in
45 :     OS.Path.concat(
46 :     Paths.diderotLib,
47 : jhr 1704 String.concat("diderot" :: lib :: t :: p :: l))
48 : jhr 1232 end
49 :    
50 : jhr 1706 (* return the CPP floating-point precision definition for the target *)
51 :     fun floatPrecisionDef (tgt : target_desc) = if #double tgt
52 :     then "DIDEROT_DOUBLE_PRECISION"
53 :     else "DIDEROT_SINGLE_PRECISION"
54 :    
55 :     (* return the CPP integer precision definition for the target *)
56 :     fun intPrecisionDef (tgt : target_desc) = if #longint tgt
57 :     then "DIDEROT_LONGINT"
58 :     else "DIDEROT_INT"
59 :    
60 :     (* return the CPP target definition for the target *)
61 :     fun targetDef (tgt : target_desc) = (case #target tgt
62 :     of TARGET_C => if #parallel tgt
63 :     then "DIDEROT_TARGET_PARALLEL"
64 :     else "DIDEROT_TARGET_C"
65 :     | TARGET_CL => "DIDEROT_TARGET_CL"
66 :     | TARGET_CUDA => "DIDEROT_TARGET_CUDA"
67 :     (* end case *))
68 :    
69 : jhr 1232 end

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