Clarify that shifts that are too large are undefined.

llvm-svn: 42588
This commit is contained in:
Chris Lattner 2007-10-03 21:01:14 +00:00
parent 4810c3a1d6
commit f0e5011d21
1 changed files with 19 additions and 3 deletions

View File

@ -2168,18 +2168,28 @@ Instruction</a> </div>
<h5>Syntax:</h5> <h5>Syntax:</h5>
<pre> &lt;result&gt; = shl &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i> <pre> &lt;result&gt; = shl &lt;ty&gt; &lt;var1&gt;, &lt;var2&gt; <i>; yields {ty}:result</i>
</pre> </pre>
<h5>Overview:</h5> <h5>Overview:</h5>
<p>The '<tt>shl</tt>' instruction returns the first operand shifted to <p>The '<tt>shl</tt>' instruction returns the first operand shifted to
the left a specified number of bits.</p> the left a specified number of bits.</p>
<h5>Arguments:</h5> <h5>Arguments:</h5>
<p>Both arguments to the '<tt>shl</tt>' instruction must be the same <a <p>Both arguments to the '<tt>shl</tt>' instruction must be the same <a
href="#t_integer">integer</a> type.</p> href="#t_integer">integer</a> type.</p>
<h5>Semantics:</h5> <h5>Semantics:</h5>
<p>The value produced is <tt>var1</tt> * 2<sup><tt>var2</tt></sup>.</p>
<p>The value produced is <tt>var1</tt> * 2<sup><tt>var2</tt></sup>. If
<tt>var2</tt> is (statically or dynamically) equal to or larger than the number
of bits in <tt>var1</tt>, the result is undefined.</p>
<h5>Example:</h5><pre> <h5>Example:</h5><pre>
&lt;result&gt; = shl i32 4, %var <i>; yields {i32}: 4 &lt;&lt; %var</i> &lt;result&gt; = shl i32 4, %var <i>; yields {i32}: 4 &lt;&lt; %var</i>
&lt;result&gt; = shl i32 4, 2 <i>; yields {i32}: 16</i> &lt;result&gt; = shl i32 4, 2 <i>; yields {i32}: 16</i>
&lt;result&gt; = shl i32 1, 10 <i>; yields {i32}: 1024</i> &lt;result&gt; = shl i32 1, 10 <i>; yields {i32}: 1024</i>
&lt;result&gt; = shl i32 1, 32 <i>; undefined</i>
</pre> </pre>
</div> </div>
<!-- _______________________________________________________________________ --> <!-- _______________________________________________________________________ -->
@ -2199,9 +2209,11 @@ operand shifted to the right a specified number of bits with zero fill.</p>
<a href="#t_integer">integer</a> type.</p> <a href="#t_integer">integer</a> type.</p>
<h5>Semantics:</h5> <h5>Semantics:</h5>
<p>This instruction always performs a logical shift right operation. The most <p>This instruction always performs a logical shift right operation. The most
significant bits of the result will be filled with zero bits after the significant bits of the result will be filled with zero bits after the
shift.</p> shift. If <tt>var2</tt> is (statically or dynamically) equal to or larger than
the number of bits in <tt>var1</tt>, the result is undefined.</p>
<h5>Example:</h5> <h5>Example:</h5>
<pre> <pre>
@ -2209,6 +2221,7 @@ shift.</p>
&lt;result&gt; = lshr i32 4, 2 <i>; yields {i32}:result = 1</i> &lt;result&gt; = lshr i32 4, 2 <i>; yields {i32}:result = 1</i>
&lt;result&gt; = lshr i8 4, 3 <i>; yields {i8}:result = 0</i> &lt;result&gt; = lshr i8 4, 3 <i>; yields {i8}:result = 0</i>
&lt;result&gt; = lshr i8 -2, 1 <i>; yields {i8}:result = 0x7FFFFFFF </i> &lt;result&gt; = lshr i8 -2, 1 <i>; yields {i8}:result = 0x7FFFFFFF </i>
&lt;result&gt; = lshr i32 1, 32 <i>; undefined</i>
</pre> </pre>
</div> </div>
@ -2232,7 +2245,9 @@ operand shifted to the right a specified number of bits with sign extension.</p>
<h5>Semantics:</h5> <h5>Semantics:</h5>
<p>This instruction always performs an arithmetic shift right operation, <p>This instruction always performs an arithmetic shift right operation,
The most significant bits of the result will be filled with the sign bit The most significant bits of the result will be filled with the sign bit
of <tt>var1</tt>.</p> of <tt>var1</tt>. If <tt>var2</tt> is (statically or dynamically) equal to or
larger than the number of bits in <tt>var1</tt>, the result is undefined.
</p>
<h5>Example:</h5> <h5>Example:</h5>
<pre> <pre>
@ -2240,6 +2255,7 @@ of <tt>var1</tt>.</p>
&lt;result&gt; = ashr i32 4, 2 <i>; yields {i32}:result = 1</i> &lt;result&gt; = ashr i32 4, 2 <i>; yields {i32}:result = 1</i>
&lt;result&gt; = ashr i8 4, 3 <i>; yields {i8}:result = 0</i> &lt;result&gt; = ashr i8 4, 3 <i>; yields {i8}:result = 0</i>
&lt;result&gt; = ashr i8 -2, 1 <i>; yields {i8}:result = -1</i> &lt;result&gt; = ashr i8 -2, 1 <i>; yields {i8}:result = -1</i>
&lt;result&gt; = ashr i32 1, 32 <i>; undefined</i>
</pre> </pre>
</div> </div>