Compilers – Register Allocation and Garbage Collection: my study notes

These notes are from the Week 9 of the Compilers course by Stanford. Register Allocation When we generate intermediate code, we are not concerned about how many registers the target machine has. Therefore, the last phase should allocate variables in registers and also have a backup plan when more variables need to be allocated at any given… Continue reading Compilers – Register Allocation and Garbage Collection: my study notes

Compilers – Local Optimization & Global Optimization: my study notes

These notes are from the Week 8 of the Compilers course by Stanford. An intermediate language provides an intermediate level of abstraction while compiling languages, helping optimizations by including more details than the source language has, but not as much as the target language. Code optimization is usually done before code generation in intermediate code, to avoid… Continue reading Compilers – Local Optimization & Global Optimization: my study notes

Compilers – Code Generation & Operational Semantics: my study notes

These notes are from the Week 7 of the Compilers course by Stanford. This focuses on the discussion about code generation. The architecture chosen for this class is a Stack Machine architecture on top of the MIPS architecture. Code Generation The MIPS processor supports the following instructions: lw reg1 offset reg2: Load a 32-bit word from the address… Continue reading Compilers – Code Generation & Operational Semantics: my study notes

Compilers – Cool Type Checking & Runtime Organization: my study notes

These notes are from the Week 6 of the Compilers course by Stanford. This week is going over how the Cool type checking and runtime organization are going to be organized. Static and Dynamic typing Dynamic and Static types vary in which time they are evaluated. Static typing is evaluated in compile-time without knowing any input from… Continue reading Compilers – Cool Type Checking & Runtime Organization: my study notes

Compilers – Semantic Analysis and Type Checking: my study notes

These notes are from the Week 5 of the Compilers course by Stanford. The semantic analysis phase is the last line of defense for the compiler, meaning the next phase will always have a valid program to compile. This is done in a separate phase because during the parsing phase, it is harder to catch some errors.… Continue reading Compilers – Semantic Analysis and Type Checking: my study notes

Compilers – Bottom-Up Parsing: my study notes

These notes are from the Week 4 of the Compilers course by Stanford. Predictive Parsing Predictive Parsing is one type of recursive parsing that does not require backtracking. It does so by looking at the next few tokens and accept LL(k) – left-to-right, left-most, k tokens – grammars. The predictive parsing algorithm uses the following steps to… Continue reading Compilers – Bottom-Up Parsing: my study notes

Compilers – Top-Down Parsing: my study notes

These notes are from the Week 3 of the Compilers course by Stanford. The parsing phase comes right after the lexing phase is complete with its result as input. The basic difference between the two is that the lexer transforms a string of characters into a string of tokens, and later on, the parser transforms that string… Continue reading Compilers – Top-Down Parsing: my study notes

Compilers – Lexical Analysis: my study notes

These notes are from the Week 2 of the Compilers course by Stanford. You may notice that this week also covers Finite Automata, but I left this out on purpose. Lexical Analysis This phase transforms the source code file into the tokens of the program. To achieve this it needs to both identify and then… Continue reading Compilers – Lexical Analysis: my study notes

Compilers – Introduction: my study notes

These notes are from the Week 1 of the Compilers course by Stanford. History The problem that compilers tried to solve, in the ’50s was basically to improve the software developers’ productivity. At that time, they started to realize that the software cost was much greater than the hardware cost, even though the hardware was… Continue reading Compilers – Introduction: my study notes