Project

General

Profile

Revision ca88e660 src/optimize_machine.ml

View differences:

src/optimize_machine.ml
45 45
and eliminate_expr elim expr =
46 46
  match expr.value_desc with
47 47
  | LocalVar v -> (try IMap.find v.var_id elim with Not_found -> expr)
48
<<<<<<< HEAD
49
  | Fun (id, vl) -> Fun (id, List.map (eliminate_expr elim) vl)
50
  | Array(vl) -> Array(List.map (eliminate_expr elim) vl)
51
  | Access(v1, v2) -> Access(eliminate_expr elim v1, eliminate_expr elim v2)
52
  | Power(v1, v2) -> Power(eliminate_expr elim v1, eliminate_expr elim v2)
53
  | Cst _ -> expr
48
  | Fun (id, vl) -> {expr with value_desc = Fun (id, List.map (eliminate_expr elim) vl)}
49
  | Array(vl) -> {expr with value_desc = Array(List.map (eliminate_expr elim) vl)}
50
  | Access(v1, v2) -> { expr with value_desc = Access(eliminate_expr elim v1, eliminate_expr elim v2)}
51
  | Power(v1, v2) -> { expr with value_desc = Power(eliminate_expr elim v1, eliminate_expr elim v2)}
52
  | Cst _ | StateVar _ -> expr
54 53

  
55 54
let eliminate_dim elim dim =
56 55
  Dimension.expr_replace_expr 
......
59 58
      with Not_found -> mkdim_ident dim.dim_loc v) 
60 59
    dim
61 60

  
61

  
62
(* 8th Jan 2016: issues when merging salsa with horn_encoding: The following
63
   functions seem unsused. They have to be adapted to the new type for expr
64

  
65

  
62 66
let unfold_expr_offset m offset expr =
63 67
  List.fold_left 
64 68
    (fun res -> 
65 69
      (function Index i -> 
66
       Access(res, value_of_dimension m i) 
70
	Access(res, value_of_dimension m i) 
67 71
      | Field f -> failwith "not yet implemented"))
68 72
    expr offset
69 73

  
......
80 84
    | _ -> (Format.eprintf "internal error: Optimize_machine.simplify_cst_expr %a@." Printers.pp_const cst; assert false)
81 85

  
82 86
let simplify_expr_offset m expr =
83
  let rec simplify offset expr =
87
  let rec simplify offset expr_desc =
84 88
    match offset, expr with
85 89
    | Field f ::q , _                -> failwith "not yet implemented"
86 90
    | _           , Fun (id, vl) when Basic_library.is_internal_fun id
......
98 102
(*    | _ -> (Format.eprintf "internal error: Optimize_machine.simplify_expr_offset %a@." pp_val expr; assert false) *)
99 103
    (*Format.eprintf "simplify_expr %a %a = %a@." pp_val expr (Utils.fprintf_list ~sep:"" Printers.pp_offset) offset pp_val res; res)
100 104
     with e -> (Format.eprintf "simplify_expr %a %a = <FAIL>@." pp_val expr (Utils.fprintf_list ~sep:"" Printers.pp_offset) offset; raise e*)
101
  in simplify [] expr
105
  in { expr with value_desc = simplify [] expr_desc }
102 106

  
103 107
let rec simplify_instr_offset m accu instr =
104 108
  match instr with
......
119 123
and simplify_instrs_offset m instrs =
120 124
  let rev_l = List.fold_left (simplify_instr_offset m) [] instrs in
121 125
  List.rev rev_l
122
=======
123
  | Fun (id, vl) -> {expr with value_desc = Fun (id, List.map (eliminate_expr elim) vl)}
124
  | Array(vl) -> {expr with value_desc = Array(List.map (eliminate_expr elim) vl)}
125
  | Access(v1, v2) -> { expr with value_desc = Access(eliminate_expr elim v1, eliminate_expr elim v2)}
126
  | Power(v1, v2) -> { expr with value_desc = Power(eliminate_expr elim v1, eliminate_expr elim v2)}
127
  | Cst _ | StateVar _ -> expr
128
>>>>>>> salsa
126
*)
129 127

  
130 128
let is_scalar_const c =
131 129
  match c with

Also available in: Unified diff