SLIM: A Simplified LLVM IR Abstraction for Compiler Design Courses
摘要
Compiler design is a foundational course in computer science curricula. Students find compiler design course extremely challenging due to its multi-phase structure, heavy theoretical concepts and complex tools used for hands-on assignments. LLVM (Low-Level Virtual Machine) is a common framework used for lab work in compiler design course since it enables students to study and modify the intermediate representation (IR) by writing passes to better understand the process of compilation. It is observed that students have trouble interpreting the LLVM IR because (a) it uses a low-level load-store based abstraction of memory instead of a relatively higher level abstraction of three-address code which uses a name-based abstraction of memory and (b) plethora of details embedded within the LLVM IR instructions. To address these concerns, we have designed SLIM (Simplified LLVM IR Modelling), a high-level abstraction built over LLVM IR that uses a name-based abstraction of memory and hides low-level details. Our experience with students implementing analyses on LLVM IR and SLIM shows that SLIM is pedagogically effective in illustrating the role of IRs in compilation. SLIM helps reduce the cognitive load of the students and allow them to implement an analysis in the stipulated time (2-3 weeks) allotted for an assignment during the course tenure.