aasmcpu.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. {
  2. $Id$
  3. Copyright (c) 2003 by Florian Klaempfl
  4. Contains the assembler object for the ARM
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit aasmcpu;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cclasses,aasmtai,
  23. aasmbase,globals,verbose,
  24. cpubase,cpuinfo;
  25. const
  26. { "mov reg,reg" source operand number }
  27. O_MOV_SOURCE = 1;
  28. { "mov reg,reg" source operand number }
  29. O_MOV_DEST = 0;
  30. type
  31. taicpu = class(taicpu_abstract)
  32. oppostfix : TOpPostfix;
  33. roundingmode : troundingmode;
  34. procedure loadshifterop(opidx:longint;const so:tshifterop);
  35. constructor op_none(op : tasmop);
  36. constructor op_reg(op : tasmop;_op1 : tregister);
  37. constructor op_const(op : tasmop;_op1 : longint);
  38. constructor op_reg_reg(op : tasmop;_op1,_op2 : tregister);
  39. constructor op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
  40. constructor op_reg_const(op:tasmop; _op1: tregister; _op2: longint);
  41. constructor op_const_const(op : tasmop;_op1,_op2 : longint);
  42. constructor op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
  43. constructor op_reg_reg_const(op : tasmop;_op1,_op2 : tregister; _op3: Longint);
  44. constructor op_reg_reg_sym_ofs(op : tasmop;_op1,_op2 : tregister; _op3: tasmsymbol;_op3ofs: longint);
  45. constructor op_reg_reg_ref(op : tasmop;_op1,_op2 : tregister; const _op3: treference);
  46. constructor op_const_reg_reg(op : tasmop;_op1 : longint;_op2, _op3 : tregister);
  47. constructor op_const_reg_const(op : tasmop;_op1 : longint;_op2 : tregister;_op3 : longint);
  48. constructor op_reg_reg_shifterop(op : tasmop;_op1,_op2 : tregister;_op3 : tshifterop);
  49. constructor op_reg_reg_reg_reg(op : tasmop;_op1,_op2,_op3,_op4 : tregister);
  50. constructor op_reg_reg_reg_const_const(op : tasmop;_op1,_op2,_op3 : tregister;_op4,_op5 : Longint);
  51. constructor op_reg_reg_const_const_const(op : tasmop;_op1,_op2 : tregister;_op3,_op4,_op5 : Longint);
  52. { this is for Jmp instructions }
  53. constructor op_cond_sym(op : tasmop;cond:TAsmCond;_op1 : tasmsymbol);
  54. constructor op_const_const_sym(op : tasmop;_op1,_op2 : longint;_op3: tasmsymbol);
  55. constructor op_sym(op : tasmop;_op1 : tasmsymbol);
  56. constructor op_sym_ofs(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint);
  57. constructor op_reg_sym_ofs(op : tasmop;_op1 : tregister;_op2:tasmsymbol;_op2ofs : longint);
  58. constructor op_sym_ofs_ref(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint;const _op2 : treference);
  59. function is_nop: boolean; override;
  60. function is_move:boolean; override;
  61. function spill_registers(list:Taasmoutput;
  62. rgget:Trggetproc;
  63. rgunget:Trgungetproc;
  64. r:Tsupregset;
  65. var unusedregsint:Tsupregset;
  66. const spilltemplist:Tspill_temp_list):boolean; override;
  67. end;
  68. tai_align = class(tai_align_abstract)
  69. { nothing to add }
  70. end;
  71. procedure InitAsm;
  72. procedure DoneAsm;
  73. implementation
  74. uses
  75. cutils,rgobj;
  76. procedure taicpu.loadshifterop(opidx:longint;const so:tshifterop);
  77. begin
  78. if opidx>=ops then
  79. ops:=opidx+1;
  80. with oper[opidx] do
  81. begin
  82. if typ<>top_shifterop then
  83. new(shifterop);
  84. shifterop^:=so;
  85. typ:=top_shifterop;
  86. end;
  87. end;
  88. {*****************************************************************************
  89. taicpu Constructors
  90. *****************************************************************************}
  91. constructor taicpu.op_none(op : tasmop);
  92. begin
  93. inherited create(op);
  94. end;
  95. constructor taicpu.op_reg(op : tasmop;_op1 : tregister);
  96. begin
  97. inherited create(op);
  98. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  99. internalerror(2003031207);
  100. ops:=1;
  101. loadreg(0,_op1);
  102. end;
  103. constructor taicpu.op_const(op : tasmop;_op1 : longint);
  104. begin
  105. inherited create(op);
  106. ops:=1;
  107. loadconst(0,aword(_op1));
  108. end;
  109. constructor taicpu.op_reg_reg(op : tasmop;_op1,_op2 : tregister);
  110. begin
  111. inherited create(op);
  112. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  113. internalerror(2003031205);
  114. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  115. internalerror(2003031206);
  116. ops:=2;
  117. loadreg(0,_op1);
  118. loadreg(1,_op2);
  119. end;
  120. constructor taicpu.op_reg_const(op:tasmop; _op1: tregister; _op2: longint);
  121. begin
  122. inherited create(op);
  123. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  124. internalerror(2003031208);
  125. ops:=2;
  126. loadreg(0,_op1);
  127. loadconst(1,aword(_op2));
  128. end;
  129. constructor taicpu.op_reg_ref(op : tasmop;_op1 : tregister;const _op2 : treference);
  130. begin
  131. inherited create(op);
  132. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  133. internalerror(2003031210);
  134. ops:=2;
  135. loadreg(0,_op1);
  136. loadref(1,_op2);
  137. end;
  138. constructor taicpu.op_const_const(op : tasmop;_op1,_op2 : longint);
  139. begin
  140. inherited create(op);
  141. ops:=2;
  142. loadconst(0,aword(_op1));
  143. loadconst(1,aword(_op2));
  144. end;
  145. constructor taicpu.op_reg_reg_reg(op : tasmop;_op1,_op2,_op3 : tregister);
  146. begin
  147. inherited create(op);
  148. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  149. internalerror(2003031211);
  150. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  151. internalerror(2003031212);
  152. if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
  153. internalerror(2003031213);
  154. ops:=3;
  155. loadreg(0,_op1);
  156. loadreg(1,_op2);
  157. loadreg(2,_op3);
  158. end;
  159. constructor taicpu.op_reg_reg_const(op : tasmop;_op1,_op2 : tregister; _op3: Longint);
  160. begin
  161. inherited create(op);
  162. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  163. internalerror(2003031214);
  164. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  165. internalerror(2003031215);
  166. ops:=3;
  167. loadreg(0,_op1);
  168. loadreg(1,_op2);
  169. loadconst(2,aword(_op3));
  170. end;
  171. constructor taicpu.op_reg_reg_sym_ofs(op : tasmop;_op1,_op2 : tregister; _op3: tasmsymbol;_op3ofs: longint);
  172. begin
  173. inherited create(op);
  174. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  175. internalerror(2003031216);
  176. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  177. internalerror(2003031217);
  178. ops:=3;
  179. loadreg(0,_op1);
  180. loadreg(1,_op2);
  181. loadsymbol(0,_op3,_op3ofs);
  182. end;
  183. constructor taicpu.op_reg_reg_ref(op : tasmop;_op1,_op2 : tregister; const _op3: treference);
  184. begin
  185. inherited create(op);
  186. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  187. internalerror(2003031218);
  188. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  189. internalerror(2003031219);
  190. ops:=3;
  191. loadreg(0,_op1);
  192. loadreg(1,_op2);
  193. loadref(2,_op3);
  194. end;
  195. constructor taicpu.op_const_reg_reg(op : tasmop;_op1 : longint;_op2, _op3 : tregister);
  196. begin
  197. inherited create(op);
  198. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  199. internalerror(2003031221);
  200. if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
  201. internalerror(2003031220);
  202. ops:=3;
  203. loadconst(0,aword(_op1));
  204. loadreg(1,_op2);
  205. loadreg(2,_op3);
  206. end;
  207. constructor taicpu.op_const_reg_const(op : tasmop;_op1 : longint;_op2 : tregister;_op3 : longint);
  208. begin
  209. inherited create(op);
  210. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  211. internalerror(2003031222);
  212. ops:=3;
  213. loadconst(0,aword(_op1));
  214. loadreg(1,_op2);
  215. loadconst(2,aword(_op3));
  216. end;
  217. constructor taicpu.op_reg_reg_shifterop(op : tasmop;_op1,_op2 : tregister;_op3 : tshifterop);
  218. begin
  219. inherited create(op);
  220. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  221. internalerror(200308233);
  222. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  223. internalerror(200308233);
  224. ops:=3;
  225. loadreg(0,_op1);
  226. loadreg(1,_op2);
  227. loadshifterop(2,_op3);
  228. end;
  229. constructor taicpu.op_reg_reg_reg_reg(op : tasmop;_op1,_op2,_op3,_op4 : tregister);
  230. begin
  231. inherited create(op);
  232. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  233. internalerror(2003031223);
  234. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  235. internalerror(2003031224);
  236. if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
  237. internalerror(2003031225);
  238. if (_op4.enum = R_INTREGISTER) and (_op4.number = NR_NO) then
  239. internalerror(2003031226);
  240. ops:=4;
  241. loadreg(0,_op1);
  242. loadreg(1,_op2);
  243. loadreg(2,_op3);
  244. loadreg(3,_op4);
  245. end;
  246. constructor taicpu.op_reg_reg_reg_const_const(op : tasmop;_op1,_op2,_op3 : tregister;_op4,_op5 : Longint);
  247. begin
  248. inherited create(op);
  249. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  250. internalerror(2003031232);
  251. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  252. internalerror(2003031233);
  253. if (_op3.enum = R_INTREGISTER) and (_op3.number = NR_NO) then
  254. internalerror(2003031233);
  255. ops:=5;
  256. loadreg(0,_op1);
  257. loadreg(1,_op2);
  258. loadreg(2,_op3);
  259. loadconst(3,cardinal(_op4));
  260. loadconst(4,cardinal(_op5));
  261. end;
  262. constructor taicpu.op_reg_reg_const_const_const(op : tasmop;_op1,_op2 : tregister;_op3,_op4,_op5 : Longint);
  263. begin
  264. inherited create(op);
  265. if (_op1.enum = R_INTREGISTER) and (_op1.number = NR_NO) then
  266. internalerror(2003031232);
  267. if (_op2.enum = R_INTREGISTER) and (_op2.number = NR_NO) then
  268. internalerror(2003031233);
  269. ops:=5;
  270. loadreg(0,_op1);
  271. loadreg(1,_op2);
  272. loadconst(2,aword(_op3));
  273. loadconst(3,cardinal(_op4));
  274. loadconst(4,cardinal(_op5));
  275. end;
  276. constructor taicpu.op_cond_sym(op : tasmop;cond:TAsmCond;_op1 : tasmsymbol);
  277. begin
  278. inherited create(op);
  279. condition:=cond;
  280. ops:=1;
  281. loadsymbol(0,_op1,0);
  282. end;
  283. constructor taicpu.op_const_const_sym(op : tasmop;_op1,_op2 : longint; _op3: tasmsymbol);
  284. begin
  285. inherited create(op);
  286. ops:=3;
  287. loadconst(0,aword(_op1));
  288. loadconst(1,aword(_op2));
  289. loadsymbol(2,_op3,0);
  290. end;
  291. constructor taicpu.op_sym(op : tasmop;_op1 : tasmsymbol);
  292. begin
  293. inherited create(op);
  294. ops:=1;
  295. loadsymbol(0,_op1,0);
  296. end;
  297. constructor taicpu.op_sym_ofs(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint);
  298. begin
  299. inherited create(op);
  300. ops:=1;
  301. loadsymbol(0,_op1,_op1ofs);
  302. end;
  303. constructor taicpu.op_reg_sym_ofs(op : tasmop;_op1 : tregister;_op2:tasmsymbol;_op2ofs : longint);
  304. begin
  305. inherited create(op);
  306. ops:=2;
  307. loadreg(0,_op1);
  308. loadsymbol(1,_op2,_op2ofs);
  309. end;
  310. constructor taicpu.op_sym_ofs_ref(op : tasmop;_op1 : tasmsymbol;_op1ofs:longint;const _op2 : treference);
  311. begin
  312. inherited create(op);
  313. ops:=2;
  314. loadsymbol(0,_op1,_op1ofs);
  315. loadref(1,_op2);
  316. end;
  317. { ****************************** newra stuff *************************** }
  318. function taicpu.is_nop: boolean;
  319. begin
  320. { we don't insert any more nops than necessary }
  321. is_nop := false;
  322. end;
  323. function taicpu.is_move:boolean;
  324. begin
  325. is_move := opcode = A_MOV;
  326. end;
  327. function taicpu.spill_registers(list:Taasmoutput;
  328. rgget:Trggetproc;
  329. rgunget:Trgungetproc;
  330. r:Tsupregset;
  331. var unusedregsint:Tsupregset;
  332. const spilltemplist:Tspill_temp_list): boolean;
  333. function get_insert_pos(p:Tai;huntfor1,huntfor2,huntfor3:Tsuperregister):Tai;
  334. var back:Tsupregset;
  335. begin
  336. back:=unusedregsint;
  337. get_insert_pos:=p;
  338. while (p<>nil) and (p.typ=ait_regalloc) do
  339. begin
  340. {Rewind the register allocation.}
  341. if Tai_regalloc(p).allocation then
  342. include(unusedregsint,Tai_regalloc(p).reg.number shr 8)
  343. else
  344. begin
  345. exclude(unusedregsint,Tai_regalloc(p).reg.number shr 8);
  346. if Tai_regalloc(p).reg.number shr 8=huntfor1 then
  347. begin
  348. get_insert_pos:=Tai(p.previous);
  349. back:=unusedregsint;
  350. end;
  351. if Tai_regalloc(p).reg.number shr 8=huntfor2 then
  352. begin
  353. get_insert_pos:=Tai(p.previous);
  354. back:=unusedregsint;
  355. end;
  356. if Tai_regalloc(p).reg.number shr 8=huntfor3 then
  357. begin
  358. get_insert_pos:=Tai(p.previous);
  359. back:=unusedregsint;
  360. end;
  361. end;
  362. p:=Tai(p.previous);
  363. end;
  364. unusedregsint:=back;
  365. end;
  366. procedure forward_allocation(p:Tai);
  367. begin
  368. {Forward the register allocation again.}
  369. while (p<>self) do
  370. begin
  371. if p.typ<>ait_regalloc then
  372. internalerror(200305311);
  373. if Tai_regalloc(p).allocation then
  374. exclude(unusedregsint,Tai_regalloc(p).reg.number shr 8)
  375. else
  376. include(unusedregsint,Tai_regalloc(p).reg.number shr 8);
  377. p:=Tai(p.next);
  378. end;
  379. end;
  380. function decode_loadstore(op: tasmop; var counterpart: tasmop; wasload: boolean): boolean;
  381. begin
  382. result := true;
  383. wasload := true;
  384. case op of
  385. A_LDR:
  386. begin
  387. counterpart := A_STR;
  388. end;
  389. A_LDM:
  390. internalerror(2003070602);
  391. else
  392. result := false;
  393. end;
  394. end;
  395. var i:byte;
  396. supreg, reg1, reg2, reg3: Tsuperregister;
  397. helpreg:Tregister;
  398. helpins:Taicpu;
  399. op:Tasmop;
  400. pos:Tai;
  401. wasload: boolean;
  402. begin
  403. spill_registers:=false;
  404. if (ops = 2) and
  405. (oper[1].typ=top_ref) and
  406. { oper[1] can also be ref in case of "lis r3,symbol@ha" or so }
  407. decode_loadstore(opcode,op,wasload) then
  408. begin
  409. { the register that's being stored/loaded }
  410. supreg:=oper[0].reg.number shr 8;
  411. if supreg in r then
  412. begin
  413. // Example:
  414. // l?? r20d, 8(r1) ; r20d must be spilled into -60(r1)
  415. //
  416. // Change into:
  417. //
  418. // l?? r21d, 8(r1)
  419. // st? r21d, -60(r1)
  420. //
  421. // And:
  422. //
  423. // st? r20d, 8(r1) ; r20d must be spilled into -60(r1)
  424. //
  425. // Change into:
  426. //
  427. // l?? r21d, -60(r1)
  428. // st? r21d, 8(r1)
  429. pos := get_insert_pos(Tai(previous),oper[0].reg.number shr 8,
  430. oper[1].ref^.base.number shr 8,oper[1].ref^.index.number shr 8);
  431. rgget(list,pos,0,helpreg);
  432. spill_registers := true;
  433. if wasload then
  434. begin
  435. helpins := taicpu.op_reg_ref(opcode,helpreg,oper[1].ref^);
  436. loadref(1,spilltemplist[supreg]);
  437. opcode := op;
  438. end
  439. else
  440. helpins := taicpu.op_reg_ref(op,helpreg,spilltemplist[supreg]);
  441. if pos=nil then
  442. list.insertafter(helpins,list.first)
  443. else
  444. list.insertafter(helpins,pos.next);
  445. loadreg(0,helpreg);
  446. rgunget(list,helpins,helpreg);
  447. forward_allocation(tai(helpins.next));
  448. {$ifdef debugra}
  449. writeln('spilling!');
  450. list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
  451. {$endif debugra}
  452. end;
  453. { now the registers used in the reference }
  454. { a) base }
  455. supreg := oper[1].ref^.base.number shr 8;
  456. if supreg in r then
  457. begin
  458. if wasload then
  459. pos:=get_insert_pos(Tai(previous),oper[1].ref^.index.number shr 8,oper[0].reg.number shr 8,0)
  460. else
  461. pos:=get_insert_pos(Tai(previous),oper[1].ref^.index.number shr 8,0,0);
  462. rgget(list,pos,0,helpreg);
  463. spill_registers:=true;
  464. helpins:=Taicpu.op_reg_ref(A_LDR,helpreg,spilltemplist[supreg]);
  465. if pos=nil then
  466. list.insertafter(helpins,list.first)
  467. else
  468. list.insertafter(helpins,pos.next);
  469. oper[1].ref^.base:=helpreg;
  470. rgunget(list,helpins,helpreg);
  471. forward_allocation(Tai(helpins.next));
  472. {$ifdef debugra}
  473. writeln('spilling!');
  474. list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
  475. {$endif debugra}
  476. end;
  477. { b) index }
  478. supreg := oper[1].ref^.index.number shr 8;
  479. if supreg in r then
  480. begin
  481. if wasload then
  482. pos:=get_insert_pos(Tai(previous),oper[1].ref^.base.number shr 8,oper[0].reg.number shr 8,0)
  483. else
  484. pos:=get_insert_pos(Tai(previous),oper[1].ref^.base.number shr 8,0,0);
  485. rgget(list,pos,0,helpreg);
  486. spill_registers:=true;
  487. helpins:=Taicpu.op_reg_ref(A_LDR,helpreg,spilltemplist[supreg]);
  488. if pos=nil then
  489. list.insertafter(helpins,list.first)
  490. else
  491. list.insertafter(helpins,pos.next);
  492. oper[1].ref^.index:=helpreg;
  493. rgunget(list,helpins,helpreg);
  494. forward_allocation(Tai(helpins.next));
  495. {$ifdef debugra}
  496. writeln('spilling!');
  497. list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
  498. {$endif debugra}
  499. end;
  500. { load/store is done }
  501. exit;
  502. end;
  503. { all other instructions the compiler generates are the same (I hope): }
  504. { operand 0 is a register and is the destination, the others are sources }
  505. { and can be either registers or constants }
  506. { exception: branches (is_jmp isn't always set for them) }
  507. if oper[0].typ <> top_reg then
  508. exit;
  509. reg1 := oper[0].reg.number shr 8;
  510. if oper[1].typ = top_reg then
  511. reg2 := oper[1].reg.number shr 8
  512. else
  513. reg2 := 0;
  514. if (ops >= 3) and
  515. (oper[2].typ = top_reg) then
  516. reg3 := oper[2].reg.number shr 8
  517. else
  518. reg3 := 0;
  519. supreg:=reg1;
  520. if supreg in r then
  521. begin
  522. // Example:
  523. // add r20d, r21d, r22d ; r20d must be spilled into -60(r1)
  524. //
  525. // Change into:
  526. //
  527. // lwz r23d, -60(r1)
  528. // add r23d, r21d, r22d
  529. // stw r23d, -60(r1)
  530. pos := get_insert_pos(Tai(previous),reg1,reg2,reg3);
  531. rgget(list,pos,0,helpreg);
  532. spill_registers := true;
  533. helpins := taicpu.op_reg_ref(A_STR,helpreg,spilltemplist[supreg]);
  534. list.insertafter(helpins,self);
  535. helpins := taicpu.op_reg_ref(A_LDR,helpreg,spilltemplist[supreg]);
  536. if pos=nil then
  537. list.insertafter(helpins,list.first)
  538. else
  539. list.insertafter(helpins,pos.next);
  540. loadreg(0,helpreg);
  541. rgunget(list,helpins,helpreg);
  542. forward_allocation(tai(helpins.next));
  543. {$ifdef debugra}
  544. writeln('spilling!');
  545. list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
  546. {$endif debugra}
  547. end;
  548. for i := 1 to 2 do
  549. if (oper[i].typ = top_reg) then
  550. begin
  551. supreg:=oper[i].reg.number;
  552. if supreg in r then
  553. begin
  554. // Example:
  555. // add r20d, r21d, r22d ; r20d must be spilled into -60(r1)
  556. //
  557. // Change into:
  558. //
  559. // lwz r23d, -60(r1)
  560. // add r23d, r21d, r22d
  561. // stw r23d, -60(r1)
  562. pos := get_insert_pos(Tai(previous),reg1,reg2,reg3);
  563. rgget(list,pos,0,helpreg);
  564. spill_registers := true;
  565. helpins := taicpu.op_reg_ref(A_LDR,helpreg,spilltemplist[supreg]);
  566. if pos=nil then
  567. list.insertafter(helpins,list.first)
  568. else
  569. list.insertafter(helpins,pos.next);
  570. loadreg(i,helpreg);
  571. rgunget(list,helpins,helpreg);
  572. forward_allocation(tai(helpins.next));
  573. {$ifdef debugra}
  574. writeln('spilling!');
  575. list.insertafter(tai_comment.Create(strpnew('Spilling!')),helpins);
  576. {$endif debugra}
  577. end;
  578. end;
  579. end;
  580. procedure InitAsm;
  581. begin
  582. end;
  583. procedure DoneAsm;
  584. begin
  585. end;
  586. end.
  587. {
  588. $Log$
  589. Revision 1.6 2003-08-28 00:05:29 florian
  590. * today's arm patches
  591. Revision 1.5 2003/08/27 00:27:56 florian
  592. + same procedure as very day: today's work on arm
  593. Revision 1.4 2003/08/25 23:20:38 florian
  594. + started to implement FPU support for the ARM
  595. * fixed a lot of other things
  596. Revision 1.3 2003/08/24 12:27:26 florian
  597. * continued to work on the arm port
  598. Revision 1.2 2003/08/20 15:50:12 florian
  599. * more arm stuff
  600. Revision 1.1 2003/08/16 13:23:01 florian
  601. * several arm related stuff fixed
  602. }