Use correct name for method in comment.
[oota-llvm.git] / docs / LangRef.html
index bacc3a3fa0608a7a9a6ae1efd463cc0eeffa12f9..09903f1016be76acc2decca4a81db68375ee86be 100644 (file)
@@ -763,8 +763,8 @@ a power of 2.</p>
 </div>
 <div class="doc_text">
   <p>Aliases act as "second name" for the aliasee value (which can be either
-  function or global variable or bitcast of global value). Aliases may have an
-  optional <a href="#linkage">linkage type</a>, and an
+  function, global variable, another alias or bitcast of global value). Aliases
+  may have an optional <a href="#linkage">linkage type</a>, and an
   optional <a href="#visibility">visibility style</a>.</p>
 
   <h5>Syntax:</h5>
@@ -829,6 +829,7 @@ declare i32 @atoi(i8*) nounwind readonly
     <dt><tt>sret</tt></dt>
     <dd>This indicates that the pointer parameter specifies the address of a
     structure that is the return value of the function in the source program.
+    Loads and stores to the structure are assumed not to trap.
     May only be applied to the first parameter.</dd>
 
     <dt><tt>noalias</tt></dt>
@@ -842,10 +843,11 @@ declare i32 @atoi(i8*) nounwind readonly
     an <tt>unreachable</tt> instruction immediately followed the call.</dd> 
 
     <dt><tt>nounwind</tt></dt>
-    <dd>This function attribute indicates that the function type does not use
-    the unwind instruction and does not allow stack unwinding to propagate
-    through it.</dd>
-    
+    <dd>This function attribute indicates that no exceptions unwind out of the
+    function.  Usually this is because the function makes no use of exceptions,
+    but it may also be that the function catches any exceptions thrown when
+    executing it.</dd>
+
     <dt><tt>nest</tt></dt>
     <dd>This indicates that the parameter can be excised using the
     <a href="#int_trampoline">trampoline intrinsics</a>.</dd>
@@ -1223,8 +1225,10 @@ type "{ i32, [0 x float]}", for example.</p>
 <div class="doc_text">
 <h5>Overview:</h5>
 <p>The function type can be thought of as a function signature.  It
-consists of a return type and a list of formal parameter types. 
-Function types are usually used to build virtual function tables
+consists of a return type and a list of formal parameter types. The
+return type of a function type is a scalar type or a void type or a struct type. 
+If the return type is a struct type then all struct elements must be of first 
+class types. Function types are usually used to build virtual function tables
 (which are structures of pointers to functions), for indirect function
 calls, and when defining a function.</p>
 
@@ -1258,6 +1262,11 @@ Variable argument functions can access their arguments with the <a
       which returns an integer.  This is the signature for <tt>printf</tt> in 
       LLVM.
     </td>
+  </tr><tr class="layout">
+    <td class="left"><tt>{i32, i32} (i32)</tt></td>
+    <td class="left">A function taking an <tt>i32></tt>, returning two 
+        <tt> i32 </tt> values as an aggregate of type <tt>{ i32, i32 }</tt>
+    </td>
   </tr>
 </table>
 
@@ -1456,8 +1465,10 @@ them all and their syntax.</p>
 
   <dd>Floating point constants use standard decimal notation (e.g. 123.421),
   exponential notation (e.g. 1.23421e+2), or a more precise hexadecimal
-  notation (see below).  Floating point constants must have a <a
-  href="#t_floating">floating point</a> type. </dd>
+  notation (see below).  The assembler requires the exact decimal value of
+  a floating-point constant.  For example, the assembler accepts 1.25 but
+  rejects 1.3 because 1.3 is a repeating decimal in binary.  Floating point
+  constants must have a <a href="#t_floating">floating point</a> type. </dd>
 
   <dt><b>Null pointer constants</b></dt>
 
@@ -1914,7 +1925,7 @@ branches or with a lookup table.</p>
 <h5>Syntax:</h5>
 
 <pre>
-  &lt;result&gt; = invoke [<a href="#callingconv">cconv</a>] &lt;ptr to function ty&gt; %&lt;function ptr val&gt;(&lt;function args&gt;) 
+  &lt;result&gt; = invoke [<a href="#callingconv">cconv</a>] &lt;ptr to function ty&gt; &lt;function ptr val&gt;(&lt;function args&gt;) 
                 to label &lt;normal label&gt; unwind label &lt;exception label&gt;
 </pre>
 
@@ -1977,9 +1988,9 @@ exception.  Additionally, this is important for implementation of
 
 <h5>Example:</h5>
 <pre>
