powerpc.inc 43 KB

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