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

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