Constants never get names.
[oota-llvm.git] / docs / ProgrammersManual.html
index c554c74963b643711c1b6f3074dfebfe5f7cdc72..6fc0ec211256f2799e2d2f05f680a99f1ac0ee3f 100644 (file)
   <li><a href="#introduction">Introduction</a></li>
   <li><a href="#general">General Information</a>
     <ul>
-      <li><a href="#stl">The C++ Standard Template Library</a><!--
-    <li>The <tt>-time-passes</tt> option
-    <li>How to use the LLVM Makefile system
-    <li>How to write a regression test
---> </li>
+      <li><a href="#stl">The C++ Standard Template Library</a></li>
+<!--
+      <li>The <tt>-time-passes</tt> option</li>
+      <li>How to use the LLVM Makefile system</li>
+      <li>How to write a regression test</li>
+
+--> 
     </ul>
   </li>
   <li><a href="#apis">Important and useful LLVM APIs</a>
@@ -34,10 +36,11 @@ and the <tt>-debug-only</tt> option</a> </li>
         </ul>
       </li>
       <li><a href="#Statistic">The <tt>Statistic</tt> template &amp; <tt>-stats</tt>
-option</a><!--
-    <li>The <tt>InstVisitor</tt> template
-    <li>The general graph API
---> </li>
+option</a></li>
+<!--
+      <li>The <tt>InstVisitor</tt> template
+      <li>The general graph API
+--> 
     </ul>
   </li>
   <li><a href="#common">Helpful Hints for Common Operations</a>
@@ -68,6 +71,7 @@ use-def chains</a> </li>
           <li><a href="#schanges_replacing">Replacing an                <tt>Instruction</tt>
 with another <tt>Value</tt></a> </li>
         </ul>
+      </li>
 <!--
     <li>Working with the Control Flow Graph
     <ul>
@@ -75,44 +79,47 @@ with another <tt>Value</tt></a> </li>
       <li>
       <li>
     </ul>
---> </li>
+--> 
     </ul>
   </li>
   <li><a href="#coreclasses">The Core LLVM Class Hierarchy Reference</a>
     <ul>
-    <li><a href="#Value">The <tt>Value</tt> class</a>
-      <ul>
-      <li><a href="#User">The <tt>User</tt> class</a>
+      <li><a href="#Value">The <tt>Value</tt> class</a>
         <ul>
-          <li><a href="#Instruction">The <tt>Instruction</tt> class</a>
+          <li><a href="#User">The <tt>User</tt> class</a>
             <ul>
-             <li><a href="#GetElementPtrInst">The <tt>GetElementPtrInst</tt>
-                   class</a></li>
-            </ul></li>
-          <li><a href="#Module">The <tt>Module</tt> class</a></li>
-          <li><a href="#Constant">The <tt>Constant</tt> class</a>
-           <ul>
-             <li><a href="#GlobalValue">The <tt>GlobalValue</tt> class</a>
-             <ul>
-               <li><a href="#BasicBlock">The <tt>BasicBlock</tt>class</a></li>
-               <li><a href="#Function">The <tt>Function</tt> class</a></li>
-               <li><a href="#GlobalVariable">The <tt>GlobalVariable</tt> class
-                 </a></li>
-             </ul></li>
+              <li><a href="#Instruction">The <tt>Instruction</tt> class</a>
+                <ul>
+                  <li><a href="#GetElementPtrInst">The <tt>GetElementPtrInst</tt> class</a></li>
+                </ul>
+              </li>
+              <li><a href="#Module">The <tt>Module</tt> class</a></li>
+              <li><a href="#Constant">The <tt>Constant</tt> class</a>
+               <ul>
+                  <li><a href="#GlobalValue">The <tt>GlobalValue</tt> class</a>
+                    <ul>
+                      <li><a href="#BasicBlock">The <tt>BasicBlock</tt>class</a></li>
+                      <li><a href="#Function">The <tt>Function</tt> class</a></li>
+                      <li><a href="#GlobalVariable">The <tt>GlobalVariable</tt> class</a></li>
+                    </ul>
+                  </li>
+                </ul>
+              </li>
            </ul>
          </li>
           <li><a href="#Type">The <tt>Type</tt> class</a> </li>
           <li><a href="#Argument">The <tt>Argument</tt> class</a></li>
