llvmpy/docs/_build/html/doc/llvm.core.Instruction.html

368 lines
No EOL
22 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>llvm.core.Instruction &mdash; llvmpy 0.8.2 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="top" title="llvmpy 0.8.2 documentation" href="../index.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li><a href="../index.html">llvmpy 0.8.2 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<table border="1" class="docutils">
<colgroup>
<col width="100%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td>layout: page</td>
</tr>
<tr class="row-even"><td>title: Instruction (llvm.core)</td>
</tr>
</tbody>
</table>
<p>An <tt class="docutils literal"><span class="pre">llvm.core.Instruction</span></tt> object represents an LLVM instruction. This
class is the root of a small hierarchy:</p>
<div class="highlight-python"><pre>Instruction
CallOrInvokeInstruction
PHINode
SwitchInstruction
CompareInstruction</pre>
</div>
<p>Instructions are not created directly, but via a builder. The builder
both creates instructions and adds them to a basic block at the same
time. One way of getting instruction objects are from basic blocks.</p>
<p>Being derived from <a class="reference external" href="llvm.core.User.html">llvm.core.User</a>, the
instruction is-a user, i.e., an instruction in turn uses other values.
The values an instruction uses are its operands. These may be accessed
using <tt class="docutils literal"><span class="pre">operands</span></tt> property from the
<a class="reference external" href="llvm.core.User.html">llvm.core.User</a> base.</p>
<p>The name of the instruction (like <tt class="docutils literal"><span class="pre">add</span></tt>, <tt class="docutils literal"><span class="pre">mul</span></tt> etc) can be got via
the <tt class="docutils literal"><span class="pre">opcode_name</span></tt> property. The <tt class="docutils literal"><span class="pre">basic_block</span></tt> property gives the
basic block to which the instruction belongs to. Note that llvmpy does
not allow free-standing instruction objects (i.e., all instructions are
created contained within a basic block).</p>
<p>Classes of instructions can be got via the properties <tt class="docutils literal"><span class="pre">is_terminator</span></tt>,
<tt class="docutils literal"><span class="pre">is_binary_op</span></tt>, <tt class="docutils literal"><span class="pre">is_shift</span></tt> etc. See below for the full list.</p>
<ul class="simple">
<li>This will become a table of contents (this text will be scraped).
{:toc}</li>
</ul>
<div class="section" id="llvm-core-instruction">
<h1>llvm.core.Instruction<a class="headerlink" href="#llvm-core-instruction" title="Permalink to this headline"></a></h1>
<div class="section" id="base-class">
<h2>Base Class<a class="headerlink" href="#base-class" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><a class="reference external" href="llvm.core.User.html">llvm.core.User</a></li>
</ul>
</div>
<div class="section" id="properties">
<h2>Properties<a class="headerlink" href="#properties" title="Permalink to this headline"></a></h2>
<div class="section" id="basic-block">
<h3><tt class="docutils literal"><span class="pre">basic_block</span></tt><a class="headerlink" href="#basic-block" title="Permalink to this headline"></a></h3>
<p>[read-only] The basic block to which this instruction belongs to.</p>
</div>
<div class="section" id="is-terminator">
<h3><tt class="docutils literal"><span class="pre">is_terminator</span></tt><a class="headerlink" href="#is-terminator" title="Permalink to this headline"></a></h3>
<p>[read-only] True if the instruction is a terminator instruction.</p>
</div>
<div class="section" id="is-binary-op">
<h3><tt class="docutils literal"><span class="pre">is_binary_op</span></tt><a class="headerlink" href="#is-binary-op" title="Permalink to this headline"></a></h3>
<p>[read-only] True if the instruction is a binary operator.</p>
</div>
<div class="section" id="is-shift">
<h3><tt class="docutils literal"><span class="pre">is_shift</span></tt><a class="headerlink" href="#is-shift" title="Permalink to this headline"></a></h3>
<p>[read-only] True if the instruction is a shift instruction.</p>
</div>
<div class="section" id="is-cast">
<h3><tt class="docutils literal"><span class="pre">is_cast</span></tt><a class="headerlink" href="#is-cast" title="Permalink to this headline"></a></h3>
<p>[read-only] True if the instruction is a cast instruction.</p>
</div>
<div class="section" id="is-logical-shift">
<h3><tt class="docutils literal"><span class="pre">is_logical_shift</span></tt><a class="headerlink" href="#is-logical-shift" title="Permalink to this headline"></a></h3>
<p>[read-only] True if the instruction is a logical shift instruction.</p>
</div>
<div class="section" id="is-arithmetic-shift">
<h3><tt class="docutils literal"><span class="pre">is_arithmetic_shift</span></tt><a class="headerlink" href="#is-arithmetic-shift" title="Permalink to this headline"></a></h3>
<p>[read-only] True if the instruction is an arithmetic shift instruction.</p>
</div>
<div class="section" id="is-associative">
<h3><tt class="docutils literal"><span class="pre">is_associative</span></tt><a class="headerlink" href="#is-associative" title="Permalink to this headline"></a></h3>
<p>[read-only] True if the instruction is associative.</p>
</div>
<div class="section" id="is-commutative">
<h3><tt class="docutils literal"><span class="pre">is_commutative</span></tt><a class="headerlink" href="#is-commutative" title="Permalink to this headline"></a></h3>
<p>[read-only] True if the instruction is commutative.</p>
</div>
<div class="section" id="is-volatile">
<h3><tt class="docutils literal"><span class="pre">is_volatile</span></tt><a class="headerlink" href="#is-volatile" title="Permalink to this headline"></a></h3>
<p>[read-only] True if the instruction is a volatile load or store.</p>
</div>
<div class="section" id="opcode">
<h3><tt class="docutils literal"><span class="pre">opcode</span></tt><a class="headerlink" href="#opcode" title="Permalink to this headline"></a></h3>
<p>[read-only] The numeric opcode value of the instruction. Do not rely on
the absolute value of this number, it may change with LLVM version.</p>
</div>
<div class="section" id="opcode-name">
<h3><tt class="docutils literal"><span class="pre">opcode_name</span></tt><a class="headerlink" href="#opcode-name" title="Permalink to this headline"></a></h3>
<p>[read-only] The name of the instruction, like <tt class="docutils literal"><span class="pre">add</span></tt>, <tt class="docutils literal"><span class="pre">sub</span></tt> etc.</p>
</div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="llvm-core-callorinvokeinstruction">
<h1>llvm.core.CallOrInvokeInstruction<a class="headerlink" href="#llvm-core-callorinvokeinstruction" title="Permalink to this headline"></a></h1>
<p>The <tt class="docutils literal"><span class="pre">llvm.core.CallOrInvokeInstruction</span></tt> is a subclass of
<tt class="docutils literal"><span class="pre">llvm.core.Instruction</span></tt>, and represents either a <tt class="docutils literal"><span class="pre">call</span></tt> or an
<tt class="docutils literal"><span class="pre">invoke</span></tt> instruction.</p>
<div class="section" id="id3">
<h2>Base Class<a class="headerlink" href="#id3" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">llvm.core.Instruction</span></tt></li>
</ul>
</div>
<div class="section" id="id4">
<h2>Properties<a class="headerlink" href="#id4" title="Permalink to this headline"></a></h2>
<p><tt class="docutils literal"><span class="pre">calling_convention</span></tt> Get or set the calling convention. See
<a class="reference external" href="functions.html#callconv">here</a> for possible values.</p>
</div>
<div class="section" id="methods">
<h2>Methods<a class="headerlink" href="#methods" title="Permalink to this headline"></a></h2>
<div class="section" id="add-parameter-attribute-idx-attr">
<h3><tt class="docutils literal"><span class="pre">add_parameter_attribute(idx,</span> <span class="pre">attr)</span></tt><a class="headerlink" href="#add-parameter-attribute-idx-attr" title="Permalink to this headline"></a></h3>
<p>Add an attribute <tt class="docutils literal"><span class="pre">attr</span></tt> to the <tt class="docutils literal"><span class="pre">idx</span></tt>-th argument. See
<a class="reference external" href="llvm.core.Argument.html">here</a> for possible values of <tt class="docutils literal"><span class="pre">attr</span></tt>.</p>
</div>
<div class="section" id="remove-parameter-attribute-idx-attr">
<h3><tt class="docutils literal"><span class="pre">remove_parameter_attribute(idx,</span> <span class="pre">attr)</span></tt><a class="headerlink" href="#remove-parameter-attribute-idx-attr" title="Permalink to this headline"></a></h3>
<p>Remove an attribute <tt class="docutils literal"><span class="pre">attr</span></tt> from the <tt class="docutils literal"><span class="pre">idx</span></tt>-th argument. See
<a class="reference external" href="llvm.core.Argument.html">here</a> for possible values of <tt class="docutils literal"><span class="pre">attr</span></tt>.</p>
</div>
<div class="section" id="set-parameter-alignment-idx-align">
<h3><tt class="docutils literal"><span class="pre">set_parameter_alignment(idx,</span> <span class="pre">align)</span></tt><a class="headerlink" href="#set-parameter-alignment-idx-align" title="Permalink to this headline"></a></h3>
<p>Set the alignment of the <tt class="docutils literal"><span class="pre">idx</span></tt>-th argument to <tt class="docutils literal"><span class="pre">align</span></tt>. <tt class="docutils literal"><span class="pre">align</span></tt>
should be a power of two.</p>
</div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="llvm-core-phinode">
<h1>llvm.core.PHINode<a class="headerlink" href="#llvm-core-phinode" title="Permalink to this headline"></a></h1>
<p>The <tt class="docutils literal"><span class="pre">llvm.core.PHINode</span></tt> is a subclass of <tt class="docutils literal"><span class="pre">llvm.core.Instruction</span></tt>,
and represents the <tt class="docutils literal"><span class="pre">phi</span></tt> instruction. When created (using
<tt class="docutils literal"><span class="pre">Builder.phi</span></tt>) the phi node contains no incoming blocks (nor their
corresponding values). To add an incoming arc to the phi node, use the
<tt class="docutils literal"><span class="pre">add_incoming</span></tt> method, which takes a source block
(<a class="reference external" href="llvm.core.BasicBlock.html">llvm.core.BasicBlock</a> object) and a value
(object of <a class="reference external" href="llvm.core.Value.html">llvm.core.Value</a> or of a class
derived from it) that the phi node will take on if control branches in
from that block.</p>
<div class="section" id="id7">
<h2>Base Class<a class="headerlink" href="#id7" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">llvm.core.Instruction</span></tt></li>
</ul>
</div>
<div class="section" id="id8">
<h2>Properties<a class="headerlink" href="#id8" title="Permalink to this headline"></a></h2>
<p><tt class="docutils literal"><span class="pre">incoming_count</span></tt> [read-only] The number of incoming arcs for this phi
node.</p>
</div>
<div class="section" id="id9">
<h2>Methods<a class="headerlink" href="#id9" title="Permalink to this headline"></a></h2>
<div class="section" id="add-incoming-value-block">
<h3><tt class="docutils literal"><span class="pre">add_incoming(value,</span> <span class="pre">block)</span></tt><a class="headerlink" href="#add-incoming-value-block" title="Permalink to this headline"></a></h3>
<p>Add an incoming arc, from the
<a class="reference external" href="llvm.core.BasicBlock.html">llvm.core.BasicBlock</a> object <tt class="docutils literal"><span class="pre">block</span></tt>,
with the corresponding value <tt class="docutils literal"><span class="pre">value</span></tt>. <tt class="docutils literal"><span class="pre">value</span></tt> should be an object of
<a class="reference external" href="llvm.core.Value.html">llvm.core.Value</a> (or of a descendent class).</p>
</div>
<div class="section" id="get-incoming-value-idx">
<h3><tt class="docutils literal"><span class="pre">get_incoming_value(idx)</span></tt><a class="headerlink" href="#get-incoming-value-idx" title="Permalink to this headline"></a></h3>
<p>Returns the <tt class="docutils literal"><span class="pre">idx</span></tt>-th incoming arc&#8217;s value.</p>
</div>
<div class="section" id="get-incoming-block-idx">
<h3><tt class="docutils literal"><span class="pre">get_incoming_block(idx)</span></tt><a class="headerlink" href="#get-incoming-block-idx" title="Permalink to this headline"></a></h3>
<p>Returns the <tt class="docutils literal"><span class="pre">idx</span></tt>-th incoming arc&#8217;s block.</p>
</div>
</div>
</div>
<div class="section" id="llvm-core-switchinstruction-switchinstr">
<h1>llvm.core.SwitchInstruction # {#switchinstr}<a class="headerlink" href="#llvm-core-switchinstruction-switchinstr" title="Permalink to this headline"></a></h1>
<p>(TODO describe)</p>
<div class="section" id="id12">
<h2>Base Class<a class="headerlink" href="#id12" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">llvm.core.Instruction</span></tt></li>
</ul>
</div>
<div class="section" id="id13">
<h2>Methods<a class="headerlink" href="#id13" title="Permalink to this headline"></a></h2>
<div class="section" id="add-case-const-block">
<h3><tt class="docutils literal"><span class="pre">add_case(const,</span> <span class="pre">block)</span></tt><a class="headerlink" href="#add-case-const-block" title="Permalink to this headline"></a></h3>
<p>Add another case to the switch statement. When the expression being
evaluated equals <tt class="docutils literal"><span class="pre">const</span></tt>, then control branches to <tt class="docutils literal"><span class="pre">block</span></tt>. Here
<tt class="docutils literal"><span class="pre">const</span></tt> must be of type
<a class="reference external" href="llvm.core.Constant.html">llvm.core.ConstantInt</a>.</p>
</div>
</div>
</div>
<hr class="docutils" />
<div class="section" id="llvm-core-compareinstruction">
<h1>llvm.core.CompareInstruction<a class="headerlink" href="#llvm-core-compareinstruction" title="Permalink to this headline"></a></h1>
<p>(TODO describe)</p>
<div class="section" id="id14">
<h2>Base Class<a class="headerlink" href="#id14" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">llvm.core.Instruction</span></tt></li>
</ul>
</div>
<div class="section" id="id15">
<h2>Properties<a class="headerlink" href="#id15" title="Permalink to this headline"></a></h2>
<div class="section" id="predicate">
<h3><tt class="docutils literal"><span class="pre">predicate</span></tt><a class="headerlink" href="#predicate" title="Permalink to this headline"></a></h3>
<p>[read-only]</p>
<p>The predicate of the compare instruction, one of the <tt class="docutils literal"><span class="pre">ICMP_*</span></tt> or
<tt class="docutils literal"><span class="pre">FCMP_*</span></tt> constants.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">llvm.core.Instruction</a><ul>
<li><a class="reference internal" href="#base-class">Base Class</a></li>
<li><a class="reference internal" href="#properties">Properties</a><ul>
<li><a class="reference internal" href="#basic-block"><tt class="docutils literal"><span class="pre">basic_block</span></tt></a></li>
<li><a class="reference internal" href="#is-terminator"><tt class="docutils literal"><span class="pre">is_terminator</span></tt></a></li>
<li><a class="reference internal" href="#is-binary-op"><tt class="docutils literal"><span class="pre">is_binary_op</span></tt></a></li>
<li><a class="reference internal" href="#is-shift"><tt class="docutils literal"><span class="pre">is_shift</span></tt></a></li>
<li><a class="reference internal" href="#is-cast"><tt class="docutils literal"><span class="pre">is_cast</span></tt></a></li>
<li><a class="reference internal" href="#is-logical-shift"><tt class="docutils literal"><span class="pre">is_logical_shift</span></tt></a></li>
<li><a class="reference internal" href="#is-arithmetic-shift"><tt class="docutils literal"><span class="pre">is_arithmetic_shift</span></tt></a></li>
<li><a class="reference internal" href="#is-associative"><tt class="docutils literal"><span class="pre">is_associative</span></tt></a></li>
<li><a class="reference internal" href="#is-commutative"><tt class="docutils literal"><span class="pre">is_commutative</span></tt></a></li>
<li><a class="reference internal" href="#is-volatile"><tt class="docutils literal"><span class="pre">is_volatile</span></tt></a></li>
<li><a class="reference internal" href="#opcode"><tt class="docutils literal"><span class="pre">opcode</span></tt></a></li>
<li><a class="reference internal" href="#opcode-name"><tt class="docutils literal"><span class="pre">opcode_name</span></tt></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#llvm-core-callorinvokeinstruction">llvm.core.CallOrInvokeInstruction</a><ul>
<li><a class="reference internal" href="#id3">Base Class</a></li>
<li><a class="reference internal" href="#id4">Properties</a></li>
<li><a class="reference internal" href="#methods">Methods</a><ul>
<li><a class="reference internal" href="#add-parameter-attribute-idx-attr"><tt class="docutils literal"><span class="pre">add_parameter_attribute(idx,</span> <span class="pre">attr)</span></tt></a></li>
<li><a class="reference internal" href="#remove-parameter-attribute-idx-attr"><tt class="docutils literal"><span class="pre">remove_parameter_attribute(idx,</span> <span class="pre">attr)</span></tt></a></li>
<li><a class="reference internal" href="#set-parameter-alignment-idx-align"><tt class="docutils literal"><span class="pre">set_parameter_alignment(idx,</span> <span class="pre">align)</span></tt></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#llvm-core-phinode">llvm.core.PHINode</a><ul>
<li><a class="reference internal" href="#id7">Base Class</a></li>
<li><a class="reference internal" href="#id8">Properties</a></li>
<li><a class="reference internal" href="#id9">Methods</a><ul>
<li><a class="reference internal" href="#add-incoming-value-block"><tt class="docutils literal"><span class="pre">add_incoming(value,</span> <span class="pre">block)</span></tt></a></li>
<li><a class="reference internal" href="#get-incoming-value-idx"><tt class="docutils literal"><span class="pre">get_incoming_value(idx)</span></tt></a></li>
<li><a class="reference internal" href="#get-incoming-block-idx"><tt class="docutils literal"><span class="pre">get_incoming_block(idx)</span></tt></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#llvm-core-switchinstruction-switchinstr">llvm.core.SwitchInstruction # {#switchinstr}</a><ul>
<li><a class="reference internal" href="#id12">Base Class</a></li>
<li><a class="reference internal" href="#id13">Methods</a><ul>
<li><a class="reference internal" href="#add-case-const-block"><tt class="docutils literal"><span class="pre">add_case(const,</span> <span class="pre">block)</span></tt></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#llvm-core-compareinstruction">llvm.core.CompareInstruction</a><ul>
<li><a class="reference internal" href="#id14">Base Class</a></li>
<li><a class="reference internal" href="#id15">Properties</a><ul>
<li><a class="reference internal" href="#predicate"><tt class="docutils literal"><span class="pre">predicate</span></tt></a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/doc/llvm.core.Instruction.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li><a href="../index.html">llvmpy 0.8.2 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2012, Mahadevan R (2008-2010), Continuum Analytics (2012).
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
</div>
</body>
</html>