From: Reid Spencer Date: Sat, 11 Nov 2006 21:00:47 +0000 (+0000) Subject: Add a preview of two new conversion operators: ptrtoint and inttoptr. Update X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=72679258ffdd3f43167bf8f4c203f0f0dc6030a3;p=oota-llvm.git Add a preview of two new conversion operators: ptrtoint and inttoptr. Update the defintion of bitconvert correspondingly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31688 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/LangRef.html b/docs/LangRef.html index d846b3963db..a5503408ac9 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -124,6 +124,8 @@
  • 'fptosi .. to' Instruction
  • 'uitofp .. to' Instruction
  • 'sitofp .. to' Instruction
  • +
  • 'ptrtoint .. to' Instruction
  • +
  • 'inttoptr .. to' Instruction
  • 'bitconvert .. to' Instruction
  • Other Operations @@ -2953,6 +2955,77 @@ the value cannot fit in the floating point value, the results are undefined.

    + + +
    + +
    Syntax:
    +
    +  <result> = ptrtoint <ty> <value> to <ty2>             ; yields ty2
    +
    + +
    Overview:
    +

    The 'ptrtoint' instruction converts the pointer value to +the integer type ty2.

    + +
    Arguments:
    +

    The 'ptrtoint' instruction takes a value to cast, which +must be a pointer value, and a type to cast it to +ty2, which must be an integer type. + +

    Semantics:
    +

    The 'ptrtoint' instruction converts value to integer type +ty2 by interpreting the pointer value as an integer and either +truncating or zero extending that value to the size of the integer type. If +value is smaller than ty2 then a zero extension is done. If +value is larger than ty2 then a truncation is done. If they +are the same size, then nothing is done (no-op cast).

    + +
    Example:
    +
    +  %X = ptrtoint int* %X to sbyte          ; yields truncation on 32-bit
    +  %Y = ptrtoint int* %x to ulong          ; yields zero extend on 32-bit
    +
    +
    + + + +
    + +
    Syntax:
    +
    +  <result> = inttoptr <ty> <value> to <ty2>             ; yields ty2
    +
    + +
    Overview:
    +

    The 'inttoptr' instruction converts an integer value to +a pointer type, ty2.

    + +
    Arguments:
    +

    The 'inttoptr' instruction takes an integer +value to cast, and a type to cast it to, which must be a +pointer type. + +

    Semantics:
    +

    The 'inttoptr' instruction converts value to type +ty2 by applying either a zero extension or a truncation depending on +the size of the integer value. If value is larger than the +size of a pointer then a truncation is done. If value is smaller than +the size of a pointer then a zero extension is done. If they are the same size, +nothing is done (no-op cast).

    + +
    Example:
    +
    +  %X = inttoptr int 255 to int*            ; yields zero extend on 64-bit
    +  %X = inttoptr int 255 to int*            ; yields no-op on 32-bit 
    +  %Y = inttoptr short 0 to int*            ; yields zero extend on 32-bit
    +
    +
    +
    'bitconvert .. to' Instruction @@ -2976,10 +3049,12 @@ and the destination type, ty2, must be identical.

    Semantics:

    The 'bitconvert' instruction converts value to type -ty2 as if the value had been stored to memory and read back as type -ty2. That is, no bits are changed during the conversion. The -bitconvert instruction is the only conversion instruction that permits -no-op casts to be constructed.

    +ty2. It is always a no-op cast because no bits change with +this conversion. The conversion is done as if the value had been +stored to memory and read back as type ty2. Pointer types may only be +converted to other pointer types with this instruction. To convert pointers to +other types, use the inttoptr or +ptrtoint instructions first.

    Example: