Remove some options that don't really have anything to do with bugpoint
[oota-llvm.git] / docs / LangRef.html
index 3215586f8646cb2e59b90afdf8475ed6fb8c841a..60dba677ba599a0ef1c87b743a2af52abbf7871d 100644 (file)
@@ -80,6 +80,7 @@
         <ol>
           <li><a href="#i_phi">'<tt>phi</tt>'   Instruction</a></li>
           <li><a href="#i_cast">'<tt>cast .. to</tt>' Instruction</a></li>
+          <li><a href="#i_select">'<tt>select</tt>' Instruction</a></li>
           <li><a href="#i_call">'<tt>call</tt>'  Instruction</a></li>
           <li><a href="#i_vanext">'<tt>vanext</tt>' Instruction</a></li>
           <li><a href="#i_vaarg">'<tt>vaarg</tt>'  Instruction</a></li>
@@ -188,7 +189,7 @@ character can be used   in a name.</li>
   <li>Unnamed values are represented as an unsigned numeric value with
 a '%'   prefix.  For example, %12, %2, %44.</li>
 </ol>
-<p>LLVM requires the values start with a '%' sign for two reasons:
+<p>LLVM requires that values start with a '%' sign for two reasons:
 Compilers don't need to worry about name clashes with reserved words,
 and the set of reserved words may be expanded in the future without
 penalty.  Additionally, unnamed identifiers allow a compiler to quickly
@@ -1422,58 +1423,103 @@ at the location specified by the '<tt>&lt;pointer&gt;</tt>' operand.</p>
   %val = load int* %ptr                           <i>; yields {int}:val = int 3</i>
 </pre>
 <!-- _______________________________________________________________________ -->
-<div class="doc_subsubsection"> <a name="i_getelementptr">'<tt>getelementptr</tt>'
-Instruction</a> </div>
+<div class="doc_subsubsection">
+   <a name="i_getelementptr">'<tt>getelementptr</tt>' Instruction</a>
+</div>
+
 <div class="doc_text">
 <h5>Syntax:</h5>
-<pre>  &lt;result&gt; = getelementptr &lt;ty&gt;* &lt;ptrval&gt;{, long &lt;aidx&gt;|, ubyte &lt;sidx&gt;}*<br></pre>
+<pre>
+  &lt;result&gt; = getelementptr &lt;ty&gt;* &lt;ptrval&gt;{, &lt;ty&gt; &lt;idx&gt;}*
+</pre>
+
 <h5>Overview:</h5>
-<p>The '<tt>getelementptr</tt>' instruction is used to get the address
-of a subelement of an aggregate data structure.</p>
+
+<p>
+The '<tt>getelementptr</tt>' instruction is used to get the address of a
+subelement of an aggregate data structure.</p>
+
 <h5>Arguments:</h5>
-<p>This instruction takes a list of <tt>long</tt> values and <tt>ubyte</tt>
-constants that indicate what form of addressing to perform.  The actual
-types of the arguments provided depend on the type of the first pointer
-argument.  The '<tt>getelementptr</tt>' instruction is used to index
-down through the type levels of a structure.</p>
+
+<p>This instruction takes a list of integer constants that indicate what
+elements of the aggregate object to index to.  The actual types of the arguments
+provided depend on the type of the first pointer argument.  The
+'<tt>getelementptr</tt>' instruction is used to index down through the type
+levels of a structure.  When indexing into a structure, only <tt>uint</tt>
+integer constants are allowed.  When indexing into an array or pointer
+<tt>int</tt> and <tt>long</tt> indexes are allowed of any sign.</p>
+
 <p>For example, let's consider a C code fragment and how it gets
 compiled to LLVM:</p>
-<pre>struct RT {<br>  char A;<br>  int B[10][20];<br>  char C;<br>};<br>struct ST {<br>  int X;<br>  double Y;<br>  struct RT Z;<br>};<br><br>int *foo(struct ST *s) {<br>  return &amp;s[1].Z.B[5][13];<br>}<br></pre>
+
+<pre>
+  struct RT {
+    char A;
+    int B[10][20];
+    char C;
+  };
+  struct ST {
+    int X;
+    double Y;
+    struct RT Z;
+  };
+
+  int *foo(struct ST *s) {
+    return &amp;s[1].Z.B[5][13];
+  }
+</pre>
+
 <p>The LLVM code generated by the GCC frontend is:</p>
