1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798(**************************************************************************)(* This file is part of the Codex semantics library. *)(* *)(* Copyright (C) 2013-2025 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file LICENSE). *)(* *)(**************************************************************************)(* Input signature for Region_analysis. *)(* type 'node entry_edge = (would be useful if we also want the "before" state)
| Entry of 'node (Function entry)
| Back_edge of 'node (Back edge to a loop)
| Norm_Edge of 'node * 'node
*)(* Edges exiting from a node. *)type'nodeedge=|Edgeof'node*'node(* Normal edge. *)|Exitof'node(* Function Exit. *)moduletypeNODE=sigtypenodevalequal:node->node->boolvalpretty:Format.formatter->node->unit(* An imperative dictionary with nodes as keys, and a default value. *)moduleDict:sigtype'at(* Create an initial array of size n, with a default value. *)valcreate:int->'a->'atvalget:'at->node->'avalset:'at->node->'a->unitvaliter:'at->(node->'a->unit)->unitvalcopy:'at->'at(* Shallow copy *)endmoduleSet:Set.Swithtypeelt=node(* The graph of nodes. *)moduleGraph:sigvalsize:intvaliter_nodes:(node->unit)->unitvaliter_succs:node->(node->unit)->unitvaliter_preds:node->(node->unit)->unit(* Entry, exits, and nodes of the whole graph. *)valall_nodes:Set.tvalentry_node:nodevalexit_nodes:nodelistendmoduleDomTree:sigvaldominates:node->node->bool(* Postfix iteration on the dominator tree. *)valdomtree_postfix_iter:(node->unit)->unitend(* An imperative dictionary of edges. No default value: calling get
on an edge that was never set is forbidden. *)moduleEdge_Dict:sigtype'atvalset:'at->nodeedge->'a->unitvalget:'at->nodeedge->'avalcreate:unit->'atvaliter:'at->(nodeedge->'a->unit)->unitend(* For now. Can be something else. TODO: Use it to perform loop analysis. *)typeabstract_value(* Compile a node into a function that, given an input abstract
value, return the output abstract value for each outgoing edge of
the node. *)valcompile_node:node->abstract_value->(nodeedge*abstract_value)list(* Merge the abstract values coming into a node from different edges. *)valjoin:abstract_valuelist->abstract_value(* Given a function providing the effect of a loop, and the initial
value at the end of the loop, return an abstract value describing
any iteration of a loop. *)valmu:(abstract_value->abstract_value)->abstract_value->abstract_valueend