Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/MLRISC/gc-safety/gc-type-system.sml
ViewVC logotype

Annotation of /sml/trunk/src/MLRISC/gc-safety/gc-type-system.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 624 - (view) (download)

1 : george 546 (*
2 :     * This signature describes the interface to a gc type system.
3 :     * This encapsulates everything dealing with GC safety analysis
4 :     * into one single signature.
5 :     *)
6 :     functor GCTypeSystem
7 :     (structure GCMap : GC_MAP
8 :     val isRecoverable : GCMap.GC.gctype -> bool
9 :     ) : GC_TYPE_SYSTEM =
10 :     struct
11 :     structure GCMap = GCMap
12 :     structure GC = GCMap.GC
13 :     structure RTL = MLTreeRTL
14 :     structure T = RTL.T
15 :    
16 :     fun error msg = MLRiscErrorMsg.error("GCTypeSystem",msg)
17 :    
18 :     fun typeOf lookup =
19 :     let fun T(T.REG(t,r)) = lookup r
20 :     | T(T.LI i) = GC.CONST i
21 :     | T(T.LI32 w) =
22 :     (GC.CONST(Word32.toIntX w) handle Overflow => GC.INT)
23 :     | T(T.CONST c) = GC.INT
24 :     | T(T.LABEL l) = GC.INT
25 :     | T(T.NEG(t,a)) = unaryArith(t,a)
26 :     | T(T.ADD(t,a,b)) = GC.ADD(t,T a,T b)
27 :     | T(T.SUB(t,a,b)) = GC.SUB(t,T a,T b)
28 :     | T(T.MULS(t,a,b)) = binaryArith(t,a,b)
29 :     | T(T.DIVS(t,a,b)) = binaryArith(t,a,b)
30 :     | T(T.QUOTS(t,a,b)) = binaryArith(t,a,b)
31 :     | T(T.REMS(t,a,b)) = binaryArith(t,a,b)
32 :     | T(T.MULU(t,a,b)) = binaryArith(t,a,b)
33 :     | T(T.DIVU(t,a,b)) = binaryArith(t,a,b)
34 :     | T(T.REMU(t,a,b)) = binaryArith(t,a,b)
35 :     | T(T.NEGT(t,a)) = unaryArith(t,a)
36 :     | T(T.ADDT(t,a,b)) = binaryArith(t,a,b)
37 :     | T(T.SUBT(t,a,b)) = binaryArith(t,a,b)
38 :     | T(T.MULT(t,a,b)) = binaryArith(t,a,b)
39 :     | T(T.DIVT(t,a,b)) = binaryArith(t,a,b)
40 :     | T(T.REMT(t,a,b)) = binaryArith(t,a,b)
41 :     | T(T.QUOTT(t,a,b)) = binaryArith(t,a,b)
42 :     | T(T.ANDB(t,a,b)) = binaryArith(t,a,b)
43 :     | T(T.ORB(t,a,b)) = binaryArith(t,a,b)
44 :     | T(T.XORB(t,a,b)) = binaryArith(t,a,b)
45 :     | T(T.SLL(t,a,b)) = binaryArith(t,a,b)
46 :     | T(T.SRA(t,a,b)) = binaryArith(t,a,b)
47 :     | T(T.SRL(t,a,b)) = binaryArith(t,a,b)
48 :     | T(T.NOTB(t,a)) = unaryArith(t,a)
49 :     | T(T.LOAD(t,ea,_)) = GC.TOP
50 :     | T(T.COND(t,a,b,c)) = GC.TOP
51 :     | T(T.PRED(e, _)) = T e
52 :     | T(T.REXT(t,RTL.OP(misc_op,es))) = GC.INT
53 : george 555 | T(T.REXT(t,RTL.FETCH(RTL.AGG(_,_,RTL.CELL(k,ty,e,_))))) = GC.TOP
54 : leunga 601 | T(e) = error("typeOf: "^ RTL.expToString e)
55 : george 546
56 :     and binaryArith(t,a,b) =
57 :     let val ta = T(a)
58 :     val tb = T(b)
59 :     in GC.join(ta,tb) end
60 :    
61 :     and unaryArith(t,a) = T(a)
62 :     in T
63 :     end
64 :    
65 :     (*
66 :     * Compute the effect
67 :     *)
68 :     fun effectOf{lookup, update} {action, dst, src, effect} =
69 : leunga 601 let fun err() = error("effectOf: "^ RTL.rtlToString action)
70 : george 546
71 :     (* Note the parallel copy semantics! *)
72 :     fun copy(dst, src, e) =
73 :     let fun upd([], [], e) = e
74 :     | upd(d::dst,t::tys,e) = upd(dst, tys, update(d, t, e))
75 :     | upd _ = error "copy"
76 :     in upd(dst, map lookup src, e) end
77 :    
78 :     fun E(T.COPY _,e) = copy(dst,src,e)
79 :     | E(T.RTL{e=s,...},e) = E(s,e)
80 :     | E(T.REGION(s,_),e) = E(s,e)
81 :     | E(T.SEQ [],e) = e
82 :     | E(T.JMP _, e) = e
83 :     | E(T.CALL _,e) = e
84 :     | E(T.RET _,e) = e
85 :     | E(T.MV(t,x,exp), e) = update(x, typeOf lookup exp, e)
86 :     | E(T.IF(_,x,y,z), e) = e
87 :     | E(T.STORE _, e) = e
88 :     | E(T.EXT(RTL.ASSIGN(loc,exp)),e) =
89 :     let val t = typeOf lookup exp
90 :     in case loc of
91 : george 555 RTL.AGG(_,_,RTL.CELL("FP",_,T.REG(_,x),_)) =>
92 : george 546 update(x, GC.REAL64, e)
93 : george 555 | RTL.AGG(_,_,RTL.CELL(_,_,T.REG(_,x),_)) =>
94 :     update(x, GC.TOP, e)
95 : george 546 | RTL.AGG(_,_,_) => e
96 :     end
97 :     | E(T.EXT(RTL.PAR(a,b)), e) = E(b,E(a,e))
98 :     | E(rtl, e) = err()
99 :     in E(action, effect) end
100 :    
101 :     val isRecoverable = isRecoverable
102 :     end

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