- A compiler is simply a computer program that translates other computer programs to prepare them for execution. the output program is expressed in the operations available on some specific processor,
- A compiler often includes an optimizer that analyzes and rewrites that intermediate form.
- Compilers that target programming languages rather than the instruction set of a computer are often called source-to-source translators.
- A virtual machine is a simulator for some processor. It is an interpreter for that machine’s instruction set.
- Interpreters and compilers have much in common
- Both analyze the input program and determine whether or not itis a valid program.
- Both build an internal model of the structure and mean-ing of the program.
- Both determine where to store values during execution.’
- However, interpreting the code to produce a result is quite different from emitting a translated program that can be executed to produce the result.
- A good compiler contains a microcosm of computer science.
- It makes practical use of greedy algorithms (register allocation),
- heuristic search techniques(list scheduling),
- graph algorithms (dead-code elimination), dynamic programming (instruction selection),
- finite automata and push-down automata(scanning and parsing),
- and fixed-point algorithms (data-flow analysis).
- It deals with problems such as dynamic allocation, synchronization, naming, locality, memory hierarchy management,and pipeline scheduling.
- The Fundamental Principles of Compilation
- The compiler must preserve the meaning of the program being compiled.
- The compiler must improve the input program in some discernible way.