Skip to content

Conversation

@nirvedhmeshram
Copy link
Contributor

Change in #166148 caused breaks for some other types.
Specifically this error was seen in a downstream project

 _ods_ir.OpOperandList[_ods_ir.IntegerType]:

TypeError: type 'iree.compiler._mlir_libs._mlir.ir.OpOperandList' is not subscriptable

This PR tries to make those changes not affect the other types

@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Nov 13, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 13, 2025

@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir

Author: Nirvedh Meshram (nirvedhmeshram)

Changes

Change in #166148 caused breaks for some other types.
Specifically this error was seen in a downstream project

 _ods_ir.OpOperandList[_ods_ir.IntegerType]:

TypeError: type 'iree.compiler._mlir_libs._mlir.ir.OpOperandList' is not subscriptable

This PR tries to make those changes not affect the other types


Full diff: https://github.com/llvm/llvm-project/pull/167930.diff

1 Files Affected:

  • (modified) mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp (+2-2)
diff --git a/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp b/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp
index f01563fd49d17..d0a25149cfe2a 100644
--- a/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp
@@ -437,7 +437,7 @@ static void emitElementAccessors(
           type = std::strcmp(kind, "operand") == 0 ? "_ods_ir.Value"
                                                    : "_ods_ir.OpResult";
         }
-        if (std::strcmp(kind, "operand") == 0) {
+        if (std::strcmp(type.c_str(), "_ods_ir.Value") == 0) {
           StringRef pythonType = getPythonType(element.constraint.getCppType());
           if (!pythonType.empty())
             type += "[" + pythonType.str() + "]";
@@ -473,7 +473,7 @@ static void emitElementAccessors(
       if (!element.isVariableLength() || element.isOptional()) {
         type = std::strcmp(kind, "operand") == 0 ? "_ods_ir.Value"
                                                  : "_ods_ir.OpResult";
-        if (std::strcmp(kind, "operand") == 0) {
+        if (std::strcmp(type.c_str(), "_ods_ir.Value") == 0) {
           StringRef pythonType = getPythonType(element.constraint.getCppType());
           if (!pythonType.empty())
             type += "[" + pythonType.str() + "]";

Signed-off-by: Nirvedh Meshram <nirvedh@gmail.com>
@amd-eochoalo
Copy link
Contributor

@nirvedhmeshram , looking a little bit closer, both _ods_ir.OpResult and _ods._ir.Value are Generic.

@nirvedhmeshram
Copy link
Contributor Author

@amd-eochoalo please let me know if my new change would be the right way to handle that.

@amd-eochoalo
Copy link
Contributor

@nirvedhmeshram it is sufficiently good :) Thanks!

Copy link
Contributor

@makslevental makslevental left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nirvedhmeshram nirvedhmeshram enabled auto-merge (squash) November 13, 2025 22:00
@nirvedhmeshram nirvedhmeshram merged commit f6d9631 into llvm:main Nov 13, 2025
8 of 9 checks passed
nirvedhmeshram added a commit to iree-org/llvm-project that referenced this pull request Nov 15, 2025
Change in llvm#166148 caused breaks
for some other types.
Specifically this error was seen in a downstream project
```
 _ods_ir.OpOperandList[_ods_ir.IntegerType]:

TypeError: type 'iree.compiler._mlir_libs._mlir.ir.OpOperandList' is not subscriptable

```
This PR tries to make those changes not affect the other types

---------

Signed-off-by: Nirvedh Meshram <nirvedh@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mlir:core MLIR Core Infrastructure mlir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants