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

SCM Repository

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

Diff of /branches/charisee/src/compiler/high-to-mid/high-to-mid.sml

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

revision 2604, Fri Apr 25 18:23:44 2014 UTC revision 2605, Wed Apr 30 01:46:09 2014 UTC
# Line 20  Line 20 
20      structure DstIL = MidIL      structure DstIL = MidIL
21      structure DstTy = MidILTypes      structure DstTy = MidILTypes
22      structure DstOp = MidOps      structure DstOp = MidOps
23      structure Expand=Expand      structure Probe = ProbeEin
24      structure P=Printer      structure P=Printer
25      structure shift=shiftHtM      structure shift = ShiftEin
26      structure split= splitHtM      structure split = SplitEin
27      structure E=Ein      structure E=Ein
28    
29     datatype peanut=    O of  SrcOp.rator | E of Ein.ein |Nope     datatype peanut=    O of  SrcOp.rator | E of Ein.ein |Nope
30    
31      fun printEin e=print(P.printerE(e))      val testing =0
   
   
32      fun getRHS x  = (case SrcIL.Var.binding x      fun getRHS x  = (case SrcIL.Var.binding x
33          of SrcIL.VB_RHS(SrcIL.OP(rator, args)) => (O rator, args)          of SrcIL.VB_RHS(SrcIL.OP(rator, args)) => (O rator, args)
34          | SrcIL.VB_RHS(SrcIL.VAR x') => getRHS x'          | SrcIL.VB_RHS(SrcIL.VAR x') => getRHS x'
# Line 41  Line 39 
39          ]))          ]))
40          (* end case *))          (* end case *))
41    
   
   
   
42          (*created so a fail isn't returned. see rename function *)          (*created so a fail isn't returned. see rename function *)
43          fun getRHS2 x  = (case SrcIL.Var.binding x          fun getRHS2 x  = (case SrcIL.Var.binding x
44              of SrcIL.VB_RHS(SrcIL.OP(rator, args)) => (O rator, args)              of SrcIL.VB_RHS(SrcIL.OP(rator, args)) => (O rator, args)
45              | SrcIL.VB_RHS(SrcIL.VAR x') => getRHS2 x'              | SrcIL.VB_RHS(SrcIL.VAR x') => getRHS2 x'
46              | SrcIL.VB_RHS(SrcIL.EINAPP(rator, args)) => (E rator,args)              | SrcIL.VB_RHS(SrcIL.EINAPP(rator, args)) => (E rator,args)
47              | _=>(print "yyy";(Nope, []))          | _=>(Nope, [])
48          (* end case *))          (* end case *))
49    
   
   
   
50      fun cvtTy SrcTy.BoolTy = DstTy.BoolTy      fun cvtTy SrcTy.BoolTy = DstTy.BoolTy
51        | cvtTy SrcTy.StringTy = DstTy.StringTy        | cvtTy SrcTy.StringTy = DstTy.StringTy
52        | cvtTy SrcTy.IntTy = DstTy.intTy        | cvtTy SrcTy.IntTy = DstTy.intTy
# Line 73  Line 65 
65    
66          (*********************FIX*********************)          (*********************FIX*********************)
67    
68          fun rename (env : var_env, x) =      fun rename (env : var_env, x) = case VTbl.find env x
   
            (* case getRHS2(x)  
             of (E e,ea)=>(print(P.printerE e);DstIL.Var.new("l",DstTy.BoolTy))  
             |_=> *)  
   
                 case VTbl.find env x  
69                  of SOME x' =>( x')                  of SOME x' =>( x')
70                  | NONE => let                  | NONE => let
                    (* val g= print "\n  in rename-none\n"*)  
71                      val dstTy = (case SrcIL.Var.ty x                      val dstTy = (case SrcIL.Var.ty x
72                           of SrcTy.ImageTy _ => (                           of SrcTy.ImageTy _ => (
73                              (* for variables with image type, we need more detailed information                              (* for variables with image type, we need more detailed information
# Line 252  Line 237 
237  (*Expand then split *)  (*Expand then split *)
238  fun setEinAp e=let  fun setEinAp e=let
239      val (y,rator,args)=e      val (y,rator,args)=e
240      val a= print(String.concat["\n \t \t ",split.printA e])      val _ = (case testing
241      (*val b=incUse y*)          of 1 => (print(String.concat["\n \t \t ",split.printA e]);1)
242            | _ => 1
243            (* end case *))
244      in      in
245          (y, DstIL.EINAPP(rator,  args))          (y, DstIL.EINAPP(rator,  args))
246      end      end
247    
248    
249    fun expandEinOp (env, y, rator, args) = let    fun expandEinOp (env, y, rator, args) = let
250          val einargs=Env.renameList(env, args)          val einargs=Env.renameList(env, args)
251    
252          val g=print "\n -----------------------------------------------\n\n  New One \n\n"      val _ = (case testing
253          val a= print(String.concat["\n previous Args ", split.printAA(y,rator,args),"\n new args \n ",split.printA (y,rator,einargs),"\n"])          of 1=>(print(String.concat[ "\n ----------------------------------------------- \n  New One \n",    split.printAA(y,rator,args),"\n Args \n ",split.printA (y,rator,einargs)," \n"]);1)
254            | _ => 1)
         val ((rator',args'),expcode)= Expand.expandEinOp(rator,args,einargs)  
255    
256        val ((rator',args'),expcode)= Probe.expandEinOp(rator,args,einargs)
257          val (change,newbie)=split.splitein(y,rator',args')          val (change,newbie)=split.splitein(y,rator',args')
   
   
258          in (case (change,newbie)          in (case (change,newbie)
259              of (0,[(_,e,a)]) => (          of (0,[(_,e,a)]) => let
260                      print(String.concat["\n No Splits \n  ",split.printA(y,e,a)]);                  val _ =(case testing of 0=> 1
261                      expcode@[(y, DstIL.EINAPP(e,  a))])                      | _ => (print(String.concat["\n No Splits \n  ",split.printA(y,e,a)]);1))
262              | _=> let                 in  expcode@[(y, DstIL.EINAPP(e,  a))] end
263                      val x=print"\n \t $plit \n"          | _=>  expcode@(List.map setEinAp newbie)
   
                     in expcode@(List.map setEinAp newbie)  
                     end  
264              (*end case*))              (*end case*))
265    
 (*  
 in         [(y,DstIL.EINAPP(identity, einargs))]*)  
   
266          end          end
267    
268    (* expand a SrcIL assignment to a list of DstIL assignments *)    (* expand a SrcIL assignment to a list of DstIL assignments *)
269      fun expand (env, (y, rhs)) = let      fun expand (env, (y, rhs)) = let
270         (* val x=print"\n newbie\n"*)              (*val _ =( case SrcIL.Var.binding y
         (*  
         val v=( case SrcIL.Var.binding y  
271              of   SrcIL.VB_RHS(SrcIL.EINAPP(rator, args))  => print(String.concat[P.printerE rator ,"\n\n"])              of   SrcIL.VB_RHS(SrcIL.EINAPP(rator, args))  => print(String.concat[P.printerE rator ,"\n\n"])
272              |_=>print "")              |_=>print "")*)
 *)  
273            fun assign rhs = [DstIL.ASSGN(Env.rename (env, y), rhs)]            fun assign rhs = [DstIL.ASSGN(Env.rename (env, y), rhs)]
274    
275            in            in

Legend:
Removed from v.2604  
changed lines
  Added in v.2605

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