The dump method on Operation is quite useful for that.
mlir.dev has the doxygen output of all the MLIR classes
I think most of the presentations introducing MLIR has a slide or so on these. The .td file is TableGen format input for ODS (the idea behind and it’s documentation is Operation Definition Specification (ODS) - MLIR). Basically it is a convenience method to define operations (the preferred way, but it is possible to do by hand). Those C++ classes correspond to some of the compile time uses, while in ODS you’d use similar terms to define what the op has. For example, you’d say in the .td that the op has an integer attribute foo, this will result in generating a named accessor foo() whose return type is Attribute.
Jacques mentioned dump, indeed many classes in MLIR (Operation, Type, Attributes at least) have a dump() method that will print it to stderr.
You can also stream theses to llvm::err():
llvm::errs() << "This is the current op: " << *op << "\n";
llvm::errs() << "This is the current block this op is in: " << *op->getParent() << "\n";
llvm::errs() << "This is the current operation holding the region this op is in: " << *op->getParentOp() << "\n";
That is tough, and quickly overwhelming indeed. I use to confuse myself all the time between “class Operation” and the templated “class Op<>” that registered operation derived from. It seems like some unfortunate naming sometimes. There are also many idioms that are very specific to the project, like our value type (these registered op, or attributes and types) that are just wrapping pointers and really have reference semantics.
Hi thanks a lot. I know the dump method, but it is a little bit not that way since we can only dump after the program is finished. What I would like to ask is a method that I can view the content of it while debugging. In such a way, I can better follow the code and understanding what they actually do.
And thanks for pointing out the documentation, I’ll have a close look again try to find the relevant information…
The debugging method is helpful but may I ask for more that say if I’m debugging using IDE and can debug it step by step. Would there be a way of monitoring ModuleOp’s content and seeing what operation is being added, what is being manipulated.
I’ll have a close look to the doc listed, thanks a lot for pointing that out ~~