diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/BranchWeightMetadata.html | 163 | ||||
-rw-r--r-- | docs/ExtendingLLVM.html | 4 | ||||
-rw-r--r-- | docs/LangRef.html | 228 | ||||
-rw-r--r-- | docs/ProgrammersManual.html | 243 | ||||
-rw-r--r-- | docs/ReleaseNotes.html | 52 | ||||
-rw-r--r-- | docs/WritingAnLLVMBackend.html | 82 | ||||
-rw-r--r-- | docs/index.html | 7 | ||||
-rw-r--r-- | docs/tutorial/OCamlLangImpl3.html | 13 |
8 files changed, 414 insertions, 378 deletions
diff --git a/docs/BranchWeightMetadata.html b/docs/BranchWeightMetadata.html new file mode 100644 index 0000000..6106e6f --- /dev/null +++ b/docs/BranchWeightMetadata.html @@ -0,0 +1,163 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" + "http://www.w3.org/TR/html4/strict.dtd"> +<html> +<head> + <title>LLVM Branch Weight Metadata</title> + <link rel="stylesheet" href="llvm.css" type="text/css"> +</head> +<body> + +<h1> + LLVM Branch Weight Metadata +</h1> + +<ol> + <li><a href="#introduction">Introduction</a></li> + <li><a href="#supported_instructions">Supported Instructions</a></li> + <li><a href="#builtin_expect">Built-in "expect" Instruction </a></li> + <li><a href="#cfg_modifications">CFG Modifications</a></li> +</ol> + +<div class="doc_author"> + <p>Written by <a href="mailto:jstaszak@apple.com">Jakub Staszak</a></p> +</div> + +<h2> + <a name="introduction">Introduction</a> +</h2> +<div> +<p>Branch Weight Metadata represents branch weights as its likeliness to +be taken. Metadata is assigned to the <tt>TerminatorInst</tt> as a +<tt>MDNode</tt> of the <tt>MD_prof</tt> kind. The first operator is always a +<tt>MDString</tt> node with the string "branch_weights". Number of operators +depends on the terminator type.</p> + +<p>Branch weights might be fetch from the profiling file, or generated based on +<a href="#builtin_expect"><tt>__builtin_expect</tt></a> instruction. +</p> + +<p>All weights are represented as an unsigned 32-bit values, where higher value +indicates greater chance to be taken.</p> +</div> + +<h2> + <a name="supported_instructions">Supported Instructions</a> +</h2> + +<div> + <h4>BranchInst</h4> + <div> + <p>Metadata is only assign to the conditional branches. There are two extra + operarands, for the true and the false branch.</p> + </div> + <div class="doc_code"> + <pre> +!0 = metadata !{ + metadata !"branch_weights", + i32 <TRUE_BRANCH_WEIGHT>, + i32 <FALSE_BRANCH_WEIGHT> +} + </pre> + </div> + + <h4>SwitchInst</h4> + <div> + <p>Branch weights are assign to every case (including <tt>default</tt> case + which is always case #0).</p> + </div> + <div class="doc_code"> + <pre> +!0 = metadata !{ + metadata !"branch_weights", + i32 <DEFAULT_BRANCH_WEIGHT> + [ , i32 <CASE_BRANCH_WEIGHT> ... ] +} + </pre> + </div> + + <h4>IndirectBrInst</h4> + <div> + <p>Branch weights are assign to every destination.</p> + </div> + <div class="doc_code"> + <pre> +!0 = metadata !{ + metadata !"branch_weights", + i32 <LABEL_BRANCH_WEIGHT> + [ , i32 <LABEL_BRANCH_WEIGHT> ... ] +} + </pre> + </div> + + <h4>Other</h4> + <div> + <p>Other terminator instructions are not allowed to contain Branch Weight + Metadata.</p> + </div> +</div> + +<h2> + <a name="builtin_expect">Built-in "expect" Instructions</a> +</h2> +<div> + <p><tt>__builtin_expect(long exp, long c)</tt> instruction provides branch + prediction information. The return value is the value of <tt>exp</tt>.</p> + + <p>It is especially useful in conditional statements. Currently Clang supports + two conditional statements: + </p> + <h4><tt>if</tt> statement</h4> + <div> + <p>The <tt>exp</tt> parameter is the condition. The <tt>c</tt> parameter is + the expected comparision value. If it is equal to 1 (true), the condition is + likely to be true, in other case condition is likely to be false. For example: + </p> + </div> + <div class="doc_code"> + <pre> + if (__builtin_expect(x > 0, 1)) { + // This block is likely to be taken. + } + </pre> + </div> + + <h4><tt>switch</tt> statement</h4> + <div> + <p>The <tt>exp</tt> parameter is the value. The <tt>c</tt> parameter is the + expected value. If the expected value doesn't show on the cases list, the + <tt>default</tt> case is assumed to be likely taken.</p> + </div> + <div class="doc_code"> + <pre> + switch (__builtin_expect(x, 5)) { + default: break; + case 0: // ... + case 3: // ... + case 5: // This case is likely to be taken. + } + </pre> + </div> +</div> + +<h2> + <a name="cfg_modifications">CFG Modifications</a> +</h2> +<div> +<p>Branch Weight Metatada is not proof against CFG changes. If terminator +operands' are changed some action should be taken. In other case some +misoptimizations may occur due to incorrent branch prediction information.</p> +</div> + +<hr> +<address> + <a href="http://jigsaw.w3.org/css-validator/check/referer"><img + src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a> + <a href="http://validator.w3.org/check/referer"><img + src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a> + + <a href="mailto:jstaszak@apple.com">Jakub Staszak</a><br> + <a href="http://llvm.org/">LLVM Compiler Infrastructure</a><br> +</address> + +</body> +</html> diff --git a/docs/ExtendingLLVM.html b/docs/ExtendingLLVM.html index 03cfa7e..cf57fab 100644 --- a/docs/ExtendingLLVM.html +++ b/docs/ExtendingLLVM.html @@ -146,7 +146,7 @@ cases, new nodes have been added to allow many targets to perform a common task complicated behavior in a single node (rotate).</p> <ol> -<li><tt>include/llvm/CodeGen/SelectionDAGNodes.h</tt>: +<li><tt>include/llvm/CodeGen/ISDOpcodes.h</tt>: Add an enum value for the new SelectionDAG node.</li> <li><tt>lib/CodeGen/SelectionDAG/SelectionDAG.cpp</tt>: Add code to print the node to <tt>getOperationName</tt>. If your new node @@ -384,7 +384,7 @@ void calcTypeName(const Type *Ty, <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a> <br> - Last modified: $Date: 2011-04-23 02:30:22 +0200 (Sat, 23 Apr 2011) $ + Last modified: $Date: 2011-06-30 08:37:07 +0200 (Thu, 30 Jun 2011) $ </address> </body> diff --git a/docs/LangRef.html b/docs/LangRef.html index 48bddfd..8e17243 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -74,16 +74,14 @@ <ol> <li><a href="#t_array">Array Type</a></li> <li><a href="#t_struct">Structure Type</a></li> - <li><a href="#t_pstruct">Packed Structure Type</a></li> + <li><a href="#t_opaque">Opaque Type</a></li> <li><a href="#t_vector">Vector Type</a></li> </ol> </li> <li><a href="#t_function">Function Type</a></li> <li><a href="#t_pointer">Pointer Type</a></li> - <li><a href="#t_opaque">Opaque Type</a></li> </ol> </li> - <li><a href="#t_uprefs">Type Up-references</a></li> </ol> </li> <li><a href="#constants">Constants</a> @@ -241,6 +239,7 @@ <li><a href="#int_pow">'<tt>llvm.pow.*</tt>' Intrinsic</a></li> <li><a href="#int_exp">'<tt>llvm.exp.*</tt>' Intrinsic</a></li> <li><a href="#int_log">'<tt>llvm.log.*</tt>' Intrinsic</a></li> + <li><a href="#int_fma">'<tt>llvm.fma.*</tt>' Intrinsic</a></li> </ol> </li> <li><a href="#int_manip">Bit Manipulation Intrinsics</a> @@ -1164,6 +1163,11 @@ define void @f() optsize { ... } Most of the functions in the Windows system DLLs in Windows XP SP2 or higher were compiled in this fashion.</dd> + <dt><tt><b>nonlazybind</b></tt></dt> + <dd>This attribute suppresses lazy symbol binding for the function. This + may make calls to the function faster, at the cost of extra program + startup time if the function is not called during program startup.</dd> + <dt><tt><b>inlinehint</b></tt></dt> <dd>This attribute indicates that the source code contained a hint that inlining this function is desirable (such as the "inline" keyword in C/C++). It @@ -1529,7 +1533,6 @@ synchronization behavior.</p> <a href="#t_function">function</a>, <a href="#t_pointer">pointer</a>, <a href="#t_struct">structure</a>, - <a href="#t_pstruct">packed structure</a>, <a href="#t_vector">vector</a>, <a href="#t_opaque">opaque</a>. </td> @@ -1697,7 +1700,9 @@ synchronization behavior.</p> possible to have a two dimensional array, using an array as the element type of another array.</p> - +</div> + + <!-- _______________________________________________________________________ --> <h4> <a name="t_aggregate">Aggregate Types</a> @@ -1836,9 +1841,7 @@ synchronization behavior.</p> <h5>Overview:</h5> <p>The structure type is used to represent a collection of data members together - in memory. The packing of the field types is defined to match the ABI of the - underlying processor. The elements of a structure may be any type that has a - size.</p> + in memory. The elements of a structure may be any type that has a size.</p> <p>Structures in memory are accessed using '<tt><a href="#i_load">load</a></tt>' and '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a field @@ -1846,66 +1849,76 @@ synchronization behavior.</p> Structures in registers are accessed using the '<tt><a href="#i_extractvalue">extractvalue</a></tt>' and '<tt><a href="#i_insertvalue">insertvalue</a></tt>' instructions.</p> + +<p>Structures may optionally be "packed" structures, which indicate that the + alignment of the struct is one byte, and that there is no padding between + the elements. In non-packed structs, padding between field types is defined + by the target data string to match the underlying processor.</p> + +<p>Structures can either be "anonymous" or "named". An anonymous structure is + defined inline with other types (e.g. <tt>{i32, i32}*</tt>) and a named types + are always defined at the top level with a name. Anonmyous types are uniqued + by their contents and can never be recursive since there is no way to write + one. Named types can be recursive. +</p> + <h5>Syntax:</h5> <pre> - { <type list> } + %T1 = type { <type list> } <i>; Named normal struct type</i> + %T2 = type <{ <type list> }> <i>; Named packed struct type</i> </pre> - + <h5>Examples:</h5> <table class="layout"> <tr class="layout"> <td class="left"><tt>{ i32, i32, i32 }</tt></td> <td class="left">A triple of three <tt>i32</tt> values</td> - </tr><tr class="layout"> + </tr> + <tr class="layout"> <td class="left"><tt>{ float, i32 (i32) * }</tt></td> <td class="left">A pair, where the first element is a <tt>float</tt> and the second element is a <a href="#t_pointer">pointer</a> to a <a href="#t_function">function</a> that takes an <tt>i32</tt>, returning an <tt>i32</tt>.</td> </tr> + <tr class="layout"> + <td class="left"><tt><{ i8, i32 }></tt></td> + <td class="left">A packed struct known to be 5 bytes in size.</td> + </tr> </table> </div> - + <!-- _______________________________________________________________________ --> <h4> - <a name="t_pstruct">Packed Structure Type</a> + <a name="t_opaque">Opaque Type</a> </h4> <div> <h5>Overview:</h5> -<p>The packed structure type is used to represent a collection of data members - together in memory. There is no padding between fields. Further, the - alignment of a packed structure is 1 byte. The elements of a packed - structure may be any type that has a size.</p> - -<p>Structures are accessed using '<tt><a href="#i_load">load</a></tt> and - '<tt><a href="#i_store">store</a></tt>' by getting a pointer to a field with - the '<tt><a href="#i_getelementptr">getelementptr</a></tt>' instruction.</p> +<p>Opaque types are used to represent named structure types that do not have a + body specified. This corresponds (for example) to the C notion of a forward + declared structure.</p> <h5>Syntax:</h5> <pre> - < { <type list> } > + %X = type opaque + %52 = type opaque </pre> <h5>Examples:</h5> <table class="layout"> <tr class="layout"> - <td class="left"><tt>< { i32, i32, i32 } ></tt></td> - <td class="left">A triple of three <tt>i32</tt> values</td> - </tr><tr class="layout"> - <td class="left"> -<tt>< { float, i32 (i32)* } ></tt></td> - <td class="left">A pair, where the first element is a <tt>float</tt> and the - second element is a <a href="#t_pointer">pointer</a> to a - <a href="#t_function">function</a> that takes an <tt>i32</tt>, returning - an <tt>i32</tt>.</td> + <td class="left"><tt>opaque</tt></td> + <td class="left">An opaque type.</td> </tr> </table> </div> + + <!-- _______________________________________________________________________ --> <h4> <a name="t_pointer">Pointer Type</a> @@ -1993,86 +2006,6 @@ synchronization behavior.</p> </div> -<!-- _______________________________________________________________________ --> -<h4> - <a name="t_opaque">Opaque Type</a> -</h4> - -<div> - -<h5>Overview:</h5> -<p>Opaque types are used to represent unknown types in the system. This - corresponds (for example) to the C notion of a forward declared structure - type. In LLVM, opaque types can eventually be resolved to any type (not just - a structure type).</p> - -<h5>Syntax:</h5> -<pre> - opaque -</pre> - -<h5>Examples:</h5> -<table class="layout"> - <tr class="layout"> - <td class="left"><tt>opaque</tt></td> - <td class="left">An opaque type.</td> - </tr> -</table> - -</div> - -</div> - -<!-- ======================================================================= --> -<h3> - <a name="t_uprefs">Type Up-references</a> -</h3> - -<div> - -<h5>Overview:</h5> -<p>An "up reference" allows you to refer to a lexically enclosing type without - requiring it to have a name. For instance, a structure declaration may - contain a pointer to any of the types it is lexically a member of. Example - of up references (with their equivalent as named type declarations) - include:</p> - -<pre> - { \2 * } %x = type { %x* } - { \2 }* %y = type { %y }* - \1* %z = type %z* -</pre> - -<p>An up reference is needed by the asmprinter for printing out cyclic types - when there is no declared name for a type in the cycle. Because the - asmprinter does not want to print out an infinite type string, it needs a - syntax to handle recursive types that have no names (all names are optional - in llvm IR).</p> - -<h5>Syntax:</h5> -<pre> - \<level> -</pre> - -<p>The level is the count of the lexical type that is being referred to.</p> - -<h5>Examples:</h5> -<table class="layout"> - <tr class="layout"> - <td class="left"><tt>\1*</tt></td> - <td class="left">Self-referential pointer.</td> - </tr> - <tr class="layout"> - <td class="left"><tt>{ { \3*, i8 }, i32 }</tt></td> - <td class="left">Recursive structure where the upref refers to the out-most - structure.</td> - </tr> -</table> - -</div> - -</div> - <!-- *********************************************************************** --> <h2><a name="constants">Constants</a></h2> <!-- *********************************************************************** --> @@ -6064,7 +5997,7 @@ LLVM</a>.</p> <h5>Syntax:</h5> <pre> - declare void @llvm.prefetch(i8* <address>, i32 <rw>, i32 <locality>) + declare void @llvm.prefetch(i8* <address>, i32 <rw>, i32 <locality>, i32 <cache type>) </pre> <h5>Overview:</h5> @@ -6077,8 +6010,10 @@ LLVM</a>.</p> <p><tt>address</tt> is the address to be prefetched, <tt>rw</tt> is the specifier determining if the fetch should be for a read (0) or write (1), and <tt>locality</tt> is a temporal locality specifier ranging from (0) - no - locality, to (3) - extremely local keep in cache. The <tt>rw</tt> - and <tt>locality</tt> arguments must be constant integers.</p> + locality, to (3) - extremely local keep in cache. The <tt>cache type</tt> + specifies whether the prefetch is performed on the data (1) or instruction (0) + cache. The <tt>rw</tt>, <tt>locality</tt> and <tt>cache type</tt> arguments + must be constant integers.</p> <h5>Semantics:</h5> <p>This intrinsic does not modify the behavior of the program. In particular, @@ -6563,6 +6498,37 @@ LLVM</a>.</p> <p>This function returns the same values as the libm <tt>log</tt> functions would, and handles error conditions in the same way.</p> +<h4> + <a name="int_fma">'<tt>llvm.fma.*</tt>' Intrinsic</a> +</h4> + +<div> + +<h5>Syntax:</h5> +<p>This is an overloaded intrinsic. You can use <tt>llvm.fma</tt> on any + floating point or vector of floating point type. Not all targets support all + types however.</p> + +<pre> + declare float @llvm.fma.f32(float %a, float %b, float %c) + declare double @llvm.fma.f64(double %a, double %b, double %c) + declare x86_fp80 @llvm.fma.f80(x86_fp80 %a, x86_fp80 %b, x86_fp80 %c) + declare fp128 @llvm.fma.f128(fp128 %a, fp128 %b, fp128 %c) + declare ppc_fp128 @llvm.fma.ppcf128(ppc_fp128 %a, ppc_fp128 %b, ppc_fp128 %c) +</pre> + +<h5>Overview:</h5> +<p>The '<tt>llvm.fma.*</tt>' intrinsics perform the fused multiply-add + operation.</p> + +<h5>Arguments:</h5> +<p>The argument and return value are floating point numbers of the same + type.</p> + +<h5>Semantics:</h5> +<p>This function returns the same values as the libm <tt>fma</tt> functions + would.</p> + </div> <!-- ======================================================================= --> @@ -6619,7 +6585,8 @@ LLVM</a>.</p> <h5>Syntax:</h5> <p>This is an overloaded intrinsic. You can use llvm.ctpop on any integer bit - width. Not all targets support all bit widths however.</p> + width, or on any vector with integer elements. Not all targets support all + bit widths or vector types, however.</p> <pre> declare i8 @llvm.ctpop.i8(i8 <src>) @@ -6627,6 +6594,7 @@ LLVM</a>.</p> declare i32 @llvm.ctpop.i32(i32 <src>) declare i64 @llvm.ctpop.i64(i64 <src>) declare i256 @llvm.ctpop.i256(i256 <src>) + declare <2 x i32> @llvm.ctpop.v2i32(<2 x i32> <src>) </pre> <h5>Overview:</h5> @@ -6635,10 +6603,12 @@ LLVM</a>.</p> <h5>Arguments:</h5> <p>The only argument is the value to be counted. The argument may be of any - integer type. The return type must match the argument type.</p> + integer type, or a vector with integer elements. + The return type must match the argument type.</p> <h5>Semantics:</h5> -<p>The '<tt>llvm.ctpop</tt>' intrinsic counts the 1's in a variable.</p> +<p>The '<tt>llvm.ctpop</tt>' intrinsic counts the 1's in a variable, or within each + element of a vector.</p> </div> @@ -6651,7 +6621,8 @@ LLVM</a>.</p> <h5>Syntax:</h5> <p>This is an overloaded intrinsic. You can use <tt>llvm.ctlz</tt> on any - integer bit width. Not all targets support all bit widths however.</p> + integer bit width, or any vector whose elements are integers. Not all + targets support all bit widths or vector types, however.</p> <pre> declare i8 @llvm.ctlz.i8 (i8 <src>) @@ -6659,6 +6630,7 @@ LLVM</a>.</p> declare i32 @llvm.ctlz.i32(i32 <src>) declare i64 @llvm.ctlz.i64(i64 <src>) declare i256 @llvm.ctlz.i256(i256 <src>) + declare <2 x i32> @llvm.ctlz.v2i32(<2 x i32> <src;gt) </pre> <h5>Overview:</h5> @@ -6667,11 +6639,13 @@ LLVM</a>.</p> <h5>Arguments:</h5> <p>The only argument is the value to be counted. The argument may be of any - integer type. The return type must match the argument type.</p> + integer type, or any vector type with integer element type. + The return type must match the argument type.</p> <h5>Semantics:</h5> <p>The '<tt>llvm.ctlz</tt>' intrinsic counts the leading (most significant) - zeros in a variable. If the src == 0 then the result is the size in bits of + zeros in a variable, or within each element of the vector if the operation + is of vector type. If the src == 0 then the result is the size in bits of the type of src. For example, <tt>llvm.ctlz(i32 2) = 30</tt>.</p> </div> @@ -6685,7 +6659,8 @@ LLVM</a>.</p> <h5>Syntax:</h5> <p>This is an overloaded intrinsic. You can use <tt>llvm.cttz</tt> on any - integer bit width. Not all targets support all bit widths however.</p> + integer bit width, or any vector of integer elements. Not all targets + support all bit widths or vector types, however.</p> <pre> declare i8 @llvm.cttz.i8 (i8 <src>) @@ -6693,6 +6668,7 @@ LLVM</a>.</p> declare i32 @llvm.cttz.i32(i32 <src>) declare i64 @llvm.cttz.i64(i64 <src>) declare i256 @llvm.cttz.i256(i256 <src>) + declase <2 x i32> @llvm.cttz.v2i32(<2 x i32> <src>) </pre> <h5>Overview:</h5> @@ -6701,11 +6677,13 @@ LLVM</a>.</p> <h5>Arguments:</h5> <p>The only argument is the value to be counted. The argument may be of any - integer type. The return type must match the argument type.</p> + integer type, or a vectory with integer element type.. The return type + must match the argument type.</p> <h5>Semantics:</h5> <p>The '<tt>llvm.cttz</tt>' intrinsic counts the trailing (least significant) - zeros in a variable. If the src == 0 then the result is the size in bits of + zeros in a variable, or within each element of a vector. + If the src == 0 then the result is the size in bits of the type of src. For example, <tt>llvm.cttz(2) = 1</tt>.</p> </div> @@ -7302,7 +7280,7 @@ LLVM</a>.</p> store i32 4, %ptr %result1 = load i32* %ptr <i>; yields {i32}:result1 = 4</i> - call void @llvm.memory.barrier(i1 false, i1 true, i1 false, i1 false) + call void @llvm.memory.barrier(i1 false, i1 true, i1 false, i1 false, i1 true) <i>; guarantee the above finishes</i> store i32 8, %ptr <i>; before this begins</i> </pre> @@ -8017,7 +7995,7 @@ LLVM</a>.</p> <a href="mailto:sabre@nondot.org">Chris Lattner</a><br> <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a><br> - Last modified: $Date: 2011-05-27 02:36:31 +0200 (Fri, 27 May 2011) $ + Last modified: $Date: 2011-07-09 19:41:24 +0200 (Sat, 09 Jul 2011) $ </address> </body> diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index 6af922b..ed43f1f 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -64,6 +64,7 @@ option</a></li> <li><a href="#dss_deque"><deque></a></li> <li><a href="#dss_list"><list></a></li> <li><a href="#dss_ilist">llvm/ADT/ilist.h</a></li> + <li><a href="#dss_packedvector">llvm/ADT/PackedVector.h</a></li> <li><a href="#dss_other">Other Sequential Container Options</a></li> </ul></li> <li><a href="#ds_set">Set-Like Containers (std::set, SmallSet, SetVector, etc)</a> @@ -159,15 +160,8 @@ with another <tt>Value</tt></a> </li> <li><a href="#advanced">Advanced Topics</a> <ul> - <li><a href="#TypeResolve">LLVM Type Resolution</a> - <ul> - <li><a href="#BuildRecType">Basic Recursive Type Construction</a></li> - <li><a href="#refineAbstractTypeTo">The <tt>refineAbstractTypeTo</tt> method</a></li> - <li><a href="#PATypeHolder">The PATypeHolder Class</a></li> - <li><a href="#AbstractTypeUser">The AbstractTypeUser Class</a></li> - </ul></li> - <li><a href="#SymbolTable">The <tt>ValueSymbolTable</tt> and <tt>TypeSymbolTable</tt> classes</a></li> + <li><a href="#SymbolTable">The <tt>ValueSymbolTable</tt> class</a></li> <li><a href="#UserLayout">The <tt>User</tt> and owned <tt>Use</tt> classes' memory layout</a></li> </ul></li> @@ -811,6 +805,10 @@ found at <a href="http://www.graphviz.org/doc/info/attrs.html">Graph Attributes</a>.) If you want to restart and clear all the current graph attributes, then you can <tt>call DAG.clearGraphAttrs()</tt>. </p> +<p>Note that graph visualization features are compiled out of Release builds +to reduce file size. This means that you need a Debug+Asserts or +Release+Asserts build to use these features.</p> + </div> </div> @@ -1065,6 +1063,44 @@ Related classes of interest are explained in the following subsections: <!-- _______________________________________________________________________ --> <h4> + <a name="dss_packedvector">llvm/ADT/PackedVector.h</a> +</h4> + +<div> +<p> +Useful for storing a vector of values using only a few number of bits for each +value. Apart from the standard operations of a vector-like container, it can +also perform an 'or' set operation. +</p> + +<p>For example:</p> + +<div class="doc_code"> +<pre> +enum State { + None = 0x0, + FirstCondition = 0x1, + SecondCondition = 0x2, + Both = 0x3 +}; + +State get() { + PackedVector<State, 2> Vec1; + Vec1.push_back(FirstCondition); + + PackedVector<State, 2> Vec2; + Vec2.push_back(SecondCondition); + + Vec1 |= Vec2; + return Vec1[0]; // returns 'Both'. +} +</pre> +</div> + +</div> + +<!-- _______________________________________________________________________ --> +<h4> <a name="dss_ilist_traits">ilist_traits</a> </h4> @@ -2602,173 +2638,10 @@ 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> + <!-- ======================================================================= --> <h3> - <a name="TypeResolve">LLVM Type Resolution</a> -</h3> - -<div> - -<p> -The LLVM type system has a very simple goal: allow clients to compare types for -structural equality with a simple pointer comparison (aka a shallow compare). -This goal makes clients much simpler and faster, and is used throughout the LLVM -system. -</p> - -<p> -Unfortunately achieving this goal is not a simple matter. In particular, -recursive types and late resolution of opaque types makes the situation very -difficult to handle. Fortunately, for the most part, our implementation makes -most clients able to be completely unaware of the nasty internal details. The -primary case where clients are exposed to the inner workings of it are when -building a recursive type. In addition to this case, the LLVM bitcode reader, -assembly parser, and linker also have to be aware of the inner workings of this -system. -</p> - -<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, i32 }</tt>"). -Third, a concrete type is a type that is not an abstract type (e.g. "<tt>{ i32, -float }</tt>"). -</p> - -<!-- ______________________________________________________________________ --> -<h4> - <a name="BuildRecType">Basic Recursive Type Construction</a> -</h4> - -<div> - -<p> -Because the most common question is "how do I build a recursive type with LLVM", -we answer it now and explain it as we go. Here we include enough to cause this -to be emitted to an output .ll file: -</p> - -<div class="doc_code"> -<pre> -%mylist = type { %mylist*, i32 } -</pre> -</div> - -<p> -To build this, use the following LLVM APIs: -</p> - -<div class="doc_code"> -<pre> -// <i>Create the initial outer struct</i> -<a href="#PATypeHolder">PATypeHolder</a> StructTy = OpaqueType::get(); -std::vector<const Type*> Elts; -Elts.push_back(PointerType::getUnqual(StructTy)); -Elts.push_back(Type::Int32Ty); -StructType *NewSTy = StructType::get(Elts); - -// <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); - -// <i>NewSTy is potentially invalidated, but StructTy (a <a href="#PATypeHolder">PATypeHolder</a>) is</i> -// <i>kept up-to-date</i> -NewSTy = cast<StructType>(StructTy.get()); - -// <i>Add a name for the type to the module symbol table (optional)</i> -MyModule->addTypeName("mylist", NewSTy); -</pre> -</div> - -<p> -This code shows the basic approach used to build recursive types: build a -non-recursive type using 'opaque', then use type unification to close the cycle. -The type unification step is performed by the <tt><a -href="#refineAbstractTypeTo">refineAbstractTypeTo</a></tt> method, which is -described next. After that, we describe the <a -href="#PATypeHolder">PATypeHolder class</a>. -</p> - -</div> - -<!-- ______________________________________________________________________ --> -<h4> - <a name="refineAbstractTypeTo">The <tt>refineAbstractTypeTo</tt> method</a> -</h4> - -<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 -often used on OpaqueType instances. Type unification is actually a recursive -process. After unification, types can become structurally isomorphic to -existing types, and all duplicates are deleted (to preserve pointer equality). -</p> - -<p> -In the example above, the OpaqueType object is definitely deleted. -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 -live across a call to <tt>refineAbstractTypeTo</tt> (note that non-abstract -types can never move or be deleted). To deal with this, the <a -href="#PATypeHolder">PATypeHolder</a> class is used to maintain a stable -reference to a possibly refined type, and the <a -href="#AbstractTypeUser">AbstractTypeUser</a> class is used to update more -complex datastructures. -</p> - -</div> - -<!-- ______________________________________________________________________ --> -<h4> - <a name="PATypeHolder">The PATypeHolder Class</a> -</h4> - -<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 -automatically updates all PATypeHolder objects to point to the new type. In the -example above, this allows the code to maintain a pointer to the resultant -resolved recursive type, even though the Type*'s are potentially invalidated. -</p> - -<p> -PATypeHolder is an extremely light-weight object that uses a lazy union-find -implementation to update pointers. For example the pointer from a Value to its -Type is maintained by PATypeHolder objects. -</p> - -</div> - -<!-- ______________________________________________________________________ --> -<h4> - <a name="AbstractTypeUser">The AbstractTypeUser Class</a> -</h4> - -<div> - -<p> -Some data structures need more to perform more complex updates when types get -resolved. To support this, a class can derive from the AbstractTypeUser class. -This class -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 any opaque -objects) can never be refined. -</p> -</div> - -</div> - -<!-- ======================================================================= --> -<h3> - <a name="SymbolTable">The <tt>ValueSymbolTable</tt> and - <tt>TypeSymbolTable</tt> classes</a> + <a name="SymbolTable">The <tt>ValueSymbolTable</tt> class</a> </h3> <div> @@ -2777,9 +2650,7 @@ ValueSymbolTable</a></tt> 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 value definitions. The symbol table can provide a name for any <a href="#Value"><tt>Value</tt></a>. -The <tt><a href="http://llvm.org/doxygen/classllvm_1_1TypeSymbolTable.html"> -TypeSymbolTable</a></tt> class is used by the <tt>Module</tt> class to store -names for types.</p> +</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 @@ -2789,13 +2660,12 @@ all LLVM an empty name) do not exist in the symbol table. </p> -<p>These symbol tables support iteration over the values/types in the symbol +<p>Symbol tables support iteration over the values in the symbol table with <tt>begin/end/iterator</tt> and supports querying to see if a specific name is in the symbol table (with <tt>lookup</tt>). The <tt>ValueSymbolTable</tt> class exposes no public mutator methods, instead, simply call <tt>setName</tt> on a value, which will autoinsert it into the -appropriate symbol table. For types, use the Module::addTypeName method to -insert entries into the symbol table.</p> +appropriate symbol table.</p> </div> @@ -3085,9 +2955,6 @@ the <tt>lib/VMCore</tt> directory.</p> <li><tt>bool isFloatingPointTy()</tt>: Return true if this is one of the five 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> @@ -3112,7 +2979,7 @@ the <tt>lib/VMCore</tt> directory.</p> </ul> </dd> <dt><tt>SequentialType</tt></dt> - <dd>This is subclassed by ArrayType and PointerType + <dd>This is subclassed by ArrayType, PointerType and VectorType. <ul> <li><tt>const Type * getElementType() const</tt>: Returns the type of each of the elements in the sequential type. </li> @@ -3149,14 +3016,6 @@ the <tt>lib/VMCore</tt> directory.</p> 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> @@ -4008,7 +3867,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: 2011-04-23 02:30:22 +0200 (Sat, 23 Apr 2011) $ + Last modified: $Date: 2011-07-12 13:37:02 +0200 (Tue, 12 Jul 2011) $ </address> </body> diff --git a/docs/ReleaseNotes.html b/docs/ReleaseNotes.html index 12546c8..d54698d 100644 --- a/docs/ReleaseNotes.html +++ b/docs/ReleaseNotes.html @@ -599,9 +599,53 @@ from the previous release.</p> LLVM API changes are:</p> <ul> -<!-- -<li></ld> ---> + +<li><code>PHINode::reserveOperandSpace</code> has been removed. Instead, you + must specify how many operands to reserve space for when you create the + PHINode, by passing an extra argument into <code>PHINode::Create</code>.</li> + +<li>PHINodes no longer store their incoming BasicBlocks as operands. Instead, + the list of incoming BasicBlocks is stored separately, and can be accessed + with new functions <code>PHINode::block_begin</code> + and <code>PHINode::block_end</code>.</li> + +<li>Various functions now take an <code>ArrayRef</code> instead of either a pair + of pointers (or iterators) to the beginning and end of a range, or a pointer + and a length. Others now return an <code>ArrayRef</code> instead of a + reference to a <code>SmallVector</code> or <code>std::vector</code>. These + include: +<ul> +<!-- Please keep this list sorted. --> +<li><code>CallInst::Create</code></li> +<li><code>ComputeLinearIndex</code> (in <code>llvm/CodeGen/Analysis.h</code>)</li> +<li><code>ConstantArray::get</code></li> +<li><code>ConstantExpr::getExtractElement</code></li> +<li><code>ConstantExpr::getIndices</code></li> +<li><code>ConstantExpr::getInsertElement</code></li> +<li><code>ConstantExpr::getWithOperands</code></li> +<li><code>ConstantVector::get</code></li> +<li><code>DIBuilder::createComplexVariable</code></li> +<li><code>DIBuilder::getOrCreateArray</code></li> +<li><code>ExtractValueInst::Create</code></li> +<li><code>ExtractValueInst::getIndexedType</code></li> +<li><code>ExtractValueInst::getIndices</code></li> +<li><code>FindInsertedValue</code> (in <code>llvm/Analysis/ValueTracking.h</code>)</li> +<li><code>IRBuilder::CreateCall</code></li> +<li><code>IRBuilder::CreateExtractValue</code></li> +<li><code>IRBuilder::CreateInsertValue</code></li> +<li><code>IRBuilder::CreateInvoke</code></li> +<li><code>InsertValueInst::Create</code></li> +<li><code>InsertValueInst::getIndices</code></li> +<li><code>InvokeInst::Create</code></li> +<li><code>MDNode::get</code></li> +<li><code>MDNode::getIfExists</code></li> +<li><code>MDNode::getTemporary</code></li> +<li><code>MDNode::getWhenValsUnresolved</code></li> +</ul></li> + +<li>All forms of <code>StringMap::getOrCreateValue</code> have been remove + except for the one which takes a <code>StringRef</code>.</li> + </ul> </div> @@ -835,7 +879,7 @@ lists</a>.</p> src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a> <a href="http://llvm.org/">LLVM Compiler Infrastructure</a><br> - Last modified: $Date: 2011-05-28 00:50:46 +0200 (Sat, 28 May 2011) $ + Last modified: $Date: 2011-07-15 10:37:34 +0200 (Fri, 15 Jul 2011) $ </address> </body> diff --git a/docs/WritingAnLLVMBackend.html b/docs/WritingAnLLVMBackend.html index c4892cb..dd6f1ec 100644 --- a/docs/WritingAnLLVMBackend.html +++ b/docs/WritingAnLLVMBackend.html @@ -706,8 +706,7 @@ classes using the following class: <div class="doc_code"> <pre> class RegisterClass<string namespace, -list<ValueType> regTypes, int alignment, - list<Register> regList> { +list<ValueType> regTypes, int alignment, dag regList> { string Namespace = namespace; list<ValueType> RegTypes = regTypes; int Size = 0; // spill size, in bits; zero lets tblgen pick the size @@ -717,7 +716,7 @@ list<ValueType> regTypes, int alignment, // default value 1 means a single instruction // A negative value means copying is extremely expensive or impossible int CopyCost = 1; - list<Register> MemberList = regList; + dag MemberList = regList; // for register classes that are subregisters of this class list<RegisterClass> SubRegClassList = []; @@ -749,9 +748,11 @@ list<ValueType> regTypes, int alignment, memory.</li> <li>The final argument, <tt>regList</tt>, specifies which registers are in this - class. If an <tt>allocation_order_*</tt> method is not specified, - then <tt>regList</tt> also defines the order of allocation used by the - register allocator.</li> + class. If an alternative allocation order method is not specified, then + <tt>regList</tt> also defines the order of allocation used by the register + allocator. Besides simply listing registers with <tt>(add R0, R1, ...)</tt>, + more advanced set operators are available. See + <tt>include/llvm/Target/Target.td</tt> for more information.</li> </ul> <p> @@ -761,44 +762,31 @@ classes, the first argument defines the namespace with the string '<tt>SP</tt>'. <tt>FPRegs</tt> defines a group of 32 single-precision floating-point registers (<tt>F0</tt> to <tt>F31</tt>); <tt>DFPRegs</tt> defines a group of 16 double-precision registers -(<tt>D0-D15</tt>). For <tt>IntRegs</tt>, the <tt>MethodProtos</tt> -and <tt>MethodBodies</tt> methods are used by TableGen to insert the specified -code into generated output. +(<tt>D0-D15</tt>). </p> <div class="doc_code"> <pre> -def FPRegs : RegisterClass<"SP", [f32], 32, - [F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, - F16, F17, F18, F19, F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30, F31]>; +// F0, F1, F2, ..., F31 +def FPRegs : RegisterClass<"SP", [f32], 32, (sequence "F%u", 0, 31)>; def DFPRegs : RegisterClass<"SP", [f64], 64, - [D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15]>; + (add D0, D1, D2, D3, D4, D5, D6, D7, D8, + D9, D10, D11, D12, D13, D14, D15)>; def IntRegs : RegisterClass<"SP", [i32], 32, - [L0, L1, L2, L3, L4, L5, L6, L7, - I0, I1, I2, I3, I4, I5, - O0, O1, O2, O3, O4, O5, O7, - G1, - // Non-allocatable regs: - G2, G3, G4, - O6, // stack ptr - I6, // frame ptr - I7, // return address - G0, // constant zero - G5, G6, G7 // reserved for kernel - ]> { - let MethodProtos = [{ - iterator allocation_order_end(const MachineFunction &MF) const; - }]; - let MethodBodies = [{ - IntRegsClass::iterator - IntRegsClass::allocation_order_end(const MachineFunction &MF) const { - return end() - 10 // Don't allocate special registers - -1; - } - }]; -} + (add L0, L1, L2, L3, L4, L5, L6, L7, + I0, I1, I2, I3, I4, I5, + O0, O1, O2, O3, O4, O5, O7, + G1, + // Non-allocatable regs: + G2, G3, G4, + O6, // stack ptr + I6, // frame ptr + I7, // return address + G0, // constant zero + G5, G6, G7 // reserved for kernel + )>; </pre> </div> @@ -820,10 +808,7 @@ which is included at the bottom of <tt>SparcRegisterInfo.cpp</tt>, the SPARC register implementation. The code below shows only the generated integer registers and associated register classes. The order of registers in <tt>IntRegs</tt> reflects the order in the definition of <tt>IntRegs</tt> in -the target description file. Take special note of the use -of <tt>MethodBodies</tt> in <tt>SparcRegisterInfo.td</tt> to create code in -<tt>SparcGenRegisterInfo.inc</tt>. <tt>MethodProtos</tt> generates similar code -in <tt>SparcGenRegisterInfo.h.inc</tt>. +the target description file. </p> <div class="doc_code"> @@ -866,13 +851,7 @@ namespace SP { // Register class instances static const TargetRegisterClass* const IntRegsSuperclasses [] = { NULL }; -... - IntRegsClass::iterator - IntRegsClass::allocation_order_end(const MachineFunction &MF) const { - return end()-10 // Don't allocate special registers - -1; - } - + IntRegsClass::IntRegsClass() : TargetRegisterClass(IntRegsRegClassID, IntRegsVTs, IntRegsSubclasses, IntRegsSuperclasses, IntRegsSubRegClasses, IntRegsSuperRegClasses, 4, 4, 1, IntRegs, IntRegs + 32) {} @@ -880,6 +859,13 @@ namespace SP { // Register class instances </pre> </div> +<p> +The register allocators will avoid using reserved registers, and callee saved +registers are not used until all the volatile registers have been used. That +is usually good enough, but in some cases it may be necessary to provide custom +allocation orders. +</p> + </div> <!-- ======================================================================= --> @@ -2540,7 +2526,7 @@ with assembler. <a href="http://www.woo.com">Mason Woo</a> and <a href="http://misha.brukman.net">Misha Brukman</a><br> <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a> <br> - Last modified: $Date: 2011-04-23 02:30:22 +0200 (Sat, 23 Apr 2011) $ + Last modified: $Date: 2011-06-16 01:28:14 +0200 (Thu, 16 Jun 2011) $ </address> </body> diff --git a/docs/index.html b/docs/index.html index e53b4c3..fc43569 100644 --- a/docs/index.html +++ b/docs/index.html @@ -164,6 +164,7 @@ understand how to use the libraries produced when LLVM is compiled.</li> <li><a href="HowToReleaseLLVM.html">How To Release LLVM To The Public</a> - This is a guide to preparing LLVM releases. Most developers can ignore it.</li> + <li><a href="http://llvm.org/doxygen/">Doxygen generated documentation</a> (<a href="http://llvm.org/doxygen/inherits.html">classes</a>) @@ -239,6 +240,10 @@ programs with link-time optimization on Linux.</li> <li><a href="DebuggingJITedCode.html">The GDB JIT interface</a> - How to debug JITed code with GDB.</li> + +<li><a href="BranchWeightMetadata.html">Branch Weight Metadata</a> - Provides +information about Branch Prediction Information.</li> + </ul> @@ -284,7 +289,7 @@ times each day, making it a high volume list.</li> src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a> <a href="http://llvm.org/">LLVM Compiler Infrastructure</a><br> - Last modified: $Date: 2011-05-30 05:36:58 +0200 (Mon, 30 May 2011) $ + Last modified: $Date: 2011-07-06 20:31:02 +0200 (Wed, 06 Jul 2011) $ </address> </body></html> diff --git a/docs/tutorial/OCamlLangImpl3.html b/docs/tutorial/OCamlLangImpl3.html index e52bb6c..c240bb9 100644 --- a/docs/tutorial/OCamlLangImpl3.html +++ b/docs/tutorial/OCamlLangImpl3.html @@ -95,8 +95,9 @@ an undeclared parameter):</p> <pre> exception Error of string -let the_module = create_module (global_context ()) "my cool jit" -let builder = builder (global_context ()) +let context = global_context () +let the_module = create_module context "my cool jit" +let builder = builder context let named_values:(string, llvalue) Hashtbl.t = Hashtbl.create 10 let double_type = double_type context </pre> @@ -176,9 +177,9 @@ variables</a>.</p> let rhs_val = codegen_expr rhs in begin match op with - | '+' -> build_add lhs_val rhs_val "addtmp" builder - | '-' -> build_sub lhs_val rhs_val "subtmp" builder - | '*' -> build_mul lhs_val rhs_val "multmp" builder + | '+' -> build_fadd lhs_val rhs_val "addtmp" builder + | '-' -> build_fsub lhs_val rhs_val "subtmp" builder + | '*' -> build_fmul lhs_val rhs_val "multmp" builder | '<' -> (* Convert bool 0/1 to double 0.0 or 1.0 *) let i = build_fcmp Fcmp.Ult lhs_val rhs_val "cmptmp" builder in @@ -1086,7 +1087,7 @@ main () <a href="mailto:sabre@nondot.org">Chris Lattner</a><br> <a href="mailto:idadesub@users.sourceforge.net">Erick Tryzelaar</a><br> <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a><br> - Last modified: $Date: 2011-04-23 02:30:22 +0200 (Sat, 23 Apr 2011) $ + Last modified: $Date: 2011-07-15 22:03:30 +0200 (Fri, 15 Jul 2011) $ </address> </body> </html> |