n386mat.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate i386 assembler for math nodes
  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 n386mat;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,nmat,ncgmat;
  23. type
  24. ti386moddivnode = class(tmoddivnode)
  25. procedure pass_2;override;
  26. end;
  27. ti386shlshrnode = class(tshlshrnode)
  28. procedure pass_2;override;
  29. { everything will be handled in pass_2 }
  30. function first_shlshr64bitint: tnode; override;
  31. end;
  32. ti386unaryminusnode = class(tcgunaryminusnode)
  33. {$ifdef SUPPORT_MMX}
  34. procedure second_mmx;override;
  35. {$endif SUPPORT_MMX}
  36. procedure second_float;override;
  37. function pass_1:tnode;override;
  38. end;
  39. ti386notnode = class(tcgnotnode)
  40. procedure second_boolean;override;
  41. {$ifdef SUPPORT_MMX}
  42. procedure second_mmx;override;
  43. {$endif SUPPORT_MMX}
  44. end;
  45. implementation
  46. uses
  47. globtype,systems,
  48. cutils,verbose,globals,
  49. symconst,symdef,aasmbase,aasmtai,defutil,
  50. cginfo,cgbase,pass_1,pass_2,
  51. ncon,
  52. cpubase,cpuinfo,
  53. cga,tgobj,ncgutil,cgobj,rgobj;
  54. {*****************************************************************************
  55. TI386MODDIVNODE
  56. *****************************************************************************}
  57. procedure ti386moddivnode.pass_2;
  58. var hreg1,hreg2:Tregister;
  59. power:longint;
  60. hl:Tasmlabel;
  61. op:Tasmop;
  62. begin
  63. secondpass(left);
  64. if codegenerror then
  65. exit;
  66. secondpass(right);
  67. if codegenerror then
  68. exit;
  69. if is_64bitint(resulttype.def) then
  70. { should be handled in pass_1 (JM) }
  71. internalerror(200109052);
  72. { put numerator in register }
  73. location_reset(location,LOC_REGISTER,OS_INT);
  74. location_force_reg(exprasmlist,left.location,OS_INT,false);
  75. hreg1:=left.location.register;
  76. if (nodetype=divn) and (right.nodetype=ordconstn) and
  77. ispowerof2(tordconstnode(right).value,power) then
  78. begin
  79. { for signed numbers, the numerator must be adjusted before the
  80. shift instruction, but not wih unsigned numbers! Otherwise,
  81. "Cardinal($ffffffff) div 16" overflows! (JM) }
  82. if is_signed(left.resulttype.def) Then
  83. begin
  84. if (aktOptProcessor <> class386) and
  85. not(cs_littlesize in aktglobalswitches) then
  86. { use a sequence without jumps, saw this in
  87. comp.compilers (JM) }
  88. begin
  89. { no jumps, but more operations }
  90. hreg2:=rg.getregisterint(exprasmlist,OS_INT);
  91. emit_reg_reg(A_MOV,S_L,hreg1,hreg2);
  92. {If the left value is signed, hreg2=$ffffffff, otherwise 0.}
  93. emit_const_reg(A_SAR,S_L,31,hreg2);
  94. {If signed, hreg2=right value-1, otherwise 0.}
  95. emit_const_reg(A_AND,S_L,tordconstnode(right).value-1,hreg2);
  96. { add to the left value }
  97. emit_reg_reg(A_ADD,S_L,hreg2,hreg1);
  98. { release EDX if we used it }
  99. rg.ungetregisterint(exprasmlist,hreg2);
  100. { do the shift }
  101. emit_const_reg(A_SAR,S_L,power,hreg1);
  102. end
  103. else
  104. begin
  105. { a jump, but less operations }
  106. emit_reg_reg(A_TEST,S_L,hreg1,hreg1);
  107. objectlibrary.getlabel(hl);
  108. emitjmp(C_NS,hl);
  109. if power=1 then
  110. emit_reg(A_INC,S_L,hreg1)
  111. else
  112. emit_const_reg(A_ADD,S_L,tordconstnode(right).value-1,hreg1);
  113. cg.a_label(exprasmlist,hl);
  114. emit_const_reg(A_SAR,S_L,power,hreg1);
  115. end
  116. end
  117. else
  118. emit_const_reg(A_SHR,S_L,power,hreg1);
  119. location.register:=hreg1;
  120. end
  121. else
  122. begin
  123. {Bring denominator to a register.}
  124. rg.ungetregisterint(exprasmlist,hreg1);
  125. rg.getexplicitregisterint(exprasmlist,NR_EAX);
  126. emit_reg_reg(A_MOV,S_L,hreg1,NR_EAX);
  127. rg.getexplicitregisterint(exprasmlist,NR_EDX);
  128. {Sign extension depends on the left type.}
  129. if torddef(left.resulttype.def).typ=u32bit then
  130. emit_reg_reg(A_XOR,S_L,NR_EDX,NR_EDX)
  131. else
  132. emit_none(A_CDQ,S_NO);
  133. {Division depends on the right type.}
  134. if Torddef(right.resulttype.def).typ=u32bit then
  135. op:=A_DIV
  136. else
  137. op:=A_IDIV;
  138. if right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  139. emit_ref(op,S_L,right.location.reference)
  140. else if right.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
  141. emit_reg(op,S_L,right.location.register)
  142. else
  143. begin
  144. hreg1:=rg.getregisterint(exprasmlist,right.location.size);
  145. cg.a_load_loc_reg(exprasmlist,OS_32,right.location,hreg1);
  146. rg.ungetregisterint(exprasmlist,hreg1);
  147. emit_reg(op,S_L,hreg1);
  148. end;
  149. location_release(exprasmlist,right.location);
  150. {Copy the result into a new register. Release EAX & EDX.}
  151. if nodetype=divn then
  152. begin
  153. rg.ungetregisterint(exprasmlist,NR_EDX);
  154. rg.ungetregisterint(exprasmlist,NR_EAX);
  155. location.register:=rg.getregisterint(exprasmlist,OS_INT);
  156. emit_reg_reg(A_MOV,S_L,NR_EAX,location.register);
  157. end
  158. else
  159. begin
  160. rg.ungetregisterint(exprasmlist,NR_EAX);
  161. rg.ungetregisterint(exprasmlist,NR_EDX);
  162. location.register:=rg.getregisterint(exprasmlist,OS_INT);
  163. emit_reg_reg(A_MOV,S_L,NR_EDX,location.register);
  164. end;
  165. end;
  166. end;
  167. {*****************************************************************************
  168. TI386SHLRSHRNODE
  169. *****************************************************************************}
  170. function ti386shlshrnode.first_shlshr64bitint: tnode;
  171. begin
  172. result := nil;
  173. end;
  174. procedure ti386shlshrnode.pass_2;
  175. var hregister2,hregisterhigh,hregisterlow:Tregister;
  176. op:Tasmop;
  177. l1,l2,l3:Tasmlabel;
  178. begin
  179. secondpass(left);
  180. secondpass(right);
  181. { determine operator }
  182. if nodetype=shln then
  183. op:=A_SHL
  184. else
  185. op:=A_SHR;
  186. if is_64bitint(left.resulttype.def) then
  187. begin
  188. location_reset(location,LOC_REGISTER,OS_64);
  189. { load left operator in a register }
  190. location_force_reg(exprasmlist,left.location,OS_64,false);
  191. hregisterhigh:=left.location.registerhigh;
  192. hregisterlow:=left.location.registerlow;
  193. { shifting by a constant directly coded: }
  194. if (right.nodetype=ordconstn) then
  195. begin
  196. { shrd/shl works only for values <=31 !! }
  197. if Tordconstnode(right).value>31 then
  198. begin
  199. if nodetype=shln then
  200. begin
  201. emit_reg_reg(A_XOR,S_L,hregisterhigh,hregisterhigh);
  202. if ((tordconstnode(right).value and 31) <> 0) then
  203. emit_const_reg(A_SHL,S_L,tordconstnode(right).value and 31,
  204. hregisterlow);
  205. end
  206. else
  207. begin
  208. emit_reg_reg(A_XOR,S_L,hregisterlow,hregisterlow);
  209. if ((tordconstnode(right).value and 31) <> 0) then
  210. emit_const_reg(A_SHR,S_L,tordconstnode(right).value and 31,
  211. hregisterhigh);
  212. end;
  213. location.registerhigh:=hregisterlow;
  214. location.registerlow:=hregisterhigh;
  215. end
  216. else
  217. begin
  218. if nodetype=shln then
  219. begin
  220. emit_const_reg_reg(A_SHLD,S_L,tordconstnode(right).value and 31,
  221. hregisterlow,hregisterhigh);
  222. emit_const_reg(A_SHL,S_L,tordconstnode(right).value and 31,
  223. hregisterlow);
  224. end
  225. else
  226. begin
  227. emit_const_reg_reg(A_SHRD,S_L,tordconstnode(right).value and 31,
  228. hregisterhigh,hregisterlow);
  229. emit_const_reg(A_SHR,S_L,tordconstnode(right).value and 31,
  230. hregisterhigh);
  231. end;
  232. location.registerlow:=hregisterlow;
  233. location.registerhigh:=hregisterhigh;
  234. end;
  235. end
  236. else
  237. begin
  238. { load right operators in a register }
  239. hregister2:=rg.getexplicitregisterint(exprasmlist,NR_ECX);
  240. cg.a_load_loc_reg(exprasmlist,OS_32,right.location,hregister2);
  241. if right.location.loc<>LOC_CREGISTER then
  242. location_release(exprasmlist,right.location);
  243. { left operator is already in a register }
  244. { hence are both in a register }
  245. { is it in the case ECX ? }
  246. { the damned shift instructions work only til a count of 32 }
  247. { so we've to do some tricks here }
  248. objectlibrary.getlabel(l1);
  249. objectlibrary.getlabel(l2);
  250. objectlibrary.getlabel(l3);
  251. emit_const_reg(A_CMP,S_L,64,hregister2);
  252. emitjmp(C_L,l1);
  253. emit_reg_reg(A_XOR,S_L,hregisterlow,hregisterlow);
  254. emit_reg_reg(A_XOR,S_L,hregisterhigh,hregisterhigh);
  255. cg.a_jmp_always(exprasmlist,l3);
  256. cg.a_label(exprasmlist,l1);
  257. emit_const_reg(A_CMP,S_L,32,hregister2);
  258. emitjmp(C_L,l2);
  259. emit_const_reg(A_SUB,S_L,32,hregister2);
  260. if nodetype=shln then
  261. begin
  262. emit_reg_reg(A_SHL,S_L,NR_CL,hregisterlow);
  263. emit_reg_reg(A_MOV,S_L,hregisterlow,hregisterhigh);
  264. emit_reg_reg(A_XOR,S_L,hregisterlow,hregisterlow);
  265. cg.a_jmp_always(exprasmlist,l3);
  266. cg.a_label(exprasmlist,l2);
  267. emit_reg_reg_reg(A_SHLD,S_L,NR_CL,hregisterlow,hregisterhigh);
  268. emit_reg_reg(A_SHL,S_L,NR_CL,hregisterlow);
  269. end
  270. else
  271. begin
  272. emit_reg_reg(A_SHR,S_L,NR_CL,hregisterhigh);
  273. emit_reg_reg(A_MOV,S_L,hregisterhigh,hregisterlow);
  274. emit_reg_reg(A_XOR,S_L,hregisterhigh,hregisterhigh);
  275. cg.a_jmp_always(exprasmlist,l3);
  276. cg.a_label(exprasmlist,l2);
  277. emit_reg_reg_reg(A_SHRD,S_L,NR_CL,hregisterhigh,hregisterlow);
  278. emit_reg_reg(A_SHR,S_L,NR_CL,hregisterhigh);
  279. end;
  280. cg.a_label(exprasmlist,l3);
  281. rg.ungetregisterint(exprasmlist,hregister2);
  282. location.registerlow:=hregisterlow;
  283. location.registerhigh:=hregisterhigh;
  284. end;
  285. end
  286. else
  287. begin
  288. { load left operators in a register }
  289. location_copy(location,left.location);
  290. location_force_reg(exprasmlist,location,OS_INT,false);
  291. { shifting by a constant directly coded: }
  292. if (right.nodetype=ordconstn) then
  293. { l shl 32 should 0 imho, but neither TP nor Delphi do it in this way (FK)}
  294. emit_const_reg(op,S_L,tordconstnode(right).value and 31,location.register)
  295. else
  296. begin
  297. { load right operators in a ECX }
  298. if right.location.loc<>LOC_CREGISTER then
  299. location_release(exprasmlist,right.location);
  300. hregister2:=rg.getexplicitregisterint(exprasmlist,NR_ECX);
  301. cg.a_load_loc_reg(exprasmlist,OS_32,right.location,hregister2);
  302. { right operand is in ECX }
  303. emit_reg_reg(op,S_L,NR_CL,location.register);
  304. rg.ungetregisterint(exprasmlist,hregister2);
  305. end;
  306. end;
  307. end;
  308. {*****************************************************************************
  309. TI386UNARYMINUSNODE
  310. *****************************************************************************}
  311. function ti386unaryminusnode.pass_1 : tnode;
  312. begin
  313. result:=nil;
  314. firstpass(left);
  315. if codegenerror then
  316. exit;
  317. if (left.resulttype.def.deftype=floatdef) then
  318. begin
  319. if (registersfpu < 1) then
  320. registersfpu := 1;
  321. expectloc:=LOC_FPUREGISTER;
  322. end
  323. {$ifdef SUPPORT_MMX}
  324. else
  325. if (cs_mmx in aktlocalswitches) and
  326. is_mmx_able_array(left.resulttype.def) then
  327. begin
  328. registers32:=left.registers32;
  329. registersfpu:=left.registersfpu;
  330. registersmmx:=left.registersmmx;
  331. if (left.location.loc<>LOC_MMXREGISTER) and
  332. (registersmmx<1) then
  333. registersmmx:=1;
  334. end
  335. {$endif SUPPORT_MMX}
  336. else
  337. inherited pass_1;
  338. end;
  339. {$ifdef SUPPORT_MMX}
  340. procedure ti386unaryminusnode.second_mmx;
  341. var
  342. op : tasmop;
  343. begin
  344. secondpass(left);
  345. location_reset(location,LOC_MMXREGISTER,OS_NO);
  346. case left.location.loc of
  347. LOC_MMXREGISTER:
  348. begin
  349. location.register:=left.location.register;
  350. emit_reg_reg(A_PXOR,S_NO,NR_MM7,NR_MM7);
  351. end;
  352. LOC_CMMXREGISTER:
  353. begin
  354. location.register:=rg.getregistermm(exprasmlist);
  355. emit_reg_reg(A_PXOR,S_NO,NR_MM7,NR_MM7);
  356. emit_reg_reg(A_MOVQ,S_NO,left.location.register,location.register);
  357. end;
  358. LOC_REFERENCE,
  359. LOC_CREFERENCE:
  360. begin
  361. reference_release(exprasmlist,left.location.reference);
  362. location.register:=rg.getregistermm(exprasmlist);
  363. emit_reg_reg(A_PXOR,S_NO,NR_MM7,NR_MM7);
  364. emit_ref_reg(A_MOVQ,S_NO,left.location.reference,location.register);
  365. end;
  366. else
  367. internalerror(200203225);
  368. end;
  369. if cs_mmx_saturation in aktlocalswitches then
  370. case mmx_type(resulttype.def) of
  371. mmxs8bit:
  372. op:=A_PSUBSB;
  373. mmxu8bit:
  374. op:=A_PSUBUSB;
  375. mmxs16bit,mmxfixed16:
  376. op:=A_PSUBSW;
  377. mmxu16bit:
  378. op:=A_PSUBUSW;
  379. end
  380. else
  381. case mmx_type(resulttype.def) of
  382. mmxs8bit,mmxu8bit:
  383. op:=A_PSUBB;
  384. mmxs16bit,mmxu16bit,mmxfixed16:
  385. op:=A_PSUBW;
  386. mmxs32bit,mmxu32bit:
  387. op:=A_PSUBD;
  388. end;
  389. emit_reg_reg(op,S_NO,location.register,NR_MM7);
  390. emit_reg_reg(A_MOVQ,S_NO,NR_MM7,location.register);
  391. end;
  392. {$endif SUPPORT_MMX}
  393. procedure ti386unaryminusnode.second_float;
  394. begin
  395. secondpass(left);
  396. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  397. case left.location.loc of
  398. LOC_REFERENCE,
  399. LOC_CREFERENCE:
  400. begin
  401. reference_release(exprasmlist,left.location.reference);
  402. location.register:=NR_ST;
  403. cg.a_loadfpu_ref_reg(exprasmlist,
  404. def_cgsize(left.resulttype.def),
  405. left.location.reference,location.register);
  406. emit_none(A_FCHS,S_NO);
  407. end;
  408. LOC_FPUREGISTER,
  409. LOC_CFPUREGISTER:
  410. begin
  411. { "load st,st" is ignored by the code generator }
  412. cg.a_loadfpu_reg_reg(exprasmlist,left.location.size,left.location.register,NR_ST);
  413. location.register:=NR_ST;
  414. emit_none(A_FCHS,S_NO);
  415. end;
  416. end;
  417. end;
  418. {*****************************************************************************
  419. TI386NOTNODE
  420. *****************************************************************************}
  421. procedure ti386notnode.second_boolean;
  422. var
  423. hl : tasmlabel;
  424. opsize : topsize;
  425. begin
  426. opsize:=def_opsize(resulttype.def);
  427. if left.expectloc=LOC_JUMP then
  428. begin
  429. location_reset(location,LOC_JUMP,OS_NO);
  430. hl:=truelabel;
  431. truelabel:=falselabel;
  432. falselabel:=hl;
  433. secondpass(left);
  434. maketojumpbool(exprasmlist,left,lr_load_regvars);
  435. hl:=truelabel;
  436. truelabel:=falselabel;
  437. falselabel:=hl;
  438. end
  439. else
  440. begin
  441. { the second pass could change the location of left }
  442. { if it is a register variable, so we've to do }
  443. { this before the case statement }
  444. secondpass(left);
  445. case left.expectloc of
  446. LOC_FLAGS :
  447. begin
  448. location_release(exprasmlist,left.location);
  449. location_reset(location,LOC_FLAGS,OS_NO);
  450. location.resflags:=left.location.resflags;
  451. inverse_flags(location.resflags);
  452. end;
  453. LOC_CONSTANT,
  454. LOC_REGISTER,
  455. LOC_CREGISTER,
  456. LOC_REFERENCE,
  457. LOC_CREFERENCE :
  458. begin
  459. location_force_reg(exprasmlist,left.location,def_cgsize(resulttype.def),true);
  460. emit_reg_reg(A_TEST,opsize,left.location.register,left.location.register);
  461. location_release(exprasmlist,left.location);
  462. location_reset(location,LOC_FLAGS,OS_NO);
  463. location.resflags:=F_E;
  464. end;
  465. else
  466. internalerror(200203224);
  467. end;
  468. end;
  469. end;
  470. {$ifdef SUPPORT_MMX}
  471. procedure ti386notnode.second_mmx;
  472. var r:Tregister;
  473. begin
  474. secondpass(left);
  475. location_reset(location,LOC_MMXREGISTER,OS_NO);
  476. r:=rg.getregisterint(exprasmlist,OS_INT);
  477. emit_const_reg(A_MOV,S_L,longint($ffffffff),r);
  478. { load operand }
  479. case left.location.loc of
  480. LOC_MMXREGISTER:
  481. location_copy(location,left.location);
  482. LOC_CMMXREGISTER:
  483. begin
  484. location.register:=rg.getregistermm(exprasmlist);
  485. emit_reg_reg(A_MOVQ,S_NO,left.location.register,location.register);
  486. end;
  487. LOC_REFERENCE,
  488. LOC_CREFERENCE:
  489. begin
  490. location_release(exprasmlist,left.location);
  491. location.register:=rg.getregistermm(exprasmlist);
  492. emit_ref_reg(A_MOVQ,S_NO,left.location.reference,location.register);
  493. end;
  494. end;
  495. { load mask }
  496. emit_reg_reg(A_MOVD,S_NO,r,NR_MM7);
  497. rg.ungetregisterint(exprasmlist,r);
  498. { lower 32 bit }
  499. emit_reg_reg(A_PXOR,S_D,NR_MM7,location.register);
  500. { shift mask }
  501. emit_const_reg(A_PSLLQ,S_NO,32,NR_MM7);
  502. { higher 32 bit }
  503. emit_reg_reg(A_PXOR,S_D,NR_MM7,location.register);
  504. end;
  505. {$endif SUPPORT_MMX}
  506. begin
  507. cmoddivnode:=ti386moddivnode;
  508. cshlshrnode:=ti386shlshrnode;
  509. cunaryminusnode:=ti386unaryminusnode;
  510. cnotnode:=ti386notnode;
  511. end.
  512. {
  513. $Log$
  514. Revision 1.60 2003-09-03 15:55:01 peter
  515. * NEWRA branch merged
  516. Revision 1.59.2.2 2003/08/31 13:50:16 daniel
  517. * Remove sorting and use pregenerated indexes
  518. * Some work on making things compile
  519. Revision 1.59.2.1 2003/08/29 17:29:00 peter
  520. * next batch of updates
  521. Revision 1.59 2003/07/02 22:18:04 peter
  522. * paraloc splitted in callerparaloc,calleeparaloc
  523. * sparc calling convention updates
  524. Revision 1.58 2003/06/13 21:19:31 peter
  525. * current_procdef removed, use current_procinfo.procdef instead
  526. Revision 1.57 2003/06/03 21:11:09 peter
  527. * cg.a_load_* get a from and to size specifier
  528. * makeregsize only accepts newregister
  529. * i386 uses generic tcgnotnode,tcgunaryminus
  530. Revision 1.56 2003/06/03 13:01:59 daniel
  531. * Register allocator finished
  532. Revision 1.55 2003/05/31 15:04:31 peter
  533. * load_loc_reg update
  534. Revision 1.54 2003/05/22 21:32:29 peter
  535. * removed some unit dependencies
  536. Revision 1.53 2003/04/22 23:50:23 peter
  537. * firstpass uses expectloc
  538. * checks if there are differences between the expectloc and
  539. location.loc from secondpass in EXTDEBUG
  540. Revision 1.52 2003/04/22 14:33:38 peter
  541. * removed some notes/hints
  542. Revision 1.51 2003/04/22 10:09:35 daniel
  543. + Implemented the actual register allocator
  544. + Scratch registers unavailable when new register allocator used
  545. + maybe_save/maybe_restore unavailable when new register allocator used
  546. Revision 1.50 2003/04/21 19:15:26 peter
  547. * when ecx is not available allocated another register
  548. Revision 1.49 2003/04/17 10:02:48 daniel
  549. * Tweaked register allocate/deallocate positition to less interferences
  550. are generated.
  551. Revision 1.48 2003/03/28 19:16:57 peter
  552. * generic constructor working for i386
  553. * remove fixed self register
  554. * esi added as address register for i386
  555. Revision 1.47 2003/03/08 20:36:41 daniel
  556. + Added newra version of Ti386shlshrnode
  557. + Added interference graph construction code
  558. Revision 1.46 2003/03/08 13:59:17 daniel
  559. * Work to handle new register notation in ag386nsm
  560. + Added newra version of Ti386moddivnode
  561. Revision 1.45 2003/02/19 22:00:15 daniel
  562. * Code generator converted to new register notation
  563. - Horribily outdated todo.txt removed
  564. Revision 1.44 2003/01/13 18:37:44 daniel
  565. * Work on register conversion
  566. Revision 1.43 2003/01/13 14:54:34 daniel
  567. * Further work to convert codegenerator register convention;
  568. internalerror bug fixed.
  569. Revision 1.42 2003/01/08 18:43:57 daniel
  570. * Tregister changed into a record
  571. Revision 1.41 2002/11/25 17:43:26 peter
  572. * splitted defbase in defutil,symutil,defcmp
  573. * merged isconvertable and is_equal into compare_defs(_ext)
  574. * made operator search faster by walking the list only once
  575. Revision 1.40 2002/09/07 15:25:10 peter
  576. * old logs removed and tabs fixed
  577. Revision 1.39 2002/08/15 15:15:55 carl
  578. * jmpbuf size allocation for exceptions is now cpu specific (as it should)
  579. * more generic nodes for maths
  580. * several fixes for better m68k support
  581. Revision 1.38 2002/08/14 19:18:16 carl
  582. * bugfix of unaryminus node with left LOC_CREGISTER
  583. Revision 1.37 2002/08/12 15:08:42 carl
  584. + stab register indexes for powerpc (moved from gdb to cpubase)
  585. + tprocessor enumeration moved to cpuinfo
  586. + linker in target_info is now a class
  587. * many many updates for m68k (will soon start to compile)
  588. - removed some ifdef or correct them for correct cpu
  589. Revision 1.36 2002/08/11 14:32:30 peter
  590. * renamed current_library to objectlibrary
  591. Revision 1.35 2002/08/11 13:24:17 peter
  592. * saving of asmsymbols in ppu supported
  593. * asmsymbollist global is removed and moved into a new class
  594. tasmlibrarydata that will hold the info of a .a file which
  595. corresponds with a single module. Added librarydata to tmodule
  596. to keep the library info stored for the module. In the future the
  597. objectfiles will also be stored to the tasmlibrarydata class
  598. * all getlabel/newasmsymbol and friends are moved to the new class
  599. Revision 1.34 2002/08/02 07:44:31 jonas
  600. * made assigned() handling generic
  601. * add nodes now can also evaluate constant expressions at compile time
  602. that contain nil nodes
  603. Revision 1.33 2002/07/20 11:58:02 florian
  604. * types.pas renamed to defbase.pas because D6 contains a types
  605. unit so this would conflicts if D6 programms are compiled
  606. + Willamette/SSE2 instructions to assembler added
  607. Revision 1.32 2002/07/01 18:46:33 peter
  608. * internal linker
  609. * reorganized aasm layer
  610. Revision 1.31 2002/05/18 13:34:25 peter
  611. * readded missing revisions
  612. Revision 1.30 2002/05/16 19:46:51 carl
  613. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  614. + try to fix temp allocation (still in ifdef)
  615. + generic constructor calls
  616. + start of tassembler / tmodulebase class cleanup
  617. Revision 1.28 2002/05/13 19:54:38 peter
  618. * removed n386ld and n386util units
  619. * maybe_save/maybe_restore added instead of the old maybe_push
  620. Revision 1.27 2002/05/12 16:53:17 peter
  621. * moved entry and exitcode to ncgutil and cgobj
  622. * foreach gets extra argument for passing local data to the
  623. iterator function
  624. * -CR checks also class typecasts at runtime by changing them
  625. into as
  626. * fixed compiler to cycle with the -CR option
  627. * fixed stabs with elf writer, finally the global variables can
  628. be watched
  629. * removed a lot of routines from cga unit and replaced them by
  630. calls to cgobj
  631. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  632. u32bit then the other is typecasted also to u32bit without giving
  633. a rangecheck warning/error.
  634. * fixed pascal calling method with reversing also the high tree in
  635. the parast, detected by tcalcst3 test
  636. Revision 1.26 2002/04/04 19:06:12 peter
  637. * removed unused units
  638. * use tlocation.size in cg.a_*loc*() routines
  639. Revision 1.25 2002/04/02 17:11:36 peter
  640. * tlocation,treference update
  641. * LOC_CONSTANT added for better constant handling
  642. * secondadd splitted in multiple routines
  643. * location_force_reg added for loading a location to a register
  644. of a specified size
  645. * secondassignment parses now first the right and then the left node
  646. (this is compatible with Kylix). This saves a lot of push/pop especially
  647. with string operations
  648. * adapted some routines to use the new cg methods
  649. Revision 1.24 2002/03/31 20:26:39 jonas
  650. + a_loadfpu_* and a_loadmm_* methods in tcg
  651. * register allocation is now handled by a class and is mostly processor
  652. independent (+rgobj.pas and i386/rgcpu.pas)
  653. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  654. * some small improvements and fixes to the optimizer
  655. * some register allocation fixes
  656. * some fpuvaroffset fixes in the unary minus node
  657. * push/popusedregisters is now called rg.save/restoreusedregisters and
  658. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  659. also better optimizable)
  660. * fixed and optimized register saving/restoring for new/dispose nodes
  661. * LOC_FPU locations now also require their "register" field to be set to
  662. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  663. - list field removed of the tnode class because it's not used currently
  664. and can cause hard-to-find bugs
  665. Revision 1.23 2002/03/04 19:10:14 peter
  666. * removed compiler warnings
  667. }