diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt index 959d6260bc7490c76eb66f7fc5951fd368cbe775..ccb61a698f89271174a701f9391498b3d88784d0 100644 --- a/offload/CMakeLists.txt +++ b/offload/CMakeLists.txt @@ -200,6 +200,8 @@ set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} nvptx64-nvidia-cuda-L set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} nvptx64-nvidia-cuda-JIT-LTO") set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} s390x-ibm-linux-gnu") set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} s390x-ibm-linux-gnu-LTO") +set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} riscv64-unknown-linux-gnu") +set (LIBOMPTARGET_ALL_TARGETS "${LIBOMPTARGET_ALL_TARGETS} riscv64-unknown-linux-gnu-LTO") # Once the plugins for the different targets are validated, they will be added to # the list of supported targets in the current system. diff --git a/offload/plugins-nextgen/common/src/Utils/ELF.cpp b/offload/plugins-nextgen/common/src/Utils/ELF.cpp index 90d6950b83e5adc93812b352b8cdd66f990aa2fd..88642fd5b56400995c7e2b1ac95b508b8f9aa45e 100644 --- a/offload/plugins-nextgen/common/src/Utils/ELF.cpp +++ b/offload/plugins-nextgen/common/src/Utils/ELF.cpp @@ -45,6 +45,8 @@ uint16_t utils::elf::getTargetMachine() { return EM_AARCH64; #elif defined(__powerpc64__) return EM_PPC64; +#elif defined(__riscv) + return EM_RISCV; #else #warning "Unknown ELF compilation target architecture" return EM_NONE; diff --git a/offload/plugins-nextgen/host/CMakeLists.txt b/offload/plugins-nextgen/host/CMakeLists.txt index 817d128f924109cf74a125dad410f6058eb172a4..286bc51cc2a435ef55074ffbea777785e44baff8 100644 --- a/offload/plugins-nextgen/host/CMakeLists.txt +++ b/offload/plugins-nextgen/host/CMakeLists.txt @@ -1,4 +1,4 @@ -set(supported_targets x86_64 aarch64 ppc64 ppc64le s390x) +set(supported_targets x86_64 aarch64 ppc64 ppc64le riscv64 s390x) if(NOT ${CMAKE_SYSTEM_PROCESSOR} IN_LIST supported_targets) message(STATUS "Not building ${machine} NextGen offloading plugin") return() @@ -59,4 +59,8 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "s390x$") list(APPEND LIBOMPTARGET_SYSTEM_TARGETS "s390x-ibm-linux-gnu" "s390x-ibm-linux-gnu-LTO") set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}" PARENT_SCOPE) +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64$") + list(APPEND LIBOMPTARGET_SYSTEM_TARGETS + "riscv64-unknown-linux-gnu" "riscv64-unknown-linux-gnu-LTO") + set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS}" PARENT_SCOPE) endif() diff --git a/offload/plugins-nextgen/host/dynamic_ffi/ffi.h b/offload/plugins-nextgen/host/dynamic_ffi/ffi.h index 0ae025805e1d405379f9dfc7b430d8e7972f79f9..8b4e0286d65e3c84a4707325ec3aaefde5e5bb16 100644 --- a/offload/plugins-nextgen/host/dynamic_ffi/ffi.h +++ b/offload/plugins-nextgen/host/dynamic_ffi/ffi.h @@ -43,7 +43,8 @@ typedef enum { typedef enum ffi_abi { #if (defined(_M_X64) || defined(__x86_64__)) FFI_DEFAULT_ABI = 2, // FFI_UNIX64. -#elif defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) +#elif defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || \ + defined(__riscv) FFI_DEFAULT_ABI = 1, // FFI_SYSV. #elif defined(__powerpc64__) FFI_DEFAULT_ABI = 8, // FFI_LINUX. diff --git a/offload/plugins-nextgen/host/src/rtl.cpp b/offload/plugins-nextgen/host/src/rtl.cpp index fe296b77c7d55781bcffb6fc54ca5b1ad629a718..6f2e3d8604ec82d296198dbc19f2a102370510a1 100644 --- a/offload/plugins-nextgen/host/src/rtl.cpp +++ b/offload/plugins-nextgen/host/src/rtl.cpp @@ -440,6 +440,8 @@ struct GenELF64PluginTy final : public GenericPluginTy { #else return llvm::Triple::ppc64; #endif +#elif defined(__riscv) && (__riscv_xlen == 64) + return llvm::Triple::riscv64; #else return llvm::Triple::UnknownArch; #endif