llvm-capstone/mlir
Ingo Müller ca23c933bd [mlir][python] Create all missing attribute builders.
This patch adds attribute builders for all buildable attributes from the
builtin dialect that did not previously have any. These builders can be
used to construct attributes of a particular type identified by a string
from a Python argument without knowing the details of how to pass that
Python argument to the attribute constructor. This is used, for example,
in the generated code of the Python bindings of ops.

The list of "all" attributes was produced with:

(
  grep -h "ods_ir.AttrBuilder.get" $(find ../build/ -name "*_ops_gen.py") \
    | cut -f2 -d"'"
  git grep -ho "^def [a-zA-Z0-9_]*" -- include/mlir/IR/CommonAttrConstraints.td \
    | cut -f2 -d" "
) | sort -u

Then, I only retained those that had an occurence in
`mlir/include/mlir/IR`. In particular, this drops many dialect-specific
attributes; registering those builders is something that those dialects
should do. Finally, I removed those attrbiutes that had a match in
`mlir/python/mlir/ir.py` already and implemented the remaining ones. The
only ones that still miss a builder now are the following:

* Represent more than one possible attribute type:
  - `Any.*Attr` (9x)
  - `IntNonNegative`
  - `IntPositive`
  - `IsNullAttr`
  - `ElementsAttr`
* I am not sure what "constant attributes" are:
  - `ConstBoolAttrFalse`
  - `ConstBoolAttrTrue`
  - `ConstUnitAttr`
* `Location` not exposed by Python bindings:
  - `LocationArrayAttr`
  - `LocationAttr`
* `get` function not implemented in Python bindings:
  - `StringElementsAttr`

This patch also fixes a compilation problem with
`I64SmallVectorArrayAttr`.

Reviewed By: makslevental, rkayaith

Differential Revision: https://reviews.llvm.org/D159403
2023-09-06 07:09:25 +00:00
..
benchmark/python
cmake/modules [mlir][python bindings] generate all the enums 2023-08-23 15:03:55 -05:00
docs [mlir] Move FunctionInterfaces to Interfaces directory and inherit from CallableOpInterface 2023-08-31 11:28:23 +00:00
examples [mlir] Move FunctionInterfaces to Interfaces directory and inherit from CallableOpInterface 2023-08-31 11:28:23 +00:00
include [mlir][python] Create all missing attribute builders. 2023-09-06 07:09:25 +00:00
lib [mlir][llvm] Add icmp folder (#65343) 2023-09-06 08:58:39 +02:00
python [mlir][python] Create all missing attribute builders. 2023-09-06 07:09:25 +00:00
test [mlir][python] Create all missing attribute builders. 2023-09-06 07:09:25 +00:00
tools Revert "Revert "[MLIR] Move builtin.module LLVM IR translation to before nested operations"" 2023-09-04 11:35:59 +01:00
unittests [mlir] Add empty to StringAttr 2023-09-05 21:45:27 +00:00
utils [mlir] Fix generating checks for multiple funcs in generate-test-checks 2023-08-03 15:55:03 +00:00
.clang-format
.clang-tidy
CMakeLists.txt [mlir][NVVM] Adds the NVVM target attribute. 2023-08-08 19:21:36 +00:00
LICENSE.TXT
README.md

Multi-Level Intermediate Representation

See https://mlir.llvm.org/ for more information.