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 /sml/trunk/src/MLRISC/mltree/mltree-utils.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/mltree/mltree-utils.sml

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

revision 600, Wed Apr 5 20:13:47 2000 UTC revision 601, Thu Apr 6 04:38:14 2000 UTC
# Line 335  Line 335 
335    (*    (*
336     * Pretty printing     * Pretty printing
337     *)     *)
338    fun show (dst,src) =    fun show {def,use,regionDef,regionUse} =
339    let fun ty t = "."^Int.toString t    let fun ty t = "."^Int.toString t
340        fun fty 32 = ".s"        fun fty 32 = ".s"
341          | fty 64 = ".d"          | fty 64 = ".d"
# Line 347  Line 347 
347        fun ccreg v = "cc"^Int.toString v        fun ccreg v = "cc"^Int.toString v
348        fun ctrlreg v = "p"^Int.toString v        fun ctrlreg v = "p"^Int.toString v
349    
350        fun srcReg(t,v) = List.nth(src,v) handle _ => reg(t,v)        fun srcReg(t,v) = use v handle _ => reg(t,v)
351        fun srcFreg(t,v) = List.nth(src,v) handle _ => freg(t,v)        fun srcFreg(t,v) = use v handle _ => freg(t,v)
352        fun srcCCreg v = List.nth(src,v) handle _ => ccreg v        fun srcCCreg v = use v handle _ => ccreg v
353        fun srcCtrlreg v = List.nth(src,v) handle _ => ctrlreg v        fun srcCtrlreg v = use v handle _ => ctrlreg v
354    
355        fun dstReg(t,v) = List.nth(dst,v) handle _ => reg(t,v)        fun dstReg(t,v) = def v handle _ => reg(t,v)
356        fun dstFreg(t,v) = List.nth(dst,v) handle _ => freg(t,v)        fun dstFreg(t,v) = def v handle _ => freg(t,v)
357        fun dstCCreg v =  List.nth(dst,v) handle _ => ccreg v        fun dstCCreg v =  def v handle _ => ccreg v
358        fun dstCtrlreg v = List.nth(dst,v) handle _ => ctrlreg v        fun dstCtrlreg v = def v handle _ => ctrlreg v
359    
360        fun listify f =        fun listify f =
361        let fun g(t,[]) = ""        let fun g(t,[]) = ""
# Line 422  Line 422 
422            (* pretty print an expression  *)            (* pretty print an expression  *)
423        and rexp(T.REG(ty, src)) = srcReg(ty,src)        and rexp(T.REG(ty, src)) = srcReg(ty,src)
424          | rexp(T.LI i) = Int.toString i          | rexp(T.LI i) = Int.toString i
425          | rexp(T.LI32 w) = Word32.toString w          | rexp(T.LI32 w) = "0x"^Word32.toString w
426          | rexp(T.LI64 w) = Word64.toString w          | rexp(T.LI64 w) = "0x"^Word64.toString w
427          | rexp(T.LABEL le) = LabelExp.toString le          | rexp(T.LABEL le) = LabelExp.toString le
428          | rexp(T.CONST c) = Constant.toString c          | rexp(T.CONST c) = Constant.toString c
429          | rexp(T.NEG x) = one("neg",x)          | rexp(T.NEG x) = unary("~",x)
430          | rexp(T.ADD x) = two("add",x)          | rexp(T.ADD x) = binary("+",x)
431          | rexp(T.SUB x) = two("sub",x)          | rexp(T.SUB x) = binary("-",x)
432          | rexp(T.MULS x) = two("muls",x)          | rexp(T.MULS x) = two("muls",x)
433          | rexp(T.DIVS x) = two("divs",x)          | rexp(T.DIVS x) = two("divs",x)
434          | rexp(T.QUOTS x) = two("quots",x)          | rexp(T.QUOTS x) = two("quots",x)
# Line 443  Line 443 
443          | rexp(T.DIVT x) = two("divt",x)          | rexp(T.DIVT x) = two("divt",x)
444          | rexp(T.QUOTT x) = two("quott",x)          | rexp(T.QUOTT x) = two("quott",x)
445          | rexp(T.REMT x) = two("remt",x)          | rexp(T.REMT x) = two("remt",x)
446          | rexp(T.ANDB x) = two("andb",x)          | rexp(T.ANDB x) = binary("&",x)
447          | rexp(T.ORB x) = two("orb",x)          | rexp(T.ORB x)  = binary("|",x)
448          | rexp(T.XORB x) = two("xorb",x)          | rexp(T.XORB x) = binary("^",x)
449          | rexp(T.NOTB x) = one("notb",x)          | rexp(T.NOTB x) = unary("!",x)
450          | rexp(T.SRA x) = two("sra",x)          | rexp(T.SRA x) = binary("~>>",x)
451          | rexp(T.SRL x) = two("srl",x)          | rexp(T.SRL x) = binary(">>",x)
452          | rexp(T.SLL x) = two("sll",x)          | rexp(T.SLL x) = binary("<<",x)
453          | rexp(T.COND(t,cc,e1,e2)) =          | rexp(T.COND(t,cc,e1,e2)) =
454               "cond"^ty t^ccexp cc^"("^rexp e1^","^rexp e2^")"               "cond"^ty t^ccexp cc^"("^rexp e1^","^rexp e2^")"
455          | rexp(T.CVTI2I(t, T.SIGN_EXTEND, t', e)) = "sx"^ty t^ty t'^" "^rexp e          | rexp(T.CVTI2I(t, T.SIGN_EXTEND, t', e)) = "sx"^ty t^ty t'^" "^rexp e
# Line 462  Line 462 
462          | rexp(T.MARK(e, _)) = rexp e          | rexp(T.MARK(e, _)) = rexp e
463          | rexp(T.REXT e) = showRext (shower()) e          | rexp(T.REXT e) = showRext (shower()) e
464    
465          and parenRexp(e as (T.REG _ | T.LI _ | T.LI32 _ | T.LI64 _)) = rexp e
466            | parenRexp e = "("^rexp e^")"
467    
468        and slices sc = listify' (fn {from,to} => rexp from^".."^rexp to) sc        and slices sc = listify' (fn {from,to} => rexp from^".."^rexp to) sc
469    
470            (* pretty print a real expression  *)            (* pretty print a real expression  *)
# Line 505  Line 508 
508        (* Auxiliary functions *)        (* Auxiliary functions *)
509        and one(opcode,(t,x)) = opcode^ty t^"("^rexp x^")"        and one(opcode,(t,x)) = opcode^ty t^"("^rexp x^")"
510        and two(opcode,(t,x,y)) = opcode^ty t^pair(x,y)        and two(opcode,(t,x,y)) = opcode^ty t^pair(x,y)
511          and binary(opcode,(t,x,y)) = parenRexp x^" "^opcode^ty t^" "^parenRexp y
512          and unary(opcode,(t,x)) = opcode^ty t^" "^parenRexp x
513        and pair(x,y) = "("^rexp x^","^rexp y^")"        and pair(x,y) = "("^rexp x^","^rexp y^")"
514        and one'(opcode,(t,x)) = opcode^fty t^"("^fexp x^")"        and one'(opcode,(t,x)) = opcode^fty t^"("^fexp x^")"
515        and two'(opcode,(t,x,y)) = opcode^fty t^pair'(x,y)        and two'(opcode,(t,x,y)) = opcode^fty t^pair'(x,y)
# Line 516  Line 521 
521                                   | (e,x) => fexp e^","^x) "" es^")"                                   | (e,x) => fexp e^","^x) "" es^")"
522        and ccexps es = "("^foldr (fn (e,"") => ccexp e        and ccexps es = "("^foldr (fn (e,"") => ccexp e
523                                    | (e,x) => ccexp e^","^x) "" es^")"                                    | (e,x) => ccexp e^","^x) "" es^")"
524        and store(t,u,ea,m,e) = mem(t,u,ea,m)^" := "^rexp e        and store(t,u,ea,m,e) = memdef(t,u,ea,m)^" := "^rexp e
525        and fstore(t,u,ea,m,e) = fmem(t,u,ea,m)^" := "^fexp e        and fstore(t,u,ea,m,e) = fmemdef(t,u,ea,m)^" := "^fexp e
526        and ccstore(u,ea,m,e) = ccmem(u,ea,m)^" := "^ccexp e        and ccstore(u,ea,m,e) = ccmemdef(u,ea,m)^" := "^ccexp e
527        and load(t,u,ea,m) = mem(t,u,ea,m)        and load(t,u,ea,m) = memuse(t,u,ea,m)
528        and fload(t,u,ea,m) = fmem(t,u,ea,m)        and fload(t,u,ea,m) = fmemuse(t,u,ea,m)
529        and ccload(u,ea,m) = ccmem(u,ea,m)        and ccload(u,ea,m) = ccmemuse(u,ea,m)
530        and addr(u,ea,m) =        and addr(u,ea,m,show) =
531            let val r = Region.toString m            let val r = show m handle _ => Region.toString m
532                val r = if r = "" then r else ","^r                val r = if r = "" then r else ":"^r
533            in  u^"["^rexp ea^r^"]" end            in  u^"["^rexp ea^r^"]" end
534        and mem(t,u,ea,m) = "mem"^ty t^addr(u,ea,m)        and mem(t,u,ea,m,show) = "mem"^ty t^addr(u,ea,m,show)
535        and fmem(t,u,ea,m) = "mem"^fty t^addr(u,ea,m)        and fmem(t,u,ea,m,show) = "mem"^fty t^addr(u,ea,m,show)
536        and ccmem(u,ea,m) = "mem"^addr(u,ea,m)        and ccmem(u,ea,m,show) = "mem"^addr(u,ea,m,show)
537          and memdef(t,u,ea,m) = mem(t,u,ea,m,regionDef)
538          and fmemdef(t,u,ea,m) = fmem(t,u,ea,m,regionDef)
539          and ccmemdef(u,ea,m) = ccmem(u,ea,m,regionDef)
540          and memuse(t,u,ea,m) = mem(t,u,ea,m,regionUse)
541          and fmemuse(t,u,ea,m) = fmem(t,u,ea,m,regionUse)
542          and ccmemuse(u,ea,m) = ccmem(u,ea,m,regionUse)
543     in shower()     in shower()
544     end     end
545    
546     fun stmToString s   = #stm(show ([],[])) s     exception Nothing
547     fun rexpToString s  = #rexp(show ([],[])) s  
548     fun fexpToString s  = #fexp(show ([],[])) s     fun dummy _ = raise Nothing
549     fun ccexpToString s = #ccexp(show ([],[])) s     val dummy = {def=dummy, use=dummy, regionDef=dummy, regionUse=dummy}
550    
551       fun stmToString s   = #stm(show dummy) s
552       fun rexpToString s  = #rexp(show dummy) s
553       fun fexpToString s  = #fexp(show dummy) s
554       fun ccexpToString s = #ccexp(show dummy) s
555    
556  end  end

Legend:
Removed from v.600  
changed lines
  Added in v.601

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