Fix grammar.
[oota-llvm.git] / docs / LangRef.html
index 4d73aaafe8d1a851a9f466a6ab202837cd23270e..bba96240d84d6d3f5e4ef0073a1011691c3ffbff 100644 (file)
@@ -26,6 +26,7 @@
       <li><a href="#functionstructure">Functions</a></li>
       <li><a href="#aliasstructure">Aliases</a>
       <li><a href="#paramattrs">Parameter Attributes</a></li>
+      <li><a href="#fnattrs">Function Attributes</a></li>
       <li><a href="#gc">Garbage Collector Names</a></li>
       <li><a href="#moduleasm">Module-Level Inline Assembly</a></li>
       <li><a href="#datalayout">Data Layout</a></li>
@@ -750,7 +751,8 @@ an optional <a href="#linkage">linkage type</a>, an optional
 <a href="#paramattrs">parameter attribute</a> for the return type, a function 
 name, a (possibly empty) argument list (each with optional 
 <a href="#paramattrs">parameter attributes</a>), an optional section, an
-optional alignment, an optional <a href="#gc">garbage collector name</a>, an
+optional alignment, an optional <a href="#gc">garbage collector name</a>, 
+an optional <a href="#notes">function notes</a>, an
 opening curly brace, a list of basic blocks, and a closing curly brace.
 
 LLVM function declarations consist of the "<tt>declare</tt>" keyword, an
@@ -800,7 +802,7 @@ a power of 2.</p>
 
 <div class="doc_code">
 <pre>
-@&lt;Name&gt; = [Linkage] [Visibility] alias &lt;AliaseeTy&gt; @&lt;Aliasee&gt;
+@&lt;Name&gt; = alias [Linkage] [Visibility] &lt;AliaseeTy&gt; @&lt;Aliasee&gt;
 </pre>
 </div>
 
@@ -824,8 +826,8 @@ a power of 2.</p>
 
 <div class="doc_code">
 <pre>
-declare i32 @printf(i8* noalias , ...) nounwind
-declare i32 @atoi(i8*) nounwind readonly
+declare i32 @printf(i8* noalias , ...)
+declare i32 @atoi(i8 zeroext*)
 </pre>
 </div>
 
@@ -843,9 +845,11 @@ declare i32 @atoi(i8*) nounwind readonly
     a call to this function.</dd>
 
     <dt><tt>inreg</tt></dt>
-    <dd>This indicates that the parameter should be placed in register (if
-    possible) during assembling function call. Support for this attribute is
-    target-specific</dd>
+    <dd>This indicates that this parameter or return value should be treated
+    in a special target-dependent fashion during while emitting code for a
+    function call or return (usually, by putting it in a register as opposed 
+    to memory; in some places it is used to distinguish between two different
+    kinds of registers).  Use of this attribute is target-specific</dd>
 
     <dt><tt>byval</tt></dt>
     <dd>This indicates that the pointer parameter should really be passed by
@@ -866,29 +870,9 @@ declare i32 @atoi(i8*) nounwind readonly
     parameter.  The caller is responsible for ensuring that this is the case,
     usually by placing the value in a stack allocation.</dd>
 
-    <dt><tt>noreturn</tt></dt>
-    <dd>This function attribute indicates that the function never returns. This
-    indicates to LLVM that every call to this function should be treated as if
-    an <tt>unreachable</tt> instruction immediately followed the call.</dd> 
-
-    <dt><tt>nounwind</tt></dt>
-    <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 pointer parameter can be excised using the
     <a href="#int_trampoline">trampoline intrinsics</a>.</dd>
-    <dt><tt>readonly</tt></dt>
-    <dd>This function attribute indicates that the function has no side-effects
-    except for producing a return value or throwing an exception.  The value
-    returned must only depend on the function arguments and/or global variables.
-    It may use values obtained by dereferencing pointers.</dd>
-    <dt><tt>readnone</tt></dt>
-    <dd>A <tt>readnone</tt> function has the same restrictions as a <tt>readonly</tt>
-    function, but in addition it is not allowed to dereference any pointer arguments
-    or global variables.
   </dl>
 
 </div>
@@ -910,6 +894,69 @@ collector which will cause the compiler to alter its output in order to support
 the named garbage collection algorithm.</p>
 </div>
 
