p4-dev@lists.p4.org

list for questions/discussion of p4 programs and tools

View all threads

Preparing a New Pass in P4C

M
mahxen@gmail.com
Mon, Nov 29, 2021 4:53 PM

Hi all,

I want to prepare a new pass to have IR in that pass (with --top4 newpass). Please let me know how I can create a new pass. Also, please let me there is a tool in P4C to create the DAG of IR. If there is, please let me know how I use it.

Thank you so much in advance.

Mohsen

Hi all, I want to prepare a new pass to have IR in that pass (with --top4 newpass). Please let me know how I can create a new pass. Also, please let me there is a tool in P4C to create the DAG of IR. If there is, please let me know how I use it. Thank you so much in advance. Mohsen
NS
Nik Sultana
Mon, Nov 29, 2021 5:03 PM

On Mon, 29 Nov 2021, mahxen@gmail.com wrote:

Hi all,

I want to prepare a new pass to have IR in that pass (with --top4 newpass). Please let me know how I can create a new pass.

This shows an example of a pass I'd created: https://github.com/eniac/Flightplan/blob/master/flightplan/flightplan.patch_516e1219ec59c06ca5640410423f653ad0fa49d1#L6432
For a more wieldy view of this, you might want to apply this patch to
the version of p4c it was last applied to -- this version info is in the
filename. By following the code to the class definition, and its
constructor in particular, you can get an idea of how to add a pass.
I had found it useful to look at existing passes in p4c, to learn the
incantation.

Also, please let me there is a tool in P4C to create the DAG of IR. If there is, please let me know how I use it.

I'm not aware of one but there's code in this patch that'll generate a
.dot file for different levels of detail of P4 code/representation: https://github.com/eniac/Flightplan/blob/master/flightplan/flightplan.patch_516e1219ec59c06ca5640410423f653ad0fa49d1#L6432
This might not work immediately for what you need, but might provide a
stepping stone.

Thank you so much in advance.

Mohsen


P4-dev mailing list -- p4-dev@lists.p4.org
To unsubscribe send an email to p4-dev-leave@lists.p4.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

On Mon, 29 Nov 2021, mahxen@gmail.com wrote: > Hi all, > > I want to prepare a new pass to have IR in that pass (with --top4 newpass). Please let me know how I can create a new pass. This shows an example of a pass I'd created: https://github.com/eniac/Flightplan/blob/master/flightplan/flightplan.patch_516e1219ec59c06ca5640410423f653ad0fa49d1#L6432 For a more wieldy view of this, you might want to apply this patch to the version of p4c it was last applied to -- this version info is in the filename. By following the code to the class definition, and its constructor in particular, you can get an idea of how to add a pass. I had found it useful to look at existing passes in p4c, to learn the incantation. > Also, please let me there is a tool in P4C to create the DAG of IR. If there is, please let me know how I use it. I'm not aware of one but there's code in this patch that'll generate a .dot file for different levels of detail of P4 code/representation: https://github.com/eniac/Flightplan/blob/master/flightplan/flightplan.patch_516e1219ec59c06ca5640410423f653ad0fa49d1#L6432 This might not work immediately for what you need, but might provide a stepping stone. > Thank you so much in advance. > > Mohsen > _______________________________________________ > P4-dev mailing list -- p4-dev@lists.p4.org > To unsubscribe send an email to p4-dev-leave@lists.p4.org > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s -- http://www.cs.iit.edu/~nsultana1
M
mahxen@gmail.com
Mon, Dec 6, 2021 1:42 PM

Hi Nik,

Thank you so much for your kind help. I can prepare a new pass with your solution and changing p4c/frontend/p4/frontend.cpp.

Hi Nik, Thank you so much for your kind help. I can prepare a new pass with your solution and changing p4c/frontend/p4/frontend.cpp.