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 *) |
---|

6 | module Atom : sig |
---|

7 | include StringSig.S |
---|

8 | end |
---|

9 | |
---|

10 | (** Simple expressions corresponding to loop tranformations. |
---|

11 | TODO: leave it abstract or not? *) |
---|

12 | type sexpr |
---|

13 | |
---|

14 | val sexpr_id : sexpr |
---|

15 | |
---|

16 | (* trying a nameless approach *) |
---|

17 | type index = int |
---|

18 | |
---|

19 | type indexing = sexpr array |
---|

20 | |
---|

21 | (** [id_indexing n] generates an identity indexing nested in [n] loops *) |
---|

22 | val id_indexing : int -> indexing |
---|

23 | |
---|

24 | (** [compose_index i s l] applies the transformation [i] |--> [s] to [l] *) |
---|

25 | val compose_index : index -> sexpr -> indexing -> unit |
---|

26 | |
---|

27 | (** [compose_index l m] applies all the transformations in [l] to [m] *) |
---|

28 | val compose_indexing : indexing -> indexing -> unit |
---|

29 | |
---|

30 | module IndexingSet : Set.S with type elt = indexing |
---|

31 | |
---|

32 | type t = { |
---|

33 | name : Atom.t; |
---|

34 | i : indexing |
---|

35 | } |
---|

36 | |
---|

37 | (** [string_of_cost_label pref t] converts an indexed label to a |
---|

38 | string suitable for a label name in source |
---|

39 | [string_of_cost_label ~pretty:true t] prints a more readable form *) |
---|

40 | val string_of_cost_label : ?pretty : bool -> t -> string |
---|

41 | |
---|

42 | (** [fresh i u] creates a fresh label using [u] as name universe, inside |
---|

43 | the indexing [i] (which represents the nested loops containing the label) *) |
---|

44 | val fresh : indexing -> Atom.Gen.universe -> t |
---|

45 | |
---|

46 | module Set : Set.S with type elt = t |
---|

47 | module Map : Map.S with type key = t |
---|

48 | |
---|

49 | (** [indexings_of a s] produces the set of indexings of an atom [a] occurring |
---|

50 | in the set of indexed labels [s]. *) |
---|

51 | val indexings_of : Atom.t -> Set.t -> IndexingSet.t |
---|

52 | |
---|

53 | (** [constant_map d x] produces a finite map which associates |
---|

54 | [x] to every element of the set [d]. *) |
---|

55 | val constant_map : Set.t -> 'a -> 'a Map.t |
---|

56 | |
---|