How to create a C compiler for custom CPU?

前端 未结 6 1436
长发绾君心
长发绾君心 2021-01-31 08:16

What would be the easiest way to create a C compiler for a custom CPU, assuming of course I already have an assembler for it?

Since a C compiler generates assembly, is t

6条回答
  •  长发绾君心
    2021-01-31 08:23

    Quick overview/tutorial on writing a LLVM backend.

    This document describes techniques for writing backends for LLVM which convert the LLVM representation to machine assembly code or other languages.

    [ . . . ]

    To create a static compiler (one that emits text assembly), you need to implement the following:

    • Describe the register set.
    • Describe the instruction set.
    • Describe the target machine.
    • Implement the assembly printer for the architecture.
    • Implement an instruction selector for the architecture.

提交回复
热议问题