Changeset 641
- Timestamp:
- Mar 7, 2011, 2:18:53 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Deliverables/D2.2/8051/src/ASM/ASMCosts.ml
r634 r641 44 44 45 45 46 let compare pc1 cost1 pc2 cost2 = 47 if cost1 <> cost2 then 46 let rec compare = function 47 | [] -> assert false (* do not use an this argument *) 48 | [(_, cost)] -> cost 49 | (pc1, cost1) :: (pc2, cost2) :: l when cost1 <> cost2 -> 48 50 warning 49 51 (Printf.sprintf 50 52 "Warning: branching to %s has cost %d, branching to %s has cost %d" 51 "*fixme*" (* pc1 *) cost1 "*fixme*" (* pc2 *) cost2) ; 52 max cost1 cost2 53 (string_of_int (BitVectors.int_of_vect pc1)) cost1 54 (string_of_int (BitVectors.int_of_vect pc2)) cost2) ; 55 max cost1 (compare ((pc2, cost2) :: l)) 56 | _ :: l -> compare l 53 57 54 58 let rec block_costl mem costs = function 55 59 | [] -> 0 56 60 | [pc] when BitVectors.WordMap.mem pc costs -> 0 57 | [pc] -> 58 let (_, _, next_pcs, cost) = inst_infos mem pc in 59 cost + (block_costl mem costs next_pcs) 60 | pc1 :: pc2 :: _ -> 61 let cost1 = block_costl mem costs [pc1] in 62 let cost2 = block_costl mem costs [pc2] in 63 compare pc1 cost1 pc2 cost2 61 | next_pcs -> 62 compare (List.map (fun pc -> (pc, block_cost mem costs pc)) next_pcs) 64 63 65 let block_cost mem costs pc = block_costl mem costs [pc] 64 and block_cost mem costs pc = 65 let (_, _, next_pcs, cost) = inst_infos mem pc in 66 cost + (block_costl mem costs next_pcs) 66 67 67 68 … … 73 74 | _::tl when BitVectors.WordMap.mem pc p.ASM.cost_labels -> 74 75 let lbl = BitVectors.WordMap.find pc p.ASM.cost_labels in 75 let cost = block_cost mem p.ASM.cost_labels newpc in76 let cost = block_cost mem p.ASM.cost_labels pc in 76 77 let costs_mapping = aux newpc tl in 77 78 CostLabel.Map.add lbl cost costs_mapping
Note: See TracChangeset
for help on using the changeset viewer.