-        </ul></li>
-    </ul></li>
-    <li><a href="#SymbolTable">The <tt>SymbolTable</tt> class </a></li>
-    <li>The <tt>ilist</tt> and <tt>iplist</tt> classes
-      <ul>
-       <li>Creating, inserting, moving and deleting from LLVM lists </li>
-      </ul>
-    </li>
-    <li>Important iterator invalidation semantics to be aware of.</li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+  <li><a href="#SymbolTable">The <tt>SymbolTable</tt> class </a></li>
+  <li>The <tt>ilist</tt> and <tt>iplist</tt> classes
+    <ul>
+      <li>Creating, inserting, moving and deleting from LLVM lists </li>
+    </ul>
   </li>
+  <li>Important iterator invalidation semantics to be aware of.</li>
 </ol>
 
 <div class="doc_author">    
@@ -206,7 +213,7 @@ STL</a>.</li>
 <li><a href="http://www.research.att.com/%7Ebs/C++.html">Bjarne Stroustrup's C++
 Page</a></li>
 
-<li><a href="http://www.linux.com.cn/Bruce_Eckel/TICPPv2/Contents.htm">
+<li><a href="http://64.78.49.204/">
 Bruce Eckel's Thinking in C++, 2nd ed. Volume 2 Revision 4.0 (even better, get
 the book).</a></li>
 
@@ -897,7 +904,7 @@ and <tt>ReplaceInstWithInst</tt>.</p>
     <p>This function replaces all uses (within a basic block) of a given
     instruction with a value, and then removes the original instruction. The
     following example illustrates the replacement of the result of a particular
-    <tt>AllocaInst</tt> that allocates memory for a single integer with an null
+    <tt>AllocaInst</tt> that allocates memory for a single integer with a null
     pointer to an integer.</p>
 
       <pre>AllocaInst* instToReplace = ...;<br>BasicBlock::iterator ii(instToReplace);<br>ReplaceInstWithValue(instToReplace-&gt;getParent()-&gt;getInstList(), ii,<br>                     Constant::getNullValue(PointerType::get(Type::IntTy)));<br></pre></li>
@@ -1085,9 +1092,9 @@ convenient form for direct access.</p></li>
 
   <li><tt>User::op_iterator</tt> - Typedef for iterator over the operand
 list<br>
-    <tt>User::op_const_iterator</tt> <tt>use_iterator op_begin()</tt> -
-Get an iterator to the start of the operand list.<br>
-    <tt>use_iterator op_end()</tt> - Get an iterator to the end of the
+    <tt>op_iterator op_begin()</tt> - Get an iterator to the start of 
+the operand list.<br>
+    <tt>op_iterator op_end()</tt> - Get an iterator to the end of the
 operand list.
     <p> Together, these methods make up the iterator based interface to
 the operands of a <tt>User</tt>.</p></li>
@@ -1666,58 +1673,55 @@ ConstantArray etc for representing the various types of Constants.</p>
 
 <!-- _______________________________________________________________________ -->
 <div class="doc_subsubsection">
-  <a name="m_Value">Important Public Methods</a>
+  <a name="m_Constant">Important Public Methods</a>
 </div>
-
 <div class="doc_text">
+</div>
 
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">Important Subclasses of Constant </div>
+<div class="doc_text">
 <ul>
-    <hr> Important Subclasses of Constant
-    <p> </p>
+  <li>ConstantSInt : This subclass of Constant represents a signed integer 
+  constant.
     <ul>
