fix build error
[platform/upstream/openblas.git] / common_alpha.h
1 /*********************************************************************/
2 /* Copyright 2009, 2010 The University of Texas at Austin.           */
3 /* All rights reserved.                                              */
4 /*                                                                   */
5 /* Redistribution and use in source and binary forms, with or        */
6 /* without modification, are permitted provided that the following   */
7 /* conditions are met:                                               */
8 /*                                                                   */
9 /*   1. Redistributions of source code must retain the above         */
10 /*      copyright notice, this list of conditions and the following  */
11 /*      disclaimer.                                                  */
12 /*                                                                   */
13 /*   2. Redistributions in binary form must reproduce the above      */
14 /*      copyright notice, this list of conditions and the following  */
15 /*      disclaimer in the documentation and/or other materials       */
16 /*      provided with the distribution.                              */
17 /*                                                                   */
18 /*    THIS  SOFTWARE IS PROVIDED  BY THE  UNIVERSITY OF  TEXAS AT    */
19 /*    AUSTIN  ``AS IS''  AND ANY  EXPRESS OR  IMPLIED WARRANTIES,    */
20 /*    INCLUDING, BUT  NOT LIMITED  TO, THE IMPLIED  WARRANTIES OF    */
21 /*    MERCHANTABILITY  AND FITNESS FOR  A PARTICULAR  PURPOSE ARE    */
22 /*    DISCLAIMED.  IN  NO EVENT SHALL THE UNIVERSITY  OF TEXAS AT    */
23 /*    AUSTIN OR CONTRIBUTORS BE  LIABLE FOR ANY DIRECT, INDIRECT,    */
24 /*    INCIDENTAL,  SPECIAL, EXEMPLARY,  OR  CONSEQUENTIAL DAMAGES    */
25 /*    (INCLUDING, BUT  NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE    */
26 /*    GOODS  OR  SERVICES; LOSS  OF  USE,  DATA,  OR PROFITS;  OR    */
27 /*    BUSINESS INTERRUPTION) HOWEVER CAUSED  AND ON ANY THEORY OF    */
28 /*    LIABILITY, WHETHER  IN CONTRACT, STRICT  LIABILITY, OR TORT    */
29 /*    (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY WAY OUT    */
30 /*    OF  THE  USE OF  THIS  SOFTWARE,  EVEN  IF ADVISED  OF  THE    */
31 /*    POSSIBILITY OF SUCH DAMAGE.                                    */
32 /*                                                                   */
33 /* The views and conclusions contained in the software and           */
34 /* documentation are those of the authors and should not be          */
35 /* interpreted as representing official policies, either expressed   */
36 /* or implied, of The University of Texas at Austin.                 */
37 /*********************************************************************/
38
39 #ifndef COMMON_ALPHA
40 #define COMMON_ALPHA
41
42 #ifndef ASSEMBLER
43
44 #define MB  asm("mb")
45 #define WMB asm("wmb")
46
47 static void __inline blas_lock(unsigned long *address){
48 #ifndef __DECC
49   unsigned long tmp1, tmp2;
50   asm volatile(
51     "1: ldq     %1,  %0\n"
52     "   bne     %1,  2f\n"
53     "   ldq_l   %1,  %0\n"
54     "   bne     %1,  2f\n"
55     "   or      %1,  1, %2\n"
56     "   stq_c   %2,  %0\n"
57     "   beq     %2,  2f\n"
58     "   mb\n              "
59     "   br      $31, 3f\n"
60     "2: br      $31, 1b\n"
61     "3:\n" : "=m"(*address), "=&r"(tmp1), "=&r"(tmp2) : :  "memory");
62 #else
63   asm (
64     "10:"
65     "   ldq     %t0,  0(%a0); "
66     "   bne     %t0, 20f;     "
67     "   ldq_l   %t0,  0(%a0); "
68     "   bne     %t0, 20f;     "
69     "   or      %t0, 1, %t1;"
70     "   stq_c   %t1,  0(%a0); "
71     "   beq     %t1, 20f;     "
72     "   mb;                   "
73     "   br      %r31,30f;     "
74     "20:                      "
75     "   br      %r31,10b;     "
76     "30:", address);
77 #endif
78 }
79 #define BLAS_LOCK_DEFINED
80
81 static __inline unsigned int rpcc(void){
82
83   unsigned int r0;
84
85 #ifndef __DECC
86   asm __volatile__("rpcc %0" : "=r"(r0)  : : "memory");
87 #else
88   r0 = asm("rpcc %v0");
89 #endif
90
91   return r0;
92 }
93 #define RPCC_DEFINED
94
95
96 #define HALT    ldq     $0, 0($0)
97
98 #ifndef __DECC
99 #define GET_IMAGE(res)  asm __volatile__("fmov $f1, %0" : "=f"(res)  : : "memory")
100 #else
101 #define GET_IMAGE(res) res = dasm("fmov $f1, %f0")
102 #endif
103
104 #ifdef SMP
105 #ifdef USE64BITINT
106 static __inline long blas_quickdivide(long x, long y){
107   return x/y;
108 }
109 #else
110 extern unsigned int blas_quick_divide_table[];
111
112 static __inline int blas_quickdivide(unsigned int x, unsigned int y){
113   if (y <= 1) return x;
114   return (int)((x * (unsigned long)blas_quick_divide_table[y]) >> 32);
115 }
116 #endif
117 #endif
118
119 #define BASE_ADDRESS ((0x1b0UL << 33) | (0x1c0UL << 23) | (0x000UL << 13))
120
121 #ifndef PAGESIZE
122 #define PAGESIZE        ( 8UL << 10)
123 #define HUGE_PAGESIZE   ( 4 << 20)
124 #endif
125 #define BUFFER_SIZE     (32UL << 20)
126
127 #else
128
129 #ifndef F_INTERFACE
130 #define REALNAME ASMNAME
131 #else
132 #define REALNAME ASMFNAME
133 #endif
134
135 #define PROLOGUE \
136         .arch ev6; \
137         .set noat; \
138         .set noreorder; \
139 .text; \
140         .align 5; \
141         .globl REALNAME; \
142         .ent REALNAME; \
143 REALNAME:
144
145 #ifdef PROFILE
146 #define PROFCODE \
147         ldgp    $gp, 0($27); \
148         lda     $28, _mcount; \
149         jsr     $28, ($28), _mcount; \
150         .prologue 1
151 #else
152 #define PROFCODE .prologue 0
153 #endif
154
155 #if defined(__linux__) && defined(__ELF__)
156 #define GNUSTACK .section .note.GNU-stack,"",@progbits
157 #else
158 #define GNUSTACK
159 #endif
160
161 #define EPILOGUE \
162         .end REALNAME; \
163         .ident VERSION; \
164         GNUSTACK
165
166 #endif
167
168 #ifdef DOUBLE
169 #define SXADDQ  s8addq
170 #define SXSUBL  s8subl
171 #define LD      ldt
172 #define ST      stt
173 #define STQ     stq
174 #define ADD     addt/su
175 #define SUB     subt/su
176 #define MUL     mult/su
177 #define DIV     divt/su
178 #else
179 #define SXADDQ  s4addq
180 #define SXSUBL  s4subl
181 #define LD      lds
182 #define ST      sts
183 #define STQ     stl
184 #define ADD     adds/su
185 #define SUB     subs/su
186 #define MUL     muls/su
187 #define DIV     divs/su
188 #endif
189 #endif