All Projects → robertmuth → Cwerg

robertmuth / Cwerg

Licence: Apache-2.0 license
A light-weight compiler backend

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language
assembly
5116 projects
Makefile
30231 projects
CMake
9771 projects

Projects that are alternatives of or similar to Cwerg

Mandibule
linux elf injector for x86 x86_64 arm arm64
Stars: ✭ 171 (-17.39%)
Mutual labels:  arm, elf, arm64
tensorflow-serving-arm
TensorFlow Serving ARM - A project for cross-compiling TensorFlow Serving targeting popular ARM cores
Stars: ✭ 75 (-63.77%)
Mutual labels:  arm, arm64
Capstone.NET
.NET Core and .NET Framework binding for the Capstone Disassembly Framework
Stars: ✭ 108 (-47.83%)
Mutual labels:  arm, arm64
docker-images
All my docker images in one mono-repository with multi-arch support
Stars: ✭ 18 (-91.3%)
Mutual labels:  arm, arm64
elfloader
ARMv7M ELF loader
Stars: ✭ 71 (-65.7%)
Mutual labels:  arm, elf
deollvm64
deobfuscator llvm arm64 script
Stars: ✭ 67 (-67.63%)
Mutual labels:  arm, arm64
WindowsSimplify
Windows 系統優化精簡 / Windows Simplify Project
Stars: ✭ 234 (+13.04%)
Mutual labels:  arm, arm64
Android Disassembler
Disassemble ANY files including .so (NDK, JNI), Windows PE(EXE, DLL, SYS, etc), linux binaries, libraries, and any other files such as pictures, audios, etc(for fun)files on Android. Capstone-based disassembler application on android. 안드로이드 NDK 공유 라이브러리, Windows 바이너리, etc,... 리버싱 앱
Stars: ✭ 250 (+20.77%)
Mutual labels:  arm, elf
fdtd3d
fdtd3d is an open source 1D, 2D, 3D FDTD electromagnetics solver with MPI, OpenMP and CUDA support for x86, arm, arm64 architectures
Stars: ✭ 77 (-62.8%)
Mutual labels:  arm, arm64
alpine-php-fpm
Lightweight and optimised PHP-FPM (PHP 7.4, 8.0, 8.1) Docker images with essential extensions on top of latest Alpine Linux.
Stars: ✭ 53 (-74.4%)
Mutual labels:  arm, arm64
nsec-badge
Software from the NorthSec badge
Stars: ✭ 34 (-83.57%)
Mutual labels:  arm, elf
alpine-qbittorrent-openvpn
qBittorrent docker container with OpenVPN client running as unprivileged user on alpine linux
Stars: ✭ 230 (+11.11%)
Mutual labels:  arm, arm64
discolix
distroless arm docker images
Stars: ✭ 22 (-89.37%)
Mutual labels:  arm, arm64
multiarch-letsencrypt-nginx-proxy
nginx-proxy, docker-gen and letsencrypt-nginx-proxy-companion on arm archs
Stars: ✭ 23 (-88.89%)
Mutual labels:  arm, arm64
makeuniversal
Tool to create a Universal Binary version of a Qt distribution.
Stars: ✭ 40 (-80.68%)
Mutual labels:  arm, arm64
tensorflow-aarch64
Compiled tensorflow for aarch64 architecture
Stars: ✭ 20 (-90.34%)
Mutual labels:  arm, arm64
GoRAT
GoRAT (Go Remote Access Tool) is an extremely powerful reverse shell, file server, and control plane using HTTPS reverse tunnels as a transport mechanism.
Stars: ✭ 34 (-83.57%)
Mutual labels:  arm, arm64
Hellosilicon
An attempt with ARM64 assembly on Apple Silicon Macs
Stars: ✭ 220 (+6.28%)
Mutual labels:  arm, arm64
Doesitarm
🦾 A list of reported app support for Apple Silicon and the new Apple M1 Macs
Stars: ✭ 3,200 (+1445.89%)
Mutual labels:  arm, arm64
DLARM
DLARM: Dissertation for Computer Science Masters Degree at UFRGS
Stars: ✭ 24 (-88.41%)
Mutual labels:  arm, arm64

