nld.pas 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552
  1. {
  2. $Id$
  3. Copyright (c) 2000-2002 by Florian Klaempfl
  4. Type checking and register allocation for load/assignment 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 nld;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,
  23. {$ifdef state_tracking}
  24. nstate,
  25. {$endif}
  26. symconst,symppu,symbase,symtype,symsym,symdef;
  27. type
  28. tloadnode = class(tunarynode)
  29. symtableentry : tsym;
  30. symtableentryderef : tderef;
  31. symtable : tsymtable;
  32. procdef : tprocdef;
  33. procdefderef : tderef;
  34. constructor create(v : tsym;st : tsymtable);virtual;
  35. constructor create_procvar(v : tsym;d:tprocdef;st : tsymtable);virtual;
  36. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  37. procedure ppuwrite(ppufile:tcompilerppufile);override;
  38. procedure derefimpl;override;
  39. procedure set_mp(p:tnode);
  40. function getcopy : tnode;override;
  41. function pass_1 : tnode;override;
  42. function det_resulttype:tnode;override;
  43. procedure mark_write;override;
  44. function docompare(p: tnode): boolean; override;
  45. procedure printnodedata(var t:text);override;
  46. end;
  47. tloadnodeclass = class of tloadnode;
  48. { different assignment types }
  49. tassigntype = (at_normal,at_plus,at_minus,at_star,at_slash);
  50. tassignmentnode = class(tbinarynode)
  51. assigntype : tassigntype;
  52. constructor create(l,r : tnode);virtual;
  53. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  54. procedure ppuwrite(ppufile:tcompilerppufile);override;
  55. function getcopy : tnode;override;
  56. function pass_1 : tnode;override;
  57. function det_resulttype:tnode;override;
  58. {$ifdef state_tracking}
  59. function track_state_pass(exec_known:boolean):boolean;override;
  60. {$endif state_tracking}
  61. function docompare(p: tnode): boolean; override;
  62. end;
  63. tassignmentnodeclass = class of tassignmentnode;
  64. tarrayconstructorrangenode = class(tbinarynode)
  65. constructor create(l,r : tnode);virtual;
  66. function pass_1 : tnode;override;
  67. function det_resulttype:tnode;override;
  68. end;
  69. tarrayconstructorrangenodeclass = class of tarrayconstructorrangenode;
  70. tarrayconstructornode = class(tbinarynode)
  71. constructor create(l,r : tnode);virtual;
  72. function getcopy : tnode;override;
  73. function pass_1 : tnode;override;
  74. function det_resulttype:tnode;override;
  75. function docompare(p: tnode): boolean; override;
  76. procedure force_type(tt:ttype);
  77. end;
  78. tarrayconstructornodeclass = class of tarrayconstructornode;
  79. ttypenode = class(tnode)
  80. allowed : boolean;
  81. restype : ttype;
  82. constructor create(t : ttype);virtual;
  83. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  84. procedure ppuwrite(ppufile:tcompilerppufile);override;
  85. procedure derefimpl;override;
  86. function pass_1 : tnode;override;
  87. function det_resulttype:tnode;override;
  88. function docompare(p: tnode): boolean; override;
  89. end;
  90. ttypenodeclass = class of ttypenode;
  91. trttinode = class(tnode)
  92. l1,l2 : longint;
  93. rttitype : trttitype;
  94. rttidef : tstoreddef;
  95. rttidefderef : tderef;
  96. constructor create(def:tstoreddef;rt:trttitype);virtual;
  97. constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
  98. procedure ppuwrite(ppufile:tcompilerppufile);override;
  99. procedure derefimpl;override;
  100. function getcopy : tnode;override;
  101. function pass_1 : tnode;override;
  102. procedure pass_2;override;
  103. function det_resulttype:tnode;override;
  104. function docompare(p: tnode): boolean; override;
  105. end;
  106. trttinodeclass = class of trttinode;
  107. var
  108. cloadnode : tloadnodeclass;
  109. cassignmentnode : tassignmentnodeclass;
  110. carrayconstructorrangenode : tarrayconstructorrangenodeclass;
  111. carrayconstructornode : tarrayconstructornodeclass;
  112. ctypenode : ttypenodeclass;
  113. crttinode : trttinodeclass;
  114. procedure load_procvar_from_calln(var p1:tnode);
  115. function load_high_value_node(vs:tvarsym):tnode;
  116. function load_self_node:tnode;
  117. function load_result_node:tnode;
  118. function load_self_pointer_node:tnode;
  119. function load_vmt_pointer_node:tnode;
  120. function is_self_node(p:tnode):boolean;
  121. implementation
  122. uses
  123. cutils,verbose,globtype,globals,systems,
  124. symtable,paramgr,defutil,defcmp,
  125. htypechk,pass_1,
  126. ncon,ninl,ncnv,nmem,ncal,cpubase,rgobj,cginfo,cgbase
  127. ,symnot
  128. ;
  129. {*****************************************************************************
  130. Helpers
  131. *****************************************************************************}
  132. procedure load_procvar_from_calln(var p1:tnode);
  133. var
  134. p2 : tnode;
  135. begin
  136. if p1.nodetype<>calln then
  137. internalerror(200212251);
  138. { was it a procvar, then we simply remove the calln and
  139. reuse the right }
  140. if assigned(tcallnode(p1).right) then
  141. begin
  142. p2:=tcallnode(p1).right;
  143. tcallnode(p1).right:=nil;
  144. end
  145. else
  146. begin
  147. p2:=cloadnode.create_procvar(tcallnode(p1).symtableprocentry,
  148. tprocdef(tcallnode(p1).procdefinition),tcallnode(p1).symtableproc);
  149. { when the methodpointer is typen we've something like:
  150. tobject.create. Then only the address is needed of the
  151. method without a self pointer }
  152. if assigned(tcallnode(p1).methodpointer) and
  153. (tcallnode(p1).methodpointer.nodetype<>typen) then
  154. begin
  155. tloadnode(p2).set_mp(tcallnode(p1).methodpointer);
  156. tcallnode(p1).methodpointer:=nil;
  157. end;
  158. end;
  159. resulttypepass(p2);
  160. p1.free;
  161. p1:=p2;
  162. end;
  163. function load_high_value_node(vs:tvarsym):tnode;
  164. var
  165. srsym : tsym;
  166. srsymtable : tsymtable;
  167. begin
  168. result:=nil;
  169. srsymtable:=vs.owner;
  170. if vo_is_local_copy in vs.varoptions then
  171. begin
  172. { next symtable is always the para symtable }
  173. srsymtable:=srsymtable.next;
  174. if not(srsymtable.symtabletype in [parasymtable,inlineparasymtable]) then
  175. internalerror(200212171);
  176. end;
  177. srsym:=searchsymonlyin(srsymtable,'high'+vs.name);
  178. if assigned(srsym) then
  179. begin
  180. result:=cloadnode.create(srsym,srsymtable);
  181. resulttypepass(result);
  182. end
  183. else
  184. CGMessage(cg_e_illegal_expression);
  185. end;
  186. function load_self_node:tnode;
  187. var
  188. srsym : tsym;
  189. srsymtable : tsymtable;
  190. begin
  191. result:=nil;
  192. searchsym('self',srsym,srsymtable);
  193. if assigned(srsym) then
  194. begin
  195. result:=cloadnode.create(srsym,srsymtable);
  196. resulttypepass(result);
  197. end
  198. else
  199. CGMessage(cg_e_illegal_expression);
  200. end;
  201. function load_result_node:tnode;
  202. var
  203. srsym : tsym;
  204. srsymtable : tsymtable;
  205. begin
  206. result:=nil;
  207. searchsym('result',srsym,srsymtable);
  208. if assigned(srsym) then
  209. begin
  210. result:=cloadnode.create(srsym,srsymtable);
  211. resulttypepass(result);
  212. end
  213. else
  214. CGMessage(cg_e_illegal_expression);
  215. end;
  216. function load_self_pointer_node:tnode;
  217. var
  218. srsym : tsym;
  219. srsymtable : tsymtable;
  220. begin
  221. result:=nil;
  222. searchsym('self',srsym,srsymtable);
  223. if assigned(srsym) then
  224. begin
  225. result:=cloadnode.create(srsym,srsymtable);
  226. include(result.flags,nf_load_self_pointer);
  227. resulttypepass(result);
  228. end
  229. else
  230. CGMessage(cg_e_illegal_expression);
  231. end;
  232. function load_vmt_pointer_node:tnode;
  233. var
  234. srsym : tsym;
  235. srsymtable : tsymtable;
  236. begin
  237. result:=nil;
  238. searchsym('vmt',srsym,srsymtable);
  239. if assigned(srsym) then
  240. begin
  241. result:=cloadnode.create(srsym,srsymtable);
  242. resulttypepass(result);
  243. end
  244. else
  245. CGMessage(cg_e_illegal_expression);
  246. end;
  247. function is_self_node(p:tnode):boolean;
  248. begin
  249. is_self_node:=(p.nodetype=loadn) and
  250. (tloadnode(p).symtableentry.typ=varsym) and
  251. (vo_is_self in tvarsym(tloadnode(p).symtableentry).varoptions);
  252. end;
  253. {*****************************************************************************
  254. TLOADNODE
  255. *****************************************************************************}
  256. constructor tloadnode.create(v : tsym;st : tsymtable);
  257. begin
  258. inherited create(loadn,nil);
  259. if not assigned(v) then
  260. internalerror(200108121);
  261. symtableentry:=v;
  262. symtable:=st;
  263. procdef:=nil;
  264. end;
  265. constructor tloadnode.create_procvar(v : tsym;d:tprocdef;st : tsymtable);
  266. begin
  267. inherited create(loadn,nil);
  268. if not assigned(v) then
  269. internalerror(200108121);
  270. symtableentry:=v;
  271. symtable:=st;
  272. procdef:=d;
  273. end;
  274. constructor tloadnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  275. begin
  276. inherited ppuload(t,ppufile);
  277. ppufile.getderef(symtableentryderef);
  278. symtable:=nil;
  279. ppufile.getderef(procdefderef);
  280. end;
  281. procedure tloadnode.ppuwrite(ppufile:tcompilerppufile);
  282. begin
  283. inherited ppuwrite(ppufile);
  284. ppufile.putderef(symtableentry,symtableentryderef);
  285. ppufile.putderef(procdef,procdefderef);
  286. end;
  287. procedure tloadnode.derefimpl;
  288. begin
  289. inherited derefimpl;
  290. symtableentry:=tsym(symtableentryderef.resolve);
  291. symtable:=symtableentry.owner;
  292. procdef:=tprocdef(procdefderef.resolve);
  293. end;
  294. procedure tloadnode.set_mp(p:tnode);
  295. begin
  296. { typen nodes should not be set }
  297. if p.nodetype=typen then
  298. internalerror(200301042);
  299. left:=p;
  300. end;
  301. function tloadnode.getcopy : tnode;
  302. var
  303. n : tloadnode;
  304. begin
  305. n:=tloadnode(inherited getcopy);
  306. n.symtable:=symtable;
  307. n.symtableentry:=symtableentry;
  308. result:=n;
  309. end;
  310. function tloadnode.det_resulttype:tnode;
  311. begin
  312. result:=nil;
  313. { handle first absolute as it will replace the symtableentry }
  314. if symtableentry.typ=absolutesym then
  315. begin
  316. { force the resulttype to the type of the absolute }
  317. resulttype:=tabsolutesym(symtableentry).vartype;
  318. { replace the symtableentry when it points to a var, else
  319. we are finished }
  320. if (tabsolutesym(symtableentry).abstyp=tovar) then
  321. begin
  322. symtableentry:=tabsolutesym(symtableentry).ref;
  323. symtable:=symtableentry.owner;
  324. include(flags,nf_absolute);
  325. end
  326. else
  327. exit;
  328. end;
  329. case symtableentry.typ of
  330. constsym:
  331. begin
  332. if tconstsym(symtableentry).consttyp=constresourcestring then
  333. resulttype:=cansistringtype
  334. else
  335. internalerror(22799);
  336. end;
  337. varsym :
  338. begin
  339. inc(tvarsym(symtableentry).refs);
  340. { if it's refered by absolute then it's used }
  341. if nf_absolute in flags then
  342. tvarsym(symtableentry).varstate:=vs_used
  343. else
  344. begin
  345. { fix self type which is declared as voidpointer in the
  346. definition }
  347. if vo_is_self in tvarsym(symtableentry).varoptions then
  348. begin
  349. resulttype.setdef(tprocdef(symtableentry.owner.defowner)._class);
  350. if (po_classmethod in tprocdef(symtableentry.owner.defowner).procoptions) or
  351. (po_staticmethod in tprocdef(symtableentry.owner.defowner).procoptions) then
  352. resulttype.setdef(tclassrefdef.create(resulttype))
  353. else if is_object(resulttype.def) and
  354. (nf_load_self_pointer in flags) then
  355. resulttype.setdef(tpointerdef.create(resulttype));
  356. end
  357. else if vo_is_vmt in tvarsym(symtableentry).varoptions then
  358. begin
  359. resulttype.setdef(tprocdef(symtableentry.owner.defowner)._class);
  360. resulttype.setdef(tclassrefdef.create(resulttype));
  361. end
  362. else
  363. resulttype:=tvarsym(symtableentry).vartype;
  364. end;
  365. end;
  366. typedconstsym :
  367. if not(nf_absolute in flags) then
  368. resulttype:=ttypedconstsym(symtableentry).typedconsttype;
  369. procsym :
  370. begin
  371. if not assigned(procdef) then
  372. begin
  373. if Tprocsym(symtableentry).procdef_count>1 then
  374. CGMessage(parser_e_no_overloaded_procvars);
  375. procdef:=tprocsym(symtableentry).first_procdef;
  376. end;
  377. { the result is a procdef, addrn and proc_to_procvar
  378. typeconvn need this as resulttype so they know
  379. that the address needs to be returned }
  380. resulttype.setdef(procdef);
  381. { process methodpointer }
  382. if assigned(left) then
  383. resulttypepass(left);
  384. end;
  385. else
  386. internalerror(200104141);
  387. end;
  388. end;
  389. procedure Tloadnode.mark_write;
  390. begin
  391. include(flags,nf_write);
  392. end;
  393. function tloadnode.pass_1 : tnode;
  394. begin
  395. result:=nil;
  396. expectloc:=LOC_REFERENCE;
  397. registers32:=0;
  398. registersfpu:=0;
  399. {$ifdef SUPPORT_MMX}
  400. registersmmx:=0;
  401. {$endif SUPPORT_MMX}
  402. case symtableentry.typ of
  403. absolutesym :
  404. ;
  405. constsym:
  406. begin
  407. if tconstsym(symtableentry).consttyp=constresourcestring then
  408. begin
  409. include(current_procinfo.flags,pi_needs_implicit_finally);
  410. expectloc:=LOC_CREFERENCE;
  411. end;
  412. end;
  413. varsym :
  414. begin
  415. if (symtable.symtabletype in [parasymtable,localsymtable]) and
  416. (current_procdef.parast.symtablelevel>symtable.symtablelevel) then
  417. begin
  418. { if the variable is in an other stackframe then we need
  419. a register to dereference }
  420. if symtable.symtablelevel>normal_function_level then
  421. begin
  422. registers32:=1;
  423. { further, the variable can't be put into a register }
  424. tvarsym(symtableentry).varoptions:=
  425. tvarsym(symtableentry).varoptions-[vo_fpuregable,vo_regable];
  426. end;
  427. end;
  428. if (tvarsym(symtableentry).varspez=vs_const) then
  429. expectloc:=LOC_CREFERENCE;
  430. { we need a register for call by reference parameters }
  431. if (tvarsym(symtableentry).varspez in [vs_var,vs_out]) or
  432. ((tvarsym(symtableentry).varspez=vs_const) and
  433. paramanager.push_addr_param(tvarsym(symtableentry).vartype.def,pocall_none)) or
  434. { call by value open arrays are also indirect addressed }
  435. is_open_array(tvarsym(symtableentry).vartype.def) then
  436. registers32:=1;
  437. if ([vo_is_thread_var,vo_is_dll_var]*tvarsym(symtableentry).varoptions)<>[] then
  438. registers32:=1;
  439. { call to get address of threadvar }
  440. if (vo_is_thread_var in tvarsym(symtableentry).varoptions) then
  441. include(current_procinfo.flags,pi_do_call);
  442. if nf_write in flags then
  443. Tvarsym(symtableentry).trigger_notifications(vn_onwrite)
  444. else
  445. Tvarsym(symtableentry).trigger_notifications(vn_onread);
  446. { count variable references }
  447. if rg.t_times>1 then
  448. inc(tvarsym(symtableentry).refs,rg.t_times-1);
  449. end;
  450. typedconstsym :
  451. ;
  452. procsym :
  453. begin
  454. { method pointer ? }
  455. if assigned(left) then
  456. begin
  457. expectloc:=LOC_CREFERENCE;
  458. firstpass(left);
  459. registers32:=max(registers32,left.registers32);
  460. registersfpu:=max(registersfpu,left.registersfpu);
  461. {$ifdef SUPPORT_MMX}
  462. registersmmx:=max(registersmmx,left.registersmmx);
  463. {$endif SUPPORT_MMX}
  464. end;
  465. end;
  466. else
  467. internalerror(200104143);
  468. end;
  469. end;
  470. function tloadnode.docompare(p: tnode): boolean;
  471. begin
  472. docompare :=
  473. inherited docompare(p) and
  474. (symtableentry = tloadnode(p).symtableentry) and
  475. (symtable = tloadnode(p).symtable);
  476. end;
  477. procedure Tloadnode.printnodedata(var t:text);
  478. begin
  479. inherited printnodedata(t);
  480. writeln(t,printnodeindention,'symbol = ',symtableentry.name);
  481. end;
  482. {*****************************************************************************
  483. TASSIGNMENTNODE
  484. *****************************************************************************}
  485. constructor tassignmentnode.create(l,r : tnode);
  486. begin
  487. inherited create(assignn,l,r);
  488. l.mark_write;
  489. assigntype:=at_normal;
  490. end;
  491. constructor tassignmentnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  492. begin
  493. inherited ppuload(t,ppufile);
  494. assigntype:=tassigntype(ppufile.getbyte);
  495. end;
  496. procedure tassignmentnode.ppuwrite(ppufile:tcompilerppufile);
  497. begin
  498. inherited ppuwrite(ppufile);
  499. ppufile.putbyte(byte(assigntype));
  500. end;
  501. function tassignmentnode.getcopy : tnode;
  502. var
  503. n : tassignmentnode;
  504. begin
  505. n:=tassignmentnode(inherited getcopy);
  506. n.assigntype:=assigntype;
  507. getcopy:=n;
  508. end;
  509. function tassignmentnode.det_resulttype:tnode;
  510. var
  511. hp : tnode;
  512. useshelper : boolean;
  513. original_size : longint;
  514. begin
  515. result:=nil;
  516. resulttype:=voidtype;
  517. original_size := 0;
  518. { must be made unique }
  519. set_unique(left);
  520. resulttypepass(left);
  521. if is_ansistring(left.resulttype.def) then
  522. begin
  523. { fold <ansistring>:=<ansistring>+<char|shortstring|ansistring> }
  524. if (right.nodetype=addn) and
  525. left.isequal(tbinarynode(right).left) and
  526. { don't fold multiple concatenations else we could get trouble
  527. with multiple uses of s
  528. }
  529. (tbinarynode(right).left.nodetype<>addn) and
  530. (tbinarynode(right).right.nodetype<>addn) then
  531. begin
  532. { don't do a resulttypepass(right), since then the addnode }
  533. { may insert typeconversions that make this optimization }
  534. { opportunity quite difficult to detect (JM) }
  535. resulttypepass(tbinarynode(right).left);
  536. resulttypepass(tbinarynode(right).right);
  537. if (is_char(tbinarynode(right).right.resulttype.def) or
  538. is_shortstring(tbinarynode(right).right.resulttype.def) or
  539. is_ansistring(tbinarynode(right).right.resulttype.def)) then
  540. begin
  541. { remove property flag so it'll not trigger an error }
  542. exclude(left.flags,nf_isproperty);
  543. { generate call to helper }
  544. hp:=ccallparanode.create(tbinarynode(right).right,
  545. ccallparanode.create(left,nil));
  546. if is_char(tbinarynode(right).right.resulttype.def) then
  547. result:=ccallnode.createintern('fpc_ansistr_append_char',hp)
  548. else if is_shortstring(tbinarynode(right).right.resulttype.def) then
  549. result:=ccallnode.createintern('fpc_ansistr_append_shortstring',hp)
  550. else
  551. result:=ccallnode.createintern('fpc_ansistr_append_ansistring',hp);
  552. tbinarynode(right).right:=nil;
  553. left:=nil;
  554. exit;
  555. end;
  556. end;
  557. end
  558. else
  559. if is_shortstring(left.resulttype.def) then
  560. begin
  561. { fold <shortstring>:=<shortstring>+<shortstring>,
  562. <shortstring>+<char> is handled by an optimized node }
  563. if (right.nodetype=addn) and
  564. left.isequal(tbinarynode(right).left) and
  565. { don't fold multiple concatenations else we could get trouble
  566. with multiple uses of s }
  567. (tbinarynode(right).left.nodetype<>addn) and
  568. (tbinarynode(right).right.nodetype<>addn) then
  569. begin
  570. { don't do a resulttypepass(right), since then the addnode }
  571. { may insert typeconversions that make this optimization }
  572. { opportunity quite difficult to detect (JM) }
  573. resulttypepass(tbinarynode(right).left);
  574. resulttypepass(tbinarynode(right).right);
  575. if is_shortstring(tbinarynode(right).right.resulttype.def) then
  576. begin
  577. { remove property flag so it'll not trigger an error }
  578. exclude(left.flags,nf_isproperty);
  579. { generate call to helper }
  580. hp:=ccallparanode.create(tbinarynode(right).right,
  581. ccallparanode.create(left,nil));
  582. if is_shortstring(tbinarynode(right).right.resulttype.def) then
  583. result:=ccallnode.createintern('fpc_shortstr_append_shortstr',hp);
  584. tbinarynode(right).right:=nil;
  585. left:=nil;
  586. exit;
  587. end;
  588. end;
  589. end;
  590. resulttypepass(right);
  591. set_varstate(left,false);
  592. set_varstate(right,true);
  593. { set_funcret_is_valid(left); }
  594. if codegenerror then
  595. exit;
  596. { assignments to open arrays aren't allowed }
  597. if is_open_array(left.resulttype.def) then
  598. CGMessage(type_e_mismatch);
  599. { test if node can be assigned, properties are allowed }
  600. valid_for_assignment(left);
  601. { assigning nil to a dynamic array clears the array }
  602. if is_dynamic_array(left.resulttype.def) and
  603. (right.nodetype=niln) then
  604. begin
  605. hp:=ccallparanode.create(caddrnode.create
  606. (crttinode.create(tstoreddef(left.resulttype.def),initrtti)),
  607. ccallparanode.create(ctypeconvnode.create_explicit(left,voidpointertype),nil));
  608. result := ccallnode.createintern('fpc_dynarray_clear',hp);
  609. left:=nil;
  610. exit;
  611. end;
  612. { shortstring helpers can do the conversion directly,
  613. so treat them separatly }
  614. if (is_shortstring(left.resulttype.def)) then
  615. begin
  616. { test for s:=s+anything ... }
  617. { the problem is for
  618. s:=s+s+s;
  619. this is broken here !! }
  620. {$ifdef newoptimizations2}
  621. { the above is fixed now, but still problem with s := s + f(); if }
  622. { f modifies s (bad programming, so only enable if uncertain }
  623. { optimizations are on) (JM) }
  624. if (cs_UncertainOpts in aktglobalswitches) then
  625. begin
  626. hp := right;
  627. while hp.treetype=addn do
  628. hp:=hp.left;
  629. if left.docompare(hp) then
  630. begin
  631. concat_string:=true;
  632. hp:=right;
  633. while hp.treetype=addn do
  634. begin
  635. hp.use_strconcat:=true;
  636. hp:=hp.left;
  637. end;
  638. end;
  639. end;
  640. {$endif newoptimizations2}
  641. { insert typeconv, except for chars that are handled in
  642. secondpass and except for ansi/wide string that can
  643. be converted immediatly }
  644. if not(is_char(right.resulttype.def) or
  645. (right.resulttype.def.deftype=stringdef)) then
  646. inserttypeconv(right,left.resulttype);
  647. if right.resulttype.def.deftype=stringdef then
  648. begin
  649. useshelper:=true;
  650. { convert constant strings to shortstrings. But
  651. skip empty constant strings, that will be handled
  652. in secondpass }
  653. if (right.nodetype=stringconstn) then
  654. begin
  655. { verify if range fits within shortstring }
  656. { just emit a warning, delphi gives an }
  657. { error, only if the type definition of }
  658. { of the string is less < 255 characters }
  659. if not is_open_string(left.resulttype.def) and
  660. (tstringconstnode(right).len > tstringdef(left.resulttype.def).len) then
  661. cgmessage(type_w_string_too_long);
  662. inserttypeconv(right,left.resulttype);
  663. if (tstringconstnode(right).len=0) then
  664. useshelper:=false;
  665. end;
  666. if useshelper then
  667. begin
  668. hp:=ccallparanode.create
  669. (right,
  670. ccallparanode.create(cinlinenode.create
  671. (in_high_x,false,left.getcopy),nil));
  672. result:=ccallnode.createinternreturn('fpc_'+tstringdef(right.resulttype.def).stringtypname+'_to_shortstr',hp,left);
  673. left:=nil;
  674. right:=nil;
  675. exit;
  676. end;
  677. end;
  678. end
  679. else
  680. begin
  681. { get the size before the type conversion - check for all nodes }
  682. if assigned(right.resulttype.def) and (right.nodetype in [loadn,vecn,calln]) then
  683. original_size := right.resulttype.def.size;
  684. inserttypeconv(right,left.resulttype);
  685. end;
  686. { check if the assignment may cause a range check error }
  687. { if its not explicit, and only if the values are }
  688. { ordinals, enumdef and floatdef }
  689. if (right.nodetype = typeconvn) and
  690. not (nf_explicit in ttypeconvnode(right).flags) then
  691. begin
  692. if assigned(left.resulttype.def) and
  693. (left.resulttype.def.deftype in [enumdef,orddef,floatdef]) then
  694. begin
  695. if (original_size <> 0) and (left.resulttype.def.size < original_size) then
  696. begin
  697. if (cs_check_range in aktlocalswitches) then
  698. Message(type_w_smaller_possible_range_check)
  699. else
  700. Message(type_h_smaller_possible_range_check);
  701. end;
  702. end;
  703. end;
  704. { call helpers for interface }
  705. if is_interfacecom(left.resulttype.def) then
  706. begin
  707. hp:=ccallparanode.create(ctypeconvnode.create_explicit
  708. (right,voidpointertype),
  709. ccallparanode.create(ctypeconvnode.create_explicit
  710. (left,voidpointertype),nil));
  711. result:=ccallnode.createintern('fpc_intf_assign',hp);
  712. left:=nil;
  713. right:=nil;
  714. exit;
  715. end;
  716. { check if local proc/func is assigned to procvar }
  717. if right.resulttype.def.deftype=procvardef then
  718. test_local_to_procvar(tprocvardef(right.resulttype.def),left.resulttype.def);
  719. end;
  720. function tassignmentnode.pass_1 : tnode;
  721. begin
  722. result:=nil;
  723. expectloc:=LOC_VOID;
  724. firstpass(left);
  725. firstpass(right);
  726. { assignment to refcounted variable -> inc/decref }
  727. if (not is_class(left.resulttype.def) and
  728. left.resulttype.def.needs_inittable) then
  729. include(current_procinfo.flags,pi_do_call);
  730. if codegenerror then
  731. exit;
  732. registers32:=left.registers32+right.registers32;
  733. registersfpu:=max(left.registersfpu,right.registersfpu);
  734. {$ifdef SUPPORT_MMX}
  735. registersmmx:=max(left.registersmmx,right.registersmmx);
  736. {$endif SUPPORT_MMX}
  737. end;
  738. function tassignmentnode.docompare(p: tnode): boolean;
  739. begin
  740. docompare :=
  741. inherited docompare(p) and
  742. (assigntype = tassignmentnode(p).assigntype);
  743. end;
  744. {$ifdef state_tracking}
  745. function Tassignmentnode.track_state_pass(exec_known:boolean):boolean;
  746. var se:Tstate_entry;
  747. begin
  748. track_state_pass:=false;
  749. if exec_known then
  750. begin
  751. track_state_pass:=right.track_state_pass(exec_known);
  752. {Force a new resulttype pass.}
  753. right.resulttype.def:=nil;
  754. do_resulttypepass(right);
  755. resulttypepass(right);
  756. aktstate.store_fact(left.getcopy,right.getcopy);
  757. end
  758. else
  759. aktstate.delete_fact(left);
  760. end;
  761. {$endif}
  762. {*****************************************************************************
  763. TARRAYCONSTRUCTORRANGENODE
  764. *****************************************************************************}
  765. constructor tarrayconstructorrangenode.create(l,r : tnode);
  766. begin
  767. inherited create(arrayconstructorrangen,l,r);
  768. end;
  769. function tarrayconstructorrangenode.det_resulttype:tnode;
  770. begin
  771. result:=nil;
  772. resulttypepass(left);
  773. resulttypepass(right);
  774. set_varstate(left,true);
  775. set_varstate(right,true);
  776. if codegenerror then
  777. exit;
  778. resulttype:=left.resulttype;
  779. end;
  780. function tarrayconstructorrangenode.pass_1 : tnode;
  781. begin
  782. firstpass(left);
  783. firstpass(right);
  784. expectloc:=LOC_CREFERENCE;
  785. calcregisters(self,0,0,0);
  786. result:=nil;
  787. end;
  788. {****************************************************************************
  789. TARRAYCONSTRUCTORNODE
  790. *****************************************************************************}
  791. constructor tarrayconstructornode.create(l,r : tnode);
  792. begin
  793. inherited create(arrayconstructorn,l,r);
  794. end;
  795. function tarrayconstructornode.getcopy : tnode;
  796. var
  797. n : tarrayconstructornode;
  798. begin
  799. n:=tarrayconstructornode(inherited getcopy);
  800. result:=n;
  801. end;
  802. function tarrayconstructornode.det_resulttype:tnode;
  803. var
  804. htype : ttype;
  805. hp : tarrayconstructornode;
  806. len : longint;
  807. varia : boolean;
  808. begin
  809. result:=nil;
  810. { are we allowing array constructor? Then convert it to a set }
  811. if not allow_array_constructor then
  812. begin
  813. hp:=tarrayconstructornode(getcopy);
  814. arrayconstructor_to_set(tnode(hp));
  815. result:=hp;
  816. exit;
  817. end;
  818. { only pass left tree, right tree contains next construct if any }
  819. htype.reset;
  820. len:=0;
  821. varia:=false;
  822. if assigned(left) then
  823. begin
  824. hp:=self;
  825. while assigned(hp) do
  826. begin
  827. resulttypepass(hp.left);
  828. set_varstate(hp.left,true);
  829. if (htype.def=nil) then
  830. htype:=hp.left.resulttype
  831. else
  832. begin
  833. if ((nf_novariaallowed in flags) or (not varia)) and
  834. (not equal_defs(htype.def,hp.left.resulttype.def)) then
  835. begin
  836. varia:=true;
  837. end;
  838. end;
  839. inc(len);
  840. hp:=tarrayconstructornode(hp.right);
  841. end;
  842. end;
  843. if not assigned(htype.def) then
  844. htype:=voidtype;
  845. resulttype.setdef(tarraydef.create(0,len-1,s32bittype));
  846. tarraydef(resulttype.def).setelementtype(htype);
  847. tarraydef(resulttype.def).IsConstructor:=true;
  848. tarraydef(resulttype.def).IsVariant:=varia;
  849. end;
  850. procedure tarrayconstructornode.force_type(tt:ttype);
  851. var
  852. hp : tarrayconstructornode;
  853. begin
  854. tarraydef(resulttype.def).setelementtype(tt);
  855. tarraydef(resulttype.def).IsConstructor:=true;
  856. tarraydef(resulttype.def).IsVariant:=false;
  857. if assigned(left) then
  858. begin
  859. hp:=self;
  860. while assigned(hp) do
  861. begin
  862. inserttypeconv(hp.left,tt);
  863. hp:=tarrayconstructornode(hp.right);
  864. end;
  865. end;
  866. end;
  867. function tarrayconstructornode.pass_1 : tnode;
  868. var
  869. thp,
  870. chp,
  871. hp : tarrayconstructornode;
  872. dovariant : boolean;
  873. htype : ttype;
  874. orgflags : tnodeflags;
  875. begin
  876. dovariant:=(nf_forcevaria in flags) or tarraydef(resulttype.def).isvariant;
  877. result:=nil;
  878. { only pass left tree, right tree contains next construct if any }
  879. if assigned(left) then
  880. begin
  881. hp:=self;
  882. while assigned(hp) do
  883. begin
  884. firstpass(hp.left);
  885. { Insert typeconvs for array of const }
  886. if dovariant then
  887. begin
  888. case hp.left.resulttype.def.deftype of
  889. enumdef :
  890. begin
  891. hp.left:=ctypeconvnode.create_explicit(hp.left,s32bittype);
  892. firstpass(hp.left);
  893. end;
  894. arraydef :
  895. begin
  896. hp.left:=ctypeconvnode.create(hp.left,charpointertype);
  897. firstpass(hp.left);
  898. end;
  899. orddef :
  900. begin
  901. if is_integer(hp.left.resulttype.def) and
  902. not(is_64bitint(hp.left.resulttype.def)) then
  903. begin
  904. hp.left:=ctypeconvnode.create(hp.left,s32bittype);
  905. firstpass(hp.left);
  906. end;
  907. end;
  908. floatdef :
  909. begin
  910. { C uses 64bit floats }
  911. if nf_cargs in flags then
  912. hp.left:=ctypeconvnode.create(hp.left,s64floattype)
  913. else
  914. hp.left:=ctypeconvnode.create(hp.left,pbestrealtype^);
  915. firstpass(hp.left);
  916. end;
  917. stringdef :
  918. begin
  919. if nf_cargs in flags then
  920. begin
  921. hp.left:=ctypeconvnode.create(hp.left,charpointertype);
  922. firstpass(hp.left);
  923. end;
  924. end;
  925. procvardef :
  926. begin
  927. hp.left:=ctypeconvnode.create(hp.left,voidpointertype);
  928. firstpass(hp.left);
  929. end;
  930. variantdef,
  931. pointerdef,
  932. classrefdef,
  933. objectdef : ;
  934. else
  935. CGMessagePos1(hp.left.fileinfo,type_e_wrong_type_in_array_constructor,hp.left.resulttype.def.typename);
  936. end;
  937. end;
  938. hp:=tarrayconstructornode(hp.right);
  939. end;
  940. { swap the tree for cargs }
  941. if (nf_cargs in flags) and (not(nf_cargswap in flags)) then
  942. begin
  943. chp:=nil;
  944. { save resulttype }
  945. htype:=resulttype;
  946. { we need a copy here, because self is destroyed }
  947. { by firstpass later }
  948. hp:=tarrayconstructornode(getcopy);
  949. { we also need a copy of the nf_ forcevaria flag to restore }
  950. { later) (JM) }
  951. orgflags := flags * [nf_forcevaria];
  952. while assigned(hp) do
  953. begin
  954. thp:=tarrayconstructornode(hp.right);
  955. hp.right:=chp;
  956. chp:=hp;
  957. hp:=thp;
  958. end;
  959. chp.flags := chp.flags+orgflags;
  960. include(chp.flags,nf_cargs);
  961. include(chp.flags,nf_cargswap);
  962. chp.expectloc:=LOC_CREFERENCE;
  963. calcregisters(chp,0,0,0);
  964. chp.resulttype:=htype;
  965. result:=chp;
  966. exit;
  967. end;
  968. end;
  969. { C style has pushed everything on the stack, so
  970. there is no return value }
  971. if (nf_cargs in flags) then
  972. expectloc:=LOC_VOID
  973. else
  974. expectloc:=LOC_CREFERENCE;
  975. { Calculate registers }
  976. calcregisters(self,0,0,0);
  977. end;
  978. function tarrayconstructornode.docompare(p: tnode): boolean;
  979. begin
  980. docompare :=
  981. inherited docompare(p);
  982. end;
  983. {*****************************************************************************
  984. TTYPENODE
  985. *****************************************************************************}
  986. constructor ttypenode.create(t : ttype);
  987. begin
  988. inherited create(typen);
  989. restype:=t;
  990. allowed:=false;
  991. end;
  992. constructor ttypenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  993. begin
  994. inherited ppuload(t,ppufile);
  995. ppufile.gettype(restype);
  996. allowed:=boolean(ppufile.getbyte);
  997. end;
  998. procedure ttypenode.ppuwrite(ppufile:tcompilerppufile);
  999. begin
  1000. inherited ppuwrite(ppufile);
  1001. ppufile.puttype(restype);
  1002. ppufile.putbyte(byte(allowed));
  1003. end;
  1004. procedure ttypenode.derefimpl;
  1005. begin
  1006. inherited derefimpl;
  1007. restype.resolve;
  1008. end;
  1009. function ttypenode.det_resulttype:tnode;
  1010. begin
  1011. result:=nil;
  1012. resulttype:=restype;
  1013. { check if it's valid }
  1014. if restype.def.deftype = errordef then
  1015. CGMessage(cg_e_illegal_expression);
  1016. end;
  1017. function ttypenode.pass_1 : tnode;
  1018. begin
  1019. result:=nil;
  1020. expectloc:=LOC_VOID;
  1021. { a typenode can't generate code, so we give here
  1022. an error. Else it'll be an abstract error in pass_2.
  1023. Only when the allowed flag is set we don't generate
  1024. an error }
  1025. if not allowed then
  1026. Message(parser_e_no_type_not_allowed_here);
  1027. end;
  1028. function ttypenode.docompare(p: tnode): boolean;
  1029. begin
  1030. docompare :=
  1031. inherited docompare(p);
  1032. end;
  1033. {*****************************************************************************
  1034. TRTTINODE
  1035. *****************************************************************************}
  1036. constructor trttinode.create(def:tstoreddef;rt:trttitype);
  1037. begin
  1038. inherited create(rttin);
  1039. rttidef:=def;
  1040. rttitype:=rt;
  1041. end;
  1042. constructor trttinode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
  1043. begin
  1044. inherited ppuload(t,ppufile);
  1045. ppufile.getderef(rttidefderef);
  1046. rttitype:=trttitype(ppufile.getbyte);
  1047. end;
  1048. procedure trttinode.ppuwrite(ppufile:tcompilerppufile);
  1049. begin
  1050. inherited ppuwrite(ppufile);
  1051. ppufile.putderef(rttidef,rttidefderef);
  1052. ppufile.putbyte(byte(rttitype));
  1053. end;
  1054. procedure trttinode.derefimpl;
  1055. begin
  1056. inherited derefimpl;
  1057. rttidef:=tstoreddef(rttidefderef.resolve);
  1058. end;
  1059. function trttinode.getcopy : tnode;
  1060. var
  1061. n : trttinode;
  1062. begin
  1063. n:=trttinode(inherited getcopy);
  1064. n.rttidef:=rttidef;
  1065. n.rttitype:=rttitype;
  1066. result:=n;
  1067. end;
  1068. function trttinode.det_resulttype:tnode;
  1069. begin
  1070. { rtti information will be returned as a void pointer }
  1071. result:=nil;
  1072. resulttype:=voidpointertype;
  1073. end;
  1074. function trttinode.pass_1 : tnode;
  1075. begin
  1076. result:=nil;
  1077. expectloc:=LOC_CREFERENCE;
  1078. end;
  1079. function trttinode.docompare(p: tnode): boolean;
  1080. begin
  1081. docompare :=
  1082. inherited docompare(p) and
  1083. (rttidef = trttinode(p).rttidef) and
  1084. (rttitype = trttinode(p).rttitype);
  1085. end;
  1086. procedure trttinode.pass_2;
  1087. begin
  1088. location_reset(location,LOC_CREFERENCE,OS_NO);
  1089. location.reference.symbol:=rttidef.get_rtti_label(rttitype);
  1090. end;
  1091. begin
  1092. cloadnode:=tloadnode;
  1093. cassignmentnode:=tassignmentnode;
  1094. carrayconstructorrangenode:=tarrayconstructorrangenode;
  1095. carrayconstructornode:=tarrayconstructornode;
  1096. ctypenode:=ttypenode;
  1097. crttinode:=trttinode;
  1098. end.
  1099. {
  1100. $Log$
  1101. Revision 1.99 2003-06-07 20:26:32 peter
  1102. * re-resolving added instead of reloading from ppu
  1103. * tderef object added to store deref info for resolving
  1104. Revision 1.98 2003/06/07 18:57:04 jonas
  1105. + added freeintparaloc
  1106. * ppc get/freeintparaloc now check whether the parameter regs are
  1107. properly allocated/deallocated (and get an extra list para)
  1108. * ppc a_call_* now internalerrors if pi_do_call is not yet set
  1109. * fixed lot of missing pi_do_call's
  1110. Revision 1.97 2003/06/07 14:39:18 jonas
  1111. * set pi_do_call for accesses to threadvars
  1112. Revision 1.96 2003/05/26 19:38:28 peter
  1113. * generic fpc_shorstr_concat
  1114. + fpc_shortstr_append_shortstr optimization
  1115. Revision 1.95 2003/05/23 17:05:13 peter
  1116. * loadn procsym need to return procdef
  1117. Revision 1.94 2003/05/23 14:27:35 peter
  1118. * remove some unit dependencies
  1119. * current_procinfo changes to store more info
  1120. Revision 1.93 2003/05/11 21:37:03 peter
  1121. * moved implicit exception frame from ncgutil to psub
  1122. * constructor/destructor helpers moved from cobj/ncgutil to psub
  1123. Revision 1.92 2003/05/11 14:45:12 peter
  1124. * tloadnode does not support objectsymtable,withsymtable anymore
  1125. * withnode cleanup
  1126. * direct with rewritten to use temprefnode
  1127. Revision 1.91 2003/05/09 17:47:02 peter
  1128. * self moved to hidden parameter
  1129. * removed hdisposen,hnewn,selfn
  1130. Revision 1.90 2003/04/27 11:21:33 peter
  1131. * aktprocdef renamed to current_procdef
  1132. * procinfo renamed to current_procinfo
  1133. * procinfo will now be stored in current_module so it can be
  1134. cleaned up properly
  1135. * gen_main_procsym changed to create_main_proc and release_main_proc
  1136. to also generate a tprocinfo structure
  1137. * fixed unit implicit initfinal
  1138. Revision 1.89 2003/04/27 07:29:50 peter
  1139. * current_procdef cleanup, current_procdef is now always nil when parsing
  1140. a new procdef declaration
  1141. * aktprocsym removed
  1142. * lexlevel removed, use symtable.symtablelevel instead
  1143. * implicit init/final code uses the normal genentry/genexit
  1144. * funcret state checking updated for new funcret handling
  1145. Revision 1.88 2003/04/26 00:28:42 peter
  1146. * removed load_funcret
  1147. Revision 1.87 2003/04/25 20:59:33 peter
  1148. * removed funcretn,funcretsym, function result is now in varsym
  1149. and aliases for result and function name are added using absolutesym
  1150. * vs_hidden parameter for funcret passed in parameter
  1151. * vs_hidden fixes
  1152. * writenode changed to printnode and released from extdebug
  1153. * -vp option added to generate a tree.log with the nodetree
  1154. * nicer printnode for statements, callnode
  1155. Revision 1.86 2003/04/23 20:16:04 peter
  1156. + added currency support based on int64
  1157. + is_64bit for use in cg units instead of is_64bitint
  1158. * removed cgmessage from n386add, replace with internalerrors
  1159. Revision 1.85 2003/04/23 10:10:54 peter
  1160. * procvar is not compared in addrn
  1161. Revision 1.84 2003/04/22 23:50:23 peter
  1162. * firstpass uses expectloc
  1163. * checks if there are differences between the expectloc and
  1164. location.loc from secondpass in EXTDEBUG
  1165. Revision 1.83 2003/04/11 15:01:23 peter
  1166. * fix bug 2438
  1167. Revision 1.82 2003/03/28 19:16:56 peter
  1168. * generic constructor working for i386
  1169. * remove fixed self register
  1170. * esi added as address register for i386
  1171. Revision 1.81 2003/03/11 21:46:24 jonas
  1172. * lots of new regallocator fixes, both in generic and ppc-specific code
  1173. (ppc compiler still can't compile the linux system unit though)
  1174. Revision 1.80 2003/01/07 16:52:58 jonas
  1175. * fixed ansistring+char and ansistring+shortstring optimizations (those
  1176. cases were always handled as ansistring+ansistring due to
  1177. typeconversions inserted by the add-node)
  1178. Revision 1.79 2003/01/05 22:44:14 peter
  1179. * remove a lot of code to support typen in loadn-procsym
  1180. Revision 1.78 2003/01/03 12:15:56 daniel
  1181. * Removed ifdefs around notifications
  1182. ifdefs around for loop optimizations remain
  1183. Revision 1.77 2002/12/31 09:55:58 daniel
  1184. + Notification implementation complete
  1185. + Add for loop code optimization using notifications
  1186. results in 1.5-1.9% speed improvement in nestloop benchmark
  1187. Optimization incomplete, compiler does not cycle yet with
  1188. notifications enabled.
  1189. Revision 1.76 2002/12/30 22:44:53 daniel
  1190. * Some work on notifications
  1191. Revision 1.75 2002/12/27 15:27:25 peter
  1192. * remove property indicator when calling internal helpers
  1193. Revision 1.74 2002/12/24 16:53:19 peter
  1194. * fix for tb0438
  1195. Revision 1.73 2002/12/20 18:14:53 peter
  1196. * fix result of high_tree when high was not available
  1197. Revision 1.72 2002/12/17 22:19:33 peter
  1198. * fixed pushing of records>8 bytes with stdcall
  1199. * simplified hightree loading
  1200. Revision 1.71 2002/12/07 14:27:07 carl
  1201. * 3% memory optimization
  1202. * changed some types
  1203. + added type checking with different size for call node and for
  1204. parameters
  1205. Revision 1.70 2002/12/02 19:38:06 carl
  1206. * fix some errors
  1207. Revision 1.69 2002/11/29 20:02:44 carl
  1208. * warning / hint for possible loss of data in assignment
  1209. Revision 1.68 2002/11/27 20:04:39 peter
  1210. * cdecl array of const fixes
  1211. Revision 1.67 2002/11/27 15:33:47 peter
  1212. * the never ending story of tp procvar hacks
  1213. Revision 1.66 2002/11/25 17:43:20 peter
  1214. * splitted defbase in defutil,symutil,defcmp
  1215. * merged isconvertable and is_equal into compare_defs(_ext)
  1216. * made operator search faster by walking the list only once
  1217. Revision 1.65 2002/11/18 17:31:57 peter
  1218. * pass proccalloption to ret_in_xxx and push_xxx functions
  1219. Revision 1.64 2002/11/15 01:58:52 peter
  1220. * merged changes from 1.0.7 up to 04-11
  1221. - -V option for generating bug report tracing
  1222. - more tracing for option parsing
  1223. - errors for cdecl and high()
  1224. - win32 import stabs
  1225. - win32 records<=8 are returned in eax:edx (turned off by default)
  1226. - heaptrc update
  1227. - more info for temp management in .s file with EXTDEBUG
  1228. Revision 1.63 2002/10/17 12:44:09 florian
  1229. + s:=s+<string type> where s is an ansistring is done via calls to append_ansistring_*
  1230. Revision 1.62 2002/10/05 12:43:25 carl
  1231. * fixes for Delphi 6 compilation
  1232. (warning : Some features do not work under Delphi)
  1233. Revision 1.61 2002/10/03 21:26:08 carl
  1234. + compile-time range checking for strings
  1235. Revision 1.60 2002/09/27 21:13:28 carl
  1236. * low-highval always checked if limit ober 2GB is reached (to avoid overflow)
  1237. Revision 1.59 2002/09/26 15:02:05 florian
  1238. + support of passing variants to "array of const"
  1239. Revision 1.58 2002/09/07 15:25:03 peter
  1240. * old logs removed and tabs fixed
  1241. Revision 1.57 2002/09/03 16:26:26 daniel
  1242. * Make Tprocdef.defs protected
  1243. Revision 1.56 2002/09/01 13:28:37 daniel
  1244. - write_access fields removed in favor of a flag
  1245. Revision 1.55 2002/09/01 08:01:16 daniel
  1246. * Removed sets from Tcallnode.det_resulttype
  1247. + Added read/write notifications of variables. These will be usefull
  1248. for providing information for several optimizations. For example
  1249. the value of the loop variable of a for loop does matter is the
  1250. variable is read after the for loop, but if it's no longer used
  1251. or written, it doesn't matter and this can be used to optimize
  1252. the loop code generation.
  1253. Revision 1.54 2002/08/25 19:25:19 peter
  1254. * sym.insert_in_data removed
  1255. * symtable.insertvardata/insertconstdata added
  1256. * removed insert_in_data call from symtable.insert, it needs to be
  1257. called separatly. This allows to deref the address calculation
  1258. * procedures now calculate the parast addresses after the procedure
  1259. directives are parsed. This fixes the cdecl parast problem
  1260. * push_addr_param has an extra argument that specifies if cdecl is used
  1261. or not
  1262. Revision 1.53 2002/08/19 19:36:43 peter
  1263. * More fixes for cross unit inlining, all tnodes are now implemented
  1264. * Moved pocall_internconst to po_internconst because it is not a
  1265. calling type at all and it conflicted when inlining of these small
  1266. functions was requested
  1267. Revision 1.52 2002/08/18 20:06:23 peter
  1268. * inlining is now also allowed in interface
  1269. * renamed write/load to ppuwrite/ppuload
  1270. * tnode storing in ppu
  1271. * nld,ncon,nbas are already updated for storing in ppu
  1272. Revision 1.51 2002/08/17 22:09:46 florian
  1273. * result type handling in tcgcal.pass_2 overhauled
  1274. * better tnode.dowrite
  1275. * some ppc stuff fixed
  1276. Revision 1.50 2002/08/17 09:23:37 florian
  1277. * first part of procinfo rewrite
  1278. Revision 1.49 2002/07/20 11:57:54 florian
  1279. * types.pas renamed to defbase.pas because D6 contains a types
  1280. unit so this would conflicts if D6 programms are compiled
  1281. + Willamette/SSE2 instructions to assembler added
  1282. Revision 1.48 2002/07/20 07:44:37 daniel
  1283. * Forgot to add a $ifdef extdebug
  1284. Revision 1.47 2002/07/19 12:55:27 daniel
  1285. * Further developed state tracking in whilerepeatn
  1286. Revision 1.46 2002/07/19 11:41:36 daniel
  1287. * State tracker work
  1288. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1289. allows the state tracker to change while nodes automatically into
  1290. repeat nodes.
  1291. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1292. 'not(a>b)' is optimized into 'a<=b'.
  1293. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1294. by removing the notn and later switchting the true and falselabels. The
  1295. same is done with 'repeat until not a'.
  1296. Revision 1.45 2002/07/15 18:03:15 florian
  1297. * readded removed changes
  1298. Revision 1.43 2002/07/11 14:41:28 florian
  1299. * start of the new generic parameter handling
  1300. Revision 1.44 2002/07/14 18:00:44 daniel
  1301. + Added the beginning of a state tracker. This will track the values of
  1302. variables through procedures and optimize things away.
  1303. Revision 1.42 2002/05/18 13:34:10 peter
  1304. * readded missing revisions
  1305. Revision 1.41 2002/05/16 19:46:38 carl
  1306. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1307. + try to fix temp allocation (still in ifdef)
  1308. + generic constructor calls
  1309. + start of tassembler / tmodulebase class cleanup
  1310. Revision 1.39 2002/05/12 16:53:07 peter
  1311. * moved entry and exitcode to ncgutil and cgobj
  1312. * foreach gets extra argument for passing local data to the
  1313. iterator function
  1314. * -CR checks also class typecasts at runtime by changing them
  1315. into as
  1316. * fixed compiler to cycle with the -CR option
  1317. * fixed stabs with elf writer, finally the global variables can
  1318. be watched
  1319. * removed a lot of routines from cga unit and replaced them by
  1320. calls to cgobj
  1321. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  1322. u32bit then the other is typecasted also to u32bit without giving
  1323. a rangecheck warning/error.
  1324. * fixed pascal calling method with reversing also the high tree in
  1325. the parast, detected by tcalcst3 test
  1326. Revision 1.38 2002/04/25 20:16:39 peter
  1327. * moved more routines from cga/n386util
  1328. Revision 1.37 2002/04/23 19:16:34 peter
  1329. * add pinline unit that inserts compiler supported functions using
  1330. one or more statements
  1331. * moved finalize and setlength from ninl to pinline
  1332. }