2
0

n386mat.pas 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  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. cgbase,pass_1,pass_2,
  51. ncon,
  52. cpubase,cpuinfo,
  53. cga,ncgutil,cgobj;
  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:=cg.getintregister(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. cg.ungetregister(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. cg.a_jmp_flags(exprasmlist,F_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. cg.ungetregister(exprasmlist,hreg1);
  125. cg.getexplicitregister(exprasmlist,NR_EAX);
  126. emit_reg_reg(A_MOV,S_L,hreg1,NR_EAX);
  127. cg.getexplicitregister(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:=cg.getintregister(exprasmlist,right.location.size);
  145. cg.a_load_loc_reg(exprasmlist,OS_32,right.location,hreg1);
  146. cg.ungetregister(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. cg.ungetregister(exprasmlist,NR_EDX);
  154. cg.ungetregister(exprasmlist,NR_EAX);
  155. location.register:=cg.getintregister(exprasmlist,OS_INT);
  156. emit_reg_reg(A_MOV,S_L,NR_EAX,location.register);
  157. end
  158. else
  159. begin
  160. cg.ungetregister(exprasmlist,NR_EAX);
  161. cg.ungetregister(exprasmlist,NR_EDX);
  162. location.register:=cg.getintregister(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 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. cg.getexplicitregister(exprasmlist,NR_ECX);
  240. cg.a_load_loc_reg(exprasmlist,OS_32,right.location,NR_ECX);
  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,NR_ECX);
  252. cg.a_jmp_flags(exprasmlist,F_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,NR_ECX);
  258. cg.a_jmp_flags(exprasmlist,F_L,l2);
  259. emit_const_reg(A_SUB,S_L,32,NR_ECX);
  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. cg.ungetregister(exprasmlist,NR_ECX);
  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. cg.getexplicitregister(exprasmlist,NR_ECX);
  301. cg.a_load_loc_reg(exprasmlist,OS_32,right.location,NR_ECX);
  302. { right operand is in ECX }
  303. cg.ungetregister(exprasmlist,NR_ECX);
  304. emit_reg_reg(op,S_L,NR_CL,location.register);
  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. hreg : tregister;
  344. begin
  345. secondpass(left);
  346. location_reset(location,LOC_MMXREGISTER,OS_NO);
  347. hreg:=cg.getmmxregister(exprasmlist,OS_M64);
  348. emit_reg_reg(A_PXOR,S_NO,hreg,hreg);
  349. case left.location.loc of
  350. LOC_MMXREGISTER:
  351. begin
  352. location.register:=left.location.register;
  353. end;
  354. LOC_CMMXREGISTER:
  355. begin
  356. location.register:=cg.getmmxregister(exprasmlist,OS_M64);
  357. emit_reg_reg(A_MOVQ,S_NO,left.location.register,location.register);
  358. end;
  359. LOC_REFERENCE,
  360. LOC_CREFERENCE:
  361. begin
  362. reference_release(exprasmlist,left.location.reference);
  363. location.register:=cg.getmmxregister(exprasmlist,OS_M64);
  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,hreg);
  390. cg.ungetregister(exprasmlist,hreg);
  391. emit_reg_reg(A_MOVQ,S_NO,hreg,location.register);
  392. end;
  393. {$endif SUPPORT_MMX}
  394. procedure ti386unaryminusnode.second_float;
  395. begin
  396. secondpass(left);
  397. location_reset(location,LOC_FPUREGISTER,def_cgsize(resulttype.def));
  398. case left.location.loc of
  399. LOC_REFERENCE,
  400. LOC_CREFERENCE:
  401. begin
  402. reference_release(exprasmlist,left.location.reference);
  403. location.register:=NR_ST;
  404. cg.a_loadfpu_ref_reg(exprasmlist,
  405. def_cgsize(left.resulttype.def),
  406. left.location.reference,location.register);
  407. emit_none(A_FCHS,S_NO);
  408. end;
  409. LOC_FPUREGISTER,
  410. LOC_CFPUREGISTER:
  411. begin
  412. { "load st,st" is ignored by the code generator }
  413. cg.a_loadfpu_reg_reg(exprasmlist,left.location.size,left.location.register,NR_ST);
  414. location.register:=NR_ST;
  415. emit_none(A_FCHS,S_NO);
  416. end;
  417. end;
  418. end;
  419. {*****************************************************************************
  420. TI386NOTNODE
  421. *****************************************************************************}
  422. procedure ti386notnode.second_boolean;
  423. var
  424. hl : tasmlabel;
  425. opsize : topsize;
  426. begin
  427. opsize:=def_opsize(resulttype.def);
  428. if left.expectloc=LOC_JUMP then
  429. begin
  430. location_reset(location,LOC_JUMP,OS_NO);
  431. hl:=truelabel;
  432. truelabel:=falselabel;
  433. falselabel:=hl;
  434. secondpass(left);
  435. maketojumpbool(exprasmlist,left,lr_load_regvars);
  436. hl:=truelabel;
  437. truelabel:=falselabel;
  438. falselabel:=hl;
  439. end
  440. else
  441. begin
  442. { the second pass could change the location of left }
  443. { if it is a register variable, so we've to do }
  444. { this before the case statement }
  445. secondpass(left);
  446. case left.expectloc of
  447. LOC_FLAGS :
  448. begin
  449. location_release(exprasmlist,left.location);
  450. location_reset(location,LOC_FLAGS,OS_NO);
  451. location.resflags:=left.location.resflags;
  452. inverse_flags(location.resflags);
  453. end;
  454. LOC_CONSTANT,
  455. LOC_REGISTER,
  456. LOC_CREGISTER,
  457. LOC_REFERENCE,
  458. LOC_CREFERENCE :
  459. begin
  460. location_force_reg(exprasmlist,left.location,def_cgsize(resulttype.def),true);
  461. location_release(exprasmlist,left.location);
  462. emit_reg_reg(A_TEST,opsize,left.location.register,left.location.register);
  463. location_reset(location,LOC_FLAGS,OS_NO);
  464. location.resflags:=F_E;
  465. end;
  466. else
  467. internalerror(200203224);
  468. end;
  469. end;
  470. end;
  471. {$ifdef SUPPORT_MMX}
  472. procedure ti386notnode.second_mmx;
  473. var hreg,r:Tregister;
  474. begin
  475. secondpass(left);
  476. location_reset(location,LOC_MMXREGISTER,OS_NO);
  477. r:=cg.getintregister(exprasmlist,OS_INT);
  478. emit_const_reg(A_MOV,S_L,longint($ffffffff),r);
  479. { load operand }
  480. case left.location.loc of
  481. LOC_MMXREGISTER:
  482. location_copy(location,left.location);
  483. LOC_CMMXREGISTER:
  484. begin
  485. location.register:=cg.getmmxregister(exprasmlist,OS_M64);
  486. emit_reg_reg(A_MOVQ,S_NO,left.location.register,location.register);
  487. end;
  488. LOC_REFERENCE,
  489. LOC_CREFERENCE:
  490. begin
  491. location_release(exprasmlist,left.location);
  492. location.register:=cg.getmmxregister(exprasmlist,OS_M64);
  493. emit_ref_reg(A_MOVQ,S_NO,left.location.reference,location.register);
  494. end;
  495. end;
  496. { load mask }
  497. hreg:=cg.getmmxregister(exprasmlist,OS_M64);
  498. emit_reg_reg(A_MOVD,S_NO,r,hreg);
  499. cg.ungetregister(exprasmlist,r);
  500. { lower 32 bit }
  501. emit_reg_reg(A_PXOR,S_D,hreg,location.register);
  502. { shift mask }
  503. emit_const_reg(A_PSLLQ,S_NO,32,hreg);
  504. { higher 32 bit }
  505. cg.ungetregister(exprasmlist,hreg);
  506. emit_reg_reg(A_PXOR,S_D,hreg,location.register);
  507. end;
  508. {$endif SUPPORT_MMX}
  509. begin
  510. cmoddivnode:=ti386moddivnode;
  511. cshlshrnode:=ti386shlshrnode;
  512. cunaryminusnode:=ti386unaryminusnode;
  513. cnotnode:=ti386notnode;
  514. end.
  515. {
  516. $Log$
  517. Revision 1.65 2003-10-10 17:48:14 peter
  518. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  519. * tregisteralloctor renamed to trgobj
  520. * removed rgobj from a lot of units
  521. * moved location_* and reference_* to cgobj
  522. * first things for mmx register allocation
  523. Revision 1.64 2003/10/09 21:31:37 daniel
  524. * Register allocator splitted, ans abstract now
  525. Revision 1.63 2003/10/01 20:34:49 peter
  526. * procinfo unit contains tprocinfo
  527. * cginfo renamed to cgbase
  528. * moved cgmessage to verbose
  529. * fixed ppc and sparc compiles
  530. Revision 1.62 2003/09/29 20:58:56 peter
  531. * optimized releasing of registers
  532. Revision 1.61 2003/09/28 21:48:20 peter
  533. * fix register leaks
  534. Revision 1.60 2003/09/03 15:55:01 peter
  535. * NEWRA branch merged
  536. Revision 1.59.2.2 2003/08/31 13:50:16 daniel
  537. * Remove sorting and use pregenerated indexes
  538. * Some work on making things compile
  539. Revision 1.59.2.1 2003/08/29 17:29:00 peter
  540. * next batch of updates
  541. Revision 1.59 2003/07/02 22:18:04 peter
  542. * paraloc splitted in callerparaloc,calleeparaloc
  543. * sparc calling convention updates
  544. Revision 1.58 2003/06/13 21:19:31 peter
  545. * current_procdef removed, use current_procinfo.procdef instead
  546. Revision 1.57 2003/06/03 21:11:09 peter
  547. * cg.a_load_* get a from and to size specifier
  548. * makeregsize only accepts newregister
  549. * i386 uses generic tcgnotnode,tcgunaryminus
  550. Revision 1.56 2003/06/03 13:01:59 daniel
  551. * Register allocator finished
  552. Revision 1.55 2003/05/31 15:04:31 peter
  553. * load_loc_reg update
  554. Revision 1.54 2003/05/22 21:32:29 peter
  555. * removed some unit dependencies
  556. Revision 1.53 2003/04/22 23:50:23 peter
  557. * firstpass uses expectloc
  558. * checks if there are differences between the expectloc and
  559. location.loc from secondpass in EXTDEBUG
  560. Revision 1.52 2003/04/22 14:33:38 peter
  561. * removed some notes/hints
  562. Revision 1.51 2003/04/22 10:09:35 daniel
  563. + Implemented the actual register allocator
  564. + Scratch registers unavailable when new register allocator used
  565. + maybe_save/maybe_restore unavailable when new register allocator used
  566. Revision 1.50 2003/04/21 19:15:26 peter
  567. * when ecx is not available allocated another register
  568. Revision 1.49 2003/04/17 10:02:48 daniel
  569. * Tweaked register allocate/deallocate positition to less interferences
  570. are generated.
  571. Revision 1.48 2003/03/28 19:16:57 peter
  572. * generic constructor working for i386
  573. * remove fixed self register
  574. * esi added as address register for i386
  575. Revision 1.47 2003/03/08 20:36:41 daniel
  576. + Added newra version of Ti386shlshrnode
  577. + Added interference graph construction code
  578. Revision 1.46 2003/03/08 13:59:17 daniel
  579. * Work to handle new register notation in ag386nsm
  580. + Added newra version of Ti386moddivnode
  581. Revision 1.45 2003/02/19 22:00:15 daniel
  582. * Code generator converted to new register notation
  583. - Horribily outdated todo.txt removed
  584. Revision 1.44 2003/01/13 18:37:44 daniel
  585. * Work on register conversion
  586. Revision 1.43 2003/01/13 14:54:34 daniel
  587. * Further work to convert codegenerator register convention;
  588. internalerror bug fixed.
  589. Revision 1.42 2003/01/08 18:43:57 daniel
  590. * Tregister changed into a record
  591. Revision 1.41 2002/11/25 17:43:26 peter
  592. * splitted defbase in defutil,symutil,defcmp
  593. * merged isconvertable and is_equal into compare_defs(_ext)
  594. * made operator search faster by walking the list only once
  595. Revision 1.40 2002/09/07 15:25:10 peter
  596. * old logs removed and tabs fixed
  597. Revision 1.39 2002/08/15 15:15:55 carl
  598. * jmpbuf size allocation for exceptions is now cpu specific (as it should)
  599. * more generic nodes for maths
  600. * several fixes for better m68k support
  601. Revision 1.38 2002/08/14 19:18:16 carl
  602. * bugfix of unaryminus node with left LOC_CREGISTER
  603. Revision 1.37 2002/08/12 15:08:42 carl
  604. + stab register indexes for powerpc (moved from gdb to cpubase)
  605. + tprocessor enumeration moved to cpuinfo
  606. + linker in target_info is now a class
  607. * many many updates for m68k (will soon start to compile)
  608. - removed some ifdef or correct them for correct cpu
  609. Revision 1.36 2002/08/11 14:32:30 peter
  610. * renamed current_library to objectlibrary
  611. Revision 1.35 2002/08/11 13:24:17 peter
  612. * saving of asmsymbols in ppu supported
  613. * asmsymbollist global is removed and moved into a new class
  614. tasmlibrarydata that will hold the info of a .a file which
  615. corresponds with a single module. Added librarydata to tmodule
  616. to keep the library info stored for the module. In the future the
  617. objectfiles will also be stored to the tasmlibrarydata class
  618. * all getlabel/newasmsymbol and friends are moved to the new class
  619. Revision 1.34 2002/08/02 07:44:31 jonas
  620. * made assigned() handling generic
  621. * add nodes now can also evaluate constant expressions at compile time
  622. that contain nil nodes
  623. Revision 1.33 2002/07/20 11:58:02 florian
  624. * types.pas renamed to defbase.pas because D6 contains a types
  625. unit so this would conflicts if D6 programms are compiled
  626. + Willamette/SSE2 instructions to assembler added
  627. Revision 1.32 2002/07/01 18:46:33 peter
  628. * internal linker
  629. * reorganized aasm layer
  630. Revision 1.31 2002/05/18 13:34:25 peter
  631. * readded missing revisions
  632. Revision 1.30 2002/05/16 19:46:51 carl
  633. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  634. + try to fix temp allocation (still in ifdef)
  635. + generic constructor calls
  636. + start of tassembler / tmodulebase class cleanup
  637. Revision 1.28 2002/05/13 19:54:38 peter
  638. * removed n386ld and n386util units
  639. * maybe_save/maybe_restore added instead of the old maybe_push
  640. Revision 1.27 2002/05/12 16:53:17 peter
  641. * moved entry and exitcode to ncgutil and cgobj
  642. * foreach gets extra argument for passing local data to the
  643. iterator function
  644. * -CR checks also class typecasts at runtime by changing them
  645. into as
  646. * fixed compiler to cycle with the -CR option
  647. * fixed stabs with elf writer, finally the global variables can
  648. be watched
  649. * removed a lot of routines from cga unit and replaced them by
  650. calls to cgobj
  651. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  652. u32bit then the other is typecasted also to u32bit without giving
  653. a rangecheck warning/error.
  654. * fixed pascal calling method with reversing also the high tree in
  655. the parast, detected by tcalcst3 test
  656. Revision 1.26 2002/04/04 19:06:12 peter
  657. * removed unused units
  658. * use tlocation.size in cg.a_*loc*() routines
  659. Revision 1.25 2002/04/02 17:11:36 peter
  660. * tlocation,treference update
  661. * LOC_CONSTANT added for better constant handling
  662. * secondadd splitted in multiple routines
  663. * location_force_reg added for loading a location to a register
  664. of a specified size
  665. * secondassignment parses now first the right and then the left node
  666. (this is compatible with Kylix). This saves a lot of push/pop especially
  667. with string operations
  668. * adapted some routines to use the new cg methods
  669. Revision 1.24 2002/03/31 20:26:39 jonas
  670. + a_loadfpu_* and a_loadmm_* methods in tcg
  671. * register allocation is now handled by a class and is mostly processor
  672. independent (+rgobj.pas and i386/rgcpu.pas)
  673. * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas)
  674. * some small improvements and fixes to the optimizer
  675. * some register allocation fixes
  676. * some fpuvaroffset fixes in the unary minus node
  677. * push/popusedregisters is now called rg.save/restoreusedregisters and
  678. (for i386) uses temps instead of push/pop's when using -Op3 (that code is
  679. also better optimizable)
  680. * fixed and optimized register saving/restoring for new/dispose nodes
  681. * LOC_FPU locations now also require their "register" field to be set to
  682. R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only)
  683. - list field removed of the tnode class because it's not used currently
  684. and can cause hard-to-find bugs
  685. Revision 1.23 2002/03/04 19:10:14 peter
  686. * removed compiler warnings
  687. }