Parsing and printing new types mlir

I have a question about this section: Chapter 7: Adding a Composite Type to Toy - MLIR. In fact, from what I understood, the printing function prints our struct type in an MLIR format with the help of the type argument, which we cast to StructType. So my first question is, when do we construct this type? And for my second question, does the parseType function parse the following code struct Struct { var a; var b; } def multiply_transpose(Struct value) { }or does it parse the .mlir code provided module { toy.func @multiply_transpose(%arg0: !toy.struct<tensor<*xf64>, tensor<*xf64>>) { toy.return } }?

The first section on this page is “Defining a struct in Toy”, and this is the only part about the language.
The rest of the page is about the IR itself: the goal of the tutorial is to learn MLIR :slight_smile:

So the section about printing/parsing is to allows to represent the MLIR type that was just defined in the textual assembly format, that is the !toy.struct<tensor<*xf64>, tensor<*xf64>> type in here:

module {
  toy.func @multiply_transpose(%arg0: !toy.struct<tensor<*xf64>, tensor<*xf64>>) {
    toy.return
  }
}
1 Like

@mehdi_amini Thank you for your response. Do you know how we can configure visual debugging in one of the Toy chapters, using a .mlir test file, and run it to observe the MLIR process? (Personally, I work with CLion. If you know a specific setup for it).

Because from what I see in the Toy chapters, there’s no main function, and no .mlir files for testing.

I’m not sure what you mean by “visual debugging”?
Have you tried building the tutorial and running the tests in the repo?

In fact, I want to know if it is possible to observe the process of transforming an .mlir representation into .ll using a graphical debugger like CLion. If it is possible, how can we set it up?

I’m not familiar with CLion, do you have an example of the “graphical” aspect you’re looking for?

I mean by that having a main file (taking as input for example .mlir file and generating .ll file at the end), and adding breakpoints to see variables, the flow of your program. Something like this Debugging in CLion - YouTube.

If you build LLVM in Debug mode, you can run any of the tutorial example code in your debugger: the binary for each chapter will be in the bin directory. I am a bit confused because here: Running Toy tutorial tests - #3 by Ayman42X you mentioned you manage to actually run the tutorial executable, so what else remains other than setting up your debugger?