[Mlir-commits] [mlir] [MLIR][Python] add type hints for accessors (PR #158455)
Maksim Levental
llvmlistbot at llvm.org
Wed Sep 17 11:14:05 PDT 2025
================
@@ -413,13 +440,23 @@ static void emitElementAccessors(
if (element.name.empty())
continue;
std::string trailing;
- if (!element.isVariableLength())
- trailing = "[0]";
- else if (element.isOptional())
- trailing = std::string(
- formatv(opVariadicSegmentOptionalTrailingTemplate, kind));
+ std::string type = std::strcmp(kind, "operand") == 0
+ ? "_ods_ir.OpOperandList"
+ : "_ods_ir.OpResultList";
+ if (!element.isVariableLength() || element.isOptional()) {
+ type = std::strcmp(kind, "operand") == 0 ? "_ods_ir.Value"
----------------
makslevental wrote:
`_ods_ir` is how the ir module is already being referenced in these generated files: https://github.com/llvm/llvm-project/blob/10d0d955e22be43abab8fe7e339e99068aaac030/mlir/tools/mlir-tblgen/OpPythonBindingGen.cpp#L44
https://github.com/llvm/llvm-project/pull/158455
More information about the Mlir-commits
mailing list