-  %retval = invoke i32 %Test(i32 15) to label %Continue
+  %retval = invoke i32 @Test(i32 15) to label %Continue
               unwind label %TestCleanup              <i>; {i32}:retval set</i>
-  %retval = invoke <a href="#callingconv">coldcc</a> i32 %Test(i32 15) to label %Continue
+  %retval = invoke <a href="#callingconv">coldcc</a> i32 %Testfnptr(i32 15) to label %Continue
               unwind label %TestCleanup              <i>; {i32}:retval set</i>
 </pre>
 </div>
@@ -2044,11 +2055,10 @@ no-return function cannot be reached, and other facts.</p>
 <div class="doc_subsection"> <a name="binaryops">Binary Operations</a> </div>
 <div class="doc_text">
 <p>Binary operators are used to do most of the computation in a
-program.  They require two operands, execute an operation on them, and
+program.  They require two operands of the same type, execute an operation on them, and
 produce a single value.  The operands might represent 
 multiple data, as is the case with the <a href="#t_vector">vector</a> data type. 
-The result value of a binary operator is not
-necessarily the same type as its operands.</p>
+The result value has the same type as its operands.</p>
 <p>There are several different binary operators:</p>
 </div>
 <!-- _______________________________________________________________________ -->
@@ -2181,7 +2191,7 @@ operands.</p>
 types. This instruction can also take <a href="#t_vector">vector</a> versions 
 of the values in which case the elements must be integers.</p>
 <h5>Semantics:</h5>
-<p>The value produced is the signed integer quotient of the two operands.</p>
+<p>The value produced is the signed integer quotient of the two operands rounded towards zero.</p>
 <p>Note that signed integer division and unsigned integer division are distinct
 operations; for unsigned integer division, use '<tt>udiv</tt>'.</p>
 <p>Division by zero leads to undefined behavior. Overflow also leads to
@@ -2229,8 +2239,7 @@ types. This instruction can also take <a href="#t_vector">vector</a> versions
 of the values in which case the elements must be integers.</p>
 <h5>Semantics:</h5>
 <p>This instruction returns the unsigned integer <i>remainder</i> of a division.
-This instruction always performs an unsigned division to get the remainder,
-regardless of whether the arguments are unsigned or not.</p>
+This instruction always performs an unsigned division to get the remainder.</p>
 <p>Note that unsigned integer remainder and signed integer remainder are
 distinct operations; for signed integer remainder, use '<tt>srem</tt>'.</p>
 <p>Taking the remainder of a division by zero leads to undefined behavior.</p>
@@ -2294,7 +2303,8 @@ division of its two operands.</p>
 identical types.  This instruction can also take <a href="#t_vector">vector</a>
 versions of floating point values.</p>
 <h5>Semantics:</h5>
-<p>This instruction returns the <i>remainder</i> of a division.</p>
+<p>This instruction returns the <i>remainder</i> of a division.
+The remainder has the same sign as the dividend.</p>
 <h5>Example:</h5>
 <pre>  &lt;result&gt; = frem float 4.0, %var          <i>; yields {float}:result = 4.0 % %var</i>
 </pre>
@@ -2307,9 +2317,8 @@ Operations</a> </div>
 <p>Bitwise binary operators are used to do various forms of
 bit-twiddling in a program.  They are generally very efficient
 instructions and can commonly be strength reduced from other
-instructions.  They require two operands, execute an operation on them,
-and produce a single value.  The resulting value of the bitwise binary
-operators is always the same type as its first operand.</p>
+instructions.  They require two operands of the same type, execute an operation on them,
+and produce a single value.  The resulting value is the same type as its operands.</p>
 </div>
 
 <!-- _______________________________________________________________________ -->
@@ -2332,9 +2341,9 @@ the left a specified number of bits.</p>
  
 <h5>Semantics:</h5>
 
-<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>
+<p>The value produced is <tt>var1</tt> * 2<sup><tt>var2</tt></sup> mod 2<sup>n</sup>,
+where n is the width of the result.  If <tt>var2</tt> is (statically or dynamically) negative or
+equal to or larger than the number of bits in <tt>var1</tt>, the result is undefined.</p>
 
 <h5>Example:</h5><pre>
   &lt;result&gt; = shl i32 4, %var   <i>; yields {i32}: 4 &lt;&lt; %var</i>
@@ -2778,7 +2787,7 @@ address space (address space zero).</p>
 bytes of memory from the operating system and returns a pointer of the
 appropriate type to the program.  If "NumElements" is specified, it is the
 number of elements allocated, otherwise "NumElements" is defaulted to be one.
