NaplesPU Tools
A new backend for llvm needs to be added and registered. After registration, llvm tools are able to lookup and use the new target at runtime. In the following, we will show which files are involved in the registration phase and which changes are required.
CMakeLists.txt
This specifies the installation path that, in our case, is: "/usr/local/llvm-nuplus/".
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr/local/llvm-nuplus/" CACHE PATH "NuPlusLLVM install prefix" FORCE)
endif()
The target name should be added to the LLVM_ALL_TARGETS list
set(LLVM_ALL_TARGETS
AArch64
AMDGPU
ARM
BPF
Hexagon
Mips
MSP430
NVPTX
PowerPC
Sparc
SystemZ
X86
XCore
NuPlus
)
In a standard version of llvm, the LLVM_TARGETS_TO_BUILD variable is set to "all" in order to compile llvm with all the provided target backends. In out custom compiler, we set this variable to "NuPlus". In this way the compiler is compiled just targeting the NuPlus architecture.
set(LLVM_TARGETS_TO_BUILD "NuPlus" CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
Finally, we remove the possibility of targeting a different architecture then NuPlus.
set(LLVM_DEFAULT_TARGET_TRIPLE "nuplus-none-none" CACHE STRING "Default target for which LLVM will generate code." )