Difference between revisions of "NaplesPU LLVM Documentation"
Line 4: | Line 4: | ||
Other than the general aspects about compilers, it is recommended to read about the [http://www.aosabook.org/en/llvm.html '''LLVM architecture'''], the [http://llvm.org/docs/LangRef.html '''LLVM Intermediate Representation'''] and [http://llvm.org/docs/TableGen/index.html '''Tablegen''']. See the following textbook for other informations [http://books.tarsoit.com/Getting%20Started%20with%20LLVM%20Core%20Libraries.pdf Getting Started with LLVM Core Libraries] and [https://github.com/iBreaker/book/blob/master/LLVM%20Cookbook.pdf LLVM Cookbook]. | Other than the general aspects about compilers, it is recommended to read about the [http://www.aosabook.org/en/llvm.html '''LLVM architecture'''], the [http://llvm.org/docs/LangRef.html '''LLVM Intermediate Representation'''] and [http://llvm.org/docs/TableGen/index.html '''Tablegen''']. See the following textbook for other informations [http://books.tarsoit.com/Getting%20Started%20with%20LLVM%20Core%20Libraries.pdf Getting Started with LLVM Core Libraries] and [https://github.com/iBreaker/book/blob/master/LLVM%20Cookbook.pdf LLVM Cookbook]. | ||
+ | |||
+ | See also [https://eli.thegreenplace.net/2012/11/24/life-of-an-instruction-in-llvm this article] to have an overview of the main CodeGenerator phases. | ||
The main task of the backend is to generate nu+ assembly code from the LLVM IR obtained by the Clang frontend. However the LLVM framework provides also base classes that can be used to create an assembler and a disassembler. | The main task of the backend is to generate nu+ assembly code from the LLVM IR obtained by the Clang frontend. However the LLVM framework provides also base classes that can be used to create an assembler and a disassembler. |
Revision as of 14:37, 17 October 2017
To fully understand some aspects of some solutions adopted in the nu+ backend, it is highly recommended to read about the general aspects of compiler structure and the LLVM architecture. In particular, a newbie must be aware of Basic Blocks, SSA (Static Single Assignment) form, AST (Abstract Syntax tree) and DAG Direct Acyclic Graph. Further informations can be retrieved from the dragonbook.
Other than the general aspects about compilers, it is recommended to read about the LLVM architecture, the LLVM Intermediate Representation and Tablegen. See the following textbook for other informations Getting Started with LLVM Core Libraries and LLVM Cookbook.
See also this article to have an overview of the main CodeGenerator phases.
The main task of the backend is to generate nu+ assembly code from the LLVM IR obtained by the Clang frontend. However the LLVM framework provides also base classes that can be used to create an assembler and a disassembler.
The nu+ backend is contained in the NuPlus folder under "compiler/lib/Target" directory. It contains several files each of which implements a specific class of the LLVM Framework, some of which are tablegen files while others are C++ classes.
Tablegen files
These files describe, through the Tablegen description language, the target architecture like the register file, the instruction set and the calling conventions.
The files implemented in the nu+ backend are:
- NuPlus.td, used to describe a target and to instruct LLVM about the names of the classes used for each of the framework component.
- NuPlusRegisterInfo.td, contains the definition of the nu+ register file.
- NuPlusCallingConv.td, used to define the calling conventions to use when a function is called.
- NuPlusInstrFormats.td and NuPlusInstrInfo.td, define the instructions supported by the nu+ architecture and the pattern LLVM must use to translate the LLVM IR in nu+ asm.
C++ classes implementation
- NuPlusFrameLowering
- NuPlusInstrInfo
- NuPlusISelDAGToDAG
- NuPlusTargetLowering
- NuPlusMachineFunctionInfo
- NuPlusMCInstLower
- NuPlusRegisterInfo
- NuPlusTargetMachine
- NuPlusSubtarget
- NuPlusTargetObjectFile
in MCTargetDesc
- NuPlusAsmBackend
- NuPlusELFObjectWriter
- NuPlusMCAsmInfo
- NuPlusMCCodeEmitter
- NuPlusMCTargetDesc
- NuPlusFixupKinds
in InstPrinter
in Disassembler
in AsmParser