-If an alignment is specified, the value result of the allocation is guaranteed to
+If a constant alignment is specified, the value result of the allocation is guaranteed to
 be aligned to at least that boundary.  If not specified, or if zero, the target can
 choose to align the allocation on any convenient boundary.</p>
 
@@ -2787,7 +2796,8 @@ choose to align the allocation on any convenient boundary.</p>
 <h5>Semantics:</h5>
 
 <p>Memory is allocated using the system "<tt>malloc</tt>" function, and
-a pointer is returned.</p>
+a pointer is returned.  Allocating zero bytes is undefined.  The result is null
+if there is insufficient memory available.</p>
 
 <h5>Example:</h5>
 
@@ -2829,7 +2839,8 @@ instruction.</p>
 <h5>Semantics:</h5>
 
 <p>Access to the memory pointed to by the pointer is no longer defined
-after this instruction executes.</p>
+after this instruction executes.  If the pointer is null, the result is
+undefined.</p>
 
 <h5>Example:</h5>
 
@@ -2865,7 +2876,7 @@ space (address space zero).</p>
 bytes of memory on the runtime stack, returning a pointer of the
 appropriate type to the program.  If "NumElements" is specified, it is the
 number of elements allocated, otherwise "NumElements" is defaulted to be one.
-If an alignment is specified, the value result of the allocation is guaranteed
+If a constant alignment is specified, the value result of the allocation is guaranteed
 to be aligned to at least that boundary.  If not specified, or if zero, the target
 can choose to align the allocation on any convenient boundary.</p>
 
@@ -2878,7 +2889,8 @@ memory is automatically released when the function returns.  The '<tt>alloca</tt
 instruction is commonly used to represent automatic variables that must
 have an address available.  When the function returns (either with the <tt><a
  href="#i_ret">ret</a></tt> or <tt><a href="#i_unwind">unwind</a></tt>
-instructions), the memory is reclaimed.</p>
+instructions), the memory is reclaimed.  Allocating zero bytes
+is legal, but the result is undefined.</p>
 
 <h5>Example:</h5>
 
@@ -2907,7 +2919,7 @@ the number or order of execution of this <tt>load</tt> with other
 volatile <tt>load</tt> and <tt><a href="#i_store">store</a></tt>
 instructions. </p>
 <p>
-The optional "align" argument specifies the alignment of the operation
+The optional constant "align" argument specifies the alignment of the operation
 (that is, the alignment of the memory address). A value of 0 or an
 omitted "align" argument means that the operation has the preferential
 alignment for the target. It is the responsibility of the code emitter
@@ -2938,13 +2950,14 @@ Instruction</a> </div>
 <h5>Arguments:</h5>
 <p>There are two arguments to the '<tt>store</tt>' instruction: a value
 to store and an address at which to store it.  The type of the '<tt>&lt;pointer&gt;</tt>'
-operand must be a pointer to the type of the '<tt>&lt;value&gt;</tt>'
+operand must be a pointer to the <a href="#t_firstclass">first class</a> type
+of the '<tt>&lt;value&gt;</tt>'
 operand. If the <tt>store</tt> is marked as <tt>volatile</tt>, then the
 optimizer is not allowed to modify the number or order of execution of
 this <tt>store</tt> with other volatile <tt>load</tt> and <tt><a
  href="#i_store">store</a></tt> instructions.</p>
 <p>
-The optional "align" argument specifies the alignment of the operation
+The optional constant "align" argument specifies the alignment of the operation
 (that is, the alignment of the memory address). A value of 0 or an
 omitted "align" argument means that the operation has the preferential
 alignment for the target. It is the responsibility of the code emitter
@@ -3034,8 +3047,8 @@ entry:
 on the pointer type that is being indexed into. <a href="#t_pointer">Pointer</a>
 and <a href="#t_array">array</a> types can use a 32-bit or 64-bit
 <a href="#t_integer">integer</a> type but the value will always be sign extended
-to 64-bits.  <a href="#t_struct">Structure</a> types require <tt>i32</tt>
-<b>constants</b>.</p>
+to 64-bits.  <a href="#t_struct">Structure</a> and <a href="#t_pstruct">packed
+structure</a> types require <tt>i32</tt> <b>constants</b>.</p>
 
 <p>In the example above, the first index is indexing into the '<tt>%ST*</tt>'
 type, which is a pointer, yielding a '<tt>%ST</tt>' = '<tt>{ i32, double, %RT
@@ -3543,7 +3556,7 @@ instructions, which defy better classification.</p>
 </pre>
 <h5>Overview:</h5>
 <p>The '<tt>icmp</tt>' instruction returns a boolean value based on comparison
