CAP/docs/html/api/Lib.CFG.html
2024-12-01 16:25:18 +01:00

375 lines
47 KiB
HTML

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Lib.CFG module &mdash; MiniC documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sphinx_highlight.js"></script>
<script src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Lib.Terminator module" href="Lib.Terminator.html" />
<link rel="prev" title="Lib.Allocator module" href="Lib.Allocator.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home">
MiniC
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="Lib.Errors.html">Base library - Errors</a></li>
<li class="toctree-l1"><a class="reference internal" href="Lib.Statement.html">Base library - Statement</a></li>
<li class="toctree-l1"><a class="reference internal" href="Lib.RiscV.html">Base library - RISC-V instructions</a></li>
<li class="toctree-l1"><a class="reference internal" href="Lib.Operands.html">Base library - Operands</a></li>
<li class="toctree-l1"><a class="reference internal" href="Lib.FunctionData.html">Base library - Function data</a></li>
<li class="toctree-l1"><a class="reference internal" href="Lib.Graphes.html">Base library - Graphs</a></li>
<li class="toctree-l1"><a class="reference internal" href="Lib.LinearCode.html">Linear intermediate representation</a></li>
<li class="toctree-l1"><a class="reference internal" href="Lib.Allocator.html">Temporary allocation</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Control Flow Graph - CFG and Basic blocks</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#Lib.CFG.Block"><code class="docutils literal notranslate"><span class="pre">Block</span></code></a><ul>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.to_dot"><code class="docutils literal notranslate"><span class="pre">Block.to_dot()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.get_body"><code class="docutils literal notranslate"><span class="pre">Block.get_body()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.get_all_statements"><code class="docutils literal notranslate"><span class="pre">Block.get_all_statements()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.get_body_and_terminator"><code class="docutils literal notranslate"><span class="pre">Block.get_body_and_terminator()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.get_label"><code class="docutils literal notranslate"><span class="pre">Block.get_label()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.get_in"><code class="docutils literal notranslate"><span class="pre">Block.get_in()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.get_terminator"><code class="docutils literal notranslate"><span class="pre">Block.get_terminator()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.set_terminator"><code class="docutils literal notranslate"><span class="pre">Block.set_terminator()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.get_phis"><code class="docutils literal notranslate"><span class="pre">Block.get_phis()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.add_phi"><code class="docutils literal notranslate"><span class="pre">Block.add_phi()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.set_phis"><code class="docutils literal notranslate"><span class="pre">Block.set_phis()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.remove_all_phis"><code class="docutils literal notranslate"><span class="pre">Block.remove_all_phis()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.iter_statements"><code class="docutils literal notranslate"><span class="pre">Block.iter_statements()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.Block.add_instruction"><code class="docutils literal notranslate"><span class="pre">Block.add_instruction()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#Lib.CFG.CFG"><code class="docutils literal notranslate"><span class="pre">CFG</span></code></a><ul>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.fdata"><code class="docutils literal notranslate"><span class="pre">CFG.fdata</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.get_start"><code class="docutils literal notranslate"><span class="pre">CFG.get_start()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.set_start"><code class="docutils literal notranslate"><span class="pre">CFG.set_start()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.get_end"><code class="docutils literal notranslate"><span class="pre">CFG.get_end()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.add_block"><code class="docutils literal notranslate"><span class="pre">CFG.add_block()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.get_block"><code class="docutils literal notranslate"><span class="pre">CFG.get_block()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.get_blocks"><code class="docutils literal notranslate"><span class="pre">CFG.get_blocks()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.get_entries"><code class="docutils literal notranslate"><span class="pre">CFG.get_entries()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.add_edge"><code class="docutils literal notranslate"><span class="pre">CFG.add_edge()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.remove_edge"><code class="docutils literal notranslate"><span class="pre">CFG.remove_edge()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.out_blocks"><code class="docutils literal notranslate"><span class="pre">CFG.out_blocks()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.gather_defs"><code class="docutils literal notranslate"><span class="pre">CFG.gather_defs()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.iter_statements"><code class="docutils literal notranslate"><span class="pre">CFG.iter_statements()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.linearize_naive"><code class="docutils literal notranslate"><span class="pre">CFG.linearize_naive()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.print_code"><code class="docutils literal notranslate"><span class="pre">CFG.print_code()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#Lib.CFG.CFG.print_dot"><code class="docutils literal notranslate"><span class="pre">CFG.print_dot()</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="Lib.Terminator.html">Control Flow Graph - Terminators</a></li>
<li class="toctree-l1"><a class="reference internal" href="Lib.Dominators.html">SSA form - Dominance frontier</a></li>
<li class="toctree-l1"><a class="reference internal" href="Lib.PhiNode.html">SSA form - Phi Nodes</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">MiniC</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Lib.CFG module</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/api/Lib.CFG.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="module-Lib.CFG">
<span id="lib-cfg-module"></span><h1>Lib.CFG module<a class="headerlink" href="#module-Lib.CFG" title="Permalink to this heading"></a></h1>
<p>Classes for a RiscV CFG: <a class="reference internal" href="#Lib.CFG.CFG" title="Lib.CFG.CFG"><code class="xref py py-class docutils literal notranslate"><span class="pre">CFG</span></code></a> for the CFG itself,
and <a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><code class="xref py py-class docutils literal notranslate"><span class="pre">Block</span></code></a> for its basic blocks.</p>
<dl class="py class">
<dt class="sig sig-object py" id="Lib.CFG.Block">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">Lib.CFG.</span></span><span class="sig-name descname"><span class="pre">Block</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Label" title="Lib.Statement.Label"><span class="pre">Label</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">insts</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Instru3A" title="Lib.Statement.Instru3A"><span class="pre">Instru3A</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Comment" title="Lib.Statement.Comment"><span class="pre">Comment</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">terminator</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="Lib.Terminator.html#Lib.Terminator.Return" title="Lib.Terminator.Return"><span class="pre">Return</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.AbsoluteJump" title="Lib.Statement.AbsoluteJump"><span class="pre">AbsoluteJump</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="Lib.Terminator.html#Lib.Terminator.BranchingTerminator" title="Lib.Terminator.BranchingTerminator"><span class="pre">BranchingTerminator</span></a></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/Lib/CFG.html#Block"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>A basic block of a <a class="reference internal" href="#Lib.CFG.CFG" title="Lib.CFG.CFG"><code class="xref py py-class docutils literal notranslate"><span class="pre">CFG</span></code></a> is made of three main parts:</p>
<ul class="simple">
<li><p>a start <a class="reference internal" href="Lib.Statement.html#Lib.Statement.Label" title="Lib.Statement.Label"><code class="xref py py-class docutils literal notranslate"><span class="pre">label</span></code></a> that uniquely identifies the block in the CFG</p></li>
<li><p>the main body of the block, a list of instructions
(excluding labels, jumps and branching instructions)</p></li>
<li><p>a <a class="reference internal" href="Lib.Terminator.html#Lib.Terminator.Terminator" title="Lib.Terminator.Terminator"><code class="xref py py-class docutils literal notranslate"><span class="pre">terminator</span></code></a>
that represents the final jump or branching instruction of the block,
and points to the successors of the block.
See the documentation for <a class="reference internal" href="Lib.Terminator.html#Lib.Terminator.Terminator" title="Lib.Terminator.Terminator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Lib.Terminator.Terminator</span></code></a> for further explanations.</p></li>
</ul>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.to_dot">
<span class="sig-name descname"><span class="pre">to_dot</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.to_dot"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.to_dot" title="Permalink to this definition"></a></dt>
<dd><p>Outputs all statements of the block as a string.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.get_body">
<span class="sig-name descname"><span class="pre">get_body</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Instru3A" title="Lib.Statement.Instru3A"><span class="pre">Instru3A</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Comment" title="Lib.Statement.Comment"><span class="pre">Comment</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.get_body"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.get_body" title="Permalink to this definition"></a></dt>
<dd><p>Return the statements in the body of the block (no phi-node nor the terminator).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.get_all_statements">
<span class="sig-name descname"><span class="pre">get_all_statements</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Statement" title="Lib.Statement.Statement"><span class="pre">Statement</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.get_all_statements"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.get_all_statements" title="Permalink to this definition"></a></dt>
<dd><p>Return all statements of the block
(including phi-nodes and the terminator, but not the label of the block).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.get_body_and_terminator">
<span class="sig-name descname"><span class="pre">get_body_and_terminator</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Statement" title="Lib.Statement.Statement"><span class="pre">Statement</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.get_body_and_terminator"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.get_body_and_terminator" title="Permalink to this definition"></a></dt>
<dd><p>Return all statements of the block, except phi-nodes
(and the label of the block).</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.get_label">
<span class="sig-name descname"><span class="pre">get_label</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Label" title="Lib.Statement.Label"><span class="pre">Label</span></a></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.get_label"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.get_label" title="Permalink to this definition"></a></dt>
<dd><p>Return the label of the block.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.get_in">
<span class="sig-name descname"><span class="pre">get_in</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><span class="pre">Block</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.get_in"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.get_in" title="Permalink to this definition"></a></dt>
<dd><p>Return the list of blocks with an edge to the considered block.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.get_terminator">
<span class="sig-name descname"><span class="pre">get_terminator</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="Lib.Terminator.html#Lib.Terminator.Return" title="Lib.Terminator.Return"><span class="pre">Return</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.AbsoluteJump" title="Lib.Statement.AbsoluteJump"><span class="pre">AbsoluteJump</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="Lib.Terminator.html#Lib.Terminator.BranchingTerminator" title="Lib.Terminator.BranchingTerminator"><span class="pre">BranchingTerminator</span></a></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.get_terminator"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.get_terminator" title="Permalink to this definition"></a></dt>
<dd><p>Return the terminator of the block.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.set_terminator">
<span class="sig-name descname"><span class="pre">set_terminator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">term</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="Lib.Terminator.html#Lib.Terminator.Return" title="Lib.Terminator.Return"><span class="pre">Return</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.AbsoluteJump" title="Lib.Statement.AbsoluteJump"><span class="pre">AbsoluteJump</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="Lib.Terminator.html#Lib.Terminator.BranchingTerminator" title="Lib.Terminator.BranchingTerminator"><span class="pre">BranchingTerminator</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.set_terminator"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.set_terminator" title="Permalink to this definition"></a></dt>
<dd><p>Set the terminator of the block.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.get_phis">
<span class="sig-name descname"><span class="pre">get_phis</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Statement" title="Lib.Statement.Statement"><span class="pre">Statement</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.get_phis"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.get_phis" title="Permalink to this definition"></a></dt>
<dd><p>Return the list of all φ instructions of the block.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.add_phi">
<span class="sig-name descname"><span class="pre">add_phi</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">phi</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Statement" title="Lib.Statement.Statement"><span class="pre">Statement</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.add_phi"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.add_phi" title="Permalink to this definition"></a></dt>
<dd><p>Add a φ instruction to the block.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.set_phis">
<span class="sig-name descname"><span class="pre">set_phis</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">phis</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Statement" title="Lib.Statement.Statement"><span class="pre">Statement</span></a><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.set_phis"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.set_phis" title="Permalink to this definition"></a></dt>
<dd><p>Replace the φ instructions in the block by the given list <cite>phis</cite>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.remove_all_phis">
<span class="sig-name descname"><span class="pre">remove_all_phis</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.remove_all_phis"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.remove_all_phis" title="Permalink to this definition"></a></dt>
<dd><p>Remove all φ instructions in the block.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.iter_statements">
<span class="sig-name descname"><span class="pre">iter_statements</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.iter_statements"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.iter_statements" title="Permalink to this definition"></a></dt>
<dd><p>Iterate over instructions.
For each real instruction i (not label or comment), replace it
with the list of instructions given by f(i).</p>
<p>Assume there is no phi-node.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.Block.add_instruction">
<span class="sig-name descname"><span class="pre">add_instruction</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">instr</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Instru3A" title="Lib.Statement.Instru3A"><span class="pre">Instru3A</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Comment" title="Lib.Statement.Comment"><span class="pre">Comment</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#Block.add_instruction"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.Block.add_instruction" title="Permalink to this definition"></a></dt>
<dd><p>Add an instruction to the body of the block.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="Lib.CFG.CFG">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">Lib.CFG.</span></span><span class="sig-name descname"><span class="pre">CFG</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fdata</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="Lib.FunctionData.html#Lib.FunctionData.FunctionData" title="Lib.FunctionData.FunctionData"><span class="pre">FunctionData</span></a></span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>A complete control-flow graph representing a function.
This class is mainly made of a list of basic <a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><code class="xref py py-class docutils literal notranslate"><span class="pre">Block</span></code></a>,
a label indicating the <a class="reference internal" href="#Lib.CFG.CFG.get_start" title="Lib.CFG.CFG.get_start"><code class="xref py py-meth docutils literal notranslate"><span class="pre">entry</span> <span class="pre">point</span> <span class="pre">of</span> <span class="pre">the</span> <span class="pre">function</span></code></a>,
and an <a class="reference internal" href="#Lib.CFG.CFG.get_end" title="Lib.CFG.CFG.get_end"><code class="xref py py-meth docutils literal notranslate"><span class="pre">exit</span> <span class="pre">label</span></code></a>.</p>
<p>As with linear code, metadata about the function can be found
in the <a class="reference internal" href="#Lib.CFG.CFG.fdata" title="Lib.CFG.CFG.fdata"><code class="xref py py-attr docutils literal notranslate"><span class="pre">fdata</span></code></a> member variable.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="Lib.CFG.CFG.fdata">
<span class="sig-name descname"><span class="pre">fdata</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference internal" href="Lib.FunctionData.html#Lib.FunctionData.FunctionData" title="Lib.FunctionData.FunctionData"><span class="pre">FunctionData</span></a></em><a class="headerlink" href="#Lib.CFG.CFG.fdata" title="Permalink to this definition"></a></dt>
<dd><p>Metadata about the function represented by this CFG</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.get_start">
<span class="sig-name descname"><span class="pre">get_start</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Label" title="Lib.Statement.Label"><span class="pre">Label</span></a></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.get_start"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.get_start" title="Permalink to this definition"></a></dt>
<dd><p>Return the entry label of the CFG.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.set_start">
<span class="sig-name descname"><span class="pre">set_start</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">start</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Label" title="Lib.Statement.Label"><span class="pre">Label</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.set_start"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.set_start" title="Permalink to this definition"></a></dt>
<dd><p>Set the entry label of the CFG.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.get_end">
<span class="sig-name descname"><span class="pre">get_end</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Label" title="Lib.Statement.Label"><span class="pre">Label</span></a></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.get_end"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.get_end" title="Permalink to this definition"></a></dt>
<dd><p>Return the exit label of the CFG.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.add_block">
<span class="sig-name descname"><span class="pre">add_block</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">blk</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><span class="pre">Block</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.add_block"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.add_block" title="Permalink to this definition"></a></dt>
<dd><p>Add a new block to the CFG.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.get_block">
<span class="sig-name descname"><span class="pre">get_block</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Label" title="Lib.Statement.Label"><span class="pre">Label</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><span class="pre">Block</span></a></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.get_block"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.get_block" title="Permalink to this definition"></a></dt>
<dd><p>Return the block with label <cite>name</cite>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.get_blocks">
<span class="sig-name descname"><span class="pre">get_blocks</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><span class="pre">Block</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.get_blocks"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.get_blocks" title="Permalink to this definition"></a></dt>
<dd><p>Return all the blocks.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.get_entries">
<span class="sig-name descname"><span class="pre">get_entries</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><span class="pre">Block</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.get_entries"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.get_entries" title="Permalink to this definition"></a></dt>
<dd><p>Return all the blocks with no predecessors.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.add_edge">
<span class="sig-name descname"><span class="pre">add_edge</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">src</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><span class="pre">Block</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">dest</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><span class="pre">Block</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.add_edge"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.add_edge" title="Permalink to this definition"></a></dt>
<dd><p>Add the edge src -&gt; dest in the control flow graph.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.remove_edge">
<span class="sig-name descname"><span class="pre">remove_edge</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">src</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><span class="pre">Block</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">dest</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><span class="pre">Block</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.remove_edge"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.remove_edge" title="Permalink to this definition"></a></dt>
<dd><p>Remove the edge src -&gt; dest in the control flow graph.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.out_blocks">
<span class="sig-name descname"><span class="pre">out_blocks</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">block</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><span class="pre">Block</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><span class="pre">Block</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.out_blocks"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.out_blocks" title="Permalink to this definition"></a></dt>
<dd><p>Return the list of blocks in the CFG targeted by
the Terminator of Block block.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.gather_defs">
<span class="sig-name descname"><span class="pre">gather_defs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Set</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#Lib.CFG.Block" title="Lib.CFG.Block"><span class="pre">Block</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.gather_defs"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.gather_defs" title="Permalink to this definition"></a></dt>
<dd><p>Return a dictionary associating variables to all the blocks
containing one of their definitions.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.iter_statements">
<span class="sig-name descname"><span class="pre">iter_statements</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.iter_statements"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.iter_statements" title="Permalink to this definition"></a></dt>
<dd><p>Apply f to all instructions in all the blocks.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.linearize_naive">
<span class="sig-name descname"><span class="pre">linearize_naive</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Iterator</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="Lib.Statement.html#Lib.Statement.Statement" title="Lib.Statement.Statement"><span class="pre">Statement</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.linearize_naive"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.linearize_naive" title="Permalink to this definition"></a></dt>
<dd><p>Linearize the given control flow graph as a list of instructions.
Naive procedure that adds jumps everywhere.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.print_code">
<span class="sig-name descname"><span class="pre">print_code</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">output</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">linearize=&lt;function</span> <span class="pre">CFG.&lt;lambda&gt;&gt;</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">comment=None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.print_code"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.print_code" title="Permalink to this definition"></a></dt>
<dd><p>Print the linearization of the CFG.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Lib.CFG.CFG.print_dot">
<span class="sig-name descname"><span class="pre">print_dot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">DF</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">view</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="../_modules/Lib/CFG.html#CFG.print_dot"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#Lib.CFG.CFG.print_dot" title="Permalink to this definition"></a></dt>
<dd><p>Print the CFG as a graph.</p>
</dd></dl>
</dd></dl>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="Lib.Allocator.html" class="btn btn-neutral float-left" title="Lib.Allocator module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="Lib.Terminator.html" class="btn btn-neutral float-right" title="Lib.Terminator module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2023, compil-lyon.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>