All Projects → IITH-Compilers → P4LLVM

IITH-Compilers / P4LLVM

Licence: Apache-2.0, Apache-2.0 licenses found Licenses found Apache-2.0 LICENSE Apache-2.0 LICENSE.md
P4-LLVM is an LLVM based compiler for P4

Programming Languages

P4
22 projects
C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language
CMake
9771 projects
c
50402 projects - #5 most used programming language
LLVM
166 projects

Projects that are alternatives of or similar to P4LLVM

p4fpga
P4-14/16 Bluespec Compiler
Stars: ✭ 70 (+112.12%)
Mutual labels:  p4c
Decaf-Compiler
Compiler for Decaf Programming Language
Stars: ✭ 36 (+9.09%)
Mutual labels:  llvm-ir
Dxbc2Dxil
DEPRECATED. DXBC to DXIL (HLSL Bytecode to LLVM IR) using internal APIs.
Stars: ✭ 21 (-36.36%)
Mutual labels:  llvm-ir
gauntlet
Finding bugs in P4 compilers using translation validation.
Stars: ✭ 23 (-30.3%)
Mutual labels:  p4c
Mcsema
Framework for lifting x86, amd64, aarch64, sparc32, and sparc64 program binaries to LLVM bitcode
Stars: ✭ 2,198 (+6560.61%)
Mutual labels:  llvm-ir
bl
Simple imperative programming language created for fun.
Stars: ✭ 57 (+72.73%)
Mutual labels:  llvm-ir
llvm-brainfuck
Brainfuck compiler based on LLVM API
Stars: ✭ 27 (-18.18%)
Mutual labels:  llvm-ir
llvm-kaleidoscope
LLVM Tutorial: Kaleidoscope (Implementing a Language with LLVM)
Stars: ✭ 124 (+275.76%)
Mutual labels:  llvm-ir
llvm-hs-typed
Type Safe LLVM IR ( Experimental )
Stars: ✭ 47 (+42.42%)
Mutual labels:  llvm-ir
LLVM-Metadata-Visualizer
LLVM Metadata Visualizer
Stars: ✭ 20 (-39.39%)
Mutual labels:  llvm-ir
TinyCompiler
c compiler based on flex(lex), bison(yacc) and LLVM, supports LLVM IR and obj code generation. 基于flex,bison以及LLVM,使用c++11实现的类C语法编译器, 支持生成中间代码及可执行文件.
Stars: ✭ 162 (+390.91%)
Mutual labels:  llvm-ir
ncc
Neural Code Comprehension: A Learnable Representation of Code Semantics
Stars: ✭ 162 (+390.91%)
Mutual labels:  llvm-ir
validating-binary-decompilation
Scalable Validator for Binary Lifters
Stars: ✭ 41 (+24.24%)
Mutual labels:  llvm-ir
doc
Design documents related to the decompilation pipeline.
Stars: ✭ 23 (-30.3%)
Mutual labels:  llvm-ir
llvm-semantics
Formal semantics of LLVM IR in K
Stars: ✭ 42 (+27.27%)
Mutual labels:  llvm-ir
McNinja
Compile Binary Ninja's MLIL to LLVM, for purposes of analysis, patching, and compiling it back to a binary again.
Stars: ✭ 30 (-9.09%)
Mutual labels:  llvm-ir
LLAST
A high level LLVM IR AST provider for GraphEngine JIT.
Stars: ✭ 21 (-36.36%)
Mutual labels:  llvm-ir
p4srv6
Proto-typing SRv6 functions with P4 lang.
Stars: ✭ 44 (+33.33%)
Mutual labels:  p4lang

P4 LLVM IR JSON

P4LLVM is an LLVM based compiler for P4, a networking language.

This project is built upon open-source P4 compiler called p4c. The LLVM IR emitter is a pass over p4c IR. We reuse the p4c front-end and translate p4c IR to LLVM IR.

If you use P4LLVM, please cite the following paper:

@inproceedings{2018p4llvm,
  title={P4LLVM: An LLVM Based P4 Compiler},
  author={Dangeti, Tharun Kumar and S, Venkata Keerthy and Upadrasta, Ramakrishna},
  booktitle={2018 IEEE 26th International Conference on Network Protocols (ICNP)},
  pages={424--429},
  year={2018},
  organization={IEEE}
}

Supporting materials can be found here

Image

Getting started

Install LLVM from source. We are using LLVM 7.0, not tested on the other versions.

  • git clone https://llvm.org/git/llvm.git
  • git checkout 04bf737a84687a17137cc39da1f2e15ee74f1a4c
  • cd llvm && mkdir build && cd build
  • cmake ../
  • make

Either do make install after make or export the path of llvm binaries.

Clone the P4lang repository. It includes submodules, so be sure to use --recursive to pull them in:

git clone --recursive https://github.com/IITH-Compilers/p4lang.git

If you forget to use --recursive, you can update the submodules at any time using:

git submodule update --init --recursive

Install dependencies.

Dependencies for this repository are same as the p4c compiler. We are listing them here for ease.

  • A C++11 compiler. GCC 4.9 or later or Clang 3.3 or later is required.
  • git for version control
  • GNU autotools for the build process
  • CMake 3.0.2 or higher
  • Boehm-Weiser garbage-collector C++ library
  • GNU Bison and Flex for the parser and lexical analyzer generators.
  • Google Protocol Buffers 3.0 or higher for control plane API generation
  • GNU multiple precision library GMP
  • C++ boost library (minimally used)
  • Python 2.7 for scripting and running tests

On Ubuntu you can use:

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

Install protobuf 3.2.0
  • git clone https://github.com/google/protobuf.git
  • git checkout v3.2.0
  • ./autogen.sh
  • ./configure
  • make
  • make check
  • sudo make install
  • sudo ldconfig # refresh shared library cache.
Build P4LLVM in a subdirectory named build.
  • mkdir build && cd build
  • cmake ..
  • make -j4

How to run?

Once make is successful, execute p4c-llbm2-ss in build directory to run the code. For example,

./p4c-llbm2-ss ../p4lang/testdata/p4_16_samples/arith-bmv2.p4

This 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.

Running with optimization

While running p4c-llbm2-ss, --optimize flag can be used to perform oz optimization of LLVM. For example,

./p4c-llbm2-ss --optimize ../p4lang/testdata/p4_16_samples/arith-bmv2.p4

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].