Intermediate Code Generation
. Abstraction at the source level
identifiers, operators, expressions, statements, conditionals, iteration, functions (user defined, system defined or libraries)
. Abstraction at the target level
memory locations, registers, stack, opcodes, addressing modes, system libraries, interface to the operating systems
. Code generation is a mapping from source level abstractions to target machine abstractions
After syntax and semantic analysis, some compilers generate an explicit intermediate representation of the source program. We can think of this IR as a program for an abstract machine. This IR should have two important properties: It should be easy to produce and it should be easy to translate into target program. IR should have the abstraction in between of the abstraction at the source level (identifiers, operators, expressions, statements, conditionals, iteration, functions (user defined, system defined or libraries)) and of the abstraction at the target level (memory locations, registers, stack, opcodes, addressing modes, system libraries and interface to the operating systems). Therefore IR is an intermediate stage of the mapping from source level abstractions to target machine abstractions.
|