diff options
Diffstat (limited to 'docs/ProgrammersManual.html')
-rw-r--r-- | docs/ProgrammersManual.html | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index ace44e7..23cfbf6 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -1211,14 +1211,14 @@ and erasing, but does not support iteration.</p> <div class="doc_text"> -<p>SmallPtrSet has all the advantages of SmallSet (and a SmallSet of pointers is -transparently implemented with a SmallPtrSet), but also supports iterators. If +<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 more than 'N' insertions are performed, a single quadratically probed hash table is allocated and grows as needed, providing extremely efficient access (constant time insertion/deleting/queries with low constant factors) and is very stingy with malloc traffic.</p> -<p>Note that, unlike std::set, the iterators of SmallPtrSet are invalidated +<p>Note that, unlike <tt>std::set</tt>, the iterators of <tt>SmallPtrSet</tt> are invalidated whenever an insertion occurs. Also, the values visited by the iterators are not visited in sorted order.</p> @@ -1843,6 +1843,21 @@ void printNextInstruction(Instruction* inst) { </pre> </div> +<p>Unfortunately, these implicit conversions come at a cost; they prevent +these iterators from conforming to standard iterator conventions, and thus +from being usable with standard algorithms and containers. For example, they +prevent the following code, where <tt>B</tt> is a <tt>BasicBlock</tt>, +from compiling:</p> + +<div class="doc_code"> +<pre> + llvm::SmallVector<llvm::Instruction *, 16>(B->begin(), B->end()); +</pre> +</div> + +<p>Because of this, these implicit conversions may be removed some day, +and <tt>operator*</tt> changed to return a pointer instead of a reference.</p> + </div> <!--_______________________________________________________________________--> @@ -1962,7 +1977,11 @@ for (Value::use_iterator i = F->use_begin(), e = F->use_end(); i != e; ++i </pre> </div> -<p>Alternately, it's common to have an instance of the <a +<p>Note that dereferencing a <tt>Value::use_iterator</tt> is not a very cheap +operation. Instead of performing <tt>*i</tt> above several times, consider +doing it only once in the loop body and reusing its result.</p> + +<p>Alternatively, it's common to have an instance of the <a href="/doxygen/classllvm_1_1User.html">User Class</a> and need to know what <tt>Value</tt>s are used by it. The list of all <tt>Value</tt>s used by a <tt>User</tt> is known as a <i>use-def</i> chain. Instances of class @@ -1981,10 +2000,13 @@ for (User::op_iterator i = pi->op_begin(), e = pi->op_end(); i != e; ++i) </pre> </div> -<!-- - def-use chains ("finding all users of"): Value::use_begin/use_end - use-def chains ("finding all values used"): User::op_begin/op_end [op=operand] ---> +<p>Declaring objects as <tt>const</tt> is an important tool of enforcing +mutation free algorithms (such as analyses, etc.). For this purpose above +iterators come in constant flavors as <tt>Value::const_use_iterator</tt> +and <tt>Value::const_op_iterator</tt>. They automatically arise when +calling <tt>use/op_begin()</tt> on <tt>const Value*</tt>s or +<tt>const User*</tt>s respectively. Upon dereferencing, they return +<tt>const Use*</tt>s. Otherwise the above patterns remain unchanged.</p> </div> @@ -3058,7 +3080,7 @@ the <tt>lib/VMCore</tt> directory.</p> <dt><tt><a name="FunctionType">FunctionType</a></tt></dt> <dd>Subclass of DerivedTypes for function types. <ul> - <li><tt>bool isVarArg() const</tt>: Returns true if its a vararg + <li><tt>bool isVarArg() const</tt>: Returns true if it's a vararg function</li> <li><tt> const Type * getReturnType() const</tt>: Returns the return type of the function.</li> @@ -3276,7 +3298,7 @@ simplifies the representation and makes it easier to manipulate.</p> <ul> <li><tt>Value::use_iterator</tt> - Typedef for iterator over the use-list<br> - <tt>Value::use_const_iterator</tt> - Typedef for const_iterator over + <tt>Value::const_use_iterator</tt> - Typedef for const_iterator over the use-list<br> <tt>unsigned use_size()</tt> - Returns the number of users of the value.<br> @@ -3921,7 +3943,7 @@ arguments. An argument has a pointer to the parent Function.</p> <a href="mailto:dhurjati@cs.uiuc.edu">Dinakar Dhurjati</a> and <a href="mailto:sabre@nondot.org">Chris Lattner</a><br> <a href="http://llvm.org">The LLVM Compiler Infrastructure</a><br> - Last modified: $Date: 2010-02-26 00:51:27 +0100 (Fri, 26 Feb 2010) $ + Last modified: $Date: 2010-04-02 02:08:26 +0200 (Fri, 02 Apr 2010) $ </address> </body> |