7.1. Boolean
A boolean is either true or false. A boolean can be
represented by an i1 in MLIR.
7.1.1. Declaration
A boolean value is declared with the keyword boolean.
If the variable is not initialized explicitly, it is set to false (zero).
7.1.2. Literals
The following are the only two valid boolean literals:
truefalse
7.1.3. Operations
The following operations are defined on boolean values. In all
of the usage examples bool-expr means some boolean yielding
expression.
Operation |
Symbol |
Usage |
Associativity |
|---|---|---|---|
parenthesis |
|
|
N/A |
negation |
|
|
right |
logical or |
|
|
left |
logical xor |
|
|
left |
logical and |
|
|
left |
equals |
|
|
left |
not equals |
|
|
left |
Unlike many languages the and and or operators do not short
circuit
evaluation.
Therefore, both the left hand side and right hand side of an expression
must always be evaluated.
This table specifies boolean operator precedence. Operators without
lines between them have the same level of precedence.
Precedence |
Operation |
|---|---|
HIGHER |
|
|
|
|
|
LOWER |
|
7.1.4. Type Casting and Type Promotion
To see the types that boolean may be cast and/or promoted to, see
the sections on Type Casting and Type Promotion
respectively.