You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

common_power.h 17 kB

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