+<!-- ======================================================================= -->
+<div class="doc_subsection">
+  <a name="fnattrs">Function Attributes</a>
+</div>
+
+<div class="doc_text">
+
+<p>Function attributes are set to communicate additional information about 
+  a function. Function attributes are considered to be part of the function,
+  not of the function type, so functions with different parameter attributes
+  can have the same function type.</p>
+
+  <p>Function attributes are simple keywords that follow the type specified. If
+  multiple attributes are needed, they are space separated. For 
+  example:</p>
+
+<div class="doc_code">
+<pre>
+define void @f() noinline { ... }
+define void @f() alwaysinline { ... }
+define void @f() alwaysinline optsize { ... }
+define void @f() optsize
+</pre>
+</div>
+
+<dl>
+<dt><tt>alwaysinline</tt></dt>
+<dd>This attribute requests inliner to inline this function irrespective of 
+inlining size threshold for this function.</dd>
+
+<dt><tt>noinline</tt></dt>
+<dd>This attributes requests inliner to never inline this function in any 
+situation. This attribute may not be used together with <tt>alwaysinline</tt>
+ attribute.</dd>
+
+<dt><tt>optsize</tt></dt>
+<dd>This attribute suggests that optimization passes and code generator passes
+make choices that help reduce code size.</dd>
+
+<dt><tt>noreturn</tt></dt>
+<dd>This function attribute indicates that the function never returns. This
+  tells LLVM that every call to this function should be treated as if
+  an <tt>unreachable</tt> instruction immediately followed the call.</dd> 
+
+<dt><tt>nounwind</tt></dt>
+<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>readonly</tt></dt>
+<dd>This function attribute indicates that the function has no side-effects
+  except for producing a return value or throwing an exception.  The value
+  returned must only depend on the function arguments and/or global variables.
+  It may use values obtained by dereferencing pointers.</dd>
+<dt><tt>readnone</tt></dt>
+<dd>A <tt>readnone</tt> function has the same restrictions as a <tt>readonly</tt>
+  function, but in addition it is not allowed to dereference any pointer arguments
+  or global variables.
+</dl>
+
+</div>
+
 <!-- ======================================================================= -->
 <div class="doc_subsection">
   <a name="moduleasm">Module-Level Inline Assembly</a>
@@ -1357,7 +1404,8 @@ instruction.</p>
     <td class="left"><tt>&lt; { i32, i32, i32 } &gt;</tt></td>
     <td class="left">A triple of three <tt>i32</tt> values</td>
   </tr><tr class="layout">
-  <td class="left"><tt>&lt; { float, i32 (i32)* } &gt;</tt></td>
+  <td class="left">
+<tt>&lt;&nbsp;{&nbsp;float,&nbsp;i32&nbsp;(i32)*&nbsp;}&nbsp;&gt;</tt></td>
     <td class="left">A pair, where the first element is a <tt>float</tt> and the
       second element is a <a href="#t_pointer">pointer</a> to a
       <a href="#t_function">function</a> that takes an <tt>i32</tt>, returning
@@ -1690,7 +1738,8 @@ following is the syntax for constant expressions:</p>
   was stored to memory and read back as TYPE. In other words, no bits change 
   with this operator, just the type.  This can be used for conversion of
   vector types to any other type, as long as they have the same bit width. For
-  pointers it is only valid to cast to another pointer type.
+  pointers it is only valid to cast to another pointer type. It is not valid
+  to bitcast to or from an aggregate type.
   </dd>
 
   <dt><b><tt>getelementptr ( CSTPTR, IDX0, IDX1, ... )</tt></b></dt>
@@ -2572,7 +2621,7 @@ values.  Both arguments must have identical types.</p>
 <h5>Semantics:</h5>
 <p>The truth table used for the '<tt>and</tt>' instruction is:</p>
 <p> </p>
-<div style="align: center">
+<div>
 <table border="1" cellspacing="0" cellpadding="4">
   <tbody>
     <tr>
@@ -2627,7 +2676,7 @@ values.  Both arguments must have identical types.</p>
 <h5>Semantics:</h5>
 <p>The truth table used for the '<tt>or</tt>' instruction is:</p>
 <p> </p>
-<div style="align: center">
+<div>
 <table border="1" cellspacing="0" cellpadding="4">
   <tbody>
     <tr>
@@ -2684,7 +2733,7 @@ values.  Both arguments must have identical types.</p>
 
 <p>The truth table used for the '<tt>xor</tt>' instruction is:</p>
 <p> </p>
-<div style="align: center">
+<div>
 <table border="1" cellspacing="0" cellpadding="4">
   <tbody>
     <tr>