-<pre>%RT = type { sbyte, [10 x [20 x int]], sbyte }<br>%ST = type { int, double, %RT }<br><br>int* "foo"(%ST* %s) {<br>  %reg = getelementptr %ST* %s, long 1, ubyte 2, ubyte 1, long 5, long 13<br>  ret int* %reg<br>}<br></pre>
+
+<pre>
+  %RT = type { sbyte, [10 x [20 x int]], sbyte }
+  %ST = type { int, double, %RT }
+
+  int* "foo"(%ST* %s) {
+    %reg = getelementptr %ST* %s, int 1, uint 2, uint 1, int 5, int 13<br>
+    ret int* %reg
+  }
+</pre>
+
 <h5>Semantics:</h5>
-<p>The index types specified for the '<tt>getelementptr</tt>'
-instruction depend on the pointer type that is being index into. <a
- href="t_pointer">Pointer</a> and <a href="t_array">array</a> types
-require '<tt>long</tt>' values, and <a href="t_struct">structure</a>
-types require '<tt>ubyte</tt>' <b>constants</b>.</p>
+
+<p>The index types specified for the '<tt>getelementptr</tt>' instruction depend
+on the pointer type that is being index into. <a href="t_pointer">Pointer</a>
+and <a href="t_array">array</a> types require <tt>uint</tt>, <tt>int</tt>,
+<tt>ulong</tt>, or <tt>long</tt> values, and <a href="t_struct">structure</a>
+types require <tt>uint</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>{ int,
-double, %RT }</tt>' type, a structure.  The second index indexes into
-the third element of the structure, yielding a '<tt>%RT</tt>' = '<tt>{
-sbyte, [10 x [20 x int]], sbyte }</tt>' type, another structure.  The
-third index indexes into the second element of the structure, yielding
-a '<tt>[10 x [20 x int]]</tt>' type, an array.  The two dimensions of
-the array are subscripted into, yielding an '<tt>int</tt>' type.  The '<tt>getelementptr</tt>'
-instruction return a pointer to this element, thus yielding a '<tt>int*</tt>'
-type.</p>
+type, which is a pointer, yielding a '<tt>%ST</tt>' = '<tt>{ int, double, %RT
+}</tt>' type, a structure.  The second index indexes into the third element of
+the structure, yielding a '<tt>%RT</tt>' = '<tt>{ sbyte, [10 x [20 x int]],
+sbyte }</tt>' type, another structure.  The third index indexes into the second
+element of the structure, yielding a '<tt>[10 x [20 x int]]</tt>' type, an
+array.  The two dimensions of the array are subscripted into, yielding an
+'<tt>int</tt>' type.  The '<tt>getelementptr</tt>' instruction return a pointer
+to this element, thus computing a value of '<tt>int*</tt>' type.</p>
+
 <p>Note that it is perfectly legal to index partially through a
 structure, returning a pointer to an inner element.  Because of this,
 the LLVM code for the given testcase is equivalent to:</p>
-<pre>int* "foo"(%ST* %s) {<br>  %t1 = getelementptr %ST* %s , long 1                        <i>; yields %ST*:%t1</i>
-  %t2 = getelementptr %ST* %t1, long 0, ubyte 2               <i>; yields %RT*:%t2</i>
-  %t3 = getelementptr %RT* %t2, long 0, ubyte 1               <i>; yields [10 x [20 x int]]*:%t3</i>
-  %t4 = getelementptr [10 x [20 x int]]* %t3, long 0, long 5  <i>; yields [20 x int]*:%t4</i>
-  %t5 = getelementptr [20 x int]* %t4, long 0, long 13        <i>; yields int*:%t5</i>
-  ret int* %t5
-}
+
+<pre>
+  int* "foo"(%ST* %s) {
+    %t1 = getelementptr %ST* %s, int 1                        <i>; yields %ST*:%t1</i>
+    %t2 = getelementptr %ST* %t1, int 0, uint 2               <i>; yields %RT*:%t2</i>
+    %t3 = getelementptr %RT* %t2, int 0, uint 1               <i>; yields [10 x [20 x int]]*:%t3</i>
+    %t4 = getelementptr [10 x [20 x int]]* %t3, int 0, int 5  <i>; yields [20 x int]*:%t4</i>
+    %t5 = getelementptr [20 x int]* %t4, int 0, int 13        <i>; yields int*:%t5</i>
+    ret int* %t5
+  }
 </pre>
 <h5>Example:</h5>
-<pre>  <i>; yields [12 x ubyte]*:aptr</i>
-  %aptr = getelementptr {int, [12 x ubyte]}* %sptr, long 0, ubyte 1<br></pre>
-<h5>&nbsp;Note To The Novice:</h5>
-When using indexing into global arrays with the  '<tt>getelementptr</tt>'
-instruction, you must remember that the&nbsp; </div>
+<pre>
+    <i>; yields [12 x ubyte]*:aptr</i>
+    %aptr = getelementptr {int, [12 x ubyte]}* %sptr, long 0, uint 1
+</pre>
+
+</div>
 <!-- ======================================================================= -->
 <div class="doc_subsection"> <a name="otherops">Other Operations</a> </div>
 <div class="doc_text">
