All Projects → jserv → Mazucc

jserv / Mazucc

Licence: bsd-2-clause
A minimalist C compiler with x86_64 code generation

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Mazucc

Mlml
self-hosted compiler for a subset of OCaml
Stars: ✭ 41 (-90.62%)
Mutual labels:  compiler, x86-64
Peachpy
x86-64 assembler embedded in Python
Stars: ✭ 1,592 (+264.3%)
Mutual labels:  compiler, x86-64
Mir
A light-weight JIT compiler based on MIR (Medium Internal Representation)
Stars: ✭ 1,075 (+146%)
Mutual labels:  compiler, x86-64
Dynarmic
An ARM dynamic recompiler.
Stars: ✭ 475 (+8.7%)
Mutual labels:  compiler, x86-64
Minijit
A basic x86-64 JIT compiler written from scratch in stock Python
Stars: ✭ 185 (-57.67%)
Mutual labels:  compiler, x86-64
Jit Compiler
JIT compiler in Go
Stars: ✭ 70 (-83.98%)
Mutual labels:  compiler, x86-64
Pyast64
Compile a subset of the Python AST to x64-64 assembler
Stars: ✭ 93 (-78.72%)
Mutual labels:  compiler, x86-64
Babygo
Go compiler made from scratch, which can compile itself. It's going to be the smallest and simplest go compiler in the world.
Stars: ✭ 143 (-67.28%)
Mutual labels:  compiler, x86-64
Wag
WebAssembly compiler implemented in Go
Stars: ✭ 177 (-59.5%)
Mutual labels:  compiler, x86-64
Crust
C compiler toolchain in Rust. [WIP, early development stage]
Stars: ✭ 150 (-65.68%)
Mutual labels:  compiler, x86-64
Asmjit
Machine code generation for C++
Stars: ✭ 2,874 (+557.67%)
Mutual labels:  compiler, x86-64
Ppci
A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python
Stars: ✭ 210 (-51.95%)
Mutual labels:  compiler, x86-64
Dora
Dora VM
Stars: ✭ 371 (-15.1%)
Mutual labels:  compiler, x86-64
Hy
A dialect of Lisp that's embedded in Python
Stars: ✭ 4,084 (+834.55%)
Mutual labels:  compiler
Scala Native
Your favorite language gets closer to bare metal.
Stars: ✭ 4,053 (+827.46%)
Mutual labels:  compiler
Nlvm
LLVM-based compiler for the Nim language
Stars: ✭ 380 (-13.04%)
Mutual labels:  compiler
Trunk
Build, bundle & ship your Rust WASM application to the web.
Stars: ✭ 378 (-13.5%)
Mutual labels:  compiler
Tiny Compiler
A tiny compiler for a language featuring LL(2) with Lexer, Parser, ASM-like codegen and VM. Complex enough to give you a flavour of how the "real" thing works whilst not being a mere toy example
Stars: ✭ 425 (-2.75%)
Mutual labels:  compiler
Oblivion
The language of Art
Stars: ✭ 414 (-5.26%)
Mutual labels:  compiler
Labeless
Labeless is a multipurpose IDA Pro plugin system for labels/comments synchronization with a debugger backend, with complex memory dumping and interactive Python scripting capabilities.
Stars: ✭ 378 (-13.5%)
Mutual labels:  x86-64

MazuCC

MazuCC is a minimalist C compiler with x86_64 code generation. It is intended to support partial C99 language features while keeping the code as small and simple as possible.

Build

Run make to build:

$ make

MazuCC comes with unit tests. To run the tests, give "check" as an argument:

$ make check

MazuCC is known to work on both GNU/Linux and macOS.

Use MazuCC to compile C source:

$ ./mzcc  sample/nqueen.c

Alternatively, MazuCC accepts the stream from standard input. The equivalent form for the above command is:

$ cat sample/nqueen.c | ./mzcc -

You will get the generated x86_64 assembly in AT&T syntax. The output can be assembled and linked into a valid executable:

$ ./mzcc -o sample/nqueen.s sample/nqueen.c
$ gcc -no-pie -o sample/nqueen sample/nqueen.s

If MazuCC is compiled and executed on macOS, the above argument -no-pie should be eliminated.

Reference output of MazuCC-compiled sample/nqueen:

Q . . . . . . .
. . . . Q . . .
. . . . . . . Q
. . . . . Q . .
. . Q . . . . .
. . . . . . Q .
. Q . . . . . .
. . . Q . . . .

Alternatively, you can dump internal abstract syntax tree:

echo 'struct {int x; char y; struct { int t; } z; } a;' | ./mzcc --dump-ast -

The expected output in S-expression form:

(decl (struct (int)
              (char)
              ((struct (int)))) a)

Acknowledge

MazuCC is heavily inspired by 8cc.

License

MazuCC is freely redistributable under the BSD 2 clause license. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

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