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

SCM Repository

[diderot] Annotation of /branches/pure-cfg/src/compiler/c-target/runtime-names.sml
ViewVC logotype

Annotation of /branches/pure-cfg/src/compiler/c-target/runtime-names.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 561 - (view) (download)

1 : jhr 551 (* runtime-names.sml
2 :     *
3 :     * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *)
6 :    
7 :     structure RuntimeNames =
8 :     struct
9 :    
10 :     (* globals that specify the target characteristics. These should be initialized
11 :     * when the program object is created.
12 :     *)
13 :     val gVectorWid = ref 4
14 :     val gIntTy = ref CLang.int32
15 :     val gRealTy = ref CLang.float
16 :     val gRealSuffix = ref "?"
17 :     val gIntSuffix = ref "?"
18 :    
19 :     (* initialize globals based on target precision *)
20 :     fun initTargetSpec () = if !Controls.doublePrecision
21 :     then (
22 :     gVectorWid := 2;
23 :     gIntTy := CLang.int64;
24 :     gRealTy := CLang.double;
25 :     gRealSuffix := "d";
26 :     gIntSuffix := "l")
27 :     else (
28 :     gVectorWid := 4;
29 :     gIntTy := CLang.int32;
30 :     gRealTy := CLang.float;
31 :     gRealSuffix := "f";
32 :     gIntSuffix := "i")
33 :    
34 :     fun addVecSuffix stem n = concat[stem, Int.toString n, !gRealSuffix]
35 :     fun addIVecSuffix stem n = concat[stem, Int.toString n, !gIntSuffix]
36 :    
37 :     fun addTySuffix (stem, TargetTy.T_Real) = stem ^ !gRealSuffix
38 :     | addTySuffix (stem, TargetTy.T_Vec n) = addVecSuffix stem n
39 :     | addTySuffix (stem, ty) = raise Fail(concat["invalid type ", TargetTy.toString ty, " for ", stem])
40 :    
41 : jhr 561 fun vecTy n = concat["vec", Int.toString n, !gRealSuffix, "_t"]
42 :     fun ivecTy n = concat["vec", Int.toString n, !gIntSuffix, "_t"]
43 : jhr 551 fun imageTy n = concat["Diderot_image", Int.toString n, "D_t"]
44 :    
45 :     (* names of generated functions *)
46 :     val initGlobals = "Diderot_InitGlobals" (* function for initializing program globals *)
47 :     fun strandInit strand = strand ^ "_InitState"
48 : jhr 552 fun strandTy strand = concat["Strand_", strand, "_t"]
49 : jhr 551
50 : jhr 561 (* scalar math functions *)
51 :     fun max ty = addTySuffix ("max", ty)
52 :     fun min ty = addTySuffix ("min", ty)
53 :    
54 : jhr 551 (* vector math functions *)
55 : jhr 553 val mkVec = addVecSuffix "vec"
56 : jhr 551 val scale = addVecSuffix "scale"
57 :     val truncToInt = addVecSuffix "truncToInt"
58 :     val dot = addVecSuffix "dot"
59 :     fun cross () = addVecSuffix "cross" 3
60 :     val length = addVecSuffix "length"
61 :     val normalize = addVecSuffix "normalize"
62 :    
63 :     (* Diderot runtime system hooks *)
64 : jhr 552 val statusTy = "Status_t"
65 : jhr 551 val toImageSpace = addVecSuffix "Diderot_ToImageSpace"
66 :     val inside = addVecSuffix "Diderot_Inside"
67 :     fun loadImage dim = concat["Diderot_LoadImage", Int.toString dim, "D"]
68 :    
69 :     fun input ty = (case ty
70 :     of TargetTy.T_String => "Diderot_InputString"
71 :     | TargetTy.T_Real => "Diderot_Input" ^ !gRealSuffix
72 :     | TargetTy.T_Vec 3 => "Diderot_InputVec3" ^ !gRealSuffix
73 :     | ty => raise Fail("unsupported input type " ^ TargetTy.toString ty)
74 :     (* end case *))
75 :    
76 :     end

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