mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-18 08:36:43 -05:00
53 lines
No EOL
24 KiB
HTML
53 lines
No EOL
24 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Flambda_utils (ocaml.Flambda_utils)</title><link rel="stylesheet" href="../../_odoc-theme/odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.2.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../index.html">ocaml</a> » Flambda_utils</nav><header class="odoc-preamble"><h1>Module <code><span>Flambda_utils</span></code></h1><p>Utility functions for the Flambda intermediate language.</p></header><div class="odoc-content"><p>Access functions</p><div class="odoc-spec"><div class="spec value anchored" id="val-find_declaration"><a href="#val-find_declaration" class="anchor"></a><code><span><span class="keyword">val</span> find_declaration :
|
||
<span><a href="../Closure_id/index.html#type-t">Closure_id.t</a> <span class="arrow">-></span></span>
|
||
<span><a href="../Flambda/index.html#type-function_declarations">Flambda.function_declarations</a> <span class="arrow">-></span></span>
|
||
<a href="../Flambda/index.html#type-function_declaration">Flambda.function_declaration</a></span></code></div><div class="spec-doc"><p><code>find_declaration f decl</code> raises <code>Not_found</code> if <code>f</code> is not in <code>decl</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-find_declaration_variable"><a href="#val-find_declaration_variable" class="anchor"></a><code><span><span class="keyword">val</span> find_declaration_variable :
|
||
<span><a href="../Closure_id/index.html#type-t">Closure_id.t</a> <span class="arrow">-></span></span>
|
||
<span><a href="../Flambda/index.html#type-function_declarations">Flambda.function_declarations</a> <span class="arrow">-></span></span>
|
||
<a href="../Variable/index.html#type-t">Variable.t</a></span></code></div><div class="spec-doc"><p><code>find_declaration_variable f decl</code> raises <code>Not_found</code> if <code>f</code> is not in <code>decl</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-find_free_variable"><a href="#val-find_free_variable" class="anchor"></a><code><span><span class="keyword">val</span> find_free_variable :
|
||
<span><a href="../Var_within_closure/index.html#type-t">Var_within_closure.t</a> <span class="arrow">-></span></span>
|
||
<span><a href="../Flambda/index.html#type-set_of_closures">Flambda.set_of_closures</a> <span class="arrow">-></span></span>
|
||
<a href="../Variable/index.html#type-t">Variable.t</a></span></code></div><div class="spec-doc"><p><code>find_free_variable v clos</code> raises <code>Not_found</code> if <code>c</code> is not in <code>clos</code>.</p></div></div><p>Utility functions</p><div class="odoc-spec"><div class="spec value anchored" id="val-function_arity"><a href="#val-function_arity" class="anchor"></a><code><span><span class="keyword">val</span> function_arity : <span><a href="../Flambda/index.html#type-function_declaration">Flambda.function_declaration</a> <span class="arrow">-></span></span> int</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-variables_bound_by_the_closure"><a href="#val-variables_bound_by_the_closure" class="anchor"></a><code><span><span class="keyword">val</span> variables_bound_by_the_closure :
|
||
<span><a href="../Closure_id/index.html#type-t">Closure_id.t</a> <span class="arrow">-></span></span>
|
||
<span><a href="../Flambda/index.html#type-function_declarations">Flambda.function_declarations</a> <span class="arrow">-></span></span>
|
||
<a href="../Variable/Set/index.html#type-t">Variable.Set.t</a></span></code></div><div class="spec-doc"><p>Variables "bound by a closure" are those variables free in the corresponding function's body that are neither:</p><ul><li>bound as parameters of that function; nor</li><li>bound by the <code>let</code> binding that introduces the function declaration(s). In particular, if <code>f</code>, <code>g</code> and <code>h</code> are being introduced by a simultaneous, possibly mutually-recursive <code>let</code> binding then none of <code>f</code>, <code>g</code> or <code>h</code> are bound in any of the closures for <code>f</code>, <code>g</code> and <code>h</code>.</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-can_be_merged"><a href="#val-can_be_merged" class="anchor"></a><code><span><span class="keyword">val</span> can_be_merged : <span><a href="../Flambda/index.html#type-t">Flambda.t</a> <span class="arrow">-></span></span> <span><a href="../Flambda/index.html#type-t">Flambda.t</a> <span class="arrow">-></span></span> bool</span></code></div><div class="spec-doc"><p>If <code>can_be_merged f1 f2</code> is <code>true</code>, it is safe to merge switch branches containing <code>f1</code> and <code>f2</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-description_of_toplevel_node"><a href="#val-description_of_toplevel_node" class="anchor"></a><code><span><span class="keyword">val</span> description_of_toplevel_node : <span><a href="../Flambda/index.html#type-t">Flambda.t</a> <span class="arrow">-></span></span> string</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-make_closure_declaration"><a href="#val-make_closure_declaration" class="anchor"></a><code><span><span class="keyword">val</span> make_closure_declaration :
|
||
<span>is_classic_mode:bool <span class="arrow">-></span></span>
|
||
<span>id:<a href="../Variable/index.html#type-t">Variable.t</a> <span class="arrow">-></span></span>
|
||
<span>body:<a href="../Flambda/index.html#type-t">Flambda.t</a> <span class="arrow">-></span></span>
|
||
<span>params:<span><a href="../Parameter/index.html#type-t">Parameter.t</a> list</span> <span class="arrow">-></span></span>
|
||
<a href="../Flambda/index.html#type-t">Flambda.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-toplevel_substitution"><a href="#val-toplevel_substitution" class="anchor"></a><code><span><span class="keyword">val</span> toplevel_substitution :
|
||
<span><span><a href="../Variable/index.html#type-t">Variable.t</a> <a href="../Variable/Map/index.html#type-t">Variable.Map.t</a></span> <span class="arrow">-></span></span>
|
||
<span><a href="../Flambda/index.html#type-expr">Flambda.expr</a> <span class="arrow">-></span></span>
|
||
<a href="../Flambda/index.html#type-expr">Flambda.expr</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-toplevel_substitution_named"><a href="#val-toplevel_substitution_named" class="anchor"></a><code><span><span class="keyword">val</span> toplevel_substitution_named :
|
||
<span><span><a href="../Variable/index.html#type-t">Variable.t</a> <a href="../Variable/Map/index.html#type-t">Variable.Map.t</a></span> <span class="arrow">-></span></span>
|
||
<span><a href="../Flambda/index.html#type-named">Flambda.named</a> <span class="arrow">-></span></span>
|
||
<a href="../Flambda/index.html#type-named">Flambda.named</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-bind"><a href="#val-bind" class="anchor"></a><code><span><span class="keyword">val</span> bind :
|
||
<span>bindings:<span><span>(<a href="../Variable/index.html#type-t">Variable.t</a> * <a href="../Flambda/index.html#type-named">Flambda.named</a>)</span> list</span> <span class="arrow">-></span></span>
|
||
<span>body:<a href="../Flambda/index.html#type-t">Flambda.t</a> <span class="arrow">-></span></span>
|
||
<a href="../Flambda/index.html#type-t">Flambda.t</a></span></code></div><div class="spec-doc"><p><code>bind [var1, expr1; ...; varN, exprN] body</code> binds using <code>Immutable</code> <code>Let</code> expressions the given <code>(var, expr)</code> pairs around the body.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-name_expr"><a href="#val-name_expr" class="anchor"></a><code><span><span class="keyword">val</span> name_expr : <span>name:<a href="../Internal_variable_names/index.html#type-t">Internal_variable_names.t</a> <span class="arrow">-></span></span> <span><a href="../Flambda/index.html#type-named">Flambda.named</a> <span class="arrow">-></span></span> <a href="../Flambda/index.html#type-t">Flambda.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-name_expr_from_var"><a href="#val-name_expr_from_var" class="anchor"></a><code><span><span class="keyword">val</span> name_expr_from_var : <span>var:<a href="../Variable/index.html#type-t">Variable.t</a> <span class="arrow">-></span></span> <span><a href="../Flambda/index.html#type-named">Flambda.named</a> <span class="arrow">-></span></span> <a href="../Flambda/index.html#type-t">Flambda.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-initialize_symbols"><a href="#val-initialize_symbols" class="anchor"></a><code><span><span class="keyword">val</span> initialize_symbols :
|
||
<span><a href="../Flambda/index.html#type-program">Flambda.program</a> <span class="arrow">-></span></span>
|
||
<span><span>(<a href="../Symbol/index.html#type-t">Symbol.t</a> * <a href="../Tag/index.html#type-t">Tag.t</a> * <span><a href="../Flambda/index.html#type-t">Flambda.t</a> list</span>)</span> list</span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-imported_symbols"><a href="#val-imported_symbols" class="anchor"></a><code><span><span class="keyword">val</span> imported_symbols : <span><a href="../Flambda/index.html#type-program">Flambda.program</a> <span class="arrow">-></span></span> <a href="../Symbol/Set/index.html#type-t">Symbol.Set.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-needed_import_symbols"><a href="#val-needed_import_symbols" class="anchor"></a><code><span><span class="keyword">val</span> needed_import_symbols : <span><a href="../Flambda/index.html#type-program">Flambda.program</a> <span class="arrow">-></span></span> <a href="../Symbol/Set/index.html#type-t">Symbol.Set.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-introduce_needed_import_symbols"><a href="#val-introduce_needed_import_symbols" class="anchor"></a><code><span><span class="keyword">val</span> introduce_needed_import_symbols : <span><a href="../Flambda/index.html#type-program">Flambda.program</a> <span class="arrow">-></span></span> <a href="../Flambda/index.html#type-program">Flambda.program</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-root_symbol"><a href="#val-root_symbol" class="anchor"></a><code><span><span class="keyword">val</span> root_symbol : <span><a href="../Flambda/index.html#type-program">Flambda.program</a> <span class="arrow">-></span></span> <a href="../Symbol/index.html#type-t">Symbol.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-might_raise_static_exn"><a href="#val-might_raise_static_exn" class="anchor"></a><code><span><span class="keyword">val</span> might_raise_static_exn : <span><a href="../Flambda/index.html#type-named">Flambda.named</a> <span class="arrow">-></span></span> <span><a href="../Static_exception/index.html#type-t">Static_exception.t</a> <span class="arrow">-></span></span> bool</span></code></div><div class="spec-doc"><p>Returns <code>true</code> iff the given term might raise the given static exception.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-make_closure_map"><a href="#val-make_closure_map" class="anchor"></a><code><span><span class="keyword">val</span> make_closure_map : <span><a href="../Flambda/index.html#type-program">Flambda.program</a> <span class="arrow">-></span></span> <span><a href="../Set_of_closures_id/index.html#type-t">Set_of_closures_id.t</a> <a href="../Closure_id/Map/index.html#type-t">Closure_id.Map.t</a></span></span></code></div><div class="spec-doc"><p>Creates a map from closure IDs to set_of_closure IDs by iterating over all sets of closures in the given program.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-all_lifted_constants"><a href="#val-all_lifted_constants" class="anchor"></a><code><span><span class="keyword">val</span> all_lifted_constants :
|
||
<span><a href="../Flambda/index.html#type-program">Flambda.program</a> <span class="arrow">-></span></span>
|
||
<span><span>(<a href="../Symbol/index.html#type-t">Symbol.t</a> * <a href="../Flambda/index.html#type-constant_defining_value">Flambda.constant_defining_value</a>)</span> list</span></span></code></div><div class="spec-doc"><p>The definitions of all constants that have been lifted out to <code>Let_symbol</code> or <code>Let_rec_symbol</code> constructions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-all_lifted_constants_as_map"><a href="#val-all_lifted_constants_as_map" class="anchor"></a><code><span><span class="keyword">val</span> all_lifted_constants_as_map :
|
||
<span><a href="../Flambda/index.html#type-program">Flambda.program</a> <span class="arrow">-></span></span>
|
||
<span><a href="../Flambda/index.html#type-constant_defining_value">Flambda.constant_defining_value</a> <a href="../Symbol/Map/index.html#type-t">Symbol.Map.t</a></span></span></code></div><div class="spec-doc"><p>Like <code>all_lifted_constant_symbols</code>, but returns a map instead of a list.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-all_lifted_constant_sets_of_closures"><a href="#val-all_lifted_constant_sets_of_closures" class="anchor"></a><code><span><span class="keyword">val</span> all_lifted_constant_sets_of_closures :
|
||
<span><a href="../Flambda/index.html#type-program">Flambda.program</a> <span class="arrow">-></span></span>
|
||
<a href="../Set_of_closures_id/Set/index.html#type-t">Set_of_closures_id.Set.t</a></span></code></div><div class="spec-doc"><p>The identifiers of all constant sets of closures that have been lifted out to <code>Let_symbol</code> or <code>Let_rec_symbol</code> constructions.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-all_lifted_constant_closures"><a href="#val-all_lifted_constant_closures" class="anchor"></a><code><span><span class="keyword">val</span> all_lifted_constant_closures : <span><a href="../Flambda/index.html#type-program">Flambda.program</a> <span class="arrow">-></span></span> <a href="../Closure_id/Set/index.html#type-t">Closure_id.Set.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-all_sets_of_closures"><a href="#val-all_sets_of_closures" class="anchor"></a><code><span><span class="keyword">val</span> all_sets_of_closures : <span><a href="../Flambda/index.html#type-program">Flambda.program</a> <span class="arrow">-></span></span> <span><a href="../Flambda/index.html#type-set_of_closures">Flambda.set_of_closures</a> list</span></span></code></div><div class="spec-doc"><p>All sets of closures in the given program (whether or not bound to a symbol.)</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-all_sets_of_closures_map"><a href="#val-all_sets_of_closures_map" class="anchor"></a><code><span><span class="keyword">val</span> all_sets_of_closures_map :
|
||
<span><a href="../Flambda/index.html#type-program">Flambda.program</a> <span class="arrow">-></span></span>
|
||
<span><a href="../Flambda/index.html#type-set_of_closures">Flambda.set_of_closures</a> <a href="../Set_of_closures_id/Map/index.html#type-t">Set_of_closures_id.Map.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-substitute_read_symbol_field_for_variables"><a href="#val-substitute_read_symbol_field_for_variables" class="anchor"></a><code><span><span class="keyword">val</span> substitute_read_symbol_field_for_variables :
|
||
<span><span><span>(<a href="../Symbol/index.html#type-t">Symbol.t</a> * <span>int list</span>)</span> <a href="../Variable/Map/index.html#type-t">Variable.Map.t</a></span> <span class="arrow">-></span></span>
|
||
<span><a href="../Flambda/index.html#type-t">Flambda.t</a> <span class="arrow">-></span></span>
|
||
<a href="../Flambda/index.html#type-t">Flambda.t</a></span></code></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Switch_storer"><a href="#module-Switch_storer" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Switch_storer/index.html">Switch_storer</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>For the compilation of switch statements.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-fun_vars_referenced_in_decls"><a href="#val-fun_vars_referenced_in_decls" class="anchor"></a><code><span><span class="keyword">val</span> fun_vars_referenced_in_decls :
|
||
<span><a href="../Flambda/index.html#type-function_declarations">Flambda.function_declarations</a> <span class="arrow">-></span></span>
|
||
<span>closure_symbol:<span>(<span><a href="../Closure_id/index.html#type-t">Closure_id.t</a> <span class="arrow">-></span></span> <a href="../Symbol/index.html#type-t">Symbol.t</a>)</span> <span class="arrow">-></span></span>
|
||
<span><a href="../Variable/Set/index.html#type-t">Variable.Set.t</a> <a href="../Variable/Map/index.html#type-t">Variable.Map.t</a></span></span></code></div><div class="spec-doc"><p>Within a set of function declarations there is a set of function bodies, each of which may (or may not) reference one of the other functions in the same set. Initially such intra-set references are by <code>Var</code>s (known as "fun_var"s) but if the function is lifted by <code>Lift_constants</code> then the references will be translated to <code>Symbol</code>s. This means that optimization passes that need to identify whether a given "fun_var" (i.e. a key in the <code>funs</code> map in a value of type <code>function_declarations</code>) is used in one of the function bodies need to examine the <code>free_symbols</code> as well as the <code>free_variables</code> members of <code>function_declarations</code>. This function makes that process easier by computing all used "fun_var"s in the bodies of the given set of function declarations, including the cases where the references are <code>Symbol</code>s. The returned value is a map from "fun_var"s to the "fun_var"s (if any) used in the body of the function associated with that "fun_var".</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-closures_required_by_entry_point"><a href="#val-closures_required_by_entry_point" class="anchor"></a><code><span><span class="keyword">val</span> closures_required_by_entry_point :
|
||
<span>entry_point:<a href="../Closure_id/index.html#type-t">Closure_id.t</a> <span class="arrow">-></span></span>
|
||
<span>closure_symbol:<span>(<span><a href="../Closure_id/index.html#type-t">Closure_id.t</a> <span class="arrow">-></span></span> <a href="../Symbol/index.html#type-t">Symbol.t</a>)</span> <span class="arrow">-></span></span>
|
||
<span><a href="../Flambda/index.html#type-function_declarations">Flambda.function_declarations</a> <span class="arrow">-></span></span>
|
||
<a href="../Variable/Set/index.html#type-t">Variable.Set.t</a></span></code></div><div class="spec-doc"><p>Computes the set of closure_id in the set of closures that are required used (transitively) the entry_point</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-all_functions_parameters"><a href="#val-all_functions_parameters" class="anchor"></a><code><span><span class="keyword">val</span> all_functions_parameters : <span><a href="../Flambda/index.html#type-function_declarations">Flambda.function_declarations</a> <span class="arrow">-></span></span> <a href="../Variable/Set/index.html#type-t">Variable.Set.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-all_free_symbols"><a href="#val-all_free_symbols" class="anchor"></a><code><span><span class="keyword">val</span> all_free_symbols : <span><a href="../Flambda/index.html#type-function_declarations">Flambda.function_declarations</a> <span class="arrow">-></span></span> <a href="../Symbol/Set/index.html#type-t">Symbol.Set.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-contains_stub"><a href="#val-contains_stub" class="anchor"></a><code><span><span class="keyword">val</span> contains_stub : <span><a href="../Flambda/index.html#type-function_declarations">Flambda.function_declarations</a> <span class="arrow">-></span></span> bool</span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-clean_projections"><a href="#val-clean_projections" class="anchor"></a><code><span><span class="keyword">val</span> clean_projections :
|
||
<span>which_variables:<span><a href="../Flambda/index.html#type-specialised_to">Flambda.specialised_to</a> <a href="../Variable/Map/index.html#type-t">Variable.Map.t</a></span> <span class="arrow">-></span></span>
|
||
<span><a href="../Flambda/index.html#type-specialised_to">Flambda.specialised_to</a> <a href="../Variable/Map/index.html#type-t">Variable.Map.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-projection_to_named"><a href="#val-projection_to_named" class="anchor"></a><code><span><span class="keyword">val</span> projection_to_named : <span><a href="../Projection/index.html#type-t">Projection.t</a> <span class="arrow">-></span></span> <a href="../Flambda/index.html#type-named">Flambda.named</a></span></code></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-specialised_to_same_as"><a href="#type-specialised_to_same_as" class="anchor"></a><code><span><span class="keyword">type</span> specialised_to_same_as</span><span> = </span></code><ol><li id="type-specialised_to_same_as.Not_specialised" class="def variant constructor anchored"><a href="#type-specialised_to_same_as.Not_specialised" class="anchor"></a><code><span>| </span><span><span class="constructor">Not_specialised</span></span></code></li><li id="type-specialised_to_same_as.Specialised_and_aliased_to" class="def variant constructor anchored"><a href="#type-specialised_to_same_as.Specialised_and_aliased_to" class="anchor"></a><code><span>| </span><span><span class="constructor">Specialised_and_aliased_to</span> <span class="keyword">of</span> <a href="../Variable/Set/index.html#type-t">Variable.Set.t</a></span></code></li></ol></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-parameters_specialised_to_the_same_variable"><a href="#val-parameters_specialised_to_the_same_variable" class="anchor"></a><code><span><span class="keyword">val</span> parameters_specialised_to_the_same_variable :
|
||
<span>function_decls:<a href="../Flambda/index.html#type-function_declarations">Flambda.function_declarations</a> <span class="arrow">-></span></span>
|
||
<span>specialised_args:<span><a href="../Flambda/index.html#type-specialised_to">Flambda.specialised_to</a> <a href="../Variable/Map/index.html#type-t">Variable.Map.t</a></span> <span class="arrow">-></span></span>
|
||
<span><span><a href="#type-specialised_to_same_as">specialised_to_same_as</a> list</span> <a href="../Variable/Map/index.html#type-t">Variable.Map.t</a></span></span></code></div><div class="spec-doc"><p>For each parameter in a given set of function declarations and the usual specialised-args mapping, determine which other parameters are specialised to the same variable as that parameter. The result is presented as a map from <code>fun_vars</code> to lists, corresponding componentwise to the usual <code>params</code> list in the corresponding function declaration.</p></div></div></div></body></html> |