15 Commits

Author SHA1 Message Date
Corentin Ferry
36b2c22e07
[mlir][emitc] Lower arith.divui, remui (#99313)
This commit lowers `arith.divui` and `arith.remui` to EmitC by wrapping
those operations with type conversions.
2024-07-31 10:41:18 +02:00
Corentin Ferry
5c09dda507
[mlir][emitc] Lower arith.index_cast, arith.index_castui, arith.shli, arith.shrui, arith.shrsi (#95795)
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).
2024-07-10 11:32:27 +02:00
Ramkumar Ramachandra
db791b278a
mlir/LogicalResult: move into llvm (#97309)
This patch is part of a project to move the Presburger library into
LLVM.
2024-07-02 10:42:33 +01:00
Corentin Ferry
519175c3f5
[mlir][emitc] Refactor ArithToEmitC: perform sign adaptation, type conversions / cast insertion in a single place (#95789)
Factor EmitC type signedness adaptation and cast operations in ArithToEmitC using adaptValueType and adaptIntegralTypeSignedness.
2024-06-19 09:19:33 +02:00
Tina Jung
ffc31d3221
[mlir][emitc] arith.negf to EmitC conversion (#95372)
Lower arith.negf to the unary minus in EmitC.
2024-06-18 16:56:56 +02:00
Tina Jung
46672c1dc3
[mlir][emitc] arith.cmpf to EmitC conversion (#93671)
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>
2024-06-04 08:10:28 +02:00
Corentin Ferry
12fcca0afe
[mlir][emitc] Lower arith.andi, arith.ori, arith.xori to EmitC
This commit lowers bitwise arith ops to EmitC and also brings in `adaptValueType` and `adaptIntegralTypeSignedness` that other ArithToEmitC functions can benefit from.
2024-06-03 13:22:52 +02:00
josel-amd
125bd061c3
[mlir][emitc] Support conversion of arith.divsi and arith.remsi to EmitC (#93450) 2024-05-28 14:36:24 +02:00
Corentin Ferry
7630379156
[mlir][emitc] Add EmitC lowering for arith.trunci, arith.extsi, arith.extui
This commit adds conversion to EmitC for arith dialect casts between integer types (trunc, extsi, extui), excluding indexes for now.
2024-05-22 16:33:37 +02:00
Corentin Ferry
18e7dcb7c5
[mlir][emitc] Arith to EmitC: handle floating-point<->integer conversions (#87614)
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.
2024-05-03 13:47:16 +02:00
Corentin Ferry
44c876f9e0
[mlir][emitc] Add EmitC lowering for arith.cmpi (#88700) 2024-04-18 16:42:13 +02:00
Matthias Gehre
71db971521
[mlir][emitc] Arith to EmitC: Handle addi, subi and muli (#86120)
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.
2024-03-22 15:39:52 +01:00
Marius Brehler
19266ca389
[mlir][EmitC] Add an emitc.conditional operator (#84883)
This adds an `emitc.conditional` operation for the ternary conditional
operator. Furthermore, this adds a converion from `arith.select` to the
new op.
2024-03-12 11:27:26 +01:00
Tina Jung
0ddb122147
[mlir][emitc] Arith to EmitC conversion: constants (#83798)
* Add a conversion from `arith.constant` to `emitc.constant`.
* Drop the translation for `arith.constant`s.
2024-03-08 09:16:10 +01:00
Marius Brehler
c40146c214
[mlir][EmitC] Add Arith to EmitC conversions (#84151)
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.
2024-03-07 11:34:11 +01:00