Does a compiler always produce an assembly code?

后端 未结 4 1981
旧巷少年郎
旧巷少年郎 2020-11-27 08:37

From Thinking in C++ - Vol 1:

In the second pass, the code generator walks through the parse tree and generates either assembly lan

4条回答
  •  生来不讨喜
    2020-11-27 08:52

    The assembler stage can be justified by two reasons:

    • it allows c/c++ code to be translated to a machine independent abstract assembler, from which there exists easy conversions to a multitude of different instruction set architectures
    • it takes out the burden of validating correct opcode, prefix, r/m, etc. instruction encoding for CISC architectures, when one can utilize an existing software [component].

    The 1st edition of that book is from 2000, but is may as well talk about the early 90's, when c++ itself was translated to c and when the gnu/free software idea (including source code for compilers) was not really known.

    EDIT: One of several nonsensical abstract machine independent languages used by GCC is RTL -- Register Transfer Language.

提交回复
热议问题