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

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