[PATCH v3] LangRef: modify varargs example to include x86_64
Ramkumar Ramachandra
artagnon at gmail.com
Sat Nov 1 18:02:54 PDT 2014
Sorry about that typo in the address of llvm-commits.
On Sat, Nov 1, 2014 at 8:59 PM, Ramkumar Ramachandra <artagnon at gmail.com> wrote:
> va_list is a different type than the generic i8* on x86_64. Include this
> type in a comment so that users can graft it in with minimal
> effort.
>
> Cc: Reid Kleckner <rnk at google.com>
> Cc: Tim Northover <t.p.northover at gmail.com>
> Signed-off-by: Ramkumar Ramachandra <artagnon at gmail.com>
> ---
> docs/LangRef.rst | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/docs/LangRef.rst b/docs/LangRef.rst
> index ddef803..3b7d80b 100644
> --- a/docs/LangRef.rst
> +++ b/docs/LangRef.rst
> @@ -6884,14 +6884,21 @@ variable argument handling intrinsic functions are used.
>
> .. code-block:: llvm
>
> + ; This struct is different for every platform. For most platforms,
> + ; it is merely an i8*.
> + %struct.va_list = type { i8* }
> +
> + ; For Unix x86_64 platforms, va_list is the following struct:
> + ; %struct.va_list = type { i32, i32, i8*, i8* }
> +
> define i32 @test(i32 %X, ...) {
> ; Initialize variable argument processing
> - %ap = alloca i8*
> - %ap2 = bitcast i8** %ap to i8*
> + %ap = alloca %struct.va_list
> + %ap2 = bitcast %struct.va_list* %ap to i8*
> call void @llvm.va_start(i8* %ap2)
>
> ; Read a single integer argument
> - %tmp = va_arg i8** %ap, i32
> + %tmp = va_arg i8* %ap2, i32
>
> ; Demonstrate usage of llvm.va_copy and llvm.va_end
> %aq = alloca i8*
> --
> 2.1.3
>
More information about the llvm-commits
mailing list