mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-03 14:31:10 +00:00
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
This commit is contained in:
parent
d7d6af9bef
commit
c88c17b0f6
@ -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>
|
href="#i_ret">ret</a> int 1<br>IfUnequal:<br> <a href="#i_ret">ret</a> int 0<br></pre>
|
||||||
</div>
|
</div>
|
||||||
<!-- _______________________________________________________________________ -->
|
<!-- _______________________________________________________________________ -->
|
||||||
<div class="doc_subsubsection"> <a name="i_switch">'<tt>switch</tt>'
|
<div class="doc_subsubsection">
|
||||||
Instruction</a> </div>
|
<a name="i_switch">'<tt>switch</tt>' Instruction</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="doc_text">
|
<div class="doc_text">
|
||||||
<h5>Syntax:</h5>
|
<h5>Syntax:</h5>
|
||||||
<pre> switch uint <value>, label <defaultdest> [ int <val>, label <dest>, ... ]<br></pre>
|
|
||||||
|
<pre>
|
||||||
|
switch <intty> <value>, label <defaultdest> [ <intty> <val>, label <dest> ... ]
|
||||||
|
</pre>
|
||||||
|
|
||||||
<h5>Overview:</h5>
|
<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
|
instruction, allowing a branch to occur to one of many possible
|
||||||
destinations.</p>
|
destinations.</p>
|
||||||
|
|
||||||
|
|
||||||
<h5>Arguments:</h5>
|
<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>'
|
<p>The '<tt>switch</tt>' instruction uses three parameters: an integer
|
||||||
destination, and an array of pairs of comparison value constants and '<tt>label</tt>'s.</p>
|
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>
|
<h5>Semantics:</h5>
|
||||||
|
|
||||||
<p>The <tt>switch</tt> instruction specifies a table of values and
|
<p>The <tt>switch</tt> instruction specifies a table of values and
|
||||||
destinations. When the '<tt>switch</tt>' instruction is executed, this
|
destinations. When the '<tt>switch</tt>' instruction is executed, this
|
||||||
table is searched for the given value. If the value is found, the
|
table is searched for the given value. If the value is found, the
|
||||||
corresponding destination is branched to, otherwise the default value
|
corresponding destination is branched to, otherwise the default value
|
||||||
it transfered to.</p>
|
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>
|
|
||||||
<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>
|
<h5>Implementation:</h5>
|
||||||
switch uint %val, label %otherwise [ int 0, label %onzero,
|
|
||||||
int 1, label %onone,
|
<p>Depending on properties of the target machine and the particular
|
||||||
int 2, label %ontwo ]
|
<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 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>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<!-- _______________________________________________________________________ -->
|
<!-- _______________________________________________________________________ -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user