Page 20 - ARM 64 Bit Assembly Language
P. 20

Introduction 3


































                                        Figure 1.2: Stages of a typical compilation sequence.


                     One example where knowledge of assembly is indispensable is when designing and imple-
                     menting compilers for high-level languages. As shown in Fig. 1.2, a typical compiler for a
                     high level language must generate assembly language as its output. Most compilers are de-
                     signed to have multiple stages. In the input stage, the source language is read and converted
                     into a graph representation. The graph may be optimized before being passed to the output,
                     or code generation, stage where it is converted to assembly language. The assembly is then
                     fed into the system’s assembler to generate an object file. The object file is linked with other
                     object files (which are often combined into libraries) to create an executable program.
                     The code generation stage of a compiler must traverse the graph and emit assembly code.
                     The quality of the assembly code that is generated can have a profound influence on the per-
                     formance of the executable program. Therefore, the programmer responsible for the code
                     generation portion of the compiler must be well-versed in assembly programming for the tar-
                     get CPU.

                     Some people believe that a good optimizing compiler will generate better assembly code than
                     a human programmer. This belief is not justified. Highly optimizing compilers have lots of
                     clever algorithms, but like all programs, they are not perfect. Outside of the cases that they
   15   16   17   18   19   20   21   22   23   24   25