Ignore:
Timestamp:
Nov 1, 2011, 6:31:24 PM (9 years ago)
Author:
tranquil
Message:
  • corrected a bug
  • implemented copy propagation
  • enhanced constant propagation with some algebraic equalities
  • temporarily added immediates to RTLabs, to be seen if it is useful
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051-indexed-labels-branch/src/RTLabs/RTLabsToRTL.ml

    r1340 r1477  
    700700      lbl lbl' def
    701701
    702   | RTLabs.St_op2 (op2, destr, srcr1, srcr2, lbl') ->
     702  | RTLabs.St_op2 (op2, destr, RTLabs.Reg srcr1, RTLabs.Reg srcr2, lbl') ->
    703703    translate_op2 op2 (find_local_env destr lenv)
    704704      (find_local_env srcr1 lenv) (find_local_env srcr2 lenv) lbl lbl' def
    705705
    706   | RTLabs.St_load (_, addr, destr, lbl') ->
     706  | RTLabs.St_load (_, RTLabs.Reg addr, destr, lbl') ->
    707707    translate_load (find_local_env addr lenv) (find_local_env destr lenv)
    708708      lbl lbl' def
    709709
    710   | RTLabs.St_store (_, addr, srcr, lbl') ->
     710  | RTLabs.St_store (_, RTLabs.Reg addr, RTLabs.Reg srcr, lbl') ->
    711711    translate_store (find_local_env addr lenv) (find_local_env srcr lenv)
    712712      lbl lbl' def
     
    747747  | RTLabs.St_return (Some r) ->
    748748    add_graph lbl (RTL.St_return (find_local_env r lenv)) def
    749 
    750 
     749               
     750        | _ -> assert false (*not possible because of previous removal of immediates*)
     751
     752let remove_immediates def =
     753        let load_arg a lbl g rs = match a with
     754                | RTLabs.Reg r -> (lbl, g, rs, r)
     755                | RTLabs.Imm (c, t) ->
     756      let new_l = Label.Gen.fresh def.RTLabs.f_luniverse in
     757      let new_r = Register.fresh def.RTLabs.f_runiverse in
     758                        let g = Label.Map.add lbl (RTLabs.St_cst (new_r, c, new_l)) g in
     759                        (new_l, g, (new_r, t) :: rs, new_r) in
     760        let f lbl stmt (g, rs) =
     761                match stmt with
     762                        | RTLabs.St_op2(op, r, a1, a2, l) ->
     763                                let (lbl', g, rs, r1) = load_arg a1 lbl g rs in
     764        let (lbl', g, rs, r2) = load_arg a2 lbl' g rs in
     765        let s = RTLabs.St_op2 (op, r, RTLabs.Reg r1, RTLabs.Reg r2, l) in
     766                                let g = Label.Map.add lbl' s g in
     767                                (g, rs)
     768      | RTLabs.St_store(q, a1, a2, l) ->
     769        let (lbl', g, rs, r1) = load_arg a1 lbl g rs in
     770        let (lbl', g, rs, r2) = load_arg a2 lbl' g rs in
     771        let s = RTLabs.St_store (q, RTLabs.Reg r1, RTLabs.Reg r2, l) in
     772        let g = Label.Map.add lbl' s g in
     773        (g, rs)
     774                        | RTLabs.St_load (q, a, r, l) ->
     775        let (lbl', g, rs, r1) = load_arg a lbl g rs in
     776        let s = RTLabs.St_load (q, RTLabs.Reg r1, r, l) in
     777        let g = Label.Map.add lbl' s g in
     778        (g, rs)
     779                        | _ -> (g, rs) in
     780        let g = def.RTLabs.f_graph in
     781        let (g, rs) = Label.Map.fold f g (g, []) in
     782        let locals = List.rev_append rs def.RTLabs.f_locals in
     783        { def with RTLabs.f_graph = g; RTLabs.f_locals = locals }
     784 
    751785let translate_internal def =
     786        let def = remove_immediates def in
    752787  let runiverse = def.RTLabs.f_runiverse in
    753788  let lenv =
Note: See TracChangeset for help on using the changeset viewer.