aboutsummaryrefslogtreecommitdiffstats
path: root/docs/LangRef.html
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-24 04:54:45 +0000
committerChris Lattner <sabre@nondot.org>2004-02-24 04:54:45 +0000
commitc88c17b0f689443be31499d7bfb147651e5ac9a6 (patch)
treefd46f6ecfed34d5259f5819bbecbfa8010104418 /docs/LangRef.html
parentd7d6af9befaf436c2a4584b742ea18dfaba4f1e7 (diff)
downloadexternal_llvm-c88c17b0f689443be31499d7bfb147651e5ac9a6.zip
external_llvm-c88c17b0f689443be31499d7bfb147651e5ac9a6.tar.gz
external_llvm-c88c17b0f689443be31499d7bfb147651e5ac9a6.tar.bz2
Wow, the description of the 'switch' instruction was out of date.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11790 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/LangRef.html')
-rw-r--r--docs/LangRef.html61
1 files changed, 41 insertions, 20 deletions
diff --git a/docs/LangRef.html b/docs/LangRef.html
index a3a0285..7b8c6c7 100644
--- a/docs/LangRef.html
+++ b/docs/LangRef.html
@@ -748,40 +748,61 @@ control flows to the '<tt>iffalse</tt>' <tt>label</tt> argument.</p>
href="#i_ret">ret</a> int 1<br>IfUnequal:<br> <a href="#i_ret">ret</a> int 0<br></pre>
</div>
<!-- _______________________________________________________________________ -->
-<div class="doc_subsubsection"> <a name="i_switch">'<tt>switch</tt>'
-Instruction</a> </div>
+<div class="doc_subsubsection">
+ <a name="i_switch">'<tt>switch</tt>' Instruction</a>
+</div>
+
<div class="doc_text">
<h5>Syntax:</h5>
-<pre> switch uint &lt;value&gt;, label &lt;defaultdest&gt; [ int &lt;val&gt;, label &lt;dest&gt;, ... ]<br></pre>
+
+<pre>
+ switch &lt;intty&gt; &lt;value&gt;, label &lt;defaultdest&gt; [ &lt;intty&gt; &lt;val&gt;, label &lt;dest&gt; ... ]
+</pre>
+
<h5>Overview:</h5>
-<p>The '<tt>switch</tt>' instruction is used to transfer control flow
-to one of several different places. It is a generalization of the '<tt>br</tt>'
+
+<p>The '<tt>switch</tt>' instruction is used to transfer control flow to one of
+several different places. It is a generalization of the '<tt>br</tt>'
instruction, allowing a branch to occur to one of many possible
destinations.</p>
+
+
<h5>Arguments:</h5>
-<p>The '<tt>switch</tt>' instruction uses three parameters: a '<tt>uint</tt>'
-comparison value '<tt>value</tt>', a default '<tt>label</tt>'
-destination, and an array of pairs of comparison value constants and '<tt>label</tt>'s.</p>
+
+<p>The '<tt>switch</tt>' instruction uses three parameters: an integer
+comparison value '<tt>value</tt>', a default '<tt>label</tt>' destination, and
+an array of pairs of comparison value constants and '<tt>label</tt>'s. The
+table is not allowed to contain duplicate constant entries.</p>
+
<h5>Semantics:</h5>
+
<p>The <tt>switch</tt> instruction specifies a table of values and
destinations. When the '<tt>switch</tt>' instruction is executed, this
table is searched for the given value. If the value is found, the
corresponding destination is branched to, otherwise the default value
it transfered to.</p>
+
<h5>Implementation:</h5>
-<p>Depending on properties of the target machine and the particular <tt>switch</tt>
-instruction, this instruction may be code generated as a series of
-chained conditional branches, or with a lookup table.</p>
+
+<p>Depending on properties of the target machine and the particular
+<tt>switch</tt> instruction, this instruction may be code generated in different
+ways, for example as a series of chained conditional branches, or with a lookup
+table.</p>
+
<h5>Example:</h5>
-<pre> <i>; Emulate a conditional br instruction</i>
- %Val = <a
- href="#i_cast">cast</a> bool %value to uint<br> switch uint %Val, label %truedest [int 0, label %falsedest ]<br><br> <i>; Emulate an unconditional br instruction</i>
- switch uint 0, label %dest [ ]
-
- <i>; Implement a jump table:</i>
- switch uint %val, label %otherwise [ int 0, label %onzero,
- int 1, label %onone,
- int 2, label %ontwo ]
+
+<pre>
+ <i>; Emulate a conditional br instruction</i>
+ %Val = <a href="#i_cast">cast</a> bool %value to int
+ switch int %Val, label %truedest [int 0, label %falsedest ]
+
+ <i>; Emulate an unconditional br instruction</i>
+ switch uint 0, label %dest [ ]
+
+ <i>; Implement a jump table:</i>
+ switch uint %val, label %otherwise [ uint 0, label %onzero
+ uint 1, label %onone
+ uint 2, label %ontwo ]
</pre>
</div>
<!-- _______________________________________________________________________ -->