7.3. Integer
An integer
is a signed 32-bit value. An integer
can be
represented by an i32
in MLIR.
7.3.1. Declaration
A integer
value is declared with the keyword integer
.
7.3.2. Literals
An integer
literal is specified in base 10. For example:
1234
2
0
7.3.3. Operations
The following operations are defined between integer
values. In all
of the usage examples int-expr
means some integer
yielding
expression.
Class |
Operation |
Symbol |
Usage |
Associativity |
---|---|---|---|---|
Grouping |
parentheses |
|
|
N/A |
Arithmetic |
addition |
|
|
left |
subtraction |
|
|
left |
|
multiplication |
|
|
left |
|
division |
|
|
left |
|
remainder |
|
|
left |
|
exponentiation |
|
|
right |
|
unary negation |
|
|
right |
|
unary plus (no-op) |
|
|
right |
|
Comparison |
less than |
|
|
left |
greater than |
|
|
left |
|
less than or equal to |
|
|
left |
|
greater than or equal to |
|
|
left |
|
equals |
|
|
left |
|
not equals |
|
|
left |
Unary negation produces the additive inverse of the integer
expression. Unary plus always produces the same result as the
integer
expression it is applied to. Remainder mirrors the behaviour
of remainder in C99.
This table specifies integer
operator precedence. Operators without
lines between them have the same level of precedence. Note that
parentheses are not included in this list because they are used to
override precedence and create new atoms in an expression.
Precedence |
Operations |
---|---|
HIGHER |
|
|
|
|
|
|
|
|
|
LOWER |
|
7.3.4. Type Casting and Type Promotion
To see the types that integer
may be cast and/or promoted to, see
the sections on Type Casting and Type Promotion
respectively.