From: Chris Lattner Date: Thu, 12 Feb 2004 17:01:32 +0000 (+0000) Subject: Document the llvm.memcpy intrinsic. Clean up some of the formatting of other X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=33aec9efa926690c1cbd92314a92a8aec563b329;p=oota-llvm.git Document the llvm.memcpy intrinsic. Clean up some of the formatting of other sections git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11350 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/LangRef.html b/docs/LangRef.html index 7cd6765b674..7b03c45511f 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -95,6 +95,11 @@
  • 'llvm.va_copy' Intrinsic
  • +
  • Standard C Library Intrinsics +
      +
    1. 'llvm.memcpy' Intrinsic
    2. +
    +
  • Debugger intrinsics
  • @@ -1594,23 +1599,31 @@ section.

    -

    LLVM supports the notion of an "intrinsic function". These -functions have well known names and semantics, and are required to -follow certain restrictions. Overall, these instructions represent an -extension mechanism for the LLVM language that does not require -changing all of the transformations in LLVM to add to the language (or -the bytecode reader/writer, the parser, etc...).

    -

    Intrinsic function names must all start with an "llvm." -prefix, this prefix is reserved in LLVM for intrinsic names, thus -functions may not be named this. Intrinsic functions must always be -external functions: you cannot define the body of intrinsic functions. -Intrinsic functions may only be used in call or invoke instructions: it -is illegal to take the address of an intrinsic function. Additionally, -because intrinsic functions are part of the LLVM language, it is -required that they all be documented here if any are added.

    -

    Unless an intrinsic function is target-specific, there must be a -lowering pass to eliminate the intrinsic or all backends must support -the intrinsic function.

    + +

    LLVM supports the notion of an "intrinsic function". These functions have +well known names and semantics, and are required to follow certain +restrictions. Overall, these instructions represent an extension mechanism for +the LLVM language that does not require changing all of the transformations in +LLVM to add to the language (or the bytecode reader/writer, the parser, +etc...).

    + +

    Intrinsic function names must all start with an "llvm." prefix, this +prefix is reserved in LLVM for intrinsic names, thus functions may not be named +this. Intrinsic functions must always be external functions: you cannot define +the body of intrinsic functions. Intrinsic functions may only be used in call +or invoke instructions: it is illegal to take the address of an intrinsic +function. Additionally, because intrinsic functions are part of the LLVM +language, it is required that they all be documented here if any are added.

    + + +

    +Adding an intrinsic to LLVM is straight-forward if it is possible to express the +concept in LLVM directly (ie, code generator support is not _required_). To do +this, extend the default implementation of the IntrinsicLowering class to handle +the intrinsic. Code generators use this class to lower intrinsics they do not +understand to raw LLVM instructions that they do. +

    +
    @@ -1631,11 +1644,26 @@ used.

    This example shows how the vanext instruction and the variable argument handling intrinsic functions are used.

    -
    int %test(int %X, ...) {
    ; Initialize variable argument processing
    %ap = call sbyte*()* %llvm.va_start()

    ; Read a single integer argument
    %tmp = vaarg sbyte* %ap, int

    ; Advance to the next argument
    %ap2 = vanext sbyte* %ap, int

    ; Demonstrate usage of llvm.va_copy and llvm.va_end
    %aq = call sbyte* (sbyte*)* %llvm.va_copy(sbyte* %ap2)
    call void %llvm.va_end(sbyte* %aq)

    ; Stop processing of arguments.
    call void %llvm.va_end(sbyte* %ap2)
    ret int %tmp
    }
    +
    +int %test(int %X, ...) {
    +  ; Initialize variable argument processing
    +  %ap = call sbyte* %llvm.va_start()
    +
    +  ; Read a single integer argument
    +  %tmp = vaarg sbyte* %ap, int
    +
    +  ; Advance to the next argument
    +  %ap2 = vanext sbyte* %ap, int
    +
    +  ; Demonstrate usage of llvm.va_copy and llvm.va_end
    +  %aq = call sbyte* %llvm.va_copy(sbyte* %ap2)
    +  call void %llvm.va_end(sbyte* %aq)
    +
    +  ; Stop processing of arguments.
    +  call void %llvm.va_end(sbyte* %ap2)
    +  ret int %tmp
    +}
    +
    @@ -1704,6 +1732,64 @@ element into the returned list. This intrinsic is necessary because the + + + +
    +

    + +

    + +
    + + + + +
    + +
    Syntax:
    +
    +  call void (sbyte*, sbyte*, uint, uint)* %llvm.memcpy(sbyte* <dest>, sbyte* <src>,
    +                                                       uint <len>, uint <align>)
    +
    + +
    Overview:
    + +

    +The 'llvm.memcpy' intrinsic copies a block of memory from the source +location to the destination location. +

    + +

    +Note that, unlike the standard libc function, the llvm.memcpy intrinsic +does not return a value, and takes an extra alignment argument. +

    + +
    Arguments:
    + +

    +The first argument is a pointer to the destination, the second is a pointer to +the source. The third argument is an (arbitrarily sized) integer argument +specifying the number of bytes to copy, and the fourth argument is the alignment +of the source and destination locations. +

    + +
    Semantics:
    + +

    +The 'llvm.memcpy' intrinsic copies a block of memory from the source +location to the destination location, which are not allowed to overlap. It +copies "len" bytes of memory over. If the argument is known to be aligned to +some boundary, this can be specified as the fourth argument, otherwise it should +be set to 0 or 1. +

    +
    + +