Git Product home page Git Product logo

mimic's Introduction

MimiC

MimiC is a compiler of C subset (extended SysY language) by USTB NSCSCC team.

MimiC can compile extended SysY language to ARM assembly and C.

Getting Started

MimiC requires:

  • cmake 3.5 or later.
  • C++ compiler supporting C++17 standard.

You can build MimiC from repository by executing the following commands:

$ git clone --recursive https://github.com/MaxXSoft/MimiC.git
$ cd MimiC && mkdir build && cd build
$ cmake .. && make -j8

Features

  • Hand written frontend.
  • Strong typed IR in SSA form.
  • Optimizer based on pass and pass manager.
  • Auto-scheduling, multi-stage, iterative pass execution.
  • Abstracted unified backend interface.
  • Machine-level IR (MIR) for multi-architecture machine instruction abstraction.
  • MIR based passes for multi-architecture assembly generation.

Architecture

Optimizer

optimizer

Backend

backend

Automated Testing Tools

See MimiC-autotest.

EBNF of the Extended SysY Lang

comp_unit       ::= {decl | type_def | func_def};
decl            ::= var_decl | func_decl;
type_def        ::= struct_def | enum_def | type_alias;
func_def        ::= func_header block;

var_decl        ::= type var_def {"," var_def} ";";
var_def         ::= ID_VAL {"[" expr "]"} ["=" init_val];
init_val        ::= expr | "{" [init_val {"," init_val}] "}";

func_decl       ::= func_header ";";
func_header     ::= type ID_VAL "(" [func_params] ")";
func_params     ::= func_param {"," func_param};
func_param      ::= type ID_VAL ["[" [expr] "]" {"[" expr "]"}];

struct_def      ::= "struct" ID_VAL "{" {struct_elem} "}" ";";
enum_def        ::= "enum" [ID_VAL] "{" enum_elems "}" ";";
type_alias      ::= "typedef" type ID_VAL ";";
struct_elem     ::= type struct_elem_def {"," struct_elem_def} ";";
struct_elem_def ::= ID_VAL {"[" expr "]"};
enum_elems      ::= ID_VAL ["=" expr] ["," enum_elems] [","];

block           ::= "{" {block_item} "}";
block_item      ::= decl | type_def | stmt;

stmt            ::= bare | block | if_else | while | control;
bare            ::= expr ";";
if_else         ::= "if" "(" expr ")" stmt ["else" stmt];
while           ::= "while" "(" expr ")" stmt;
control         ::= ("break" | "continue" | ("return" [expr])) ";";

expr            ::= cast {bin_op cast};
cast            ::= {"(" type ")"} unary;
unary           ::= {unary_op} factor | "sizeof" (factor | "(" type ")");
factor          ::= value | index | func_call | access | "(" expr ")";

bin_op          ::= "+"   | "-"   | "*"   | "/"   | "%"   | "&"
                  | "|"   | "^"   | "&&"  | "||"  | "<<"  | ">>"
                  | "=="  | "!="  | "<"   | "<="  | ">"   | ">="
                  | "="   | "+="  | "-="  | "*="  | "/="  | "%="
                  | "&="  | "|="  | "^="  | "<<=" | ">>=";
unary_op        ::= "+"   | "-"   | "!"   | "~"   | "*"   | "&";

value           ::= INT_VAL | CHAR_VAL | STR_VAL | ID_VAL;
index           ::= expr "[" expr "]";
func_call       ::= expr "(" [expr {"," expr}] ")";
access          ::= factor ("." | "->") ID_VAL;

type            ::= prim_type | struct_type | enum_type | const | pointer
                  | user_type;
prim_type       ::= "void" | ["unsigned"] "int" | "char";
struct_type     ::= "struct" ID_VAL;
enum_type       ::= "enum" ID_VAL;
const           ::= "const" type;
pointer         ::= type "*" {"*"};
user_type       ::= ID_VAL;

Copyright & License

Copyright (C) 2010-2020 MaxXSoft MaxXing, 2018-2020 USTB NSCSCC team.

License GPLv3.

mimic's People

Contributors

maxxsoft avatar yingluoqwq avatar

Watchers

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