llvm-project/mlir/test
Markus Böck 37da2a141c [mlir][LLVM] Rework the API of GEPOp
The implementation and API of GEP Op has gotten a bit convoluted over the time. Issues with it are:
* Misleading naming: `indices` actually only contains the dynamic indices, not all of them. To get the amount of indices you need to query the size of `structIndices`
* Very difficult to iterate over all indices properly: One had to iterate over `structIndices`, check whether it contains the magic constant `kDynamicIndex`, if it does, access the next value in `index` etc.
* Inconvenient to build: One either has create lots of constant ops for every index or have an odd split of passing both a `ValueRange` as well as a `ArrayRef<int32_t>` filled with `kDynamicIndex` at the correct places.
* Implementation doing verification in the build method
and more.

This patch attempts to address all these issues via convenience classes and reworking the way GEP Op works:
* Adds `GEPArg` class which is a sum type of a `int32_t` and `Value` and is used to have a single convenient easy to use `ArrayRef<GEPArg>` in the builders instead of the previous `ValueRange` + `ArrayRef<int32_t>` builders.
* Adds `GEPIndicesAdapter` which is a class used for easy random access and iteration over the indices of a GEP. It is generic and flexible enough to also instead return eg. a corresponding `Attribute` for an operand inside of `fold`.
*  Rename `structIndices` to `rawConstantIndices` and `indices` to `dynamicIndices`: `rawConstantIndices` signifies one shouldn't access it directly as it is encoded, and `dynamicIndices` is more accurate and also frees up the `indices` name.
* Add `getIndices` returning a `GEPIndicesAdapter` to easily iterate over the GEP Ops indices.
* Move the verification/asserts out of the build method and into the `verify` method emitting op error messages.
* Add convenient builder methods making use of `GEPArg`.
* Add canonicalizer turning dynamic indices with constant values into constant indices to have a canonical representation.

The only breaking change is for any users building GEPOps that have so far used the old `ValueRange` + `ArrayRef<int32_t>` builder as well as those using the generic syntax.

Another follow up patch then goes through upstream and makes use of the new `ArrayRef<GEPArg>` builder to remove a lot of code building constants for GEP indices.

Differential Revision: https://reviews.llvm.org/D130730
2022-07-29 18:22:54 +02:00
..
Analysis [MLIR][Liveness] Add `currentlyLiveValues`, a way to get a set of values that are live as of a given operation. 2022-07-15 22:10:53 -07:00
CAPI [MLIR] Add function to create Float16 array attribute 2022-07-20 21:58:15 +00:00
Conversion [mlir][spirv] Fix spv.CompositeConstruct assembly and validation 2022-07-27 19:17:23 -04:00
Dialect [mlir][LLVM] Rework the API of GEPOp 2022-07-29 18:22:54 +02:00
Examples [mlir] Tunnel LLVM_USE_LINKER through to the standalone example build. 2022-06-05 12:31:41 -07:00
IR [mlir:SubElementsInterface] Add support for "skipping" when replacing attributes/types 2022-07-28 10:52:12 -07:00
Integration [mlir][sparse] Add arith-expand pass to the sparse-compiler pipeline. 2022-07-27 14:42:21 -07:00
Interfaces [mlir][TilingInterface] Add a method to generate scalar implementation of the op. 2022-07-28 16:37:15 +00:00
Pass [mlir] Fixed ordering of pass statistics. 2022-07-19 15:52:02 -07:00
Rewrite [mlir:PDLInterp] Refactor the implementation of result type inferrence 2022-05-01 12:25:05 -07:00
Target [Flang][MLIR][OpenMP] Add support for simdlen clause 2022-07-28 23:49:17 +08:00
Transforms [mlir] SCCP add missing pessimistic setting 2022-07-25 17:41:17 -07:00
Unit [lit] Fix setup of sanitizer environment 2022-05-19 19:24:16 -07:00
lib [mlir][TilingInterface] Add a method to generate scalar implementation of the op. 2022-07-28 16:37:15 +00:00
mlir-cpu-runner [mlir] move _mlir_alloc and friends to CRunnerUtils 2022-07-25 15:52:53 +02:00
mlir-linalg-ods-gen [mlir] Flip LinAlg dialect to _Both 2022-07-19 14:42:58 -07:00
mlir-lsp-server [mlir:LSP] Add a quickfix code action for inserting expected-* diagnostic checks 2022-07-20 15:43:59 -07:00
mlir-opt [Coroutines] Convert coroutine.presplit to enum attr 2022-06-14 14:23:46 +08:00
mlir-pdll [mlir][ods] Make Type- and AttrInterfaces also `Type`s and `Attr`s 2022-07-07 11:54:47 +02:00
mlir-pdll-lsp-server [mlir:PDLL] Add support for inlay hints 2022-06-06 20:20:19 -07:00
mlir-reduce [MLIR] prefer /bin/sh over /bin/bash for simple test scripts 2022-04-21 20:25:17 -05:00
mlir-spirv-cpu-runner [mlir][spirv] Replace StructAttrs with AttrDefs 2022-06-09 23:16:44 +00:00
mlir-tblgen [mlir] Introduce DefaultValuedOptionalAttr 2022-07-28 14:43:13 -07:00
mlir-translate [mlir][NFC] Update textual references of `func` to `func.func` in tool/runner tests 2022-04-20 22:17:30 -07:00
mlir-vulkan-runner [mlir][vulkan] Add missing '<>' in test IRs to fix test 2022-06-10 18:09:12 -04:00
python [mlir][python] Fix issue in diagnostic note initialization 2022-07-22 16:56:14 -04:00
tblgen-lsp-server [mlir:LSP] Switch document sync mode to Incremental 2022-06-06 20:20:19 -07:00
APITest.h Adjust "end namespace" comment in MLIR to match new agree'd coding style 2021-12-08 06:05:26 +00:00
CMakeLists.txt [mlir][sparse] Add complex number reading from files. 2022-06-08 13:33:35 -07:00
lit.cfg.py [mlir] Use 'native' instead of 'llvm_has_native_target' in the mlir tests 2022-05-23 12:38:24 -07:00
lit.site.cfg.py.in [mlir] Tunnel LLVM_USE_LINKER through to the standalone example build. 2022-06-05 12:31:41 -07:00