[MLIR][TableGen] What is the purpose of "XOpOperandAdaptor" classes?

I am inspecting the TableGen output for the MLIR Toy example. I see that for each Op XOp, a class called XOpOperandAdaptor is also generated. However, I don’t these classes being used anywhere. Also, the logic implemented by their methods is repeated in similar methods on the Op class itself.

I am curious to know why such adaptors are generated.

They are used together with dialect conversion. In dialect conversion each op rewrite pattern takes in the converted input arguments as an ArrayRef<Value> arguments. So instead of using arguments[N] one can create an adaptor from arguments to use the nicer and meaningful getter methods like adaptor.some_value(), etc. There is an example in the Toy tutorial : https://mlir.llvm.org/docs/Tutorials/Toy/Ch-5/#conversion-patterns. There are also some more explanation here: https://mlir.llvm.org/docs/OpDefinitions/#operand-adaptors.

Thanks for the clarification :+1:. I guess, I should have been a bit more patient, didn’t get that far yet in the Toy example.