Introduction¶
The ppci (pure python compiler infrastructure) project is a compiler written entirely in python.
The project contains:
- A set of command line utilities, such as ppci-cc and ppci-ld.
- A pythonic api
- Support for:
- A simple intermediate language
- Machine independent code generation algorithms for register allocation and instruction selection
- A simple way to describe an instruction set
An example of command-line usage:
$ cd examples/linux64/hello-make
$ ppci-cc -c -O1 -o hello.o hello.c
...
$ ppci-ld --entry main --layout linux64.ld hello.o -o hello
...
$ ./hello
Hello, World!
An example usage of the library API:
>>> import io
>>> from ppci.api import cc, link
>>> source_file = io.StringIO("""
... int printf(char* fmt) { }
...
... void main() {
... printf("Hello world!\n");
... }
... """)
>>> obj = cc(source_file, 'arm')
>>> obj = link([obj])
Moving to the assembly level:
>>> import io
>>> from ppci.api import asm
>>> source_file = io.StringIO("""section code
... pop rbx
... push r10
... mov rdi, 42""")
>>> obj = asm(source_file, 'x86_64')
>>> obj.get_section('code').data
bytearray(b'[ARH\xbf*\x00\x00\x00\x00\x00\x00\x00')
Or even lower level:
>>> from ppci.arch.x86_64 import instructions, registers
>>> i = instructions.Pop(registers.rbx)
>>> i.encode()
b'['
Warning
This project is in alpha state and not ready for production use!
Table of contents¶
- Introduction
- Quickstart
- Howto
- Reference
- Compiler internals
- Faq
- Contributing
- Changelog
- Release 1.0 (Planned)
- Release 0.5.9 (Upcoming)
- Release 0.5.8 (Jun 8, 2020)
- Release 0.5.7 (Dec 31, 2019)
- Release 0.5.6 (Aug 22, 2018)
- Release 0.5.5 (Jan 17, 2018)
- Release 0.5.4 (Aug 26, 2017)
- Release 0.5.3 (Apr 27, 2017)
- Release 0.5.2 (Dec 29, 2016)
- Release 0.5.1 (Oct 16, 2016)
- Release 0.5 (Aug 6, 2016)
- Release 0.4.0 (Apr 27, 2016)
- Release 0.3.0 (Feb 23, 2016)
- Release 0.2.0 (Jan 23, 2016)
- Release 0.1.0 (Dec 29, 2015)
- Release 0.0.5 (Mar 21, 2015)
- Release 0.0.4 (Feb 24, 2015)
- Release 0.0.3 (Feb 17, 2015)
- Release 0.0.2 (Nov 9, 2014)
- Release 0.0.1 (Oct 10, 2014)
See also: Index, Module Index