Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make DumpPipe from Tofino available to all #5184

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

grg
Copy link
Contributor

@grg grg commented Mar 19, 2025

Move the DumpPipe inspector from Tofino into the common ir/dump.h

Add a pair of DumpPipe passes to the p4test backend.

@grg grg requested review from hanw, ChrisDodd, fruffy and pkotikal March 19, 2025 02:02
@grg grg force-pushed the gleng/dump_pipe branch 3 times, most recently from b5e6b29 to 55ead7e Compare March 19, 2025 02:17
@fruffy fruffy added core Topics concerning the core segments of the compiler (frontend, midend, parser) tofino Topics related to the Tofino switch and back end. labels Mar 19, 2025
@grg grg marked this pull request as ready for review March 19, 2025 02:23
@grg
Copy link
Contributor Author

grg commented Mar 19, 2025

Usage question for all: because I've placed the preorder implementation in dump.cpp, dumping is enabled via -T dump:1 (or higher number). Let me know if anyone is really attached to -T dump_pipe:1 and I can move the implementation to a separate file.

@grg grg requested a review from ChrisDodd March 19, 2025 13:25
@fruffy
Copy link
Collaborator

fruffy commented Mar 19, 2025

I have never actually used this, what is it for?

@grg
Copy link
Contributor Author

grg commented Mar 19, 2025

I have never actually used this, what is it for?

It was really useful during Tofino development when trying to see how a pass or set of passes had transformed the IR without having to set breakpoints in a debugger and manually inspect nodes.

There is overlap with the P4 dumping functionality (via --toP4). But dumping the IR tree provides detail that can't always be discerned from a P4 dump. For example, is a headers_t reference a StringLiteral or a Type_Header at a given point in the program execution? Plus it's quite useful in a backend like Tofino that introduces custom IR nodes that don't necessarily have a clean/easy transformation back into P4.

@ChrisDodd
Copy link
Contributor

Usage question for all: because I've placed the preorder implementation in dump.cpp, dumping is enabled via -T dump:1 (or higher number). Let me know if anyone is really attached to -T dump_pipe:1 and I can move the implementation to a separate file.

I think this is fine.

I have never actually used this, what is it for?

The main usage is to have a dump that uses dbprint (at level 1) instead of toP4, mostly for backend-specific stuff that doesn't map well to P4 (and isn't handled by toP4 -- it just gets skipped). Having a level-2 full dump is sometimes useful too (though that is often too verbose).

@grg
Copy link
Contributor Author

grg commented Mar 19, 2025

@ChrisDodd Anything else blocking approval of this PR?

@ChrisDodd
Copy link
Contributor

@ChrisDodd Anything else blocking approval of this PR?

Just the one suggestion (moving the #if so as to not visit when the pass is disabled) above.

@grg
Copy link
Contributor Author

grg commented Mar 19, 2025

@ChrisDodd Anything else blocking approval of this PR?

Just the one suggestion (moving the #if so as to not visit when the pass is disabled) above.

Whoops -- that's on me 😬 I missed pushing the changes after making them locally.

Thanks for the approval!

@grg grg force-pushed the gleng/dump_pipe branch 2 times, most recently from 9294705 to 9a04eaa Compare March 19, 2025 20:51
@grg grg enabled auto-merge March 19, 2025 20:54
Move the DumpPipe inspector from Tofino into the common ir/dump.h

Add a pair of DumpPipe passes to the p4test backend.

Signed-off-by: Glen Gibb <gleng@ai-fabrics.com>
@grg grg force-pushed the gleng/dump_pipe branch from 9a04eaa to eed800a Compare March 19, 2025 20:56
@grg grg added this pull request to the merge queue Mar 19, 2025
Merged via the queue into p4lang:main with commit 03c6717 Mar 19, 2025
20 checks passed
@grg grg deleted the gleng/dump_pipe branch March 19, 2025 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Topics concerning the core segments of the compiler (frontend, midend, parser) tofino Topics related to the Tofino switch and back end.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants