From 00efdc1cd6f3140efcefb1b6f9de86371d15dbba Mon Sep 17 00:00:00 2001 From: Jeremy Newton Date: Wed, 6 Apr 2022 11:07:35 -0400 Subject: [PATCH] SWDEV-323669 - Improve arch detection - Clean up detection by using visual studio macros to detect arch; I didn't list all possible ARM platforms (can be done later if desired) - Fixed two incorrect uses of !defined(ATI_ARCH_ARM) to instead use defined(ATI_ARCH_X86), as they contain X86 specific code - Fixed one use of __ARM_ARCH_7A__ to use ATI_ARCH_ARM instead This is an improvement to the fixes in the last patch for SWDEV-323669 Signed-off-by: Jeremy Newton Change-Id: I8568167293c34ad5331902105877f3ab6e25acb3 --- rocclr/include/top.hpp | 12 ++++-------- rocclr/os/os.cpp | 2 +- rocclr/os/os_posix.cpp | 6 +++--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/rocclr/include/top.hpp b/rocclr/include/top.hpp index 70273510c9..d6aa00c8d3 100644 --- a/rocclr/include/top.hpp +++ b/rocclr/include/top.hpp @@ -21,15 +21,11 @@ #ifndef TOP_HPP_ #define TOP_HPP_ -#if defined(__GNUC__) -#if defined(__arm__) || defined(__aarch64__) +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__arm) || defined(__arm__) || defined(_M_ARM) || defined(__aarch64__) || defined(_M_ARM64) #define ATI_ARCH_ARM -#elif defined(__x86__) || defined(__x86_64__) +#elif defined(i386) || defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__x86__) || defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(__amd64__) || defined(_M_X64) || defined(_M_AMD64) #define ATI_ARCH_X86 #endif -#else /*!__GNUC__*/ -#define ATI_ARCH_X86 -#endif /*!__GNUC__*/ #if defined(ATI_ARCH_ARM) #define __EXPORTED_HEADERS__ 1 @@ -51,9 +47,9 @@ #define CL_DEVICE_HOST_UNIFIED_MEMORY 0x1035 #endif -#if !defined(ATI_ARCH_ARM) +#if defined(ATI_ARCH_X86) #include -#endif /*!ATI_ARCH_ARM*/ +#endif /*ATI_ARCH_X86*/ #include #include diff --git a/rocclr/os/os.cpp b/rocclr/os/os.cpp index f5ea547ddf..0437f7f1d6 100644 --- a/rocclr/os/os.cpp +++ b/rocclr/os/os.cpp @@ -112,7 +112,7 @@ int Os::processorCount_ = 0; void Os::spinPause() { #if defined(ATI_ARCH_X86) _mm_pause(); -#elif defined(__ARM_ARCH_7A__) +#elif defined(ATI_ARCH_ARM) __asm__ __volatile__("yield"); #endif } diff --git a/rocclr/os/os_posix.cpp b/rocclr/os/os_posix.cpp index dd1e61fccf..aa43a7730b 100644 --- a/rocclr/os/os_posix.cpp +++ b/rocclr/os/os_posix.cpp @@ -701,14 +701,14 @@ void Os::setCurrentStackPtr(address sp) { sp -= sizeof(void*); *(void**)sp = __builtin_return_address(0); -#if defined(ATI_ARCH_ARM) - assert(!"Unimplemented"); -#else +#if defined(ATI_ARCH_X86) __asm__ __volatile__( #if !defined(OMIT_FRAME_POINTER) LP64_SWITCH("movl (%%ebp),%%ebp;", "movq (%%rbp),%%rbp;") #endif // !OMIT_FRAME_POINTER LP64_SWITCH("movl %0,%%esp; ret;", "movq %0,%%rsp; ret;")::"r"(sp)); +#else + assert(!"Unimplemented"); #endif }