CS 375: Compilers: Lecture Notes


Copyright © 2014 by Gordon S. Novak Jr.

Permission is granted for individuals to make copies of these notes for personal use, or for instructors to make copies for classroom use.

Note: Many of these pages use math symbols such as: ∀ ∃ . Microsoft Internet Explorer will not display the math symbols, but Firefox will.

Index

1. CS 375, Compilers: Class Notes
2.
3. Course Topics
4. Pascal Test Program
5. Introduction
6. Machine Language
7. Assembly Language
8. High-Level Language
9. Compilers
10. Sequential Phases of a Compiler
11. Data Flow through the Compiler
12. Line Handler
13. Lexical Analyzer
14. Syntactic Analyzer
15. Semantic Analysis
16. Lexical Analysis
17. Character Classes
18. Implementation of Character Classes
19. Hand-written Lexical Analyzer
20. Example Lexical Analyzer
21. Flowchart for Parsing Identifier
22. Lexical Language Design
23. Token Data Structure
24. Example Token Data Structure
25. Number Conversion
26. Simple Number Scanner
27. Lexical Analyzer Output
28. Floating Point Numbers
29. IEEE Floating Point Standard
30. Floating Point Examples
31. Errors
32. Error Messages
33. Formal Syntax
34. Grammar
35. Language Generation
36. Parsing
37. Ambiguity
38. Notation
39. Phrase Structure Grammar
40. Chomsky Hierarchy
41. Recognizing Automaton
42. Chomsky Language Hierarchy
43. Regular Languages
44. Example Regular Language
45. lex
46. Regular Expressions
47. Lex Specifications
48. Sample lex Specification
49. C for Lex Sample
50. lex.yy.c
51. Comments on Sample lex
52. Translation Section
53. Lex Conventions
54. The Lookahead Operator
55. Auxiliary Procedures
56. Parser Overview
57. Context Free Languages
58. Context Sensitive Languages
59. Derivations
60. Language Generated by a Grammar
61. Ambiguity and Left Recursion
62. Parsing
63. Top-down Parser
64. Bottom-up Parsing
65. Chart Parser
66. Augmented Transition Network Grammars
67. Augmented Transition Networks
68. Context Free Parser
69. Semantics Influences Parsing
70. Arithmetic Expressions
71. Example of Operator Precedence
72. Operator Precedence
73. Operator Precedence Parsing
74. Operator Precedence Parser
75. Examples
76. Stack Handling in C
77. Basic Routines
78.
79. Operator Precedence Parser
80.
81. Additional Considerations
82. Recursive Descent Parser
83. Bottom-up Table-driven (LR) Parsing
84. The LR Parsing Algorithm
85. Shift-Reduce Parser
86. Example Parsing Table(Aho, Lam, Sethi, and
87. A Parse of id * id + id(Aho, Lam, Sethi, and
88. Synthesized Translation
89. Using yacc
90. y.tab.c
91. Yacc Specifications
92. Example: Desk Calculator
93. Yacc: Pascal Subset
94. Auxiliary C Code
95. Auxiliary C Code ...
96. Controllability and Observability
97. Example
98. Examples ...
99. Examples ...
100. Hints for yacc
101. File trivb.tree
102. The Semantic Actions
103. Supporting C Routines
104. Example
105. Comments on the Example
106. Parsing Action Conflicts
107. Resolving Shift/Reduce Conflicts
108. Error Productions
109. Error Handling
110. Parsing Techniques
111. Looping Statements
112. Symbol Table
113. Symbol Table Organization
114. Symbol Table Organizations
115. Binary Tree Symbol Table
116. AVL Trees
117. Hash Table
118. Hash Functions
119. Indexed Buckets
120. Lexical Scoping
121. Tree of Symbol Tables
122. Stack Symbol Table
123. Use of Symbol Table
124. Symbol Table Entry
125. Kinds of Symbols
126. Kinds of Symbols ...
127. Looking up ID in Symbol Table
128. Variable Declarations
129. Identifier List etc.
130. Data Addressing
131. Storage Allocation
132. Alignment and Padding
133. Installing Variables in Symbol Table
134. Record Declarations
135. Symbol Table Structures for Record
136. Array Declarations
137. Symbol Table Structures for Array
138. Type Checking, Coercion, and Inference
139. Structure References
140. Structure References....
141. Record References
142. Array References
143. Array References in Pascal
144. Does Array Order Matter?
145. Example of Structure Declaration
146. Example of Structure Reference
147. Pointer Reference
148. Types as Tree Structures
149. Dynamic Type Checking
150. Static Type Checking
151. Strong Typing
152. Type Equivalence
153. Type Signatures
154. Polymorphic Procedures
155. Table for Labels
156. Intermediate Code
157. Trees
158. Quadruples
159. Triples
160. Reverse Polish Notation
161. Trees and Reverse Polish
162. Converting a Tree to RPN
163. Executing Reverse Polish
164. Executing RPN
165. RPN as Intermediate Code
166. Code Generation
167. Loading Process
168. Absolute File
169. Initializing BSS Storage
170. Banked Memory
171. Location Counter
172. Example of Assembly Listing
173. Backpatching
174. Link Editing Process
175. Relocatable Code
176. Finding Relocatable Modules
177. Assigning Absolute Addresses
178. Absolute Addresses
179. Link Editor
180. Form of Relocatable Code
181. Static Allocation
182. Dynamically Linked Library
183. Run-Time Support
184. Operations by Subroutine
185. Special Subroutines
186. Memory Management
187. Returning Memory
188. Heap Memory Management
189. Garbage Collection
190. Garbage Collection
191. Mark-And-Sweep Garbage Collection
192. Mark-and-Sweep ...
193. Copying Garbage Collection
194. Reference Counting
195. Reference Counting...
196. Garbage Collection Is Expensive
197. Compiled Procedure
198. Subroutine Call Is Expensive
199. Activations and Control Stack
200. Environment
201. Run-time Memory Organization
202. Code Generation
203. Code Generation
204. Code Generation
205. Running Generated Code
206. Overview of Code Generation
207. Code Generation for Statements
208. Arithmetic Expressions
209. Basic Expression Algorithm
210. Trace of Expression Algorithm
211. Arithmetic Expression Algorithm
212. Register Management
213. Simple Register Allocation
214. Heuristic for Expressions
215. Improving Register Allocation
216. Register Allocation
217. Example of Code Generation
218. Example (2)
219. Example (3)
220. Example (4)
221. Reusing Register Contents
222. Register Targeting
223. x86 Processor
224. Move (Load/Store) Instructions
225. Kinds of Move Addressing
226. Move with Calculated Address
227. Literals
228. Integer Arithmetic Instructions
229. Compare and Jump
230. Floating Point
231. Intrinsic Functions
232. Function Calls
233. Volatile Registers
234. Details of Function Call
235. IF Statement Generation
236. IF Statement Optimization
237. Array References
238. Easy Array References
239. Better Array References
240. Pointer References
241. switch Statement
242. switch Statement Compiled
243. switch Statement Compiled -O
244. Table Lookup
245. Table Lookup Compiled
246. Table Lookup Compiled -O
247. Parameter Passing
248. Macros
249. In-line Compilation
250. Optimization
251. Correctness of Optimization
252. Optional Optimization
253. Local and Global Optimization
254. Easy Optimization Techniques
255. Constant Folding
256. Peephole Optimization
257. Loop Unrolling
258. Partial Evaluation
259. Partial Evaluation
260. Example
261. Simple Partial Evaluator
262. Simple Partial Evaluator...
263. Examples
264. Examples
265. Binding-Time Analysis
266. Futamura Projections
267. Interpreter
268. Specialization
269. Parameterized Programs
270. Pitfalls of Partial Evaluation
271. Pitfalls ...
272. Program Analysis
273. Basic Block
274. Finding Basic Blocks
275. Relations and Graphs
276. Graph Notations
277. Bit Vector Representations
278. Boolean Matrix Representation of Graph
279. Dominators
280. Intervals
281. Definition and Reference of Variables
282. Data Flow Analysis for a Block
283. Availability of Expressions
284. Data Flow Analysis for an Interval
285. Busy Variables
286. Variable Uses and Register Assignment
287. Register Allocation by Graph Coloring
288. Overview of Global Optimization
289. gcc Compiler Optimization Options
290. gcc Optimizations
291. Loop Transformations
292. Strip Mining
293. Induction Variable Transformation
294. Finite Differencing
295. Example: Computing Squares
296. General Case
297. Finite Differencing for Set Operations
298. Memoization
299. Hardware Assistance
300. PowerPC Features
301. SPARC Features
302. Hardware Trends
303. Object-oriented Programming
304. Access to Objects
305. Domain Analysis
306. Internal Implementation is Hidden
307. Encapsulation with OOP
308. Object-oriented Programming Terminology
309. Terminology ...
310. Implementation of Objects
311. Are Basic Types Objects?
312. Inheritance and Class Structure
313. Message Sending
314. Dynamic Method Lookup
315. Static Method Lookup
316. Multiple Inheritance
317. Improving OOP Efficiency
318. Smalltalk
319. Smalltalk Code
320. ThingLab
321. ThingLab Examples
322. Good Features of OOP
323. Unfortunate Features of OOP
324. Why OOP Is Not Enough
325. Top Ten Lies About OOP
326. Aspect-Oriented Programming
327. Lisp
328. History of Lisp
329. Advantages of Lisp
330. Lisp Interaction
331. Function Definition
332. List Structure
333. Abstract Syntax Tree
334. Binding Lists
335. Substitution
336. Copying and Substitution Functions
337. Substitution in C
338. Loop Unrolling
339. Instantiating Design Patterns
340. Pattern Matching
341. Pattern Matching
342. Transformation by Patterns
343. Transformation Patterns
344. Program Transformation using Lisp
345. Dot Matching
346. Looping Patterns
347. Code Expansion by Looping Patterns
348. More Complex Rules
349. Multi-Level Patterns
350. Use of Multi-Level Patterns
351. Function Inlining
352. Program Transformation
353. Pattern Optimization Examples
354. Examples ...
355. Examples ...
356. Examples ...
357. Paul Graham:
358. English
359. Expression Trees to English (file
360. Generating English
361. Parsing English
362. ATN in Lisp (file atn.lsp))/A>
363. Parsing Functions
364. Grammar Compiler (file gramcom.lsp)
365. Access to Database(file restgram.lsp)
366. Restaurant Database Grammar
367. Restaurant Queries
368. Physics Problems(file physgram.lsp)
369. Physics Queries


CS 375