Compiler Construction
The compiler construction course isn’t offered every semester, so as soon as I saw that it was being offered I decided to register for the course. In fact, it was a course that I had been interested in taking since the end of my second year and just now during my fourth year I had managed to register for it.
Concepts covered during the semester were a breakdown of the four main stages of a compiler; lexical analysis (tokenization), syntactical analysis (parsing), code generation, and code optimization. The assignments given corresponded to these four stages. For development of the assignments, we used the Java programming language along with SSCC, and Jasmin. SSCC is a compiler compiler, and much like JavaCC it creates a parser based upon the definition of a language. Jasmin is an assembler for the Java Virtual Machine.
During the classes we learnt theory regarding compilers, which included a review of regular expressions, finite state machines, and context-free grammars, as they are used in the front end of a compiler. New material discussed included an explanation of the two main types of parsing and their related grammars – LL(1) and LR(k) – along with the processes used for type checking, intermediate code generation, scoping, code analysis, and optimization. Along with these subjects we also looked at the inner workings of SSCC, the Java Virtual Machine, and then briefly at the GNU Compiler Collection.
The more interesting part of this course in my opinion occurred in the latter half. The fourth – and last – assignment was to implement a handful of code optimizations which included peephole optimizations for flow of control and constant folding, dead code elimination, reductions of strength, and some basic optimizations dealing with reaching definitions and next use information of variables. The optimizations themselves were iterated on the code until no new changes were made, ensuring fully optimized code according to the implemented optimizations.
Categories
- bmx (1)
- hardware (1)
- software (2)
- uncategorized (1)
Articles
- January 2012 (2)
- November 2011 (3)