[llvm-commits] [llvm] r76495 - /llvm/trunk/docs/LangRef.html

Dan Gohman gohman at apple.com
Mon Jul 20 15:41:19 PDT 2009


Author: djg
Date: Mon Jul 20 17:41:19 2009
New Revision: 76495

URL: http://llvm.org/viewvc/llvm-project?rev=76495&view=rev
Log:
Documentation for the new non-overflow and exact keywords.

Modified:
    llvm/trunk/docs/LangRef.html

Modified: llvm/trunk/docs/LangRef.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=76495&r1=76494&r2=76495&view=diff

==============================================================================
--- llvm/trunk/docs/LangRef.html (original)
+++ llvm/trunk/docs/LangRef.html Mon Jul 20 17:41:19 2009
@@ -2600,7 +2600,9 @@
 
 <h5>Syntax:</h5>
 <pre>
-  <result> = add <ty> <op1>, <op2>   <i>; yields {ty}:result</i>
+  <result> = add <ty> <op1>, <op2>          <i>; yields {ty}:result</i>
+  <result> = signed add <ty> <op1>, <op2>   <i>; yields {ty}:result</i>
+  <result> = unsigned add <ty> <op1>, <op2> <i>; yields {ty}:result</i>
 </pre>
 
 <h5>Overview:</h5>
@@ -2620,6 +2622,10 @@
 <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>
   <result> = add i32 4, %var          <i>; yields {i32}:result = 4 + %var</i>
@@ -2666,7 +2672,9 @@
 
 <h5>Syntax:</h5>
 <pre>
-  <result> = sub <ty> <op1>, <op2>   <i>; yields {ty}:result</i>
+  <result> = sub <ty> <op1>, <op2>            <i>; yields {ty}:result</i>
+  <result> = signed sub <ty> <op1>, <op2>     <i>; yields {ty}:result</i>
+  <result> = unsigned sub <ty> <op1>, <op2>   <i>; yields {ty}:result</i>
 </pre>
 
 <h5>Overview:</h5>
@@ -2692,6 +2700,10 @@
 <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>
   <result> = sub i32 4, %var          <i>; yields {i32}:result = 4 - %var</i>
@@ -2745,7 +2757,9 @@
 
 <h5>Syntax:</h5>
 <pre>
-  <result> = mul <ty> <op1>, <op2>   <i>; yields {ty}:result</i>
+  <result> = mul <ty> <op1>, <op2>            <i>; yields {ty}:result</i>
+  <result> = signed mul <ty> <op1>, <op2>     <i>; yields {ty}:result</i>
+  <result> = unsigned mul <ty> <op1>, <op2>   <i>; yields {ty}:result</i>
 </pre>
 
 <h5>Overview:</h5>
@@ -2770,6 +2784,10 @@
    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>
   <result> = mul i32 4, %var          <i>; yields {i32}:result = 4 * %var</i>
@@ -2849,7 +2867,8 @@
 
 <h5>Syntax:</h5>
 <pre>
-  <result> = sdiv <ty> <op1>, <op2>   <i>; yields {ty}:result</i>
+  <result> = sdiv <ty> <op1>, <op2>         <i>; yields {ty}:result</i>
+  <result> = exact sdiv <ty> <op1>, <op2>   <i>; yields {ty}:result</i>
 </pre>
 
 <h5>Overview:</h5>
@@ -2871,6 +2890,9 @@
    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>
   <result> = sdiv i32 4, %var          <i>; yields {i32}:result = 4 / %var</i>
@@ -3912,13 +3934,6 @@
   }
 </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>
 





More information about the llvm-commits mailing list