summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@google.com>2009-04-30 22:33:41 +0000
committerJeffrey Yasskin <jyasskin@google.com>2009-04-30 22:33:41 +0000
commit714257f5deec6049a4170bdd77ca1c3df989d67e (patch)
tree30ce1bec046b61fe5e2734972dbbfb9b695de392 /docs
parent3a155f0e34f3d33920b6a9308ae3464f5c506438 (diff)
downloadllvm-714257f5deec6049a4170bdd77ca1c3df989d67e.tar.gz
llvm-714257f5deec6049a4170bdd77ca1c3df989d67e.tar.bz2
llvm-714257f5deec6049a4170bdd77ca1c3df989d67e.tar.xz
Add a mention of TypeBuilder to the programmer's manual, and clean up the class
comment a bit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70515 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs')
-rw-r--r--docs/ProgrammersManual.html41
1 files changed, 41 insertions, 0 deletions
diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html
index e2525ae84e..253e836361 100644
--- a/docs/ProgrammersManual.html
+++ b/docs/ProgrammersManual.html
@@ -117,6 +117,7 @@ with another <tt>Value</tt></a> </li>
<li><a href="#schanges_deletingGV">Deleting <tt>GlobalVariable</tt>s</a> </li>
</ul>
</li>
+ <li><a href="#create_types">How to Create Types</a></li>
<!--
<li>Working with the Control Flow Graph
<ul>
@@ -2088,6 +2089,46 @@ GV-&gt;eraseFromParent();
</div>
+<!-- ======================================================================= -->
+<div class="doc_subsection">
+ <a name="create_types">How to Create Types</a>
+</div>
+
+<div class="doc_text">
+
+<p>In generating IR, you may need some complex types. If you know these types
+statically, you can use <tt>TypeBuilder&lt;...>::get()</tt>, defined
+in <tt>llvm/Support/TypeBuilder.h</tt>, to retrieve them. <tt>TypeBuilder</tt>
+has two forms depending on whether you're building types for cross-compilation
+or native library use. <tt>TypeBuilder&lt;T, true></tt> requires
+that <tt>T</tt> be independent of the host environment, meaning that it's built
+out of types from
+the <a href="/doxygen/namespacellvm_1_1types.html"><tt>llvm::types</tt></a>
+namespace and pointers, functions, arrays, etc. built of
+those. <tt>TypeBuilder&lt;T, false></tt> additionally allows native C types
+whose size may depend on the host compiler. For example,</p>
+
+<div class="doc_code">
+<pre>
+FunctionType *ft = TypeBuilder&lt;types::i&lt;8>(types::i&lt;32>*), true>::get();
+</pre>
+</div>
+
+<p>is easier to read and write than the equivalent</p>
+
+<div class="doc_code">
+<pre>
+std::vector<const Type*> params;
+params.push_back(PointerType::getUnqual(Type::Int32Ty));
+FunctionType *ft = FunctionType::get(Type::Int8Ty, params, false);
+</pre>
+</div>
+
+<p>See the <a href="/doxygen/TypeBuilder_8h-source.html#l00001">class
+comment</a> for more details.</p>
+
+</div>
+
<!-- *********************************************************************** -->
<div class="doc_section">
<a name="advanced">Advanced Topics</a>