-      <li>ConstantSInt : This subclass of Constant represents a signed
-integer constant.
-        <ul>
-       <li><tt>int64_t getValue() const</tt>: Returns the underlying value of
-this constant. </li>
-        </ul>
-      </li>
-      <li>ConstantUInt : This class represents an unsigned integer.
-        <ul>
-       <li><tt>uint64_t getValue() const</tt>: Returns the underlying value
-of this constant. </li>
-        </ul>
-      </li>
-      <li>ConstantFP : This class represents a floating point constant.
-        <ul>
-       <li><tt>double getValue() const</tt>: Returns the underlying value of
-this constant. </li>
-        </ul>
-      </li>
-      <li>ConstantBool : This represents a boolean constant.
-        <ul>
-       <li><tt>bool getValue() const</tt>: Returns the underlying value of
-this constant. </li>
-        </ul>
-      </li>
-      <li>ConstantArray : This represents a constant array.
-        <ul>
-       <li><tt>const std::vector&lt;Use&gt; &amp;getValues() const</tt>:
-Returns a Vecotr of component constants that makeup this array. </li>
-        </ul>
-      </li>
-      <li>ConstantStruct : This represents a constant struct.
-        <ul>
-       <li><tt>const std::vector&lt;Use&gt; &amp;getValues() const</tt>:
-Returns a Vecotr of component constants that makeup this array. </li>
-        </ul>
-      </li>
-      <li>GlobalValue : This represents either a global variable or a
-      function. In either case, the value is a constant fixed address
-      (after linking). 
-      </li>
+      <li><tt>int64_t getValue() const</tt>: Returns the underlying value of
+      this constant. </li>
+    </ul>
+  </li>
+  <li>ConstantUInt : This class represents an unsigned integer.
+    <ul>
+      <li><tt>uint64_t getValue() const</tt>: Returns the underlying value of 
+      this constant. </li>
     </ul>
   </li>
+  <li>ConstantFP : This class represents a floating point constant.
+    <ul>
+      <li><tt>double getValue() const</tt>: Returns the underlying value of 
+      this constant. </li>
+    </ul>
+  </li>
+  <li>ConstantBool : This represents a boolean constant.
+    <ul>
+      <li><tt>bool getValue() const</tt>: Returns the underlying value of this 
+      constant. </li>
+    </ul>
+  </li>
+  <li>ConstantArray : This represents a constant array.
+    <ul>
+      <li><tt>const std::vector&lt;Use&gt; &amp;getValues() const</tt>: Returns 
+      a vector of component constants that makeup this array. </li>
+    </ul>
+  </li>
+  <li>ConstantStruct : This represents a constant struct.
+    <ul>
+      <li><tt>const std::vector&lt;Use&gt; &amp;getValues() const</tt>: Returns 
+      a vector of component constants that makeup this array. </li>
+    </ul>
+  </li>
+  <li>GlobalValue : This represents either a global variable or a function. In 
+  either case, the value is a constant fixed address (after linking). 
+  </li>
 </ul>
 </div>
 
@@ -1768,42 +1772,43 @@ types.</p>
   <li><tt>isLosslesslyConvertableTo (const Type *Ty) const</tt>: Return true if
   this type can be converted to 'Ty' without any reinterpretation of bits. For
   example, uint to int or one pointer type to another.</li>
+</ul>
+</div>
 
-<br>
-    <p>Derived Types</p>
-
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">
+  <a name="m_Value">Important Derived Types</a>
+</div>
+<div class="doc_text">
+<ul>
+  <li>SequentialType : This is subclassed by ArrayType and PointerType
     <ul>
