Project

General

Profile

« Previous | Next » 

Revision c4780a6a

Added by LĂ©lio Brun 7 months ago

work on new reset functions generation

View differences:

src/optimize_machine.ml
33 33
  | MSetReset _
34 34
  | MNoReset _
35 35
  | MClearReset
36
  | MResetAssign _
36 37
  | MSpec _
37 38
  | MComment _         -> instr
38 39
  | MStep (il, i, vl)  -> update_instr_desc instr (MStep(il, i, List.map e_expr vl))
......
58 59
  | Array(vl) -> {expr with value_desc = Array(List.map (eliminate_expr elim) vl)}
59 60
  | Access(v1, v2) -> { expr with value_desc = Access(eliminate_expr elim v1, eliminate_expr elim v2)}
60 61
  | Power(v1, v2) -> { expr with value_desc = Power(eliminate_expr elim v1, eliminate_expr elim v2)}
61
  | Cst _ -> expr
62
  | Cst _ | ResetFlag -> expr
62 63

  
63 64
let eliminate_dim elim dim =
64 65
  Dimension.expr_replace_expr 
......
74 75

  
75 76
let unfold_expr_offset m offset expr =
76 77
  List.fold_left
77
    (fun res -> (function | Index i -> mk_val (Access (res, value_of_dimension m i))
78
					      (Types.array_element_type res.value_type)
79
                          | Field _ -> Format.eprintf "internal error: not yet implemented !"; assert false))
78
    (fun res -> function
79
       | Index i ->
80
         mk_val (Access (res, value_of_dimension m i))
81
           (Types.array_element_type res.value_type)
82
       | Field _ ->
83
         Format.eprintf "internal error: not yet implemented !";
84
         assert false)
80 85
    expr offset
81 86

  
82 87
let rec simplify_cst_expr m offset typ cst =
......
104 109
    | _           , Var _            -> unfold_expr_offset m offset expr
105 110
    | _           , Cst cst          -> simplify_cst_expr m offset expr.value_type cst
106 111
    | _           , Access (expr, i) -> simplify (Index (dimension_of_value i) :: offset) expr
112
    | _           , ResetFlag        -> expr
107 113
    | []          , _                -> expr
108 114
    | Index _ :: q, Power (expr, _)  -> simplify q expr
109 115
    | Index i :: q, Array vl when Dimension.is_dimension_const i
......
120 126
  | MSetReset _
121 127
  | MNoReset _
122 128
  | MClearReset
129
  | MResetAssign _
123 130
  | MSpec _
124 131
  | MComment _             -> instr
125 132
  | MStep (outputs, id, inputs) -> update_instr_desc instr (MStep (outputs, id, List.map (simplify_expr_offset m) inputs))
......
493 500

  
494 501
let rec value_replace_var fvar value =
495 502
  match value.value_desc with
496
  | Cst _ -> value
503
  | Cst _ | ResetFlag -> value
497 504
  | Var v -> { value with value_desc = Var (fvar v) }
498 505
  | Fun (id, args) -> { value with value_desc = Fun (id, List.map (value_replace_var fvar) args) }
499 506
  | Array vl -> { value with value_desc = Array (List.map (value_replace_var fvar) vl)}
......
507 514
  | MSetReset _
508 515
  | MNoReset _
509 516
  | MClearReset
517
  | MResetAssign _
510 518
  | MSpec _
511 519
  | MComment _          -> instr_cons instr cont
512 520
  | MStep (il, i, vl)   -> instr_cons (update_instr_desc instr (MStep (List.map fvar il, i, List.map (value_replace_var fvar) vl))) cont

Also available in: Unified diff