From: Chris Lattner
Loop: ; Infinite loop that counts from 0 on up...+ - + +
%indvar = phi uint [ 0, %LoopHeader ], [ %nextindvar, %Loop ]
%nextindvar = add uint %indvar, 1
br label %Loop
<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
+ <result> = select bool <cond>, <ty> <val1>, <ty> <val2> ; yields ty ++ +
+The 'select' instruction is used to choose one value based on a +condition, without branching. +
+ + ++The 'select' instruction requires a boolean value indicating the condition, and two values of the same first class type. +
+ ++If the boolean condition evaluates to true, the instruction returns the first +value argument, otherwise it returns the second value argument. +
+ ++ %X = select bool true, ubyte 17, ubyte 42 ; yields ubyte:17 ++