Skip to main content
Engineering LibreTexts

1.6: Intermediate steps

  • Page ID
    29010
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Intermediate Code Generator

    Most compilers translate a source program into an independent intermediate code, then the back end of the compiler uses this intermediate code to generate the target code specifically for the machine architecture and operating system that the code is being written for.

    The benefits of using machine independent intermediate code are:

    • Because of the machine independent intermediate code, portability will be enhanced.For ex, suppose, if a compiler translates the source language to its target machine language without having the option for generating intermediate code, then for each new machine, a full native compiler is required. Because, obviously, there were some modifications in the compiler itself according to the machine specifications.
    • It is easier to apply source code modification to improve the performance of source code by optimising the intermediate code.

    In a compiler that uses an intermediate language, there may be two instruction selection stages—one to convert the parse tree (that information that comes from the previous stages of the compiling process) into intermediate code, and a second phase much later to convert the intermediate code into instructions from the instruction set of the target machine. 

    Adapted from: "Intermediate Code Generation in Compiler Design" by Aaqib Bashir is licensed under CC BY-SA 4.0


    This page titled 1.6: Intermediate steps is shared under a CC BY-SA license and was authored, remixed, and/or curated by Patrick McClanahan.