Skip to content

Commit fe3d08a

Browse files
[mlir][python] Fix ir.Value type to not break other types (llvm#167930)
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 <[email protected]>
1 parent 7b7a422 commit fe3d08a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,8 @@ static void emitElementAccessors(
437437
type = std::strcmp(kind, "operand") == 0 ? "_ods_ir.Value"
438438
: "_ods_ir.OpResult";
439439
}
440-
if (std::strcmp(kind, "operand") == 0) {
440+
if (std::strcmp(type.c_str(), "_ods_ir.Value") == 0 ||
441+
std::strcmp(type.c_str(), "_ods_ir.OpResult") == 0) {
441442
StringRef pythonType = getPythonType(element.constraint.getCppType());
442443
if (!pythonType.empty())
443444
type += "[" + pythonType.str() + "]";
@@ -473,7 +474,8 @@ static void emitElementAccessors(
473474
if (!element.isVariableLength() || element.isOptional()) {
474475
type = std::strcmp(kind, "operand") == 0 ? "_ods_ir.Value"
475476
: "_ods_ir.OpResult";
476-
if (std::strcmp(kind, "operand") == 0) {
477+
if (std::strcmp(type.c_str(), "_ods_ir.Value") == 0 ||
478+
std::strcmp(type.c_str(), "_ods_ir.OpResult") == 0) {
477479
StringRef pythonType = getPythonType(element.constraint.getCppType());
478480
if (!pythonType.empty())
479481
type += "[" + pythonType.str() + "]";

0 commit comments

Comments
 (0)