@@ -1506,38 +1552,111 @@ came from in the last <a href="#terminators">terminator</a> instruction.</p>
 <h5>Example:</h5>
 <pre>Loop:       ; Infinite loop that counts from 0 on up...<br>  %indvar = phi uint [ 0, %LoopHeader ], [ %nextindvar, %Loop ]<br>  %nextindvar = add uint %indvar, 1<br>  br label %Loop<br></pre>
 </div>
+
 <!-- _______________________________________________________________________ -->
-<div class="doc_subsubsection"> <a name="i_cast">'<tt>cast .. to</tt>'
-Instruction</a> </div>
+<div class="doc_subsubsection">
+   <a name="i_cast">'<tt>cast .. to</tt>' Instruction</a>
+</div>
+
 <div class="doc_text">
+
 <h5>Syntax:</h5>
-<pre>  &lt;result&gt; = cast &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
+
+<pre>
+  &lt;result&gt; = cast &lt;ty&gt; &lt;value&gt; to &lt;ty2&gt;             <i>; yields ty2</i>
 </pre>
+
 <h5>Overview:</h5>
-<p>The '<tt>cast</tt>' instruction is used as the primitive means to
-convert integers to floating point, change data type sizes, and break
-type safety (by casting pointers).</p>
+
+<p>
+The '<tt>cast</tt>' instruction is used as the primitive means to convert
+integers to floating point, change data type sizes, and break type safety (by
+casting pointers).
+</p>
+
+
 <h5>Arguments:</h5>
-<p>The '<tt>cast</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.</p>
+
+<p>
+The '<tt>cast</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.
+</p>
+
 <h5>Semantics:</h5>
-<p>This instruction follows the C rules for explicit casts when
-determining how the data being cast must change to fit in its new
-container.</p>
-<p>When casting to bool, any value that would be considered true in the
-context of a C '<tt>if</tt>' condition is converted to the boolean '<tt>true</tt>'
-values, all else are '<tt>false</tt>'.</p>
-<p>When extending an integral value from a type of one signness to
-another (for example '<tt>sbyte</tt>' to '<tt>ulong</tt>'), the value
-is sign-extended if the <b>source</b> value is signed, and
-zero-extended if the source value is unsigned. <tt>bool</tt> values
-are always zero extended into either zero or one.</p>
+
+<p>
+This instruction follows the C rules for explicit casts when determining how the
+data being cast must change to fit in its new container.
+</p>
+
+<p>
+When casting to bool, any value that would be considered true in the context of
+a C '<tt>if</tt>' condition is converted to the boolean '<tt>true</tt>' values,
+all else are '<tt>false</tt>'.
+</p>
+
+<p>
+When extending an integral value from a type of one signness to another (for
+example '<tt>sbyte</tt>' to '<tt>ulong</tt>'), the value is sign-extended if the
+<b>source</b> value is signed, and zero-extended if the source value is
+unsigned. <tt>bool</tt> values are always zero extended into either zero or
+one.
+</p>
+
 <h5>Example:</h5>
-<pre>  %X = cast int 257 to ubyte              <i>; yields ubyte:1</i>
+
+<pre>
+  %X = cast int 257 to ubyte              <i>; yields ubyte:1</i>
   %Y = cast int 123 to bool               <i>; yields bool:true</i>
 </pre>
 </div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">
+   <a name="i_select">'<tt>select</tt>' Instruction</a>
+</div>
+
+<div class="doc_text">
+
+<h5>Syntax:</h5>
+
+<pre>
+  &lt;result&gt; = select bool &lt;cond&gt;, &lt;ty&gt; &lt;val1&gt;, &lt;ty&gt; &lt;val2&gt;             <i>; yields ty</i>
+</pre>
+
+<h5>Overview:</h5>
+
+<p>
+The '<tt>select</tt>' instruction is used to choose one value based on a
+condition, without branching.
+</p>
+
+
+<h5>Arguments:</h5>
+
+<p>
+The '<tt>select</tt>' instruction requires a boolean value indicating the condition, and two values of the same <a href="#t_firstclass">first class</a> type.
+</p>
+
+<h5>Semantics:</h5>
+
+<p>
+If the boolean condition evaluates to true, the instruction returns the first
+value argument, otherwise it returns the second value argument.
+</p>
+
+<h5>Example:</h5>
+
+<pre>
+  %X = select bool true, ubyte 17, ubyte 42          <i>; yields ubyte:17</i>
+</pre>
+</div>
+
+
+
+
+
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsubsection"> <a name="i_call">'<tt>call</tt>'
 Instruction</a> </div>