-      <li>SequentialType : This is subclassed by ArrayType and PointerType
-        <ul>
-       <li><tt>const Type * getElementType() const</tt>: Returns the type of
-each of the elements in the sequential type. </li>
-        </ul>
-      </li>
-      <li>ArrayType : This is a subclass of SequentialType and defines
-interface for array types.
-        <ul>
-       <li><tt>unsigned getNumElements() const</tt>: Returns the number of
-elements in the array. </li>
-        </ul>
-      </li>
-      <li>PointerType : Subclass of SequentialType for  pointer types. </li>
-      <li>StructType : subclass of DerivedTypes for struct types </li>
-      <li>FunctionType : subclass of DerivedTypes for function types.
-        <ul>
-         <li><tt>bool isVarArg() const</tt>: Returns true if its a vararg
-          function</li>
-          <li><tt> const Type * getReturnType() const</tt>: Returns the
-          return type of the function.</li>
-          <li><tt>const Type * getParamType (unsigned i)</tt>: Returns
-          the type of the ith parameter.</li>
-          <li><tt> const unsigned getNumParams() const</tt>: Returns the
-          number of formal parameters.</li>
-        </ul>
-      </li>
+      <li><tt>const Type * getElementType() const</tt>: Returns the type of each
+      of the elements in the sequential type. </li>
+    </ul>
+  </li>
+  <li>ArrayType : This is a subclass of SequentialType and defines interface for
+  array types.
+    <ul>
+      <li><tt>unsigned getNumElements() const</tt>: Returns the number of 
+      elements in the array. </li>
+    </ul>
+  </li>
+  <li>PointerType : Subclass of SequentialType for  pointer types. </li>
+  <li>StructType : subclass of DerivedTypes for struct types </li>
+  <li>FunctionType : subclass of DerivedTypes for function types.
+    <ul>
+      <li><tt>bool isVarArg() const</tt>: Returns true if its a vararg
+      function</li>
+      <li><tt> const Type * getReturnType() const</tt>: Returns the
+      return type of the function.</li>
+      <li><tt>const Type * getParamType (unsigned i)</tt>: Returns
+      the type of the ith parameter.</li>
+      <li><tt> const unsigned getNumParams() const</tt>: Returns the
+      number of formal parameters.</li>
     </ul>
   </li>
 </ul>
-
 </div>
 
 <!-- ======================================================================= -->
@@ -1814,7 +1819,7 @@ elements in the array. </li>
 <div class="doc_text">
 
 <p>This subclass of Value defines the interface for incoming formal
-arguments to a function. A Function maitanis a list of its formal
+arguments to a function. A Function maintains a list of its formal
 arguments. An argument has a pointer to the parent Function.</p>
 
 </div>
@@ -1939,36 +1944,37 @@ however, are stored in a single dimension and accessed only by name.</p>
 the beginning or end of the sequence for both const and non-const. It is
 important to keep track of the different kinds of iterators. There are
 three idioms worth pointing out:</p>
-<table class="doc_table">
+<table>
   <tr><th>Units</th><th>Iterator</th><th>Idiom</th></tr>
   <tr>
-    <td>Planes Of name/Value maps</td><td>PI</td>
-    <td><tt><pre>
+    <td align="left">Planes Of name/Value maps</td><td>PI</td>
+    <td align="left"><pre><tt>
 for (SymbolTable::plane_const_iterator PI = ST.plane_begin(),
-PE = ST.plane_end(); PI != PE; ++PI ) {
+     PE = ST.plane_end(); PI != PE; ++PI ) {
   PI-&gt;first // This is the Type* of the plane
   PI-&gt;second // This is the SymbolTable::ValueMap of name/Value pairs
-    </pre></tt></td>
+    </tt></pre></td>
   </tr>
   <tr>
-    <td>All name/Type Pairs</td><td>TI</td>
-    <td><tt><pre>
+    <td align="left">All name/Type Pairs</td><td>TI</td>
+    <td align="left"><pre><tt>
 for (SymbolTable::type_const_iterator TI = ST.type_begin(),
      TE = ST.type_end(); TI != TE; ++TI )
   TI-&gt;first  // This is the name of the type
   TI-&gt;second // This is the Type* value associated with the name
-    </pre></tt></td>
+    </tt></pre></td>
   </tr>
   <tr>
-    <td>name/Value pairs in a plane</td><td>VI</td>
-    <td><tt><pre>
+    <td align="left">name/Value pairs in a plane</td><td>VI</td>
+    <td align="left"><pre><tt>
 for (SymbolTable::value_const_iterator VI = ST.value_begin(SomeType),
      VE = ST.value_end(SomeType); VI != VE; ++VI )
   VI-&gt;first  // This is the name of the Value
   VI-&gt;second // This is the Value* value associated with the name
-    </pre></tt></td>
+    </tt></pre></td>
   </tr>
 </table>
+
 <p>Using the recommended iterator names and idioms will help you avoid
 making mistakes. Of particular note, make sure that whenever you use
 value_begin(SomeType) that you always compare the resulting iterator