<li><a href="#coreclasses">The Core LLVM Class Hierarchy Reference</a>
<ul>
+ <li><a href="#Type">The <tt>Type</tt> class</a> </li>
<li><a href="#Value">The <tt>Value</tt> class</a>
<ul>
<li><a href="#User">The <tt>User</tt> class</a>
</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>
<p>The <tt>STATISTIC</tt> macro defines a static variable, whose name is
specified by the first argument. The pass name is taken from the DEBUG_TYPE
macro, and the description is taken from the second argument. The variable
- defined ("NumXForms" in this case) acts like an unsigned int.</p></li>
+ defined ("NumXForms" in this case) acts like an unsigned integer.</p></li>
<li><p>Whenever you make a transformation, bump the counter:</p>
<div class="doc_text">
<p>Frequently, we might have an instance of the <a
-href="/doxygen/structllvm_1_1Value.html">Value Class</a> and we want to
+href="/doxygen/classllvm_1_1Value.html">Value Class</a> and we want to
determine which <tt>User</tt>s use the <tt>Value</tt>. The list of all
<tt>User</tt>s of a particular <tt>Value</tt> is called a <i>def-use</i> chain.
For example, let's say we have a <tt>Function*</tt> named <tt>F</tt> to a
<p>You can use <tt>Value::replaceAllUsesWith</tt> and
<tt>User::replaceUsesOfWith</tt> to change more than one use at a time. See the
-doxygen documentation for the <a href="/doxygen/structllvm_1_1Value.html">Value Class</a>
+doxygen documentation for the <a href="/doxygen/classllvm_1_1Value.html">Value Class</a>
and <a href="/doxygen/classllvm_1_1User.html">User Class</a>, respectively, for more
information.</p>
For our purposes below, we need three concepts. First, an "Opaque Type" is
exactly as defined in the <a href="LangRef.html#t_opaque">language
reference</a>. Second an "Abstract Type" is any type which includes an
-opaque type as part of its type graph (for example "<tt>{ opaque, int }</tt>").
-Third, a concrete type is a type that is not an abstract type (e.g. "<tt>{ int,
+opaque type as part of its type graph (for example "<tt>{ opaque, i32 }</tt>").
+Third, a concrete type is a type that is not an abstract type (e.g. "<tt>{ i32,
float }</tt>").
</p>
<div class="doc_code">
<pre>
-%mylist = type { %mylist*, int }
+%mylist = type { %mylist*, i32 }
</pre>
</div>
Elts.push_back(Type::IntTy);
StructType *NewSTy = StructType::get(Elts);
-// <i>At this point, NewSTy = "{ opaque*, int }". Tell VMCore that</i>
+// <i>At this point, NewSTy = "{ opaque*, i32 }". Tell VMCore that</i>
// <i>the struct and the opaque type are actually the same.</i>
cast<OpaqueType>(StructTy.get())-><a href="#refineAbstractTypeTo">refineAbstractTypeTo</a>(NewSTy);
<p>
In the example above, the OpaqueType object is definitely deleted.
-Additionally, if there is an "{ \2*, int}" type already created in the system,
+Additionally, if there is an "{ \2*, i32}" type already created in the system,
the pointer and struct type created are <b>also</b> deleted. Obviously whenever
a type is deleted, any "Type*" pointers in the program are invalidated. As
such, it is safest to avoid having <i>any</i> "Type*" pointers to abstract types
allows it to get callbacks when certain types are resolved. To register to get
callbacks for a particular type, the DerivedType::{add/remove}AbstractTypeUser
methods can be called on a type. Note that these methods only work for <i>
-abstract</i> types. Concrete types (those that do not include an opaque objects
-somewhere) can never be refined.
+ abstract</i> types. Concrete types (those that do not include any opaque
+objects) can never be refined.
</p>
</div>
<p>This class provides a symbol table that the <a
href="#Function"><tt>Function</tt></a> and <a href="#Module">
<tt>Module</tt></a> classes use for naming definitions. The symbol table can
-provide a name for any <a href="#Value"><tt>Value</tt></a> or <a
-href="#Type"><tt>Type</tt></a>. <tt>SymbolTable</tt> is an abstract data
-type. It hides the data it contains and provides access to it through a
-controlled interface.</p>
-
-<p>Note that the symbol table class is should not be directly accessed by most
-clients. It should only be used when iteration over the symbol table names
-themselves are required, which is very special purpose. Note that not all LLVM
+provide a name for any <a href="#Value"><tt>Value</tt></a>.
+<tt>SymbolTable</tt> is an abstract data type. It hides the data it contains
+and provides access to it through a controlled interface.</p>
+
+<p>Note that the <tt>SymbolTable</tt> class should not be directly accessed
+by most clients. It should only be used when iteration over the symbol table
+names themselves are required, which is very special purpose. Note that not
+all LLVM
<a href="#Value">Value</a>s have names, and those without names (i.e. they have
an empty name) do not exist in the symbol table.
</p>
structure of the information it holds. The class contains two
<tt>std::map</tt> objects. The first, <tt>pmap</tt>, is a map of
<tt>Type*</tt> to maps of name (<tt>std::string</tt>) to <tt>Value*</tt>.
-The second, <tt>tmap</tt>, is a map of names to <tt>Type*</tt>. Thus, Values
-are stored in two-dimensions and accessed by <tt>Type</tt> and name. Types,
-however, are stored in a single dimension and accessed only by name.</p>
+Thus, Values are stored in two-dimensions and accessed by <tt>Type</tt> and
+name.</p>
<p>The interface of this class provides three basic types of operations:
<ol>
<a href="#SymbolTable_insert"><tt>insert</tt></a>.</li>
<li><em>Iterators</em>. Iterators allow the user to traverse the content
of the symbol table in well defined ways, such as the method
- <a href="#SymbolTable_type_begin"><tt>type_begin</tt></a>.</li>
+ <a href="#SymbolTable_plane_begin"><tt>plane_begin</tt></a>.</li>
</ol>
<h3>Accessors</h3>
<tt>Ty</tt> parameter for a <tt>Value</tt> with the provided <tt>name</tt>.
If a suitable <tt>Value</tt> is not found, null is returned.</dd>
- <dt><tt>Type* lookupType( const std::string& name) const</tt>:</dt>
- <dd>The <tt>lookupType</tt> method searches through the types for a
- <tt>Type</tt> with the provided <tt>name</tt>. If a suitable <tt>Type</tt>
- is not found, null is returned.</dd>
-
- <dt><tt>bool hasTypes() const</tt>:</dt>
- <dd>This function returns true if an entry has been made into the type
- map.</dd>
-
<dt><tt>bool isEmpty() const</tt>:</dt>
<dd>This function returns true if both the value and types maps are
empty</dd>
name. There can be a many to one mapping between names and constants
or types.</dd>
- <dt><tt>void insert(const std::string& Name, Type *Typ)</tt>:</dt>
- <dd> Inserts a type into the symbol table with the specified name. There
- can be a many-to-one mapping between names and types. This method
- allows a type with an existing entry in the symbol table to get
- a new name.</dd>
-
<dt><tt>void remove(Value* Val)</tt>:</dt>
<dd> This method removes a named value from the symbol table. The
type and name of the Value are extracted from \p N and used to
not in the symbol table, this method silently ignores the
request.</dd>
- <dt><tt>void remove(Type* Typ)</tt>:</dt>
- <dd> This method removes a named type from the symbol table. The
- name of the type is extracted from \P T and used to look up
- the Type in the type map. If the Type is not in the symbol
- table, this method silently ignores the request.</dd>
-
<dt><tt>Value* remove(const std::string& Name, Value *Val)</tt>:</dt>
<dd> Remove a constant or type with the specified name from the
symbol table.</dd>
- <dt><tt>Type* remove(const std::string& Name, Type* T)</tt>:</dt>
- <dd> Remove a type with the specified name from the symbol table.
- Returns the removed Type.</dd>
-
- <dt><tt>Value *value_remove(const value_iterator& It)</tt>:</dt>
+ <dt><tt>Value *remove(const value_iterator& It)</tt>:</dt>
<dd> Removes a specific value from the symbol table.
Returns the removed value.</dd>
PE = ST.plane_end(); PI != PE; ++PI ) {
PI->first // <i>This is the Type* of the plane</i>
PI->second // <i>This is the SymbolTable::ValueMap of name/Value pairs</i>
-}
- </tt></pre></td>
- </tr>
- <tr>
- <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->first // <i>This is the name of the type</i>
- TI->second // <i>This is the Type* value associated with the name</i>
}
</tt></pre></td>
</tr>
marker for end of iteration of the type plane.
Note: the type plane must already exist before using this.</dd>
- <dt><tt>type_iterator type_begin()</tt>:</dt>
- <dd>Get an iterator to the start of the name/Type map.</dd>
-
- <dt><tt>type_const_iterator type_begin() cons</tt>:</dt>
- <dd> Get a const_iterator to the start of the name/Type map.</dd>
-
- <dt><tt>type_iterator type_end()</tt>:</dt>
- <dd>Get an iterator to the end of the name/Type map. This serves as the
- marker for end of iteration of the types.</dd>
-
- <dt><tt>type_const_iterator type_end() const</tt>:</dt>
- <dd>Get a const-iterator to the end of the name/Type map. This serves
- as the marker for end of iteration of the types.</dd>
-
<dt><tt>plane_const_iterator find(const Type* Typ ) const</tt>:</dt>
<dd>This method returns a plane_const_iterator for iteration over
the type planes starting at a specific plane, given by \p Ty.</dd>
<!-- *********************************************************************** -->
<div class="doc_text">
+<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>
<p>The Core LLVM classes are the primary means of representing the program
being inspected or transformed. The core LLVM classes are defined in
</div>
+<!-- ======================================================================= -->
+<div class="doc_subsection">
+ <a name="Type">The <tt>Type</tt> class and Derived Types</a>
+</div>
+
+<div class="doc_text">
+
+ <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
+ through its subclasses. Certain primitive types (<tt>VoidType</tt>,
+ <tt>LabelType</tt>, <tt>FloatType</tt> and <tt>DoubleType</tt>) have hidden
+ subclasses. They are hidden because they offer no useful functionality beyond
+ what the <tt>Type</tt> class offers except to distinguish themselves from
+ other subclasses of <tt>Type</tt>.</p>
+ <p>All other types are subclasses of <tt>DerivedType</tt>. Types can be
+ named, but this is not a requirement. There exists exactly
+ one instance of a given shape at any one time. This allows type equality to
+ 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>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">
+ <a name="m_Value">Important Public Methods</a>
+</div>
+
+<div class="doc_text">
+
+<ul>
+ <li><tt>bool isInteger() const</tt>: Returns true for any integer type.</li>
+
+ <li><tt>bool isFloatingPoint()</tt>: Return true if this is one of the two
+ floating point types.</li>
+
+ <li><tt>bool isAbstract()</tt>: Return true if the type is abstract (contains
+ an OpaqueType anywhere in its definition).</li>
+
+ <li><tt>bool isSized()</tt>: Return true if the type has known size. Things
+ that don't have a size are abstract types, labels and void.</li>
+
+</ul>
+</div>
+
+<!-- _______________________________________________________________________ -->
+<div class="doc_subsubsection">
+ <a name="m_Value">Important Derived Types</a>
+</div>
+<div class="doc_text">
+<dl>
+ <dt><tt>IntegerType</tt></dt>
+ <dd>Subclass of DerivedType that represents integer types of any bit width.
+ Any bit width between <tt>IntegerType::MIN_INT_BITS</tt> (1) and
+ <tt>IntegerType::MAX_INT_BITS</tt> (~8 million) can be represented.
+ <ul>
+ <li><tt>static const IntegerType* get(unsigned NumBits)</tt>: get an integer
+ type of a specific bit width.</li>
+ <li><tt>unsigned getBitWidth() const</tt>: Get the bit width of an integer
+ type.</li>
+ </ul>
+ </dd>
+ <dt><tt>SequentialType</tt></dt>
+ <dd>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>
+ </dd>
+ <dt><tt>ArrayType</tt></dt>
+ <dd>This is a subclass of SequentialType and defines the interface for array
+ types.
+ <ul>
+ <li><tt>unsigned getNumElements() const</tt>: Returns the number of
+ elements in the array. </li>
+ </ul>
+ </dd>
+ <dt><tt>PointerType</tt></dt>
+ <dd>Subclass of SequentialType for pointer types.</li>
+ <dt><tt>PackedType</tt></dt>
+ <dd>Subclass of SequentialType for packed (vector) types. A
+ packed type is similar to an ArrayType but is distinguished because it is
+ a first class type wherease ArrayType is not. Packed types are used for
+ vector operations and are usually small vectors of of an integer or floating
+ point type.</dd>
+ <dt><tt>StructType</tt></dt>
+ <dd>Subclass of DerivedTypes for struct types.</dd>
+ <dt><tt>FunctionType</tt></dt>
+ <dd>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>
+ </dd>
+ <dt><tt>OpaqueType</tt></dt>
+ <dd>Sublcass of DerivedType for abstract types. This class
+ defines no content and is used as a placeholder for some other type. Note
+ that OpaqueType is used (temporarily) during type resolution for forward
+ references of types. Once the referenced type is resolved, the OpaqueType
+ is replaced with the actual type. OpaqueType can also be used for data
+ abstraction. At link time opaque types can be resolved to actual types
+ of the same name.</dd>
+</dl>
+</div>
+
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="Value">The <tt>Value</tt> class</a>
<p><tt>#include "<a href="/doxygen/Value_8h-source.html">llvm/Value.h</a>"</tt>
<br>
-doxygen info: <a href="/doxygen/structllvm_1_1Value.html">Value Class</a></p>
+doxygen info: <a href="/doxygen/classllvm_1_1Value.html">Value Class</a></p>
<p>The <tt>Value</tt> class is the most important class in the LLVM Source
base. It represents a typed value that may be used (among other things) as an
<div class="doc_code">
<pre>
-%<b>foo</b> = add int 1, 2
+%<b>foo</b> = add i32 1, 2
</pre>
</div>
when using the <tt>GetElementPtrInst</tt> instruction because this pointer must
be dereferenced first. For example, if you have a <tt>GlobalVariable</tt> (a
subclass of <tt>GlobalValue)</tt> that is an array of 24 ints, type <tt>[24 x
-int]</tt>, then the <tt>GlobalVariable</tt> is a pointer to that array. Although
+i32]</tt>, then the <tt>GlobalVariable</tt> is a pointer to that array. Although
the address of the first element of this array and the value of the
<tt>GlobalVariable</tt> are the same, they have different types. The
-<tt>GlobalVariable</tt>'s type is <tt>[24 x int]</tt>. The first element's type
-is <tt>int.</tt> Because of this, accessing a global value requires you to
+<tt>GlobalVariable</tt>'s type is <tt>[24 x i32]</tt>. The first element's type
+is <tt>i32.</tt> Because of this, accessing a global value requires you to
dereference the pointer with <tt>GetElementPtrInst</tt> first, then its elements
can be accessed. This is explained in the <a href="LangRef.html#globalvars">LLVM
Language Reference Manual</a>.</p>
<div class="doc_text">
<p>Constant represents a base class for different types of constants. It
-is subclassed by ConstantBool, ConstantInt, ConstantArray etc for representing
+is subclassed by ConstantInt, ConstantArray, etc. for representing
the various types of Constants.</p>
</div>
<div class="doc_subsubsection">Important Subclasses of Constant </div>
<div class="doc_text">
<ul>
- <li>ConstantInt : This subclass of Constant represents an integer constant.
+ <li>ConstantInt : This subclass of Constant represents an integer constant of
+ any width, including boolean (1 bit integer).
<ul>
<li><tt>int64_t getSExtValue() const</tt>: Returns the underlying value of
this constant as a sign extended signed integer value.</li>
<li><tt>uint64_t getZExtValue() const</tt>: Returns the underlying value
of this constant as a zero extended unsigned integer value.</li>
+ <li><tt>static ConstantInt* get(const Type *Ty, uint64_t Val)</tt>:
+ Returns the ConstantInt object that represents the value provided by
+ <tt>Val</tt> for integer type <tt>Ty</tt>.</li>
</ul>
</li>
<li>ConstantFP : This class represents a floating point constant.
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>
</li>
</ul>
</div>
-
-<!-- ======================================================================= -->
-<div class="doc_subsection">
- <a name="Type">The <tt>Type</tt> class and Derived Types</a>
-</div>
-
-<div class="doc_text">
-
-<p>Type as noted earlier is also a subclass of a Value class. Any primitive
-type (like int, short etc) in LLVM is an instance of Type Class. All other
-types are instances of subclasses of type like FunctionType, ArrayType
-etc. DerivedType is the interface for all such dervied types including
-FunctionType, ArrayType, PointerType, StructType. Types can have names. They can
-be recursive (StructType). There exists exactly one instance of any type
-structure at a time. This allows using pointer equality of Type *s for comparing
-types.</p>
-
-</div>
-
-<!-- _______________________________________________________________________ -->
-<div class="doc_subsubsection">
- <a name="m_Value">Important Public Methods</a>
-</div>
-
-<div class="doc_text">
-
-<ul>
- <li><tt>bool isInteger() const</tt>: True for any integer type.</li>
-
- <li><tt>bool isIntegral() const</tt>: Returns true if this is an integral
- type, which is either Bool type or one of the Integer types.</li>
-
- <li><tt>bool isFloatingPoint()</tt>: Return true if this is one of the two
- floating point types.</li>
-
- <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>
-
-<!-- _______________________________________________________________________ -->
-<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><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>
-
<!-- ======================================================================= -->
<div class="doc_subsection">
<a name="Argument">The <tt>Argument</tt> class</a>