Skip to content

A rudimentary RISC-V compiler targeting preprocessed C90 written in C++

Notifications You must be signed in to change notification settings

sarachehab/UlyCpp

Repository files navigation

This repository documents the work on the final coursework for the Instruction Architecture and Compilers 2024 module, collaboratively completed with Noam Weitzman.

Project Overview

In this project, we implemented a C90 to RISC-V compiler using C++. The compiler supports the following features:

  • Binary and Unary operations
  • Integers
  • Floats and Doubles
  • Function calls
  • Arrays
  • Pointers
  • Chars
  • Strings
  • Globals
  • Control flow
  • Switch statement
  • Enums
  • Typedef

Repository Structure

├───compiler_tests
│   ├───array
│   ├───control_flow
│   ├───...
├───include
│   ├───arrays
│   ├───context
│   ├───...
├───scripts
└───src
    ├───arrays
    ├───context
    ├───...
  • include/: Contains user-defined header files, such as ast.hpp.
  • scripts/: Contains scripts for running the compiler and tests.
  • src/: Contains the source code, including lexer, parser, compiler, and command line programs.

To build and test the compiler, run:

python3 test.py ../compiler_tests

Future Work

Over the summer, the codebase will be augmented to include structs.

Technologies Used

The project makes use of:

  • LEX for token recognition
  • YACC for AST building
  • Object-Oriented Programming, inheritance and polymorphism for Node handling

Acknowledgements

  • The coursework was originally designed by David Thomas, who lectured this module until 2017-18. It is nowadays maintained by John Wickerson, to whom any feedback should be sent.
  • Thanks to Yann Herklotz for making various improvements to the compiler-testing scripts.
  • Thanks to Archie Crichton for providing a basic "getting started" compiler.
  • Thanks to James Nock for overhauling the scripts for configuring the development environment, for writing detailed instructions for setting this up on various operating systems, and for creating GitHub actions capable of automatically testing compilers.
  • Thanks to Quentin Corradi for setting up coverage testing and writing a getting-started guide for that.
  • Thanks to Filip Wojcicki for overhauling the coursework specification and providing a new getting-started guide.
  • Thanks to Noam Weitzman for putting up with me! ;)

About

A rudimentary RISC-V compiler targeting preprocessed C90 written in C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published