-of its two integer operands.</p>
+of its two integer or pointer operands.</p>
 <h5>Arguments:</h5>
 <p>The '<tt>icmp</tt>' instruction takes three operands. The first operand is
 the condition code indicating the kind of comparison to perform. It is not
@@ -3817,25 +3830,23 @@ transfer to a specified function, with its incoming arguments bound to
 the specified values. Upon a '<tt><a href="#i_ret">ret</a></tt>'
 instruction in the called function, control flow continues with the
 instruction after the function call, and the return value of the
-function is bound to the result argument.  If the '<tt><a href="#i_ret">ret</a>
-</tt>' instruction returns multiple values then the return values of the
-function are only accessible through a '<tt><a href="#i_getresult">getresult</a>
-</tt>' instruction. This is a simpler case of
-the <a href="#i_invoke">invoke</a> instruction.</p>
+function is bound to the result argument.  If the callee returns multiple 
+values then the return values of the function are only accessible through 
+the '<tt><a href="#i_getresult">getresult</a></tt>' instruction.</p>
 
 <h5>Example:</h5>
 
 <pre>
   %retval = call i32 @test(i32 %argc)
-  call i32 (i8 *, ...)* @printf(i8 * %msg, i32 12, i8 42);
-  %X = tail call i32 @foo()
-  %Y = tail call <a href="#callingconv">fastcc</a> i32 @foo()
-  %Z = call void %foo(i8 97 signext)
+  call i32 (i8 *, ...)* @printf(i8 * %msg, i32 12, i8 42)      <i>; yields i32</i>
+  %X = tail call i32 @foo()                                    <i>; yields i32</i>
+  %Y = tail call <a href="#callingconv">fastcc</a> i32 @foo()  <i>; yields i32</i>
+  call void %foo(i8 97 signext)
 
   %struct.A = type { i32, i8 }
-  %r = call %struct.A @foo()
-  %gr = getresult %struct.A %r, 0
-  %gr1 = getresult %struct.A %r, 1
+  %r = call %struct.A @foo()                     <i>; yields { 32, i8 }</i>
+  %gr = getresult %struct.A %r, 0                <i>; yields i32</i>
+  %gr1 = getresult %struct.A %r, 1               <i>; yields i8</i>
 </pre>
 
 </div>
@@ -3897,24 +3908,27 @@ argument.</p>
 
 <h5>Syntax:</h5>
 <pre>
-  &lt;resultval&gt; = getresult &lt;type&gt; &lt;retval&gt;,  &lt;index&gt;
+  &lt;resultval&gt; = getresult &lt;type&gt; &lt;retval&gt;, &lt;index&gt;
 </pre>
+
 <h5>Overview:</h5>
 
 <p> The '<tt>getresult</tt>' instruction is used to extract individual values
-from multiple values returned by a '<tt><a href="#i_call">call</a></tt>' 
-or '<tt><a href="#i_invoke">invoke</a></tt>' instruction.
+from a '<tt><a href="#i_call">call</a></tt>' 
+or '<tt><a href="#i_invoke">invoke</a></tt>' instruction that returns multiple
+results.</p>
 
 <h5>Arguments:</h5>
 
-The '<tt>getresult</tt>' instruction takes a return value as first argument. 
-The value must have <a href="#t_struct">structure type</a>. The second argument 
-is an unsigned index value. 
+<p>The '<tt>getresult</tt>' instruction takes a call or invoke value as its 
+first argument.  The value must have <a href="#t_struct">structure type</a>. 
+The second argument is a constant unsigned index value which must be in range for
+the number of values returned by the call.</p>
 
 <h5>Semantics:</h5>
 
-The '<tt>getresult</tt>' instruction extracts the element identified by
-'<tt>index</tt>' from the aggregate value.
+<p>The '<tt>getresult</tt>' instruction extracts the element identified by
+'<tt>index</tt>' from the aggregate value.</p>
 
 <h5>Example:</h5>
 
@@ -3922,8 +3936,8 @@ The '<tt>getresult</tt>' instruction extracts the element identified by
   %struct.A = type { i32, i8 }
 
   %r = call %struct.A @foo()
-  %gr = getresult %struct.A %r, 0
-  %gr1 = getresult %struct.A %r, 1 
+  %gr = getresult %struct.A %r, 0    <i>; yields i32:%gr</i>
+  %gr1 = getresult %struct.A %r, 1   <i>; yields i8:%gr1</i>
   add i32 %gr, 42
   add i8 %gr1, 41
 </pre>