[486] | 1 | |
---|
[1291] | 2 | (** This module provides functions to manipulate and create indexed cost |
---|
[486] | 3 | labels. *) |
---|
[1291] | 4 | |
---|
| 5 | (** [Atom] provides functions for cost atoms, the root of indexed costs *) |
---|
| 6 | module Atom : sig |
---|
| 7 | include StringSig.S |
---|
| 8 | end |
---|
[486] | 9 | |
---|
[1297] | 10 | (** Simple expressions corresponding to loop tranformations. |
---|
| 11 | TODO: leave it abstract or not? *) |
---|
[1291] | 12 | type sexpr |
---|
| 13 | |
---|
| 14 | val sexpr_id : sexpr |
---|
| 15 | |
---|
[1297] | 16 | (* trying a nameless approach *) |
---|
| 17 | type index = int |
---|
[1291] | 18 | |
---|
[1305] | 19 | val make_id : string -> index -> string |
---|
| 20 | |
---|
[1310] | 21 | type indexing = sexpr list |
---|
[1291] | 22 | |
---|
[1319] | 23 | type const_indexing = int array |
---|
[1310] | 24 | |
---|
| 25 | (** [enter_loop n indexing] is used to update indexing when one is entering a |
---|
| 26 | loop indexed by [n]. |
---|
| 27 | The function recycles the same constant indexing *) |
---|
[1319] | 28 | val enter_loop : index option -> const_indexing -> unit |
---|
[1310] | 29 | |
---|
| 30 | (** [continue_loop n indexing] is used to update indexing when one is continuing a |
---|
| 31 | loop indexed by [n]. *) |
---|
[1319] | 32 | val continue_loop : index option -> const_indexing -> unit |
---|
[1310] | 33 | |
---|
[1319] | 34 | (** [empty_indexing] generates an empty indexing *) |
---|
| 35 | val empty_indexing : indexing |
---|
[1297] | 36 | |
---|
[1319] | 37 | (** [add_id_indexing ind] adds an identity mapping in front of ind **) |
---|
| 38 | val add_id_indexing : indexing -> indexing |
---|
[1291] | 39 | |
---|
[1297] | 40 | module IndexingSet : Set.S with type elt = indexing |
---|
[1291] | 41 | |
---|
| 42 | type t = { |
---|
| 43 | name : Atom.t; |
---|
[1297] | 44 | i : indexing |
---|
[1291] | 45 | } |
---|
| 46 | |
---|
[1319] | 47 | val apply_const_indexing : const_indexing -> t -> t |
---|
| 48 | |
---|
| 49 | |
---|
[1297] | 50 | (** [string_of_cost_label pref t] converts an indexed label to a |
---|
| 51 | string suitable for a label name in source |
---|
[1291] | 52 | [string_of_cost_label ~pretty:true t] prints a more readable form *) |
---|
| 53 | val string_of_cost_label : ?pretty : bool -> t -> string |
---|
| 54 | |
---|
| 55 | (** [fresh i u] creates a fresh label using [u] as name universe, inside |
---|
| 56 | the indexing [i] (which represents the nested loops containing the label) *) |
---|
[1297] | 57 | val fresh : indexing -> Atom.Gen.universe -> t |
---|
[1291] | 58 | |
---|
| 59 | module Set : Set.S with type elt = t |
---|
| 60 | module Map : Map.S with type key = t |
---|
| 61 | |
---|
| 62 | (** [indexings_of a s] produces the set of indexings of an atom [a] occurring |
---|
| 63 | in the set of indexed labels [s]. *) |
---|
| 64 | val indexings_of : Atom.t -> Set.t -> IndexingSet.t |
---|
| 65 | |
---|
[486] | 66 | (** [constant_map d x] produces a finite map which associates |
---|
| 67 | [x] to every element of the set [d]. *) |
---|
| 68 | val constant_map : Set.t -> 'a -> 'a Map.t |
---|
[1291] | 69 | |
---|