# USTC: Principles and Techniques of Compiler

## Descriptions

- Offered by: University of Science and Technology of China (USTC)
- Prerequisites:  
- Programming Languages:  
- Difficulty: 🌟🌟🌟🌟
- Class Hour: 100 hours

The theoretical part of this course covers a wide range of topics, including lexical analysis, syntax analysis, syntax-directed translation, and intermediate code translation from traditional compiler principles courses, as well as runtime management and both machine-independent and machine-specific code optimization. The practical component provides C++ code for the Cminusf compiler framework, allowing students to progressively build a fully functional modern compiler over six labs. Unlike other compiler courses, this course uses a subset of modern LLVM as the intermediate code, offering a forward-looking approach and including backend code generation and intermediate code optimization, making it a world-class compiler course.

- The course labs use scripts to provide comprehensive automated testing, with complete tutorials available on the course homepage.
- The course includes a full set of open-source course materials, lab framework code, and lab tutorials, making it beginner-friendly.
- The labs progress gradually, increasing in difficulty, ensuring that students with varying levels of prior knowledge can benefit.
- In Lab 1, Flex and Bison are used to implement the compiler frontend. Lab 2 involves generating intermediate code with LightIR (a subset of LLVM). Lab 3 covers backend code generation for the Loongson assembly language. Lab 4 focuses on intermediate code optimization. Lab 5 implements machine-independent optimization, and Lab 6 deals with register allocation.

## Course Resources

- Course Website: <https://ustc-compiler-principles.github.io/2023>
- Recordings: <https://www.bilibili.com/video/BV1D7421N7c4>
- Textbook: See the course website
- Assignments: <https://ustc-compiler-principles.github.io/textbook>