Proposal for a LLVM front-end for P4 language

Dear community,

We, a team at IIT Hyderabad are developing an LLVM front end for a networking language called P4 ( Our work aims to enable LLVM based optimizations for P4.

As the P4 language was designed to target many different switch architectures, we feel that P4 can comfortably fit in the LLVM framework where adding targets is more structured.

The existing open-source P4 compiler ( supports its BPF backend via clang by emitting C code.

P4 —> C ----> | Clang | → BPF.

We propose that having an LLVM front-end can make it much simpler by by-passing the C code-generation step.

As part of our implementation, we have a zeroth version of front-end to support some P4-16 constructs. We request the community to help us with the feedback. Here is the GitHub link.

Background on P4:

P4 is a high-level language for Programming Protocol-independent Packet Processors. P4 resembles C language, and is developed with the following goals:

  • Reconfigurability in the field: Programmers should be able to change the way switches process packets once they are deployed.

  • Protocol independence: Switches should not be tied to any specific network protocols.

  • Target independence: Programmers should be able to describe packet processing functionality independently of the specifics of the underlying hardware

More details can be found in the published p4 paper. (


Thank you

= Tharun, Venkat, Pankaj and Bhanu