llvm-project/mlir/lib
River Riddle d80d3a358f [mlir] Refactor ElementsAttr into an AttrInterface
This revision refactors ElementsAttr into an Attribute Interface.
This enables a common interface with which to interact with
element attributes, without needing to modify the builtin
dialect. It also removes a majority (if not all?) of the need for
the current OpaqueElementsAttr, which was originally intended as
a way to opaquely represent data that was not representable by
the other builtin constructs.

The new ElementsAttr interface not only allows for users to
natively represent their data in the way that best suits them,
it also allows for efficient opaque access and iteration of the
underlying data. Attributes using the ElementsAttr interface
can directly expose support for interacting with the held
elements using any C++ data type they claim to support. For
example, DenseIntOrFpElementsAttr supports iteration using
various native C++ integer/float data types, as well as
APInt/APFloat, and more. ElementsAttr instances that refer to
DenseIntOrFpElementsAttr can use all of these data types for
iteration:

```c++
DenseIntOrFpElementsAttr intElementsAttr = ...;

ElementsAttr attr = intElementsAttr;
for (uint64_t value : attr.getValues<uint64_t>())
  ...;
for (APInt value : attr.getValues<APInt>())
  ...;
for (IntegerAttr value : attr.getValues<IntegerAttr>())
  ...;
```

ElementsAttr also supports failable range/iterator access,
allowing for selective code paths depending on data type
support:

```c++
ElementsAttr attr = ...;
if (auto range = attr.tryGetValues<uint64_t>()) {
  for (uint64_t value : *range)
    ...;
}
```

Differential Revision: https://reviews.llvm.org/D109190
2021-09-21 01:57:43 +00:00
..
Analysis [MLIR] Simplex::appendVariable: early return if count == 0 2021-09-20 13:16:56 +05:30
Bindings/Python [mlir][python] Forward _OperationBase _CAPIPtr to the Operation. 2021-09-20 18:52:05 -07:00
CAPI [mlir] Add value_begin/value_end methods to DenseElementsAttr 2021-09-21 01:57:43 +00:00
Conversion [mlir] Add value_begin/value_end methods to DenseElementsAttr 2021-09-21 01:57:43 +00:00
Dialect [mlir] Add value_begin/value_end methods to DenseElementsAttr 2021-09-21 01:57:43 +00:00
ExecutionEngine [mlir][sparse] add more asserts to sparse support lib 2021-09-16 10:13:29 -07:00
IR [mlir] Refactor ElementsAttr into an AttrInterface 2021-09-21 01:57:43 +00:00
Interfaces [mlir] Add value_begin/value_end methods to DenseElementsAttr 2021-09-21 01:57:43 +00:00
Parser [mlir] Tighten verification of SparseElementsAttr 2021-09-21 01:57:42 +00:00
Pass Remove unused llvm/Support/Parallel.h from MLIR (NFC) 2021-09-14 23:30:42 +00:00
Reducer [mlir-reduce] Fix the memory leak and recycle unused modules. 2021-07-08 20:03:47 +08:00
Rewrite [SymbolRefAttr] Revise SymbolRefAttr to hold a StringAttr. 2021-08-29 21:54:47 -07:00
Support Make the --mlir-disable-threading command line option overrides the C++ API usage 2021-09-15 03:20:48 +00:00
TableGen [mlir-tblgen] Add DagNode StaticMatcher. 2021-09-20 23:37:42 +00:00
Target [mlir] Add value_begin/value_end methods to DenseElementsAttr 2021-09-21 01:57:43 +00:00
Tools [mlir-lsp-server] Only use one MLIRContext per MLIRTextFile 2021-08-04 20:09:07 +00:00
Transforms [mlir] Fix bug in partial dialect conversion 2021-09-20 10:39:10 +03:00
Translation [mlir] run the verifier before translating a module 2021-07-28 18:15:58 +02:00
CMakeLists.txt Re-engineer MLIR python build support. 2021-07-27 15:54:58 +00:00