Skip to content

Commit b6bd747

Browse files
authored
[Offload] Add support for riscv64 to host plugin (#115773)
This adds support for the riscv64 architecture to the offload host plugin. The check to define FFI_DEFAULT_ABI is intentionally not guarded by __riscv_xlen as the value is the same for riscv32 and riscv64 (support for OpenMP on riscv32 is still under review).
1 parent b63b010 commit b6bd747

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

offload/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} nvptx64-nvidia-cuda-L
199199
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} nvptx64-nvidia-cuda-JIT-LTO")
200200
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} s390x-ibm-linux-gnu")
201201
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} s390x-ibm-linux-gnu-LTO")
202+
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} riscv64-unknown-linux-gnu")
203+
set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} riscv64-unknown-linux-gnu-LTO")
202204

203205
# Once the plugins for the different targets are validated, they will be added to
204206
# the list of supported targets in the current system.

offload/plugins-nextgen/common/src/Utils/ELF.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ uint16_t utils::elf::getTargetMachine() {
4545
return EM_AARCH64;
4646
#elif defined(__powerpc64__)
4747
return EM_PPC64;
48+
#elif defined(__riscv)
49+
return EM_RISCV;
4850
#else
4951
#warning "Unknown ELF compilation target architecture"
5052
return EM_NONE;

offload/plugins-nextgen/host/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(supported_targets x86_64 aarch64 ppc64 ppc64le s390x)
1+
set(supported_targets x86_64 aarch64 ppc64 ppc64le riscv64 s390x)
22
if(NOT ${CMAKE_SYSTEM_PROCESSOR} IN_LIST supported_targets)
33
message(STATUS "Not building ${machine} NextGen offloading plugin")
44
return()
@@ -59,4 +59,8 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "s390x$")
5959
list(APPEND LIBOMPTARGET_SYSTEM_TARGETS
6060
"s390x-ibm-linux-gnu" "s390x-ibm-linux-gnu-LTO")
6161
set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}" PARENT_SCOPE)
62+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64$")
63+
list(APPEND LIBOMPTARGET_SYSTEM_TARGETS
64+
"riscv64-unknown-linux-gnu" "riscv64-unknown-linux-gnu-LTO")
65+
set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}" PARENT_SCOPE)
6266
endif()

offload/plugins-nextgen/host/dynamic_ffi/ffi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ typedef enum {
4343
typedef enum ffi_abi {
4444
#if (defined(_M_X64) || defined(__x86_64__))
4545
FFI_DEFAULT_ABI = 2, // FFI_UNIX64.
46-
#elif defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64)
46+
#elif defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || \
47+
defined(__riscv)
4748
FFI_DEFAULT_ABI = 1, // FFI_SYSV.
4849
#elif defined(__powerpc64__)
4950
FFI_DEFAULT_ABI = 8, // FFI_LINUX.

offload/plugins-nextgen/host/src/rtl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ struct GenELF64PluginTy final : public GenericPluginTy {
440440
#else
441441
return llvm::Triple::ppc64;
442442
#endif
443+
#elif defined(__riscv) && (__riscv_xlen == 64)
444+
return llvm::Triple::riscv64;
443445
#else
444446
return llvm::Triple::UnknownArch;
445447
#endif

0 commit comments

Comments
 (0)