Merge pull request #876 from wernsaar/develop
[platform/upstream/openblas.git] / common_power.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_POWER
40 #define COMMON_POWER
41
42 #if defined(POWER8)
43 #define MB              __asm__ __volatile__ ("eieio":::"memory")
44 #define WMB             __asm__ __volatile__ ("eieio":::"memory")
45 #else
46 #define MB              __asm__ __volatile__ ("sync")
47 #define WMB             __asm__ __volatile__ ("sync")
48 #endif
49
50 #define INLINE inline
51
52 #ifdef PPC440
53 #define STDERR stdout
54 #define QNONCACHE 0x1
55 #define QCOMMS    0x2
56 #define QFAST     0x4
57 #endif
58
59 #ifndef ASSEMBLER
60
61 void *qalloc(int flags, size_t bytes);
62
63 static void INLINE blas_lock(volatile unsigned long *address){
64
65   long int ret, val = 1;
66
67   do {
68     while (*address) {YIELDING;};
69
70 #if defined(OS_LINUX) || defined(OS_DARWIN)
71   __asm__ __volatile__ (
72            "0:  lwarx %0, 0, %1\n"
73            "    cmpwi %0, 0\n"
74            "    bne- 1f\n"
75            "    stwcx. %2,0, %1\n"
76            "    bne- 0b\n"
77            "1:    "
78         : "=&r"(ret)
79         : "r"(address), "r" (val)
80         : "cr0", "memory");
81 #else
82   __asm__ __volatile__ (
83            ".machine \"any\"\n"
84            "    lwarx %0, 0, %1\n"
85            "    cmpwi  %0, 0\n"
86            "    bne-  $+12\n"
87            "    stwcx. %2,0, %1\n"
88            "    bne-  $-16\n"
89         : "=&r"(ret)
90         : "r"(address), "r" (val)
91         : "cr0", "memory");
92 #endif
93   } while (ret);
94 }
95 #define BLAS_LOCK_DEFINED
96
97 static inline unsigned long rpcc(void){
98   unsigned long ret;
99
100 #ifdef OS_AIX
101   __asm__ __volatile__(".machine \"any\" ;");
102 #endif
103   __asm__ __volatile__ ("mftb %0" : "=r" (ret) : );
104
105 #if defined(POWER5) || defined(PPC970)
106   return (ret << 6);
107 #else
108   return (ret << 3);
109 #endif
110
111 }
112 #define RPCC_DEFINED
113
114 #ifdef __64BIT__
115 #define RPCC64BIT
116 #endif
117
118 static inline unsigned long getstackaddr(void){
119   unsigned long addr;
120
121   __asm__ __volatile__ ("mr %0, 1"
122                          : "=r"(addr) : : "memory");
123
124   return addr;
125 };
126
127 #if defined(OS_LINUX) || defined(OS_AIX)
128 #define GET_IMAGE(res)  __asm__ __volatile__("fmr %0, 2" : "=f"(res)  : : "memory")
129 #else
130 #define GET_IMAGE(res)  __asm__ __volatile__("fmr %0, f2" : "=f"(res)  : : "memory")
131
132 #define GET_IMAGE_CANCEL
133
134 #endif
135
136 #ifdef SMP
137 static inline int blas_quickdivide(blasint x, blasint y){
138   return x / y;
139 }
140 #endif
141
142 #endif
143
144
145 #ifdef ASSEMBLER
146
147 #ifdef DOUBLE
148 #define LFD     lfd
149 #define LFDX    lfdx
150 #define LFPDX   lfpdx
151 #define LFSDX   lfsdx
152 #define LFXDX   lfxdx
153 #define LFDU    lfdu
154 #define LFDUX   lfdux
155 #define LFPDUX  lfpdux
156 #define LFSDUX  lfsdux
157 #define LFXDUX  lfxdux
158 #define STFD    stfd
159 #define STFDX   stfdx
160 #define STFPDX  stfpdx
161 #define STFSDX  stfsdx
162 #define STFXDX  stfxdx
163 #define STFDU   stfdu
164 #define STFDUX  stfdux
165 #define STFPDUX stfpdux
166 #define STFSDUX stfsdux
167 #define STFXDUX stfxdux
168 #define FMADD   fmadd
169 #define FMSUB   fmsub
170 #define FNMADD  fnmadd
171 #define FNMSUB  fnmsub
172 #define FMUL    fmul
173 #define FADD    fadd
174 #define FSUB    fsub
175 #else
176 #define LFD     lfs
177 #define LFDX    lfsx
178 #define LFPDX   lfpsx
179 #define LFSDX   lfssx
180 #define LFXDX   lfxsx
181 #define LFDU    lfsu
182 #define LFDUX   lfsux
183 #define LFPDUX  lfpsux
184 #define LFSDUX  lfssux
185 #define LFXDUX  lfxsux
186 #define STFD    stfs
187 #define STFDX   stfsx
188 #define STFPDX  stfpsx
189 #define STFSDX  stfssx
190 #define STFXDX  stfxsx
191 #define STFDU   stfsu
192 #define STFDUX  stfsux
193 #define STFPDUX stfpsux
194 #define STFSDUX stfssux
195 #define STFXDUX stfxsux
196 #define FMADD   fmadds
197 #define FMSUB   fmsubs
198 #define FNMADD  fnmadds
199 #define FNMSUB  fnmsubs
200 #define FMUL    fmuls
201 #define FADD    fadds
202 #define FSUB    fsubs
203 #endif
204
205 #ifdef __64BIT__
206 #define LDLONG  ld
207 #else
208 #define LDLONG  lwz
209 #endif
210
211 #ifdef OS_DARWIN
212 #define LL(x)   L##x
213 #endif
214
215 #ifdef OS_LINUX
216 #define LL(x)   .L##x
217 #endif
218
219 #ifndef LL
220 #define LL(x)   __L##x
221 #endif
222
223
224 #if   defined(__64BIT__) &&  defined(USE64BITINT)
225 #define LDINT   ld
226 #elif defined(__64BIT__) && !defined(USE64BITINT)
227 #define LDINT   lwa
228 #else
229 #define LDINT   lwz
230 #endif
231
232 /*
233 #define DCBT(REGA, REGB, NUM) .long (0x7c00022c | (REGA << 16) | (REGB << 11) | ((NUM) << 21))
234 #define DCBTST(REGA, REGB, NUM) .long (0x7c0001ec | (REGA << 16) | (REGB << 11) | ((NUM) << 21))
235 */
236
237 #define DSTATTR_H(SIZE, COUNT, STRIDE) ((SIZE << 8) | (COUNT))
238 #define DSTATTR_L(SIZE, COUNT, STRIDE) (STRIDE)
239
240 #if defined(PPC970) || defined(POWER3) || defined(POWER4) || defined(POWER5) || defined(PPCG4)
241 #define HAVE_PREFETCH
242 #endif
243
244 #if defined(POWER3) || defined(POWER6) || defined(PPCG4) || defined(CELL) || defined(POWER8)
245 #define DCBT_ARG        0
246 #else
247 #define DCBT_ARG        8
248 #endif
249
250 #ifdef CELL
251 #define L1_DUALFETCH
252 #define L1_PREFETCHSIZE (64 + 128 * 13)
253 #endif
254
255 #if defined(POWER3) || defined(POWER4) || defined(POWER5)
256 #define L1_DUALFETCH
257 #define L1_PREFETCHSIZE (96 + 128 * 12)
258 #endif
259
260 #if defined(POWER6)
261 #define L1_DUALFETCH
262 #define L1_PREFETCHSIZE (16 + 128 * 100)
263 #define L1_PREFETCH     dcbtst
264 #endif
265
266 #if defined(POWER8)
267 #define L1_DUALFETCH
268 #define L1_PREFETCHSIZE (16 + 128 * 100)
269 #define L1_PREFETCH     dcbtst
270 #endif
271
272 #
273 #ifndef L1_PREFETCH
274 #define L1_PREFETCH     dcbt
275 #endif
276
277 #ifndef L1_PREFETCHW
278 #define L1_PREFETCHW    dcbtst
279 #endif
280
281 #if DCBT_ARG == 0
282 #define DCBT(REGA, REGB)        L1_PREFETCH     REGB, REGA
283 #define DCBTST(REGA, REGB)      L1_PREFETCHW    REGB, REGA
284 #else
285 #define DCBT(REGA, REGB)        L1_PREFETCH     DCBT_ARG, REGB, REGA
286 #define DCBTST(REGA, REGB)      L1_PREFETCHW    DCBT_ARG, REGB, REGA
287 #endif
288
289
290 #ifndef L1_PREFETCHSIZE
291 #define L1_PREFETCHSIZE (96 + 128 * 12)
292 #endif
293
294 #if !defined(OS_DARWIN) || defined(NEEDPARAM)
295 #define f0      0
296 #define f1      1
297 #define f2      2
298 #define f3      3
299 #define f4      4
300 #define f5      5
301 #define f6      6
302 #define f7      7
303 #define f8      8
304 #define f9      9
305 #define f10     10
306 #define f11     11
307 #define f12     12
308 #define f13     13
309 #define f14     14
310 #define f15     15
311 #define f16     16
312 #define f17     17
313 #define f18     18
314 #define f19     19
315 #define f20     20
316 #define f21     21
317 #define f22     22
318 #define f23     23
319 #define f24     24
320 #define f25     25
321 #define f26     26
322 #define f27     27
323 #define f28     28
324 #define f29     29
325 #define f30     30
326 #define f31     31
327
328 #define r0      0
329 #define r1      1
330 #define r2      2
331 #define r3      3
332 #define r4      4
333 #define r5      5
334 #define r6      6
335 #define r7      7
336 #define r8      8
337 #define r9      9
338 #define r10     10
339 #define r11     11
340 #define r12     12
341 #define r13     13
342 #define r14     14
343 #define r15     15
344 #define r16     16
345 #define r17     17
346 #define r18     18
347 #define r19     19
348 #define r20     20
349 #define r21     21
350 #define r22     22
351 #define r23     23
352 #define r24     24
353 #define r25     25
354 #define r26     26
355 #define r27     27
356 #define r28     28
357 #define r29     29
358 #define r30     30
359 #define r31     31
360
361 #define v0      0
362 #define v1      1
363 #define v2      2
364 #define v3      3
365 #define v4      4
366 #define v5      5
367 #define v6      6
368 #define v7      7
369 #define v8      8
370 #define v9      9
371 #define v10     10
372 #define v11     11
373 #define v12     12
374 #define v13     13
375 #define v14     14
376 #define v15     15
377 #define v16     16
378 #define v17     17
379 #define v18     18
380 #define v19     19
381 #define v20     20
382 #define v21     21
383 #define v22     22
384 #define v23     23
385 #define v24     24
386 #define v25     25
387 #define v26     26
388 #define v27     27
389 #define v28     28
390 #define v29     29
391 #define v30     30
392 #define v31     31
393
394 #define BO_dCTR_NZERO_AND_NOT   0
395 #define BO_dCTR_NZERO_AND_NOT_1 1
396 #define BO_dCTR_ZERO_AND_NOT    2
397 #define BO_dCTR_ZERO_AND_NOT_1  3
398 #define BO_IF_NOT       4
399 #define BO_IF_NOT_1     5
400 #define BO_IF_NOT_2     6
401 #define BO_IF_NOT_3     7
402 #define BO_dCTR_NZERO_AND       8
403 #define BO_dCTR_NZERO_AND_1     9
404 #define BO_dCTR_ZERO_AND        10
405 #define BO_dCTR_ZERO_AND_1      11
406 #define BO_IF   12
407 #define BO_IF_1 13
408 #define BO_IF_2 14
409 #define BO_IF_3 15
410 #define BO_dCTR_NZERO   16
411 #define BO_dCTR_NZERO_1 17
412 #define BO_dCTR_ZERO    18
413 #define BO_dCTR_ZERO_1  19
414 #define BO_ALWAYS       20
415 #define BO_ALWAYS_1     21
416 #define BO_ALWAYS_2     22
417 #define BO_ALWAYS_3     23
418 #define BO_dCTR_NZERO_8 24
419 #define BO_dCTR_NZERO_9 25
420 #define BO_dCTR_ZERO_8  26
421 #define BO_dCTR_ZERO_9  27
422 #define BO_ALWAYS_8     28
423 #define BO_ALWAYS_9     29
424 #define BO_ALWAYS_10    30
425 #define BO_ALWAYS_11    31
426
427 #define CR0_LT  0
428 #define CR0_GT  1
429 #define CR0_EQ  2
430 #define CR0_SO  3
431 #define CR1_FX  4
432 #define CR1_FEX 5
433 #define CR1_VX  6
434 #define CR1_OX  7
435 #define CR2_LT  8
436 #define CR2_GT  9
437 #define CR2_EQ  10
438 #define CR2_SO  11
439 #define CR3_LT  12
440 #define CR3_GT  13
441 #define CR3_EQ  14
442 #define CR3_SO  15
443 #define CR4_LT  16
444 #define CR4_GT  17
445 #define CR4_EQ  18
446 #define CR4_SO  19
447 #define CR5_LT  20
448 #define CR5_GT  21
449 #define CR5_EQ  22
450 #define CR5_SO  23
451 #define CR6_LT  24
452 #define CR6_GT  25
453 #define CR6_EQ  26
454 #define CR6_SO  27
455 #define CR7_LT  28
456 #define CR7_GT  29
457 #define CR7_EQ  30
458 #define CR7_SO  31
459 #define TO_LT   16
460 #define TO_GT   8
461 #define TO_EQ   4
462 #define TO_LLT  2
463 #define TO_LGT  1
464 #define CR0      0
465 #define CR1      1
466 #define CR2      2
467 #define CR3      3
468 #define CR4      4
469 #define CR5      5
470 #define CR6      6
471 #define CR7      7
472 #define cr0      0
473 #define cr1      1
474 #define cr2      2
475 #define cr3      3
476 #define cr4      4
477 #define cr5      5
478 #define cr6      6
479 #define cr7      7
480 #define VRsave  256
481
482 #endif
483
484 #define CTR 9
485 #define SP r1
486
487 #ifdef __64BIT__
488 #define slwi    sldi
489 #define cmpwi   cmpdi
490 #define srawi   sradi
491 #define mullw   mulld
492 #endif
493
494 #ifndef F_INTERFACE
495 #define REALNAME ASMNAME
496 #else
497 #define REALNAME ASMFNAME
498 #endif
499
500 #if defined(ASSEMBLER) && !defined(NEEDPARAM)
501
502 #ifdef OS_LINUX
503 #ifndef __64BIT__
504 #define PROLOGUE \
505         .section .text;\
506         .align 6;\
507         .globl  REALNAME;\
508         .type   REALNAME, @function;\
509 REALNAME:
510 #define EPILOGUE        .size   REALNAME, .-REALNAME
511 #else
512 #if _CALL_ELF == 2
513 #define PROLOGUE \
514         .section .text;\
515         .align 6;\
516         .globl  REALNAME;\
517         .type   REALNAME, @function;\
518 REALNAME:
519 #define EPILOGUE        .size   REALNAME, .-REALNAME
520 #else
521 #define PROLOGUE \
522         .section .text;\
523         .align 5;\
524         .globl REALNAME;\
525         .section        ".opd","aw";\
526         .align 3;\
527 REALNAME:;\
528         .quad   .REALNAME, .TOC.@tocbase, 0;\
529         .previous;\
530         .size   REALNAME, 24;\
531         .type   .REALNAME, @function;\
532         .globl  .REALNAME;\
533 .REALNAME:
534 #define EPILOGUE \
535         .long 0 ; \
536         .byte 0,0,0,1,128,0,0,0 ; \
537         .size   .REALNAME, .-.REALNAME; \
538         .section        .note.GNU-stack,"",@progbits
539 #endif
540 #endif
541
542 #ifdef PROFILE
543 #ifndef __64BIT__
544 #define PROFCODE ;\
545         .section        ".data";\
546         .align 2;\
547 .LP3:;\
548         .long   0;\
549         .section        ".text";\
550         mflr    r0;\
551         stw     r0,   4(SP);\
552         lis     r12, .LP3@ha;\
553         la      r0, .LP3@l(r12);\
554         bl      _mcount;\
555         lwz     r0,   4(SP);\
556         mtlr    r0
557 #else
558 #define PROFCODE \
559         .globl   _mcount; \
560         mflr    r0; \
561         std     r0,    16(SP); \
562         mr      r11, SP; \
563         addi    SP, SP, -256; \
564         std     r11,    0(SP); \
565         std     r3,   128(SP); \
566         std     r4,   136(SP); \
567         std     r5,   144(SP); \
568         std     r6,   152(SP); \
569         std     r7,   160(SP); \
570         std     r8,   168(SP); \
571         std     r9,   176(SP); \
572         std     r10,  184(SP); \
573         stfd    f3,   192(SP); \
574         stfd    f4,   200(SP); \
575         bl      ._mcount; \
576         nop; \
577         ld      r3,   128(SP);\
578         ld      r4,   136(SP);\
579         ld      r5,   144(SP);\
580         ld      r6,   152(SP);\
581         ld      r7,   160(SP);\
582         ld      r8,   168(SP);\
583         ld      r9,   176(SP);\
584         ld      r10,  184(SP);\
585         lfd     f3,   192(SP);\
586         lfd     f4,   200(SP);\
587         addi    SP, SP,  256;\
588         ld      r0,    16(SP);\
589         mtlr    r0
590 #endif
591 #else
592 #define PROFCODE
593 #endif
594
595 #endif
596
597 #if OS_AIX
598 #ifndef __64BIT__
599 #define PROLOGUE \
600         .machine "any";\
601         .globl .REALNAME;\
602         .csect .text[PR],5;\
603 .REALNAME:;
604
605 #define EPILOGUE \
606 _section_.text:;\
607         .csect .data[RW],4;\
608         .long _section_.text;
609
610 #else
611
612 #define PROLOGUE \
613         .machine "any";\
614         .globl .REALNAME;\
615         .csect .text[PR], 5;\
616 .REALNAME:;
617
618 #define EPILOGUE \
619 _section_.text:;\
620         .csect .data[RW],4;\
621         .llong _section_.text;
622 #endif
623
624 #define PROFCODE
625
626 #endif
627
628 #ifdef OS_DARWIN
629 #ifndef __64BIT__
630         .macro PROLOGUE
631         .section __TEXT,__text,regular,pure_instructions
632         .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
633         .machine ppc
634         .text
635         .align 4
636         .globl REALNAME
637 REALNAME:
638         .endmacro
639 #else
640         .macro PROLOGUE
641         .section __TEXT,__text,regular,pure_instructions
642         .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
643         .machine ppc64
644         .text
645         .align 4
646         .globl REALNAME
647 REALNAME:
648         .endmacro
649 #endif
650
651 #ifndef PROFILE
652 #define PROFCODE
653 #define EPILOGUE        .subsections_via_symbols
654 #else
655 #ifndef __64BIT__
656
657         .macro PROFCODE
658         mflr    r0
659         stw     r0,     8(SP)
660         addi    SP, SP, -64
661         stw     SP,     0(SP)
662         stw     r3,    12(SP)
663         stw     r4,    16(SP)
664         stw     r5,    20(SP)
665         stw     r6,    24(SP)
666         stw     r7,    28(SP)
667         stw     r8,    32(SP)
668         stw     r9,    36(SP)
669         stw     r10,   40(SP)
670         stfd    f1,    48(SP)
671         stfd    f2,    56(SP)
672         mr      r3, r0
673         bl      Lmcount$stub
674         nop
675         lwz     r3,    12(SP)
676         lwz     r4,    16(SP)
677         lwz     r5,    20(SP)
678         lwz     r6,    24(SP)
679         lwz     r7,    28(SP)
680         lwz     r8,    32(SP)
681         lwz     r9,    36(SP)
682         lwz     r10,   40(SP)
683         lfd     f1,    48(SP)
684         lfd     f2,    56(SP)
685         addi    SP, SP,  64
686         lwz     r0,     8(SP)
687         mtlr    r0
688         .endmacro
689
690         .macro EPILOGUE
691         .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
692         .align 5
693 Lmcount$stub:
694         .indirect_symbol mcount
695         mflr r0
696         bcl 20,31,L00000000001$spb
697 L00000000001$spb:
698         mflr r11
699         addis r11,r11,ha16(Lmcount$lazy_ptr-L00000000001$spb)
700         mtlr r0
701         lwzu r12,lo16(Lmcount$lazy_ptr-L00000000001$spb)(r11)
702         mtctr r12
703         bctr
704         .lazy_symbol_pointer
705 Lmcount$lazy_ptr:
706         .indirect_symbol mcount
707         .long   dyld_stub_binding_helper
708         .subsections_via_symbols
709         .endmacro
710
711 #else
712         .macro PROFCODE
713         mflr    r0
714         std     r0,    16(SP)
715         addi    SP, SP, -128
716         std     SP,     0(SP)
717         std     r3,    24(SP)
718         std     r4,    32(SP)
719         std     r5,    40(SP)
720         std     r6,    48(SP)
721         std     r7,    56(SP)
722         std     r8,    64(SP)
723         std     r9,    72(SP)
724         std     r10,   80(SP)
725         stfd    f1,    88(SP)
726         stfd    f2,    96(SP)
727         mr      r3, r0
728         bl      Lmcount$stub
729         nop
730         ld      r3,    24(SP)
731         ld      r4,    32(SP)
732         ld      r5,    40(SP)
733         ld      r6,    48(SP)
734         ld      r7,    56(SP)
735         ld      r8,    64(SP)
736         ld      r9,    72(SP)
737         ld      r10,   80(SP)
738         lfd     f1,    88(SP)
739         lfd     f2,    86(SP)
740         addi    SP, SP,  128
741         ld      r0,    16(SP)
742         mtlr    r0
743         .endmacro
744
745         .macro EPILOGUE
746         .data
747         .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
748         .align 5
749 Lmcount$stub:
750         .indirect_symbol mcount
751         mflr r0
752         bcl 20,31,L00000000001$spb
753 L00000000001$spb:
754         mflr r11
755         addis r11,r11,ha16(Lmcount$lazy_ptr-L00000000001$spb)
756         mtlr r0
757         ld r12,lo16(Lmcount$lazy_ptr-L00000000001$spb)(r11)
758         mtctr r12
759         bctr
760         .lazy_symbol_pointer
761 Lmcount$lazy_ptr:
762         .indirect_symbol mcount
763         .quad   dyld_stub_binding_helper
764         .subsections_via_symbols
765         .endmacro
766 #endif
767
768 #endif
769
770 #endif
771 #endif
772
773 #endif
774
775 #define HALT            mfspr   r0, 1023
776
777 #ifdef OS_LINUX
778 #if defined(PPC440) || defined(PPC440FP2)
779 #undef  MAX_CPU_NUMBER
780 #define MAX_CPU_NUMBER 1
781 #endif
782 #if !defined(__64BIT__) && !defined(PROFILE) && !defined(PPC440) && !defined(PPC440FP2)
783 #define START_ADDRESS (0x0b000000UL)
784 #else
785 #define SEEK_ADDRESS
786 #endif
787 #endif
788
789 #ifdef OS_AIX
790 #ifndef __64BIT__
791 #define START_ADDRESS (0xf0000000UL)
792 #else
793 #define SEEK_ADDRESS
794 #endif
795 #endif
796
797 #ifdef OS_DARWIN
798 #define SEEK_ADDRESS
799 #endif
800
801 #if defined(PPC440)
802 #define BUFFER_SIZE     (  2 << 20)
803 #elif defined(PPC440FP2)
804 #define BUFFER_SIZE     ( 16 << 20)
805 #elif defined(POWER8)
806 #define BUFFER_SIZE     ( 64 << 20)
807 #else
808 #define BUFFER_SIZE     ( 16 << 20)
809 #endif
810
811 #ifndef PAGESIZE
812 #define PAGESIZE        ( 4 << 10)
813 #endif
814 #define HUGE_PAGESIZE   (16 << 20)
815
816 #define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)
817
818 #ifndef MAP_ANONYMOUS
819 #define MAP_ANONYMOUS MAP_ANON
820 #endif
821
822 #ifdef OS_LINUX
823 #ifndef __64BIT__
824 #define FRAMESLOT(X) (((X) * 4) + 8)
825 #else
826 #if _CALL_ELF == 2
827 #define FRAMESLOT(X) (((X) * 8) + 96)
828 #else
829 #define FRAMESLOT(X) (((X) * 8) + 112)
830 #endif
831 #endif
832 #endif
833
834 #if defined(OS_AIX) || defined(OS_DARWIN)
835 #ifndef __64BIT__
836 #define FRAMESLOT(X) (((X) * 4) + 56)
837 #else
838 #define FRAMESLOT(X) (((X) * 8) + 112)
839 #endif
840 #endif
841
842 #endif