{"id":18397012,"url":"https://github.com/iith-compilers/p4llvm","last_synced_at":"2025-07-25T23:32:50.859Z","repository":{"id":129375009,"uuid":"116374523","full_name":"IITH-Compilers/P4LLVM","owner":"IITH-Compilers","description":"P4-LLVM is an LLVM based compiler for P4","archived":false,"fork":false,"pushed_at":"2019-04-01T10:11:19.000Z","size":27857,"stargazers_count":43,"open_issues_count":4,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-04T12:06:05.670Z","etag":null,"topics":["llvm-ir","p4c","p4lang"],"latest_commit_sha":null,"homepage":"","language":"P4","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IITH-Compilers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-05T10:43:38.000Z","updated_at":"2024-08-12T06:45:17.000Z","dependencies_parsed_at":"2023-03-29T04:18:10.869Z","dependency_job_id":null,"html_url":"https://github.com/IITH-Compilers/P4LLVM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/IITH-Compilers/P4LLVM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IITH-Compilers%2FP4LLVM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IITH-Compilers%2FP4LLVM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IITH-Compilers%2FP4LLVM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IITH-Compilers%2FP4LLVM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IITH-Compilers","download_url":"https://codeload.github.com/IITH-Compilers/P4LLVM/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IITH-Compilers%2FP4LLVM/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267083606,"owners_count":24033329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["llvm-ir","p4c","p4lang"],"created_at":"2024-11-06T02:15:25.932Z","updated_at":"2025-07-25T23:32:50.834Z","avatar_url":"https://github.com/IITH-Compilers.png","language":"P4","funding_links":[],"categories":[],"sub_categories":[],"readme":"# P4 ➡ LLVM IR ➡ JSON\nP4LLVM is an LLVM based compiler for P4, a networking language.\n\nThis project is built upon open-source P4 compiler called [p4c](https://github.com/p4lang/p4c).\nThe LLVM IR emitter is a pass over p4c IR. We reuse the p4c front-end and translate p4c IR to LLVM IR.\n\nIf you use P4LLVM, please cite the following [paper](https://ieeexplore.ieee.org/document/8526847):\n```\n@inproceedings{2018p4llvm,\n  title={P4LLVM: An LLVM Based P4 Compiler},\n  author={Dangeti, Tharun Kumar and S, Venkata Keerthy and Upadrasta, Ramakrishna},\n  booktitle={2018 IEEE 26th International Conference on Network Protocols (ICNP)},\n  pages={424--429},\n  year={2018},\n  organization={IEEE}\n}\n```\nSupporting materials can be found [here](https://p4.org/assets/P4WE_2018/Dangeti_Kumar.pdf)\n\n![Image](images/blockdiagram.png)\n## Getting started\nInstall LLVM from source. We are using LLVM 7.0, not tested on the other versions.\n\n* `git clone https://llvm.org/git/llvm.git`\n* `git checkout 04bf737a84687a17137cc39da1f2e15ee74f1a4c` \n* `cd llvm \u0026\u0026 mkdir build \u0026\u0026 cd build`\n* `cmake ../`\n* `make `\n\nEither do `make install` after `make` or export the path of llvm binaries.\n\nClone the P4lang repository. It includes submodules, so be sure to use --recursive to pull them in:\n\n`git clone --recursive https://github.com/IITH-Compilers/p4lang.git`\n\nIf you forget to use `--recursive`, you can update the submodules at any time using:\n\n`git submodule update --init --recursive`\n\n### Install dependencies.\n\nDependencies for this repository are same as the p4c compiler. We are listing them here for ease.\n\n* A C++11 compiler. GCC 4.9 or later or Clang 3.3 or later is required.\n* git for version control\n* GNU autotools for the build process\n* CMake 3.0.2 or higher\n* Boehm-Weiser garbage-collector C++ library\n* GNU Bison and Flex for the parser and lexical analyzer generators.\n* Google Protocol Buffers 3.0 or higher for control plane API generation\n* GNU multiple precision library GMP\n* C++ boost library (minimally used)\n* Python 2.7 for scripting and running tests\n\n\n#### On Ubuntu you can use:\n\n`sudo apt-get install g++ git automake libtool libgc-dev bison flex libfl-dev libgmp-dev libboost-dev libboost-iostreams-dev libboost-graph-dev pkg-config python python-scapy python-ipaddr tcpdump cmake`\n\n##### Install protobuf 3.2.0\n\n* `git clone https://github.com/google/protobuf.git`\n* `git checkout v3.2.0`\n* `./autogen.sh`\n* `./configure`\n* `make`\n* `make check`\n* `sudo make install`\n* `sudo ldconfig # refresh shared library cache.`\n\n##### Build P4LLVM in a subdirectory named build.\n\n* `mkdir build \u0026\u0026 cd build`\n* `cmake ..`\n* `make -j4`\n\n## How to run?\nOnce make is successful, execute `p4c-llbm2-ss` in build directory to run the code. For example,\n\n`./p4c-llbm2-ss ../p4lang/testdata/p4_16_samples/arith-bmv2.p4`\n\nThis would create `arith2-bmv2.p4.ll`, a file with LLVM IR equivalent of `arith2-bmv2.p4` and `arith2-bmv2.p4.ll.json`, a JSON file to target BMV2 compiler. `arith2-bmv2.p4.ll.json` file would be found under P4_16_sample directory.\n\n## Running with optimization\nWhile running p4c-llbm2-ss, `--optimize` flag can be used to perform `oz` optimization of LLVM. For example,\n\n`./p4c-llbm2-ss --optimize ../p4lang/testdata/p4_16_samples/arith-bmv2.p4`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiith-compilers%2Fp4llvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiith-compilers%2Fp4llvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiith-compilers%2Fp4llvm/lists"}