P4C
The P4 Compiler
|
This is a back-end which generates code for the Behavioral Model version 2 (BMv2).
It can accept either P4_14 programs, or P4_16 programs written for the v1model.p4
switch model.
To run and test this back-end you need some additional tools:
sudo ldconfig
sudo pip3 install scapy
Here are some unsupported features we are aware of. We will update this list as more features get supported in the bmv2 compiler backend and as we discover more issues.
bit<>
or int<>
)v1model.p4
The backends/bmv2/pna_nic
directory contains components specific to the BMv2's PNA NIC (Portable NIC Architecture) backend in the P4C compiler. The files in this folder depend on each other, on the files in the bmv2/common
and portable_common
directories. Most of the classes are inherited from the classes in the portable_common
directory.
Output Binary: p4c-bm2-pna
File(s) | Description |
---|---|
pnaProgramStructure.h , pnaProgramStructure.cpp | Defines and implements the program structure (metadata, parsers, controls, and deparsers) and parsing logic specific to the BMv2's PNA NIC backend. |
midend.h , midend.cpp | Defines the mid-end processing of the PNA NIC compiler. Performs various transformations and optimizations on the program's Intermediate Representation (IR). |
options.h , options.cpp | Manages the command-line options for the PNA NIC compiler. |
pnaNic.h , pnaNic.cpp | Provides backend implementation to the BMv2's PNA NIC compiler. |
main.cpp | Sets up compilation environment, integrates various components, and executes the PNA NIC compiler. |
version.h.cmake | Defines macros containing version information for the PNA NIC compiler. |
The portable_common
directory contains reusable components common to both the psa_switch
and pna_nic
backends.
File Name | Description |
---|---|
midend.h, midend.cpp | Defines the common mid-end processing of both the psa_switch and pna_nic backends. |
options.h, options.cpp | Defines the common command-line options of both the psa_switch and pna_nic backends. |
portable.h, portable.cpp | Defines common functionalities that generate representations of P4 programs. |
portableProgramStructure.h, portableProgramStructure.cpp | Defines and implements the common program structure of both the psa_switch and pna_nic backends. _These files are located in the backends/common directory. |