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