Ignore:
Timestamp:
Mar 7, 2011, 4:04:42 PM (9 years ago)
Author:
ayache
Message:

Pretty output in D2.2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/clight/clightAnnotator.ml

    r640 r645  
    181181  | Clight.Sskip | Clight.Sbreak | Clight.Scontinue | Clight.Sreturn None
    182182  | Clight.Sgoto _ ->
    183       stmt
     183    stmt
    184184  | Clight.Sassign (e1, e2) ->
    185       let e1' = instrument_expr cost_mapping cost_incr e1 in
    186       let e2' = instrument_expr cost_mapping cost_incr e2 in
    187       Clight.Sassign (e1', e2')
     185    let e1' = instrument_expr cost_mapping cost_incr e1 in
     186    let e2' = instrument_expr cost_mapping cost_incr e2 in
     187    Clight.Sassign (e1', e2')
    188188  | Clight.Scall (eopt, f, args) ->
    189       let eopt' = match eopt with
    190         | None -> None
    191         | Some e -> Some (instrument_expr cost_mapping cost_incr e) in
    192       let f' = instrument_expr cost_mapping cost_incr f in
    193       let args' = List.map (instrument_expr cost_mapping cost_incr) args in
    194       Clight.Scall (eopt', f', args')
     189    let eopt' = match eopt with
     190      | None -> None
     191      | Some e -> Some (instrument_expr cost_mapping cost_incr e) in
     192    let f' = instrument_expr cost_mapping cost_incr f in
     193    let args' = List.map (instrument_expr cost_mapping cost_incr) args in
     194    Clight.Scall (eopt', f', args')
    195195  | Clight.Ssequence (s1, s2) ->
    196       Clight.Ssequence (instrument_body cost_mapping cost_incr s1,
    197                         instrument_body cost_mapping cost_incr s2)
     196    Clight.Ssequence (instrument_body cost_mapping cost_incr s1,
     197                      instrument_body cost_mapping cost_incr s2)
    198198  | Clight.Sifthenelse (e, s1, s2) ->
    199       let e' = instrument_expr cost_mapping cost_incr e in
    200       let s1' = instrument_body cost_mapping cost_incr s1 in
    201       let s2' = instrument_body cost_mapping cost_incr s2 in
    202       Clight.Sifthenelse (e', s1', s2')
     199    let e' = instrument_expr cost_mapping cost_incr e in
     200    let s1' = instrument_body cost_mapping cost_incr s1 in
     201    let s2' = instrument_body cost_mapping cost_incr s2 in
     202    Clight.Sifthenelse (e', s1', s2')
    203203  | Clight.Swhile (e, s) ->
    204       let e' = instrument_expr cost_mapping cost_incr e in
    205       let s' = instrument_body cost_mapping cost_incr s in
    206       Clight.Swhile (e', s')
     204    let e' = instrument_expr cost_mapping cost_incr e in
     205    let s' = instrument_body cost_mapping cost_incr s in
     206    Clight.Swhile (e', s')
    207207  | Clight.Sdowhile (e, s) ->
    208       let e' = instrument_expr cost_mapping cost_incr e in
    209       let s' = instrument_body cost_mapping cost_incr s in
    210       Clight.Sdowhile (e', s')
     208    let e' = instrument_expr cost_mapping cost_incr e in
     209    let s' = instrument_body cost_mapping cost_incr s in
     210    Clight.Sdowhile (e', s')
    211211  | Clight.Sfor (s1, e, s2, s3) ->
    212       let s1' = instrument_body cost_mapping cost_incr s1 in
    213       let e' = instrument_expr cost_mapping cost_incr e in
    214       let s2' = instrument_body cost_mapping cost_incr s2 in
    215       let s3' = instrument_body cost_mapping cost_incr s3 in
    216       Clight.Sfor (s1', e', s2', s3')
     212    let s1' = instrument_body cost_mapping cost_incr s1 in
     213    let e' = instrument_expr cost_mapping cost_incr e in
     214    let s2' = instrument_body cost_mapping cost_incr s2 in
     215    let s3' = instrument_body cost_mapping cost_incr s3 in
     216    Clight.Sfor (s1', e', s2', s3')
    217217  | Clight.Sreturn (Some e) ->
    218       let e' = instrument_expr cost_mapping cost_incr e in
    219       Clight.Sreturn (Some e')
     218    let e' = instrument_expr cost_mapping cost_incr e in
     219    Clight.Sreturn (Some e')
    220220  | Clight.Sswitch (e, ls) ->
    221       let e' = instrument_expr cost_mapping cost_incr e in
    222       let ls' = instrument_ls cost_mapping cost_incr ls in
    223       Clight.Sswitch (e', ls')
     221    let e' = instrument_expr cost_mapping cost_incr e in
     222    let ls' = instrument_ls cost_mapping cost_incr ls in
     223    Clight.Sswitch (e', ls')
    224224  | Clight.Slabel (lbl, s) ->
    225       let s' = instrument_body cost_mapping cost_incr s in
    226       Clight.Slabel (lbl, s')
     225    let s' = instrument_body cost_mapping cost_incr s in
     226    Clight.Slabel (lbl, s')
    227227  | Clight.Scost (lbl, s) when CostLabel.Map.mem lbl cost_mapping ->
    228       let s' = instrument_body cost_mapping cost_incr s in
    229       let incr = CostLabel.Map.find lbl cost_mapping in
    230       if incr = 0 then s'
    231       else
    232         let fun_typ = Clight.Tfunction ([int_typ], Clight.Tvoid) in
    233         let f = Clight.Expr (Clight.Evar cost_incr, fun_typ) in
    234         let args = [Clight.Expr (Clight.Econst_int incr, int_typ)] in
    235         Clight.Ssequence (Clight.Scall (None, f, args), s')
    236   | Clight.Scost (_, s) ->
    237       instrument_body cost_mapping cost_incr s
     228    (* Keep the cost label in the code. *)
     229    let s' = instrument_body cost_mapping cost_incr s in
     230    let incr = CostLabel.Map.find lbl cost_mapping in
     231    let fun_typ = Clight.Tfunction ([int_typ], Clight.Tvoid) in
     232    let f = Clight.Expr (Clight.Evar cost_incr, fun_typ) in
     233    let args = [Clight.Expr (Clight.Econst_int incr, int_typ)] in
     234    Clight.Scost (lbl, Clight.Ssequence (Clight.Scall (None, f, args), s'))
     235  (*
     236    let s' = instrument_body cost_mapping cost_incr s in
     237    let incr = CostLabel.Map.find lbl cost_mapping in
     238    if incr = 0 then s'
     239    else
     240    let fun_typ = Clight.Tfunction ([int_typ], Clight.Tvoid) in
     241    let f = Clight.Expr (Clight.Evar cost_incr, fun_typ) in
     242    let args = [Clight.Expr (Clight.Econst_int incr, int_typ)] in
     243    Clight.Ssequence (Clight.Scall (None, f, args), s')
     244  *)
     245  | Clight.Scost (lbl, s) ->
     246    (* Keep the cost label in the code and show the increment of 0. *)
     247    let s' = instrument_body cost_mapping cost_incr s in
     248    let fun_typ = Clight.Tfunction ([int_typ], Clight.Tvoid) in
     249    let f = Clight.Expr (Clight.Evar cost_incr, fun_typ) in
     250    let args = [Clight.Expr (Clight.Econst_int 0, int_typ)] in
     251    Clight.Scost (lbl, Clight.Ssequence (Clight.Scall (None, f, args), s'))
     252  (*
     253    instrument_body cost_mapping cost_incr s
     254  *)
    238255and instrument_ls cost_mapping cost_incr = function
    239256  | Clight.LSdefault s ->
    240       let s' = instrument_body cost_mapping cost_incr s in
    241       Clight.LSdefault s'
     257    let s' = instrument_body cost_mapping cost_incr s in
     258    Clight.LSdefault s'
    242259  | Clight.LScase (i, s, ls) ->
    243       let s' = instrument_body cost_mapping cost_incr s in
    244       let ls' = instrument_ls cost_mapping cost_incr ls in
    245       Clight.LScase (i, s', ls')
     260    let s' = instrument_body cost_mapping cost_incr s in
     261    let ls' = instrument_ls cost_mapping cost_incr ls in
     262    Clight.LScase (i, s', ls')
    246263
    247264(* Instrument a function. *)
Note: See TracChangeset for help on using the changeset viewer.