From cc37aae854d1778b2d446a5d3bf7d43dfae088a1 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 12 Mar 2004 05:50:16 +0000 Subject: [PATCH] Cleanup the cast section, add the select instruction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12307 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LangRef.html | 116 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 95 insertions(+), 21 deletions(-) diff --git a/docs/LangRef.html b/docs/LangRef.html index 3215586f864..de0ac2efdf4 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -80,6 +80,7 @@
  1. 'phi' Instruction
  2. 'cast .. to' Instruction
  3. +
  4. 'select' Instruction
  5. 'call' Instruction
  6. 'vanext' Instruction
  7. 'vaarg' Instruction
  8. @@ -1506,38 +1507,111 @@ came from in the last terminator instruction.

    Example:
    Loop:       ; Infinite loop that counts from 0 on up...
    %indvar = phi uint [ 0, %LoopHeader ], [ %nextindvar, %Loop ]
    %nextindvar = add uint %indvar, 1
    br label %Loop
    + - + +
    +
    Syntax:
    -
      <result> = cast <ty> <value> to <ty2>             ; yields ty2
    +
    +
    +  <result> = cast <ty> <value> to <ty2>             ; yields ty2
     
    +
    Overview:
    -

    The 'cast' instruction is used as the primitive means to -convert integers to floating point, change data type sizes, and break -type safety (by casting pointers).

    + +

    +The 'cast' instruction is used as the primitive means to convert +integers to floating point, change data type sizes, and break type safety (by +casting pointers). +

    + +
    Arguments:
    -

    The 'cast' instruction takes a value to cast, which must be -a first class value, and a type to cast it to, which must also be a first class type.

    + +

    +The 'cast' instruction takes a value to cast, which must be a first +class value, and a type to cast it to, which must also be a first class type. +

    +
    Semantics:
    -

    This instruction follows the C rules for explicit casts when -determining how the data being cast must change to fit in its new -container.

    -

    When casting to bool, any value that would be considered true in the -context of a C 'if' condition is converted to the boolean 'true' -values, all else are 'false'.

    -

    When extending an integral value from a type of one signness to -another (for example 'sbyte' to 'ulong'), the value -is sign-extended if the source value is signed, and -zero-extended if the source value is unsigned. bool values -are always zero extended into either zero or one.

    + +

    +This instruction follows the C rules for explicit casts when determining how the +data being cast must change to fit in its new container. +

    + +

    +When casting to bool, any value that would be considered true in the context of +a C 'if' condition is converted to the boolean 'true' values, +all else are 'false'. +

    + +

    +When extending an integral value from a type of one signness to another (for +example 'sbyte' to 'ulong'), the value is sign-extended if the +source value is signed, and zero-extended if the source value is +unsigned. bool values are always zero extended into either zero or +one. +

    +
    Example:
    -
      %X = cast int 257 to ubyte              ; yields ubyte:1
    +
    +
    +  %X = cast int 257 to ubyte              ; yields ubyte:1
       %Y = cast int 123 to bool               ; yields bool:true
     
    + + + + +
    + +
    Syntax:
    + +
    +  <result> = select bool <cond>, <ty> <val1>, <ty> <val2>             ; yields ty
    +
    + +
    Overview:
    + +

    +The 'select' instruction is used to choose one value based on a +condition, without branching. +

    + + +
    Arguments:
    + +

    +The 'select' instruction requires a boolean value indicating the condition, and two values of the same first class type. +

    + +
    Semantics:
    + +

    +If the boolean condition evaluates to true, the instruction returns the first +value argument, otherwise it returns the second value argument. +

    + +
    Example:
    + +
    +  %X = select bool true, ubyte 17, ubyte 42          ; yields ubyte:17
    +
    +
    + + + + + -- 2.34.1