From f3a70a6cd9841a824a186891cbe169919e4e9005 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sat, 18 Nov 2006 21:50:54 +0000 Subject: [PATCH] For PR950: Documentation preview of the upcoming icmp and fcmp instructions that will replace the various setcc instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31859 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LangRef.html | 210 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 162 insertions(+), 48 deletions(-) diff --git a/docs/LangRef.html b/docs/LangRef.html index 7f404af10b9..5324c0ef294 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -83,7 +83,6 @@
  • 'urem' Instruction
  • 'srem' Instruction
  • 'frem' Instruction
  • -
  • 'setcc' Instructions
  • Bitwise Binary Operations @@ -96,6 +95,7 @@
  • 'ashr' Instruction
  • +
  • Vector Operations
    1. 'extractelement' Instruction
    2. @@ -130,6 +130,8 @@
  • Other Operations
      +
    1. 'icmp' Instruction
    2. +
    3. 'fcmp' Instruction
    4. 'phi' Instruction
    5. 'select' Instruction
    6. 'call' Instruction
    7. @@ -1838,51 +1840,6 @@ identical types.

      Example:
        <result> = frem float 4.0, %var          ; yields {float}:result = 4.0 % %var
       
      - - - - -
      -
      Syntax:
      -
        <result> = seteq <ty> <var1>, <var2>   ; yields {bool}:result
      -  <result> = setne <ty> <var1>, <var2>   ; yields {bool}:result
      -  <result> = setlt <ty> <var1>, <var2>   ; yields {bool}:result
      -  <result> = setgt <ty> <var1>, <var2>   ; yields {bool}:result
      -  <result> = setle <ty> <var1>, <var2>   ; yields {bool}:result
      -  <result> = setge <ty> <var1>, <var2>   ; yields {bool}:result
      -
      -
      Overview:
      -

      The 'setcc' family of instructions returns a boolean -value based on a comparison of their two operands.

      -
      Arguments:
      -

      The two arguments to the 'setcc' instructions must -be of first class type (it is not possible -to compare 'label's, 'array's, 'structure' -or 'void' values, etc...). Both arguments must have identical -types.

      -
      Semantics:
      -

      The 'seteq' instruction yields a true 'bool' -value if both operands are equal.
      -The 'setne' instruction yields a true 'bool' -value if both operands are unequal.
      -The 'setlt' instruction yields a true 'bool' -value if the first operand is less than the second operand.
      -The 'setgt' instruction yields a true 'bool' -value if the first operand is greater than the second operand.
      -The 'setle' instruction yields a true 'bool' -value if the first operand is less than or equal to the second operand.
      -The 'setge' instruction yields a true 'bool' -value if the first operand is greater than or equal to the second -operand.

      -
      Example:
      -
        <result> = seteq int   4, 5        ; yields {bool}:result = false
      -  <result> = setne float 4, 5        ; yields {bool}:result = true
      -  <result> = setlt uint  4, 5        ; yields {bool}:result = true
      -  <result> = setgt sbyte 4, 5        ; yields {bool}:result = false
      -  <result> = setle sbyte 4, 5        ; yields {bool}:result = true
      -  <result> = setge sbyte 4, 5        ; yields {bool}:result = false
      -
      @@ -2537,7 +2494,7 @@ provided depend on the type of the first pointer argument. The levels of a structure or to a specific index in an array. When indexing into a structure, only uint integer constants are allowed. When indexing into an array or pointer, -int and long indexes are allowed of any sign.

      +int and long and ulong indexes are allowed.

      For example, let's consider a C code fragment and how it gets compiled to LLVM:

      @@ -2578,7 +2535,7 @@ compiled to LLVM:

      The index types specified for the 'getelementptr' instruction depend on the pointer type that is being indexed into. Pointer -and array types require uint, int, +and array types require int, ulong, or long values, and structure types require uint constants.

      @@ -3083,6 +3040,163 @@ other types, use the inttoptr or

      The instructions in this category are the "miscellaneous" instructions, which defy better classification.

      + + + +
      +
      Syntax:
      +
        <result> = icmp <cond> <ty> <var1>, <var2>   ; yields {bool}:result
      +
      +
      Overview:
      +

      The 'icmp' instruction returns a boolean value based on comparison +of its two integer operands.

      +
      Arguments:
      +

      The 'icmp' instruction takes three operands. The first operand is +the condition code which indicates the kind of comparison to perform. It is not +a value, just a keyword. The possibilities for the condition code are: +

        +
      1. eq: equal
      2. +
      3. ne: not equal
      4. +
      5. ugt: unsigned greater than
      6. +
      7. uge: unsigned greater or equal
      8. +
      9. ult: unsigned less than
      10. +
      11. ule: unsigned less or equal
      12. +
      13. sgt: signed greater than
      14. +
      15. sge: signed greater or equal
      16. +
      17. slt: signed less than
      18. +
      19. sle: signed less or equal
      20. +
      +

      The remaining two arguments must be of integral, +pointer or a packed integral +type. They must have identical types.

      +
      Semantics:
      +

      The 'icmp' compares var1 and var2 according to +the condition code given as cond. The comparison performed always +yields a bool result, as follows: +

        +
      1. eq: yields true if the operands are equal, + false otherwise. No sign interpretation is necessary or performed. +
      2. +
      3. ne: yields true if the operands are unequal, + false otherwise. No sign interpretation is necessary or performed. +
      4. ugt: interprets the operands as unsigned values and yields + true if var1 is greater than var2.
      5. +
      6. uge: interprets the operands as unsigned values and yields + true if var1 is greater than or equal to var2.
      7. +
      8. ult: interprets the operands as unsigned values and yields + true if var1 is less than var2.
      9. +
      10. ule: interprets the operands as unsigned values and yields + true if var1 is less than or equal to var2.
      11. +
      12. sgt: interprets the operands as signed values and yields + true if var1 is greater than var2.
      13. +
      14. sge: interprets the operands as signed values and yields + true if var1 is greater than or equal to var2.
      15. +
      16. slt: interprets the operands as signed values and yields + true if var1 is less than var2.
      17. +
      18. sle: interprets the operands as signed values and yields + true if var1 is less than or equal to var2.
      19. + +
      +

      If the operands are pointer typed, the pointer +values are treated as integers and then compared.

      +

      If the operands are packed typed, the elements of +the vector are compared in turn and the predicate must hold for all elements. +While this is of dubious use for predicates other than eq and +ne, the other predicates can be used with packed types.

      + +
      Example:
      +
        <result> = icmp eq int 4, 5           ; yields: result=false
      +  <result> = icmp ne float* %X, %X      ; yields: result=false
      +  <result> = icmp ult short 4, 5        ; yields: result=true
      +  <result> = icmp sgt sbyte 4, 5        ; yields: result=false
      +  <result> = icmp ule sbyte -4, 5       ; yields: result=false
      +  <result> = icmp sge sbyte 4, 5        ; yields: result=false
      +
      +
      + + + +
      +
      Syntax:
      +
        <result> = fcmp <cond> <ty> <var1>, <var2>   ; yields {bool}:result
      +
      +
      Overview:
      +

      The 'fcmp' instruction returns a boolean value based on comparison +of its floating point operands.

      +
      Arguments:
      +

      The 'fcmp' instruction takes three operands. The first operand is +the condition code which indicates the kind of comparison to perform. It is not +a value, just a keyword. The possibilities for the condition code are: +

        +
      1. false: no comparison, always false (always folded)
      2. +
      3. oeq: ordered and equal
      4. +
      5. ogt: ordered and greater than
      6. +
      7. oge: ordered and greater than or equal
      8. +
      9. olt: ordered and less than
      10. +
      11. ole: ordered and less than or equal
      12. +
      13. one: ordered and not equal
      14. +
      15. ord: ordered (no nans)
      16. +
      17. ueq: unordered or equal
      18. +
      19. ugt: unordered or greater than
      20. +
      21. uge: unordered or greater than or equal
      22. +
      23. ult: unordered or less than
      24. +
      25. ule: unordered or less than or equal
      26. +
      27. une: unordered or not equal
      28. +
      29. uno: unordered (either nans)
      30. +
      31. true: no comparison, always true (always folded)
      32. +
      +

      The val1 and val2 arguments must be of +floating point, or a packed +floating point type. They must have identical types.

      +
      Semantics:
      +

      The 'fcmp' compares var1 and var2 according to +the condition code given as cond. The comparison performed always +yields a bool result, as follows: +

        +
      1. false: always yields false, regardless of operands.
      2. +
      3. oeq: yields true if both operands are ordered and + var1 is equal to var2.
      4. +
      5. ogt: yields true if both operands are ordered and + var1 is greather than var2.
      6. +
      7. oge: yields true if both operands are ordered and + var1 is greater than or equal to var2.
      8. +
      9. olt: yields true if both operands are ordered and + var1 is less than var2.
      10. +
      11. ole: yields true if both operands are ordered and + var1 is less than or equal to var2.
      12. +
      13. one: yields true if both operands are ordered and + var1 is not equal to var2.
      14. +
      15. ord: yields true if both operands are ordered.
      16. +
      17. ueq: yields true if either operand is unordered or + var1 is equal to var2.
      18. +
      19. ugt: yields true if either operand is unordered or + var1 is greater than var2.
      20. +
      21. uge: yields true if either operand is unordered or + var1 is greater than or equal to var2.
      22. +
      23. ult: yields true if either operand is unordered or + var1 is less than var2.
      24. +
      25. ule: yields true if either operand is unordered or + var1 is less than or equal to var2.
      26. +
      27. une: yields true if either operand is unordered or + var1 is not equal to var2.
      28. +
      29. uno: yields true if either operand is unordered.
      30. +
      31. true: always yields true, regardless of operands.
      32. +
      +

      If the operands are packed typed, the elements of +the vector are compared in turn and the predicate must hold for all elements. +While this is of dubious use for predicates other than eq and +ne, the other predicates can be used with packed types.

      + +
      Example:
      +
        <result> = fcmp oeq float 4.0, 5.0    ; yields: result=false
      +  <result> = icmp one float 4.0, 5.0    ; yields: result=true
      +  <result> = icmp olt float 4.0, 5.0    ; yields: result=true
      +  <result> = icmp ueq double 1.0, 2.0   ; yields: result=false
      +
      +
      +