[P4-dev] p4c compiler output in .p4i

Mihai Budiu mbudiu at vmware.com
Thu Jun 8 18:20:26 EDT 2017


p4c is just a shell script which invokes various compilers.
If you know which compiler you need you can just invoke it manually.
I guess it is p4c-bm2-ss.

Mihai

From: P4-dev [mailto:p4-dev-bounces at lists.p4.org] On Behalf Of hemant at mnkcg.com
Sent: Thursday, June 8, 2017 3:18 PM
To: 'Han Wang' <hw342 at cornell.edu>
Cc: 'p4-dev' <p4-dev at lists.p4.org>
Subject: Re: [P4-dev] p4c compiler output in .p4i

Hi Han,

The slides show the p4c compiler does support a –top4 option on slide 6.  However, the version of the p4c compiler that I downloaded (in early May 2017) does not have support for such an option.

$ p4c -x p4-16 -v --top4 pass1 stateful.p4
usage: p4c [-h] [-V] [-v] [-###] [-Xpreprocessor <arg>] [-Xp4c <arg>]
           [-Xassembler <arg>] [-Xlinker <arg>] [-b BACKEND] [-E] [-e] [-S]
           [-c] [-x {p4-14,p4-16}] [-I SEARCH_PATH] [-o PATH] [--target-help]
           [source_file]
p4c: error: unrecognized arguments: --top4 stateful.p4

Hemant

From: Han Wang [mailto:hw342 at cornell.edu]
Sent: Thursday, June 08, 2017 5:16 PM
To: hemant at mnkcg.com<mailto:hemant at mnkcg.com>
Cc: p4-dev <p4-dev at lists.p4.org<mailto:p4-dev at lists.p4.org>>
Subject: Re: [P4-dev] p4c compiler output in .p4i

Hi Hemant,

You can use the —top4 flag in p4c-bm2-ss and p4test to dump IR as inlined comments in p4 program, see slide 32 in compiler-design.pptx

Han

On Jun 8, 2017, at 2:01 PM, <hemant at mnkcg.com<mailto:hemant at mnkcg.com>> <hemant at mnkcg.com<mailto:hemant at mnkcg.com>> wrote:

Hi Han,

Got it.  I found the tools/driver/p4_src/p4c.bmv2.cfg and see the p4i is part of the preprocessor setup.  Thanks to Mihai for replying too.  About IR, what support does the current p4c compiler have for outputting IR?  Isn’t JSON output pending to be developed?

Thanks,

Hemant

From: Han Wang [mailto:hanwang at barefootnetworks.com]
Sent: Thursday, June 08, 2017 4:48 PM
To: hemant at mnkcg.com<mailto:hemant at mnkcg.com>
Cc: p4-dev <p4-dev at lists.p4.org<mailto:p4-dev at lists.p4.org>>
Subject: Re: [P4-dev] p4c compiler output in .p4i

Hi Hemant,

p4c is a compiler driver that invokes the other components of the p4 tool chain to process a p4 program. Specifically, for bmv2, the compiler driver invokes preprocessor and p4c-bm2-ss to generate the output json configuration for bmv2.

You can use the -### flag or --test-only flag to find out which commands are invoked by p4c compiler driver.

In this case, the .p4i file is the output of the preprocessor step.

Han

On Jun 8, 2017, at 1:40 PM, hemant at mnkcg.com<mailto:hemant at mnkcg.com> wrote:

The compiler-design slides included with the docs for the p4c compiler do not include some details.  Thus a question:

When I use p4c to compile P4-16 code in a .p4 file, the compiler outputs a .p4i file.  Looking at this file, it looks like IR (Intermediate Representation) to me – am I correct?   It would be good to describe this output file in the docs.

Thanks,

Hemant

_______________________________________________
P4-dev mailing list
P4-dev at lists.p4.org<mailto:P4-dev at lists.p4.org>
http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org<https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.p4.org_mailman_listinfo_p4-2Ddev-5Flists.p4.org&d=DwMFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=tGW6TKXajnoXSyy1S1P4DHGPe8sj54GGvw-b21n7aWg&m=x-mhhybccBKaaac4uXr3JRBprY6eFDtU3s56iVHeMyo&s=eOCvZSSebL5hZt-KfMysjfaW3K7GPGi0NJv8WQGIwFw&e=>

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


More information about the P4-dev mailing list