@@ -3769,8 +3818,9 @@ nothing is done (<i>no-op cast</i>).</p>
 <h5>Arguments:</h5>
 
 <p>The '<tt>bitcast</tt>' instruction takes a value to cast, which must be 
-a first class value, and a type to cast it to, which must also be a <a
-  href="#t_firstclass">first class</a> type. The bit sizes of <tt>value</tt>
+a non-aggregate first class value, and a type to cast it to, which must also be
+a non-aggregate <a href="#t_firstclass">first class</a> type. The bit sizes of
+<tt>value</tt>
 and the destination type, <tt>ty2</tt>, must be identical. If the source
 type is a pointer, the destination type must also be a pointer.  This
 instruction supports bitwise conversion of vectors to integers and to vectors
@@ -3805,11 +3855,12 @@ instructions, which defy better classification.</p>
 </div>
 <div class="doc_text">
 <h5>Syntax:</h5>
-<pre>  &lt;result&gt; = icmp &lt;cond&gt; &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;   <i>; yields {i1}:result</i>
+<pre>  &lt;result&gt; = icmp &lt;cond&gt; &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;   <i>; yields {i1} or {&lt;N x i1&gt}:result</i>
 </pre>
 <h5>Overview:</h5>
-<p>The '<tt>icmp</tt>' instruction returns a boolean value based on comparison
-of its two integer or pointer operands.</p>
+<p>The '<tt>icmp</tt>' instruction returns a boolean value or
+a vector of boolean values based on comparison
+of its two integer, integer vector, 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
@@ -3827,11 +3878,13 @@ a value, just a keyword. The possible condition code are:
   <li><tt>sle</tt>: signed less or equal</li>
 </ol>
 <p>The remaining two arguments must be <a href="#t_integer">integer</a> or
-<a href="#t_pointer">pointer</a> typed. They must also be identical types.</p>
+<a href="#t_pointer">pointer</a>
+or integer <a href="#t_vector">vector</a> typed.
+They must also be identical types.</p>
 <h5>Semantics:</h5>
 <p>The '<tt>icmp</tt>' compares <tt>op1</tt> and <tt>op2</tt> according to 
 the condition code given as <tt>cond</tt>. The comparison performed always
-yields a <a href="#t_primitive">i1</a> result, as follows: 
+yields either an <a href="#t_primitive"><tt>i1</tt></a> or vector of <tt>i1</tt> result, as follows: 
 <ol>
   <li><tt>eq</tt>: yields <tt>true</tt> if the operands are equal, 
   <tt>false</tt> otherwise. No sign interpretation is necessary or performed.
@@ -3857,6 +3910,11 @@ yields a <a href="#t_primitive">i1</a> result, as follows:
 </ol>
 <p>If the operands are <a href="#t_pointer">pointer</a> typed, the pointer
 values are compared as if they were integers.</p>
+<p>If the operands are integer vectors, then they are compared
+element by element. The result is an <tt>i1</tt> vector with
+the same number of elements as the values being compared.
+Otherwise, the result is an <tt>i1</tt>.
+</p>
 
 <h5>Example:</h5>
 <pre>  &lt;result&gt; = icmp eq i32 4, 5          <i>; yields: result=false</i>
@@ -3873,11 +3931,19 @@ values are compared as if they were integers.</p>
 </div>
 <div class="doc_text">
 <h5>Syntax:</h5>
-<pre>  &lt;result&gt; = fcmp &lt;cond&gt; &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;     <i>; yields {i1}:result</i>
+<pre>  &lt;result&gt; = fcmp &lt;cond&gt; &lt;ty&gt; &lt;op1&gt;, &lt;op2&gt;     <i>; yields {i1} or {&lt;N x i1&gt}:result</i>
 </pre>
 <h5>Overview:</h5>
-<p>The '<tt>fcmp</tt>' instruction returns a boolean value based on comparison
-of its floating point operands.</p>
+<p>The '<tt>fcmp</tt>' instruction returns a boolean value
+or vector of boolean values based on comparison
+of its operands.
+<p>
+If the operands are floating point scalars, then the result
+type is a boolean (<a href="#t_primitive"><tt>i1</tt></a>).
+</p>
+<p>If the operands are floating point vectors, then the result type
+is a vector of boolean with the same number of elements as the
+operands being compared.</p>
 <h5>Arguments:</h5>
 <p>The '<tt>fcmp</tt>' instruction takes three operands. The first operand is
 the condition code indicating the kind of comparison to perform. It is not
@@ -3902,13 +3968,17 @@ a value, just a keyword. The possible condition code are:
 </ol>
 <p><i>Ordered</i> means that neither operand is a QNAN while
 <i>unordered</i> means that either operand may be a QNAN.</p>
