powerpc.inc 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2000-2001 by the Free Pascal development team.
  5. Portions Copyright (c) 2000 by Casey Duncan ([email protected])
  6. Processor dependent implementation for the system unit for
  7. PowerPC
  8. See the file COPYING.FPC, included in this distribution,
  9. for details about the copyright.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. **********************************************************************}
  14. {****************************************************************************
  15. PowerPC specific stuff
  16. ****************************************************************************}
  17. {
  18. const
  19. ppc_fpu_overflow = (1 shl (32-3));
  20. ppc_fpu_underflow = (1 shl (32-4));
  21. ppc_fpu_divbyzero = (1 shl (32-5));
  22. ppc_fpu_inexact = (1 shl (32-6));
  23. ppc_fpu_invalid_snan = (1 shl (32-7));
  24. }
  25. procedure fpc_enable_ppc_fpu_exceptions;
  26. assembler; nostackframe;
  27. asm
  28. { clear all "exception happened" flags we care about}
  29. mtfsfi 0,0
  30. mtfsfi 1,0
  31. mtfsfi 2,0
  32. mtfsfi 3,0
  33. {$ifdef fpc_mtfsb0_corrected}
  34. mtfsb0 21
  35. mtfsb0 22
  36. mtfsb0 23
  37. {$endif fpc_mtfsb0_corrected}
  38. { enable invalid operations and division by zero exceptions. }
  39. { No overflow/underflow, since those give some spurious }
  40. { exceptions }
  41. mtfsfi 6,9
  42. end;
  43. procedure fpc_cpuinit;
  44. begin
  45. fpc_enable_ppc_fpu_exceptions;
  46. end;
  47. function fpc_get_ppc_fpscr: cardinal;
  48. assembler;
  49. var
  50. temp: record a,b:longint; end;
  51. asm
  52. mffs f0
  53. stfd f0,temp
  54. lwz r3,temp.b
  55. { clear all exception flags }
  56. {
  57. rlwinm r4,r3,0,16,31
  58. stw r4,temp.b
  59. lfd f0,temp
  60. a_mtfsf f0
  61. }
  62. end;
  63. { This function is never called directly, it's a dummy to hold the register save/
  64. load subroutines
  65. }
  66. {$ifndef MACOS}
  67. label
  68. _restfpr_14_x,
  69. _restfpr_15_x,
  70. _restfpr_16_x,
  71. _restfpr_17_x,
  72. _restfpr_18_x,
  73. _restfpr_19_x,
  74. _restfpr_20_x,
  75. _restfpr_21_x,
  76. _restfpr_22_x,
  77. _restfpr_23_x,
  78. _restfpr_24_x,
  79. _restfpr_25_x,
  80. _restfpr_26_x,
  81. _restfpr_27_x,
  82. _restfpr_28_x,
  83. _restfpr_29_x,
  84. _restfpr_30_x,
  85. _restfpr_31_x,
  86. _restfpr_14_l,
  87. _restfpr_15_l,
  88. _restfpr_16_l,
  89. _restfpr_17_l,
  90. _restfpr_18_l,
  91. _restfpr_19_l,
  92. _restfpr_20_l,
  93. _restfpr_21_l,
  94. _restfpr_22_l,
  95. _restfpr_23_l,
  96. _restfpr_24_l,
  97. _restfpr_25_l,
  98. _restfpr_26_l,
  99. _restfpr_27_l,
  100. _restfpr_28_l,
  101. _restfpr_29_l,
  102. _restfpr_30_l,
  103. _restfpr_31_l;
  104. procedure saverestorereg;assembler; nostackframe;
  105. asm
  106. { exit }
  107. .globl _restfpr_14_x
  108. _restfpr_14_x: lfd f14, -144(r11)
  109. .globl _restfpr_15_x
  110. _restfpr_15_x: lfd f15, -136(r11)
  111. .globl _restfpr_16_x
  112. _restfpr_16_x: lfd f16, -128(r11)
  113. .globl _restfpr_17_x
  114. _restfpr_17_x: lfd f17, -120(r11)
  115. .globl _restfpr_18_x
  116. _restfpr_18_x: lfd f18, -112(r11)
  117. .globl _restfpr_19_x
  118. _restfpr_19_x: lfd f19, -104(r11)
  119. .globl _restfpr_20_x
  120. _restfpr_20_x: lfd f20, -96(r11)
  121. .globl _restfpr_21_x
  122. _restfpr_21_x: lfd f21, -88(r11)
  123. .globl _restfpr_22_x
  124. _restfpr_22_x: lfd f22, -80(r11)
  125. .globl _restfpr_23_x
  126. _restfpr_23_x: lfd f23, -72(r11)
  127. .globl _restfpr_24_x
  128. _restfpr_24_x: lfd f24, -64(r11)
  129. .globl _restfpr_25_x
  130. _restfpr_25_x: lfd f25, -56(r11)
  131. .globl _restfpr_26_x
  132. _restfpr_26_x: lfd f26, -48(r11)
  133. .globl _restfpr_27_x
  134. _restfpr_27_x: lfd f27, -40(r11)
  135. .globl _restfpr_28_x
  136. _restfpr_28_x: lfd f28, -32(r11)
  137. .globl _restfpr_29_x
  138. _restfpr_29_x: lfd f29, -24(r11)
  139. .globl _restfpr_30_x
  140. _restfpr_30_x: lfd f30, -16(r11)
  141. .globl _restfpr_31_x
  142. _restfpr_31_x: lwz r0, 4(r11)
  143. lfd f31, -8(r11)
  144. mtlr r0
  145. ori r1, r11, 0
  146. blr
  147. { exit with restoring lr }
  148. .globl _restfpr_14_l
  149. _restfpr_14_l: lfd f14, -144(r11)
  150. .globl _restfpr_15_l
  151. _restfpr_15_l: lfd f15, -136(r11)
  152. .globl _restfpr_16_l
  153. _restfpr_16_l: lfd f16, -128(r11)
  154. .globl _restfpr_17_l
  155. _restfpr_17_l: lfd f17, -120(r11)
  156. .globl _restfpr_18_l
  157. _restfpr_18_l: lfd f18, -112(r11)
  158. .globl _restfpr_19_l
  159. _restfpr_19_l: lfd f19, -104(r11)
  160. .globl _restfpr_20_l
  161. _restfpr_20_l: lfd f20, -96(r11)
  162. .globl _restfpr_21_l
  163. _restfpr_21_l: lfd f21, -88(r11)
  164. .globl _restfpr_22_l
  165. _restfpr_22_l: lfd f22, -80(r11)
  166. .globl _restfpr_23_l
  167. _restfpr_23_l: lfd f23, -72(r11)
  168. .globl _restfpr_24_l
  169. _restfpr_24_l: lfd f24, -64(r11)
  170. .globl _restfpr_25_l
  171. _restfpr_25_l: lfd f25, -56(r11)
  172. .globl _restfpr_26_l
  173. _restfpr_26_l: lfd f26, -48(r11)
  174. .globl _restfpr_27_l
  175. _restfpr_27_l: lfd f27, -40(r11)
  176. .globl _restfpr_28_l
  177. _restfpr_28_l: lfd f28, -32(r11)
  178. .globl _restfpr_29_l
  179. _restfpr_29_l: lfd f29, -24(r11)
  180. .globl _restfpr_30_l
  181. _restfpr_30_l: lfd f30, -16(r11)
  182. .globl _restfpr_31_l
  183. _restfpr_31_l: lwz r0, 4(r11)
  184. lfd f31, -8(r11)
  185. mtlr r0
  186. ori r1, r11, 0
  187. blr
  188. end;
  189. {$endif MACOS}
  190. {****************************************************************************
  191. Move / Fill
  192. ****************************************************************************}
  193. {$ifndef FPC_SYSTEM_HAS_MOVE}
  194. {$define FPC_SYSTEM_HAS_MOVE}
  195. procedure Move(const source;var dest;count:longint);[public, alias: 'FPC_MOVE'];assembler; nostackframe;
  196. asm
  197. { count <= 0 ? }
  198. cmpwi cr0,r5,0
  199. { check if we have to do the move backwards because of overlap }
  200. sub r10,r4,r3
  201. { carry := boolean(dest-source < count) = boolean(overlap) }
  202. subc r10,r10,r5
  203. { count < 15 ? (to decide whether we will move dwords or bytes }
  204. cmpwi cr1,r5,15
  205. { if overlap, then r10 := -1 else r10 := 0 }
  206. subfe r10,r10,r10
  207. { count < 63 ? (32 + max. alignment (31) }
  208. cmpwi cr7,r5,63
  209. { if count <= 0, stop }
  210. ble cr0,.LMoveDone
  211. { load the begin of the source in the data cache }
  212. dcbt 0,r3
  213. { and the dest as well }
  214. dcbtst 0,r4
  215. { if overlap, then r0 := count else r0 := 0 }
  216. and r0,r5,r10
  217. { if overlap, then point source and dest to the end }
  218. add r3,r3,r0
  219. add r4,r4,r0
  220. { if overlap, then r6 := 0, else r6 := -1 }
  221. not r6,r10
  222. { if overlap, then r10 := -2, else r10 := 0 }
  223. slwi r10,r10,1
  224. { if overlap, then r10 := -1, else r10 := 1 }
  225. addi r10,r10,1
  226. { if count < 15, copy everything byte by byte }
  227. blt cr1,.LMoveBytes
  228. { if no overlap, then source/dest += -1, otherwise they stay }
  229. { After the next instruction, r3/r4 + r10 = next position to }
  230. { load/store from/to }
  231. add r3,r3,r6
  232. add r4,r4,r6
  233. { otherwise, guarantee 4 byte alignment for dest for starters }
  234. .LMove4ByteAlignLoop:
  235. lbzux r0,r3,r10
  236. stbux r0,r4,r10
  237. { is dest now 4 aligned? }
  238. andi. r0,r4,3
  239. subi r5,r5,1
  240. { while not aligned, continue }
  241. bne cr0,.LMove4ByteAlignLoop
  242. {$ifndef ppc603}
  243. { check for 32 byte alignment }
  244. andi. r7,r4,31
  245. {$endif non ppc603}
  246. { we are going to copy one byte again (the one at the newly }
  247. { aligned address), so increase count byte 1 }
  248. addi r5,r5,1
  249. { count div 4 for number of dwords to copy }
  250. srwi r0,r5,2
  251. { if 11 <= count < 63, copy using dwords }
  252. blt cr7,.LMoveDWords
  253. {$ifndef ppc603}
  254. { # of dwords to copy to reach 32 byte alignment (*4) }
  255. { (depends on forward/backward copy) }
  256. { if forward copy, r6 = -1 -> r8 := 32 }
  257. { if backward copy, r6 = 0 -> r8 := 0 }
  258. rlwinm r8,r6,0,31-6+1,31-6+1
  259. { if forward copy, we have to copy 32 - unaligned count bytes }
  260. { if backward copy unaligned count bytes }
  261. sub r7,r8,r7
  262. { if backward copy, the calculated value is now negate -> }
  263. { make it positive again }
  264. not r8, r6
  265. add r7, r7, r8
  266. xor r7, r7, r8
  267. {$endif not ppc603}
  268. { multiply the update count with 4 }
  269. slwi r10,r10,2
  270. slwi r6,r6,2
  271. { and adapt the source and dest }
  272. add r3,r3,r6
  273. add r4,r4,r6
  274. {$ifndef ppc603}
  275. beq cr0,.LMove32BytesAligned
  276. .L32BytesAlignMoveLoop:
  277. { count >= 39 -> align to 8 byte boundary and then use the FPU }
  278. { since we're already at 4 byte alignment, use dword store }
  279. subic. r7,r7,4
  280. lwzux r0,r3,r10
  281. subi r5,r5,4
  282. stwux r0,r4,r10
  283. bne .L32BytesAlignMoveLoop
  284. .LMove32BytesAligned:
  285. { count div 32 ( >= 1, since count was >=63 }
  286. srwi r0,r5,5
  287. { remainder }
  288. andi. r5,r5,31
  289. { to decide if we will do some dword stores (instead of only }
  290. { byte stores) afterwards or not }
  291. {$else not ppc603}
  292. srwi r0,r5,4
  293. andi. r5,r5,15
  294. {$endif not ppc603}
  295. cmpwi cr1,r5,11
  296. mtctr r0
  297. { r0 := count div 4, will be moved to ctr when copying dwords }
  298. srwi r0,r5,2
  299. {$ifndef ppc603}
  300. { adjust the update count: it will now be 8 or -8 depending on overlap }
  301. slwi r10,r10,1
  302. { adjust source and dest pointers: because of the above loop, dest is now }
  303. { aligned to 8 bytes. So if we add r6 we will still have an 8 bytes }
  304. { aligned address) }
  305. add r3,r3,r6
  306. add r4,r4,r6
  307. slwi r6,r6,1
  308. { the dcbz offset must give a 32 byte aligned address when added }
  309. { to the current dest address and its address must point to the }
  310. { bytes that will be overwritten in the current iteration. In case }
  311. { of a forward loop, the dest address has currently an offset of }
  312. { -8 compared to the bytes that will be overwritten (and r6 = -8). }
  313. { In case of a backward of a loop, the dest address currently has }
  314. { an offset of +32 compared to the bytes that will be overwritten }
  315. { (and r6 = 0). So the forward dcbz offset must become +8 and the }
  316. { backward -32 -> (-r6 * 5) - 32 gives the correct offset }
  317. slwi r7,r6,2
  318. add r7,r7,r6
  319. neg r7,r7
  320. subi r7,r7,32
  321. .LMove32ByteDcbz:
  322. lfdux f0,r3,r10
  323. lfdux f1,r3,r10
  324. lfdux f2,r3,r10
  325. lfdux f3,r3,r10
  326. { must be done only now, in case source and dest are less than }
  327. { 32 bytes apart! }
  328. dcbz r4,r7
  329. stfdux f0,r4,r10
  330. stfdux f1,r4,r10
  331. stfdux f2,r4,r10
  332. stfdux f3,r4,r10
  333. bdnz .LMove32ByteDcbz
  334. .LMove32ByteLoopDone:
  335. {$else not ppc603}
  336. .LMove16ByteLoop:
  337. lwzux r11,r3,r10
  338. lwzux r7,r3,r10
  339. lwzux r8,r3,r10
  340. lwzux r9,r3,r10
  341. stwux r11,r4,r10
  342. stwux r7,r4,r10
  343. stwux r8,r4,r10
  344. stwux r9,r4,r10
  345. bdnz .LMove16ByteLoop
  346. {$endif not ppc603}
  347. { cr0*4+eq is true if "count and 31" = 0 }
  348. beq cr0,.LMoveDone
  349. { make r10 again -1 or 1, but first adjust source/dest pointers }
  350. sub r3,r3,r6
  351. sub r4,r4,r6
  352. {$ifndef ppc603}
  353. srawi r10,r10,3
  354. srawi r6,r6,3
  355. {$else not ppc603}
  356. srawi r10,r10,2
  357. srawi r6,r6,2
  358. {$endif not ppc603}
  359. { cr1 contains whether count <= 11 }
  360. ble cr1,.LMoveBytes
  361. .LMoveDWords:
  362. mtctr r0
  363. andi. r5,r5,3
  364. { r10 * 4 }
  365. slwi r10,r10,2
  366. slwi r6,r6,2
  367. add r3,r3,r6
  368. add r4,r4,r6
  369. .LMoveDWordsLoop:
  370. lwzux r0,r3,r10
  371. stwux r0,r4,r10
  372. bdnz .LMoveDWordsLoop
  373. beq cr0,.LMoveDone
  374. { make r10 again -1 or 1 }
  375. sub r3,r3,r6
  376. sub r4,r4,r6
  377. srawi r10,r10,2
  378. srawi r6,r6,2
  379. .LMoveBytes:
  380. add r3,r3,r6
  381. add r4,r4,r6
  382. mtctr r5
  383. .LMoveBytesLoop:
  384. lbzux r0,r3,r10
  385. stbux r0,r4,r10
  386. bdnz .LMoveBytesLoop
  387. .LMoveDone:
  388. end;
  389. {$endif FPC_SYSTEM_HAS_MOVE}
  390. {$ifndef FPC_SYSTEM_HAS_FILLCHAR}
  391. {$define FPC_SYSTEM_HAS_FILLCHAR}
  392. Procedure FillChar(var x;count:longint;value:byte);assembler;
  393. { input: x in r3, count in r4, value in r5 }
  394. {$ifndef FPC_ABI_AIX}
  395. { in the AIX ABI, we can use te red zone for temp storage, otherwise we have }
  396. { to explicitely allocate room }
  397. var
  398. temp : packed record
  399. case byte of
  400. 0: (l1,l2: longint);
  401. 1: (d: double);
  402. end;
  403. {$endif FPC_ABI_AIX}
  404. asm
  405. { no bytes? }
  406. cmpwi cr6,r4,0
  407. { less than 15 bytes? }
  408. cmpwi cr7,r4,15
  409. { less than 64 bytes? }
  410. cmpwi cr1,r4,64
  411. { fill r5 with ValueValueValueValue }
  412. rlwimi r5,r5,8,16,23
  413. { setup for aligning x to multiple of 4}
  414. rlwinm r10,r3,0,31-2+1,31
  415. rlwimi r5,r5,16,0,15
  416. ble cr6,.LFillCharDone
  417. { get the start of the data in the cache (and mark it as "will be }
  418. { modified") }
  419. dcbtst 0,r3
  420. subfic r10,r10,4
  421. blt cr7,.LFillCharVerySmall
  422. { just store 4 bytes instead of using a loop to align (there are }
  423. { plenty of other instructions now to keep the processor busy }
  424. { while it handles the (possibly unaligned) store) }
  425. stw r5,0(r3)
  426. { r3 := align(r3,4) }
  427. add r3,r3,r10
  428. { decrease count with number of bytes already stored }
  429. sub r4,r4,r10
  430. blt cr1,.LFillCharSmall
  431. { if we have to fill with 0 (which happens a lot), we can simply use }
  432. { dcbz for the most part, which is very fast, so make a special case }
  433. { for that }
  434. cmplwi cr1,r5,0
  435. { align to a multiple of 32 (and immediately check whether we aren't }
  436. { already 32 byte aligned) }
  437. rlwinm. r10,r3,0,31-5+1,31
  438. { setup r3 for using update forms of store instructions }
  439. subi r3,r3,4
  440. { get number of bytes to store }
  441. subfic r10,r10,32
  442. { if already 32byte aligned, skip align loop }
  443. beq .L32ByteAlignLoopDone
  444. { substract from the total count }
  445. sub r4,r4,r10
  446. .L32ByteAlignLoop:
  447. { we were already aligned to 4 byres, so this will count down to }
  448. { exactly 0 }
  449. subic. r10,r10,4
  450. stwu r5,4(r3)
  451. bne .L32ByteAlignLoop
  452. .L32ByteAlignLoopDone:
  453. { get the amount of 32 byte blocks }
  454. srwi r10,r4,5
  455. { and keep the rest in r4 (recording whether there is any rest) }
  456. rlwinm. r4,r4,0,31-5+1,31
  457. { move to ctr }
  458. mtctr r10
  459. { check how many rest there is (to decide whether we'll use }
  460. { FillCharSmall or FillCharVerySmall) }
  461. cmplwi cr7,r4,11
  462. { if filling with zero, only use dcbz }
  463. bne cr1, .LFillCharNoZero
  464. { make r3 point again to the actual store position }
  465. addi r3,r3,4
  466. .LFillCharDCBZLoop:
  467. dcbz 0,r3
  468. addi r3,r3,32
  469. bdnz .LFillCharDCBZLoop
  470. { if there was no rest, we're finished }
  471. beq .LFillCharDone
  472. b .LFillCharVerySmall
  473. .LFillCharNoZero:
  474. {$ifdef FPC_ABI_AIX}
  475. stw r5,-4(r1)
  476. stw r5,-8(r1)
  477. lfd f0,-8(r1)
  478. {$else FPC_ABI_AIX}
  479. stw r5,temp
  480. stw r5,temp+4
  481. lfd f0,temp
  482. {$endif FPC_ABI_AIX}
  483. { make r3 point to address-8, so we're able to use fp double stores }
  484. { with update (it's already -4 now) }
  485. subi r3,r3,4
  486. { load r10 with 8, so that dcbz uses the correct address }
  487. li r10, 8
  488. .LFillChar32ByteLoop:
  489. dcbz r3,r10
  490. stfdu f0,8(r3)
  491. stfdu f0,8(r3)
  492. stfdu f0,8(r3)
  493. stfdu f0,8(r3)
  494. bdnz .LFillChar32ByteLoop
  495. { if there was no rest, we're finished }
  496. beq .LFillCharDone
  497. { make r3 point again to the actual next byte that must be written }
  498. addi r3,r3,8
  499. b .LFillCharVerySmall
  500. .LFillCharSmall:
  501. { when we arrive here, we're already 4 byte aligned }
  502. { get count div 4 to store dwords }
  503. srwi r10,r4,2
  504. { get ready for use of update stores }
  505. subi r3,r3,4
  506. mtctr r10
  507. rlwinm. r4,r4,0,31-2+1,31
  508. .LFillCharSmallLoop:
  509. stwu r5,4(r3)
  510. bdnz .LFillCharSmallLoop
  511. { if nothing left, stop }
  512. beq .LFillCharDone
  513. { get ready to store bytes }
  514. addi r3,r3,4
  515. .LFillCharVerySmall:
  516. mtctr r4
  517. subi r3,r3,1
  518. .LFillCharVerySmallLoop:
  519. stbu r5,1(r3)
  520. bdnz .LFillCharVerySmallLoop
  521. .LFillCharDone:
  522. end;
  523. {$endif FPC_SYSTEM_HAS_FILLCHAR}
  524. {$ifndef FPC_SYSTEM_HAS_FILLDWORD}
  525. {$define FPC_SYSTEM_HAS_FILLDWORD}
  526. procedure filldword(var x;count : longint;value : dword);
  527. assembler; nostackframe;
  528. asm
  529. { registers:
  530. r3 x
  531. r4 count
  532. r5 value
  533. }
  534. cmpwi cr0,r4,0
  535. mtctr r4
  536. subi r3,r3,4
  537. ble .LFillDWordEnd //if count<=0 Then Exit
  538. .LFillDWordLoop:
  539. stwu r5,4(r3)
  540. bdnz .LFillDWordLoop
  541. .LFillDWordEnd:
  542. end;
  543. {$endif FPC_SYSTEM_HAS_FILLDWORD}
  544. {$ifndef FPC_SYSTEM_HAS_INDEXBYTE}
  545. {$define FPC_SYSTEM_HAS_INDEXBYTE}
  546. function IndexByte(const buf;len:longint;b:byte):longint; assembler; nostackframe;
  547. { input: r3 = buf, r4 = len, r5 = b }
  548. { output: r3 = position of b in buf (-1 if not found) }
  549. asm
  550. { load the begin of the buffer in the data cache }
  551. dcbt 0,r3
  552. cmplwi r4,0
  553. mtctr r4
  554. subi r10,r3,1
  555. mr r0,r3
  556. { assume not found }
  557. li r3,-1
  558. ble .LIndexByteDone
  559. .LIndexByteLoop:
  560. lbzu r9,1(r10)
  561. cmplw r9,r5
  562. bdnzf cr0*4+eq,.LIndexByteLoop
  563. { r3 still contains -1 here }
  564. bne .LIndexByteDone
  565. sub r3,r10,r0
  566. .LIndexByteDone:
  567. end;
  568. {$endif FPC_SYSTEM_HAS_INDEXBYTE}
  569. {$ifndef FPC_SYSTEM_HAS_INDEXWORD}
  570. {$define FPC_SYSTEM_HAS_INDEXWORD}
  571. function IndexWord(const buf;len:longint;b:word):longint; assembler; nostackframe;
  572. { input: r3 = buf, r4 = len, r5 = b }
  573. { output: r3 = position of b in buf (-1 if not found) }
  574. asm
  575. { load the begin of the buffer in the data cache }
  576. dcbt 0,r3
  577. cmplwi r4,0
  578. mtctr r4
  579. subi r10,r3,2
  580. mr r0,r3
  581. { assume not found }
  582. li r3,-1
  583. ble .LIndexWordDone
  584. .LIndexWordLoop:
  585. lhzu r9,2(r10)
  586. cmplw r9,r5
  587. bdnzf cr0*4+eq,.LIndexWordLoop
  588. { r3 still contains -1 here }
  589. bne .LIndexWordDone
  590. sub r3,r10,r0
  591. srawi r3,r3,1
  592. .LIndexWordDone:
  593. end;
  594. {$endif FPC_SYSTEM_HAS_INDEXWORD}
  595. {$ifndef FPC_SYSTEM_HAS_INDEXDWORD}
  596. {$define FPC_SYSTEM_HAS_INDEXDWORD}
  597. function IndexDWord(const buf;len:longint;b:DWord):longint; assembler; nostackframe;
  598. { input: r3 = buf, r4 = len, r5 = b }
  599. { output: r3 = position of b in buf (-1 if not found) }
  600. asm
  601. { load the begin of the buffer in the data cache }
  602. dcbt 0,r3
  603. cmplwi r4,0
  604. mtctr r4
  605. subi r10,r3,4
  606. mr r0,r3
  607. { assume not found }
  608. li r3,-1
  609. ble .LIndexDWordDone
  610. .LIndexDWordLoop:
  611. lwzu r9,4(r10)
  612. cmplw r9,r5
  613. bdnzf cr0*4+eq, .LIndexDWordLoop
  614. { r3 still contains -1 here }
  615. bne .LIndexDWordDone
  616. sub r3,r10,r0
  617. srawi r3,r3,2
  618. .LIndexDWordDone:
  619. end;
  620. {$endif FPC_SYSTEM_HAS_INDEXDWORD}
  621. {$ifndef FPC_SYSTEM_HAS_COMPAREBYTE}
  622. {$define FPC_SYSTEM_HAS_COMPAREBYTE}
  623. function CompareByte(const buf1,buf2;len:longint):longint; assembler; nostackframe;
  624. { input: r3 = buf1, r4 = buf2, r5 = len }
  625. { output: r3 = 0 if equal, < 0 if buf1 < str2, > 0 if buf1 > str2 }
  626. { note: almost direct copy of strlcomp() from strings.inc }
  627. asm
  628. { load the begin of the first buffer in the data cache }
  629. dcbt 0,r3
  630. { use r0 instead of r3 for buf1 since r3 contains result }
  631. cmplwi r5,0
  632. mtctr r5
  633. subi r11,r3,1
  634. subi r4,r4,1
  635. li r3,0
  636. ble .LCompByteDone
  637. .LCompByteLoop:
  638. { load next chars }
  639. lbzu r9,1(r11)
  640. lbzu r10,1(r4)
  641. { calculate difference }
  642. sub. r3,r9,r10
  643. { if chars not equal or at the end, we're ready }
  644. bdnzt cr0*4+eq, .LCompByteLoop
  645. .LCompByteDone:
  646. end;
  647. {$endif FPC_SYSTEM_HAS_COMPAREBYTE}
  648. {$ifndef FPC_SYSTEM_HAS_COMPAREWORD}
  649. {$define FPC_SYSTEM_HAS_COMPAREWORD}
  650. function CompareWord(const buf1,buf2;len:longint):longint; assembler; nostackframe;
  651. { input: r3 = buf1, r4 = buf2, r5 = len }
  652. { output: r3 = 0 if equal, < 0 if buf1 < str2, > 0 if buf1 > str2 }
  653. { note: almost direct copy of strlcomp() from strings.inc }
  654. asm
  655. { load the begin of the first buffer in the data cache }
  656. dcbt 0,r3
  657. { use r0 instead of r3 for buf1 since r3 contains result }
  658. cmplwi r5,0
  659. mtctr r5
  660. subi r11,r3,2
  661. subi r4,r4,2
  662. li r3,0
  663. ble .LCompWordDone
  664. .LCompWordLoop:
  665. { load next chars }
  666. lhzu r9,2(r11)
  667. lhzu r10,2(r4)
  668. { calculate difference }
  669. sub. r3,r9,r10
  670. { if chars not equal or at the end, we're ready }
  671. bdnzt cr0*4+eq, .LCompWordLoop
  672. .LCompWordDone:
  673. end;
  674. {$endif FPC_SYSTEM_HAS_COMPAREWORD}
  675. {$ifndef FPC_SYSTEM_HAS_COMPAREDWORD}
  676. {$define FPC_SYSTEM_HAS_COMPAREDWORD}
  677. function CompareDWord(const buf1,buf2;len:longint):longint; assembler; nostackframe;
  678. { input: r3 = buf1, r4 = buf2, r5 = len }
  679. { output: r3 = 0 if equal, < 0 if buf1 < str2, > 0 if buf1 > str2 }
  680. { note: almost direct copy of strlcomp() from strings.inc }
  681. asm
  682. { load the begin of the first buffer in the data cache }
  683. dcbt 0,r3
  684. { use r0 instead of r3 for buf1 since r3 contains result }
  685. cmplwi r5,0
  686. mtctr r5
  687. subi r11,r3,4
  688. subi r4,r4,4
  689. li r3,0
  690. ble .LCompDWordDone
  691. .LCompDWordLoop:
  692. { load next chars }
  693. lwzu r9,4(r11)
  694. lwzu r10,4(r4)
  695. { calculate difference }
  696. sub. r3,r9,r10
  697. { if chars not equal or at the end, we're ready }
  698. bdnzt cr0*4+eq, .LCompDWordLoop
  699. .LCompDWordDone:
  700. end;
  701. {$endif FPC_SYSTEM_HAS_COMPAREDWORD}
  702. {$ifndef FPC_SYSTEM_HAS_INDEXCHAR0}
  703. {$define FPC_SYSTEM_HAS_INDEXCHAR0}
  704. function IndexChar0(const buf;len:longint;b:Char):longint; assembler; nostackframe;
  705. { input: r3 = buf, r4 = len, r5 = b }
  706. { output: r3 = position of found position (-1 if not found) }
  707. asm
  708. { load the begin of the buffer in the data cache }
  709. dcbt 0,r3
  710. { length = 0? }
  711. cmplwi r4,0
  712. mtctr r4
  713. subi r9,r3,1
  714. subi r0,r3,1
  715. { assume not found }
  716. li r3,-1
  717. { if yes, do nothing }
  718. ble .LIndexChar0Done
  719. .LIndexChar0Loop:
  720. lbzu r10,1(r9)
  721. cmplwi cr1,r10,0
  722. cmplw r10,r5
  723. beq cr1,.LIndexChar0Done
  724. bdnzf cr0*4+eq, .LIndexChar0Loop
  725. bne .LIndexChar0Done
  726. sub r3,r9,r0
  727. .LIndexChar0Done:
  728. end;
  729. {$endif FPC_SYSTEM_HAS_INDEXCHAR0}
  730. {****************************************************************************
  731. String
  732. ****************************************************************************}
  733. {$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
  734. {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
  735. function fpc_shortstr_to_shortstr(len:longint; const sstr: shortstring): shortstring; [public,alias: 'FPC_SHORTSTR_TO_SHORTSTR']; compilerproc;
  736. assembler; nostackframe;
  737. { input: r3: pointer to result, r4: len, r5: sstr }
  738. asm
  739. { load length source }
  740. lbz r10,0(r5)
  741. { load the begin of the dest buffer in the data cache }
  742. dcbtst 0,r3
  743. { put min(length(sstr),len) in r4 }
  744. subfc r7,r10,r4 { r0 := r4 - r10 }
  745. subfe r4,r4,r4 { if r3 >= r4 then r3' := 0 else r3' := -1 }
  746. and r7,r7,r4 { if r3 >= r4 then r3' := 0 else r3' := r3-r10 }
  747. add r4,r10,r7 { if r3 >= r4 then r3' := r10 else r3' := r3 }
  748. cmplwi r4,0
  749. { put length in ctr }
  750. mtctr r4
  751. stb r4,0(r3)
  752. beq .LShortStrCopyDone
  753. .LShortStrCopyLoop:
  754. lbzu r0,1(r5)
  755. stbu r0,1(r3)
  756. bdnz .LShortStrCopyLoop
  757. .LShortStrCopyDone:
  758. end;
  759. {$ifdef interncopy}
  760. procedure fpc_shortstr_assign(len:longint;sstr,dstr:pointer);[public,alias:'FPC_SHORTSTR_ASSIGN'];
  761. {$else}
  762. procedure fpc_shortstr_copy(len:longint;sstr,dstr:pointer);[public,alias:'FPC_SHORTSTR_COPY'];
  763. {$endif}
  764. assembler; nostackframe;
  765. { input: r3: len, r4: sstr, r5: dstr }
  766. asm
  767. { load length source }
  768. lbz r10,0(r4)
  769. { load the begin of the dest buffer in the data cache }
  770. dcbtst 0,r5
  771. { put min(length(sstr),len) in r3 }
  772. subc r0,r3,r10 { r0 := r3 - r10 }
  773. subfe r3,r3,r3 { if r3 >= r4 then r3' := 0 else r3' := -1 }
  774. and r3,r0,r3 { if r3 >= r4 then r3' := 0 else r3' := r3-r10 }
  775. add r3,r3,r10 { if r3 >= r4 then r3' := r10 else r3' := r3 }
  776. cmplwi r3,0
  777. { put length in ctr }
  778. mtctr r3
  779. stb r3,0(r5)
  780. beq .LShortStrCopyDone2
  781. .LShortStrCopyLoop2:
  782. lbzu r0,1(r4)
  783. stbu r0,1(r5)
  784. bdnz .LShortStrCopyLoop2
  785. .LShortStrCopyDone2:
  786. end;
  787. {$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
  788. (*
  789. {$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
  790. {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
  791. function fpc_shortstr_concat(const s1, s2: shortstring): shortstring; compilerproc; [public, alias: 'FPC_SHORTSTR_CONCAT'];
  792. { expects that (r3) contains a pointer to the result r4 to s1, r5 to s2 }
  793. assembler;
  794. asm
  795. { load length s1 }
  796. lbz r6, 0(r4)
  797. { load length s2 }
  798. lbz r10, 0(r5)
  799. { length 0 for s1? }
  800. cmplwi cr7,r6,0
  801. { length 255 for s1? }
  802. subfic. r7,r6,255
  803. { length 0 for s2? }
  804. cmplwi cr1,r10,0
  805. { calculate min(length(s2),255-length(s1)) }
  806. subc r8,r7,r10 { r8 := r7 - r10 }
  807. cror 4*6+2,4*1+2,4*7+2
  808. subfe r7,r7,r7 { if r7 >= r10 then r7' := 0 else r7' := -1 }
  809. mtctr r6
  810. and r7,r8,r7 { if r7 >= r10 then r7' := 0 else r7' := r7-r10 }
  811. add r7,r7,r10 { if r7 >= r10 then r7' := r10 else r7' := r7 }
  812. mr r9,r3
  813. { calculate length of final string }
  814. add r8,r7,r6
  815. stb r8,0(r3)
  816. beq cr7, .Lcopys1loopDone
  817. .Lcopys1loop:
  818. lbzu r0,1(r4)
  819. stbu r0,1(r9)
  820. bdnz .Lcopys1loop
  821. .Lcopys1loopDone:
  822. mtctr r7
  823. beq cr6, .LconcatDone
  824. .Lcopys2loop:
  825. lbzu r0,1(r5)
  826. stbu r0,1(r9)
  827. bdnz .Lcopys2loop
  828. end;
  829. {$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
  830. *)
  831. {$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
  832. {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
  833. procedure fpc_shortstr_append_shortstr(var s1: shortstring; const s2: shortstring); compilerproc;
  834. { expects that results (r3) contains a pointer to the current string s1, r4 }
  835. { high(s1) and (r5) a pointer to the one that has to be concatenated }
  836. assembler; nostackframe;
  837. asm
  838. { load length s1 }
  839. lbz r6, 0(r3)
  840. { load length s2 }
  841. lbz r10, 0(r5)
  842. { length 0? }
  843. cmplw cr1,r6,r4
  844. cmplwi r10,0
  845. { calculate min(length(s2),high(result)-length(result)) }
  846. sub r9,r4,r6
  847. subc r8,r9,r10 { r8 := r9 - r10 }
  848. cror 4*7+2,4*0+2,4*1+2
  849. subfe r9,r9,r9 { if r9 >= r10 then r9' := 0 else r9' := -1 }
  850. and r9,r8,r9 { if r9 >= r10 then r9' := 0 else r9' := r9-r10 }
  851. add r9,r9,r10 { if r9 >= r10 then r9' := r10 else r9' := r9 }
  852. { calculate new length }
  853. add r10,r6,r9
  854. { load value to copy in ctr }
  855. mtctr r9
  856. { store new length }
  857. stb r10,0(r3)
  858. { go to last current character of result }
  859. add r3,r6,r3
  860. { if nothing to do, exit }
  861. beq cr7, .LShortStrAppendDone
  862. { and concatenate }
  863. .LShortStrAppendLoop:
  864. lbzu r10,1(r5)
  865. stbu r10,1(r3)
  866. bdnz .LShortStrAppendLoop
  867. .LShortStrAppendDone:
  868. end;
  869. {$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
  870. (*
  871. {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
  872. function fpc_shortstr_compare(const dstr,sstr:shortstring): longint; [public,alias:'FPC_SHORTSTR_COMPARE']; compilerproc;
  873. assembler;
  874. asm
  875. { load length sstr }
  876. lbz r9,0(r4)
  877. { load length dstr }
  878. lbz r10,0(r3)
  879. { save their difference for later and }
  880. { calculate min(length(sstr),length(dstr)) }
  881. subfc r7,r10,r9 { r0 := r9 - r10 }
  882. subfe r9,r9,r9 { if r9 >= r10 then r9' := 0 else r9' := -1 }
  883. and r7,r7,r9 { if r9 >= r10 then r9' := 0 else r9' := r9-r8 }
  884. add r9,r10,r7 { if r9 >= r10 then r9' := r10 else r9' := r9 }
  885. { first compare dwords (length/4) }
  886. srwi. r5,r9,2
  887. { keep length mod 4 for the ends }
  888. rlwinm r9,r9,0,30,31
  889. { already check whether length mod 4 = 0 }
  890. cmplwi cr1,r9,0
  891. { so we can load r3 with 0, in case the strings both have length 0 }
  892. mr r8,r3
  893. li r3, 0
  894. { length div 4 in ctr for loop }
  895. mtctr r5
  896. { if length < 3, goto byte comparing }
  897. beq LShortStrCompare1
  898. { setup for use of update forms of load/store with dwords }
  899. subi r4,r4,3
  900. subi r8,r8,3
  901. LShortStrCompare4Loop:
  902. lwzu r3,4(r4)
  903. lwzu r10,4(r8)
  904. sub. r3,r3,r10
  905. bdnzt cr0+eq,LShortStrCompare4Loop
  906. { r3 contains result if we stopped because of "ne" flag }
  907. bne LShortStrCompareDone
  908. { setup for use of update forms of load/store with bytes }
  909. addi r4,r4,3
  910. addi r8,r8,3
  911. LShortStrCompare1:
  912. { if comparelen mod 4 = 0, skip this and return the difference in }
  913. { lengths }
  914. beq cr1,LShortStrCompareLen
  915. mtctr r9
  916. LShortStrCompare1Loop:
  917. lbzu r3,1(r4)
  918. lbzu r10,1(r8)
  919. sub. r3,r3,r10
  920. bdnzt cr0+eq,LShortStrCompare1Loop
  921. bne LShortStrCompareDone
  922. LShortStrCompareLen:
  923. { also return result in flags, maybe we can use this in the CG }
  924. mr. r3,r3
  925. LShortStrCompareDone:
  926. end;
  927. *)
  928. {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
  929. {$define FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
  930. function fpc_pchar_to_shortstr(p:pchar):shortstring;[public,alias:'FPC_PCHAR_TO_SHORTSTR']; compilerproc;
  931. assembler; nostackframe;
  932. {$include strpas.inc}
  933. {$endif FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
  934. {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
  935. {$define FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
  936. function fpc_pchar_length(p:pchar):longint;assembler;[public,alias:'FPC_PCHAR_LENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif} nostackframe;
  937. {$include strlen.inc}
  938. {$endif FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
  939. {$define FPC_SYSTEM_HAS_GET_FRAME}
  940. function get_frame:pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif} nostackframe;
  941. asm
  942. { all abi's I know use r1 as stack pointer }
  943. mr r3, r1
  944. end;
  945. {$define FPC_SYSTEM_HAS_GET_CALLER_ADDR}
  946. function get_caller_addr(framebp:pointer):pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif} nostackframe;
  947. asm
  948. cmplwi r3,0
  949. beq .Lcaller_addr_frame_null
  950. lwz r3,0(r3)
  951. cmplwi r3,0
  952. beq .Lcaller_addr_frame_null
  953. {$ifdef FPC_ABI_AIX}
  954. lwz r3,8(r3)
  955. {$else FPC_ABI_AIX}
  956. lwz r3,4(r3)
  957. {$endif FPC_ABI_AIX}
  958. .Lcaller_addr_frame_null:
  959. end;
  960. {$define FPC_SYSTEM_HAS_GET_CALLER_FRAME}
  961. function get_caller_frame(framebp:pointer):pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif} nostackframe;
  962. asm
  963. cmplwi r3,0
  964. beq .Lcaller_frame_null
  965. lwz r3,0(r3)
  966. .Lcaller_frame_null:
  967. end;
  968. {$define FPC_SYSTEM_HAS_ABS_LONGINT}
  969. function abs(l:longint):longint; assembler;{$ifndef INTERNCONSTINTF}[internconst:fpc_in_const_abs];{$endif}{$ifdef SYSTEMINLINE}inline;{$endif} nostackframe;
  970. asm
  971. srawi r0,r3,31
  972. add r3,r0,r3
  973. xor r3,r3,r0
  974. end;
  975. {****************************************************************************
  976. Math
  977. ****************************************************************************}
  978. {$define FPC_SYSTEM_HAS_ODD_LONGINT}
  979. function odd(l:longint):boolean;assembler;{$ifndef INTERNCONSTINTF}[internconst:fpc_in_const_odd];{$endif}{$ifdef SYSTEMINLINE}inline;{$endif} nostackframe;
  980. asm
  981. rlwinm r3,r3,0,31,31
  982. end;
  983. {$define FPC_SYSTEM_HAS_SQR_LONGINT}
  984. function sqr(l:longint):longint;assembler;{$ifndef INTERNCONSTINTF}[internconst:fpc_in_const_sqr];{$endif}{$ifdef SYSTEMINLINE}inline;{$endif} nostackframe;
  985. asm
  986. mullw r3,r3,r3
  987. end;
  988. {$define FPC_SYSTEM_HAS_SPTR}
  989. Function Sptr : Pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif} nostackframe;
  990. asm
  991. mr r3,r1
  992. end;
  993. {****************************************************************************
  994. Str()
  995. ****************************************************************************}
  996. { int_str: generic implementation is used for now }
  997. {****************************************************************************
  998. Multithreading
  999. ****************************************************************************}
  1000. { do a thread save inc/dec }
  1001. {$define FPC_SYSTEM_HAS_DECLOCKED_LONGINT}
  1002. function declocked(var l : longint) : boolean;assembler;nostackframe;
  1003. { input: address of l in r3 }
  1004. { output: boolean indicating whether l is zero after decrementing }
  1005. asm
  1006. .LDecLockedLoop:
  1007. lwarx r10,0,r3
  1008. subi r10,r10,1
  1009. stwcx. r10,0,r3
  1010. bne- .LDecLockedLoop
  1011. cntlzw r3,r10
  1012. srwi r3,r3,5
  1013. end;
  1014. {$define FPC_SYSTEM_HAS_INCLOCKED_LONGINT}
  1015. procedure inclocked(var l : longint);assembler;nostackframe;
  1016. asm
  1017. .LIncLockedLoop:
  1018. lwarx r10,0,r3
  1019. addi r10,r10,1
  1020. stwcx. r10,0,r3
  1021. bne- .LIncLockedLoop
  1022. end;
  1023. {
  1024. $Log$
  1025. Revision 1.73 2004-11-20 15:49:21 jonas
  1026. * some compilation fixes for powerpc after all the internconst and
  1027. internproc changes, still crashes with internalerror(88) for ppc1
  1028. on real2str.inc(193,39)
  1029. Revision 1.72 2004/11/08 08:54:51 jonas
  1030. * use "round to nearest" rounding mode again, just like C (affects
  1031. results of divisions as well)
  1032. Revision 1.71 2004/10/24 14:43:26 jonas
  1033. * fixed redzone usage in fillchar
  1034. Revision 1.70 2004/10/24 14:20:21 jonas
  1035. * fixed default rounding mode
  1036. Revision 1.69 2004/10/19 18:51:15 jonas
  1037. + "nostackframe" modifier, because the automatic detection in the
  1038. compiler to determine that a stack frame is not needed no longer works
  1039. Revision 1.68 2004/10/09 21:00:46 jonas
  1040. + cgenmath with libc math functions. Faster than the routines in genmath
  1041. and also have full double support (exp() only has support for values in
  1042. the single range in genmath, for example). Used in FPC_USE_LIBC is
  1043. defined
  1044. * several fixes to allow compilation with -dHASINLINE, but internalerrors
  1045. because of missing support for inlining assembler code
  1046. Revision 1.67 2004/05/01 17:02:37 jonas
  1047. * use some more string routines from libc if FPC_USE_LIBC is used
  1048. Revision 1.66 2004/04/29 20:00:47 peter
  1049. * inclocked_longint ifdef fixed
  1050. Revision 1.65 2004/01/11 11:10:07 jonas
  1051. + cgeneric.inc: implementations of rtl routines based on libc
  1052. * system.inc: include cgeneric.inc before powerpc.inc/i386.inc/... if
  1053. FPC_USE_LIBC is defined
  1054. * powerpc.inc, i386.inc: check whether the routines they implement aren't
  1055. implemented yet in another include file (cgeneric.inc)
  1056. Revision 1.64 2004/01/10 00:16:20 jonas
  1057. * fixed mtfsb0 instruction for assembler reader/writer
  1058. * fixed initialisation of fpscr register to avoid spurious SIGPFE's
  1059. (uses mtfsb0 instruction, so added extra define in options.pas to avoid
  1060. requiring to start with a cross compiler)
  1061. Revision 1.63 2004/01/03 19:46:29 jonas
  1062. * fixed syntax error caught by Mac OS X' as :)
  1063. Revision 1.62 2004/01/02 17:21:50 jonas
  1064. + fpc_cpuinit procedure to allow cpu/fpu initialisation before any unit
  1065. initialises
  1066. + fpu exceptions for invalid operations and division by zero enabled for
  1067. ppc
  1068. Revision 1.61 2003/12/28 21:06:56 jonas
  1069. * fixed fillchar for SYSV abi
  1070. Revision 1.60 2003/12/21 21:23:09 florian
  1071. * fixed compilation with sysv calling conventions
  1072. Revision 1.59 2003/12/09 20:08:30 jonas
  1073. * fixed buffer overflow bug in fpc_shortstr_append_shortstr in case
  1074. the result was already 255 characters long
  1075. Revision 1.58 2003/12/07 14:27:45 jonas
  1076. * fixed buffer overrun error in fillchar
  1077. Revision 1.57 2003/12/07 13:29:02 jonas
  1078. + added FPC_MOVE alias to move for open array support
  1079. Revision 1.56 2003/11/23 17:34:27 jonas
  1080. * fixed some label names
  1081. Revision 1.55 2003/11/15 19:01:27 florian
  1082. * fixed rtl to work with the integrated fpc ppc assembler reader
  1083. Revision 1.54 2003/09/14 20:33:28 jonas
  1084. * renamed sp to r1, gnu as doesn't understand sp
  1085. Revision 1.53 2003/09/06 10:44:41 olle
  1086. + Used macros ABI_AIX and ABI_SYSV exchanged to FPC_ABI_AIX and FPC_ABI_SYSV.
  1087. Revision 1.52 2003/08/24 20:47:49 olle
  1088. + added support for ABI_AIX in get_caller_addr
  1089. Revision 1.51 2003/06/14 12:41:08 jonas
  1090. * fixed compilation problems (removed unnecessary modified registers
  1091. lists from procedures)
  1092. Revision 1.50 2003/06/01 14:50:17 jonas
  1093. * fpc_shortstr_append_shortstr has to use high(s1) instead of 255 as
  1094. maxlen
  1095. + ppc version of fpc_shortstr_append_shortstr
  1096. Revision 1.49 2003/05/29 21:17:27 jonas
  1097. * compile with -dppc603 to not use unaligned float loads in move() and
  1098. g_concatcopy, because the 603 and 604 take an exception for those
  1099. (and netbsd doesn't even handle those in the kernel). There are
  1100. still some of those left that could cause problems though (e.g.
  1101. in the set helpers)
  1102. Revision 1.48 2003/05/29 14:32:54 jonas
  1103. * changed dcbst to dcbtst (former means "flush cache block to memory,
  1104. the latter means "I will soon store something to that cache block")
  1105. Revision 1.47 2003/05/29 12:14:02 jonas
  1106. * move() now uses dcbz if possible
  1107. Revision 1.46 2003/05/17 00:19:51 jonas
  1108. * fixed inclocked
  1109. Revision 1.45 2003/05/14 19:47:35 jonas
  1110. * fixed stupid bug in filldword
  1111. Revision 1.44 2003/05/13 20:39:26 florian
  1112. * uncommented shortstring compare, buggy
  1113. Revision 1.43 2003/05/12 19:39:33 jonas
  1114. * fixed final fillchar error (tfillchr passes now)
  1115. Revision 1.42 2003/05/12 19:00:50 jonas
  1116. * fixed bug in fillchar
  1117. Revision 1.41 2003/05/10 20:33:39 jonas
  1118. * fixed get_caller_frame and get_caller_addr
  1119. Revision 1.40 2003/05/10 17:33:06 jonas
  1120. * final (? :) fix to move, passes new tests/test/tmove test
  1121. Revision 1.39 2003/05/02 19:03:25 jonas
  1122. * fixed some bugs in move()
  1123. Revision 1.38 2003/04/27 16:24:44 jonas
  1124. - disabled fpc_shortstr_concat because it's called differently than that
  1125. routine is declared
  1126. Revision 1.37 2003/04/26 20:37:17 jonas
  1127. * fixed and re-enabled routines commented out by Florian :)
  1128. Revision 1.36 2003/04/26 17:46:49 florian
  1129. * commented out not working routines
  1130. * reactivated assembler fillchar
  1131. Revision 1.35 2003/04/26 17:35:15 jonas
  1132. * fixed FillChar
  1133. Revision 1.34 2003/04/26 12:05:10 florian
  1134. * removed object/class helpers, the compiler uses the generic ones
  1135. Revision 1.33 2003/04/26 11:55:52 florian
  1136. * fixed newlines
  1137. Revision 1.32 2003/04/23 21:04:48 florian
  1138. * fixed fpc_shortstr_to_shortstr
  1139. Revision 1.31 2003/03/17 14:30:11 peter
  1140. * changed address parameter/return values to pointer instead
  1141. of longint
  1142. Revision 1.30 2003/03/12 19:21:29 jonas
  1143. + implemented get_frame()
  1144. * fixed bug in IndexDWord()
  1145. Revision 1.29 2003/01/09 20:14:35 florian
  1146. * fixed helper declarations
  1147. Revision 1.28 2003/01/09 13:38:56 florian
  1148. * dec/inclocked got defines
  1149. Revision 1.27 2002/11/07 15:23:13 jonas
  1150. * always use code that was between 'ifdef mt', since that define is
  1151. deprecated now
  1152. Revision 1.26 2002/11/01 13:27:55 jonas
  1153. * changed "dcbtst r0,x" to "dcbtst 0,x"
  1154. Revision 1.25 2002/10/23 15:26:00 olle
  1155. * excluded saverestorereg for target macos
  1156. Revision 1.24 2002/10/20 13:40:55 jonas
  1157. * move/fill*/index*/comp* routines immediately exit if length is negative
  1158. Revision 1.23 2002/10/17 10:12:50 jonas
  1159. * fixed return value of declocked()
  1160. Revision 1.22 2002/10/05 14:20:16 peter
  1161. * fpc_pchar_length compilerproc and strlen alias
  1162. Revision 1.21 2002/10/02 18:21:52 peter
  1163. * Copy() changed to internal function calling compilerprocs
  1164. * FPC_SHORTSTR_COPY renamed to FPC_SHORTSTR_ASSIGN because of the
  1165. new copy functions
  1166. Revision 1.20 2002/09/10 21:30:34 jonas
  1167. * disabled powerpc-specific fpc_shortstr_concat for now, it was
  1168. completely wrong
  1169. Revision 1.19 2002/09/10 17:47:20 jonas
  1170. * fixed bug with concatting 0-length shortstrings
  1171. Revision 1.18 2002/09/07 16:01:26 peter
  1172. * old logs removed and tabs fixed
  1173. Revision 1.17 2002/08/31 21:29:57 florian
  1174. * several PC related fixes
  1175. Revision 1.16 2002/08/31 16:08:36 florian
  1176. * fixed undefined labels
  1177. Revision 1.15 2002/08/31 13:11:11 florian
  1178. * several fixes for Linux/PPC compilation
  1179. Revision 1.14 2002/08/18 22:11:10 florian
  1180. * fixed remaining assembler errors
  1181. Revision 1.13 2002/08/18 21:37:48 florian
  1182. * several errors in inline assembler fixed
  1183. Revision 1.12 2002/08/10 17:14:36 jonas
  1184. * various fixes, mostly changing the names of the modifies registers to
  1185. upper case since that seems to be required by the compiler
  1186. Revision 1.11 2002/07/30 17:29:53 florian
  1187. + dummy setjmp and longjmp added
  1188. + dummy implemtation of the destructor helper
  1189. Revision 1.10 2002/07/28 21:39:29 florian
  1190. * made abs a compiler proc if it is generic
  1191. Revision 1.9 2002/07/28 20:43:49 florian
  1192. * several fixes for linux/powerpc
  1193. * several fixes to MT
  1194. Revision 1.8 2002/07/26 15:45:56 florian
  1195. * changed multi threading define: it's MT instead of MTRTL
  1196. }