1 | open RTLabs |
---|
2 | |
---|
3 | type node = Label.t |
---|
4 | |
---|
5 | (** Successors of a statement *) |
---|
6 | val statement_successors : statement -> node list |
---|
7 | |
---|
8 | (** computes a map binding each node to its set of predecessors. The domain |
---|
9 | is guaranteed to be equal to the domain of the input graph *) |
---|
10 | val compute_predecessors : graph -> Label.Set.t Label.Map.t |
---|
11 | |
---|
12 | (** computes a map binding each node to its list of predecessors. The domain |
---|
13 | is guaranteed to be equal to the domain of the input graph *) |
---|
14 | val compute_predecessor_lists : graph -> Label.t list Label.Map.t |
---|
15 | |
---|
16 | (** Fills the labels of the statement with ones provided as argument. If not |
---|
17 | enough labels are provided it raises Invalid_arguement. If more than enough |
---|
18 | labels are provided, exceeding labels are ignored *) |
---|
19 | val fill_labels : statement -> Label.t list -> statement |
---|
20 | |
---|
21 | (** Given a graph and an entry point, this function deletes all unreachable |
---|
22 | nodes *) |
---|
23 | val dead_code_elim : graph -> node -> graph |
---|
24 | |
---|
25 | (** [insert_in_between u g src tgt s] inserts [s] between [src] and [tgt]. |
---|
26 | [tgt] should be a successor of [src], and the provided [s] should already be |
---|
27 | linked to [tgt]. This function just generates a new node containing [s] |
---|
28 | and updates [src]'s links to [tgt] to be pointing to this new node. |
---|
29 | If [src] is linked to [tgt] multiple times, all such links are updated. |
---|
30 | The generated label is provided alongside the new graph. *) |
---|
31 | val insert_in_between : |
---|
32 | (unit -> node) -> graph -> node -> node -> statement -> Label.t * graph |
---|
33 | |
---|
34 | (** [dfs_fold f g entry a] preforms a fold with function [f] and initial value |
---|
35 | [a] doing a depth-first sweep of [g] from entry node [entry]. In particular |
---|
36 | all unreachable nodes are ignored. *) |
---|
37 | val dfs_fold : (node -> statement -> 'a -> 'a) -> graph -> node -> 'a -> 'a |
---|
38 | |
---|
39 | (** [dfs_fold f g entry a] preforms an iteration of function [f] performing a |
---|
40 | depth-first sweep of [g] from entry node [entry]. In particular |
---|
41 | all unreachable nodes are ignored. *) |
---|
42 | val dfs_iter : (node -> statement -> unit) -> graph -> node -> unit |
---|
43 | |
---|
44 | (** Computes a map from register to their types in the function |
---|
45 | TODO: are gloabl variables registers too? *) |
---|
46 | val computes_type_map : internal_function -> AST.sig_type Register.Map.t |
---|
47 | |
---|
48 | (** Tells what local register is directly modified by the statement, if any *) |
---|
49 | val modified_at_stmt : statement -> Register.t option |
---|
50 | |
---|
51 | (** [modified_at g l] is the same as [modified_at_stmt s] where [s] is the |
---|
52 | statement in [g] at [l]. *) |
---|
53 | val modified_at : graph -> node -> Register.t option |
---|