-<p>The <tt>val1</tt> and <tt>val2</tt> arguments must be
-<a href="#t_floating">floating point</a> typed.  They must have identical 
-types.</p>
+<p>Each of <tt>val1</tt> and <tt>val2</tt> arguments must be
+either a <a href="#t_floating">floating point</a> type
+or a <a href="#t_vector">vector</a> of floating point type.
+They must have identical types.</p>
 <h5>Semantics:</h5>
 <p>The '<tt>fcmp</tt>' instruction compares <tt>op1</tt> and <tt>op2</tt>
-according to the condition code given as <tt>cond</tt>. The comparison performed 
-always yields a <a href="#t_primitive">i1</a> result, as follows: 
+according to the condition code given as <tt>cond</tt>.
+If the operands are vectors, then the vectors are compared
+element by element.
+Each comparison performed 
+always yields an <a href="#t_primitive">i1</a> result, as follows: 
 <ol>
   <li><tt>false</tt>: always yields <tt>false</tt>, regardless of operands.</li>
   <li><tt>oeq</tt>: yields <tt>true</tt> if both operands are not a QNAN and 
@@ -3942,9 +4012,9 @@ always yields a <a href="#t_primitive">i1</a> result, as follows:
 
 <h5>Example:</h5>
 <pre>  &lt;result&gt; = fcmp oeq float 4.0, 5.0    <i>; yields: result=false</i>
-  &lt;result&gt; = icmp one float 4.0, 5.0    <i>; yields: result=true</i>
-  &lt;result&gt; = icmp olt float 4.0, 5.0    <i>; yields: result=true</i>
-  &lt;result&gt; = icmp ueq double 1.0, 2.0   <i>; yields: result=false</i>
+  &lt;result&gt; = fcmp one float 4.0, 5.0    <i>; yields: result=true</i>
+  &lt;result&gt; = fcmp olt float 4.0, 5.0    <i>; yields: result=true</i>
+  &lt;result&gt; = fcmp ueq double 1.0, 2.0   <i>; yields: result=false</i>
 </pre>
 </div>
 
@@ -3975,7 +4045,7 @@ a value, just a keyword. The possible condition code are:
   <li><tt>slt</tt>: signed less than</li>
   <li><tt>sle</tt>: signed less or equal</li>
 </ol>
-<p>The remaining two arguments must be <a href="#t_vector">vector</a> o
+<p>The remaining two arguments must be <a href="#t_vector">vector</a> or
 <a href="#t_integer">integer</a> typed. They must also be identical types.</p>
 <h5>Semantics:</h5>
 <p>The '<tt>vicmp</tt>' instruction compares <tt>op1</tt> and <tt>op2</tt>
@@ -4099,7 +4169,9 @@ Loop:       ; Infinite loop that counts from 0 on up...
 <h5>Syntax:</h5>
 
 <pre>
-  &lt;result&gt; = select i1 &lt;cond&gt;, &lt;ty&gt; &lt;val1&gt;, &lt;ty&gt; &lt;val2&gt;             <i>; yields ty</i>
+  &lt;result&gt; = select <i>selty</i> &lt;cond&gt;, &lt;ty&gt; &lt;val1&gt;, &lt;ty&gt; &lt;val2&gt;             <i>; yields ty</i>
+
+  <i>selty</i> is either i1 or {&lt;N x i1&gt}
 </pre>
 
 <h5>Overview:</h5>
@@ -4113,18 +4185,25 @@ condition, without branching.
 <h5>Arguments:</h5>
 
 <p>
-The '<tt>select</tt>' instruction requires an 'i1' value indicating the
+The '<tt>select</tt>' instruction requires an 'i1' value or
+a vector of 'i1' values indicating the
 condition, and two values of the same <a href="#t_firstclass">first class</a>
-type.  If the val1/val2 are vectors, the entire vectors are selected, not
+type.  If the val1/val2 are vectors and
+the condition is a scalar, then entire vectors are selected, not
 individual elements.
 </p>
 
 <h5>Semantics:</h5>
 
 <p>
-If the i1 condition evaluates is 1, the instruction returns the first
+If the condition is an i1 and it evaluates to 1, the instruction returns the first
 value argument; otherwise, it returns the second value argument.
 </p>
+<p>
+If the condition is a vector of i1, then the value arguments must
+be vectors of the same size, and the selection is done element 
+by element.
+</p>
 
 <h5>Example:</h5>