Here are some useful links:<p>
<ol>
-<li><a href="http://www.dinkumware.com/htm_cpl/index.html">Dinkumware C++
+<li><a href="http://www.dinkumware.com/refxcpp.html">Dinkumware C++
Library reference</a> - an excellent reference for the STL and other parts of
-the standard C++ library.<br>
+the standard C++ library.
+
+<li><a href="http://www.tempest-sw.com/cpp/">C++ In a Nutshell</a> - This is an
+O'Reilly book in the making. It has a decent <a
+href="http://www.tempest-sw.com/cpp/ch13-libref.html">Standard Library
+Reference</a> that rivals Dinkumware's, and is actually free until the book is
+published.
<li><a href="http://www.parashift.com/c++-faq-lite/">C++ Frequently Asked
Questions</a>
<pre>
<i>// Loop over all of the phi nodes in a basic block</i>
BasicBlock::iterator BBI = BB->begin();
- for (; <a href="#PhiNode">PHINode</a> *PN = dyn_cast<<a href="#PHINode">PHINode</a>>(&*BBI); ++BBI)
+ for (; <a href="#PhiNode">PHINode</a> *PN = dyn_cast<<a href="#PHINode">PHINode</a>>(BBI); ++BBI)
cerr << *PN;
</pre><p>
them out, allowing you to enable them if you need them in the future.<p>
The "<tt><a
-href="/doxygen/StatisticReporter_8h-source.html">StatisticReporter.h</a></tt>"
+href="/doxygen/Statistic_8h-source.html">Support/Statistic.h</a></tt>"
file provides a macro named <tt>DEBUG()</tt> that is a much nicer solution to
this problem. Basically, you can put arbitrary code into the argument of the
<tt>DEBUG</tt> macro, and it is only executed if '<tt>opt</tt>' is run with the
Using the <tt>DEBUG()</tt> macro instead of a home brewed solution allows you to
now have to create "yet another" command line option for the debug output for
-your pass. Note that <tt>DEBUG()</tt> macros are disabled for optimized
-builds, so they do not cause a performance impact at all.<p>
+your pass. Note that <tt>DEBUG()</tt> macros are disabled for optimized builds,
+so they do not cause a performance impact at all (for the same reason, they
+should also not contain side-effects!).<p>
+
+One additional nice thing about the <tt>DEBUG()</tt> macro is that you can
+enable or disable it directly in gdb. Just use "<tt>set DebugFlag=0</tt>" or
+"<tt>set DebugFlag=1</tt>" from the gdb if the program is running. If the
+program hasn't been started yet, you can always just run it with
+<tt>-debug</tt>.<p>
<!-- ======================================================================= -->
</b></font></td></tr></table><ul>
The "<tt><a
-href="/doxygen/StatisticReporter_8h-source.html">StatisticReporter.h</a></tt>"
+href="/doxygen/Statistic_8h-source.html">Support/Statistic.h</a></tt>"
file provides a template named <tt>Statistic</tt> that is used as a unified way
to keeping track of what the LLVM compiler is doing and how effective various
optimizations are. It is useful to see what optimizations are contributing to
<li>Define your statistic like this:<p>
<pre>
-static Statistic<> NumXForms("mypassname\t- The # of times I did stuff");
+static Statistic<> NumXForms("mypassname", "The # of times I did stuff");
</pre><p>
The <tt>Statistic</tt> template can emulate just about any data-type, but if you
<pre>Instruction* pinst = i;</pre>
-<b>Caveat emptor</b>: The above syntax works <i>only</i> when you're <i>not</i>
-working with <tt>dyn_cast</tt>. The template definition of <tt><a
-href="#isa">dyn_cast</a></tt> isn't implemented to handle this yet, so you'll
-still need the following in order for things to work properly:
-
-<pre>
-BasicBlock::iterator bbi = ...;
-<a href="#BranchInst">BranchInst</a>* b = <a href="#isa">dyn_cast</a><<a href="#BranchInst">BranchInst</a>>(&*bbi);
-</pre>
-
It's also possible to turn a class pointer into the corresponding
iterator. Usually, this conversion is quite inexpensive. The
following code snippet illustrates use of the conversion constructors
<pre>
AllocaInst* instToReplace = ...;
-ReplaceInstWithValue(*instToReplace->getParent(), instToReplace,
+BasicBlock::iterator ii(instToReplace);
+ReplaceInstWithValue(instToReplace->getParent()->getInstList(), ii,
Constant::getNullValue(PointerType::get(Type::IntTy)));
</pre>
<pre>
AllocaInst* instToReplace = ...;
-ReplaceInstWithInst(*instToReplace->getParent(), instToReplace,
- new AllocaInst(Type::IntTy, 0, "ptrToReplacedInt");
+BasicBlock::iterator ii(instToReplace);
+ReplaceInstWithInst(instToReplace->getParent()->getInstList(), ii,
+ new AllocaInst(Type::IntTy, 0, "ptrToReplacedInt"));
</pre>
</ul>
Returns the <a href="#BasicBlock"><tt>BasicBlock</tt></a> that this
<tt>Instruction</tt> is embedded into.<p>
-<li><tt>bool hasSideEffects()</tt><p>
+<li><tt>bool mayWriteToMemory()</tt><p>
-Returns true if the instruction has side effects, i.e. it is a <tt>call</tt>,
+Returns true if the instruction writes to memory, i.e. it is a <tt>call</tt>,
<tt>free</tt>, <tt>invoke</tt>, or <tt>store</tt>.<p>
<li><tt>unsigned getOpcode()</tt><p>
\end{itemize}
<li>LoadInst, StoreInst, GetElemPtrInst : These subclasses represent load, store and getelementptr instructions in LLVM.
\begin{itemize}
- <li><tt>Value * getPointerOperand ()</tt>: Returns the Pointer Operand which is typically the 0th operand.
+ <li><tt>Value * getPointerOperand()</tt>: Returns the Pointer Operand which is typically the 0th operand.
\end{itemize}
<li>BranchInst : This is a subclass of TerminatorInst and defines the interface for conditional and unconditional branches in LLVM.
\begin{itemize}
and returns the return type of the function, or the <a
href="#FunctionType"><tt>FunctionType</tt></a> of the actual function.<p>
-
-<li><tt>bool hasSymbolTable() const</tt><p>
-
-Return true if the <tt>Function</tt> has a symbol table allocated to it and if
-there is at least one entry in it.<p>
-
<li><tt><a href="#SymbolTable">SymbolTable</a> *getSymbolTable()</tt><p>
Return a pointer to the <a href="#SymbolTable"><tt>SymbolTable</tt></a> for this
-<tt>Function</tt> or a null pointer if one has not been allocated (because there
-are no named values in the function).<p>
-
-<li><tt><a href="#SymbolTable">SymbolTable</a> *getSymbolTableSure()</tt><p>
-
-Return a pointer to the <a href="#SymbolTable"><tt>SymbolTable</tt></a> for this
-<tt>Function</tt> or allocate a new <a
-href="#SymbolTable"><tt>SymbolTable</tt></a> if one is not already around. This
-should only be used when adding elements to the <a
-href="#SymbolTable"><tt>SymbolTable</tt></a>, so that empty symbol tables are
-not left laying around.<p>
+<tt>Function</tt>.<p>
<!-- Symbol table stuff -->
<hr size=0>
-<li><tt>bool hasSymbolTable() const</tt><p>
-
-Return true if the <tt>Module</tt> has a symbol table allocated to it and if
-there is at least one entry in it.<p>
-
<li><tt><a href="#SymbolTable">SymbolTable</a> *getSymbolTable()</tt><p>
-Return a pointer to the <a href="#SymbolTable"><tt>SymbolTable</tt></a> for this
-<tt>Module</tt> or a null pointer if one has not been allocated (because there
-are no named values in the function).<p>
-
-<li><tt><a href="#SymbolTable">SymbolTable</a> *getSymbolTableSure()</tt><p>
-
-Return a pointer to the <a href="#SymbolTable"><tt>SymbolTable</tt></a> for this
-<tt>Module</tt> or allocate a new <a
-href="#SymbolTable"><tt>SymbolTable</tt></a> if one is not already around. This
-should only be used when adding elements to the <a
-href="#SymbolTable"><tt>SymbolTable</tt></a>, so that empty symbol tables are
-not left laying around.<p>
+Return a reference to the <a href="#SymbolTable"><tt>SymbolTable</tt></a> for
+this <tt>Module</tt>.<p>
<!-- Convenience methods -->
<li><tt>bool isConstantExpr()</tt>: Returns true if it is a ConstantExpr
+<hr>
+Important Subclasses of Constant<p>
-
-\subsection{Important Subclasses of Constant}
-\begin{itemize}
+<ul>
<li>ConstantSInt : This subclass of Constant represents a signed integer constant.
- \begin{itemize}
- <li><tt>int64_t getValue () const</tt>: Returns the underlying value of this constant.
- \end{itemize}
+<ul>
+ <li><tt>int64_t getValue() const</tt>: Returns the underlying value of this constant.
+</ul>
<li>ConstantUInt : This class represents an unsigned integer.
- \begin{itemize}
- <li><tt>uint64_t getValue () const</tt>: Returns the underlying value of this constant.
- \end{itemize}
+<ul>
+ <li><tt>uint64_t getValue() const</tt>: Returns the underlying value of this constant.
+</ul>
<li>ConstantFP : This class represents a floating point constant.
- \begin{itemize}
- <li><tt>double getValue () const</tt>: Returns the underlying value of this constant.
- \end{itemize}
+<ul>
+ <li><tt>double getValue() const</tt>: Returns the underlying value of this constant.
+</ul>
<li>ConstantBool : This represents a boolean constant.
- \begin{itemize}
- <li><tt>bool getValue () const</tt>: Returns the underlying value of this constant.
- \end{itemize}
+<ul>
+ <li><tt>bool getValue() const</tt>: Returns the underlying value of this constant.
+</ul>
<li>ConstantArray : This represents a constant array.
- \begin{itemize}
+<ul>
<li><tt>const std::vector<Use> &getValues() const</tt>: Returns a Vecotr of component constants that makeup this array.
- \end{itemize}
+</ul>
<li>ConstantStruct : This represents a constant struct.
- \begin{itemize}
+<ul>
<li><tt>const std::vector<Use> &getValues() const</tt>: Returns a Vecotr of component constants that makeup this array.
- \end{itemize}
+</ul>
<li>ConstantPointerRef : This represents a constant pointer value that is initialized to point to a global value, which lies at a constant fixed address.
- \begin{itemize}
+<ul>
<li><tt>GlobalValue *getValue()</tt>: Returns the global value to which this pointer is pointing to.
- \end{itemize}
-\end{itemize}
+</ul>
+</ul>
<!-- ======================================================================= -->
<!-- _______________________________________________________________________ -->
</ul><h4><a name="m_Value"><hr size=0>Important Public Methods</h4><ul>
-<li><tt>PrimitiveID getPrimitiveID () const</tt>: Returns the base type of the type.
-<li><tt> bool isSigned () const</tt>: Returns whether an integral numeric type is signed. This is true for SByteTy, ShortTy, IntTy, LongTy. Note that this is not true for Float and Double.
-<li><tt>bool isUnsigned () const</tt>: Returns whether a numeric type is unsigned. This is not quite the complement of isSigned... nonnumeric types return false as they do with isSigned. This returns true for UByteTy, UShortTy, UIntTy, and ULongTy.
-<li><tt> bool isInteger () const</tt>: Equilivent to isSigned() || isUnsigned(), but with only a single virtual function invocation.
-<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><tt>PrimitiveID getPrimitiveID() const</tt>: Returns the base type of the type.
+<li><tt> bool isSigned() const</tt>: Returns whether an integral numeric type is signed. This is true for SByteTy, ShortTy, IntTy, LongTy. Note that this is not true for Float and Double.
+<li><tt>bool isUnsigned() const</tt>: Returns whether a numeric type is unsigned. This is not quite the complement of isSigned... nonnumeric types return false as they do with isSigned. This returns true for UByteTy, UShortTy, UIntTy, and ULongTy.
+<li><tt> bool isInteger() const</tt>: Equilivent to isSigned() || isUnsigned(), but with only a single virtual function invocation.
+<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><tt>bool isFloatingPoint ()</tt>: Return true if this is one of the two floating point types.
-<li><tt>bool isRecursive () const</tt>: Returns rue if the type graph contains a cycle.
+<li><tt>bool isFloatingPoint()</tt>: Return true if this is one of the two floating point types.
+<li><tt>bool isRecursive() const</tt>: Returns rue if the type graph contains a cycle.
<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.
-<li><tt>bool isPrimitiveType () const</tt>: Returns true if it is a primitive type.
-<li><tt>bool isDerivedType () const</tt>: Returns true if it is a derived type.
+<li><tt>bool isPrimitiveType() const</tt>: Returns true if it is a primitive type.
+<li><tt>bool isDerivedType() const</tt>: Returns true if it is a derived type.
<li><tt>const Type * getContainedType (unsigned i) const</tt>:
This method is used to implement the type iterator. For derived types, this returns the types 'contained' in the derived type, returning 0 when 'i' becomes invalid. This allows the user to iterate over the types in a struct, for example, really easily.
-<li><tt>unsigned getNumContainedTypes () const</tt>: Return the number of types in the derived type.
+<li><tt>unsigned getNumContainedTypes() const</tt>: Return the number of types in the derived type.
+<p>
+<hr>
+Derived Types<p>
-\subsection{Derived Types}
-\begin{itemize}
+<ul>
<li>SequentialType : This is subclassed by ArrayType and PointerType
- \begin{itemize}
- <li><tt>const Type * getElementType () const</tt>: Returns the type of each of the elements in the sequential type.
- \end{itemize}
+<ul>
+ <li><tt>const Type * getElementType() const</tt>: Returns the type of each of the elements in the sequential type.
+</ul>
<li>ArrayType : This is a subclass of SequentialType and defines interface for array types.
- \begin{itemize}
- <li><tt>unsigned getNumElements () const</tt>: Returns the number of elements in the array.
- \end{itemize}
+<ul>
+ <li><tt>unsigned getNumElements() const</tt>: Returns the number of elements in the array.
+</ul>
<li>PointerType : Subclass of SequentialType for pointer types.
<li>StructType : subclass of DerivedTypes for struct types
<li>FunctionType : subclass of DerivedTypes for function types.
- \begin{itemize}
+
+<ul>
- <li><tt>bool isVarArg () const</tt>: Returns true if its a vararg function
- <li><tt> const Type * getReturnType () const</tt>: Returns the return type of the function.
- <li><tt> const ParamTypes &getParamTypes () const</tt>: Returns a vector of parameter types.
+ <li><tt>bool isVarArg() const</tt>: Returns true if its a vararg function
+ <li><tt> const Type * getReturnType() const</tt>: Returns the return type of the function.
+ <li><tt> const ParamTypes &getParamTypes() const</tt>: Returns a vector of parameter types.
<li><tt>const Type * getParamType (unsigned i)</tt>: Returns the type of the ith parameter.
- <li><tt> const unsigned getNumParams () const</tt>: Returns the number of formal parameters.
- \end{itemize}
-\end{itemize}
+ <li><tt> const unsigned getNumParams() const</tt>: Returns the number of formal parameters.
+</ul>
+</ul>
<a href="mailto:sabre@nondot.org">Chris Lattner</a></address>
<!-- Created: Tue Aug 6 15:00:33 CDT 2002 -->
<!-- hhmts start -->
-Last modified: Sun Sep 22 14:38:05 CDT 2002
+Last modified: Wed Apr 23 11:21:57 CDT 2003
<!-- hhmts end -->
</font></body></html>