| 1 |
package ssa |
| 2 |
|
| 3 |
// IntegerCmpCond represents a condition for integer comparison. |
| 4 |
type IntegerCmpCond byte |
| 5 |
|
| 6 |
const ( |
| 7 |
// IntegerCmpCondInvalid represents an invalid condition. |
| 8 |
IntegerCmpCondInvalid IntegerCmpCond = iota |
| 9 |
// IntegerCmpCondEqual represents "==". |
| 10 |
IntegerCmpCondEqual |
| 11 |
// IntegerCmpCondNotEqual represents "!=". |
| 12 |
IntegerCmpCondNotEqual |
| 13 |
// IntegerCmpCondSignedLessThan represents Signed "<". |
| 14 |
IntegerCmpCondSignedLessThan |
| 15 |
// IntegerCmpCondSignedGreaterThanOrEqual represents Signed ">=". |
| 16 |
IntegerCmpCondSignedGreaterThanOrEqual |
| 17 |
// IntegerCmpCondSignedGreaterThan represents Signed ">". |
| 18 |
IntegerCmpCondSignedGreaterThan |
| 19 |
// IntegerCmpCondSignedLessThanOrEqual represents Signed "<=". |
| 20 |
IntegerCmpCondSignedLessThanOrEqual |
| 21 |
// IntegerCmpCondUnsignedLessThan represents Unsigned "<". |
| 22 |
IntegerCmpCondUnsignedLessThan |
| 23 |
// IntegerCmpCondUnsignedGreaterThanOrEqual represents Unsigned ">=". |
| 24 |
IntegerCmpCondUnsignedGreaterThanOrEqual |
| 25 |
// IntegerCmpCondUnsignedGreaterThan represents Unsigned ">". |
| 26 |
IntegerCmpCondUnsignedGreaterThan |
| 27 |
// IntegerCmpCondUnsignedLessThanOrEqual represents Unsigned "<=". |
| 28 |
IntegerCmpCondUnsignedLessThanOrEqual |
| 29 |
) |
| 30 |
|
| 31 |
// String implements fmt.Stringer. |
| 32 |
func (i IntegerCmpCond) String() string { |
| 33 |
switch i { |
| 34 |
case IntegerCmpCondEqual: |
| 35 |
return "eq" |
| 36 |
case IntegerCmpCondNotEqual: |
| 37 |
return "neq" |
| 38 |
case IntegerCmpCondSignedLessThan: |
| 39 |
return "lt_s" |
| 40 |
case IntegerCmpCondSignedGreaterThanOrEqual: |
| 41 |
return "ge_s" |
| 42 |
case IntegerCmpCondSignedGreaterThan: |
| 43 |
return "gt_s" |
| 44 |
case IntegerCmpCondSignedLessThanOrEqual: |
| 45 |
return "le_s" |
| 46 |
case IntegerCmpCondUnsignedLessThan: |
| 47 |
return "lt_u" |
| 48 |
case IntegerCmpCondUnsignedGreaterThanOrEqual: |
| 49 |
return "ge_u" |
| 50 |
case IntegerCmpCondUnsignedGreaterThan: |
| 51 |
return "gt_u" |
| 52 |
case IntegerCmpCondUnsignedLessThanOrEqual: |
| 53 |
return "le_u" |
| 54 |
default: |
| 55 |
panic("invalid integer comparison condition") |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
// Signed returns true if the condition is signed integer comparison. |
| 60 |
func (i IntegerCmpCond) Signed() bool { |
| 61 |
switch i { |
| 62 |
case IntegerCmpCondSignedLessThan, IntegerCmpCondSignedGreaterThanOrEqual, |
| 63 |
IntegerCmpCondSignedGreaterThan, IntegerCmpCondSignedLessThanOrEqual: |
| 64 |
return true |
| 65 |
default: |
| 66 |
return false |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
type FloatCmpCond byte |
| 71 |
|
| 72 |
const ( |
| 73 |
// FloatCmpCondInvalid represents an invalid condition. |
| 74 |
FloatCmpCondInvalid FloatCmpCond = iota |
| 75 |
// FloatCmpCondEqual represents "==". |
| 76 |
FloatCmpCondEqual |
| 77 |
// FloatCmpCondNotEqual represents "!=". |
| 78 |
FloatCmpCondNotEqual |
| 79 |
// FloatCmpCondLessThan represents "<". |
| 80 |
FloatCmpCondLessThan |
| 81 |
// FloatCmpCondLessThanOrEqual represents "<=". |
| 82 |
FloatCmpCondLessThanOrEqual |
| 83 |
// FloatCmpCondGreaterThan represents ">". |
| 84 |
FloatCmpCondGreaterThan |
| 85 |
// FloatCmpCondGreaterThanOrEqual represents ">=". |
| 86 |
FloatCmpCondGreaterThanOrEqual |
| 87 |
) |
| 88 |
|
| 89 |
// String implements fmt.Stringer. |
| 90 |
func (f FloatCmpCond) String() string { |
| 91 |
switch f { |
| 92 |
case FloatCmpCondEqual: |
| 93 |
return "eq" |
| 94 |
case FloatCmpCondNotEqual: |
| 95 |
return "neq" |
| 96 |
case FloatCmpCondLessThan: |
| 97 |
return "lt" |
| 98 |
case FloatCmpCondLessThanOrEqual: |
| 99 |
return "le" |
| 100 |
case FloatCmpCondGreaterThan: |
| 101 |
return "gt" |
| 102 |
case FloatCmpCondGreaterThanOrEqual: |
| 103 |
return "ge" |
| 104 |
default: |
| 105 |
panic("invalid float comparison condition") |
| 106 |
} |
| 107 |
} |