diff --git a/mlir/cmake/modules/AddMLIRPython.cmake b/mlir/cmake/modules/AddMLIRPython.cmake --- a/mlir/cmake/modules/AddMLIRPython.cmake +++ b/mlir/cmake/modules/AddMLIRPython.cmake @@ -271,6 +271,11 @@ # SOURCES: Same as declare_mlir_python_sources(). # SOURCES_GLOB: Same as declare_mlir_python_sources(). # DEPENDS: Additional dependency targets. +# +# TODO: Right now `TD_FILE` can't be the actual dialect tablegen file, since we +# use its path to determine where to place the generated python file. If +# we made the output path an additional argument here we could remove the +# need for the separate "wrapper" .td files function(declare_mlir_dialect_python_bindings) cmake_parse_arguments(ARG "" diff --git a/mlir/docs/Bindings/Python.md b/mlir/docs/Bindings/Python.md --- a/mlir/docs/Bindings/Python.md +++ b/mlir/docs/Bindings/Python.md @@ -919,7 +919,6 @@ #ifndef PYTHON_BINDINGS_FUNC_OPS #define PYTHON_BINDINGS_FUNC_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Func/IR/FuncOps.td" #endif // PYTHON_BINDINGS_FUNC_OPS @@ -1125,14 +1124,10 @@ properties. Therefore, there is no need to implement a separate C API for them. For operations defined in ODS, `mlir-tblgen -gen-python-op-bindings -bind-dialect=` generates the Python API from the declarative -description. If the build API uses specific attribute types, such as -`::mlir::IntegerAttr` or `::mlir::DenseIntElementsAttr`, for its arguments, the -mapping to the corresponding Python types should be provided in ODS definition. -For built-in attribute types, this mapping is available in -[`include/mlir/Bindings/Python/Attributes.td`](https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/Bindings/Python/Attributes.td); -it is sufficient to create a new `.td` file that includes this file and the -original ODS definition and use it as source for the `mlir-tblgen` call. Such -`.td` files reside in +description. +It is sufficient to create a new `.td` file that includes the original ODS +definition and use it as source for the `mlir-tblgen` call. +Such `.td` files reside in [`python/mlir/dialects/`](https://github.com/llvm/llvm-project/tree/main/mlir/python/mlir/dialects). The results of `mlir-tblgen` are expected to produce a file named `__ops_gen.py` by convention. The generated operation classes diff --git a/mlir/examples/standalone/python/mlir_standalone/dialects/StandaloneOps.td b/mlir/examples/standalone/python/mlir_standalone/dialects/StandaloneOps.td --- a/mlir/examples/standalone/python/mlir_standalone/dialects/StandaloneOps.td +++ b/mlir/examples/standalone/python/mlir_standalone/dialects/StandaloneOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_STANDALONE_OPS #define PYTHON_BINDINGS_STANDALONE_OPS -include "mlir/Bindings/Python/Attributes.td" include "Standalone/StandaloneOps.td" #endif diff --git a/mlir/include/mlir/Bindings/Python/Attributes.td b/mlir/include/mlir/Bindings/Python/Attributes.td deleted file mode 100644 --- a/mlir/include/mlir/Bindings/Python/Attributes.td +++ /dev/null @@ -1,24 +0,0 @@ -//===-- Attributes.td - Attribute mapping for Python -------*- tablegen -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This defines the mapping between MLIR ODS attributes and the corresponding -// Python binding classes. -// -//===----------------------------------------------------------------------===// - -#ifndef PYTHON_BINDINGS_ATTRIBUTES -#define PYTHON_BINDINGS_ATTRIBUTES - -// A mapping between the attribute storage type and the corresponding Python -// type. There is not necessarily a 1-1 match for non-builtin attributes. -class PythonAttr { - string cppStorageType = c; - string pythonType = p; -} - -#endif diff --git a/mlir/python/mlir/dialects/ArithOps.td b/mlir/python/mlir/dialects/ArithOps.td --- a/mlir/python/mlir/dialects/ArithOps.td +++ b/mlir/python/mlir/dialects/ArithOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_ARITH_OPS #define PYTHON_BINDINGS_ARITH_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Arith/IR/ArithOps.td" #endif diff --git a/mlir/python/mlir/dialects/AsyncOps.td b/mlir/python/mlir/dialects/AsyncOps.td --- a/mlir/python/mlir/dialects/AsyncOps.td +++ b/mlir/python/mlir/dialects/AsyncOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_ASYNC_OPS #define PYTHON_BINDINGS_ASYNC_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Async/IR/AsyncOps.td" #endif diff --git a/mlir/python/mlir/dialects/BufferizationOps.td b/mlir/python/mlir/dialects/BufferizationOps.td --- a/mlir/python/mlir/dialects/BufferizationOps.td +++ b/mlir/python/mlir/dialects/BufferizationOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_BUFFERIZATION_OPS #define PYTHON_BINDINGS_BUFFERIZATION_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Bufferization/IR/BufferizationOps.td" #endif diff --git a/mlir/python/mlir/dialects/BufferizationTransformOps.td b/mlir/python/mlir/dialects/BufferizationTransformOps.td --- a/mlir/python/mlir/dialects/BufferizationTransformOps.td +++ b/mlir/python/mlir/dialects/BufferizationTransformOps.td @@ -15,7 +15,6 @@ #ifndef PYTHON_BINDINGS_BUFFERIZATION_TRANSFORM_OPS #define PYTHON_BINDINGS_BUFFERIZATION_TRANSFORM_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Bufferization/TransformOps/BufferizationTransformOps.td" #endif // PYTHON_BINDINGS_BUFFERIZATION_TRANSFORM_OPS diff --git a/mlir/python/mlir/dialects/BuiltinOps.td b/mlir/python/mlir/dialects/BuiltinOps.td --- a/mlir/python/mlir/dialects/BuiltinOps.td +++ b/mlir/python/mlir/dialects/BuiltinOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_BUILTIN_OPS #define PYTHON_BINDINGS_BUILTIN_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/IR/BuiltinOps.td" #endif diff --git a/mlir/python/mlir/dialects/ComplexOps.td b/mlir/python/mlir/dialects/ComplexOps.td --- a/mlir/python/mlir/dialects/ComplexOps.td +++ b/mlir/python/mlir/dialects/ComplexOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_COMPLEX_OPS #define PYTHON_BINDINGS_COMPLEX_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Complex/IR/ComplexOps.td" #endif diff --git a/mlir/python/mlir/dialects/ControlFlowOps.td b/mlir/python/mlir/dialects/ControlFlowOps.td --- a/mlir/python/mlir/dialects/ControlFlowOps.td +++ b/mlir/python/mlir/dialects/ControlFlowOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_CONTROL_FLOW_OPS #define PYTHON_BINDINGS_CONTROL_FLOW_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.td" #endif diff --git a/mlir/python/mlir/dialects/FuncOps.td b/mlir/python/mlir/dialects/FuncOps.td --- a/mlir/python/mlir/dialects/FuncOps.td +++ b/mlir/python/mlir/dialects/FuncOps.td @@ -14,7 +14,6 @@ #ifndef PYTHON_BINDINGS_FUNC #define PYTHON_BINDINGS_FUNC -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Func/IR/FuncOps.td" #endif diff --git a/mlir/python/mlir/dialects/GPUOps.td b/mlir/python/mlir/dialects/GPUOps.td --- a/mlir/python/mlir/dialects/GPUOps.td +++ b/mlir/python/mlir/dialects/GPUOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_GPU_OPS #define PYTHON_BINDINGS_GPU_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/GPU/IR/GPUOps.td" #endif diff --git a/mlir/python/mlir/dialects/LinalgOps.td b/mlir/python/mlir/dialects/LinalgOps.td --- a/mlir/python/mlir/dialects/LinalgOps.td +++ b/mlir/python/mlir/dialects/LinalgOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_LINALG_OPS #define PYTHON_BINDINGS_LINALG_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Linalg/IR/LinalgOps.td" include "mlir/Dialect/Linalg/IR/LinalgStructuredOps.td" diff --git a/mlir/python/mlir/dialects/LinalgStructuredTransformOps.td b/mlir/python/mlir/dialects/LinalgStructuredTransformOps.td --- a/mlir/python/mlir/dialects/LinalgStructuredTransformOps.td +++ b/mlir/python/mlir/dialects/LinalgStructuredTransformOps.td @@ -15,7 +15,6 @@ #ifndef PYTHON_BINDINGS_LINALG_STRUCTURED_TRANSFORM_OPS #define PYTHON_BINDINGS_LINALG_STRUCTURED_TRANSFORM_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td" #endif // PYTHON_BINDINGS_LINALG_STRUCTURED_TRANSFORM_OPS diff --git a/mlir/python/mlir/dialects/MLProgramOps.td b/mlir/python/mlir/dialects/MLProgramOps.td --- a/mlir/python/mlir/dialects/MLProgramOps.td +++ b/mlir/python/mlir/dialects/MLProgramOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_MLPROGRAM_OPS #define PYTHON_BINDINGS_MLPROGRAM_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/MLProgram/IR/MLProgramOps.td" #endif diff --git a/mlir/python/mlir/dialects/MathOps.td b/mlir/python/mlir/dialects/MathOps.td --- a/mlir/python/mlir/dialects/MathOps.td +++ b/mlir/python/mlir/dialects/MathOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_MATH_OPS #define PYTHON_BINDINGS_MATH_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Math/IR/MathOps.td" #endif diff --git a/mlir/python/mlir/dialects/MemRefOps.td b/mlir/python/mlir/dialects/MemRefOps.td --- a/mlir/python/mlir/dialects/MemRefOps.td +++ b/mlir/python/mlir/dialects/MemRefOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_MEMREF_OPS #define PYTHON_BINDINGS_MEMREF_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/MemRef/IR/MemRefOps.td" #endif diff --git a/mlir/python/mlir/dialects/PDLOps.td b/mlir/python/mlir/dialects/PDLOps.td --- a/mlir/python/mlir/dialects/PDLOps.td +++ b/mlir/python/mlir/dialects/PDLOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_PDL_OPS #define PYTHON_BINDINGS_PDL_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/PDL/IR/PDLOps.td" #endif diff --git a/mlir/python/mlir/dialects/SCFLoopTransformOps.td b/mlir/python/mlir/dialects/SCFLoopTransformOps.td --- a/mlir/python/mlir/dialects/SCFLoopTransformOps.td +++ b/mlir/python/mlir/dialects/SCFLoopTransformOps.td @@ -15,7 +15,6 @@ #ifndef PYTHON_BINDINGS_SCF_LOOP_TRANSFORM_OPS #define PYTHON_BINDINGS_SCF_LOOP_TRANSFORM_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/SCF/TransformOps/SCFTransformOps.td" #endif // PYTHON_BINDINGS_SCF_LOOP_TRANSFORM_OPS diff --git a/mlir/python/mlir/dialects/SCFOps.td b/mlir/python/mlir/dialects/SCFOps.td --- a/mlir/python/mlir/dialects/SCFOps.td +++ b/mlir/python/mlir/dialects/SCFOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_SCF_OPS #define PYTHON_BINDINGS_SCF_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/SCF/IR/SCFOps.td" #endif diff --git a/mlir/python/mlir/dialects/ShapeOps.td b/mlir/python/mlir/dialects/ShapeOps.td --- a/mlir/python/mlir/dialects/ShapeOps.td +++ b/mlir/python/mlir/dialects/ShapeOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_SHAPE_OPS #define PYTHON_BINDINGS_SHAPE_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Shape/IR/ShapeOps.td" #endif diff --git a/mlir/python/mlir/dialects/SparseTensorOps.td b/mlir/python/mlir/dialects/SparseTensorOps.td --- a/mlir/python/mlir/dialects/SparseTensorOps.td +++ b/mlir/python/mlir/dialects/SparseTensorOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_SPARSE_TENSOR_OPS #define PYTHON_BINDINGS_SPARSE_TENSOR_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/SparseTensor/IR/SparseTensorOps.td" #endif diff --git a/mlir/python/mlir/dialects/TensorOps.td b/mlir/python/mlir/dialects/TensorOps.td --- a/mlir/python/mlir/dialects/TensorOps.td +++ b/mlir/python/mlir/dialects/TensorOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_TENSOR_OPS #define PYTHON_BINDINGS_TENSOR_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Tensor/IR/TensorOps.td" #endif diff --git a/mlir/python/mlir/dialects/TosaOps.td b/mlir/python/mlir/dialects/TosaOps.td --- a/mlir/python/mlir/dialects/TosaOps.td +++ b/mlir/python/mlir/dialects/TosaOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_TOSA_OPS #define PYTHON_BINDINGS_TOSA_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Tosa/IR/TosaOps.td" #endif diff --git a/mlir/python/mlir/dialects/TransformOps.td b/mlir/python/mlir/dialects/TransformOps.td --- a/mlir/python/mlir/dialects/TransformOps.td +++ b/mlir/python/mlir/dialects/TransformOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_TRANSFORM_OPS #define PYTHON_BINDINGS_TRANSFORM_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Transform/IR/TransformOps.td" #endif // PYTHON_BINDINGS_TRANSFORM_OPS diff --git a/mlir/python/mlir/dialects/TransformPDLExtensionOps.td b/mlir/python/mlir/dialects/TransformPDLExtensionOps.td --- a/mlir/python/mlir/dialects/TransformPDLExtensionOps.td +++ b/mlir/python/mlir/dialects/TransformPDLExtensionOps.td @@ -14,7 +14,6 @@ #ifndef PYTHON_BINDINGS_TRANSFORM_PDL_EXTENSION_OPS #define PYTHON_BINDINGS_TRANSFORM_PDL_EXTENSION_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Transform/PDLExtension/PDLExtensionOps.td" #endif // PYTHON_BINDINGS_TRANSFORM_PDL_EXTENSION_OPS diff --git a/mlir/python/mlir/dialects/VectorOps.td b/mlir/python/mlir/dialects/VectorOps.td --- a/mlir/python/mlir/dialects/VectorOps.td +++ b/mlir/python/mlir/dialects/VectorOps.td @@ -9,7 +9,6 @@ #ifndef PYTHON_BINDINGS_VECTOR_OPS #define PYTHON_BINDINGS_VECTOR_OPS -include "mlir/Bindings/Python/Attributes.td" include "mlir/Dialect/Vector/IR/VectorOps.td" #endif diff --git a/mlir/test/mlir-tblgen/op-python-bindings.td b/mlir/test/mlir-tblgen/op-python-bindings.td --- a/mlir/test/mlir-tblgen/op-python-bindings.td +++ b/mlir/test/mlir-tblgen/op-python-bindings.td @@ -3,7 +3,6 @@ include "mlir/IR/OpBase.td" include "mlir/IR/AttrTypeBase.td" include "mlir/Interfaces/InferTypeOpInterface.td" -include "mlir/Bindings/Python/Attributes.td" // CHECK: @_ods_cext.register_dialect // CHECK: class _Dialect(_ods_ir.Dialect): @@ -13,8 +12,6 @@ let name = "test"; let cppNamespace = "Test"; } -def TestAttr : AttrDef; -def : PythonAttr">; class TestOp traits = []> : Op; @@ -114,7 +111,7 @@ // CHECK-NOT: _ODS_OPERAND_SEGMENTS // CHECK-NOT: _ODS_RESULT_SEGMENTS def AttributedOp : TestOp<"attributed_op"> { - // CHECK: def __init__(self, i32attr, in_, test_attr, *, optionalF32Attr=None, unitAttr=None, loc=None, ip=None): + // CHECK: def __init__(self, i32attr, in_, *, optionalF32Attr=None, unitAttr=None, loc=None, ip=None): // CHECK: operands = [] // CHECK: results = [] // CHECK: attributes = {} @@ -134,13 +131,13 @@ // CHECK: @builtins.property // CHECK: def i32attr(self): - // CHECK: return (self.operation.attributes["i32attr"]) + // CHECK: return self.operation.attributes["i32attr"] // CHECK: @builtins.property // CHECK: def optionalF32Attr(self): // CHECK: if "optionalF32Attr" not in self.operation.attributes: // CHECK: return None - // CHECK: return (self.operation.attributes["optionalF32Attr"]) + // CHECK: return self.operation.attributes["optionalF32Attr"] // CHECK: @builtins.property // CHECK: def unitAttr(self): @@ -148,13 +145,10 @@ // CHECK: @builtins.property // CHECK: def in_(self): - // CHECK: return (self.operation.attributes["in"]) + // CHECK: return self.operation.attributes["in"] - // CHECK: @builtins.property - // CHECK: def test_attr(self): - // CHECK: return (self.operation.attributes["test_attr"]) let arguments = (ins I32Attr:$i32attr, OptionalAttr:$optionalF32Attr, - UnitAttr:$unitAttr, I32Attr:$in, TestAttr:$test_attr); + UnitAttr:$unitAttr, I32Attr:$in); } // CHECK: @_ods_cext.register_operation(_Dialect) @@ -186,7 +180,7 @@ // CHECK: def is_(self): // CHECK: if "is" not in self.operation.attributes: // CHECK: return None - // CHECK: return (self.operation.attributes["is"]) + // CHECK: return self.operation.attributes["is"] let arguments = (ins I32, UnitAttr:$in, F32, OptionalAttr:$is); } diff --git a/mlir/test/python/python_test_ops.td b/mlir/test/python/python_test_ops.td --- a/mlir/test/python/python_test_ops.td +++ b/mlir/test/python/python_test_ops.td @@ -10,7 +10,6 @@ #define PYTHON_TEST_OPS include "mlir/IR/AttrTypeBase.td" -include "mlir/Bindings/Python/Attributes.td" include "mlir/IR/OpBase.td" include "mlir/Interfaces/InferTypeOpInterface.td" diff --git a/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp b/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp --- a/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp +++ b/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp @@ -182,24 +182,22 @@ /// Template for an operation attribute getter: /// {0} is the name of the attribute sanitized for Python; -/// {1} is the Python type of the attribute; -/// {2} os the original name of the attribute. +/// {1} is the original name of the attribute. constexpr const char *attributeGetterTemplate = R"Py( @builtins.property def {0}(self): - return {1}(self.operation.attributes["{2}"]) + return self.operation.attributes["{1}"] )Py"; /// Template for an optional operation attribute getter: /// {0} is the name of the attribute sanitized for Python; -/// {1} is the Python type of the attribute; -/// {2} is the original name of the attribute. +/// {1} is the original name of the attribute. constexpr const char *optionalAttributeGetterTemplate = R"Py( @builtins.property def {0}(self): - if "{2}" not in self.operation.attributes: + if "{1}" not in self.operation.attributes: return None - return {1}(self.operation.attributes["{2}"]) + return self.operation.attributes["{1}"] )Py"; /// Template for a getter of a unit operation attribute, returns True of the @@ -443,9 +441,7 @@ } /// Emits accessors to Op attributes. -static void emitAttributeAccessors(const Operator &op, - const AttributeClasses &attributeClasses, - raw_ostream &os) { +static void emitAttributeAccessors(const Operator &op, raw_ostream &os) { for (const auto &namedAttr : op.getAttributes()) { // Skip "derived" attributes because they are just C++ functions that we // don't currently expose. @@ -468,17 +464,15 @@ continue; } - StringRef pythonType = - attributeClasses.lookup(namedAttr.attr.getStorageType()); if (namedAttr.attr.isOptional()) { os << llvm::formatv(optionalAttributeGetterTemplate, sanitizedName, - pythonType, namedAttr.name); + namedAttr.name); os << llvm::formatv(optionalAttributeSetterTemplate, sanitizedName, namedAttr.name); os << llvm::formatv(attributeDeleterTemplate, sanitizedName, namedAttr.name); } else { - os << llvm::formatv(attributeGetterTemplate, sanitizedName, pythonType, + os << llvm::formatv(attributeGetterTemplate, sanitizedName, namedAttr.name); os << llvm::formatv(attributeSetterTemplate, sanitizedName, namedAttr.name); @@ -944,15 +938,6 @@ llvm::join(builderLines, "\n ")); } -static void constructAttributeMapping(const llvm::RecordKeeper &records, - AttributeClasses &attributeClasses) { - for (const llvm::Record *rec : - records.getAllDerivedDefinitions("PythonAttr")) { - attributeClasses.try_emplace(rec->getValueAsString("cppStorageType").trim(), - rec->getValueAsString("pythonType").trim()); - } -} - static void emitSegmentSpec( const Operator &op, const char *kind, llvm::function_ref getNumElements, @@ -999,9 +984,7 @@ } /// Emits bindings for a specific Op to the given output stream. -static void emitOpBindings(const Operator &op, - const AttributeClasses &attributeClasses, - raw_ostream &os) { +static void emitOpBindings(const Operator &op, raw_ostream &os) { os << llvm::formatv(opClassTemplate, op.getCppClassName(), op.getOperationName()); @@ -1016,7 +999,7 @@ emitRegionAttributes(op, os); emitDefaultOpBuilder(op, os); emitOperandAccessors(op, os); - emitAttributeAccessors(op, attributeClasses, os); + emitAttributeAccessors(op, os); emitResultAccessors(op, os); emitRegionAccessors(op, os); } @@ -1028,9 +1011,6 @@ if (clDialectName.empty()) llvm::PrintFatalError("dialect name not provided"); - AttributeClasses attributeClasses; - constructAttributeMapping(records, attributeClasses); - bool isExtension = !clDialectExtensionName.empty(); os << llvm::formatv(fileHeader, isExtension ? clDialectExtensionName.getValue() @@ -1043,7 +1023,7 @@ for (const llvm::Record *rec : records.getAllDerivedDefinitions("Op")) { Operator op(rec); if (op.getDialectName() == clDialectName.getValue()) - emitOpBindings(op, attributeClasses, os); + emitOpBindings(op, os); } return false; }