Ignore:
Timestamp:
Nov 23, 2011, 5:43:24 PM (9 years ago)
Author:
tranquil
Message:

merge of indexed labels branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/RTLabs/RTLabsToRTL.ml

    r818 r1542  
    9393  | RTL.St_skip _ -> RTL.St_skip lbl
    9494  | RTL.St_cost (cost_lbl, _) -> RTL.St_cost (cost_lbl, lbl)
     95  | RTL.St_ind_0 (i, _) -> RTL.St_ind_0 (i, lbl)
     96  | RTL.St_ind_inc (i, _) -> RTL.St_ind_inc (i, lbl)
    9597  | RTL.St_addr (r1, r2, id, _) -> RTL.St_addr (r1, r2, id, lbl)
    9698  | RTL.St_stackaddr (r1, r2, _) -> RTL.St_stackaddr (r1, r2, lbl)
     
    685687    add_graph lbl (RTL.St_cost (cost_lbl, lbl')) def
    686688
     689  | RTLabs.St_ind_0 (i, lbl') ->
     690    add_graph lbl (RTL.St_ind_0 (i, lbl')) def
     691
     692  | RTLabs.St_ind_inc (i, lbl') ->
     693    add_graph lbl (RTL.St_ind_inc (i, lbl')) def
     694
    687695  | RTLabs.St_cst (destr, cst, lbl') ->
    688696    translate_cst cst (find_local_env destr lenv) lbl lbl' def
     
    692700      lbl lbl' def
    693701
    694   | RTLabs.St_op2 (op2, destr, srcr1, srcr2, lbl') ->
     702  | RTLabs.St_op2 (op2, destr, RTLabs.Reg srcr1, RTLabs.Reg srcr2, lbl') ->
    695703    translate_op2 op2 (find_local_env destr lenv)
    696704      (find_local_env srcr1 lenv) (find_local_env srcr2 lenv) lbl lbl' def
    697705
    698   | RTLabs.St_load (_, addr, destr, lbl') ->
     706  | RTLabs.St_load (_, RTLabs.Reg addr, destr, lbl') ->
    699707    translate_load (find_local_env addr lenv) (find_local_env destr lenv)
    700708      lbl lbl' def
    701709
    702   | RTLabs.St_store (_, addr, srcr, lbl') ->
     710  | RTLabs.St_store (_, RTLabs.Reg addr, RTLabs.Reg srcr, lbl') ->
    703711    translate_store (find_local_env addr lenv) (find_local_env srcr lenv)
    704712      lbl lbl' def
     
    739747  | RTLabs.St_return (Some r) ->
    740748    add_graph lbl (RTL.St_return (find_local_env r lenv)) def
    741 
    742 
     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 
    743785let translate_internal def =
     786  let def = remove_immediates def in
    744787  let runiverse = def.RTLabs.f_runiverse in
    745788  let lenv =
Note: See TracChangeset for help on using the changeset viewer.