Giter VIP home page Giter VIP logo

8cc's Introduction

8cc C Compiler

8cc is a small C compiler. It supports a broad range of C99 features, such as compound literals or designated initializers. Some GNU extensions, such as computed gotos, are also supported. 8cc is self-hosting, which means 8cc can compile itself.

8cc's source code is carefully written to be as concise and easy-to-read as possible, so that the source code will eventually be a good study material to learn various techniques used in compilers. You might find the lexer, the preprocessor and the parser are already useful to learn how C source code is processed at each stage.

It does not produce optimized assembly code; 8cc treats the CPU as a stack machine. Local variables are always assigned on the stack. Operations in the form of A = B op C are executed in the following way.

  1. Load B and C to registers
  2. Apply op to yield a result
  3. Write the results back to A's location

Producing optimized assembly is being planned.

Build

Run make to build:

make

8cc comes with unit tests. To run the tests, give "test" as an argument:

make test

The following command compiles 8cc three times. The second generation binary and the third are self-compiled ones, and it's tested that they are identical. The unit tests are run for each generation of binaries.

make fulltest

8cc supports x86-64 Linux only. I'm using Ubuntu 11 as a development platform. It should work on other x86-64 Linux distributions.

Author

Rui Ueyama [email protected]

Links for C compiler development

8cc's People

Contributors

rui314 avatar shinh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.