Documentation for the new non-overflow and exact keywords.
authorDan Gohman <gohman@apple.com>
Mon, 20 Jul 2009 22:41:19 +0000 (22:41 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 20 Jul 2009 22:41:19 +0000 (22:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76495 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LangRef.html

index dced11c44166905ee060d7c1ccc6657467fdb855..334cb68772c611d57cab0f3c27e43cc018296c44 100644 (file)
@@ -2600,7 +2600,9 @@ Instruction</a> </div>
 
 <h5>Syntax:</h5>
 <pre>
-  &lt;result&gt; = add &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;   <i>; yields {ty}:result</i>
+  &lt;result&gt; = add &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;          <i>; yields {ty}:result</i>
+  &lt;result&gt; = signed add &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;   <i>; yields {ty}:result</i>
+  &lt;result&gt; = unsigned add &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt; <i>; yields {ty}:result</i>
 </pre>
 
 <h5>Overview:</h5>
@@ -2620,6 +2622,10 @@ Instruction</a> </div>
 <p>Because LLVM integers use a two's complement representation, this instruction
    is appropriate for both signed and unsigned integers.</p>
 
+<p>If the <tt>signed</tt> and/or <tt>unsigned</tt> keywords are present,
+   the behavior of the <tt>add</tt> is undefined if signed and/or unsigned
+   overflow, respectively, occurs.</p>
+
 <h5>Example:</h5>
 <pre>
   &lt;result&gt; = add i32 4, %var          <i>; yields {i32}:result = 4 + %var</i>
@@ -2666,7 +2672,9 @@ Instruction</a> </div>
 
 <h5>Syntax:</h5>
 <pre>
-  &lt;result&gt; = sub &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;   <i>; yields {ty}:result</i>
+  &lt;result&gt; = sub &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;            <i>; yields {ty}:result</i>
+  &lt;result&gt; = signed sub &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;     <i>; yields {ty}:result</i>
+  &lt;result&gt; = unsigned sub &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;   <i>; yields {ty}:result</i>
 </pre>
 
 <h5>Overview:</h5>
@@ -2692,6 +2700,10 @@ Instruction</a> </div>
 <p>Because LLVM integers use a two's complement representation, this instruction
    is appropriate for both signed and unsigned integers.</p>
 
+<p>If the <tt>signed</tt> and/or <tt>unsigned</tt> keywords are present,
+   the behavior of the <tt>sub</tt> is undefined if signed and/or unsigned
+   overflow, respectively, occurs.</p>
+
 <h5>Example:</h5>
 <pre>
   &lt;result&gt; = sub i32 4, %var          <i>; yields {i32}:result = 4 - %var</i>
@@ -2745,7 +2757,9 @@ Instruction</a> </div>
 
 <h5>Syntax:</h5>
 <pre>
-  &lt;result&gt; = mul &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;   <i>; yields {ty}:result</i>
+  &lt;result&gt; = mul &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;            <i>; yields {ty}:result</i>
+  &lt;result&gt; = signed mul &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;     <i>; yields {ty}:result</i>
+  &lt;result&gt; = unsigned mul &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;   <i>; yields {ty}:result</i>
 </pre>
 
 <h5>Overview:</h5>
@@ -2770,6 +2784,10 @@ Instruction</a> </div>
    be sign-extended or zero-extended as appropriate to the width of the full
    product.</p>
 
+<p>If the <tt>signed</tt> and/or <tt>unsigned</tt> keywords are present,
+   the behavior of the <tt>mul</tt> is undefined if signed and/or unsigned
+   overflow, respectively, occurs.</p>
+
 <h5>Example:</h5>
 <pre>
   &lt;result&gt; = mul i32 4, %var          <i>; yields {i32}:result = 4 * %var</i>
@@ -2849,7 +2867,8 @@ Instruction</a> </div>
 
 <h5>Syntax:</h5>
 <pre>
-  &lt;result&gt; = sdiv &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;   <i>; yields {ty}:result</i>
+  &lt;result&gt; = sdiv &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;         <i>; yields {ty}:result</i>
+  &lt;result&gt; = exact sdiv &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;   <i>; yields {ty}:result</i>
 </pre>
 
 <h5>Overview:</h5>
@@ -2871,6 +2890,9 @@ Instruction</a> </div>
    undefined behavior; this is a rare case, but can occur, for example, by doing
    a 32-bit division of -2147483648 by -1.</p>
 
+<p>If the <tt>exact</tt> keyword is present, the result of the <tt>sdiv</tt>
+   is undefined if the result would be rounded or if overflow occurs.</p>
+
 <h5>Example:</h5>
 <pre>
   &lt;result&gt; = sdiv i32 4, %var          <i>; yields {i32}:result = 4 / %var</i>
@@ -3912,13 +3934,6 @@ entry:
   }
 </pre>
 
-<p>Note that it is undefined to access an array out of bounds: array and pointer
-   indexes must always be within the defined bounds of the array type when
-   accessed with an instruction that dereferences the pointer (e.g. a load or
-   store instruction).  The one exception for this rule is zero length arrays.
-   These arrays are defined to be accessible as variable length arrays, which
-   requires access beyond the zero'th element.</p>
-
 <p>The getelementptr instruction is often confusing.  For some more insight into
    how it works, see <a href="GetElementPtr.html">the getelementptr FAQ</a>.</p>