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

SCM Repository

[diderot] Annotation of /branches/vis15/src/compiler/tree-to-c/tree-to-c.sml
ViewVC logotype

Annotation of /branches/vis15/src/compiler/tree-to-c/tree-to-c.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3864 - (view) (download)

1 : jhr 3864 (* tree-to-c.sml
2 :     *
3 :     * Code generation for the sequential and parallel targets.
4 :     *
5 :     * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
6 :     *
7 :     * COPYRIGHT (c) 2016 The University of Chicago
8 :     * All rights reserved.
9 :     *)
10 :    
11 :     structure TreeToC : sig
12 :    
13 :     val target : TargetOptions.t -> {
14 :     info : TreeIR.target_info,
15 :     generate : TreeIR.program -> unit
16 :     }
17 :    
18 :     end = struct
19 :    
20 :     structure IR = TreeIR
21 :     structure CL = CLang
22 :     structure Spec = TargetSpec
23 :    
24 :     (* generate a function definition for a strand method *)
25 :     fun genMethod (spec, strandName, methTy, methName, body) = let
26 :     val globTy = N.globalsPtrTy props
27 :     val fName = concat[strandName, "_", methName]
28 :     val stateParams = if Spec.dualState spec
29 :     then [
30 :     CL.PARAM(["const"], CL.T_Ptr(CL.T_Named tyName), "selfIn"),
31 :     CL.PARAM([], CL.T_Ptr(CL.T_Named tyName), "selfOut")
32 :     ]
33 :     else [CL.PARAM([], CL.T_Ptr(CL.T_Named tyName), "self")]
34 :     val params = if #hasGlobals spec
35 :     then CL.PARAM([], globTy, "glob") :: stateParams
36 :     else stateParams
37 :     val methFn = CL.D_Func(["static"], resTy, fName, params, body)
38 :     in
39 :     CL.D_Func(["static"], methTy, methName, params, body)
40 :     end
41 :    
42 :     fun genInitiallyMethod (_, _, NONE) = []
43 :     | genInitiallyMethod (spec, strandName, SOME body) =
44 :     genMethod (spec, strandName, CL.T_Named "StrandStatus_t", "initially", body)
45 :    
46 :     fun genUpdateMethod (spec, strandName, body) =
47 :     genMethod (spec, strandName, CL.T_Named "StrandStatus_t", "update", body)
48 :    
49 :     fun genStabilizeMethod (_, _, NONE) = []
50 :     | genStabilizeMethod (spec, strandName, SOME body) =
51 :     genMethod (spec, strandName, CL.voidTy, "stabilize", body)
52 :    
53 :     fun generate (tgt : TargetOptions.t) prog = let
54 :     val IR.Program{
55 :     props, target, consts, inputs, constInit,
56 :     globals, globalInit, strand, create, update
57 :     } = prog
58 :     val spec = TargetSpec.mk (tgt, props)
59 :     in
60 :     if (* standalone exec *)
61 :     then
62 :     else
63 :     end
64 :    
65 :     fun info (tgt : TargetOptions.t) = {
66 :     layout = if (#scalar tgt)
67 :     then DefaultLayout.scalar
68 :     else DefaultLayout.layout (DefaultLayout.gccVectorSizes (#double tgt)),
69 :     isInline =
70 :     fn LowOps.EigenVecs2x2 => false
71 :     | LowOps.EigenVecs3x3 => false
72 :     | LowOps.EigenVals2x2 => false
73 :     | LowOps.EigenVals3x3 => false
74 :     | LowOps.Zero => false
75 :     | _ => true
76 :     }
77 :    
78 :     fun target tgt = {
79 :     info = info tgt,
80 :     generate = generate tgt
81 :     }
82 :    
83 :     end

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