nld.pas 52 KB

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