# `Beaver.MLIR.Dialect.Index`

# `add`

Return op name `index.add` as a bitstring.

# `add`

`index.add` - index addition

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.add` operation takes two index values and computes their sum.

Example:

```mlir
// c = a + b
%c = index.add %a, %b
```

# `and`

Return op name `index.and` as a bitstring.

# `and`

`index.and` - index bitwise and

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.and` operation takes two index values and computes their bitwise
and.

Example:

```mlir
// c = a & b
%c = index.and %a, %b
```

# `bool_constant`

Return op name `index.bool.constant` as a bitstring.

# `bool_constant`

`index.bool.constant` - boolean constant

This op has support for result type inference.

## Attributes
- `value` - Single, `BoolAttr`, bool attribute

## Results
- `result` - Single, `I1`, 1-bit signless integer
## Description
The `index.bool.constant` operation produces an bool-typed SSA value equal
to either `true` or `false`.

This operation is used to materialize bool constants that arise when folding
`index.cmp`.

Example:

```mlir
%0 = index.bool.constant true
```

# `casts`

Return op name `index.casts` as a bitstring.

# `casts`

`index.casts` - index signed cast

## Operands
- `input` - Single, anonymous/composite constraint, integer or index

## Results
- `output` - Single, anonymous/composite constraint, integer or index
## Description
The `index.casts` operation enables conversions between values of index type
and concrete fixed-width integer types. If casting to a wider integer, the
value is sign-extended. If casting to a narrower integer, the value is
truncated.

Example:

```mlir
// Cast to i32
%0 = index.casts %a : index to i32

// Cast from i64
%1 = index.casts %b : i64 to index
```

# `castu`

Return op name `index.castu` as a bitstring.

# `castu`

`index.castu` - index unsigned cast

## Operands
- `input` - Single, anonymous/composite constraint, integer or index

## Results
- `output` - Single, anonymous/composite constraint, integer or index
## Description
The `index.castu` operation enables conversions between values of index type
and concrete fixed-width integer types. If casting to a wider integer, the
value is zero-extended. If casting to a narrower integer, the value is
truncated.

Example:

```mlir
// Cast to i32
%0 = index.castu %a : index to i32

// Cast from i64
%1 = index.castu %b : i64 to index
```

# `ceildivs`

Return op name `index.ceildivs` as a bitstring.

# `ceildivs`

`index.ceildivs` - index signed ceil division

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.ceildivs` operation takes two index values and computes their
signed quotient. Treats the leading bit as the sign and rounds towards
positive infinity, i.e. `7 / -2 = -3`.

Note: division by zero and signed division overflow are undefined behaviour.

Example:

```mlir
// c = ceil(a / b)
%c = index.ceildivs %a, %b
```

# `ceildivu`

Return op name `index.ceildivu` as a bitstring.

# `ceildivu`

`index.ceildivu` - index unsigned ceil division

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.ceildivu` operation takes two index values and computes their
unsigned quotient. Treats the leading bit as the most significant and rounds
towards positive infinity, i.e. `6 / -2 = 1`.

Note: division by zero is undefined behaviour.

Example:

```mlir
// c = ceil(a / b)
%c = index.ceildivu %a, %b
```

# `cmp`

Return op name `index.cmp` as a bitstring.

# `cmp`

`index.cmp` - index compare

This op has support for result type inference.

## Attributes
- `pred` - Single, `IndexCmpPredicateAttr`, index comparison predicate kind

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `I1`, 1-bit signless integer
## Description
The `index.cmp` operation takes two index values and compares them according
to the comparison predicate and returns an `i1`. The following comparisons
are supported:

-   `eq`:  equal
-   `ne`:  not equal
-   `slt`: signed less than
-   `sle`: signed less than or equal
-   `sgt`: signed greater than
-   `sge`: signed greater than or equal
-   `ult`: unsigned less than
-   `ule`: unsigned less than or equal
-   `ugt`: unsigned greater than
-   `uge`: unsigned greater than or equal

The result is `1` if the comparison is true and `0` otherwise.

Example:

```mlir
// Signed less than comparison.
%0 = index.cmp slt(%a, %b)

// Unsigned greater than or equal comparison.
%1 = index.cmp uge(%a, %b)

// Not equal comparison.
%2 = index.cmp ne(%a, %b)
```

# `constant`

Return op name `index.constant` as a bitstring.

# `constant`

`index.constant` - index constant

This op has support for result type inference.

## Attributes
- `value` - Single, `IndexAttr`, index attribute

## Results
- `result` - Single, `Index`, index
## Description
The `index.constant` operation produces an index-typed SSA value equal to
some index-typed integer constant.

Example:

```mlir
%0 = index.constant 42
```

# `divs`

Return op name `index.divs` as a bitstring.

# `divs`

`index.divs` - index signed division

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.divs` operation takes two index values and computes their signed
quotient. Treats the leading bit as the sign and rounds towards zero, i.e.
`6 / -2 = -3`.

Note: division by zero and signed division overflow are undefined behaviour.

Example:

```mlir
// c = a / b
%c = index.divs %a, %b
```

# `divu`

Return op name `index.divu` as a bitstring.

# `divu`

`index.divu` - index unsigned division

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.divu` operation takes two index values and computes their
unsigned quotient. Treats the leading bit as the most significant and rounds
towards zero, i.e. `6 / -2 = 0`.

Note: division by zero is undefined behaviour.

Example:

```mlir
// c = a / b
%c = index.divu %a, %b
```

