</h2>
<!-- *********************************************************************** -->
-<div class="doc_text">
+<div>
<p>This document is meant to highlight some of the important classes and
interfaces available in the LLVM source-base. This manual is not
</h2>
<!-- *********************************************************************** -->
-<div class="doc_text">
+<div>
<p>This section contains general information that is useful if you are working
in the LLVM source-base, but that isn't specific to any particular API.</p>
-</div>
-
<!-- ======================================================================= -->
<h3>
<a name="stl">The C++ Standard Template Library</a>
</h3>
-<div class="doc_text">
+<div>
<p>LLVM makes heavy use of the C++ Standard Template Library (STL),
perhaps much more than you are used to, or have seen before. Because of
<a name="stl">Other useful references</a>
</h3>
-<div class="doc_text">
+<div>
<ol>
<li><a href="http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html">Using
</div>
+</div>
+
<!-- *********************************************************************** -->
<h2>
<a name="apis">Important and useful LLVM APIs</a>
</h2>
<!-- *********************************************************************** -->
-<div class="doc_text">
+<div>
<p>Here we highlight some LLVM APIs that are generally useful and good to
know about when writing transformations.</p>
-</div>
-
<!-- ======================================================================= -->
<h3>
<a name="isa">The <tt>isa<></tt>, <tt>cast<></tt> and
<tt>dyn_cast<></tt> templates</a>
</h3>
-<div class="doc_text">
+<div>
<p>The LLVM source-base makes extensive use of a custom form of RTTI.
These templates have many similarities to the C++ <tt>dynamic_cast<></tt>
and <tt>Twine</tt> classes)</a>
</h3>
-<div class="doc_text">
+<div>
<p>Although LLVM generally does not do much string manipulation, we do have
several important APIs which take strings. Two important examples are the
many LLVM APIs use a <tt>StringRef</tt> or a <tt>const Twine&</tt> for
passing strings efficiently.</p>
-</div>
-
<!-- _______________________________________________________________________ -->
<h4>
<a name="StringRef">The <tt>StringRef</tt> class</a>
</h4>
-<div class="doc_text">
+<div>
<p>The <tt>StringRef</tt> data type represents a reference to a constant string
(a character array and a length) and supports the common operations available
<a name="Twine">The <tt>Twine</tt> class</a>
</h4>
-<div class="doc_text">
+<div>
<p>The <tt>Twine</tt> class is an efficient way for APIs to accept concatenated
strings. For example, a common LLVM paradigm is to name one instruction based on
</div>
+</div>
<!-- ======================================================================= -->
<h3>
<a name="DEBUG">The <tt>DEBUG()</tt> macro and <tt>-debug</tt> option</a>
</h3>
-<div class="doc_text">
+<div>
<p>Often when working on your pass you will put a bunch of debugging printouts
and other code into your pass. After you get it working, you want to remove
program hasn't been started yet, you can always just run it with
<tt>-debug</tt>.</p>
-</div>
-
<!-- _______________________________________________________________________ -->
<h4>
<a name="DEBUG_TYPE">Fine grained debug info with <tt>DEBUG_TYPE</tt> and
the <tt>-debug-only</tt> option</a>
</h4>
-<div class="doc_text">
+<div>
<p>Sometimes you may find yourself in a situation where enabling <tt>-debug</tt>
just turns on <b>too much</b> information (such as when working on the code
</div>
+</div>
+
<!-- ======================================================================= -->
<h3>
<a name="Statistic">The <tt>Statistic</tt> class & <tt>-stats</tt>
option</a>
</h3>
-<div class="doc_text">
+<div>
<p>The "<tt><a
href="/doxygen/Statistic_8h-source.html">llvm/ADT/Statistic.h</a></tt>" file
<a name="ViewGraph">Viewing graphs while debugging code</a>
</h3>
-<div class="doc_text">
+<div>
<p>Several of the important data structures in LLVM are graphs: for example
CFGs made out of LLVM <a href="#BasicBlock">BasicBlock</a>s, CFGs made out of
</div>
+</div>
+
<!-- *********************************************************************** -->
<h2>
<a name="datastructure">Picking the Right Data Structure for a Task</a>
</h2>
<!-- *********************************************************************** -->
-<div class="doc_text">
+<div>
<p>LLVM has a plethora of data structures in the <tt>llvm/ADT/</tt> directory,
and we commonly use STL data structures. This section describes the trade-offs
. Doing so avoids (relatively) expensive malloc/free calls, which dwarf the
cost of adding the elements to the container. </p>
-</div>
-
<!-- ======================================================================= -->
<h3>
<a name="ds_sequential">Sequential Containers (std::vector, std::list, etc)</a>
</h3>
-<div class="doc_text">
+<div>
There are a variety of sequential containers available for you, based on your
needs. Pick the first in this section that will do what you want.
-</div>
<!-- _______________________________________________________________________ -->
<h4>
<a name="dss_arrayref">llvm/ADT/ArrayRef.h</a>
</h4>
-<div class="doc_text">
+<div>
<p>The llvm::ArrayRef class is the preferred class to use in an interface that
accepts a sequential list of elements in memory and just reads from them. By
taking an ArrayRef, the API can be passed a fixed size array, an std::vector,
<a name="dss_fixedarrays">Fixed Size Arrays</a>
</h4>
-<div class="doc_text">
+<div>
<p>Fixed size arrays are very simple and very fast. They are good if you know
exactly how many elements you have, or you have a (low) upper bound on how many
you have.</p>
<a name="dss_heaparrays">Heap Allocated Arrays</a>
</h4>
-<div class="doc_text">
+<div>
<p>Heap allocated arrays (new[] + delete[]) are also simple. They are good if
the number of elements is variable, if you know how many elements you will need
before the array is allocated, and if the array is usually large (if not,
<a name="dss_smallvector">"llvm/ADT/SmallVector.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p><tt>SmallVector<Type, N></tt> is a simple class that looks and smells
just like <tt>vector<Type></tt>:
it supports efficient iteration, lays out elements in memory order (so you can
<a name="dss_vector"><vector></a>
</h4>
-<div class="doc_text">
+<div>
<p>
std::vector is well loved and respected. It is useful when SmallVector isn't:
when the size of the vector is often large (thus the small optimization will
<a name="dss_deque"><deque></a>
</h4>
-<div class="doc_text">
+<div>
<p>std::deque is, in some senses, a generalized version of std::vector. Like
std::vector, it provides constant time random access and other similar
properties, but it also provides efficient access to the front of the list. It
<a name="dss_list"><list></a>
</h4>
-<div class="doc_text">
+<div>
<p>std::list is an extremely inefficient class that is rarely useful.
It performs a heap allocation for every element inserted into it, thus having an
extremely high constant factor, particularly for small data types. std::list
<a name="dss_ilist">llvm/ADT/ilist.h</a>
</h4>
-<div class="doc_text">
+<div>
<p><tt>ilist<T></tt> implements an 'intrusive' doubly-linked list. It is
intrusive, because it requires the element to store and provide access to the
prev/next pointers for the list.</p>
<a name="dss_ilist_traits">ilist_traits</a>
</h4>
-<div class="doc_text">
+<div>
<p><tt>ilist_traits<T></tt> is <tt>ilist<T></tt>'s customization
mechanism. <tt>iplist<T></tt> (and consequently <tt>ilist<T></tt>)
publicly derive from this traits class.</p>
<a name="dss_iplist">iplist</a>
</h4>
-<div class="doc_text">
+<div>
<p><tt>iplist<T></tt> is <tt>ilist<T></tt>'s base and as such
supports a slightly narrower interface. Notably, inserters from
<tt>T&</tt> are absent.</p>
<a name="dss_ilist_node">llvm/ADT/ilist_node.h</a>
</h4>
-<div class="doc_text">
+<div>
<p><tt>ilist_node<T></tt> implements a the forward and backward links
that are expected by the <tt>ilist<T></tt> (and analogous containers)
in the default manner.</p>
<a name="dss_ilist_sentinel">Sentinels</a>
</h4>
-<div class="doc_text">
+<div>
<p><tt>ilist</tt>s have another specialty that must be considered. To be a good
citizen in the C++ ecosystem, it needs to support the standard container
operations, such as <tt>begin</tt> and <tt>end</tt> iterators, etc. Also, the
<a name="dss_other">Other Sequential Container options</a>
</h4>
-<div class="doc_text">
+<div>
<p>Other STL containers are available, such as std::string.</p>
<p>There are also various STL adapter classes such as std::queue,
</div>
+</div>
<!-- ======================================================================= -->
<h3>
<a name="ds_set">Set-Like Containers (std::set, SmallSet, SetVector, etc)</a>
</h3>
-<div class="doc_text">
+<div>
<p>Set-like containers are useful when you need to canonicalize multiple values
into a single representation. There are several different choices for how to do
this, providing various trade-offs.</p>
-</div>
-
-
<!-- _______________________________________________________________________ -->
<h4>
<a name="dss_sortedvectorset">A sorted 'vector'</a>
</h4>
-<div class="doc_text">
+<div>
<p>If you intend to insert a lot of elements, then do a lot of queries, a
great approach is to use a vector (or other sequential container) with
<a name="dss_smallset">"llvm/ADT/SmallSet.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p>If you have a set-like data structure that is usually small and whose elements
are reasonably small, a <tt>SmallSet<Type, N></tt> is a good choice. This set
<a name="dss_smallptrset">"llvm/ADT/SmallPtrSet.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p>SmallPtrSet has all the advantages of <tt>SmallSet</tt> (and a <tt>SmallSet</tt> of pointers is
transparently implemented with a <tt>SmallPtrSet</tt>), but also supports iterators. If
<a name="dss_denseset">"llvm/ADT/DenseSet.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p>
DenseSet is a simple quadratically probed hash table. It excels at supporting
<a name="dss_FoldingSet">"llvm/ADT/FoldingSet.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p>
FoldingSet is an aggregate class that is really good at uniquing
<a name="dss_set"><set></a>
</h4>
-<div class="doc_text">
+<div>
<p><tt>std::set</tt> is a reasonable all-around set class, which is decent at
many things but great at nothing. std::set allocates memory for each element
<a name="dss_setvector">"llvm/ADT/SetVector.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p>LLVM's SetVector<Type> is an adapter class that combines your choice of
a set-like container along with a <a href="#ds_sequential">Sequential
Container</a>. The important property
<a name="dss_uniquevector">"llvm/ADT/UniqueVector.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p>
UniqueVector is similar to <a href="#dss_setvector">SetVector</a>, but it
<a name="dss_otherset">Other Set-Like Container Options</a>
</h4>
-<div class="doc_text">
+<div>
<p>
The STL provides several other options, such as std::multiset and the various
</div>
+</div>
+
<!-- ======================================================================= -->
<h3>
<a name="ds_map">Map-Like Containers (std::map, DenseMap, etc)</a>
</h3>
-<div class="doc_text">
+<div>
Map-like containers are useful when you want to associate data to a key. As
usual, there are a lot of different ways to do this. :)
-</div>
<!-- _______________________________________________________________________ -->
<h4>
<a name="dss_sortedvectormap">A sorted 'vector'</a>
</h4>
-<div class="doc_text">
+<div>
<p>
If your usage pattern follows a strict insert-then-query approach, you can
<a name="dss_stringmap">"llvm/ADT/StringMap.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p>
Strings are commonly used as keys in maps, and they are difficult to support
<a name="dss_indexedmap">"llvm/ADT/IndexedMap.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p>
IndexedMap is a specialized container for mapping small dense integers (or
values that can be mapped to small dense integers) to some other type. It is
<a name="dss_densemap">"llvm/ADT/DenseMap.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p>
DenseMap is a simple quadratically probed hash table. It excels at supporting
<a name="dss_valuemap">"llvm/ADT/ValueMap.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p>
ValueMap is a wrapper around a <a href="#dss_densemap">DenseMap</a> mapping
<a name="dss_intervalmap">"llvm/ADT/IntervalMap.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p> IntervalMap is a compact map for small keys and values. It maps key
intervals instead of single keys, and it will automatically coalesce adjacent
<a name="dss_map"><map></a>
</h4>
-<div class="doc_text">
+<div>
<p>
std::map has similar characteristics to <a href="#dss_set">std::set</a>: it uses
<a name="dss_inteqclasses">"llvm/ADT/IntEqClasses.h"</a>
</h4>
-<div class="doc_text">
+<div>
<p>IntEqClasses provides a compact representation of equivalence classes of
small integers. Initially, each integer in the range 0..n-1 has its own
<a name="dss_othermap">Other Map-Like Container Options</a>
</h4>
-<div class="doc_text">
+<div>
<p>
The STL provides several other options, such as std::multimap and the various
</div>
+</div>
+
<!-- ======================================================================= -->
<h3>
<a name="ds_string">String-like containers</a>
</h3>
-<div class="doc_text">
+<div>
<p>
TODO: const char* vs stringref vs smallstring vs std::string. Describe twine,
<a name="ds_bit">Bit storage containers (BitVector, SparseBitVector)</a>
</h3>
-<div class="doc_text">
+<div>
<p>Unlike the other containers, there are only two bit storage containers, and
choosing when to use each is relatively straightforward.</p>
GCC) is extremely inefficient and 2) the C++ standards committee is likely to
deprecate this container and/or change it significantly somehow. In any case,
please don't use it.</p>
-</div>
<!-- _______________________________________________________________________ -->
<h4>
<a name="dss_bitvector">BitVector</a>
</h4>
-<div class="doc_text">
+<div>
<p> The BitVector container provides a dynamic size set of bits for manipulation.
It supports individual bit setting/testing, as well as set operations. The set
operations take time O(size of bitvector), but operations are performed one word
<a name="dss_smallbitvector">SmallBitVector</a>
</h4>
-<div class="doc_text">
+<div>
<p> The SmallBitVector container provides the same interface as BitVector, but
it is optimized for the case where only a small number of bits, less than
25 or so, are needed. It also transparently supports larger bit counts, but
<a name="dss_sparsebitvector">SparseBitVector</a>
</h4>
-<div class="doc_text">
+<div>
<p> The SparseBitVector container is much like BitVector, with one major
difference: Only the bits that are set, are stored. This makes the
SparseBitVector much more space efficient than BitVector when the set is sparse,
</p>
</div>
+</div>
+
+</div>
+
<!-- *********************************************************************** -->
<h2>
<a name="common">Helpful Hints for Common Operations</a>
</h2>
<!-- *********************************************************************** -->
-<div class="doc_text">
+<div>
<p>This section describes how to perform some very simple transformations of
LLVM code. This is meant to give examples of common idioms used, showing the
<a href="#coreclasses">Core LLVM Class Hierarchy Reference</a> contains details
and descriptions of the main classes that you should know about.</p>
-</div>
-
<!-- NOTE: this section should be heavy on example code -->
<!-- ======================================================================= -->
<h3>
<a name="inspection">Basic Inspection and Traversal Routines</a>
</h3>
-<div class="doc_text">
+<div>
<p>The LLVM compiler infrastructure have many different data structures that may
be traversed. Following the example of the C++ standard template library, the
examples of the data structures that need to be traversed. Other data
structures are traversed in very similar ways.</p>
-</div>
-
<!-- _______________________________________________________________________ -->
<h4>
<a name="iterate_function">Iterating over the </a><a
href="#Function"><tt>Function</tt></a>
</h4>
-<div class="doc_text">
+<div>
<p>It's quite common to have a <tt>Function</tt> instance that you'd like to
transform in some way; in particular, you'd like to manipulate its
href="#BasicBlock"><tt>BasicBlock</tt></a>
</h4>
-<div class="doc_text">
+<div>
<p>Just like when dealing with <tt>BasicBlock</tt>s in <tt>Function</tt>s, it's
easy to iterate over the individual instructions that make up
href="#Function"><tt>Function</tt></a>
</h4>
-<div class="doc_text">
+<div>
<p>If you're finding that you commonly iterate over a <tt>Function</tt>'s
<tt>BasicBlock</tt>s and then that <tt>BasicBlock</tt>'s <tt>Instruction</tt>s,
vice-versa)</a>
</h4>
-<div class="doc_text">
+<div>
<p>Sometimes, it'll be useful to grab a reference (or pointer) to a class
instance when all you've got at hand is an iterator. Well, extracting
example</a>
</h4>
-<div class="doc_text">
+<div>
<p>Say that you're writing a FunctionPass and would like to count all the
locations in the entire module (that is, across every <tt>Function</tt>) where a
<a name="calls_and_invokes">Treating calls and invokes the same way</a>
</h4>
-<div class="doc_text">
+<div>
<p>You may have noticed that the previous example was a bit oversimplified in
that it did not deal with call sites generated by 'invoke' instructions. In
<a name="iterate_chains">Iterating over def-use & use-def chains</a>
</h4>
-<div class="doc_text">
+<div>
<p>Frequently, we might have an instance of the <a
href="/doxygen/classllvm_1_1Value.html">Value Class</a> and we want to
successors of blocks</a>
</h4>
-<div class="doc_text">
+<div>
<p>Iterating over the predecessors and successors of a block is quite easy
with the routines defined in <tt>"llvm/Support/CFG.h"</tt>. Just use code like
</div>
+</div>
<!-- ======================================================================= -->
<h3>
<a name="simplechanges">Making simple changes</a>
</h3>
-<div class="doc_text">
+<div>
<p>There are some primitive transformation operations present in the LLVM
infrastructure that are worth knowing about. When performing
blocks. This section describes some of the common methods for doing so
and gives example code.</p>
-</div>
-
<!--_______________________________________________________________________-->
<h4>
<a name="schanges_creating">Creating and inserting new
<tt>Instruction</tt>s</a>
</h4>
-<div class="doc_text">
+<div>
<p><i>Instantiating Instructions</i></p>
<a name="schanges_deleting">Deleting <tt>Instruction</tt>s</a>
</h4>
-<div class="doc_text">
+<div>
<p>Deleting an instruction from an existing sequence of instructions that form a
<a href="#BasicBlock"><tt>BasicBlock</tt></a> is very straight-forward: just
<tt>Value</tt></a>
</h4>
-<div class="doc_text">
+<div>
<p><i>Replacing individual instructions</i></p>
<a name="schanges_deletingGV">Deleting <tt>GlobalVariable</tt>s</a>
</h4>
-<div class="doc_text">
+<div>
<p>Deleting a global variable from a module is just as easy as deleting an
Instruction. First, you must have a pointer to the global variable that you wish
</div>
+</div>
+
<!-- ======================================================================= -->
<h3>
<a name="create_types">How to Create Types</a>
</h3>
-<div class="doc_text">
+<div>
<p>In generating IR, you may need some complex types. If you know these types
statically, you can use <tt>TypeBuilder<...>::get()</tt>, defined
</div>
+</div>
+
<!-- *********************************************************************** -->
<h2>
<a name="threading">Threads and LLVM</a>
</h2>
<!-- *********************************************************************** -->
-<div class="doc_text">
+<div>
<p>
This section describes the interaction of the LLVM APIs with multithreading,
both on the part of client applications, and in the JIT, in the hosted
using the resultant compiler to build a copy of LLVM with multithreading
support.
</p>
-</div>
<!-- ======================================================================= -->
<h3>
<a name="startmultithreaded">Entering and Exiting Multithreaded Mode</a>
</h3>
-<div class="doc_text">
+<div>
<p>
In order to properly protect its internal data structures while avoiding
<a name="shutdown">Ending Execution with <tt>llvm_shutdown()</tt></a>
</h3>
-<div class="doc_text">
+<div>
<p>
When you are done using the LLVM APIs, you should call <tt>llvm_shutdown()</tt>
to deallocate memory used for internal structures. This will also invoke
<a name="managedstatic">Lazy Initialization with <tt>ManagedStatic</tt></a>
</h3>
-<div class="doc_text">
+<div>
<p>
<tt>ManagedStatic</tt> is a utility class in LLVM used to implement static
initialization of static resources, such as the global type tables. Before the
<a name="llvmcontext">Achieving Isolation with <tt>LLVMContext</tt></a>
</h3>
-<div class="doc_text">
+<div>
<p>
<tt>LLVMContext</tt> is an opaque class in the LLVM API which clients can use
to operate multiple, isolated instances of LLVM concurrently within the same
<a name="jitthreading">Threads and the JIT</a>
</h3>
-<div class="doc_text">
+<div>
<p>
LLVM's "eager" JIT compiler is safe to use in threaded programs. Multiple
threads can call <tt>ExecutionEngine::getPointerToFunction()</tt> or
</p>
</div>
+</div>
+
<!-- *********************************************************************** -->
<h2>
<a name="advanced">Advanced Topics</a>
</h2>
<!-- *********************************************************************** -->
-<div class="doc_text">
+<div>
<p>
This section describes some of the advanced or obscure API's that most clients
do not need to be aware of. These API's tend manage the inner workings of the
LLVM system, and only need to be accessed in unusual circumstances.
</p>
-</div>
<!-- ======================================================================= -->
<h3>
<a name="TypeResolve">LLVM Type Resolution</a>
</h3>
-<div class="doc_text">
+<div>
<p>
The LLVM type system has a very simple goal: allow clients to compare types for
float }</tt>").
</p>
-</div>
-
<!-- ______________________________________________________________________ -->
<h4>
<a name="BuildRecType">Basic Recursive Type Construction</a>
</h4>
-<div class="doc_text">
+<div>
<p>
Because the most common question is "how do I build a recursive type with LLVM",
<a name="refineAbstractTypeTo">The <tt>refineAbstractTypeTo</tt> method</a>
</h4>
-<div class="doc_text">
+<div>
<p>
The <tt>refineAbstractTypeTo</tt> method starts the type unification process.
While this method is actually a member of the DerivedType class, it is most
<a name="PATypeHolder">The PATypeHolder Class</a>
</h4>
-<div class="doc_text">
+<div>
<p>
PATypeHolder is a form of a "smart pointer" for Type objects. When VMCore
happily goes about nuking types that become isomorphic to existing types, it
<a name="AbstractTypeUser">The AbstractTypeUser Class</a>
</h4>
-<div class="doc_text">
+<div>
<p>
Some data structures need more to perform more complex updates when types get
</p>
</div>
+</div>
<!-- ======================================================================= -->
<h3>
<tt>TypeSymbolTable</tt> classes</a>
</h3>
-<div class="doc_text">
+<div>
<p>The <tt><a href="http://llvm.org/doxygen/classllvm_1_1ValueSymbolTable.html">
ValueSymbolTable</a></tt> class provides a symbol table that the <a
href="#Function"><tt>Function</tt></a> and <a href="#Module">
<a name="UserLayout">The <tt>User</tt> and owned <tt>Use</tt> classes' memory layout</a>
</h3>
-<div class="doc_text">
+<div>
<p>The <tt><a href="http://llvm.org/doxygen/classllvm_1_1User.html">
User</a></tt> class provides a basis for expressing the ownership of <tt>User</tt>
towards other <tt><a href="http://llvm.org/doxygen/classllvm_1_1Value.html">
</a>
</h4>
-<div class="doc_text">
+<div>
<p>
A subclass of <tt>User</tt> can choose between incorporating its <tt>Use</tt> objects
or refer to them out-of-line by means of a pointer. A mixed variant
(some <tt>Use</tt>s inline others hung off) is impractical and breaks the invariant
that the <tt>Use</tt> objects belonging to the same <tt>User</tt> form a contiguous array.
</p>
-</div>
<p>
We have 2 different layouts in the <tt>User</tt> (sub)classes:
<i>(In the above figures '<tt>P</tt>' stands for the <tt>Use**</tt> that
is stored in each <tt>Use</tt> object in the member <tt>Use::Prev</tt>)</i>
+</div>
+
<!-- ______________________________________________________________________ -->
<h4>
<a name="Waymarking">The waymarking algorithm</a>
</h4>
-<div class="doc_text">
+<div>
<p>
Since the <tt>Use</tt> objects are deprived of the direct (back)pointer to
their <tt>User</tt> objects, there must be a fast and exact method to
recover it. This is accomplished by the following scheme:</p>
-</div>
A bit-encoding in the 2 LSBits (least significant bits) of the <tt>Use::Prev</tt> allows to find the
start of the <tt>User</tt> object:
stops, so that the <i>worst case is 20 memory accesses</i> when there are
1000 <tt>Use</tt> objects associated with a <tt>User</tt>.</p>
+</div>
+
<!-- ______________________________________________________________________ -->
<h4>
<a name="ReferenceImpl">Reference implementation</a>
</h4>
-<div class="doc_text">
+<div>
<p>
The following literate Haskell fragment demonstrates the concept:</p>
-</div>
<div class="doc_code">
<pre>
OK, passed 500 tests.
</pre>
+</div>
+
<!-- ______________________________________________________________________ -->
<h4>
<a name="Tagging">Tagging considerations</a>
</h4>
+<div>
+
<p>
To maintain the invariant that the 2 LSBits of each <tt>Use**</tt> in <tt>Use</tt>
never change after being set up, setters of <tt>Use::Prev</tt> must re-tag the
</div>
- <!-- *********************************************************************** -->
+</div>
+
+</div>
+
+<!-- *********************************************************************** -->
<h2>
<a name="coreclasses">The Core LLVM Class Hierarchy Reference </a>
</h2>
<!-- *********************************************************************** -->
-<div class="doc_text">
+<div>
<p><tt>#include "<a href="/doxygen/Type_8h-source.html">llvm/Type.h</a>"</tt>
<br>doxygen info: <a href="/doxygen/classllvm_1_1Type.html">Type Class</a></p>
header files in the <tt>include/llvm/</tt> directory, and implemented in
the <tt>lib/VMCore</tt> directory.</p>
-</div>
-
<!-- ======================================================================= -->
<h3>
<a name="Type">The <tt>Type</tt> class and Derived Types</a>
</h3>
-<div class="doc_text">
+<div>
<p><tt>Type</tt> is a superclass of all type classes. Every <tt>Value</tt> has
a <tt>Type</tt>. <tt>Type</tt> cannot be instantiated directly but only
be performed with address equality of the Type Instance. That is, given two
<tt>Type*</tt> values, the types are identical if the pointers are identical.
</p>
-</div>
<!-- _______________________________________________________________________ -->
<h4>
<a name="m_Type">Important Public Methods</a>
</h4>
-<div class="doc_text">
+<div>
<ul>
<li><tt>bool isIntegerTy() const</tt>: Returns true for any integer type.</li>
<h4>
<a name="derivedtypes">Important Derived Types</a>
</h4>
-<div class="doc_text">
+<div>
<dl>
<dt><tt>IntegerType</tt></dt>
<dd>Subclass of DerivedType that represents integer types of any bit width.
</dl>
</div>
-
+</div>
<!-- ======================================================================= -->
<h3>
<a name="Module">The <tt>Module</tt> class</a>
</h3>
-<div class="doc_text">
+<div>
<p><tt>#include "<a
href="/doxygen/Module_8h-source.html">llvm/Module.h</a>"</tt><br> doxygen info:
href="#SymbolTable"><tt>SymbolTable</tt></a>. Additionally, it contains a few
helpful member functions that try to make common operations easy.</p>
-</div>
-
<!-- _______________________________________________________________________ -->
<h4>
<a name="m_Module">Important Public Members of the <tt>Module</tt> class</a>
</h4>
-<div class="doc_text">
+<div>
<ul>
<li><tt>Module::Module(std::string name = "")</tt></li>
</div>
+</div>
<!-- ======================================================================= -->
<h3>
<a name="Value">The <tt>Value</tt> class</a>
</h3>
-<div class="doc_text">
+<div>
<p><tt>#include "<a href="/doxygen/Value_8h-source.html">llvm/Value.h</a>"</tt>
<br>
represents this value. Although this may take some getting used to, it
simplifies the representation and makes it easier to manipulate.</p>
-</div>
-
<!-- _______________________________________________________________________ -->
<h4>
<a name="m_Value">Important Public Members of the <tt>Value</tt> class</a>
</h4>
-<div class="doc_text">
+<div>
<ul>
<li><tt>Value::use_iterator</tt> - Typedef for iterator over the
</div>
+</div>
+
<!-- ======================================================================= -->
<h3>
<a name="User">The <tt>User</tt> class</a>
</h3>
-<div class="doc_text">
+<div>
<p>
<tt>#include "<a href="/doxygen/User_8h-source.html">llvm/User.h</a>"</tt><br>
allowing this direct connection. This connection provides the use-def
information in LLVM.</p>
-</div>
-
<!-- _______________________________________________________________________ -->
<h4>
<a name="m_User">Important Public Members of the <tt>User</tt> class</a>
</h4>
-<div class="doc_text">
+<div>
<p>The <tt>User</tt> class exposes the operand list in two ways: through
an index access interface and through an iterator based interface.</p>
</div>
+</div>
+
<!-- ======================================================================= -->
<h3>
<a name="Instruction">The <tt>Instruction</tt> class</a>
</h3>
-<div class="doc_text">
+<div>
<p><tt>#include "</tt><tt><a
href="/doxygen/Instruction_8h-source.html">llvm/Instruction.h</a>"</tt><br>
this file confuses doxygen, so these enum values don't show up correctly in the
<a href="/doxygen/classllvm_1_1Instruction.html">doxygen output</a>.</p>
-</div>
-
<!-- _______________________________________________________________________ -->
<h4>
<a name="s_Instruction">
Important Subclasses of the <tt>Instruction</tt> class
</a>
</h4>
-<div class="doc_text">
+<div>
<ul>
<li><tt><a name="BinaryOperator">BinaryOperator</a></tt>
<p>This subclasses represents all two operand instructions whose operands
</a>
</h4>
-<div class="doc_text">
+<div>
<ul>
<li><tt><a href="#BasicBlock">BasicBlock</a> *getParent()</tt>
</div>
+</div>
+
<!-- ======================================================================= -->
<h3>
<a name="Constant">The <tt>Constant</tt> class and subclasses</a>
</h3>
-<div class="doc_text">
+<div>
<p>Constant represents a base class for different types of constants. It
is subclassed by ConstantInt, ConstantArray, etc. for representing
a subclass, which represents the address of a global variable or function.
</p>
-</div>
-
<!-- _______________________________________________________________________ -->
<h4>Important Subclasses of Constant</h4>
-<div class="doc_text">
+<div>
<ul>
<li>ConstantInt : This subclass of Constant represents an integer constant of
any width.
</ul>
</div>
+</div>
<!-- ======================================================================= -->
<h3>
<a name="GlobalValue">The <tt>GlobalValue</tt> class</a>
</h3>
-<div class="doc_text">
+<div>
<p><tt>#include "<a
href="/doxygen/GlobalValue_8h-source.html">llvm/GlobalValue.h</a>"</tt><br>
can be accessed. This is explained in the <a href="LangRef.html#globalvars">LLVM
Language Reference Manual</a>.</p>
-</div>
-
<!-- _______________________________________________________________________ -->
<h4>
<a name="m_GlobalValue">
</a>
</h4>
-<div class="doc_text">
+<div>
<ul>
<li><tt>bool hasInternalLinkage() const</tt><br>
</div>
+</div>
+
<!-- ======================================================================= -->
<h3>
<a name="Function">The <tt>Function</tt> class</a>
</h3>
-<div class="doc_text">
+<div>
<p><tt>#include "<a
href="/doxygen/Function_8h-source.html">llvm/Function.h</a>"</tt><br> doxygen
<p>Note that <tt>Function</tt> is a <a href="#GlobalValue">GlobalValue</a>
and therefore also a <a href="#Constant">Constant</a>. The value of the function
is its address (after linking) which is guaranteed to be constant.</p>
-</div>
<!-- _______________________________________________________________________ -->
<h4>
</a>
</h4>
-<div class="doc_text">
+<div>
<ul>
<li><tt>Function(const </tt><tt><a href="#FunctionType">FunctionType</a>
</div>
+</div>
+
<!-- ======================================================================= -->
<h3>
<a name="GlobalVariable">The <tt>GlobalVariable</tt> class</a>
</h3>
-<div class="doc_text">
+<div>
<p><tt>#include "<a
href="/doxygen/GlobalVariable_8h-source.html">llvm/GlobalVariable.h</a>"</tt>
<a href="#Constant"><tt>Constant</tt></a>), and if they have an initializer,
they may be marked as "constant" themselves (indicating that their contents
never change at runtime).</p>
-</div>
<!-- _______________________________________________________________________ -->
<h4>
</a>
</h4>
-<div class="doc_text">
+<div>
<ul>
<li><tt>GlobalVariable(const </tt><tt><a href="#Type">Type</a> *Ty, bool
</div>
+</div>
<!-- ======================================================================= -->
<h3>
<a name="BasicBlock">The <tt>BasicBlock</tt> class</a>
</h3>
-<div class="doc_text">
+<div>
<p><tt>#include "<a
href="/doxygen/BasicBlock_8h-source.html">llvm/BasicBlock.h</a>"</tt><br>
like branches and can go in the switch tables. <tt>BasicBlock</tt>s have type
<tt>label</tt>.</p>
-</div>
-
<!-- _______________________________________________________________________ -->
<h4>
<a name="m_BasicBlock">
</a>
</h4>
-<div class="doc_text">
+<div>
<ul>
<li><tt>BasicBlock(const std::string &Name = "", </tt><tt><a
</div>
+</div>
<!-- ======================================================================= -->
<h3>
<a name="Argument">The <tt>Argument</tt> class</a>
</h3>
-<div class="doc_text">
+<div>
<p>This subclass of Value defines the interface for incoming formal
arguments to a function. A Function maintains a list of its formal
</div>
+</div>
+
<!-- *********************************************************************** -->
<hr>
<address>