mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 19:12:56 +02:00
HTML cleanup and validation.
llvm-svn: 108239
This commit is contained in:
parent
710b57b4b1
commit
9af04e360e
@ -370,11 +370,9 @@
|
|||||||
what is considered 'well formed'. For example, the following instruction is
|
what is considered 'well formed'. For example, the following instruction is
|
||||||
syntactically okay, but not well formed:</p>
|
syntactically okay, but not well formed:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%x = <a href="#i_add">add</a> i32 1, %x
|
%x = <a href="#i_add">add</a> i32 1, %x
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>because the definition of <tt>%x</tt> does not dominate all of its uses. The
|
<p>because the definition of <tt>%x</tt> does not dominate all of its uses. The
|
||||||
LLVM infrastructure provides a verification pass that may be used to verify
|
LLVM infrastructure provides a verification pass that may be used to verify
|
||||||
@ -437,29 +435,23 @@
|
|||||||
|
|
||||||
<p>The easy way:</p>
|
<p>The easy way:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%result = <a href="#i_mul">mul</a> i32 %X, 8
|
%result = <a href="#i_mul">mul</a> i32 %X, 8
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>After strength reduction:</p>
|
<p>After strength reduction:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%result = <a href="#i_shl">shl</a> i32 %X, i8 3
|
%result = <a href="#i_shl">shl</a> i32 %X, i8 3
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>And the hard way:</p>
|
<p>And the hard way:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%0 = <a href="#i_add">add</a> i32 %X, %X <i>; yields {i32}:%0</i>
|
%0 = <a href="#i_add">add</a> i32 %X, %X <i>; yields {i32}:%0</i>
|
||||||
%1 = <a href="#i_add">add</a> i32 %0, %0 <i>; yields {i32}:%1</i>
|
%1 = <a href="#i_add">add</a> i32 %0, %0 <i>; yields {i32}:%1</i>
|
||||||
%result = <a href="#i_add">add</a> i32 %1, %1
|
%result = <a href="#i_add">add</a> i32 %1, %1
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>This last way of multiplying <tt>%X</tt> by 8 illustrates several important
|
<p>This last way of multiplying <tt>%X</tt> by 8 illustrates several important
|
||||||
lexical features of LLVM:</p>
|
lexical features of LLVM:</p>
|
||||||
@ -498,8 +490,7 @@
|
|||||||
forward declarations, and merges symbol table entries. Here is an example of
|
forward declarations, and merges symbol table entries. Here is an example of
|
||||||
the "hello world" module:</p>
|
the "hello world" module:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
<i>; Declare the string constant as a global constant.</i>
|
<i>; Declare the string constant as a global constant.</i>
|
||||||
<a href="#identifiers">@.LC0</a> = <a href="#linkage_internal">internal</a> <a href="#globalvars">constant</a> <a href="#t_array">[13 x i8]</a> c"hello world\0A\00" <i>; [13 x i8]*</i>
|
<a href="#identifiers">@.LC0</a> = <a href="#linkage_internal">internal</a> <a href="#globalvars">constant</a> <a href="#t_array">[13 x i8]</a> c"hello world\0A\00" <i>; [13 x i8]*</i>
|
||||||
|
|
||||||
@ -519,7 +510,6 @@ define i32 @main() { <i>; i32()* </i>
|
|||||||
!1 = metadata !{i32 41}
|
!1 = metadata !{i32 41}
|
||||||
!foo = !{!1, null}
|
!foo = !{!1, null}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>This example is made up of a <a href="#globalvars">global variable</a> named
|
<p>This example is made up of a <a href="#globalvars">global variable</a> named
|
||||||
"<tt>.LC0</tt>", an external declaration of the "<tt>puts</tt>" function,
|
"<tt>.LC0</tt>", an external declaration of the "<tt>puts</tt>" function,
|
||||||
@ -793,11 +783,9 @@ define i32 @main() { <i>; i32()* </i>
|
|||||||
it easier to read the IR and make the IR more condensed (particularly when
|
it easier to read the IR and make the IR more condensed (particularly when
|
||||||
recursive types are involved). An example of a name specification is:</p>
|
recursive types are involved). An example of a name specification is:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%mytype = type { %mytype*, i32 }
|
%mytype = type { %mytype*, i32 }
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>You may give a name to any <a href="#typesystem">type</a> except
|
<p>You may give a name to any <a href="#typesystem">type</a> except
|
||||||
"<a href="t_void">void</a>". Type name aliases may be used anywhere a type
|
"<a href="t_void">void</a>". Type name aliases may be used anywhere a type
|
||||||
@ -869,11 +857,9 @@ define i32 @main() { <i>; i32()* </i>
|
|||||||
<p>For example, the following defines a global in a numbered address space with
|
<p>For example, the following defines a global in a numbered address space with
|
||||||
an initializer, section, and alignment:</p>
|
an initializer, section, and alignment:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
@G = addrspace(5) constant float 1.0, section "foo", align 4
|
@G = addrspace(5) constant float 1.0, section "foo", align 4
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -926,15 +912,13 @@ define i32 @main() { <i>; i32()* </i>
|
|||||||
alignments must be a power of 2.</p>
|
alignments must be a power of 2.</p>
|
||||||
|
|
||||||
<h5>Syntax:</h5>
|
<h5>Syntax:</h5>
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
define [<a href="#linkage">linkage</a>] [<a href="#visibility">visibility</a>]
|
define [<a href="#linkage">linkage</a>] [<a href="#visibility">visibility</a>]
|
||||||
[<a href="#callingconv">cconv</a>] [<a href="#paramattrs">ret attrs</a>]
|
[<a href="#callingconv">cconv</a>] [<a href="#paramattrs">ret attrs</a>]
|
||||||
<ResultType> @<FunctionName> ([argument list])
|
<ResultType> @<FunctionName> ([argument list])
|
||||||
[<a href="#fnattrs">fn Attrs</a>] [section "name"] [align N]
|
[<a href="#fnattrs">fn Attrs</a>] [section "name"] [align N]
|
||||||
[<a href="#gc">gc</a>] { ... }
|
[<a href="#gc">gc</a>] { ... }
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -951,11 +935,9 @@ define [<a href="#linkage">linkage</a>] [<a href="#visibility">visibility</a>]
|
|||||||
optional <a href="#visibility">visibility style</a>.</p>
|
optional <a href="#visibility">visibility style</a>.</p>
|
||||||
|
|
||||||
<h5>Syntax:</h5>
|
<h5>Syntax:</h5>
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
@<Name> = alias [Linkage] [Visibility] <AliaseeTy> @<Aliasee>
|
@<Name> = alias [Linkage] [Visibility] <AliaseeTy> @<Aliasee>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -971,12 +953,10 @@ define [<a href="#linkage">linkage</a>] [<a href="#visibility">visibility</a>]
|
|||||||
a named metadata.</p>
|
a named metadata.</p>
|
||||||
|
|
||||||
<h5>Syntax:</h5>
|
<h5>Syntax:</h5>
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
!1 = metadata !{metadata !"one"}
|
!1 = metadata !{metadata !"one"}
|
||||||
!name = !{null, !1}
|
!name = !{null, !1}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -996,13 +976,11 @@ define [<a href="#linkage">linkage</a>] [<a href="#visibility">visibility</a>]
|
|||||||
multiple parameter attributes are needed, they are space separated. For
|
multiple parameter attributes are needed, they are space separated. For
|
||||||
example:</p>
|
example:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
declare i32 @printf(i8* noalias nocapture, ...)
|
declare i32 @printf(i8* noalias nocapture, ...)
|
||||||
declare i32 @atoi(i8 zeroext)
|
declare i32 @atoi(i8 zeroext)
|
||||||
declare signext i8 @returns_signed_char()
|
declare signext i8 @returns_signed_char()
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>Note that any attributes for the function result (<tt>nounwind</tt>,
|
<p>Note that any attributes for the function result (<tt>nounwind</tt>,
|
||||||
<tt>readonly</tt>) come immediately after the argument list.</p>
|
<tt>readonly</tt>) come immediately after the argument list.</p>
|
||||||
@ -1095,11 +1073,9 @@ declare signext i8 @returns_signed_char()
|
|||||||
<p>Each function may specify a garbage collector name, which is simply a
|
<p>Each function may specify a garbage collector name, which is simply a
|
||||||
string:</p>
|
string:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
define void @f() gc "name" { ... }
|
define void @f() gc "name" { ... }
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>The compiler declares the supported values of <i>name</i>. Specifying a
|
<p>The compiler declares the supported values of <i>name</i>. Specifying a
|
||||||
collector which will cause the compiler to alter its output in order to
|
collector which will cause the compiler to alter its output in order to
|
||||||
@ -1122,14 +1098,12 @@ define void @f() gc "name" { ... }
|
|||||||
<p>Function attributes are simple keywords that follow the type specified. If
|
<p>Function attributes are simple keywords that follow the type specified. If
|
||||||
multiple attributes are needed, they are space separated. For example:</p>
|
multiple attributes are needed, they are space separated. For example:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
define void @f() noinline { ... }
|
define void @f() noinline { ... }
|
||||||
define void @f() alwaysinline { ... }
|
define void @f() alwaysinline { ... }
|
||||||
define void @f() alwaysinline optsize { ... }
|
define void @f() alwaysinline optsize { ... }
|
||||||
define void @f() optsize { ... }
|
define void @f() optsize { ... }
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt><tt><b>alignstack(<<em>n</em>>)</b></tt></dt>
|
<dt><tt><b>alignstack(<<em>n</em>>)</b></tt></dt>
|
||||||
@ -1236,12 +1210,10 @@ define void @f() optsize { ... }
|
|||||||
concatenated by LLVM and treated as a single unit, but may be separated in
|
concatenated by LLVM and treated as a single unit, but may be separated in
|
||||||
the <tt>.ll</tt> file if desired. The syntax is very simple:</p>
|
the <tt>.ll</tt> file if desired. The syntax is very simple:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
module asm "inline asm code goes here"
|
module asm "inline asm code goes here"
|
||||||
module asm "more can go here"
|
module asm "more can go here"
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>The strings can contain any character by escaping non-printable characters.
|
<p>The strings can contain any character by escaping non-printable characters.
|
||||||
The escape sequence used is simply "\xx" where "xx" is the two digit hex code
|
The escape sequence used is simply "\xx" where "xx" is the two digit hex code
|
||||||
@ -1263,11 +1235,9 @@ module asm "more can go here"
|
|||||||
data is to be laid out in memory. The syntax for the data layout is
|
data is to be laid out in memory. The syntax for the data layout is
|
||||||
simply:</p>
|
simply:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
target datalayout = "<i>layout specification</i>"
|
target datalayout = "<i>layout specification</i>"
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>The <i>layout specification</i> consists of a list of specifications
|
<p>The <i>layout specification</i> consists of a list of specifications
|
||||||
separated by the minus sign character ('-'). Each specification starts with
|
separated by the minus sign character ('-'). Each specification starts with
|
||||||
@ -1663,8 +1633,6 @@ Classifications</a> </div>
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- _______________________________________________________________________ -->
|
<!-- _______________________________________________________________________ -->
|
||||||
<div class="doc_subsubsection"> <a name="t_array">Array Type</a> </div>
|
<div class="doc_subsubsection"> <a name="t_array">Array Type</a> </div>
|
||||||
|
|
||||||
@ -2198,13 +2166,11 @@ Classifications</a> </div>
|
|||||||
have <a href="#t_pointer">pointer</a> type. For example, the following is a
|
have <a href="#t_pointer">pointer</a> type. For example, the following is a
|
||||||
legal LLVM file:</p>
|
legal LLVM file:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
@X = global i32 17
|
@X = global i32 17
|
||||||
@Y = global i32 42
|
@Y = global i32 42
|
||||||
@Z = global [2 x i32*] [ i32* @X, i32* @Y ]
|
@Z = global [2 x i32*] [ i32* @X, i32* @Y ]
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -2223,8 +2189,7 @@ Classifications</a> </div>
|
|||||||
surprising) transformations that are valid (in pseudo IR):</p>
|
surprising) transformations that are valid (in pseudo IR):</p>
|
||||||
|
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%A = add %X, undef
|
%A = add %X, undef
|
||||||
%B = sub %X, undef
|
%B = sub %X, undef
|
||||||
%C = xor %X, undef
|
%C = xor %X, undef
|
||||||
@ -2233,13 +2198,11 @@ Safe:
|
|||||||
%B = undef
|
%B = undef
|
||||||
%C = undef
|
%C = undef
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>This is safe because all of the output bits are affected by the undef bits.
|
<p>This is safe because all of the output bits are affected by the undef bits.
|
||||||
Any output bit can have a zero or one depending on the input bits.</p>
|
Any output bit can have a zero or one depending on the input bits.</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%A = or %X, undef
|
%A = or %X, undef
|
||||||
%B = and %X, undef
|
%B = and %X, undef
|
||||||
Safe:
|
Safe:
|
||||||
@ -2249,7 +2212,6 @@ Unsafe:
|
|||||||
%A = undef
|
%A = undef
|
||||||
%B = undef
|
%B = undef
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>These logical operations have bits that are not always affected by the input.
|
<p>These logical operations have bits that are not always affected by the input.
|
||||||
For example, if "%X" has a zero bit, then the output of the 'and' operation will
|
For example, if "%X" has a zero bit, then the output of the 'and' operation will
|
||||||
@ -2260,8 +2222,7 @@ optimize the and to 0. Likewise, it is safe to assume that all the bits of
|
|||||||
the undef operand to the or could be set, allowing the or to be folded to
|
the undef operand to the or could be set, allowing the or to be folded to
|
||||||
-1.</p>
|
-1.</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%A = select undef, %X, %Y
|
%A = select undef, %X, %Y
|
||||||
%B = select undef, 42, %Y
|
%B = select undef, 42, %Y
|
||||||
%C = select %X, %Y, undef
|
%C = select %X, %Y, undef
|
||||||
@ -2274,7 +2235,6 @@ Unsafe:
|
|||||||
%B = undef
|
%B = undef
|
||||||
%C = undef
|
%C = undef
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>This set of examples show that undefined select (and conditional branch)
|
<p>This set of examples show that undefined select (and conditional branch)
|
||||||
conditions can go "either way" but they have to come from one of the two
|
conditions can go "either way" but they have to come from one of the two
|
||||||
@ -2284,8 +2244,7 @@ the optimizer is allowed to assume that the undef operand could be the same as
|
|||||||
%Y, allowing the whole select to be eliminated.</p>
|
%Y, allowing the whole select to be eliminated.</p>
|
||||||
|
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%A = xor undef, undef
|
%A = xor undef, undef
|
||||||
|
|
||||||
%B = undef
|
%B = undef
|
||||||
@ -2303,7 +2262,6 @@ Safe:
|
|||||||
%E = undef
|
%E = undef
|
||||||
%F = undef
|
%F = undef
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>This example points out that two undef operands are not necessarily the same.
|
<p>This example points out that two undef operands are not necessarily the same.
|
||||||
This can be surprising to people (and also matches C semantics) where they
|
This can be surprising to people (and also matches C semantics) where they
|
||||||
@ -2316,15 +2274,13 @@ so the value is not necessarily consistent over time. In fact, %A and %C need
|
|||||||
to have the same semantics or the core LLVM "replace all uses with" concept
|
to have the same semantics or the core LLVM "replace all uses with" concept
|
||||||
would not hold.</p>
|
would not hold.</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%A = fdiv undef, %X
|
%A = fdiv undef, %X
|
||||||
%B = fdiv %X, undef
|
%B = fdiv %X, undef
|
||||||
Safe:
|
Safe:
|
||||||
%A = undef
|
%A = undef
|
||||||
b: unreachable
|
b: unreachable
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>These examples show the crucial difference between an <em>undefined
|
<p>These examples show the crucial difference between an <em>undefined
|
||||||
value</em> and <em>undefined behavior</em>. An undefined value (like undef) is
|
value</em> and <em>undefined behavior</em>. An undefined value (like undef) is
|
||||||
@ -2339,15 +2295,13 @@ it: since the undefined operation "can't happen", the optimizer can assume that
|
|||||||
it occurs in dead code.
|
it occurs in dead code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
a: store undef -> %X
|
a: store undef -> %X
|
||||||
b: store %X -> undef
|
b: store %X -> undef
|
||||||
Safe:
|
Safe:
|
||||||
a: <deleted>
|
a: <deleted>
|
||||||
b: unreachable
|
b: unreachable
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>These examples reiterate the fdiv example: a store "of" an undefined value
|
<p>These examples reiterate the fdiv example: a store "of" an undefined value
|
||||||
can be assumed to not have any effect: we can assume that the value is
|
can be assumed to not have any effect: we can assume that the value is
|
||||||
@ -2373,7 +2327,6 @@ has undefined behavior.</p>
|
|||||||
|
|
||||||
<p>Trap value behavior is defined in terms of value <i>dependence</i>:</p>
|
<p>Trap value behavior is defined in terms of value <i>dependence</i>:</p>
|
||||||
|
|
||||||
<p>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Values other than <a href="#i_phi"><tt>phi</tt></a> nodes depend on
|
<li>Values other than <a href="#i_phi"><tt>phi</tt></a> nodes depend on
|
||||||
their operands.</li>
|
their operands.</li>
|
||||||
@ -2417,7 +2370,6 @@ has undefined behavior.</p>
|
|||||||
<li>Dependence is transitive.</li>
|
<li>Dependence is transitive.</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>Whenever a trap value is generated, all values which depend on it evaluate
|
<p>Whenever a trap value is generated, all values which depend on it evaluate
|
||||||
to trap. If they have side effects, the evoke their side effects as if each
|
to trap. If they have side effects, the evoke their side effects as if each
|
||||||
@ -2426,8 +2378,7 @@ has undefined behavior.</p>
|
|||||||
|
|
||||||
<p>Here are some examples:</p>
|
<p>Here are some examples:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
entry:
|
entry:
|
||||||
%trap = sub nuw i32 0, 1 ; Results in a trap value.
|
%trap = sub nuw i32 0, 1 ; Results in a trap value.
|
||||||
%still_trap = and i32 %trap, 0 ; Whereas (and i32 undef, 0) would return 0.
|
%still_trap = and i32 %trap, 0 ; Whereas (and i32 undef, 0) would return 0.
|
||||||
@ -2462,7 +2413,6 @@ end:
|
|||||||
; so this is defined (ignoring earlier
|
; so this is defined (ignoring earlier
|
||||||
; undefined behavior in this example).
|
; undefined behavior in this example).
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -2644,31 +2594,25 @@ end:
|
|||||||
containing the asm needs to align its stack conservatively. An example
|
containing the asm needs to align its stack conservatively. An example
|
||||||
inline assembler expression is:</p>
|
inline assembler expression is:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
i32 (i32) asm "bswap $0", "=r,r"
|
i32 (i32) asm "bswap $0", "=r,r"
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>Inline assembler expressions may <b>only</b> be used as the callee operand of
|
<p>Inline assembler expressions may <b>only</b> be used as the callee operand of
|
||||||
a <a href="#i_call"><tt>call</tt> instruction</a>. Thus, typically we
|
a <a href="#i_call"><tt>call</tt> instruction</a>. Thus, typically we
|
||||||
have:</p>
|
have:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%X = call i32 asm "<a href="#int_bswap">bswap</a> $0", "=r,r"(i32 %Y)
|
%X = call i32 asm "<a href="#int_bswap">bswap</a> $0", "=r,r"(i32 %Y)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>Inline asms with side effects not visible in the constraint list must be
|
<p>Inline asms with side effects not visible in the constraint list must be
|
||||||
marked as having side effects. This is done through the use of the
|
marked as having side effects. This is done through the use of the
|
||||||
'<tt>sideeffect</tt>' keyword, like so:</p>
|
'<tt>sideeffect</tt>' keyword, like so:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
call void asm sideeffect "eieio", ""()
|
call void asm sideeffect "eieio", ""()
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>In some cases inline asms will contain code that will not work unless the
|
<p>In some cases inline asms will contain code that will not work unless the
|
||||||
stack is aligned in some way, such as calls or SSE instructions on x86,
|
stack is aligned in some way, such as calls or SSE instructions on x86,
|
||||||
@ -2677,11 +2621,9 @@ call void asm sideeffect "eieio", ""()
|
|||||||
contain and should generate its usual stack alignment code in the prologue
|
contain and should generate its usual stack alignment code in the prologue
|
||||||
if the '<tt>alignstack</tt>' keyword is present:</p>
|
if the '<tt>alignstack</tt>' keyword is present:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
call void asm alignstack "eieio", ""()
|
call void asm alignstack "eieio", ""()
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>If both keywords appear the '<tt>sideeffect</tt>' keyword must come
|
<p>If both keywords appear the '<tt>sideeffect</tt>' keyword must come
|
||||||
first.</p>
|
first.</p>
|
||||||
@ -2705,13 +2647,11 @@ call void asm alignstack "eieio", ""()
|
|||||||
front-end to correlate backend errors that occur with inline asm back to the
|
front-end to correlate backend errors that occur with inline asm back to the
|
||||||
source code that produced it. For example:</p>
|
source code that produced it. For example:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
call void asm sideeffect "something bad", ""()<b>, !srcloc !42</b>
|
call void asm sideeffect "something bad", ""()<b>, !srcloc !42</b>
|
||||||
...
|
...
|
||||||
!42 = !{ i32 1234567 }
|
!42 = !{ i32 1234567 }
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>It is up to the front-end to make sense of the magic numbers it places in the
|
<p>It is up to the front-end to make sense of the magic numbers it places in the
|
||||||
IR.</p>
|
IR.</p>
|
||||||
@ -2746,22 +2686,18 @@ call void asm sideeffect "something bad", ""()<b>, !srcloc !42</b>
|
|||||||
example: "<tt>!foo = metadata !{!4, !3}</tt>".
|
example: "<tt>!foo = metadata !{!4, !3}</tt>".
|
||||||
|
|
||||||
<p>Metadata can be used as function arguments. Here <tt>llvm.dbg.value</tt>
|
<p>Metadata can be used as function arguments. Here <tt>llvm.dbg.value</tt>
|
||||||
function is using two metadata arguments.
|
function is using two metadata arguments.</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
|
call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
|
||||||
</pre>
|
</pre>
|
||||||
</div></p>
|
|
||||||
|
|
||||||
<p>Metadata can be attached with an instruction. Here metadata <tt>!21</tt> is
|
<p>Metadata can be attached with an instruction. Here metadata <tt>!21</tt> is
|
||||||
attached with <tt>add</tt> instruction using <tt>!dbg</tt> identifier.
|
attached with <tt>add</tt> instruction using <tt>!dbg</tt> identifier.</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%indvar.next = add i64 %indvar, 1, !dbg !21
|
%indvar.next = add i64 %indvar, 1, !dbg !21
|
||||||
</pre>
|
</pre>
|
||||||
</div></p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -4389,8 +4325,8 @@ Instruction</a> </div>
|
|||||||
|
|
||||||
<h5>Syntax:</h5>
|
<h5>Syntax:</h5>
|
||||||
<pre>
|
<pre>
|
||||||
store <ty> <value>, <ty>* <pointer>[, align <alignment>][, !nontemporal !<index>] <i>; yields {void}</i>
|
store <ty> <value>, <ty>* <pointer>[, align <alignment>][, !nontemporal !<index>] <i>; yields {void}</i>
|
||||||
volatile store <ty> <value>, <ty>* <pointer>[, align <alignment>][, !nontemporal !<index>] <i>; yields {void}</i>
|
volatile store <ty> <value>, <ty>* <pointer>[, align <alignment>][, !nontemporal !<index>] <i>; yields {void}</i>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h5>Overview:</h5>
|
<h5>Overview:</h5>
|
||||||
@ -4415,7 +4351,7 @@ Instruction</a> </div>
|
|||||||
produce less efficient code. An alignment of 1 is always safe.</p>
|
produce less efficient code. An alignment of 1 is always safe.</p>
|
||||||
|
|
||||||
<p>The optional !nontemporal metadata must reference a single metatadata
|
<p>The optional !nontemporal metadata must reference a single metatadata
|
||||||
name <index> corresponding to a metadata node with one i32 entry of
|
name <index> corresponding to a metadata node with one i32 entry of
|
||||||
value 1. The existence of the !nontemporal metatadata on the
|
value 1. The existence of the !nontemporal metatadata on the
|
||||||
instruction tells the optimizer and code generator that this load is
|
instruction tells the optimizer and code generator that this load is
|
||||||
not expected to be reused in the cache. The code generator may
|
not expected to be reused in the cache. The code generator may
|
||||||
@ -4482,8 +4418,7 @@ Instruction</a> </div>
|
|||||||
<p>For example, let's consider a C code fragment and how it gets compiled to
|
<p>For example, let's consider a C code fragment and how it gets compiled to
|
||||||
LLVM:</p>
|
LLVM:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
struct RT {
|
struct RT {
|
||||||
char A;
|
char A;
|
||||||
int B[10][20];
|
int B[10][20];
|
||||||
@ -4499,12 +4434,10 @@ int *foo(struct ST *s) {
|
|||||||
return &s[1].Z.B[5][13];
|
return &s[1].Z.B[5][13];
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>The LLVM code generated by the GCC frontend is:</p>
|
<p>The LLVM code generated by the GCC frontend is:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%RT = <a href="#namedtypes">type</a> { i8 , [10 x [20 x i32]], i8 }
|
%RT = <a href="#namedtypes">type</a> { i8 , [10 x [20 x i32]], i8 }
|
||||||
%ST = <a href="#namedtypes">type</a> { i32, double, %RT }
|
%ST = <a href="#namedtypes">type</a> { i32, double, %RT }
|
||||||
|
|
||||||
@ -4514,7 +4447,6 @@ entry:
|
|||||||
ret i32* %reg
|
ret i32* %reg
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<h5>Semantics:</h5>
|
<h5>Semantics:</h5>
|
||||||
<p>In the example above, the first index is indexing into the '<tt>%ST*</tt>'
|
<p>In the example above, the first index is indexing into the '<tt>%ST*</tt>'
|
||||||
@ -5585,8 +5517,7 @@ freestanding environments and non-C-based languages.</p>
|
|||||||
instruction and the variable argument handling intrinsic functions are
|
instruction and the variable argument handling intrinsic functions are
|
||||||
used.</p>
|
used.</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
define i32 @test(i32 %X, ...) {
|
define i32 @test(i32 %X, ...) {
|
||||||
; Initialize variable argument processing
|
; Initialize variable argument processing
|
||||||
%ap = alloca i8*
|
%ap = alloca i8*
|
||||||
@ -5611,7 +5542,6 @@ declare void @llvm.va_start(i8*)
|
|||||||
declare void @llvm.va_copy(i8*, i8*)
|
declare void @llvm.va_copy(i8*, i8*)
|
||||||
declare void @llvm.va_end(i8*)
|
declare void @llvm.va_end(i8*)
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -6977,14 +6907,12 @@ LLVM</a>.</p>
|
|||||||
pointer has signature <tt>i32 (i32, i32)*</tt>. It can be created as
|
pointer has signature <tt>i32 (i32, i32)*</tt>. It can be created as
|
||||||
follows:</p>
|
follows:</p>
|
||||||
|
|
||||||
<div class="doc_code">
|
<pre class="doc_code">
|
||||||
<pre>
|
|
||||||
%tramp = alloca [10 x i8], align 4 ; size and alignment only correct for X86
|
%tramp = alloca [10 x i8], align 4 ; size and alignment only correct for X86
|
||||||
%tramp1 = getelementptr [10 x i8]* %tramp, i32 0, i32 0
|
%tramp1 = getelementptr [10 x i8]* %tramp, i32 0, i32 0
|
||||||
%p = call i8* @llvm.init.trampoline(i8* %tramp1, i8* bitcast (i32 (i8* nest , i32, i32)* @f to i8*), i8* %nval)
|
%p = call i8* @llvm.init.trampoline(i8* %tramp1, i8* bitcast (i32 (i8* nest , i32, i32)* @f to i8*), i8* %nval)
|
||||||
%fp = bitcast i8* %p to i32 (i32, i32)*
|
%fp = bitcast i8* %p to i32 (i32, i32)*
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>The call <tt>%val = call i32 %fp(i32 %x, i32 %y)</tt> is then equivalent
|
<p>The call <tt>%val = call i32 %fp(i32 %x, i32 %y)</tt> is then equivalent
|
||||||
to <tt>%val = call i32 %f(i8* %nval, i32 %x, i32 %y)</tt>.</p>
|
to <tt>%val = call i32 %f(i8* %nval, i32 %x, i32 %y)</tt>.</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user