Changeset 1421 for Deliverables/D2.2


Ignore:
Timestamp:
Oct 19, 2011, 5:59:50 PM (8 years ago)
Author:
tranquil
Message:

first draft of peeling optimization:

  • a framework for heuristics has been set up, but peeling is always applied at the moment
  • cost mapping not touched yet
Location:
Deliverables/D2.2
Files:
6 edited

Legend:

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

    r1349 r1421  
    293293  let cost_universe = CostLabel.Atom.Gen.new_universe cost_prefix in
    294294  {p with prog_funct = List.map (process_f cost_universe) p.prog_funct}
     295
  • Deliverables/D2.2/8051-indexed-labels-branch/src/clight/clightToCminor.ml

    r1392 r1421  
    604604                        (tmps, Cminor.St_cost (lbl, stmt))
    605605
    606     | _ -> assert false (* type error *)
     606(*    | _ -> assert false (* type error *) *)
    607607
    608608
     
    646646
    647647let translate p =
     648        (* apply loop peeling *)
     649        let p = LoopPeeling.apply p in
    648650  let fresh = ClightAnnotator.make_fresh "_tmp" p in
    649651  { Cminor.vars = List.map translate_global p.Clight.prog_vars ;
  • Deliverables/D2.2/8051-indexed-labels-branch/src/cminor/cminorToRTLabs.ml

    r1392 r1421  
    269269    (rtlabs_fun : RTLabs.internal_function)
    270270    (lenv       : local_env)
    271     (exits      : Label.t list)
     271(*    (exits      : Label.t list) *)
    272272    (stmt       : Cminor.statement)
    273273    : RTLabs.internal_function =
     
    321321
    322322    | Cminor.St_seq (s1, s2) ->
    323       let rtlabs_fun = translate_stmt rtlabs_fun lenv exits s2 in
    324       translate_stmt rtlabs_fun lenv exits s1
     323      let rtlabs_fun = translate_stmt rtlabs_fun lenv s2 in
     324      translate_stmt rtlabs_fun lenv (* exits *) s1
    325325
    326326    | Cminor.St_ifthenelse (e, s1, s2) ->
    327327      let old_entry = rtlabs_fun.RTLabs.f_entry in
    328       let rtlabs_fun = translate_stmt rtlabs_fun lenv exits s2 in
     328      let rtlabs_fun = translate_stmt rtlabs_fun lenv s2 in
    329329      let lbl_false = rtlabs_fun.RTLabs.f_entry in
    330330      let rtlabs_fun = change_entry rtlabs_fun old_entry in
    331       let rtlabs_fun = translate_stmt rtlabs_fun lenv exits s1 in
     331      let rtlabs_fun = translate_stmt rtlabs_fun lenv s1 in
    332332      let lbl_true = rtlabs_fun.RTLabs.f_entry in
    333333      translate_branch rtlabs_fun lenv e lbl_true lbl_false
     
    362362
    363363    | Cminor.St_label (lbl, s) ->
    364       let rtlabs_fun = translate_stmt rtlabs_fun lenv exits s in
     364      let rtlabs_fun = translate_stmt rtlabs_fun lenv s in
    365365      let old_entry = rtlabs_fun.RTLabs.f_entry in
    366366      add_graph rtlabs_fun lbl (RTLabs.St_skip old_entry)
    367367
    368368    | Cminor.St_cost (lbl, s) ->
    369       let rtlabs_fun = translate_stmt rtlabs_fun lenv exits s in
     369      let rtlabs_fun = translate_stmt rtlabs_fun lenv s in
    370370      let old_entry = rtlabs_fun.RTLabs.f_entry in
    371371      generate rtlabs_fun (RTLabs.St_cost (lbl, old_entry))
    372372
    373373    | Cminor.St_ind_0 (i, s) ->
    374       let rtlabs_fun = translate_stmt rtlabs_fun lenv exits s in
     374      let rtlabs_fun = translate_stmt rtlabs_fun lenv s in
    375375      let old_entry = rtlabs_fun.RTLabs.f_entry in
    376376      generate rtlabs_fun (RTLabs.St_ind_0 (i, old_entry))
    377377
    378378    | Cminor.St_ind_inc (i, s) ->
    379       let rtlabs_fun = translate_stmt rtlabs_fun lenv exits s in
     379      let rtlabs_fun = translate_stmt rtlabs_fun lenv s in
    380380      let old_entry = rtlabs_fun.RTLabs.f_entry in
    381381      generate rtlabs_fun (RTLabs.St_ind_inc (i, old_entry))
     
    456456
    457457  (* Complete the graph *)
    458   translate_stmt rtlabs_fun lenv [] f_def.Cminor.f_body
     458  translate_stmt rtlabs_fun lenv f_def.Cminor.f_body
    459459
    460460
  • Deliverables/D2.2/8051-indexed-labels-branch/src/common/costLabel.ml

    r1357 r1421  
    99type sexpr =
    1010    | Sexpr of int*int
     11
     12let is_const_sexpr (Sexpr(a, _)) = (a = 0)
    1113
    1214let sexpr_id = Sexpr(1, 0)
     
    7577
    7678(* i|-->e ° I *)
    77 let rec compose_index i s l = match i, l with
     79let rec compose_index_indexing i s l = match i, l with
    7880        | 0, s' :: l' -> compose_sexpr s s' :: l'
    79         | x, s' :: l' -> compose_index (i-1) s l'
     81        | x, s' :: l' -> s' :: compose_index_indexing (i-1) s l'
    8082        | _ -> l
    8183
     
    8991        | [] -> []
    9092        | s :: l ->
    91                 try
    92                   const_sexpr (ev_sexpr (ExtArray.get c i) s) ::
    93                          compose_const_indexing_i (i+1) c l
    94                 with
    95                         | Invalid_argument _ ->
    96                                 invalid_arg "constant indexing not enough to be applied"
     93                let head =
     94                        (* if s is constant leave it be. In particular, avoid raising the error *)
     95                        if is_const_sexpr s then s else
     96                        try
     97                          const_sexpr (ev_sexpr (ExtArray.get c i) s)
     98                        with
     99                                | Invalid_argument _ ->
     100                                        invalid_arg "constant indexing not enough to be applied" in
     101          head :: compose_const_indexing_i (i+1) c l
    97102
    98103module IndexingSet = Set.Make(struct
     
    105110    i : indexing
    106111}
     112
     113let comp_index i s lbl =
     114        {lbl with i = compose_index_indexing i s lbl.i}
    107115
    108116let ev_indexing c lbl =
  • Deliverables/D2.2/8051-indexed-labels-branch/src/common/costLabel.mli

    r1357 r1421  
    99
    1010(** Simple expressions corresponding to loop tranformations.
    11     TODO: leave it abstract or not? *)
    12 type sexpr
     11    TODO: abstract or not? *)
     12type sexpr = Sexpr of int*int
    1313
    1414val sexpr_id : sexpr
     
    7676}
    7777
    78 (** [apply_const_indexing ind lbl] returns [lbl] where its indexing has been
     78(** [comp_index i s lbl] gives back the label [lbl] where index [i] is remapped
     79    to the simple expression [s]. *)
     80val comp_index : index -> sexpr -> t -> t
     81
     82
     83(** [ev_indexing ind lbl] returns [lbl] where its indexing has been
    7984    evaluated in the constant indexing [ind].
    8085                @raise  Invalid_argument "constant indexing not enough to be applied" if
  • Deliverables/D2.2/8051/src/cminor/cminorInterpret.ml

    r818 r1421  
    248248  | St_switch(_,_,_)            -> None
    249249  | St_return(_)                -> None
    250   | St_label(l,s)               -> if l=lbl then Some((s,k)) else None
     250  | St_label(l,s) when l = lbl  -> Some((s,k))
    251251  | St_goto(_)                  -> None
    252   | St_cost (_,s)               -> fdlbl k s
     252  | St_cost(_,s) | St_label(_,s)-> fdlbl k s
    253253  in match fdlbl k st with
    254254      None -> assert false (*Wrong label*)
Note: See TracChangeset for help on using the changeset viewer.