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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/codegen/codegen-fn.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/codegen/codegen-fn.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 524, Sat Feb 12 21:11:01 2011 UTC revision 525, Sat Feb 12 22:59:18 2011 UTC
# Line 15  Line 15 
15    end = struct    end = struct
16    
17      structure IL = LowIL      structure IL = LowIL
18        structure Ty = LowILTypes
19      structure V = LowIL.Var      structure V = LowIL.Var
20      structure Op = LowOps      structure Op = LowOps
21      structure Nd = LowIL.Node      structure Nd = LowIL.Node
22      structure CFG = LowIL.CFG      structure CFG = LowIL.CFG
23    
24      (* convert LowIL types to T types *)
25        fun cvtTy ty = (case ty
26               of Ty.BoolTy => T.boolTy
27                | Ty.StringTy => raise Fail "FIXME: StringTy"
28                | Ty.IVecTy 1 => T.intTy
29                | Ty.IVecTy n => T.ivecTy n         (* FIXME: what about vector splits? *)
30                | Ty.VecTy 1 => T.realTy
31                | Ty.VecTy n => T.vecTy n           (* FIXME: what about vector splits? *)
32                | Ty.AddrTy => raise Fail "FIXME: AddrTy"
33                | Ty.ImageTy =>  raise Fail "FIXME: ImageTy"
34              (* end case *))
35    
36    (* a mapping from LowIL variables to target expressions.  Variables get    (* a mapping from LowIL variables to target expressions.  Variables get
37     * removed when the expressions are used as arguments.     * removed when the expressions are used as arguments.
38     *)     *)
# Line 69  Line 82 
82                V.Tbl.insert tbl (x, {cnt = ref(V.useCount x), bind = exp})                V.Tbl.insert tbl (x, {cnt = ref(V.useCount x), bind = exp})
83    
84          fun assign tbl (x, exp) = let          fun assign tbl (x, exp) = let
85                      val lhs = T.Var.tmp()                      val lhs = T.Var.tmp(cvtTy(V.ty x))
86                      in                      in
87                        V.Tbl.insert tbl                        V.Tbl.insert tbl
88                          (x, {cnt = ref(V.useCount x), bind = T.Expr.var lhs});                          (x, {cnt = ref(V.useCount x), bind = T.Expr.var lhs});
# Line 79  Line 92 
92          fun bind tbl (x, exp) = (case V.useCount x          fun bind tbl (x, exp) = (case V.useCount x
93                 of 1 => (V.Tbl.insert tbl (x, {cnt = ref 1, bind = exp}); [])                 of 1 => (V.Tbl.insert tbl (x, {cnt = ref 1, bind = exp}); [])
94                  | n => let (* bind exp to a new target variable *)                  | n => let (* bind exp to a new target variable *)
95                      val lhs = T.Var.tmp()                      val lhs = T.Var.tmp(cvtTy(V.ty x))
96                      in                      in
97                        V.Tbl.insert tbl (x, {cnt = ref n, bind = T.Expr.var lhs});                        V.Tbl.insert tbl (x, {cnt = ref n, bind = T.Expr.var lhs});
98                        [T.Stmt.assign(lhs, exp)]                        [T.Stmt.assign(lhs, exp)]
# Line 143  Line 156 
156                    | (Op.Input(ty, name), []) =>                    | (Op.Input(ty, name), []) =>
157                    | (Op.InputWithDefault(ty, name), [a]) =>                    | (Op.InputWithDefault(ty, name), [a]) =>
158  *)  *)
159                      | _ => raise Fail "incorrect number of arguments"
160                  (* end case *))                  (* end case *))
161            in            in
162              f              f

Legend:
Removed from v.524  
changed lines
  Added in v.525

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