diff options
author | Chris Lattner <sabre@nondot.org> | 2011-07-09 17:41:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-07-09 17:41:24 +0000 |
commit | 1afcace3a3a138b1b18e5c6270caa8dae2261ae2 (patch) | |
tree | 2fed26ec8965151524b81246c7fa7c3e2382fd31 | |
parent | c36ed70ec5c3c99f9559cfaa199373f60219a2be (diff) |
Land the long talked about "type system rewrite" patch. This
patch brings numerous advantages to LLVM. One way to look at it
is through diffstat:
109 files changed, 3005 insertions(+), 5906 deletions(-)
Removing almost 3K lines of code is a good thing. Other advantages
include:
1. Value::getType() is a simple load that can be CSE'd, not a mutating
union-find operation.
2. Types a uniqued and never move once created, defining away PATypeHolder.
3. Structs can be "named" now, and their name is part of the identity that
uniques them. This means that the compiler doesn't merge them structurally
which makes the IR much less confusing.
4. Now that there is no way to get a cycle in a type graph without a named
struct type, "upreferences" go away.
5. Type refinement is completely gone, which should make LTO much MUCH faster
in some common cases with C++ code.
6. Types are now generally immutable, so we can use "Type *" instead
"const Type *" everywhere.
Downsides of this patch are that it removes some functions from the C API,
so people using those will have to upgrade to (not yet added) new API.
"LLVM 3.0" is the right time to do this.
There are still some cleanups pending after this, this patch is large enough
as-is.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134829 91177308-0d34-0410-b5e6-96231b3b80d8
109 files changed, 3032 insertions, 5933 deletions
diff --git a/docs/LangRef.html b/docs/LangRef.html index 08d84df4a8..5959b3d5dc 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> @@ -1535,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> @@ -1703,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> @@ -1842,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 @@ -1852,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> - & |