mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
OK, after checking the backwards compatibility code on X86 and the new code
path on alpha, now has come the time for new vararg support. So, with out further ado, I revert behavior back a couple of years! Well, ok, I lied. A few more notes. First, the Simple ISels cannot be expected to work any longer, but they should still compile Second, there are likely some bugs to track down once the nightly testers start with this. Third, the initial patch doesn't include sparcv9, but I'll do that today. Forth, subsequent patches won't bother being long winded. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22251 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
134d2e4af8
commit
8bf607a221
@ -101,7 +101,6 @@
|
|||||||
<li><a href="#i_cast">'<tt>cast .. to</tt>' Instruction</a></li>
|
<li><a href="#i_cast">'<tt>cast .. to</tt>' Instruction</a></li>
|
||||||
<li><a href="#i_select">'<tt>select</tt>' Instruction</a></li>
|
<li><a href="#i_select">'<tt>select</tt>' Instruction</a></li>
|
||||||
<li><a href="#i_call">'<tt>call</tt>' Instruction</a></li>
|
<li><a href="#i_call">'<tt>call</tt>' Instruction</a></li>
|
||||||
<li><a href="#i_vanext">'<tt>vanext</tt>' Instruction</a></li>
|
|
||||||
<li><a href="#i_vaarg">'<tt>vaarg</tt>' Instruction</a></li>
|
<li><a href="#i_vaarg">'<tt>vaarg</tt>' Instruction</a></li>
|
||||||
</ol>
|
</ol>
|
||||||
</li>
|
</li>
|
||||||
@ -2209,58 +2208,6 @@ the <a href="#i_invoke">invoke</a> instruction.</p>
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- _______________________________________________________________________ -->
|
|
||||||
<div class="doc_subsubsection">
|
|
||||||
<a name="i_vanext">'<tt>vanext</tt>' Instruction</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="doc_text">
|
|
||||||
|
|
||||||
<h5>Syntax:</h5>
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
<resultarglist> = vanext <va_list> <arglist>, <argty>
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Overview:</h5>
|
|
||||||
|
|
||||||
<p>The '<tt>vanext</tt>' instruction is used to access arguments passed
|
|
||||||
through the "variable argument" area of a function call. It is used to
|
|
||||||
implement the <tt>va_arg</tt> macro in C.</p>
|
|
||||||
|
|
||||||
<h5>Arguments:</h5>
|
|
||||||
|
|
||||||
<p>This instruction takes a <tt>va_list</tt> value and the type of the
|
|
||||||
argument. It returns another <tt>va_list</tt>. The actual type of
|
|
||||||
<tt>va_list</tt> may be defined differently for different targets. Most targets
|
|
||||||
use a <tt>va_list</tt> type of <tt>sbyte*</tt> or some other pointer type.</p>
|
|
||||||
|
|
||||||
<h5>Semantics:</h5>
|
|
||||||
|
|
||||||
<p>The '<tt>vanext</tt>' instruction advances the specified <tt>va_list</tt>
|
|
||||||
past an argument of the specified type. In conjunction with the <a
|
|
||||||
href="#i_vaarg"><tt>vaarg</tt></a> instruction, it is used to implement
|
|
||||||
the <tt>va_arg</tt> macro available in C. For more information, see
|
|
||||||
the variable argument handling <a href="#int_varargs">Intrinsic
|
|
||||||
Functions</a>.</p>
|
|
||||||
|
|
||||||
<p>It is legal for this instruction to be called in a function which
|
|
||||||
does not take a variable number of arguments, for example, the <tt>vfprintf</tt>
|
|
||||||
function.</p>
|
|
||||||
|
|
||||||
<p><tt>vanext</tt> is an LLVM instruction instead of an <a
|
|
||||||
href="#intrinsics">intrinsic function</a> because it takes a type as an
|
|
||||||
argument. The type refers to the current argument in the <tt>va_list</tt>; it
|
|
||||||
tells the compiler how far on the stack it needs to advance to find the next
|
|
||||||
argument.</p>
|
|
||||||
|
|
||||||
<h5>Example:</h5>
|
|
||||||
|
|
||||||
<p>See the <a href="#int_varargs">variable argument processing</a>
|
|
||||||
section.</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- _______________________________________________________________________ -->
|
<!-- _______________________________________________________________________ -->
|
||||||
<div class="doc_subsubsection">
|
<div class="doc_subsubsection">
|
||||||
<a name="i_vaarg">'<tt>vaarg</tt>' Instruction</a>
|
<a name="i_vaarg">'<tt>vaarg</tt>' Instruction</a>
|
||||||
@ -2271,34 +2218,35 @@ section.</p>
|
|||||||
<h5>Syntax:</h5>
|
<h5>Syntax:</h5>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
<resultval> = vaarg <va_list> <arglist>, <argty>
|
<resultval> = va_arg <va_list*> <arglist>, <argty>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h5>Overview:</h5>
|
<h5>Overview:</h5>
|
||||||
|
|
||||||
<p>The '<tt>vaarg</tt>' instruction is used to access arguments passed through
|
<p>The '<tt>va_arg</tt>' instruction is used to access arguments passed through
|
||||||
the "variable argument" area of a function call. It is used to implement the
|
the "variable argument" area of a function call. It is used to implement the
|
||||||
<tt>va_arg</tt> macro in C.</p>
|
<tt>va_arg</tt> macro in C.</p>
|
||||||
|
|
||||||
<h5>Arguments:</h5>
|
<h5>Arguments:</h5>
|
||||||
|
|
||||||
<p>This instruction takes a <tt>va_list</tt> value and the type of the
|
<p>This instruction takes a <tt>va_list*</tt> value and the type of
|
||||||
argument. It returns a value of the specified argument type. Again, the actual
|
the argument. It returns a value of the specified argument type and
|
||||||
type of <tt>va_list</tt> is target specific.</p>
|
increments the <tt>va_list</tt> to poin to the next argument. Again, the
|
||||||
|
actual type of <tt>va_list</tt> is target specific.</p>
|
||||||
|
|
||||||
<h5>Semantics:</h5>
|
<h5>Semantics:</h5>
|
||||||
|
|
||||||
<p>The '<tt>vaarg</tt>' instruction loads an argument of the specified type from
|
<p>The '<tt>va_arg</tt>' instruction loads an argument of the specified
|
||||||
the specified <tt>va_list</tt>. In conjunction with the <a
|
type from the specified <tt>va_list</tt> and causes the
|
||||||
href="#i_vanext"><tt>vanext</tt></a> instruction, it is used to implement the
|
<tt>va_list</tt> to point to the next argument. For more information,
|
||||||
<tt>va_arg</tt> macro available in C. For more information, see the variable
|
see the variable argument handling <a href="#int_varargs">Intrinsic
|
||||||
argument handling <a href="#int_varargs">Intrinsic Functions</a>.</p>
|
Functions</a>.</p>
|
||||||
|
|
||||||
<p>It is legal for this instruction to be called in a function which does not
|
<p>It is legal for this instruction to be called in a function which does not
|
||||||
take a variable number of arguments, for example, the <tt>vfprintf</tt>
|
take a variable number of arguments, for example, the <tt>vfprintf</tt>
|
||||||
function.</p>
|
function.</p>
|
||||||
|
|
||||||
<p><tt>vaarg</tt> is an LLVM instruction instead of an <a
|
<p><tt>va_arg</tt> is an LLVM instruction instead of an <a
|
||||||
href="#intrinsics">intrinsic function</a> because it takes a type as an
|
href="#intrinsics">intrinsic function</a> because it takes a type as an
|
||||||
argument.</p>
|
argument.</p>
|
||||||
|
|
||||||
@ -2361,20 +2309,20 @@ used.</p>
|
|||||||
<pre>
|
<pre>
|
||||||
int %test(int %X, ...) {
|
int %test(int %X, ...) {
|
||||||
; Initialize variable argument processing
|
; Initialize variable argument processing
|
||||||
%ap = call sbyte* %<a href="#i_va_start">llvm.va_start</a>()
|
%ap = alloca sbyte*
|
||||||
|
call void %<a href="#i_va_start">llvm.va_start</a>(sbyte** %ap)
|
||||||
|
|
||||||
; Read a single integer argument
|
; Read a single integer argument
|
||||||
%tmp = vaarg sbyte* %ap, int
|
%tmp = va_arg sbyte** %ap, int
|
||||||
|
|
||||||
; Advance to the next argument
|
|
||||||
%ap2 = vanext sbyte* %ap, int
|
|
||||||
|
|
||||||
; Demonstrate usage of llvm.va_copy and llvm.va_end
|
; Demonstrate usage of llvm.va_copy and llvm.va_end
|
||||||
%aq = call sbyte* %<a href="#i_va_copy">llvm.va_copy</a>(sbyte* %ap2)
|
%aq = alloca sbyte*
|
||||||
call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %aq)
|
%apv = load sbyte** %ap
|
||||||
|
call void %<a href="#i_va_copy">llvm.va_copy</a>(sbyte** %aq, sbyte* %apv)
|
||||||
|
call void %<a href="#i_va_end">llvm.va_end</a>(sbyte** %aq)
|
||||||
|
|
||||||
; Stop processing of arguments.
|
; Stop processing of arguments.
|
||||||
call void %<a href="#i_va_end">llvm.va_end</a>(sbyte* %ap2)
|
call void %<a href="#i_va_end">llvm.va_end</a>(sbyte** %ap)
|
||||||
ret int %tmp
|
ret int %tmp
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
@ -2388,19 +2336,25 @@ int %test(int %X, ...) {
|
|||||||
|
|
||||||
<div class="doc_text">
|
<div class="doc_text">
|
||||||
<h5>Syntax:</h5>
|
<h5>Syntax:</h5>
|
||||||
<pre> declare <va_list> %llvm.va_start()<br></pre>
|
<pre> declare void %llvm.va_start(<va_list>* <arglist>)<br></pre>
|
||||||
<h5>Overview:</h5>
|
<h5>Overview:</h5>
|
||||||
<p>The '<tt>llvm.va_start</tt>' intrinsic returns a new <tt><arglist></tt>
|
<P>The '<tt>llvm.va_start</tt>' intrinsic initializes
|
||||||
for subsequent use by the variable argument intrinsics.</p>
|
<tt>*<arglist></tt> for subsequent use by <tt><a
|
||||||
|
href="#i_va_arg">va_arg</a></tt>.</p>
|
||||||
|
|
||||||
|
<h5>Arguments:</h5>
|
||||||
|
|
||||||
|
<P>The argument is a pointer to a <tt>va_list</tt> element to initialize.</p>
|
||||||
|
|
||||||
<h5>Semantics:</h5>
|
<h5>Semantics:</h5>
|
||||||
<p>The '<tt>llvm.va_start</tt>' intrinsic works just like the <tt>va_start</tt>
|
|
||||||
macro available in C. In a target-dependent way, it initializes and
|
<P>The '<tt>llvm.va_start</tt>' intrinsic works just like the <tt>va_start</tt>
|
||||||
returns a <tt>va_list</tt> element, so that the next <tt>vaarg</tt>
|
macro available in C. In a target-dependent way, it initializes the
|
||||||
will produce the first variable argument passed to the function. Unlike
|
<tt>va_list</tt> element the argument points to, so that the next call to
|
||||||
the C <tt>va_start</tt> macro, this intrinsic does not need to know the
|
<tt>va_arg</tt> will produce the first variable argument passed to the function.
|
||||||
last argument of the function; the compiler can figure that out.</p>
|
Unlike the C <tt>va_start</tt> macro, this intrinsic does not need to know the
|
||||||
<p>Note that this intrinsic function is only legal to be called from
|
last argument of the function, the compiler can figure that out.</p>
|
||||||
within the body of a variable argument function.</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- _______________________________________________________________________ -->
|
<!-- _______________________________________________________________________ -->
|
||||||
@ -2410,7 +2364,7 @@ within the body of a variable argument function.</p>
|
|||||||
|
|
||||||
<div class="doc_text">
|
<div class="doc_text">
|
||||||
<h5>Syntax:</h5>
|
<h5>Syntax:</h5>
|
||||||
<pre> declare void %llvm.va_end(<va_list> <arglist>)<br></pre>
|
<pre> declare void %llvm.va_end(<va_list*> <arglist>)<br></pre>
|
||||||
<h5>Overview:</h5>
|
<h5>Overview:</h5>
|
||||||
<p>The '<tt>llvm.va_end</tt>' intrinsic destroys <tt><arglist></tt>
|
<p>The '<tt>llvm.va_end</tt>' intrinsic destroys <tt><arglist></tt>
|
||||||
which has been initialized previously with <tt><a href="#i_va_start">llvm.va_start</a></tt>
|
which has been initialized previously with <tt><a href="#i_va_start">llvm.va_start</a></tt>
|
||||||
@ -2435,24 +2389,27 @@ with calls to <tt>llvm.va_end</tt>.</p>
|
|||||||
<h5>Syntax:</h5>
|
<h5>Syntax:</h5>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
declare <va_list> %llvm.va_copy(<va_list> <destarglist>)
|
declare void %llvm.va_copy(<va_list>* <destarglist>,
|
||||||
|
<va_list> <srcarglist>)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h5>Overview:</h5>
|
<h5>Overview:</h5>
|
||||||
|
|
||||||
<p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position
|
<p>The '<tt>llvm.va_copy</tt>' intrinsic copies the current argument position from
|
||||||
from the source argument list to the destination argument list.</p>
|
the source argument list to the destination argument list.</p>
|
||||||
|
|
||||||
<h5>Arguments:</h5>
|
<h5>Arguments:</h5>
|
||||||
|
|
||||||
<p>The argument is the <tt>va_list</tt> to copy.</p>
|
<p>The first argument is a pointer to a <tt>va_list</tt> element to initialize.
|
||||||
|
The second argument is a <tt>va_list</tt> element to copy from.</p>
|
||||||
|
|
||||||
|
|
||||||
<h5>Semantics:</h5>
|
<h5>Semantics:</h5>
|
||||||
|
|
||||||
<p>The '<tt>llvm.va_copy</tt>' intrinsic works just like the <tt>va_copy</tt>
|
<p>The '<tt>llvm.va_copy</tt>' intrinsic works just like the <tt>va_copy</tt> macro
|
||||||
macro available in C. In a target-dependent way, it copies the source
|
available in C. In a target-dependent way, it copies the source
|
||||||
<tt>va_list</tt> element into the returned list. This intrinsic is necessary
|
<tt>va_list</tt> element into the destination list. This intrinsic is necessary
|
||||||
because the <tt><a href="#i_va_start">llvm.va_start</a></tt> intrinsic may be
|
because the <tt><a href="i_va_begin">llvm.va_begin</a></tt> intrinsic may be
|
||||||
arbitrarily complex and require memory allocation, for example.</p>
|
arbitrarily complex and require memory allocation, for example.</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user