From: Reid Spencer
+ <result> = ptrtoint <ty> <value> to <ty2> ; yields ty2 ++ +
The 'ptrtoint' instruction converts the pointer value to +the integer type ty2.
+ +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. + +
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).
+ ++ %X = ptrtoint int* %X to sbyte ; yields truncation on 32-bit + %Y = ptrtoint int* %x to ulong ; yields zero extend on 32-bit ++
+ <result> = inttoptr <ty> <value> to <ty2> ; yields ty2 ++ +
The 'inttoptr' instruction converts an integer value to +a pointer type, ty2.
+ +The 'inttoptr' instruction takes an integer +value to cast, and a type to cast it to, which must be a +pointer type. + +
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).
+ ++ %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 ++
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.