aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Huber <huberjn@outlook.com>2024-01-08 13:23:38 -0600
committerGitHub <noreply@github.com>2024-01-08 13:23:38 -0600
commite7655ad605d77e206ec94b2cef59c41a508edba7 (patch)
tree573b87f4805d605ea14298e748ad63453ddaa08a
parentdaa4728deed3d222ff163cfb963321938549ddf1 (diff)
downloadllvm-e7655ad605d77e206ec94b2cef59c41a508edba7.zip
llvm-e7655ad605d77e206ec94b2cef59c41a508edba7.tar.gz
llvm-e7655ad605d77e206ec94b2cef59c41a508edba7.tar.bz2
[Libomptarget] Remove unnecessary CMake definition of endiannness (#77205)
Summary: This is needed for some definition in `hsa.h` that requires this to be set for some architectures when it fails at autodetection. We only really build `libomptarget` with `gcc` and `clang` which already provide their own way of detecting this. Remove the unnecessary define and move it into the source.
-rw-r--r--openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt8
-rw-r--r--openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp12
2 files changed, 12 insertions, 8 deletions
diff --git a/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt b/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt
index bbf8c0a..68ce634 100644
--- a/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt
+++ b/openmp/libomptarget/plugins-nextgen/amdgpu/CMakeLists.txt
@@ -35,14 +35,6 @@ add_definitions(-DTARGET_NAME=AMDGPU)
# requires changing the original plugins.
add_definitions(-DDEBUG_PREFIX="TARGET AMDGPU RTL")
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "(ppc64le)|(aarch64)$")
- add_definitions(-DLITTLEENDIAN_CPU=1)
-endif()
-
-if(CMAKE_BUILD_TYPE MATCHES Debug)
- add_definitions(-DDEBUG)
-endif()
-
set(LIBOMPTARGET_DLOPEN_LIBHSA OFF)
option(LIBOMPTARGET_FORCE_DLOPEN_LIBHSA "Build with dlopened libhsa" ${LIBOMPTARGET_DLOPEN_LIBHSA})
diff --git a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
index 18076f8..b67642e 100644
--- a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
@@ -43,6 +43,18 @@
#include "llvm/Support/Program.h"
#include "llvm/Support/raw_ostream.h"
+#if !defined(__BYTE_ORDER__) || !defined(__ORDER_LITTLE_ENDIAN__) || \
+ !defined(__ORDER_BIG_ENDIAN__)
+#error "Missing preprocessor definitions for endianness detection."
+#endif
+
+// The HSA headers require these definitions.
+#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+#define LITTLEENDIAN_CPU
+#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+#define BIGENDIAN_CPU
+#endif
+
#if defined(__has_include)
#if __has_include("hsa/hsa.h")
#include "hsa/hsa.h"