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

SCM Repository

[diderot] View of /branches/charisee/src/compiler/tree-il/tree-func.sml
ViewVC logotype

View of /branches/charisee/src/compiler/tree-il/tree-func.sml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2681 - (download) (annotate)
Sun Aug 24 18:59:07 2014 UTC (5 years, 1 month ago) by cchiw
File size: 2429 byte(s)
cleanup tree-il exp/stmts
(* Get Types of Expressions *)

structure TreeFunc= struct

    structure Ty = TreeILTypes
    structure Op = TreeOps

    datatype oprator = LDArr of bool*int * int
        | OP of Op.rator
        | CONS of Ty.ty (*returns Diderot_real Prog-Ty*)
        | CONSV of int  (*returns vec, used between vector operations*)
        | STORE of bool*int *int* bool (*Aligned, RtnSize, ArgSize,^*)

    fun q m=Int.toString(m)

    fun same( LDArr(a2,a0,a1), LDArr(b2,b0,b1))= Op.sameint(a0, b0) andalso Op.sameint(a1, b1) andalso (a2=b2)
    | same ( STORE(a2,a0,a3,a4),  STORE(b2,b0,b3,b4))=Op.sameint(a0, b0) andalso Op.sameint(a3, b3)  andalso (a2=b2) andalso (a4=b4)
    | same ( OP a0,  OP b0)= Op.same(a0,b0)
    | same ( CONS a0, CONS b0)= Ty.same(a0,b0)
    | same ( CONSV a0, CONSV b0)= Op.sameint(a0,b0)
    | same _ =false

    fun hash( LDArr(true,a0,a1)) =0w3+Op.hashint a0 + Op.hashint a1+0w13
    | hash( LDArr(_,a0,a1)) =0w3+Op.hashint a0 + Op.hashint a1
    | hash ( STORE  (true,tyNew,tyOrig,true))= 0w13 + Op.hashint tyOrig
    | hash ( STORE  (true,tyNew,tyOrig,false))= 0w17 + Op.hashint tyOrig
    | hash ( STORE  (false,tyNew,tyOrig,true))= 0w19 + Op.hashint tyOrig
    | hash ( STORE  (false,tyNew,tyOrig,false))= 0w23 + Op.hashint tyOrig
    | hash ( OP(rator))= 0w7 + Op.hash(rator)
    | hash(  CONS a0)= 0w11 +Ty.hash(a0)
    | hash(  CONSV a0)= 0w13 +Op.hashint a0

    fun boolToString true="true"
      | boolToString false="false"

    fun toString( LDArr (b,tyNew,tyOrig))=String.concat["LDArr:", q tyOrig , "to",q tyNew,boolToString b]
      | toString( STORE  (b,tyNew,tyOrig,true))=
        String.concat["STOREToArr(",q tyNew,"to",q tyOrig,")",boolToString b]
    | toString( STORE  (b,tyNew,tyOrig,_))=
            String.concat["STOREToVec(",q tyNew,"to",q tyOrig,")",boolToString b]
    | toString( OP(rator))=String.concat["OP-",Op.toString rator]
    | toString( CONS a0)= String.concat["CONStoArrayType-",Ty.toString(a0)]
    | toString( CONSV a0)= String.concat["CONStoVecType-",q(a0)]

    fun cmp(e1,e2)=String.compare(toString e1, toString e2)

    structure StringKey =
            type ord_key = Ty.ty
            val compare = Ty.cmp

    structure TySet = RedBlackSetFn(StringKey);

    structure OprKey =
            type ord_key = oprator
            val compare = cmp

    structure  OprSet= RedBlackSetFn(OprKey);


ViewVC Help
Powered by ViewVC 1.0.0