# `floordivs`

Return op name `index.floordivs` as a bitstring.

# `floordivs`

`index.floordivs` - index signed floor division

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.floordivs` operation takes two index values and computes their
signed quotient. Treats the leading bit as the sign and rounds towards
negative infinity, i.e. `5 / -2 = -3`.

Note: division by zero and signed division overflow are undefined behaviour.

Example:

```mlir
// c = floor(a / b)
%c = index.floordivs %a, %b
```

# `maxs`

Return op name `index.maxs` as a bitstring.

# `maxs`

`index.maxs` - index signed maximum

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.maxs` operation takes two index values and computes their signed
maximum value. Treats the leading bit as the sign, i.e. `max(-2, 6) = 6`.

Example:

```mlir
// c = max(a, b)
%c = index.maxs %a, %b
```

# `maxu`

Return op name `index.maxu` as a bitstring.

# `maxu`

`index.maxu` - index unsigned maximum

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.maxu` operation takes two index values and computes their
unsigned maximum value. Treats the leading bit as the most significant, i.e.
`max(15, 6) = 15` or `max(-2, 6) = -2`.

Example:

```mlir
// c = max(a, b)
%c = index.maxu %a, %b
```

# `mins`

Return op name `index.mins` as a bitstring.

# `mins`

`index.mins` - index signed minimum

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.mins` operation takes two index values and computes their signed
minimum value. Treats the leading bit as the sign, i.e. `min(-2, 6) = -2`.

Example:

```mlir
// c = min(a, b)
%c = index.mins %a, %b
```

# `minu`

Return op name `index.minu` as a bitstring.

# `minu`

`index.minu` - index unsigned minimum

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.minu` operation takes two index values and computes their
unsigned minimum value. Treats the leading bit as the most significant, i.e.
`min(15, 6) = 6` or `min(-2, 6) = 6`.

Example:

```mlir
// c = min(a, b)
%c = index.minu %a, %b
```

# `mul`

Return op name `index.mul` as a bitstring.

# `mul`

`index.mul` - index multiplication

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.mul` operation takes two index values and computes their product.

Example:

```mlir
// c = a * b
%c = index.mul %a, %b
```

# `or`

Return op name `index.or` as a bitstring.

# `or`

`index.or` - index bitwise or

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.or` operation takes two index values and computes their bitwise
or.

Example:

```mlir
// c = a | b
%c = index.or %a, %b
```

# `rems`

Return op name `index.rems` as a bitstring.

# `rems`

`index.rems` - index signed remainder

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.rems` operation takes two index values and computes their signed
remainder. Treats the leading bit as the sign, i.e. `6 % -2 = 0`.

Example:

```mlir
// c = a % b
%c = index.rems %a, %b
```

# `remu`

Return op name `index.remu` as a bitstring.

# `remu`

`index.remu` - index unsigned remainder

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.remu` operation takes two index values and computes their
unsigned remainder. Treats the leading bit as the most significant, i.e.
`6 % -2 = 6`.

Example:

```mlir
// c = a % b
%c = index.remu %a, %b
```

# `shl`

Return op name `index.shl` as a bitstring.

# `shl`

`index.shl` - index shift left

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.shl` operation shifts an index value to the left by a variable
amount. The low order bits are filled with zeroes. The RHS operand is always
treated as unsigned. If the RHS operand is equal to or greater than the
index bitwidth, the result is a poison value.

Example:

```mlir
// c = a << b
%c = index.shl %a, %b
```

# `shrs`

Return op name `index.shrs` as a bitstring.

# `shrs`

`index.shrs` - signed index shift right

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.shrs` operation shifts an index value to the right by a variable
amount. The LHS operand is treated as signed. The high order bits are filled
with copies of the most significant bit. If the RHS operand is equal to or
greater than the index bitwidth, the result is a poison value.

Example:

```mlir
// c = a >> b
%c = index.shrs %a, %b
```

# `shru`

Return op name `index.shru` as a bitstring.

# `shru`

`index.shru` - unsigned index shift right

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.shru` operation shifts an index value to the right by a variable
amount. The LHS operand is treated as unsigned. The high order bits are
filled with zeroes. If the RHS operand is equal to or greater than the index
bitwidth, the result is a poison value.

Example:

```mlir
// c = a >> b
%c = index.shru %a, %b
```

# `sizeof`

Return op name `index.sizeof` as a bitstring.

# `sizeof`

`index.sizeof` - size in bits of the index type

This op has support for result type inference.

## Results
- `result` - Single, `Index`, index
## Description
The `index.sizeof` operation produces an index-typed SSA value equal to the
size in bits of the `index` type. For example, on 32-bit systems, the result
is `32 : index`, and on 64-bit systems, the result is `64 : index`.

Example:

```mlir
%0 = index.sizeof
```

# `sub`

Return op name `index.sub` as a bitstring.

# `sub`

`index.sub` - index subtraction

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.sub` operation takes two index values and computes the difference
of the first from the second operand.

Example:

```mlir
// c = a - b
%c = index.sub %a, %b
```

# `xor`

Return op name `index.xor` as a bitstring.

# `xor`

`index.xor` - index bitwise xor

This op has support for result type inference.

## Operands
- `lhs` - Single, `Index`, index
- `rhs` - Single, `Index`, index

## Results
- `result` - Single, `Index`, index
## Description
The `index.xor` operation takes two index values and computes their bitwise
xor.

Example:

```mlir
// c = a ^ b
%c = index.xor %a, %b
```

