|
C2MP
|
See https://gliech.pages.unistra.fr/compilation/
Sample input file:
You will need a C compiler (tested against GCC and clang), make, flex and bison for building. bats and the MPC/MPFR library headers are needed for running the test suite (see tests/main.c and tests/e2e/). doxygen and dot are required for building the documentation.
make for building the binarymake doc for running Doxygenmake clean for cleaning all productsmake release for building a binary with optimizations enabled (clean first)make test for building the unit-test binary and run the unit and end-to-end testsmake cover for building binaries with coverage enabled and running the test suite (clean first)-a let's you see the tree.lexer.l, parser.y)ast.c, statement.c). During this phase, the type of each symbol is checked (e.g. x = y < z means x is a bool, while y and z both need to be numeric values).optim.c)x = y * 1 yields x = y ; x = y + 0 yields x = y)x = y, it aliases x to y)init section, where all the temporary variables are initializedassign section, where external variables and constants are setoperations section, where each quad yields codeclear section, where symbols are output and variables clearedif, loops, return, break, continue) are not supported yet by the quad generator-v option)A few unit tests are defined. They essentially cover operations on the AST, on statements, on quads and the code generation.
The generation of quads from the AST is not yet covered by the tests.
End to end tests are in the tests/e2e/ directory. You'll find in here examples of files that work with C2MP.
tests/e2e/files/%.c is the input filetests/e2e/expected/output/%.c is the generated filetests/e2e/expected/optimized/%.c is the generated file with optimizations enabledtests/e2e/expected/ast/%.ast is the generated ASTEach test file is done so it can be compiled without C2MP transforming it first. Each test file is compiled and run in its 3 forms (original, transformed, optimized) and the output is checked.
This allowed us to squash a lot of bugs and ensure optimizations yield the same results.
Tests are run with GitLab CI on each commit with both GCC and clang.
The documentation is generated by Doxygen and automatically published to https://gliech.pages.unistra.fr/compilation/ by GitLab CI.
Code is hosted on GitLab: https://git.unistra.fr/gliech/compilation
1.8.15