build: LLVM: Add Flang compiler support and enable OpenMP for Clang
[platform/upstream/openblas.git] / common_zarch.h
1 /*****************************************************************************
2 Copyright (c) 2011-2016, The OpenBLAS Project
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are
7 met:
8
9    1. Redistributions of source code must retain the above copyright
10       notice, this list of conditions and the following disclaimer.
11
12    2. Redistributions in binary form must reproduce the above copyright
13       notice, this list of conditions and the following disclaimer in
14       the documentation and/or other materials provided with the
15       distribution.
16    3. Neither the name of the OpenBLAS project nor the names of 
17       its contributors may be used to endorse or promote products 
18       derived from this software without specific prior written 
19       permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
30 USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 **********************************************************************************/
32
33 #ifndef COMMON_ZARCH
34 #define COMMON_ZARCH
35
36 #define MB   
37 //__asm__ __volatile__ ("dmb  ish" : : : "memory")
38 #define WMB  
39 //__asm__ __volatile__ ("dmb  ishst" : : : "memory")
40
41
42 #define INLINE inline
43
44 #define RETURN_BY_COMPLEX
45
46 #ifndef ASSEMBLER
47
48   /*
49 static void __inline blas_lock(volatile BLASULONG *address){
50
51   BLASULONG ret;
52
53   do {
54     while (*address) {YIELDING;};
55
56     __asm__ __volatile__(
57                          "mov   x4, #1                                                  \n\t"
58                          "1:                                                            \n\t"
59                          "ldaxr x2, [%1]                                                \n\t"
60                          "cbnz  x2, 1b                                                  \n\t"
61                          "2:                                                            \n\t"
62                          "stxr  w3, x4, [%1]                                            \n\t"
63                          "cbnz  w3, 1b                                                  \n\t"
64                          "mov   %0, #0                                                  \n\t"
65                          : "=r"(ret), "=r"(address)
66                          : "1"(address)
67                          : "memory", "x2" , "x3", "x4"
68
69
70     );
71
72
73   } while (ret);
74
75 }
76   */
77 //#define BLAS_LOCK_DEFINED
78
79
80
81 static inline int blas_quickdivide(blasint x, blasint y){
82   return x / y;
83 }
84
85 #if defined(DOUBLE)
86 #define GET_IMAGE(res)  __asm__ __volatile__("str d1, %0" : "=m"(res) : : "memory")
87 #else
88 #define GET_IMAGE(res)  __asm__ __volatile__("str s1, %0" : "=m"(res) : : "memory")
89 #endif
90
91 #define GET_IMAGE_CANCEL
92
93 #endif
94
95
96 #ifndef F_INTERFACE
97 #define REALNAME ASMNAME
98 #else
99 #define REALNAME ASMFNAME
100 #endif
101
102 #if defined(ASSEMBLER) && !defined(NEEDPARAM)
103
104 #define PROLOGUE \
105         .text ;\
106         .align  256 ;\
107         .global REALNAME ;\
108         .type   REALNAME, %function ;\
109 REALNAME:
110  
111
112 #define EPILOGUE
113
114 #define PROFCODE
115
116 #endif
117
118
119 #define SEEK_ADDRESS
120
121 #ifndef PAGESIZE
122 #define PAGESIZE        ( 4 << 10)
123 #endif
124 #define HUGE_PAGESIZE   ( 4 << 20)
125
126 #if defined(CORTEXA57)
127 #define BUFFER_SIZE     (20 << 20)
128 #else
129 #define BUFFER_SIZE     (16 << 20)
130 #endif
131
132
133 #define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)
134
135 #ifndef MAP_ANONYMOUS
136 #define MAP_ANONYMOUS MAP_ANON
137 #endif
138
139 #endif
140