build: LLVM: Add Flang compiler support and enable OpenMP for Clang
[platform/upstream/openblas.git] / common_x86.h
index 0cb242c..4363fb2 100644 (file)
 
 #ifndef ASSEMBLER
 
+#ifdef C_MSVC
+#include <intrin.h>
+#endif
+
 #define MB
 #define WMB
 
@@ -58,7 +62,7 @@ static void __inline blas_lock(volatile BLASULONG *address){
 
 #if defined(_MSC_VER) && !defined(__clang__)
        // use intrinsic instead of inline assembly
-       ret = _InterlockedExchange(address, 1);
+       ret = _InterlockedExchange((volatile LONG *)address, 1);
        // inline assembly
        /*__asm {
                mov eax, address
@@ -77,6 +81,7 @@ static void __inline blas_lock(volatile BLASULONG *address){
   } while (ret);
 
 }
+#define BLAS_LOCK_DEFINED
 
 static __inline unsigned long long rpcc(void){
 #if defined(_MSC_VER) && !defined(__clang__)
@@ -89,6 +94,7 @@ static __inline unsigned long long rpcc(void){
   return ((unsigned long long)a + ((unsigned long long)d << 32));
 #endif
 };
+#define RPCC_DEFINED
 
 static __inline unsigned long getstackaddr(void){
 #if defined(_MSC_VER) && !defined(__clang__)
@@ -168,12 +174,13 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){
 
   if (y <= 1) return x;
 
-  y = blas_quick_divide_table[y];
-
 #if defined(_MSC_VER) && !defined(__clang__)
-  (void*)result;
-  return x*y;
+  result = x/y;
+  return result;
 #else
+
+  y = blas_quick_divide_table[y];
+
   __asm__ __volatile__  ("mull %0" :"=d" (result) :"a"(x), "0" (y));
 
   return result;
@@ -200,7 +207,7 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){
 #define MMXSTORE       movd
 #endif
 
-#if defined(PILEDRIVER) || defined(BULLDOZER) || defined(STEAMROLLER)
+#if defined(PILEDRIVER) || defined(BULLDOZER) || defined(STEAMROLLER) || defined(EXCAVATOR)
 //Enable some optimazation for barcelona.
 #define BARCELONA_OPTIMIZATION
 #endif
@@ -313,8 +320,12 @@ REALNAME:
 
 #define PROFCODE
 
+#ifdef __clang__
+#define EPILOGUE .end
+#else
 #define EPILOGUE .end   REALNAME
 #endif
+#endif
 
 #if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_NETBSD) || defined(__ELF__)
 #define PROLOGUE \