[P4-dev] Convert HLIR or JSON back to P4 source code

Antonin Bas antonin at barefootnetworks.com
Wed Oct 17 18:19:52 EDT 2018


Some HLIR objects have a dump_to_p4 method but I'm pretty sure it's missing
for most, so you would have to write that code yourself. p4-hlir is in
maintenance mode and we do not add new features anymore. I recommend that
you look at the new p4c compiler (https://github.com/p4lang/p4c) which
supports both P4_14 and P4_16. It has its own C++ IR and is in active



On Wed, Oct 17, 2018 at 2:29 PM Dingming Wu <dmwu0506 at gmail.com> wrote:

> Hi All,
> The standard P4 compiler frontend will generate a HLIR object from the P4
> source. I was wondering whether there is  a tool/methodology to convert
> this HLIR object back into a p4 source file?
> Basically, what I want to do is to modify the HLIR object, e.g., change
> some table properties or add new tables/actions. It is desirable for us to
> do this modifications  without touching the original P4 source code.
> If switch targets do not consume P4 program in the HLIR format (does
> tofino accept that? Not sure), we will then have to convert HLIR back to
> source code.
> Similarly, can we generate the JSON file from a source file, do some
> modifications to the JSON file and then convert it back into source code?
> Thank you
> -Dingming
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20181017/ac69a602/attachment.html>

More information about the P4-dev mailing list