llvm / circt

Circuit IR Compilers and Tools
https://circt.org
Other
1.64k stars 287 forks source link

Passes #5731

Open MuhammadTalha-10 opened 1 year ago

MuhammadTalha-10 commented 1 year ago

I am just starting out with CIRCT I wanted to know the procedure on lowering dialects to Verilog. I went through the CIRCT documentation and came upon passes. I want to know if these passes and optimizations are supposed to be done through C++ (importing classes and functions) or command line flags of the compiled executables after compiling CIRCT. If it is the former, do I just import the classes from the repository? Is there a specific directory containing all the passes or do I have to look around?

One more thing. Can the workflow of transformation of a high level language to Verilog using CIRCT can be done with the Python bindings and C++ programming (collectively and/or individually).

mikeurbach commented 1 year ago

Thanks for your interest in CIRCT, some answers below:

I want to know if these passes and optimizations are supposed to be done through C++ (importing classes and functions) or command line flags of the compiled executables after compiling CIRCT.

CIRCT is just like any MLIR-based project in this sense, so both are possible.

We provide a circt-opt tool that has all of the passes registered, and this is useful for our test suite and exploring CIRCT. I would definitely suggest trying out passes with circt-opt to learn what is available and how they work.

Usually for "production" tools, you would build your own tool, which includes and runs the relevant passes for your use case. There is no one place to import all the passes, but you can take a look at how circt-opt is set up for an example of grabbing everything. It uses this helper.

Can the workflow of transformation of a high level language to Verilog using CIRCT can be done with the Python bindings and C++ programming (collectively and/or individually).

Yes, this is possible. As above, the support for Python in CIRCT is the same as any MLIR project that uses the Python bindings. There are some very rough edges if you start mixing and matching Python mutations of the IR with C++ mutations. One common pattern that I have seen work is to build up IR in Python, and then run passes defined in C++. There's a small example of running C++ passes from Python here.

MuhammadTalha-10 commented 6 months ago

I want to know that are there any optimization passes available in calyx?