source: Deliverables/D2.2/8051-indexed-labels-branch/src/common/costLabel.mli @ 1433

Last change on this file since 1433 was 1433, checked in by tranquil, 8 years ago
  • added infrastructure to add same-language transformations along the compilation chain from command line options
  • started work on cost expression semplification
File size: 3.7 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
14val sexpr_id : sexpr
15
16(* trying a nameless approach *)
17type index = int
18
19val make_id : string -> index -> string
20
21type indexing = sexpr list
22
23type const_indexing
24
25val const_ind_iter : (int -> unit) -> const_indexing -> unit
26
27(** Top of the stack.
28    @raise [Invalid_argument "non-empty indexing stack"] if argument is empty *)
29val curr_const_ind : const_indexing list -> const_indexing
30
31(** [enter_loop inds n] is used to update the indexing stack [ind] when one
32    is entering a loop indexed by [n]. Raises [Invalid_argument
33                "non-empty indexing stack"] if [inds] is empty. *)
34val enter_loop : const_indexing list -> index -> unit
35
36(** [enter_loop_opt inds (Some n)] behaves like [enter_loop inds n], and does
37    nothing in case of [None].
38                @see enter_loop *)
39val enter_loop_opt : const_indexing list -> index option -> unit 
40
41(** [continue_loop inds n] is used to update the indexing stack [inds] when
42    one is continuing a loop indexed by [n].
43                @raise [Invalid_argument "non-empty indexing stack"] if [inds] is empty.
44                @raise [Invalid_argument "uninitialized loop index"] if the head of
45                [inds] has no value for [index]. *)
46val continue_loop : const_indexing list -> index -> unit
47
48(** [continue_loop_opt inds (Some n)] behaves like [continue_loop inds n], and
49    does nothing in case of [None].
50    @see continue_loop *)
51val continue_loop_opt : const_indexing list -> index option -> unit
52
53(** [new_const_ind inds] pushes a new empty constant indexing on top of the
54    stack [inds]. *) 
55val new_const_ind : const_indexing list -> const_indexing list
56
57(** [forget_const_ind inds] pops and discards the top constant indexing from the
58    stack [inds].  Raises [Invalid_argument "non-empty indexing stack"] if
59                [inds] is empty. *) 
60val forget_const_ind : const_indexing list -> const_indexing list
61
62
63 
64
65(** [empty_indexing] generates an empty indexing *) 
66val empty_indexing : indexing
67
68(** [add_id_indexing ind] adds an identity mapping in front of ind **)
69val add_id_indexing : indexing -> indexing
70
71module IndexingSet : Set.S with type elt = indexing
72
73type t = {
74        name : Atom.t;
75        i : indexing
76}
77
78(** [comp_index i s lbl] gives back the label [lbl] where index [i] is remapped
79    to the simple expression [s]. *)
80val comp_index : index -> sexpr -> t -> t
81
82
83(** [ev_indexing ind lbl] returns [lbl] where its indexing has been
84    evaluated in the constant indexing [ind].
85                @raise  Invalid_argument "constant indexing not enough to be applied" if
86                [ind] does not contain enough mappings to evaluate [lbl]'s indexing. *)
87val ev_indexing : const_indexing -> t -> t
88
89(** [string_of_cost_label pref t] converts an indexed label to a
90    string suitable for a label name in source
91                [string_of_cost_label ~pretty:true t] prints a more readable form *)
92val string_of_cost_label : ?pretty : bool -> t -> string
93
94(** [fresh i u] creates a fresh label using [u] as name universe, inside
95    the indexing [i] (which represents the nested loops containing the label) *)
96val fresh : indexing -> Atom.Gen.universe -> t
97
98module Set : Set.S with type elt = t
99module Map : Map.S with type key = t
100
101(** [indexings_of a s] produces the set of indexings of an atom [a] occurring
102    in the set of indexed labels [s]. *)
103val indexings_of : Atom.t -> Set.t -> IndexingSet.t
104
105(** [constant_map d x] produces a finite map which associates
106    [x] to every element of the set [d]. *)
107val constant_map : Set.t -> 'a -> 'a Map.t
108
109
Note: See TracBrowser for help on using the repository browser.