diff --git a/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp b/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp index f01563fd49d17..2c33f4efac3ac 100644 --- a/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp +++ b/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp @@ -437,7 +437,8 @@ 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 || + std::strcmp(type.c_str(), "_ods_ir.OpResult") == 0) { StringRef pythonType = getPythonType(element.constraint.getCppType()); if (!pythonType.empty()) type += "[" + pythonType.str() + "]"; @@ -473,7 +474,8 @@ 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 || + std::strcmp(type.c_str(), "_ods_ir.OpResult") == 0) { StringRef pythonType = getPythonType(element.constraint.getCppType()); if (!pythonType.empty()) type += "[" + pythonType.str() + "]";