1 / 19

Introduction to Compilers: Overview, Structure, and Projects

This overview provides a brief introduction to compilers and their importance in software development. It covers the history, structure, and phases of compiler design, as well as the combination of theory and practice involved. The course structure, online resources, textbooks, and project details are also mentioned.

acutler
Télécharger la présentation

Introduction to Compilers: Overview, Structure, and Projects

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Overview Compiler Baojian Hua bjhua@ustc.edu.cn

  2. What is a Compiler? • A compiler translates source programs into target programs. • High-level source languages: • C/C++, Java, C#, html, ... • Low-level: • x86, IA64, ARM, MIPS, … • The concept of compiling is often more general than this

  3. High-level View source program compiler static computations target program machine dynamic computations results

  4. Long History • Long history of study in CS • in 50’s last century, Fortran • Almost all of the key ideas in compiler design are also important in other problem domains • You will end up using compiler design principles in almost every software development project

  5. Still active today • Compiler design is still an active area of research • Tremendous amount of activity in various forms of security and safety-related compilation • Parallel languages and multi-processors machines • domain-specific languages • We will do some reading of recent research papers, in addition to working on our own compiler projects

  6. Compiler Structure • Compilers are structured in highly modularized fashion • promotes better correctness, maintenance, etc • permits easier retargeting for new architectures • naturally follows the static/dynamic staging of high-level source programs

  7. Compiler structure string of characters lexical analyzer sequence of tokens parser symbol table abstract syntax tree semantic analyzer intermediate code code generator relocatable object code

  8. Compiler phases, more detailed… lex parse parsing actions semantic analysis Source program Translate Abstract syntax Reductions Tokens translate canonicalize instruction selection control flow analysis Translate Flow Graph Assem IR trees IR trees register allocation code emission assembler linker Relocatable code Register assignment Assembly code Flow Graph Machine code

  9. Every phase is different • All in all, every phase presents unique challenges, and makes use of different (math) concepts, data structures, and algorithms • A major aspect of compiler design, therefore, is how to synthesize all of this into a coherent, reliable, and robust system

  10. Theory & Practice • The beauty of a compiler comes from its elegant combination of theory and practice • Theory part: automata, grammar, type theory, closure, lattice, fix-point, … • Practice part: various data structures & algorithms, software engineering techniques to handle all of them

  11. How This Course Works

  12. Structure of this course • Readings • Textbook, research papers • Lectures • now • Exercises & quizzes • one quiz one lecture • Projects • development of a compiler from scratch

  13. Online Resources • Web site: • http://staff.ustc.edu.cn/~bjhua • Material: • course policies and schedule of lectures • readings and exercises • project information • development resources • some lecture notes • Check the web site frequently

  14. Textbooks & Reference • Modern compiler implementation in C/ML/Java (tiger book) • Compilers: principals, techniques and tools (dragon book) • Advanced compiler design and implementation (whale book) • Engineering a compiler (ark book)

  15. Projects • You’ll build a compiler Tiger, from scratch, in Java for (a subset of) Java • 6 labs planned + one final • Lab1: lexer and parser • Lab2: abstract syntax tree & elaborator • Lab3: code generators • Lab4: garbage collector • Lab5: optimizations • Lab6: register allocator • Final: a project on your own • Lab 1 is out, due next week, so start early

  16. Projects • In each lab, you’ll build a working component step by step • Using Java as the implementation languages • chick-and-egg • we offer some code skeleton • Team working is required

  17. Evaluation • 50%: projects • 50%: middle and final tests

  18. Summary • This is intended to be a fun and engaging project-oriented class • By the end of the term, you will have implemented a serious compiler for a nontrivial OO programming language! • Stay engaged, and pay attention to coding style and modularity, and it is fun and profit

  19. Last Thing • Read textbook chap1, chap2 • Start early on Lab1

More Related