Coder Social home page Coder Social logo

mfc's Introduction

MFC

CI

MFC stands for "My First Compiler". It is a little compiler for a language created by SolarLiner. It targets ARM.

Using it

Compiling MFC requires dune and the ocamlgraph package.

[1] Dependencies installation :

opam install dune ocamlgraph

[2] Compiling Mfc :

dune build

[3] Using Mfc :

./_build/default/bin/main.exe -i input.get -o output.s [-r]

Help can be displayed passing the -h flag.

./_build/default/bin/main.exe -h

Overview of the Gen language

The language Mfc compiles is minimalist. It manipulates only integers.

Variables declarations

var x

Variables affectation

x = 5

Note : As in old C standards, declarations and affectations should be separated.

Loops

while (x < 10) {
  ...
}

Conditionals

if (x < 10) {
  ...
} else {
  ...
}

Arithmetic

x = x + x
x = x - x
x = x * x

Structure of the compiler

MFC is designed in OCaml. For now, it's a 3 passes compiler :

  1. Parsing (using our own functional parser)
  2. Quad generation (intermediate "3 addresses" language)
  3. Arm generation (Register allocation)

Ocaml modules are like follow :

  • Mfc_ast : Module implementing the AST
  • Mfc_parser : The parser
  • Mfc_parsing : The parsing lib
  • Mfc_reg_alloc : Algorithm(s) for register allocation
  • Mfc_quad : Quad generation module
  • Mfc_env : Environnement manipulation (symbol table etc)

Todo(s)

Even if MFC is working on small examples, there are possible improvements.

  • Real intermediate language : in fact, our quad language is an abstraction over ARM. and is not generic at all.
  • Ast verification : The AST is currently poorly verified
  • Code optimization : Some simple optimizations could be implemented (DAGs to avoid recomputing arithmetic expressions for example).

mfc's People

Contributors

acorrenson avatar solarliner avatar

Stargazers

Brett Dispoto avatar  avatar

Watchers

James Cloos 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.