From 5c0ef47d8378196527091de80c38745f7a1fdb42 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sat, 11 Nov 2006 23:08:07 +0000 Subject: Document new constant expr operators, rename bitconvert as bitcast. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31693 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LangRef.html | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'docs') diff --git a/docs/LangRef.html b/docs/LangRef.html index a5503408ac..7f404af10b 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -126,7 +126,7 @@
  • 'sitofp .. to' Instruction
  • 'ptrtoint .. to' Instruction
  • 'inttoptr .. to' Instruction
  • -
  • 'bitconvert .. to' Instruction
  • +
  • 'bitcast .. to' Instruction
  • Other Operations
      @@ -290,9 +290,10 @@ unnamed identifiers allow a compiler to quickly come up with a temporary variable without having to avoid symbol table conflicts.

      Reserved words in LLVM are very similar to reserved words in other -languages. There are keywords for different opcodes ('add', 'cast', 'ret', etc...), for primitive type names ('add', + 'bitcast', + 'ret', etc...), for primitive type names ('void', 'uint', etc...), and others. These reserved words cannot conflict with variable names, because none of them start with a '%' character.

      @@ -1223,12 +1224,24 @@ following is the syntax for constant expressions:

      constant. TYPE must be floating point. CST must be of integer type. If the value won't fit in the floating point type, the results are undefined. -
      bitconvert ( CST to TYPE )
      +
      ptrtoint ( CST to TYPE )
      +
      Convert a pointer typed constant to the corresponding integer constant + TYPE must be an integer type. CST must be of pointer type. The CST value is + zero extended, truncated, or unchanged to make it fit in TYPE.
      + +
      inttoptr ( CST to TYPE )
      +
      Convert a integer constant to a pointer constant. TYPE must be a + pointer type. CST must be of integer type. The CST value is zero extended, + truncated, or unchanged to make it fit in a pointer size. This one is + really dangerous!
      + +
      bitcast ( CST to TYPE )
      Convert a constant, CST, to another TYPE. The size of CST and TYPE must be identical (same number of bits). The conversion is done as if the CST value was stored to memory and read back as TYPE. In other words, no bits change - with this operator, just the type. This can be used for conversion of pointer - and packed types to any other type, as long as they have the same bit width. + with this operator, just the type. This can be used for conversion of + packed types to any other type, as long as they have the same bit width. For + pointers it is only valid to cast to another pointer type.
      getelementptr ( CSTPTR, IDX0, IDX1, ... )
      @@ -2801,7 +2814,7 @@ type must be smaller than the destination type.

      floating point type to a larger floating point type. The fpext cannot be used to make a no-op cast because it always changes bits. Use -bitconvert to make a no-op cast for a floating point cast.

      +bitcast to make a no-op cast for a floating point cast.

      Example:
      @@ -3028,27 +3041,27 @@ nothing is done (no-op cast).

      Syntax:
      -  <result> = bitconvert <ty> <value> to <ty2>             ; yields ty2
      +  <result> = bitcast <ty> <value> to <ty2>             ; yields ty2
       
      Overview:
      -

      The 'bitconvert' instruction converts value to type +

      The 'bitcast' instruction converts value to type ty2 without changing any bits.

      Arguments:
      -

      The 'bitconvert' instruction takes a value to cast, which must be +

      The 'bitcast' 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 bit sizes of value and the destination type, ty2, must be identical.

      Semantics:
      -

      The 'bitconvert' instruction converts value to type +

      The 'bitcast' instruction converts value to type 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 @@ -3058,8 +3071,9 @@ other types, use the inttoptr or

      Example:
      -  %X = bitconvert ubyte 255 to sbyte         ; yields sbyte:-1
      -  %Y = bitconvert uint* %x to uint           ; yields uint:%x
      +  %X = bitcast ubyte 255 to sbyte         ; yields sbyte:-1
      +  %Y = bitcast uint* %x to sint*          ; yields sint*:%x
      +  %Z = bitcast <2xint> %V to long;        ; yields long: %V   
       
      -- cgit v1.2.3