Skip to content

haotianmichael/rvcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rvcc

rvcc is my first compiler. And I decided not to maintain it.

It supports a subsets of C98. I choose 3-Address Code as IR for optimization. rvcc produces tmpCodeFile.txt to show IR, however, optimization doesn't perform well in rvcc, which will be the focus of my next Compiler.

For better readability, rvcc produces symbolTableFile.txt to show the symbolTable consists of var, const and function name of source code.

Finally, riscvCodeFile.s as the target assembly file will be produced. BUT, rvcc achieves few RISCV-Instructions, for Its origin purpose was to learn compiler technology.

TestSuite is here . All of tests can be compiled to IR level. But only J-constTB.c and J-varTB.c is fully compiled to run on the qemu. Here shows you how to build RISC-V GNU Compiler Toolchain.

RISCV

A breif introduction of my rv-implementation is here;

  • basic Memory layout
  • scanf
  • printf

Build

  • cd rvcc && mkdir build && cd build

  • cmake ../

  • make

  • ./release ../test_src/**TB.c

Output

  • riscvCodeFile.s
  • symbolTableFile.txt
  • tmpCodeFile.txt

About

A Small RISC-V Compiler

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published