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

SCM Repository

[smlnj] Diff of /MLRISC/trunk/mltree/mltree-check-ty.sml
ViewVC logotype

Diff of /MLRISC/trunk/mltree/mltree-check-ty.sml

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

revision 3043, Thu May 29 01:53:59 2008 UTC revision 3044, Thu May 29 06:38:23 2008 UTC
# Line 58  Line 58 
58       | checkRexp (T.SX(toTy,fromTy,e)) = (checkRexps(fromTy, [e]); toTy)       | checkRexp (T.SX(toTy,fromTy,e)) = (checkRexps(fromTy, [e]); toTy)
59       | checkRexp (T.ZX(toTy,fromTy,e)) = (checkRexps(fromTy, [e]); toTy)       | checkRexp (T.ZX(toTy,fromTy,e)) = (checkRexps(fromTy, [e]); toTy)
60       | checkRexp (T.CVTF2I(ty,_,_,_)) = ty       | checkRexp (T.CVTF2I(ty,_,_,_)) = ty
61       | checkRexp (T.COND(ty,_,_,_)) = ty       | checkRexp (T.COND(ty,cce,e1,e2)) = (checkCCexp cce; checkRexps(ty, [e1, e2]))
62       | checkRexp (T.LOAD(ty,_,_)) = ty       | checkRexp (T.LOAD(ty,ea,_)) = (checkRexps(intTy, [ea]); ty)
63       | checkRexp (T.PRED(e,_)) = checkRexp e       | checkRexp (T.PRED(e,_)) = checkRexp e
64       | checkRexp (T.LET(_,e)) = checkRexp e       | checkRexp (T.LET(_,e)) = checkRexp e
65       | checkRexp (T.REXT(ty,_)) = ty       | checkRexp (T.REXT(ty,_)) = ty
# Line 71  Line 71 
71       | checkRexp (T.BITSLICE(ty,_,_)) = ty       | checkRexp (T.BITSLICE(ty,_,_)) = ty
72       | checkRexp (T.???) = intTy       | checkRexp (T.???) = intTy
73    
74     fun checkFexp (T.FREG(ty,_)) = ty     and checkFexps (ty, es) = let
75       | checkFexp (T.FLOAD(ty,_,_)) = ty            val tys = List.map (fn e => SOME (checkFexp e) handle AmbiguousType => NONE) es
76       | checkFexp (T.FADD(ty,_,_)) = ty            in
77       | checkFexp (T.FSUB(ty,_,_)) = ty               chkTys(ty, tys)
78       | checkFexp (T.FMUL(ty,_,_)) = ty            end
79       | checkFexp (T.FDIV(ty,_,_)) = ty  
80       | checkFexp (T.FABS(ty,_)) = ty     and checkFexp (T.FREG(ty,_)) = raise AmbiguousType
81       | checkFexp (T.FNEG(ty,_)) = ty       | checkFexp (T.FLOAD(ty,ea,_)) = (checkRexps(intTy, [ea]); ty)
82       | checkFexp (T.FSQRT(ty,_)) = ty       | checkFexp (T.FADD(ty,e1,e2)) = checkFexps(ty, [e1, e2])
83       | checkFexp (T.FCOND(ty,_,_,_)) = ty       | checkFexp (T.FSUB(ty,e1,e2)) = checkFexps(ty, [e1, e2])
84         | checkFexp (T.FMUL(ty,e1,e2)) = checkFexps(ty, [e1, e2])
85         | checkFexp (T.FDIV(ty,e1,e2)) = checkFexps(ty, [e1, e2])
86         | checkFexp (T.FABS(ty,e)) = checkFexps(ty, [e])
87         | checkFexp (T.FNEG(ty,e)) = checkFexps(ty, [e])
88         | checkFexp (T.FSQRT(ty,e)) = checkFexps(ty, [e])
89         | checkFexp (T.FCOND(ty,ce,e1,e2)) = (checkCCexp ce; checkFexps(ty, [e1, e2]))
90       | checkFexp (T.CVTI2F(ty,_,_)) = ty       | checkFexp (T.CVTI2F(ty,_,_)) = ty
91       | checkFexp (T.CVTF2F(ty,_,_)) = ty       | checkFexp (T.CVTF2F(ty,_,_)) = ty
92       | checkFexp (T.FCOPYSIGN(ty,_,_)) = ty       | checkFexp (T.FCOPYSIGN(ty,e1,e2)) = checkFexps(ty, [e1, e2])
93       | checkFexp (T.FPRED(e,_)) = checkFexp e       | checkFexp (T.FPRED(e,_)) = checkFexp e
94       | checkFexp (T.FEXT(ty,_)) = ty       | checkFexp (T.FEXT(ty,_)) = ty
95       | checkFexp (T.FMARK(e,_)) = checkFexp e       | checkFexp (T.FMARK(e,_)) = checkFexp e
96    
97    (* don't care about ambiguous types *)    (* don't care about ambiguous types *)
98     fun checkRexpB (ty, e) = checkRexp e = ty handle AmbiguousType => true     and checkRexpB (ty, e) = checkRexp e = ty handle AmbiguousType => true
99    
100       and checkCCexp cce = checkCCexpB cce orelse raise TypeError
101    
102     fun checkCCexp cce = (case cce     and checkCCexpB cce = (case cce
103            of T.NOT cce => checkCCexp cce            of T.NOT cce => checkCCexpB cce
104             | ( T.AND (cce1, cce2) | T.OR (cce1, cce2) | T.XOR (cce1, cce2) | T.EQV (cce1, cce2) ) =>             | ( T.AND (cce1, cce2) | T.OR (cce1, cce2) | T.XOR (cce1, cce2) | T.EQV (cce1, cce2) ) =>
105               checkCCexp cce1 andalso checkCCexp cce2               checkCCexpB cce1 andalso checkCCexpB cce2
106             | T.CMP (ty, _, e1, e2) => ty = checkRexp e1 andalso ty = checkRexp e2             | T.CMP (ty, _, e1, e2) => ty = checkRexp e1 andalso ty = checkRexp e2
107             | T.FCMP (fty, _, e1, e2) => fty = checkFexp e1 andalso fty = checkFexp e2             | T.FCMP (fty, _, e1, e2) => fty = checkFexp e1 andalso fty = checkFexp e2
108             | T.CCMARK (cce, _) => checkCCexp cce             | T.CCMARK (cce, _) => checkCCexpB cce
109             | T.CCEXT (ty, ccext) => true             | T.CCEXT (ty, ccext) => true
110            (* end case *))            (* end case *))
111    
112      fun check stm = (case stm      fun check stm = (case stm
113             of T.MV (ty, d, e) => checkRexpB (ty, e)             of T.MV (ty, d, e) => checkRexpB (ty, e)
114              | T.CCMV (dst, cce) => checkCCexp cce              | T.CCMV (dst, cce) => checkCCexpB cce
115              | T.FMV (fty, dst, e) => checkFexp e = fty              | T.FMV (fty, dst, e) => checkFexp e = fty
116              | T.COPY _ => true              | T.COPY _ => true
117              | T.FCOPY _ => true              | T.FCOPY _ => true
118              | T.JMP (e, _) => checkRexpB (intTy, e)              | T.JMP (e, _) => checkRexpB (intTy, e)
119              | T.BCC (cce, _) => checkCCexp cce              | T.BCC (cce, _) => checkCCexpB cce
120              | T.CALL {funct, ...} => checkRexpB (intTy, funct)              | T.CALL {funct, ...} => checkRexpB (intTy, funct)
121              | T.FLOW_TO (stm, _) => check stm              | T.FLOW_TO (stm, _) => check stm
122              | T.RET _ => true              | T.RET _ => true
123              | T.IF (cce, stm1, stm2) => checkCCexp cce andalso check stm1 andalso check stm2              | T.IF (cce, stm1, stm2) => checkCCexpB cce andalso check stm1 andalso check stm2
124              | T.STORE (ty, e1, e2, _) => checkRexpB (intTy, e1) andalso checkRexpB(intTy, e2)              | T.STORE (ty, e1, e2, _) => checkRexpB (intTy, e1) andalso checkRexpB(intTy, e2)
125              | T.FSTORE (fty, e1, e2, _) => checkRexpB (intTy, e1) andalso fty = checkFexp e2              | T.FSTORE (fty, e1, e2, _) => checkRexpB (intTy, e1) andalso fty = checkFexp e2
126              | T.REGION (stm, _) => check stm              | T.REGION (stm, _) => check stm

Legend:
Removed from v.3043  
changed lines
  Added in v.3044

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