[mlir][sparse] Macros to clean up StridedMemRefType in the SparseTensorRuntime
authorwren romano <2998727+wrengr@users.noreply.github.com>
Wed, 16 Nov 2022 21:26:58 +0000 (13:26 -0800)
committerwren romano <2998727+wrengr@users.noreply.github.com>
Thu, 17 Nov 2022 00:40:13 +0000 (16:40 -0800)
commita3e4888350169d1f61b3de4df3b0960f865ca416
treefda33593268e307f324a530d874754156bd6cda4
parent84ef7235732896530564289c8db59291a7d5413e
[mlir][sparse] Macros to clean up StridedMemRefType in the SparseTensorRuntime

In particular, this silences warnings from [-Wsign-compare].

This is a revised version of D137735, which got reverted due to a sign-comparison warning on LLVM's Windows buildbot (which was not on MLIR's Windows buildbot).  Differences vs the previous differential:

* `vectorToMemref` now uses `detail::checkOverflowCast` to silence the warning that caused the the previous differential to get reverted.
* `MEMREF_GET_USIZE` now uses `detail::checkOverflowCast` rather than `static_cast`
* `ASSERT_USIZE_EQ` added to abbreviate another common idiom, and to ensure that we use `detail::safelyEQ` everywhere (to silence a few other warnings)
* A couple for-loops now use `index_type` for the induction variable, since their upper bound uses that typedef too. (Namely `_mlir_ciface_getSparseTensorReaderDimSizes` and `_mlir_ciface_outSparseTensorWriterNext`)

Depends on D138149

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D137998
mlir/lib/ExecutionEngine/SparseTensorRuntime.cpp