Docsity

Knowledge Required for Implementing A Successful Compiler | COP 5621, Study notes of Computer Science

Toggle sidebar
bg1
Concepts Introduced in Chapter 1
๎˜€
High-level introducti on to compiling.
๎˜
Phases
๎˜
Compiler Construction Tools
๎˜
Front Ends and Back Ends
๎˜
Analysis-Synthesis Model
๎˜
Assemblers
๎˜
Linkers and Loaders
Translator
๎˜€
A translator is a program that reads a program
written in a source language and translates it to an
equivalent program written in a target language.
Knowledge Required for
Implementing a Successful Compiler
๎˜€
Programming Languages
๎˜€
Computer Architecture
๎˜€
Formal Languages
๎˜€
Algorithms
๎˜€
Graph Theory
๎˜€
Software Engineering
Other Applications Related to
Compilers
๎˜€
Compiler Relatives
๎˜
Interpreters
๎˜
Structure Editors
๎˜
Pretty Printers
๎˜
Static Checkers
๎˜
Debuggers
๎˜€
Other Applications
๎˜
Text Formatters
๎˜
Silicon Compilers
๎˜
Query Interpreters
pf3
pf4
pf5

Partial preview of the text

Download Knowledge Required for Implementing A Successful Compiler | COP 5621 and more Study notes Computer Science in PDF only on Docsity!

Concepts Introduced in Chapter 1

^ High-level introduction to compiling.

^ Phases ^ Compiler Construction Tools ^ Front Ends and Back Ends ^ Analysis-Synthesis Model ^ Assemblers ^ Linkers and Loaders

Translator

^ A translator is a program that reads a programwritten in a source language and translates it to anequivalent program written in a target language.

Knowledge Required for

Implementing a Successful Compiler^

Programming Languages Computer Architecture Formal Languages Algorithms Graph Theory Software Engineering

Other Applications Related to

Compilers

^ Compiler Relatives

^ Interpreters ^ Structure Editors ^ Pretty Printers ^ Static Checkers ^ Debuggers

^ Other Applications

^ Text Formatters ^ Silicon Compilers ^ Query Interpreters

Compiler Phases

Compiler Construction Tools

^ Front End (Analysis)

^ Scanner Generators: Lex ^ Parser Generators: Yacc ^ Syntax-Directed Translation Engines

^ Back End (Synthesis)

^ Automatic Code Generators ^ Peephole Optimizer Construction Tools

Front Ends and Back Ends

Analysis-Synthesis Model of

Compilation

^ Analysis Part

^ Breaks up the source program into pieces and createsan intermediate representation.

^ Synthesis Part

^ Constructs a target program from the intermediaterepresentation.

Intermediate Code Generation

^ After analysis, most compilers generate anintermediate representation of a program. ^ Properties

^ machine-independent ^ easy to translate to the target machine language

^ Can have a common intermediate language that isthe target of several front ends and is input toseveral back ends.

Code Optimization

^ Often performed on intermediate code. ^ Goals

^ Make program run faster. ^ Make program take up less space. ^ Make program use less power.

^ Should never change the semantic behavior of theprogram.

Code Generation

^ Produces assembly or object code from theintermediate representation. ^ Each intermediate operation is translated to anequivalent sequence of machine instructions. ^ Special features of the architecture are exploited.

Preprocessors

^ Perform some preliminary processing on a sourcemodule.

^ definitions and macros

^ #define

^ file inclusion

^ #include

^ conditional compilation

^ #ifdef

^ line numbering

^ #line

Assemblers

^ Typically accomplished in 2 passes.

^ Pass 1: Stores all of the identifiers representing tokensin a table. ^ Pass 2: Translates the instructions and data into bitsfor the machine code.

^ Produces relocatable code.

Linkers and Loaders

^ Linker

^ Produces an executable file. ^ Resolves external references. ^ Includes appropriate libraries.

^ Loader

^ Creates a process from the executable. ^ Loads the process (or a portion of it) into mainmemory. ^ Produces absolute machine code.