An optimizing compiler of SysY, a subset of C. Supported targets are armv7 and risc-v32. (To be accurate, armv7ve and rv32im.)
SysY is the language used by the Collegiate Student System Capability Challenge (Compiler Track) 2021, a compiler contest in China. (contest homepage)
For SysY specification (in Chinese), runtime, and testcases, see here.
Testcases of the contest consist of two parts: functional testcases and performance testcases. The functional testcases were scored by correctness, and the performance testcases were scored based on the running time of the compiler output. In the contest, we passed all the functional testcases, so did most of the teams in the final round. Our performance score and total score both took the first place.
Here are some test results on the performance testcases of the contest. The test environment is a Raspberry Pi 4B. As a comparison, the performance of the code generated by gcc (Raspbian 8.3.0-6+rpi1) 8.3.0
is also listed.
Arguments for gcc are -march=armv7ve -Ofast
.
Test results when automatic parallelization is disabled: no parallelization
Test results when automatic parallelization is enabled (add --enable-loop-parallel
to this compiler, -ftree-parallelize-loops=4
to gcc): parallelization
- Build
mkdir build
cd build
cmake ..
make -j$(nproc)
- Run
./compiler <source_code>.sy -o <output_asm>.s
Use --set-<key>=<value>
to specify key-value pairs. Here are the available options:
key | value | default | hint |
---|---|---|---|
arch |
armv7 , rv32 |
armv7 |
|
num-thread |
positive integer | 4 | The number of threads in auto parallelization when --enable-loop-parallel is specified. |
Other flags:
flag | hint |
---|---|
--enable-loop-parallel |
Enable automatic parallelization. Currently it's not available for rv32 . |
--exec |
Simulate the execution of IR instead of generating assembly code. |
--debug , --info , --warning , --error |
Different levels of logging. default to warning level. |
Also, remember to link the output with the runtime under runtime/
.
doc/intro.pdf
doc/pre.pdf
Kobayashi is a name from the anime Miss Kobayashi's Dragon Maid, and our team name in the contest is Miss Kobayashi's Compiler.