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 16 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  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. #define PROLOGUE \
  444. .section .text;\
  445. .align 5;\
  446. .globl REALNAME;\
  447. .section ".opd","aw";\
  448. .align 3;\
  449. REALNAME:;\
  450. .quad .REALNAME, .TOC.@tocbase, 0;\
  451. .previous;\
  452. .size REALNAME, 24;\
  453. .type .REALNAME, @function;\
  454. .globl .REALNAME;\
  455. .REALNAME:
  456. #define EPILOGUE \
  457. .long 0 ; \
  458. .byte 0,0,0,1,128,0,0,0 ; \
  459. .size .REALNAME, .-.REALNAME; \
  460. .section .note.GNU-stack,"",@progbits
  461. #endif
  462. #ifdef PROFILE
  463. #ifndef __64BIT__
  464. #define PROFCODE ;\
  465. .section ".data";\
  466. .align 2;\
  467. .LP3:;\
  468. .long 0;\
  469. .section ".text";\
  470. mflr r0;\
  471. stw r0, 4(SP);\
  472. lis r12, .LP3@ha;\
  473. la r0, .LP3@l(r12);\
  474. bl _mcount;\
  475. lwz r0, 4(SP);\
  476. mtlr r0
  477. #else
  478. #define PROFCODE \
  479. .globl _mcount; \
  480. mflr r0; \
  481. std r0, 16(SP); \
  482. mr r11, SP; \
  483. addi SP, SP, -256; \
  484. std r11, 0(SP); \
  485. std r3, 128(SP); \
  486. std r4, 136(SP); \
  487. std r5, 144(SP); \
  488. std r6, 152(SP); \
  489. std r7, 160(SP); \
  490. std r8, 168(SP); \
  491. std r9, 176(SP); \
  492. std r10, 184(SP); \
  493. stfd f3, 192(SP); \
  494. stfd f4, 200(SP); \
  495. bl ._mcount; \
  496. nop; \
  497. ld r3, 128(SP);\
  498. ld r4, 136(SP);\
  499. ld r5, 144(SP);\
  500. ld r6, 152(SP);\
  501. ld r7, 160(SP);\
  502. ld r8, 168(SP);\
  503. ld r9, 176(SP);\
  504. ld r10, 184(SP);\
  505. lfd f3, 192(SP);\
  506. lfd f4, 200(SP);\
  507. addi SP, SP, 256;\
  508. ld r0, 16(SP);\
  509. mtlr r0
  510. #endif
  511. #else
  512. #define PROFCODE
  513. #endif
  514. #endif
  515. #if OS_AIX
  516. #ifndef __64BIT__
  517. #define PROLOGUE \
  518. .machine "any";\
  519. .globl .REALNAME;\
  520. .csect .text[PR],5;\
  521. .REALNAME:;
  522. #define EPILOGUE \
  523. _section_.text:;\
  524. .csect .data[RW],4;\
  525. .long _section_.text;
  526. #else
  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. .llong _section_.text;
  536. #endif
  537. #define PROFCODE
  538. #endif
  539. #ifdef OS_DARWIN
  540. #ifndef __64BIT__
  541. .macro PROLOGUE
  542. .section __TEXT,__text,regular,pure_instructions
  543. .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
  544. .machine ppc
  545. .text
  546. .align 4
  547. .globl REALNAME
  548. REALNAME:
  549. .endmacro
  550. #else
  551. .macro PROLOGUE
  552. .section __TEXT,__text,regular,pure_instructions
  553. .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
  554. .machine ppc64
  555. .text
  556. .align 4
  557. .globl REALNAME
  558. REALNAME:
  559. .endmacro
  560. #endif
  561. #ifndef PROFILE
  562. #define PROFCODE
  563. #define EPILOGUE .subsections_via_symbols
  564. #else
  565. #ifndef __64BIT__
  566. .macro PROFCODE
  567. mflr r0
  568. stw r0, 8(SP)
  569. addi SP, SP, -64
  570. stw SP, 0(SP)
  571. stw r3, 12(SP)
  572. stw r4, 16(SP)
  573. stw r5, 20(SP)
  574. stw r6, 24(SP)
  575. stw r7, 28(SP)
  576. stw r8, 32(SP)
  577. stw r9, 36(SP)
  578. stw r10, 40(SP)
  579. stfd f1, 48(SP)
  580. stfd f2, 56(SP)
  581. mr r3, r0
  582. bl Lmcount$stub
  583. nop
  584. lwz r3, 12(SP)
  585. lwz r4, 16(SP)
  586. lwz r5, 20(SP)
  587. lwz r6, 24(SP)
  588. lwz r7, 28(SP)
  589. lwz r8, 32(SP)
  590. lwz r9, 36(SP)
  591. lwz r10, 40(SP)
  592. lfd f1, 48(SP)
  593. lfd f2, 56(SP)
  594. addi SP, SP, 64
  595. lwz r0, 8(SP)
  596. mtlr r0
  597. .endmacro
  598. .macro EPILOGUE
  599. .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
  600. .align 5
  601. Lmcount$stub:
  602. .indirect_symbol mcount
  603. mflr r0
  604. bcl 20,31,L00000000001$spb
  605. L00000000001$spb:
  606. mflr r11
  607. addis r11,r11,ha16(Lmcount$lazy_ptr-L00000000001$spb)
  608. mtlr r0
  609. lwzu r12,lo16(Lmcount$lazy_ptr-L00000000001$spb)(r11)
  610. mtctr r12
  611. bctr
  612. .lazy_symbol_pointer
  613. Lmcount$lazy_ptr:
  614. .indirect_symbol mcount
  615. .long dyld_stub_binding_helper
  616. .subsections_via_symbols
  617. .endmacro
  618. #else
  619. .macro PROFCODE
  620. mflr r0
  621. std r0, 16(SP)
  622. addi SP, SP, -128
  623. std SP, 0(SP)
  624. std r3, 24(SP)
  625. std r4, 32(SP)
  626. std r5, 40(SP)
  627. std r6, 48(SP)
  628. std r7, 56(SP)
  629. std r8, 64(SP)
  630. std r9, 72(SP)
  631. std r10, 80(SP)
  632. stfd f1, 88(SP)
  633. stfd f2, 96(SP)
  634. mr r3, r0
  635. bl Lmcount$stub
  636. nop
  637. ld r3, 24(SP)
  638. ld r4, 32(SP)
  639. ld r5, 40(SP)
  640. ld r6, 48(SP)
  641. ld r7, 56(SP)
  642. ld r8, 64(SP)
  643. ld r9, 72(SP)
  644. ld r10, 80(SP)
  645. lfd f1, 88(SP)
  646. lfd f2, 86(SP)
  647. addi SP, SP, 128
  648. ld r0, 16(SP)
  649. mtlr r0
  650. .endmacro
  651. .macro EPILOGUE
  652. .data
  653. .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
  654. .align 5
  655. Lmcount$stub:
  656. .indirect_symbol mcount
  657. mflr r0
  658. bcl 20,31,L00000000001$spb
  659. L00000000001$spb:
  660. mflr r11
  661. addis r11,r11,ha16(Lmcount$lazy_ptr-L00000000001$spb)
  662. mtlr r0
  663. ld r12,lo16(Lmcount$lazy_ptr-L00000000001$spb)(r11)
  664. mtctr r12
  665. bctr
  666. .lazy_symbol_pointer
  667. Lmcount$lazy_ptr:
  668. .indirect_symbol mcount
  669. .quad dyld_stub_binding_helper
  670. .subsections_via_symbols
  671. .endmacro
  672. #endif
  673. #endif
  674. #endif
  675. #endif
  676. #endif
  677. #define HALT mfspr r0, 1023
  678. #ifdef OS_LINUX
  679. #if defined(PPC440) || defined(PPC440FP2)
  680. #undef MAX_CPU_NUMBER
  681. #define MAX_CPU_NUMBER 1
  682. #endif
  683. #if !defined(__64BIT__) && !defined(PROFILE) && !defined(PPC440) && !defined(PPC440FP2)
  684. #define START_ADDRESS (0x0b000000UL)
  685. #else
  686. #define SEEK_ADDRESS
  687. #endif
  688. #endif
  689. #ifdef OS_AIX
  690. #ifndef __64BIT__
  691. #define START_ADDRESS (0xf0000000UL)
  692. #else
  693. #define SEEK_ADDRESS
  694. #endif
  695. #endif
  696. #ifdef OS_DARWIN
  697. #define SEEK_ADDRESS
  698. #endif
  699. #if defined(PPC440)
  700. #define BUFFER_SIZE ( 2 << 20)
  701. #elif defined(PPC440FP2)
  702. #define BUFFER_SIZE ( 16 << 20)
  703. #else
  704. #define BUFFER_SIZE ( 16 << 20)
  705. #endif
  706. #ifndef PAGESIZE
  707. #define PAGESIZE ( 4 << 10)
  708. #endif
  709. #define HUGE_PAGESIZE (16 << 20)
  710. #define BASE_ADDRESS (START_ADDRESS - BUFFER_SIZE * MAX_CPU_NUMBER)
  711. #ifndef MAP_ANONYMOUS
  712. #define MAP_ANONYMOUS MAP_ANON
  713. #endif
  714. #endif