source: Deliverables/D2.2/8051/src/common/costLabel.mli

Last change on this file was 1585, checked in by tranquil, 9 years ago

fighting with a bug of the translation from RTL to ERTL

File size: 4.0 KB
Line 
1
2(** This module provides functions to manipulate and create indexed cost
3    labels. *)
4
5(** [Atom] provides functions for cost atoms, the root of indexed costs *)
6module Atom : sig
7  include StringSig.S
8end
9
10(** Simple expressions corresponding to loop tranformations.
11    TODO: abstract or not? *)
12type sexpr = Sexpr of int*int
13
14(** The identity simple expression, used in initialization. *)
15val sexpr_id : sexpr
16
17(** Indexes are identified with (single-entry) loop depths. *)
18type index = int
19
20(** [make_id prefix index] produces an identifier out of a
21    prefix and a loop depth. *)
22val make_id : string -> index -> string
23
24type indexing = sexpr list
25
26(** The type of constant indexings, to be used by interpreations *)
27type const_indexing
28
29(** [const_ind_iter f c] iterates [f] over the values of indexes in c *)
30val const_ind_iter : (int -> unit) -> const_indexing -> unit
31
32(** This is equivalent to [List.hd], but raises
33    [Invalid_argument "empty indexing stack"] if argument is empty *)
34val curr_const_ind : const_indexing list -> const_indexing
35
36(** [enter_loop inds n] is used to update the indexing stack [ind] when one
37    is entering a loop indexed by [n]. Raises [Invalid_argument
38    "non-empty indexing stack"] if [inds] is empty. *)
39val enter_loop : const_indexing list -> index -> unit
40
41(** [enter_loop_opt inds (Some n)] behaves like [enter_loop inds n], and does
42    nothing in case of [None].
43    @see enter_loop *)
44val enter_loop_opt : const_indexing list -> index option -> unit 
45
46(** [continue_loop inds n] is used to update the indexing stack [inds] when
47    one is continuing a loop indexed by [n].
48    @raise [Invalid_argument "empty indexing stack"] if [inds] is empty.
49    @raise [Invalid_argument "uninitialized loop index"] if the head of
50    [inds] has no value for [index]. *)
51val continue_loop : const_indexing list -> index -> unit
52
53(** [continue_loop_opt inds (Some n)] behaves like [continue_loop inds n], and
54    does nothing in case of [None].
55    @see continue_loop *)
56val continue_loop_opt : const_indexing list -> index option -> unit
57
58(** [new_const_ind inds] pushes a new empty constant indexing on top of the
59    stack [inds]. *) 
60val new_const_ind : const_indexing list -> const_indexing list
61
62(** [forget_const_ind inds] pops and discards the top constant indexing from the
63    stack [inds].  Raises [Invalid_argument "empty indexing stack"] if
64    [inds] is empty. *) 
65val forget_const_ind : const_indexing list -> const_indexing list
66
67(** [empty_indexing] is the empty indexing *) 
68val empty_indexing : indexing
69
70(** [add_id_indexing ind] adds an identity mapping in front of ind **)
71val add_id_indexing : indexing -> indexing
72
73module IndexingSet : Set.S with type elt = indexing
74
75type t = {
76  name : Atom.t;
77  i : indexing
78}
79
80(** [comp_index i s lbl] gives back the label [lbl] where index [i] is remapped
81    to the simple expression [s]. *)
82val comp_index : index -> sexpr -> t -> t
83
84(** [ev_indexing ind lbl] returns [lbl] where its indexing has been
85    evaluated in the constant indexing [ind].
86    @raise  Invalid_argument "constant indexing not enough to be applied" if
87    [ind] does not contain enough mappings to evaluate [lbl]'s indexing. *)
88val ev_indexing : const_indexing -> t -> t
89
90(** [string_of_cost_label pref t] converts an indexed label to a
91    string suitable for a label name in C source.
92    [string_of_cost_label ~pretty:true t] prints a more readable form *)
93val string_of_cost_label : ?pretty : bool -> t -> string
94
95(** [fresh i u] creates a fresh label using [u] as name universe, inside
96    the indexing [i] (which represents the nested loops containing the label) *)
97val fresh : indexing -> Atom.Gen.universe -> t
98
99module Set : Set.S with type elt = t
100module Map : Map.S with type key = t
101
102(** [indexings_of a s] produces the set of indexings of an atom [a] occurring
103    in the set of indexed labels [s]. *)
104val indexings_of : Atom.t -> Set.t -> IndexingSet.t
105
106(** [constant_map d x] produces a finite map which associates
107    [x] to every element of the set [d]. *)
108val constant_map : Set.t -> 'a -> 'a Map.t
Note: See TracBrowser for help on using the repository browser.