This PR makes use of the newly introduced EmitC types, and lowers:
* ops dealing with index types (index_cast, index_castui),
* ops where `size_t` is used as part of the lowering (shli, shrui,
shrsi, to check for overflow and avoid UB in this case).
Convert all arith.cmpf on floats (not vectors/tensors thereof) to EmitC.
---------
Co-authored-by: Matthias Gehre <matthias.gehre@amd.com>
Co-authored-by: Jose Lopes <jose.lopes@amd.com>
This commit lowers bitwise arith ops to EmitC and also brings in `adaptValueType` and `adaptIntegralTypeSignedness` that other ArithToEmitC functions can benefit from.
Add support for floating-point to integer, integer to floating-point
conversions. Floating point conversions to 1-bit integer types are not
handled at the moment, as these don't map directly to boolean
conversions.
Important to consider that `arith` has wrap around semantics, and in C++
signed overflow is UB.
Unless the operation guarantees that no signed overflow happens, we will
perform the arithmetic in an equivalent unsigned type.
`bool` also doesn't wrap around in C++, and is not addressed here.
This adds patterns and a pass to convert the Arith dialect to EmitC. For
now, this covers arithemtic binary ops operating on floating point
types.
It is not checked within the patterns whether the types, such as the
Tensor type, are supported in the respective EmitC operations. If
unsupported types should be converted, the conversion will fail anyway
because no legal EmitC operation can be created. This can clearly be
improved in a follow up, also resulting in better error messages.
Functions for such checks should not solely be used in the conversions
and should also be (re)used in the verifier.