Giter Club home page Giter Club logo

mcc's Introduction

mcc

This repository contains my implementation of a compiler for a subset of C language. The compiler is written in C++, it accepts C files and generates X86-64 assembly output.

Layout

  • examples/ contains sample example files and corresponding assembly generated by gcc
  • src/ contains all compiler source files
  • tests/ contains tests in form of a program and expected program output
  • LOG.md contains the working log on the project, describing some design decisions and general dev process

Install

Note that x86-64 Linux is the only supported platform for now.

git clone https://github.com/caballeto/mcc
cd mcc/
make
make install

Features

The compiler functionality is mainly finished, at least the part I was aiming at. It supports operators, function calls, register spilling, struct, union, enum, typedef, pointers, pointer arithmetic, arrays, and more.

Bugs & More

These are some bugs I intend to fix, once I will have some time for that.

  • call inside arguments reassigns %rdi (param) registers
  • implement better conditional expression generation
  • rewrite register allocation algorithm
  • would be good to extend fully integer types (signed/unsigned/long long int, etc.) and be able to use gcc headers

Resources

  • github.com/DoctorWkt/acwj - a C compiler in C
  • https://www.cs.virginia.edu/~evans/cs216/guides/x86.html - x86 tutorial
  • Retargetable C compiler - implementation of a small production C compiler (lcc)

Ideas and some parts of the code have been taken from Tommy Warren's github.com/DoctorWkt/acwj.

mcc's People

Contributors

caballeto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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