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 | val make_id : string -> index -> string |
---|

20 | |
---|

21 | type indexing = sexpr array |
---|

22 | |
---|

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

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

25 | |
---|

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

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

28 | |
---|

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

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

31 | |
---|

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

33 | |
---|

34 | type t = { |
---|

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

36 | i : indexing |
---|

37 | } |
---|

38 | |
---|

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

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

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

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

43 | |
---|

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

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

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

47 | |
---|

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

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

50 | |
---|

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

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

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

54 | |
---|

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

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

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

58 | |
---|