Maps character stream into words: the basic unit of syntax
Produce pairs: a word and its part of speech (the pair is called a token)
becomes
Parser
Recognizes context-free syntax & reports errors
Backend
Instruction Selector
Produce fast, compact code
Take advantage of target features such as addressing modes
Usually viewed as a pattern matching problem
Register Allocation
Have each value in a register when it is used
Manage a limited set of resources
Can change instruction choices & insert LOADs & STOREs
Optimal allocation is NP-Complete
Instruction Scheduling
Avoid hardware stalls and interlocks.
Use all functional units productively
Can increase lifetime of variables
Traditional Three-Pass Compiler
900
⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: 'Decompress current Excalidraw file'. For more info check in plugin settings under 'Saving'
Excalidraw Data
Text Elements
Frontend
Middle End
Back End
IR
IR
Source
Code
Machine
Code
Errors
The Optimizer (or Middle End)
900
⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠ You can decompress Drawing data with the command palette: 'Decompress current Excalidraw file'. For more info check in plugin settings under 'Saving'