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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/high-il/normalize.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/high-il/normalize.sml

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

revision 2844, Tue Dec 9 18:05:29 2014 UTC revision 2845, Fri Dec 12 06:46:23 2014 UTC
# Line 52  Line 52 
52          val cntUnused = cntUnused)          val cntUnused = cntUnused)
53    
54      fun useCount (IL.V{useCnt, ...}) = !useCnt      fun useCount (IL.V{useCnt, ...}) = !useCnt
   
55     (* adjust a variable's use count *)     (* adjust a variable's use count *)
56      fun incUse (IL.V{useCnt, ...}) = (useCnt := !useCnt + 1)      fun incUse (IL.V{useCnt, ...}) = (useCnt := !useCnt + 1)
57      fun decUse (IL.V{useCnt, ...}) = (useCnt := !useCnt - 1)      fun decUse (IL.V{useCnt, ...}) = (useCnt := !useCnt - 1)
# Line 63  Line 62 
62          |_=>NONE          |_=>NONE
63      (* end case *))      (* end case *))
64    
   
65      val testing=0      val testing=0
66      fun testp e=(case testing      fun testp e=(case testing
67          of 1 => (print(String.concat e);1)          of 1 => (print(String.concat e);1)
68          | _ => 1          | _ => 1
69      (*end case*))      (*end case*))
70    
71        (*doNormalize:EIN->EIN
     (*doNomralize:EIN->EIN  
72      * Orders EIN, normalizes it, then cleans the summation      * Orders EIN, normalizes it, then cleans the summation
73      *)      *)
74      fun doNormalize e=let      fun doNormalize e=let
# Line 84  Line 81 
81          e'          e'
82      end      end
83    
84  (*foundEIN:EIN.Params*int*int*EIN*HighIL Vars* rhs list* EIN  *HighIL Var->int*EIN*int*rhs list      (*foundEIN:EIN.Params*int*int*EIN*HighIL Vars* rhs list* EIN  *HighIL Var
85            ->int*EIN*int*rhs list
86  * Orders EIN, normalizes it, then cleans the summation  * Orders EIN, normalizes it, then cleans the summation
87  *orig-original EIN  *orig-original EIN
88  *)  *)
   
89  fun foundEin(paramCount,place,change,newE,newArgs,done,newEinApp,orig,lhs)= (case (List.nth(paramCount, place))  fun foundEin(paramCount,place,change,newE,newArgs,done,newEinApp,orig,lhs)= (case (List.nth(paramCount, place))
90      of Ein.TEN(0,_)=> (change,orig, place+1,  done@[newEinApp])      of Ein.TEN(0,_)=> (change,orig, place+1,  done@[newEinApp])
91      | _ => let      | _ => let
# Line 97  Line 94 
94                  "\n","Subst Result:\t", P.printerE(subst), "\n"]                  "\n","Subst Result:\t", P.printerE(subst), "\n"]
95          in (case c          in (case c
96              of 0 => (1,subst, place+length(newArgs), done@newArgs)              of 0 => (1,subst, place+length(newArgs), done@newArgs)
97              |_ => (incUse lhs;(*decUse e;*)(1,subst, place+length(newArgs), done@newArgs))                  |_ => (use lhs;(*decUse e;*)(1,subst, place+length(newArgs), done@newArgs))
98              (*end case*))              (*end case*))
99          end          end
100      (*end case*))      (*end case*))
101    
   
   
102  (*  (*
103  doRHS: HighIL.var * rhs -> option rhs      *doRHS: HighIL.var * rhs -> option rhs
104  Looks at each argument to EINAPP.      *Looks at each argument to the original EINAPP.
105  If it is another EIN APP calls foundEIN to do application      *If it is another EIN APP calls foundEIN to do application
106  Keeps track of the place of the arguments      * "place"-The Param-id for the EIN operator.
107        * Keeps track of the place of the argument in substitution.
108  *)  *)
109  fun doRHS (lhs, IL.EINAPP (ein, args))=let  fun doRHS (lhs, IL.EINAPP (ein, args))=let
110      val _ = testp ["\n\n**************************\n\n\n",V.toString  lhs,"=="," ---Current: ", P.printerE(ein), (String.concatWith "," (List.map V.toString args))]      val _ = testp ["\n\n**************************\n\n\n",V.toString  lhs,"=="," ---Current: ", P.printerE(ein), (String.concatWith "," (List.map V.toString args))]

Legend:
Removed from v.2844  
changed lines
  Added in v.2845

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