Skip to content

Compiler of SysY, course project of Compile Principles in PKU

Notifications You must be signed in to change notification settings

qts0312/SysY-Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SysY-Compiler

Introduction

This project is a compiler for SysY language, which is a subset of C. It is implemented in Rust and uses Koopa as intermediate representation.

The compiler can compile SysY source code into Koopa IR with -koopa option and RISC-V assembly with -riscv option.

Even though the compiler can satisfy the standard of course, there are still some bugs and flaws. I am glad to receive any suggestions and corrections.

Architecture

Building a compiler is a complex task. With the help of automatic tools, I devote most of my effort in parts below.

  • mem: create Koopa IR in memory, based on the AST. In this process, the compiler collects information about the birth and death of values, and large arrays initialized with zero.
  • ir: translate Koopa IR in memory into string.
  • asm: generate RISC-V assembly from Koopa IR in memory. Register allocation and other optimization is done in this process.

Evaluation

In performance evaluation, 20 benchmark programs compiled by the compiler are tested, which cost 278.91s in total. The compiler is ranked 5th this term.

About

Compiler of SysY, course project of Compile Principles in PKU

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages