ab331b04a0ccc1b72b39dd97dc2a8fcb5f33a5e8
[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)
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 #ifndef L1_PREFETCH
262 #define L1_PREFETCH     dcbt
263 #endif
264
265 #ifndef L1_PREFETCHW
266 #define L1_PREFETCHW    dcbtst
267 #endif
268
269 #if DCBT_ARG == 0
270 #define DCBT(REGA, REGB)        L1_PREFETCH     REGB, REGA
271 #define DCBTST(REGA, REGB)      L1_PREFETCHW    REGB, REGA
272 #else
273 #define DCBT(REGA, REGB)        L1_PREFETCH     DCBT_ARG, REGB, REGA
274 #define DCBTST(REGA, REGB)      L1_PREFETCHW    DCBT_ARG, REGB, REGA
275 #endif
276
277
278 #ifndef L1_PREFETCHSIZE
279 #define L1_PREFETCHSIZE (96 + 128 * 12)
280 #endif
281
282 #if !defined(OS_DARWIN) || defined(NEEDPARAM)
283 #define f0      0
284 #define f1      1
285 #define f2      2
286 #define f3      3
287 #define f4      4
288 #define f5      5
289 #define f6      6
290 #define f7      7
291 #define f8      8
292 #define f9      9
293 #define f10     10
294 #define f11     11
295 #define f12     12
296 #define f13     13
297 #define f14     14
298 #define f15     15
299 #define f16     16
300 #define f17     17
301 #define f18     18
302 #define f19     19
303 #define f20     20
304 #define f21     21
305 #define f22     22
306 #define f23     23
307 #define f24     24
308 #define f25     25
309 #define f26     26
310 #define f27     27
311 #define f28     28
312 #define f29     29
313 #define f30     30
314 #define f31     31
315
316 #define r0      0
317 #define r1      1
318 #define r2      2
319 #define r3      3
320 #define r4      4
321 #define r5      5
322 #define r6      6
323 #define r7      7
324 #define r8      8
325 #define r9      9
326 #define r10     10
327 #define r11     11
328 #define r12     12
329 #define r13     13
330 #define r14     14
331 #define r15     15
332 #define r16     16
333 #define r17     17
334 #define r18     18
335 #define r19     19
336 #define r20     20
337 #define r21     21
338 #define r22     22
339 #define r23     23
340 #define r24     24
341 #define r25     25
342 #define r26     26
343 #define r27     27
344 #define r28     28
345 #define r29     29
346 #define r30     30
347 #define r31     31
348
349 #define v0      0
350 #define v1      1
351 #define v2      2
352 #define v3      3
353 #define v4      4
354 #define v5      5
355 #define v6      6
356 #define v7      7
357 #define v8      8
358 #define v9      9
359 #define v10     10
360 #define v11     11
361 #define v12     12
362 #define v13     13
363 #define v14     14
364 #define v15     15
365 #define v16     16
366 #define v17     17
367 #define v18     18
368 #define v19     19
369 #define v20     20
370 #define v21     21
371 #define v22     22
372 #define v23     23
373 #define v24     24
374 #define v25     25
375 #define v26     26
376 #define v27     27
377 #define v28     28
378 #define v29     29
379 #define v30     30
380 #define v31     31
381
382 #define BO_dCTR_NZERO_AND_NOT   0
383 #define BO_dCTR_NZERO_AND_NOT_1 1
384 #define BO_dCTR_ZERO_AND_NOT    2
385 #define BO_dCTR_ZERO_AND_NOT_1  3
386 #define BO_IF_NOT       4
387 #define BO_IF_NOT_1     5
388 #define BO_IF_NOT_2     6
389 #define BO_IF_NOT_3     7
390 #define BO_dCTR_NZERO_AND       8
391 #define BO_dCTR_NZERO_AND_1     9
392 #define BO_dCTR_ZERO_AND        10
393 #define BO_dCTR_ZERO_AND_1      11
394 #define BO_IF   12
395 #define BO_IF_1 13
396 #define BO_IF_2 14
397 #define BO_IF_3 15
398 #define BO_dCTR_NZERO   16
399 #define BO_dCTR_NZERO_1 17
400 #define BO_dCTR_ZERO    18
401 #define BO_dCTR_ZERO_1  19
402 #define BO_ALWAYS       20
403 #define BO_ALWAYS_1     21
404 #define BO_ALWAYS_2     22
405 #define BO_ALWAYS_3     23
406 #define BO_dCTR_NZERO_8 24
407 #define BO_dCTR_NZERO_9 25
408 #define BO_dCTR_ZERO_8  26
409 #define BO_dCTR_ZERO_9  27
410 #define BO_ALWAYS_8     28
411 #define BO_ALWAYS_9     29
412 #define BO_ALWAYS_10    30
413 #define BO_ALWAYS_11    31
414
415 #define CR0_LT  0
416 #define CR0_GT  1
417 #define CR0_EQ  2
418 #define CR0_SO  3
419 #define CR1_FX  4
420 #define CR1_FEX 5
421 #define CR1_VX  6
422 #define CR1_OX  7
423 #define CR2_LT  8
424 #define CR2_GT  9
425 #define CR2_EQ  10
426 #define CR2_SO  11
427 #define CR3_LT  12
428 #define CR3_GT  13
429 #define CR3_EQ  14
430 #define CR3_SO  15
431 #define CR4_LT  16
432 #define CR4_GT  17
433 #define CR4_EQ  18
434 #define CR4_SO  19
435 #define CR5_LT  20
436 #define CR5_GT  21
437 #define CR5_EQ  22
438 #define CR5_SO  23
439 #define CR6_LT  24
440 #define CR6_GT  25
441 #define CR6_EQ  26
442 #define CR6_SO  27
443 #define CR7_LT  28
444 #define CR7_GT  29
445 #define CR7_EQ  30
446 #define CR7_SO  31
447 #define TO_LT   16
448 #define TO_GT   8
449 #define TO_EQ   4
450 #define TO_LLT  2
451 #define TO_LGT  1
452 #define CR0      0
453 #define CR1      1
454 #define CR2      2
455 #define CR3      3
456 #define CR4      4
457 #define CR5      5
458 #define CR6      6
459 #define CR7      7
460 #define cr0      0
461 #define cr1      1
462 #define cr2      2
463 #define cr3      3
464 #define cr4      4
465 #define cr5      5
466 #define cr6      6
467 #define cr7      7
468 #define VRsave  256
469
470 #endif
471
472 #define CTR 9
473 #define SP r1
474
475 #ifdef __64BIT__
476 #define slwi    sldi
477 #define cmpwi   cmpdi
478 #define srawi   sradi
479 #define mullw   mulld
480 #endif
481
482 #ifndef F_INTERFACE
483 #define REALNAME ASMNAME
484 #else
485 #define REALNAME ASMFNAME
486 #endif
487
488 #if defined(ASSEMBLER) && !defined(NEEDPARAM)
489
490 #ifdef OS_LINUX
491 #ifndef __64BIT__
492 #define PROLOGUE \
493         .section .text;\
494         .align 6;\
495         .globl  REALNAME;\
496         .type   REALNAME, @function;\
497 REALNAME:
498 #define EPILOGUE        .size   REALNAME, .-REALNAME
499 #else
500 #if _CALL_ELF == 2
501 #define PROLOGUE \
502         .section .text;\
503         .align 6;\
504         .globl  REALNAME;\
505         .type   REALNAME, @function;\
506 REALNAME:
507 #define EPILOGUE        .size   REALNAME, .-REALNAME
508 #else
509 #define PROLOGUE \
510         .section .text;\
511         .align 5;\
512         .globl REALNAME;\
513         .section        ".opd","aw";\
514         .align 3;\
515 REALNAME:;\
516         .quad   .REALNAME, .TOC.@tocbase, 0;\
517         .previous;\
518         .size   REALNAME, 24;\
519         .type   .REALNAME, @function;\
520         .globl  .REALNAME;\
521 .REALNAME:
522 #define EPILOGUE \
523         .long 0 ; \
524         .byte 0,0,0,1,128,0,0,0 ; \
525         .size   .REALNAME, .-.REALNAME; \
526         .section        .note.GNU-stack,"",@progbits
527 #endif
528 #endif
529
530 #ifdef PROFILE
531 #ifndef __64BIT__
532 #define PROFCODE ;\
533         .section        ".data";\
534         .align 2;\
535 .LP3:;\
536         .long   0;\
537         .section        ".text";\
538         mflr    r0;\
539         stw     r0,   4(SP);\
540         lis     r12, .LP3@ha;\
541         la      r0, .LP3@l(r12);\
542         bl      _mcount;\
543         lwz     r0,   4(SP);\
544         mtlr    r0
545 #else
546 #define PROFCODE \
547         .globl   _mcount; \
548         mflr    r0; \
549         std     r0,    16(SP); \
550         mr      r11, SP; \
551         addi    SP, SP, -256; \
552         std     r11,    0(SP); \
553         std     r3,   128(SP); \
554         std     r4,   136(SP); \
555         std     r5,   144(SP); \
556         std     r6,   152(SP); \
557         std     r7,   160(SP); \
558         std     r8,   168(SP); \
559         std     r9,   176(SP); \
560         std     r10,  184(SP); \
561         stfd    f3,   192(SP); \
562         stfd    f4,   200(SP); \
563         bl      ._mcount; \
564         nop; \
565         ld      r3,   128(SP);\
566         ld      r4,   136(SP);\
567         ld      r5,   144(SP);\
568         ld      r6,   152(SP);\
569         ld      r7,   160(SP);\
570         ld      r8,   168(SP);\
571         ld      r9,   176(SP);\
572         ld      r10,  184(SP);\
573         lfd     f3,   192(SP);\
574         lfd     f4,   200(SP);\
575         addi    SP, SP,  256;\
576         ld      r0,    16(SP);\
577         mtlr    r0
578 #endif
579 #else
580 #define PROFCODE
581 #endif
582
583 #endif
584
585 #if OS_AIX
586 #ifndef __64BIT__
587 #define PROLOGUE \
588         .machine "any";\
589         .globl .REALNAME;\
590         .csect .text[PR],5;\
591 .REALNAME:;
592
593 #define EPILOGUE \
594 _section_.text:;\
595         .csect .data[RW],4;\
596         .long _section_.text;
597
598 #else
599
600 #define PROLOGUE \
601         .machine "any";\
602         .globl .REALNAME;\
603         .csect .text[PR], 5;\
604 .REALNAME:;
605
606 #define EPILOGUE \
607 _section_.text:;\
608         .csect .data[RW],4;\
609         .llong _section_.text;
610 #endif
611
612 #define PROFCODE
613
614 #endif
615
616 #ifdef OS_DARWIN
617 #ifndef __64BIT__
618         .macro PROLOGUE
619         .section __TEXT,__text,regular,pure_instructions
620         .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
621         .machine ppc
622         .text
623         .align 4
624         .globl REALNAME
625 REALNAME:
626         .endmacro
627 #else
628         .macro PROLOGUE
629         .section __TEXT,__text,regular,pure_instructions
630         .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
631         .machine ppc64
632         .text
633         .align 4
634         .globl REALNAME
635 REALNAME:
636         .endmacro
637 #endif
638
639 #ifndef PROFILE
640 #define PROFCODE
641 #define EPILOGUE        .subsections_via_symbols
642 #else
643 #ifndef __64BIT__
644
645         .macro PROFCODE
646         mflr    r0
647         stw     r0,     8(SP)
648         addi    SP, SP, -64
649         stw     SP,     0(SP)
650         stw     r3,    12(SP)
651         stw     r4,    16(SP)
652         stw     r5,    20(SP)
653         stw     r6,    24(SP)
654         stw     r7,    28(SP)
655         stw     r8,    32(SP)
656         stw     r9,    36(SP)
657         stw     r10,   40(SP)
658         stfd    f1,    48(SP)
659         stfd    f2,    56(SP)
660         mr      r3, r0
661         bl      Lmcount$stub
662         nop
663         lwz     r3,    12(SP)
664         lwz     r4,    16(SP)
665         lwz     r5,    20(SP)
666         lwz     r6,    24(SP)
667         lwz     r7,    28(SP)
668         lwz     r8,    32(SP)
669         lwz     r9,    36(SP)
670         lwz     r10,   40(SP)
671         lfd     f1,    48(SP)
672         lfd     f2,    56(SP)
673         addi    SP, SP,  64
674         lwz     r0,     8(SP)
675         mtlr    r0
676         .endmacro
677
678         .macro EPILOGUE
679         .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
680         .align 5
681 Lmcount$stub:
682         .indirect_symbol mcount
683         mflr r0
684         bcl 20,31,L00000000001$spb
685 L00000000001$spb:
686         mflr r11
687         addis r11,r11,ha16(Lmcount$lazy_ptr-L00000000001$spb)
688         mtlr r0
689         lwzu r12,lo16(Lmcount$lazy_ptr-L00000000001$spb)(r11)
690         mtctr r12
691         bctr
692         .lazy_symbol_pointer
693 Lmcount$lazy_ptr:
694         .indirect_symbol mcount
695         .long   dyld_stub_binding_helper
696         .subsections_via_symbols
697         .endmacro
698
699 #else
700         .macro PROFCODE
701         mflr    r0
702         std     r0,    16(SP)
703         addi    SP, SP, -128
704         std     SP,     0(SP)
705         std     r3,    24(SP)
706         std     r4,    32(SP)
707         std     r5,    40(SP)
708         std     r6,    48(SP)
709         std     r7,    56(SP)
710         std     r8,    64(SP)
711         std     r9,    72(SP)
712         std     r10,   80(SP)
713         stfd    f1,    88(SP)
714         stfd    f2,    96(SP)
715         mr      r3, r0
716         bl      Lmcount$stub
717         nop
718         ld      r3,    24(SP)
719         ld      r4,    32(SP)
720         ld      r5,    40(SP)
721         ld      r6,    48(SP)
722         ld      r7,    56(SP)
723         ld      r8,    64(SP)
724         ld      r9,    72(SP)
725         ld      r10,   80(SP)
726         lfd     f1,    88(SP)
727         lfd     f2,    86(SP)
728         addi    SP, SP,  128
729         ld      r0,    16(SP)
730         mtlr    r0
731         .endmacro
732
733         .macro EPILOGUE
734         .data
735         .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
736         .align 5
737 Lmcount$stub:
738         .indirect_symbol mcount
739         mflr r0
740         bcl 20,31,L00000000001$spb
741 L00000000001$spb:
742         mflr r11
743         addis r11,r11,ha16(Lmcount$lazy_ptr-L00000000001$spb)
744         mtlr r0
745         ld r12,lo16(Lmcount$lazy_ptr-L00000000001$spb)(r11)
746         mtctr r12
747         bctr
748         .lazy_symbol_pointer
749 Lmcount$lazy_ptr:
750         .indirect_symbol mcount
751         .quad   dyld_stub_binding_helper
752         .subsections_via_symbols
753         .endmacro
754 #endif
755
756 #endif
757
758 #endif
759 #endif
760
761 #endif
762
763 #define HALT            mfspr   r0, 1023
764
765 #ifdef OS_LINUX
766 #if defined(PPC440) || defined(PPC440FP2)
767 #undef  MAX_CPU_NUMBER
768 #define MAX_CPU_NUMBER 1
769 #endif
770 #if !defined(__64BIT__) && !defined(PROFILE) && !defined(PPC440) && !defined(PPC440FP2)
771 #define START_ADDRESS (0x0b000000UL)
772 #else
773 #define SEEK_ADDRESS
774 #endif
775 #endif
776
777 #ifdef OS_AIX
778 #ifndef __64BIT__
779 #define START_ADDRESS (0xf0000000UL)
780 #else
781 #define SEEK_ADDRESS
782 #endif
783 #endif
784
785 #ifdef OS_DARWIN
786 #define SEEK_ADDRESS
787 #endif
788
789 #if defined(PPC440)
790 #define BUFFER_SIZE     (  2 << 20)
791 #elif defined(PPC440FP2)
792 #define BUFFER_SIZE     ( 16 << 20)
793 #else
794 #define BUFFER_SIZE     ( 16 << 20)
795 #endif
796
797 #ifndef PAGESIZE
798 #define PAGESIZE        ( 4 << 10)
799 #endif
800 #define HUGE_PAGESIZE   (16 << 20)
801
802 #define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)
803
804 #ifndef MAP_ANONYMOUS
805 #define MAP_ANONYMOUS MAP_ANON
806 #endif
807
808 #ifdef OS_LINUX
809 #ifndef __64BIT__
810 #define FRAMESLOT(X) (((X) * 4) + 8)
811 #else
812 #if _CALL_ELF == 2
813 #define FRAMESLOT(X) (((X) * 8) + 96)
814 #else
815 #define FRAMESLOT(X) (((X) * 8) + 112)
816 #endif
817 #endif
818 #endif
819
820 #if defined(OS_AIX) || defined(OS_DARWIN)
821 #ifndef __64BIT__
822 #define FRAMESLOT(X) (((X) * 4) + 56)
823 #else
824 #define FRAMESLOT(X) (((X) * 8) + 112)
825 #endif
826 #endif
827
828 #endif