Cwerg

[Documentation] Status

NOTE: The author is looking for projects that want to try out Cwerg. So if you are interested in using Cwerg for your own compiler project, please check out Interfacing with Cwerg and/or reach out to the author.

Cwerg is a lightweight compiler backend aimed at new programming language implementations that want to avoid heavy dependencies like LLVM. It has no dependencies and can directly generate ELF executables for Arm32, Arm64 and X86-64 ISAs. Besides AOT compilation, (one-shot) JITing is also supported.

The core project currently consists of:

You may also find the following useful:

  • Docs (misc. documentation)
  • Examples (examples demonstrating API usage)

Most components are implemented twice (see rationale):

  1. spec/reference implementation: Python 3.9
  2. high performance implementation: C++17 (with limited STL usage)

Re-implementations in other languages are explicitly encouraged. A lot of code is table driven to facilitate that.

Cwerg de-emphasizes quality of the generated code (we hope to come within 50% of state of the art compilers) in favor of a small code base that can be understood by a single developer and very fast translation times.

Size Targets

The project tracks code size in LOC carefully. The goal is to limit the IR optimizer to 10kLOC and an additional 5kLOC for each supported target ISA (per implementation language). Note, that code generated from tables is not counted but the tables (written in Python) are.

Speed Targets

The goal for the c++ implementation is to translate the IR to an Elf executable at a speed of 500k IR instructions per sec using at most 4 cores on a 2020 era midrange desktop or high end laptop.

Whole program translation and parallel translation at the function level are explicit design goals for the C++ implementations.

Cwerg does not have a linker. Instead the responsibility of generating executables and resolving relocations rests with the assembler components of the various backends. An ELF library helps with the generation of ELF executables, which is the only object format currently supported.

Intentional Limitations

To keep the project lightweight the feature set must be curtailed. Since the project is still evolving, the details are not entirely cast in stone but the following features are unlikely to be supported (contact us before starting any work on these):

  • Instruction sets other than little endian (host and target) with 2's complement integers and IEEE floats.
  • Variable number of function parameters (var-args). Basically only used for printf/scanf and responsible for a disproportionate amount of complexity in ABIs. (Note, this precludes a proper C frontend.)
  • Full-blown dwarf debug info. The standard is over 300 pages long and unlikely to fit into the complexity budget. Line numbers will likely be supported.
  • C++ exception/unwind tables. A lot of code and complexity that only benefits one language.
  • Linking against code produced with other toolchains. There are currently no plans to emit linkable object code. And there is no ABI compatibility except for simple cases and syscalls.
  • Shared libs/dynamic linking adds complexity and slows programs down (both because of slower code idioms and prevention of optimizations), not to mention the DLL hell problem. (see also: https://drewdevault.com/dynlib, https://www.kix.in/2008/06/19/an-alternative-to-shared-libraries/) (Lack of shared lib support likely precludes Windows as a target platform.)
  • Sophisticated instruction scheduling which is less important for memory bound code and out-of-order CPUs.
  • Sophisticated loop optimizations. Probably best left to the frontend.
  • Variable sized stack frames (alloca). This requires a frame pointer, wasting a register, and makes it more difficult to reason about stack overflows.
  • A large standard library with unicode and locale support. Those add a lot of complexity and are better left to dedicated libraries.
  • Sophisticated DSLs like LLVM's Tablegen. DSLs increase cognitive load and require additional infrastructure like parsers which eat into our size targets. Instead we leverage the expressiveness of Python.

The IR optimizer currently does not use a full-blown Single Static Assigment (SSA) form. Instead it uses a modified use-def chain approach to get some of the benefits of SSA.

Porting to other Architectures

Ports for more regular architectures, e.g. RISC V, should be straight forward to implement (see porting hints).

Dependencies

Cwerg controls dependencies carefully to keep them at a bare minimum:

  • pycparser used by the (optional) C frontend

Inspirations

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