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 2668 - (download) (annotate)
Thu Jun 12 03:29:04 2014 UTC (5 years, 2 months ago) by cchiw
File size: 2081 byte(s)
Change global types to arrays and print them
(* Get Types of Expressions *)

structure TreeFunc= struct

    structure Ty = TreeILTypes
    structure Op = TreeOps

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


    
    fun q m=Int.toString(m)


    fun same( LD(a2,a0,a1), LD(b2,b0,b1))= Op.sameint(a0, b0) andalso Op.sameint(a1, b1) andalso (a2=b2)
    | same ( MKVEC(a2,a0,a3),  MKVEC (b2,b0,b3))=Op.sameint(a0, b0) andalso Op.sameint(a3, b3)  andalso (a2=b2)
    | 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( LD(true,a0,a1)) =0w3+Op.hashint a0 + Op.hashint a1+0w13
    | hash( LD(_,a0,a1)) =0w3+Op.hashint a0 + Op.hashint a1
    | hash ( MKVEC (true,tyNew,tyOrig))= 0w5 + Op.hashint tyOrig+0w13
    | hash ( MKVEC (_,tyNew,tyOrig))= 0w5 + 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( LD (b,tyNew,tyOrig))=
        String.concat["LD:", q tyOrig , "to",q tyNew,boolToString b]
    | toString( MKVEC (b,tyNew,tyOrig))=
        String.concat["MKVEC(",q tyNew,"to",q tyOrig,")",boolToString b]
    | toString( OP(rator))=String.concat["OP-",Op.toString rator]
    | toString( CONS a0)= String.concat["CONS-",Ty.toString(a0)]
    | toString( CONSV a0)= String.concat["CONStoVecType-",q(a0)]
 

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

    structure StringKey =
        struct
            type ord_key = Ty.ty
            val compare = Ty.cmp
        end;

    structure TySet = RedBlackSetFn(StringKey);

    structure OprKey =
        struct
            type ord_key = oprator
            val compare = cmp
        end;

    structure  OprSet= RedBlackSetFn(OprKey);

end

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