Changeset 632


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

Small change in ASMCosts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/ASM/ASMCosts.ml

    r631 r632  
    6666let block_cost mem costs pc =
    6767  let treat = treat mem costs in
    68   let (init_cost, next_pcs) = treat pc in
    6968  let rec aux = function
    7069    | [] -> 0
    71     | [pc] when BitVectors.WordMap.mem pc costs ->0
     70    | [pc] when BitVectors.WordMap.mem pc costs -> 0
    7271    | [pc] -> full_cost pc
    7372    | [pc1 ; pc2] when BitVectors.WordMap.mem pc1 costs &&
     
    8786    let (cost, next_pcs) = treat pc in
    8887    cost + (aux next_pcs) in
    89   init_cost + (aux next_pcs)
     88  full_cost pc
    9089
    9190
     
    113112let first_cost_label mem costs =
    114113  let rec aux oldpc =
    115     try (BitVectors.WordMap.find oldpc costs, 0)
    116     with
    117       | Not_found ->
    118         let inst,pc,inst_cost = ASMInterpret.fetch mem oldpc in
    119         match inst_nature oldpc inst with
    120           | Direct_fun_call pc ->
    121             let (lbl, cost) = aux pc in
    122             (lbl, inst_cost + cost)
    123           | Return
    124           | Goto _
    125           | Branch _ ->
    126             assert false (* no such instructions before calling main *)
    127           | Other ->
    128             let (lbl, cost) = aux pc in
    129             (lbl, inst_cost + cost)
     114    if BitVectors.WordMap.mem oldpc costs then
     115      (BitVectors.WordMap.find oldpc costs, 0)
     116    else
     117      let (inst, pc, inst_cost) = ASMInterpret.fetch mem oldpc in
     118      match inst_nature oldpc inst with
     119        | Direct_fun_call pc ->
     120          let (lbl, cost) = aux pc in
     121          (lbl, inst_cost + cost)
     122        | Return
     123        | Goto _
     124        | Branch _ ->
     125          assert false (* no such instructions before calling main *)
     126        | Other ->
     127          let (lbl, cost) = aux pc in
     128          (lbl, inst_cost + cost)
    130129  in
    131130  aux (BitVectors.zero `Sixteen)
Note: See TracChangeset for help on using the changeset viewer.