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/functionToString.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2632 - (download) (annotate)
Fri May 23 18:57:58 2014 UTC (6 years, 8 months ago) by jhr
File size: 2529 byte(s)
  various changes
(* Exp to Function name *)

structure fnNames= struct

    structure Op = TreeOps
    structure Ty = TreeILTypes
    structure IL=TreeIL
    structure CE=clangEin

    val default=[]
    val defaultExp="Exp-default"
    fun q n=Int.toString n

    (*Returns names for functions*)
    fun OptoCString rator = (case rator
           of Op.prodScaV n => CE.applyfn(CE.rtnVec n,CE.scale n,CE. Sconcat [CE.argReal,CE.argVec n])
            | Op.sumVec n => CE.applyfn(CE.rtnReal, CE.sum n,CE.argVec n)
            | Op.imgAddr _ => default
            | Op.imgLoad _ => default
            | _ => default
          (* end case *))

        fun flat [] = []
        | flat (l::ls) = l @ flat ls;

    (*return:resultTy and fnName*)
    fun ExptoCString2 exp=(case exp
        of  IL.E_Op(Op, exps) =>let
            val fnName = OptoCString Op
            val argName=flat(List.map ExptoCString2 exps)

        | IL.E_LoadVec(fullTy, origTy, exp, offset) =>let
            val fnName = CE.loadVec(fullTy,origTy)
            (* [IL.E_Lit(  offset)*)

            val m = String.concat[CE.argInt,",",CE.argVec origTy]
               CE.applyfn(CE.rtnVec fullTy ,fnName,m)@(ExptoCString2 exp)

       | IL.E_mkVec(fullTy,origTy,Ty.vectorLength peices,exps) =>let
            val fnName=CE.mkVec(origTy,fullTy)
            val argName= flat(List.map ExptoCString2 exps)
            val m=String.concatWith "," (List.map CE.argVec peices)
                 CE.applyfn(CE.rtnVec origTy,fnName,m)@argName
       | IL.E_Cons _ => []
       | IL.E_Var _ =>  []
       | IL.E_Lit _ =>  []
       | _=>[defaultExp]

        (*end case*))

    fun ExptoCStringPnt(IL.S_Assign (_,exp))= let
        val a=  ExptoCString2 exp

        val _=print("\n \t Function names:\n \t\t ")
        val _=print (String.concatWith"\n\t\t" a)
        in a

    fun ExptoCString(IL.S_Assign (_,exp))=  ExptoCString2 exp

    (*Filter Types, Just one of each *)
    fun m([],rest)=rest
        | m (e1::es, rest)=(case (List.find(fn x=> (x=e1)) rest)
        of NONE=> m (es, rest@[e1])
        | _ => m (es, rest)
        (*end case*))

    fun gotFiltered []= (print(String.concat["\n \t No Function Name"]);1)
      | gotFiltered fnName= let
        val names=m (fnName,[])

        val pnstr= print(String.concat[" Final function Calls:\n ",String.concatWith "\n\t\t" names,"\n\n "])
        in 1


ViewVC Help
Powered by ViewVC 1.0.0