windelbouwman / ppci

A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python

Home Page:https://ppci.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction

The PPCI (Pure Python Compiler Infrastructure) project is a compiler written entirely in the Python programming language. It contains front-ends for various programming languages as well as machine code generation functionality. With this library you can generate (working!) machine code using Python (and thus very easy to explore, extend, etc.)!

The project contains:

  • Language frontends for C, Python, Pascal, Basic and Brainfuck
  • Code generation for several architectures: 6500, arm, avr, m68k, microblaze, msp430, openrisc, risc-v, stm8, x86_64, xtensa
  • Command line utilities, such as ppci-cc, ppci-ld and ppci-opt
  • WebAssembly, JVM, OCaml support
  • Support for ELF, EXE, S-record and hexfile formats
  • An intermediate representation (IR) which can be serialized in json
  • The project can be used as a library so you can script the compilation process

Installation

Since the compiler is a python package, you can install it with pip:

Usage

An example of commandline usage:

API example to compile C code:

Example how to assemble some assembly code:

Example of the low level api usage:

Functionality

  • Command line utilities:
  • Can be used with tools like make or other build tools.
  • Language support:
    • C
    • Pascal
    • Python
    • Basic
    • Brainfuck
    • C3 (PPCI's own systems language, intended to address some pitfalls of C)
  • CPU support:
    • 6500, arm, avr, m68k, microblaze, msp430, openrisc, risc-v, stm8, x86_64, xtensa
  • Support for:
    • WebAssembly
    • JVM
    • OCaml bytecode
    • LLVM IR
    • DWARF debugging format
  • File formats:
    • ELF files
    • COFF PE (EXE) files
    • hex files
    • S-record files
  • Uses well known human-readable and machine-processable formats like JSON and XML as its tools' formats.

Documentation

Documentation can be found here:

Warning

This project is in alpha state and not ready for production use!

You can try out PPCI at godbolt.org, a site which offers Web access to various compilers: https://godbolt.org/g/eooaPP

gitter_ appveyor_ codecov_ docstate_ travis_ codacygrade_ codacycoverage_ downloads_ conda_

About

A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python

https://ppci.readthedocs.io/en/latest/

License:BSD 2-Clause "Simplified" License


Languages

Language:Python 89.6%Language:C 6.8%Language:Verilog 3.0%Language:LLVM 0.3%Language:Brainfuck 0.2%Language:JavaScript 0.1%Language:Pascal 0.1%Language:C++ 0.0%Language:Shell 0.0%Language:HTML 0.0%Language:Assembly 0.0%