Difference between revisions of "NaplesPU Tools"

From NaplesPU Documentation
Jump to: navigation, search
(Created page with "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 w...")
 
Line 1: Line 1:
 
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.  
 
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.
+
In the following, we will show which files are involved in the registration phase and which changes are required.  
  
== CMakeLists.txt ==
+
==== CMakeLists.txt ====
 
+
This specifies the installation path that, in our case, is: "/usr/local/llvm-nuplus/".
<syntaxhighlight lang="cpp" line='line'>
+
<syntaxhighlight lang="java" line='line'>
 
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
 
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
 
set(CMAKE_INSTALL_PREFIX "/usr/local/llvm-nuplus/" CACHE PATH "NuPlusLLVM install prefix" FORCE)
 
set(CMAKE_INSTALL_PREFIX "/usr/local/llvm-nuplus/" CACHE PATH "NuPlusLLVM install prefix" FORCE)
 
endif()
 
endif()
 +
</syntaxhighlight>
 +
 +
The target name should be added to the LLVM_ALL_TARGETS list
 +
<syntaxhighlight lang="java" line='line'>
 +
set(LLVM_ALL_TARGETS
 +
  AArch64
 +
  AMDGPU
 +
  ARM
 +
  BPF
 +
  Hexagon
 +
  Mips
 +
  MSP430
 +
  NVPTX
 +
  PowerPC
 +
  Sparc
 +
  SystemZ
 +
  X86
 +
  XCore
 +
  NuPlus
 +
  )
 +
</syntaxhighlight>
 +
 +
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.
 +
<syntaxhighlight lang="java" line='line'>
 +
set(LLVM_TARGETS_TO_BUILD "NuPlus" CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
 +
</syntaxhighlight>
 +
 +
Finally, we remove the possibility of targeting a different architecture then NuPlus.
 +
<syntaxhighlight lang="java" line='line'>
 +
set(LLVM_DEFAULT_TARGET_TRIPLE "nuplus-none-none" CACHE STRING "Default target for which LLVM will generate code." )
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 15:25, 12 September 2017

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." )