nadd.pas 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Type checking and register allocation for add 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 nadd;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node;
  23. type
  24. taddnode = class(tbinopnode)
  25. constructor create(tt : tnodetype;l,r : tnode);override;
  26. function pass_1 : tnode;override;
  27. function det_resulttype:tnode;override;
  28. {$ifdef state_tracking}
  29. function track_state_pass(exec_known:boolean):boolean;override;
  30. {$endif}
  31. protected
  32. { override the following if you want to implement }
  33. { parts explicitely in the code generator (JM) }
  34. function first_addstring: tnode; virtual;
  35. function first_addset: tnode; virtual;
  36. { only implements "muln" nodes, the rest always has to be done in }
  37. { the code generator for performance reasons (JM) }
  38. function first_add64bitint: tnode; virtual;
  39. { This routine calls internal runtime library helpers
  40. for all floating point arithmetic in the case
  41. where the emulation switches is on. Otherwise
  42. returns nil, and everything must be done in
  43. the code generation phase.
  44. }
  45. function first_addfloat : tnode; virtual;
  46. end;
  47. taddnodeclass = class of taddnode;
  48. var
  49. { caddnode is used to create nodes of the add type }
  50. { the virtual constructor allows to assign }
  51. { another class type to caddnode => processor }
  52. { specific node types can be created }
  53. caddnode : taddnodeclass;
  54. implementation
  55. uses
  56. globtype,systems,
  57. cutils,verbose,globals,widestr,
  58. symconst,symtype,symdef,symsym,symtable,defbase,
  59. cgbase,
  60. htypechk,pass_1,
  61. nmat,ncnv,ncon,nset,nopt,ncal,ninl,
  62. {$ifdef state_tracking}
  63. nstate,
  64. {$endif}
  65. cpubase,cpuinfo;
  66. {*****************************************************************************
  67. TADDNODE
  68. *****************************************************************************}
  69. {$ifdef fpc}
  70. {$maxfpuregisters 0}
  71. {$endif fpc}
  72. constructor taddnode.create(tt : tnodetype;l,r : tnode);
  73. begin
  74. inherited create(tt,l,r);
  75. end;
  76. function taddnode.det_resulttype:tnode;
  77. var
  78. hp,t : tnode;
  79. lt,rt : tnodetype;
  80. rd,ld : tdef;
  81. htype : ttype;
  82. ot : tnodetype;
  83. concatstrings : boolean;
  84. resultset : Tconstset;
  85. i : longint;
  86. b : boolean;
  87. s1,s2 : pchar;
  88. ws1,ws2 : pcompilerwidestring;
  89. l1,l2 : longint;
  90. rv,lv : tconstexprint;
  91. rvd,lvd : bestreal;
  92. {$ifdef state_tracking}
  93. factval : Tnode;
  94. change : boolean;
  95. {$endif}
  96. begin
  97. result:=nil;
  98. { first do the two subtrees }
  99. resulttypepass(left);
  100. resulttypepass(right);
  101. { both left and right need to be valid }
  102. set_varstate(left,true);
  103. set_varstate(right,true);
  104. if codegenerror then
  105. exit;
  106. { convert array constructors to sets, because there is no other operator
  107. possible for array constructors }
  108. if is_array_constructor(left.resulttype.def) then
  109. begin
  110. arrayconstructor_to_set(left);
  111. resulttypepass(left);
  112. end;
  113. if is_array_constructor(right.resulttype.def) then
  114. begin
  115. arrayconstructor_to_set(right);
  116. resulttypepass(right);
  117. end;
  118. { allow operator overloading }
  119. hp:=self;
  120. if isbinaryoverloaded(hp) then
  121. begin
  122. result:=hp;
  123. exit;
  124. end;
  125. { Kylix allows enum+ordconstn in an enum declaration (blocktype
  126. is bt_type), we need to do the conversion here before the
  127. constant folding }
  128. if (m_delphi in aktmodeswitches) and
  129. (blocktype=bt_type) then
  130. begin
  131. if (left.resulttype.def.deftype=enumdef) and
  132. (right.resulttype.def.deftype=orddef) then
  133. begin
  134. { insert explicit typecast to s32bit }
  135. left:=ctypeconvnode.create(left,s32bittype);
  136. left.toggleflag(nf_explizit);
  137. resulttypepass(left);
  138. end
  139. else
  140. if (left.resulttype.def.deftype=orddef) and
  141. (right.resulttype.def.deftype=enumdef) then
  142. begin
  143. { insert explicit typecast to s32bit }
  144. right:=ctypeconvnode.create(right,s32bittype);
  145. include(right.flags,nf_explizit);
  146. resulttypepass(right);
  147. end;
  148. end;
  149. { is one a real float, then both need to be floats, this
  150. need to be done before the constant folding so constant
  151. operation on a float and int are also handled }
  152. if (right.resulttype.def.deftype=floatdef) or (left.resulttype.def.deftype=floatdef) then
  153. begin
  154. inserttypeconv(right,pbestrealtype^);
  155. inserttypeconv(left,pbestrealtype^);
  156. end;
  157. { if one operand is a widechar or a widestring, both operands }
  158. { are converted to widestring. This must be done before constant }
  159. { folding to allow char+widechar etc. }
  160. if is_widestring(right.resulttype.def) or
  161. is_widestring(left.resulttype.def) or
  162. is_widechar(right.resulttype.def) or
  163. is_widechar(left.resulttype.def) then
  164. begin
  165. inserttypeconv(right,cwidestringtype);
  166. inserttypeconv(left,cwidestringtype);
  167. end;
  168. { load easier access variables }
  169. rd:=right.resulttype.def;
  170. ld:=left.resulttype.def;
  171. rt:=right.nodetype;
  172. lt:=left.nodetype;
  173. { both are int constants }
  174. if (((is_constintnode(left) and is_constintnode(right)) or
  175. (is_constboolnode(left) and is_constboolnode(right) and
  176. (nodetype in [ltn,lten,gtn,gten,equaln,unequaln,andn,xorn,orn])))) or
  177. { support pointer arithmetics on constants (JM) }
  178. ((lt = pointerconstn) and is_constintnode(right) and
  179. (nodetype in [addn,subn])) or
  180. (((lt = pointerconstn) or (lt = niln)) and
  181. ((rt = pointerconstn) or (rt = niln)) and
  182. (nodetype in [ltn,lten,gtn,gten,equaln,unequaln,subn])) then
  183. begin
  184. { when comparing/substracting pointers, make sure they are }
  185. { of the same type (JM) }
  186. if (lt = pointerconstn) and (rt = pointerconstn) then
  187. begin
  188. if not(cs_extsyntax in aktmoduleswitches) and
  189. not(nodetype in [equaln,unequaln]) then
  190. CGMessage(type_e_mismatch)
  191. else
  192. if (nodetype <> subn) and
  193. is_voidpointer(rd) then
  194. inserttypeconv(right,left.resulttype)
  195. else if (nodetype <> subn) and
  196. is_voidpointer(ld) then
  197. inserttypeconv(left,right.resulttype)
  198. else if not(is_equal(ld,rd)) then
  199. CGMessage(type_e_mismatch);
  200. end
  201. else if (lt=ordconstn) and (rt=ordconstn) then
  202. begin
  203. { make left const type the biggest (u32bit is bigger than
  204. s32bit for or,and,xor) }
  205. if (rd.size>ld.size) or
  206. ((torddef(rd).typ=u32bit) and
  207. (torddef(ld).typ=s32bit) and
  208. (nodetype in [orn,andn,xorn])) then
  209. inserttypeconv(left,right.resulttype);
  210. end;
  211. { load values }
  212. case lt of
  213. ordconstn:
  214. lv:=tordconstnode(left).value;
  215. pointerconstn:
  216. lv:=tpointerconstnode(left).value;
  217. niln:
  218. lv:=0;
  219. else
  220. internalerror(2002080202);
  221. end;
  222. case rt of
  223. ordconstn:
  224. rv:=tordconstnode(right).value;
  225. pointerconstn:
  226. rv:=tpointerconstnode(right).value;
  227. niln:
  228. rv:=0;
  229. else
  230. internalerror(2002080203);
  231. end;
  232. if (lt = pointerconstn) and
  233. (rt <> pointerconstn) then
  234. rv := rv * tpointerdef(left.resulttype.def).pointertype.def.size;
  235. if (rt = pointerconstn) and
  236. (lt <> pointerconstn) then
  237. lv := lv * tpointerdef(right.resulttype.def).pointertype.def.size;
  238. case nodetype of
  239. addn :
  240. if (lt <> pointerconstn) then
  241. t := genintconstnode(lv+rv)
  242. else
  243. t := cpointerconstnode.create(lv+rv,left.resulttype);
  244. subn :
  245. if (lt <> pointerconstn) or (rt = pointerconstn) then
  246. t := genintconstnode(lv-rv)
  247. else
  248. t := cpointerconstnode.create(lv-rv,left.resulttype);
  249. muln :
  250. t:=genintconstnode(lv*rv);
  251. xorn :
  252. t:=cordconstnode.create(lv xor rv,left.resulttype);
  253. orn :
  254. t:=cordconstnode.create(lv or rv,left.resulttype);
  255. andn :
  256. t:=cordconstnode.create(lv and rv,left.resulttype);
  257. ltn :
  258. t:=cordconstnode.create(ord(lv<rv),booltype);
  259. lten :
  260. t:=cordconstnode.create(ord(lv<=rv),booltype);
  261. gtn :
  262. t:=cordconstnode.create(ord(lv>rv),booltype);
  263. gten :
  264. t:=cordconstnode.create(ord(lv>=rv),booltype);
  265. equaln :
  266. t:=cordconstnode.create(ord(lv=rv),booltype);
  267. unequaln :
  268. t:=cordconstnode.create(ord(lv<>rv),booltype);
  269. slashn :
  270. begin
  271. { int/int becomes a real }
  272. rvd:=rv;
  273. lvd:=lv;
  274. if int(rvd)=0 then
  275. begin
  276. Message(parser_e_invalid_float_operation);
  277. t:=crealconstnode.create(0,pbestrealtype^);
  278. end
  279. else
  280. t:=crealconstnode.create(int(lvd)/int(rvd),pbestrealtype^);
  281. end;
  282. else
  283. CGMessage(type_e_mismatch);
  284. end;
  285. result:=t;
  286. exit;
  287. end;
  288. { both real constants ? }
  289. if (lt=realconstn) and (rt=realconstn) then
  290. begin
  291. lvd:=trealconstnode(left).value_real;
  292. rvd:=trealconstnode(right).value_real;
  293. case nodetype of
  294. addn :
  295. t:=crealconstnode.create(lvd+rvd,pbestrealtype^);
  296. subn :
  297. t:=crealconstnode.create(lvd-rvd,pbestrealtype^);
  298. muln :
  299. t:=crealconstnode.create(lvd*rvd,pbestrealtype^);
  300. starstarn,
  301. caretn :
  302. begin
  303. if lvd<0 then
  304. begin
  305. Message(parser_e_invalid_float_operation);
  306. t:=crealconstnode.create(0,pbestrealtype^);
  307. end
  308. else if lvd=0 then
  309. t:=crealconstnode.create(1.0,pbestrealtype^)
  310. else
  311. t:=crealconstnode.create(exp(ln(lvd)*rvd),pbestrealtype^);
  312. end;
  313. slashn :
  314. begin
  315. if rvd=0 then
  316. begin
  317. Message(parser_e_invalid_float_operation);
  318. t:=crealconstnode.create(0,pbestrealtype^);
  319. end
  320. else
  321. t:=crealconstnode.create(lvd/rvd,pbestrealtype^);
  322. end;
  323. ltn :
  324. t:=cordconstnode.create(ord(lvd<rvd),booltype);
  325. lten :
  326. t:=cordconstnode.create(ord(lvd<=rvd),booltype);
  327. gtn :
  328. t:=cordconstnode.create(ord(lvd>rvd),booltype);
  329. gten :
  330. t:=cordconstnode.create(ord(lvd>=rvd),booltype);
  331. equaln :
  332. t:=cordconstnode.create(ord(lvd=rvd),booltype);
  333. unequaln :
  334. t:=cordconstnode.create(ord(lvd<>rvd),booltype);
  335. else
  336. CGMessage(type_e_mismatch);
  337. end;
  338. result:=t;
  339. exit;
  340. end;
  341. { first, we handle widestrings, so we can check later for }
  342. { stringconstn only }
  343. { widechars are converted above to widestrings too }
  344. { this isn't veryy efficient, but I don't think }
  345. { that it does matter that much (FK) }
  346. if (lt=stringconstn) and (rt=stringconstn) and
  347. (tstringconstnode(left).st_type=st_widestring) and
  348. (tstringconstnode(right).st_type=st_widestring) then
  349. begin
  350. initwidestring(ws1);
  351. initwidestring(ws2);
  352. copywidestring(pcompilerwidestring(tstringconstnode(left).value_str),ws1);
  353. copywidestring(pcompilerwidestring(tstringconstnode(right).value_str),ws2);
  354. case nodetype of
  355. addn :
  356. begin
  357. concatwidestrings(ws1,ws2);
  358. t:=cstringconstnode.createwstr(ws1);
  359. end;
  360. ltn :
  361. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<0),booltype);
  362. lten :
  363. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<=0),booltype);
  364. gtn :
  365. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)>0),booltype);
  366. gten :
  367. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)>=0),booltype);
  368. equaln :
  369. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)=0),booltype);
  370. unequaln :
  371. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<>0),booltype);
  372. end;
  373. donewidestring(ws1);
  374. donewidestring(ws2);
  375. result:=t;
  376. exit;
  377. end;
  378. { concating strings ? }
  379. concatstrings:=false;
  380. s1:=nil;
  381. s2:=nil;
  382. if (lt=ordconstn) and (rt=ordconstn) and
  383. is_char(ld) and is_char(rd) then
  384. begin
  385. s1:=strpnew(char(byte(tordconstnode(left).value)));
  386. s2:=strpnew(char(byte(tordconstnode(right).value)));
  387. l1:=1;
  388. l2:=1;
  389. concatstrings:=true;
  390. end
  391. else
  392. if (lt=stringconstn) and (rt=ordconstn) and is_char(rd) then
  393. begin
  394. s1:=tstringconstnode(left).getpcharcopy;
  395. l1:=tstringconstnode(left).len;
  396. s2:=strpnew(char(byte(tordconstnode(right).value)));
  397. l2:=1;
  398. concatstrings:=true;
  399. end
  400. else
  401. if (lt=ordconstn) and (rt=stringconstn) and is_char(ld) then
  402. begin
  403. s1:=strpnew(char(byte(tordconstnode(left).value)));
  404. l1:=1;
  405. s2:=tstringconstnode(right).getpcharcopy;
  406. l2:=tstringconstnode(right).len;
  407. concatstrings:=true;
  408. end
  409. else if (lt=stringconstn) and (rt=stringconstn) then
  410. begin
  411. s1:=tstringconstnode(left).getpcharcopy;
  412. l1:=tstringconstnode(left).len;
  413. s2:=tstringconstnode(right).getpcharcopy;
  414. l2:=tstringconstnode(right).len;
  415. concatstrings:=true;
  416. end;
  417. if concatstrings then
  418. begin
  419. case nodetype of
  420. addn :
  421. t:=cstringconstnode.createpchar(concatansistrings(s1,s2,l1,l2),l1+l2);
  422. ltn :
  423. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<0),booltype);
  424. lten :
  425. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<=0),booltype);
  426. gtn :
  427. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)>0),booltype);
  428. gten :
  429. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)>=0),booltype);
  430. equaln :
  431. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)=0),booltype);
  432. unequaln :
  433. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<>0),booltype);
  434. end;
  435. ansistringdispose(s1,l1);
  436. ansistringdispose(s2,l2);
  437. result:=t;
  438. exit;
  439. end;
  440. { set constant evaluation }
  441. if (right.nodetype=setconstn) and
  442. not assigned(tsetconstnode(right).left) and
  443. (left.nodetype=setconstn) and
  444. not assigned(tsetconstnode(left).left) then
  445. begin
  446. { check if size adjusting is needed, only for left
  447. to right as the other way is checked in the typeconv }
  448. if (tsetdef(right.resulttype.def).settype=smallset) and
  449. (tsetdef(left.resulttype.def).settype<>smallset) then
  450. tsetdef(right.resulttype.def).changesettype(normset);
  451. { check base types }
  452. inserttypeconv(left,right.resulttype);
  453. if codegenerror then
  454. begin
  455. { recover by only returning the left part }
  456. result:=left;
  457. left:=nil;
  458. exit;
  459. end;
  460. {$ifdef oldset}
  461. case nodetype of
  462. addn :
  463. begin
  464. for i:=0 to 31 do
  465. resultset[i]:=tsetconstnode(right).value_set^[i] or tsetconstnode(left).value_set^[i];
  466. t:=csetconstnode.create(@resultset,left.resulttype);
  467. end;
  468. muln :
  469. begin
  470. for i:=0 to 31 do
  471. resultset[i]:=tsetconstnode(right).value_set^[i] and tsetconstnode(left).value_set^[i];
  472. t:=csetconstnode.create(@resultset,left.resulttype);
  473. end;
  474. subn :
  475. begin
  476. for i:=0 to 31 do
  477. resultset[i]:=tsetconstnode(left).value_set^[i] and not(tsetconstnode(right).value_set^[i]);
  478. t:=csetconstnode.create(@resultset,left.resulttype);
  479. end;
  480. symdifn :
  481. begin
  482. for i:=0 to 31 do
  483. resultset[i]:=tsetconstnode(left).value_set^[i] xor tsetconstnode(right).value_set^[i];
  484. t:=csetconstnode.create(@resultset,left.resulttype);
  485. end;
  486. unequaln :
  487. begin
  488. b:=true;
  489. for i:=0 to 31 do
  490. if tsetconstnode(right).value_set^[i]=tsetconstnode(left).value_set^[i] then
  491. begin
  492. b:=false;
  493. break;
  494. end;
  495. t:=cordconstnode.create(ord(b),booltype);
  496. end;
  497. equaln :
  498. begin
  499. b:=true;
  500. for i:=0 to 31 do
  501. if tsetconstnode(right).value_set^[i]<>tsetconstnode(left).value_set^[i] then
  502. begin
  503. b:=false;
  504. break;
  505. end;
  506. t:=cordconstnode.create(ord(b),booltype);
  507. end;
  508. lten :
  509. begin
  510. b := true;
  511. for i := 0 to 31 Do
  512. if (tsetconstnode(right).value_set^[i] And tsetconstnode(left).value_set^[i]) <>
  513. tsetconstnode(left).value_set^[i] Then
  514. begin
  515. b := false;
  516. break
  517. end;
  518. t := cordconstnode.create(ord(b),booltype);
  519. end;
  520. gten :
  521. begin
  522. b := true;
  523. for i := 0 to 31 Do
  524. If (tsetconstnode(left).value_set^[i] And tsetconstnode(right).value_set^[i]) <>
  525. tsetconstnode(right).value_set^[i] Then
  526. begin
  527. b := false;
  528. break
  529. end;
  530. t := cordconstnode.create(ord(b),booltype);
  531. end;
  532. end;
  533. {$else}
  534. case nodetype of
  535. addn :
  536. begin
  537. resultset:=tsetconstnode(right).value_set^ + tsetconstnode(left).value_set^;
  538. t:=csetconstnode.create(@resultset,left.resulttype);
  539. end;
  540. muln :
  541. begin
  542. resultset:=tsetconstnode(right).value_set^ * tsetconstnode(left).value_set^;
  543. t:=csetconstnode.create(@resultset,left.resulttype);
  544. end;
  545. subn :
  546. begin
  547. resultset:=tsetconstnode(left).value_set^ - tsetconstnode(right).value_set^;
  548. t:=csetconstnode.create(@resultset,left.resulttype);
  549. end;
  550. symdifn :
  551. begin
  552. resultset:=tsetconstnode(right).value_set^ >< tsetconstnode(left).value_set^;
  553. t:=csetconstnode.create(@resultset,left.resulttype);
  554. end;
  555. unequaln :
  556. begin
  557. b:=tsetconstnode(right).value_set^ <> tsetconstnode(left).value_set^;
  558. t:=cordconstnode.create(byte(b),booltype);
  559. end;
  560. equaln :
  561. begin
  562. b:=tsetconstnode(right).value_set^ = tsetconstnode(left).value_set^;
  563. t:=cordconstnode.create(byte(b),booltype);
  564. end;
  565. lten :
  566. begin
  567. b:=tsetconstnode(left).value_set^ <= tsetconstnode(right).value_set^;
  568. t:=cordconstnode.create(byte(b),booltype);
  569. end;
  570. gten :
  571. begin
  572. b:=tsetconstnode(left).value_set^ >= tsetconstnode(right).value_set^;
  573. t:=cordconstnode.create(byte(b),booltype);
  574. end;
  575. end;
  576. {$endif}
  577. result:=t;
  578. exit;
  579. end;
  580. { but an int/int gives real/real! }
  581. if nodetype=slashn then
  582. begin
  583. CGMessage(type_h_use_div_for_int);
  584. inserttypeconv(right,pbestrealtype^);
  585. inserttypeconv(left,pbestrealtype^);
  586. end
  587. { if both are orddefs then check sub types }
  588. else if (ld.deftype=orddef) and (rd.deftype=orddef) then
  589. begin
  590. { optimize multiplacation by a power of 2 }
  591. if not(cs_check_overflow in aktlocalswitches) and
  592. (nodetype = muln) and
  593. (((left.nodetype = ordconstn) and
  594. ispowerof2(tordconstnode(left).value,i)) or
  595. ((right.nodetype = ordconstn) and
  596. ispowerof2(tordconstnode(right).value,i))) then
  597. begin
  598. if left.nodetype = ordconstn then
  599. begin
  600. tordconstnode(left).value := i;
  601. result := cshlshrnode.create(shln,right,left);
  602. end
  603. else
  604. begin
  605. tordconstnode(right).value := i;
  606. result := cshlshrnode.create(shln,left,right);
  607. end;
  608. left := nil;
  609. right := nil;
  610. exit;
  611. end;
  612. { 2 booleans? Make them equal to the largest boolean }
  613. if is_boolean(ld) and is_boolean(rd) then
  614. begin
  615. if torddef(left.resulttype.def).size>torddef(right.resulttype.def).size then
  616. begin
  617. right:=ctypeconvnode.create(right,left.resulttype);
  618. ttypeconvnode(right).convtype:=tc_bool_2_int;
  619. right.toggleflag(nf_explizit);
  620. resulttypepass(right);
  621. end
  622. else if torddef(left.resulttype.def).size<torddef(right.resulttype.def).size then
  623. begin
  624. left:=ctypeconvnode.create(left,right.resulttype);
  625. ttypeconvnode(left).convtype:=tc_bool_2_int;
  626. left.toggleflag(nf_explizit);
  627. resulttypepass(left);
  628. end;
  629. case nodetype of
  630. xorn,
  631. ltn,
  632. lten,
  633. gtn,
  634. gten,
  635. andn,
  636. orn:
  637. begin
  638. end;
  639. unequaln,
  640. equaln:
  641. begin
  642. if not(cs_full_boolean_eval in aktlocalswitches) then
  643. begin
  644. { Remove any compares with constants }
  645. if (left.nodetype=ordconstn) then
  646. begin
  647. hp:=right;
  648. b:=(tordconstnode(left).value<>0);
  649. ot:=nodetype;
  650. left.free;
  651. left:=nil;
  652. right:=nil;
  653. if (not(b) and (ot=equaln)) or
  654. (b and (ot=unequaln)) then
  655. begin
  656. hp:=cnotnode.create(hp);
  657. end;
  658. result:=hp;
  659. exit;
  660. end;
  661. if (right.nodetype=ordconstn) then
  662. begin
  663. hp:=left;
  664. b:=(tordconstnode(right).value<>0);
  665. ot:=nodetype;
  666. right.free;
  667. right:=nil;
  668. left:=nil;
  669. if (not(b) and (ot=equaln)) or
  670. (b and (ot=unequaln)) then
  671. begin
  672. hp:=cnotnode.create(hp);
  673. end;
  674. result:=hp;
  675. exit;
  676. end;
  677. end;
  678. end;
  679. else
  680. CGMessage(type_e_mismatch);
  681. end;
  682. end
  683. { Both are chars? }
  684. else if is_char(rd) and is_char(ld) then
  685. begin
  686. if nodetype=addn then
  687. begin
  688. resulttype:=cshortstringtype;
  689. if not(is_constcharnode(left) and is_constcharnode(right)) then
  690. begin
  691. inserttypeconv(left,cshortstringtype);
  692. hp := genaddsstringcharoptnode(self);
  693. result := hp;
  694. exit;
  695. end;
  696. end;
  697. end
  698. { is there a signed 64 bit type ? }
  699. else if ((torddef(rd).typ=s64bit) or (torddef(ld).typ=s64bit)) then
  700. begin
  701. if (torddef(ld).typ<>s64bit) then
  702. inserttypeconv(left,cs64bittype);
  703. if (torddef(rd).typ<>s64bit) then
  704. inserttypeconv(right,cs64bittype);
  705. end
  706. { is there a unsigned 64 bit type ? }
  707. else if ((torddef(rd).typ=u64bit) or (torddef(ld).typ=u64bit)) then
  708. begin
  709. if (torddef(ld).typ<>u64bit) then
  710. inserttypeconv(left,cu64bittype);
  711. if (torddef(rd).typ<>u64bit) then
  712. inserttypeconv(right,cu64bittype);
  713. end
  714. { is there a cardinal? }
  715. else if ((torddef(rd).typ=u32bit) or (torddef(ld).typ=u32bit)) then
  716. begin
  717. if is_signed(ld) and
  718. { then rd = u32bit }
  719. { convert positive constants to u32bit }
  720. not(is_constintnode(left) and
  721. (tordconstnode(left).value >= 0)) and
  722. { range/overflow checking on mixed signed/cardinal expressions }
  723. { is only possible if you convert everything to 64bit (JM) }
  724. ((aktlocalswitches * [cs_check_overflow,cs_check_range] <> []) and
  725. (nodetype in [addn,subn,muln])) then
  726. begin
  727. { perform the operation in 64bit }
  728. CGMessage(type_w_mixed_signed_unsigned);
  729. inserttypeconv(left,cs64bittype);
  730. inserttypeconv(right,cs64bittype);
  731. end
  732. else
  733. begin
  734. { and,or,xor work on bit patterns and don't care
  735. about the sign }
  736. if nodetype in [andn,orn,xorn] then
  737. inserttypeconv_explicit(left,u32bittype)
  738. else
  739. begin
  740. if is_signed(ld) and
  741. not(is_constintnode(left) and
  742. (tordconstnode(left).value >= 0)) and
  743. (cs_check_range in aktlocalswitches) then
  744. CGMessage(type_w_mixed_signed_unsigned2);
  745. inserttypeconv(left,u32bittype);
  746. end;
  747. if is_signed(rd) and
  748. { then ld = u32bit }
  749. { convert positive constants to u32bit }
  750. not(is_constintnode(right) and
  751. (tordconstnode(right).value >= 0)) and
  752. ((aktlocalswitches * [cs_check_overflow,cs_check_range] <> []) and
  753. (nodetype in [addn,subn,muln])) then
  754. begin
  755. { perform the operation in 64bit }
  756. CGMessage(type_w_mixed_signed_unsigned);
  757. inserttypeconv(left,cs64bittype);
  758. inserttypeconv(right,cs64bittype);
  759. end
  760. else
  761. begin
  762. { and,or,xor work on bit patterns and don't care
  763. about the sign }
  764. if nodetype in [andn,orn,xorn] then
  765. inserttypeconv_explicit(left,u32bittype)
  766. else
  767. begin
  768. if is_signed(rd) and
  769. not(is_constintnode(right) and
  770. (tordconstnode(right).value >= 0)) and
  771. (cs_check_range in aktlocalswitches) then
  772. CGMessage(type_w_mixed_signed_unsigned2);
  773. inserttypeconv(right,u32bittype);
  774. end;
  775. end;
  776. end;
  777. end
  778. { generic ord conversion is s32bit }
  779. else
  780. begin
  781. inserttypeconv(right,s32bittype);
  782. inserttypeconv(left,s32bittype);
  783. end;
  784. end
  785. { if both are floatdefs, conversion is already done before constant folding }
  786. else if (ld.deftype=floatdef) then
  787. begin
  788. { already converted }
  789. end
  790. { left side a setdef, must be before string processing,
  791. else array constructor can be seen as array of char (PFV) }
  792. else if (ld.deftype=setdef) then
  793. begin
  794. { trying to add a set element? }
  795. if (nodetype=addn) and (rd.deftype<>setdef) then
  796. begin
  797. if (rt=setelementn) then
  798. begin
  799. if not(is_equal(tsetdef(ld).elementtype.def,rd)) then
  800. CGMessage(type_e_set_element_are_not_comp);
  801. end
  802. else
  803. CGMessage(type_e_mismatch)
  804. end
  805. else
  806. begin
  807. if not(nodetype in [addn,subn,symdifn,muln,equaln,unequaln,lten,gten]) then
  808. CGMessage(type_e_set_operation_unknown);
  809. { right def must be a also be set }
  810. if (rd.deftype<>setdef) or not(is_equal(rd,ld)) then
  811. CGMessage(type_e_set_element_are_not_comp);
  812. end;
  813. { ranges require normsets }
  814. if (tsetdef(ld).settype=smallset) and
  815. (rt=setelementn) and
  816. assigned(tsetelementnode(right).right) then
  817. begin
  818. { generate a temporary normset def, it'll be destroyed
  819. when the symtable is unloaded }
  820. htype.setdef(tsetdef.create(tsetdef(ld).elementtype,255));
  821. inserttypeconv(left,htype);
  822. end;
  823. { if the right side is also a setdef then the settype must
  824. be the same as the left setdef }
  825. if (rd.deftype=setdef) and
  826. (tsetdef(ld).settype<>tsetdef(rd).settype) then
  827. inserttypeconv(right,left.resulttype);
  828. end
  829. { compare pchar to char arrays by addresses like BP/Delphi }
  830. else if (is_pchar(ld) and is_chararray(rd)) or
  831. (is_pchar(rd) and is_chararray(ld)) then
  832. begin
  833. if is_chararray(rd) then
  834. inserttypeconv(right,left.resulttype)
  835. else
  836. inserttypeconv(left,right.resulttype);
  837. end
  838. { is one of the operands a string?,
  839. chararrays are also handled as strings (after conversion), also take
  840. care of chararray+chararray and chararray+char }
  841. else if (rd.deftype=stringdef) or (ld.deftype=stringdef) or
  842. ((is_chararray(rd) or is_char(rd)) and
  843. (is_chararray(ld) or is_char(ld))) then
  844. begin
  845. if is_widestring(rd) or is_widestring(ld) then
  846. begin
  847. if not(is_widestring(rd)) then
  848. inserttypeconv(right,cwidestringtype);
  849. if not(is_widestring(ld)) then
  850. inserttypeconv(left,cwidestringtype);
  851. end
  852. else if is_ansistring(rd) or is_ansistring(ld) then
  853. begin
  854. if not(is_ansistring(rd)) then
  855. inserttypeconv(right,cansistringtype);
  856. if not(is_ansistring(ld)) then
  857. inserttypeconv(left,cansistringtype);
  858. end
  859. else if is_longstring(rd) or is_longstring(ld) then
  860. begin
  861. if not(is_longstring(rd)) then
  862. inserttypeconv(right,clongstringtype);
  863. if not(is_longstring(ld)) then
  864. inserttypeconv(left,clongstringtype);
  865. location.loc:=LOC_CREFERENCE;
  866. end
  867. else
  868. begin
  869. if not(is_shortstring(ld)) then
  870. inserttypeconv(left,cshortstringtype);
  871. { don't convert char, that can be handled by the optimized node }
  872. if not(is_shortstring(rd) or is_char(rd)) then
  873. inserttypeconv(right,cshortstringtype);
  874. end;
  875. end
  876. { pointer comparision and subtraction }
  877. else if (rd.deftype=pointerdef) and (ld.deftype=pointerdef) then
  878. begin
  879. case nodetype of
  880. equaln,unequaln :
  881. begin
  882. if is_voidpointer(right.resulttype.def) then
  883. inserttypeconv(right,left.resulttype)
  884. else if is_voidpointer(left.resulttype.def) then
  885. inserttypeconv(left,right.resulttype)
  886. else if not(is_equal(ld,rd)) then
  887. CGMessage(type_e_mismatch);
  888. end;
  889. ltn,lten,gtn,gten:
  890. begin
  891. if (cs_extsyntax in aktmoduleswitches) then
  892. begin
  893. if is_voidpointer(right.resulttype.def) then
  894. inserttypeconv(right,left.resulttype)
  895. else if is_voidpointer(left.resulttype.def) then
  896. inserttypeconv(left,right.resulttype)
  897. else if not(is_equal(ld,rd)) then
  898. CGMessage(type_e_mismatch);
  899. end
  900. else
  901. CGMessage(type_e_mismatch);
  902. end;
  903. subn:
  904. begin
  905. if (cs_extsyntax in aktmoduleswitches) then
  906. begin
  907. if is_voidpointer(right.resulttype.def) then
  908. inserttypeconv(right,left.resulttype)
  909. else if is_voidpointer(left.resulttype.def) then
  910. inserttypeconv(left,right.resulttype)
  911. else if not(is_equal(ld,rd)) then
  912. CGMessage(type_e_mismatch);
  913. end
  914. else
  915. CGMessage(type_e_mismatch);
  916. resulttype:=s32bittype;
  917. exit;
  918. end;
  919. addn:
  920. begin
  921. if (cs_extsyntax in aktmoduleswitches) then
  922. begin
  923. if is_voidpointer(right.resulttype.def) then
  924. inserttypeconv(right,left.resulttype)
  925. else if is_voidpointer(left.resulttype.def) then
  926. inserttypeconv(left,right.resulttype)
  927. else if not(is_equal(ld,rd)) then
  928. CGMessage(type_e_mismatch);
  929. end
  930. else
  931. CGMessage(type_e_mismatch);
  932. resulttype:=s32bittype;
  933. exit;
  934. end;
  935. else
  936. CGMessage(type_e_mismatch);
  937. end;
  938. end
  939. { class or interface equation }
  940. else if is_class_or_interface(rd) or is_class_or_interface(ld) then
  941. begin
  942. if is_class_or_interface(rd) and is_class_or_interface(ld) then
  943. begin
  944. if tobjectdef(rd).is_related(tobjectdef(ld)) then
  945. inserttypeconv(right,left.resulttype)
  946. else
  947. inserttypeconv(left,right.resulttype);
  948. end
  949. else if is_class_or_interface(rd) then
  950. inserttypeconv(left,right.resulttype)
  951. else
  952. inserttypeconv(right,left.resulttype);
  953. if not(nodetype in [equaln,unequaln]) then
  954. CGMessage(type_e_mismatch);
  955. end
  956. else if (rd.deftype=classrefdef) and (ld.deftype=classrefdef) then
  957. begin
  958. if tobjectdef(tclassrefdef(rd).pointertype.def).is_related(
  959. tobjectdef(tclassrefdef(ld).pointertype.def)) then
  960. inserttypeconv(right,left.resulttype)
  961. else
  962. inserttypeconv(left,right.resulttype);
  963. if not(nodetype in [equaln,unequaln]) then
  964. CGMessage(type_e_mismatch);
  965. end
  966. { allows comperasion with nil pointer }
  967. else if is_class_or_interface(rd) or (rd.deftype=classrefdef) then
  968. begin
  969. inserttypeconv(left,right.resulttype);
  970. if not(nodetype in [equaln,unequaln]) then
  971. CGMessage(type_e_mismatch);
  972. end
  973. else if is_class_or_interface(ld) or (ld.deftype=classrefdef) then
  974. begin
  975. inserttypeconv(right,left.resulttype);
  976. if not(nodetype in [equaln,unequaln]) then
  977. CGMessage(type_e_mismatch);
  978. end
  979. { support procvar=nil,procvar<>nil }
  980. else if ((ld.deftype=procvardef) and (rt=niln)) or
  981. ((rd.deftype=procvardef) and (lt=niln)) then
  982. begin
  983. if not(nodetype in [equaln,unequaln]) then
  984. CGMessage(type_e_mismatch);
  985. end
  986. {$ifdef SUPPORT_MMX}
  987. { mmx support, this must be before the zero based array
  988. check }
  989. else if (cs_mmx in aktlocalswitches) and
  990. is_mmx_able_array(ld) and
  991. is_mmx_able_array(rd) and
  992. is_equal(ld,rd) then
  993. begin
  994. case nodetype of
  995. addn,subn,xorn,orn,andn:
  996. ;
  997. { mul is a little bit restricted }
  998. muln:
  999. if not(mmx_type(ld) in [mmxu16bit,mmxs16bit,mmxfixed16]) then
  1000. CGMessage(type_e_mismatch);
  1001. else
  1002. CGMessage(type_e_mismatch);
  1003. end;
  1004. end
  1005. {$endif SUPPORT_MMX}
  1006. { this is a little bit dangerous, also the left type }
  1007. { pointer to should be checked! This broke the mmx support }
  1008. else if (rd.deftype=pointerdef) or is_zero_based_array(rd) then
  1009. begin
  1010. if is_zero_based_array(rd) then
  1011. begin
  1012. resulttype.setdef(tpointerdef.create(tarraydef(rd).elementtype));
  1013. inserttypeconv(right,resulttype);
  1014. end;
  1015. inserttypeconv(left,s32bittype);
  1016. if nodetype=addn then
  1017. begin
  1018. if not(cs_extsyntax in aktmoduleswitches) or
  1019. (not(is_pchar(ld)) and not(m_add_pointer in aktmodeswitches)) then
  1020. CGMessage(type_e_mismatch);
  1021. if (rd.deftype=pointerdef) and
  1022. (tpointerdef(rd).pointertype.def.size>1) then
  1023. left:=caddnode.create(muln,left,cordconstnode.create(tpointerdef(rd).pointertype.def.size,s32bittype));
  1024. end
  1025. else
  1026. CGMessage(type_e_mismatch);
  1027. end
  1028. else if (ld.deftype=pointerdef) or is_zero_based_array(ld) then
  1029. begin
  1030. if is_zero_based_array(ld) then
  1031. begin
  1032. resulttype.setdef(tpointerdef.create(tarraydef(ld).elementtype));
  1033. inserttypeconv(left,resulttype);
  1034. end;
  1035. inserttypeconv(right,s32bittype);
  1036. if nodetype in [addn,subn] then
  1037. begin
  1038. if not(cs_extsyntax in aktmoduleswitches) or
  1039. (not(is_pchar(ld)) and not(m_add_pointer in aktmodeswitches)) then
  1040. CGMessage(type_e_mismatch);
  1041. if (ld.deftype=pointerdef) and
  1042. (tpointerdef(ld).pointertype.def.size>1) then
  1043. right:=caddnode.create(muln,right,cordconstnode.create(tpointerdef(ld).pointertype.def.size,s32bittype));
  1044. end
  1045. else
  1046. CGMessage(type_e_mismatch);
  1047. end
  1048. else if (rd.deftype=procvardef) and (ld.deftype=procvardef) and is_equal(rd,ld) then
  1049. begin
  1050. if not (nodetype in [equaln,unequaln]) then
  1051. CGMessage(type_e_mismatch);
  1052. end
  1053. { enums }
  1054. else if (ld.deftype=enumdef) and (rd.deftype=enumdef) then
  1055. begin
  1056. if not(is_equal(ld,rd)) then
  1057. inserttypeconv(right,left.resulttype);
  1058. if not(nodetype in [equaln,unequaln,ltn,lten,gtn,gten]) then
  1059. CGMessage(type_e_mismatch);
  1060. end
  1061. { generic conversion, this is for error recovery }
  1062. else
  1063. begin
  1064. inserttypeconv(left,s32bittype);
  1065. inserttypeconv(right,s32bittype);
  1066. end;
  1067. { set resulttype if not already done }
  1068. if not assigned(resulttype.def) then
  1069. begin
  1070. case nodetype of
  1071. ltn,lten,gtn,gten,equaln,unequaln :
  1072. resulttype:=booltype;
  1073. slashn :
  1074. resulttype:=pbestrealtype^;
  1075. addn:
  1076. begin
  1077. { for strings, return is always a 255 char string }
  1078. if is_shortstring(left.resulttype.def) then
  1079. resulttype:=cshortstringtype
  1080. else
  1081. resulttype:=left.resulttype;
  1082. end;
  1083. else
  1084. resulttype:=left.resulttype;
  1085. end;
  1086. end;
  1087. end;
  1088. function taddnode.first_addstring: tnode;
  1089. var
  1090. p: tnode;
  1091. begin
  1092. { when we get here, we are sure that both the left and the right }
  1093. { node are both strings of the same stringtype (JM) }
  1094. case nodetype of
  1095. addn:
  1096. begin
  1097. { note: if you implemented an fpc_shortstr_concat similar to the }
  1098. { one in i386.inc, you have to override first_addstring like in }
  1099. { ti386addnode.first_string and implement the shortstring concat }
  1100. { manually! The generic routine is different from the i386 one (JM) }
  1101. { create the call to the concat routine both strings as arguments }
  1102. result := ccallnode.createintern('fpc_'+
  1103. tstringdef(resulttype.def).stringtypname+'_concat',
  1104. ccallparanode.create(right,ccallparanode.create(left,nil)));
  1105. { we reused the arguments }
  1106. left := nil;
  1107. right := nil;
  1108. firstpass(result);
  1109. end;
  1110. ltn,lten,gtn,gten,equaln,unequaln :
  1111. begin
  1112. { generate better code for s='' and s<>'' }
  1113. if (nodetype in [equaln,unequaln]) and
  1114. (((left.nodetype=stringconstn) and (str_length(left)=0)) or
  1115. ((right.nodetype=stringconstn) and (str_length(right)=0))) then
  1116. begin
  1117. { switch so that the constant is always on the right }
  1118. if left.nodetype = stringconstn then
  1119. begin
  1120. p := left;
  1121. left := right;
  1122. right := p;
  1123. end;
  1124. if is_shortstring(left.resulttype.def) then
  1125. { compare the length with 0 }
  1126. result := caddnode.create(nodetype,
  1127. cinlinenode.create(in_length_x,false,left),
  1128. cordconstnode.create(0,s32bittype))
  1129. else
  1130. begin
  1131. { compare the pointer with nil (for ansistrings etc), }
  1132. { faster than getting the length (JM) }
  1133. result:= caddnode.create(nodetype,
  1134. ctypeconvnode.create(left,voidpointertype),
  1135. cpointerconstnode.create(0,voidpointertype));
  1136. taddnode(result).left.toggleflag(nf_explizit);
  1137. end;
  1138. { left is reused }
  1139. left := nil;
  1140. { right isn't }
  1141. right.free;
  1142. right := nil;
  1143. firstpass(result);
  1144. exit;
  1145. end;
  1146. { no string constant -> call compare routine }
  1147. result := ccallnode.createintern('fpc_'+
  1148. tstringdef(left.resulttype.def).stringtypname+'_compare',
  1149. ccallparanode.create(right,ccallparanode.create(left,nil)));
  1150. { and compare its result with 0 according to the original operator }
  1151. result := caddnode.create(nodetype,result,
  1152. cordconstnode.create(0,s32bittype));
  1153. left := nil;
  1154. right := nil;
  1155. firstpass(result);
  1156. end;
  1157. end;
  1158. end;
  1159. function taddnode.first_addset: tnode;
  1160. var
  1161. procname: string[31];
  1162. tempn: tnode;
  1163. paras: tcallparanode;
  1164. srsym: ttypesym;
  1165. begin
  1166. { get the sym that represents the fpc_normal_set type }
  1167. if not searchsystype('FPC_NORMAL_SET',srsym) then
  1168. internalerror(200108313);
  1169. case nodetype of
  1170. equaln,unequaln,lten,gten:
  1171. begin
  1172. case nodetype of
  1173. equaln,unequaln:
  1174. procname := 'fpc_set_comp_sets';
  1175. lten,gten:
  1176. begin
  1177. procname := 'fpc_set_contains_sets';
  1178. { (left >= right) = (right <= left) }
  1179. if nodetype = gten then
  1180. begin
  1181. tempn := left;
  1182. left := right;
  1183. right := tempn;
  1184. end;
  1185. end;
  1186. end;
  1187. { convert the arguments (explicitely) to fpc_normal_set's }
  1188. left := ctypeconvnode.create_explicit(left,srsym.restype);
  1189. right := ctypeconvnode.create_explicit(right,srsym.restype);
  1190. result := ccallnode.createintern(procname,ccallparanode.create(right,
  1191. ccallparanode.create(left,nil)));
  1192. { left and right are reused as parameters }
  1193. left := nil;
  1194. right := nil;
  1195. { for an unequaln, we have to negate the result of comp_sets }
  1196. if nodetype = unequaln then
  1197. result := cnotnode.create(result);
  1198. end;
  1199. addn:
  1200. begin
  1201. { optimize first loading of a set }
  1202. if (right.nodetype=setelementn) and
  1203. not(assigned(tsetelementnode(right).right)) and
  1204. is_emptyset(left) then
  1205. begin
  1206. { type cast the value to pass as argument to a byte, }
  1207. { since that's what the helper expects }
  1208. tsetelementnode(right).left :=
  1209. ctypeconvnode.create(tsetelementnode(right).left,u8bittype);
  1210. tsetelementnode(right).left.toggleflag(nf_explizit);
  1211. { set the resulttype to the actual one (otherwise it's }
  1212. { "fpc_normal_set") }
  1213. result := ccallnode.createinternres('fpc_set_create_element',
  1214. ccallparanode.create(tsetelementnode(right).left,nil),
  1215. resulttype);
  1216. { reused }
  1217. tsetelementnode(right).left := nil;
  1218. end
  1219. else
  1220. begin
  1221. if right.nodetype=setelementn then
  1222. begin
  1223. { convert the arguments to bytes, since that's what }
  1224. { the helper expects }
  1225. tsetelementnode(right).left :=
  1226. ctypeconvnode.create(tsetelementnode(right).left,
  1227. u8bittype);
  1228. tsetelementnode(right).left.toggleflag(nf_explizit);
  1229. { convert the original set (explicitely) to an }
  1230. { fpc_normal_set so we can pass it to the helper }
  1231. left := ctypeconvnode.create(left,srsym.restype);
  1232. left.toggleflag(nf_explizit);
  1233. { add a range or a single element? }
  1234. if assigned(tsetelementnode(right).right) then
  1235. begin
  1236. tsetelementnode(right).right :=
  1237. ctypeconvnode.create(tsetelementnode(right).right,
  1238. u8bittype);
  1239. tsetelementnode(right).right.toggleflag(nf_explizit);
  1240. { create the call }
  1241. result := ccallnode.createinternres('fpc_set_set_range',
  1242. ccallparanode.create(tsetelementnode(right).right,
  1243. ccallparanode.create(tsetelementnode(right).left,
  1244. ccallparanode.create(left,nil))),resulttype);
  1245. end
  1246. else
  1247. begin
  1248. result := ccallnode.createinternres('fpc_set_set_byte',
  1249. ccallparanode.create(tsetelementnode(right).left,
  1250. ccallparanode.create(left,nil)),resulttype);
  1251. end;
  1252. { remove reused parts from original node }
  1253. tsetelementnode(right).right := nil;
  1254. tsetelementnode(right).left := nil;
  1255. left := nil;
  1256. end
  1257. else
  1258. begin
  1259. { add two sets }
  1260. { convert the sets to fpc_normal_set's }
  1261. left := ctypeconvnode.create(left,srsym.restype);
  1262. left.toggleflag(nf_explizit);
  1263. right := ctypeconvnode.create(right,srsym.restype);
  1264. right.toggleflag(nf_explizit);
  1265. result := ccallnode.createinternres('fpc_set_add_sets',
  1266. ccallparanode.create(right,
  1267. ccallparanode.create(left,nil)),resulttype);
  1268. { remove reused parts from original node }
  1269. left := nil;
  1270. right := nil;
  1271. end;
  1272. end
  1273. end;
  1274. subn,symdifn,muln:
  1275. begin
  1276. { convert the sets to fpc_normal_set's }
  1277. left := ctypeconvnode.create(left,srsym.restype);
  1278. left.toggleflag(nf_explizit);
  1279. right := ctypeconvnode.create(right,srsym.restype);
  1280. right.toggleflag(nf_explizit);
  1281. paras := ccallparanode.create(right,
  1282. ccallparanode.create(left,nil));
  1283. case nodetype of
  1284. subn:
  1285. result := ccallnode.createinternres('fpc_set_sub_sets',
  1286. paras,resulttype);
  1287. symdifn:
  1288. result := ccallnode.createinternres('fpc_set_symdif_sets',
  1289. paras,resulttype);
  1290. muln:
  1291. result := ccallnode.createinternres('fpc_set_mul_sets',
  1292. paras,resulttype);
  1293. end;
  1294. { remove reused parts from original node }
  1295. left := nil;
  1296. right := nil;
  1297. end;
  1298. else
  1299. internalerror(200108311);
  1300. end;
  1301. firstpass(result);
  1302. end;
  1303. function taddnode.first_add64bitint: tnode;
  1304. var
  1305. procname: string[31];
  1306. temp: tnode;
  1307. power: longint;
  1308. begin
  1309. result := nil;
  1310. { create helper calls mul }
  1311. if nodetype <> muln then
  1312. exit;
  1313. { make sure that if there is a constant, that it's on the right }
  1314. if left.nodetype = ordconstn then
  1315. begin
  1316. temp := right;
  1317. right := left;
  1318. left := temp;
  1319. end;
  1320. { can we use a shift instead of a mul? }
  1321. if (right.nodetype = ordconstn) and
  1322. ispowerof2(tordconstnode(right).value,power) then
  1323. begin
  1324. tordconstnode(right).value := power;
  1325. result := cshlshrnode.create(shln,left,right);
  1326. { left and right are reused }
  1327. left := nil;
  1328. right := nil;
  1329. { return firstpassed new node }
  1330. firstpass(result);
  1331. exit;
  1332. end;
  1333. { otherwise, create the parameters for the helper }
  1334. right := ccallparanode.create(
  1335. cordconstnode.create(ord(cs_check_overflow in aktlocalswitches),booltype),
  1336. ccallparanode.create(right,ccallparanode.create(left,nil)));
  1337. left := nil;
  1338. if torddef(resulttype.def).typ = s64bit then
  1339. procname := 'fpc_mul_int64'
  1340. else
  1341. procname := 'fpc_mul_qword';
  1342. result := ccallnode.createintern(procname,right);
  1343. right := nil;
  1344. firstpass(result);
  1345. end;
  1346. function taddnode.first_addfloat: tnode;
  1347. var
  1348. procname: string[31];
  1349. temp: tnode;
  1350. power: longint;
  1351. { do we need to reverse the result ? }
  1352. notnode : boolean;
  1353. begin
  1354. result := nil;
  1355. notnode := false;
  1356. { In non-emulation mode, real opcodes are
  1357. emitted for floating point values.
  1358. }
  1359. if not (cs_fp_emulation in aktmoduleswitches) then
  1360. exit;
  1361. procname := 'FPC_REAL_';
  1362. case nodetype of
  1363. addn : procname := procname + 'ADD';
  1364. muln : procname := procname + 'MUL';
  1365. subn : procname := procname + 'SUB';
  1366. slashn : procname := procname + 'DIV';
  1367. ltn : procname := procname + 'LESS_THAN';
  1368. lten: procname := procname + 'LESS_EQUAL_THAN';
  1369. gtn:
  1370. begin
  1371. procname := procname + 'LESS_EQUAL_THAN';
  1372. notnode := true;
  1373. end;
  1374. gten:
  1375. begin
  1376. procname := procname + 'LESS_THAN';
  1377. notnode := true;
  1378. end;
  1379. equaln: procname := procname + 'EQUAL';
  1380. unequaln :
  1381. begin
  1382. procname := procname + 'EQUAL';
  1383. notnode := true;
  1384. end;
  1385. else
  1386. CGMessage(type_e_mismatch);
  1387. end;
  1388. { otherwise, create the parameters for the helper }
  1389. right := ccallparanode.create(right,ccallparanode.create(left,nil));
  1390. left := nil;
  1391. { do we need to reverse the result }
  1392. if notnode then
  1393. result := cnotnode.create(ccallnode.createintern(procname,right))
  1394. else
  1395. result := ccallnode.createintern(procname,right);
  1396. right := nil;
  1397. firstpass(result);
  1398. end;
  1399. function taddnode.pass_1 : tnode;
  1400. var
  1401. hp : tnode;
  1402. lt,rt : tnodetype;
  1403. rd,ld : tdef;
  1404. begin
  1405. result:=nil;
  1406. { first do the two subtrees }
  1407. firstpass(left);
  1408. firstpass(right);
  1409. if codegenerror then
  1410. exit;
  1411. { load easier access variables }
  1412. rd:=right.resulttype.def;
  1413. ld:=left.resulttype.def;
  1414. rt:=right.nodetype;
  1415. lt:=left.nodetype;
  1416. { int/int gives real/real! }
  1417. if nodetype=slashn then
  1418. begin
  1419. result := first_addfloat;
  1420. if assigned(result) then
  1421. exit;
  1422. location.loc:=LOC_FPUREGISTER;
  1423. { maybe we need an integer register to save }
  1424. { a reference }
  1425. if ((left.location.loc<>LOC_FPUREGISTER) or
  1426. (right.location.loc<>LOC_FPUREGISTER)) and
  1427. (left.registers32=right.registers32) then
  1428. calcregisters(self,1,1,0)
  1429. else
  1430. calcregisters(self,0,1,0);
  1431. { an add node always first loads both the left and the }
  1432. { right in the fpu before doing the calculation. However, }
  1433. { calcregisters(0,2,0) will overestimate the number of }
  1434. { necessary registers (it will make it 3 in case one of }
  1435. { the operands is already in the fpu) (JM) }
  1436. if ((left.location.loc <> LOC_FPUREGISTER) or
  1437. (right.location.loc <> LOC_FPUREGISTER)) and
  1438. (registersfpu < 2) then
  1439. inc(registersfpu);
  1440. end
  1441. { if both are orddefs then check sub types }
  1442. else if (ld.deftype=orddef) and (rd.deftype=orddef) then
  1443. begin
  1444. { 2 booleans ? }
  1445. if is_boolean(ld) and is_boolean(rd) then
  1446. begin
  1447. if not(cs_full_boolean_eval in aktlocalswitches) and
  1448. (nodetype in [andn,orn]) then
  1449. begin
  1450. location.loc:=LOC_JUMP;
  1451. calcregisters(self,0,0,0);
  1452. end
  1453. else
  1454. begin
  1455. location.loc := LOC_FLAGS;
  1456. if (left.location.loc in [LOC_JUMP,LOC_FLAGS]) and
  1457. (left.location.loc in [LOC_JUMP,LOC_FLAGS]) then
  1458. calcregisters(self,2,0,0)
  1459. else
  1460. calcregisters(self,1,0,0);
  1461. end;
  1462. end
  1463. else
  1464. { Both are chars? only convert to shortstrings for addn }
  1465. if is_char(ld) then
  1466. begin
  1467. if nodetype=addn then
  1468. internalerror(200103291);
  1469. location.loc := LOC_FLAGS;
  1470. calcregisters(self,1,0,0);
  1471. end
  1472. { is there a 64 bit type ? }
  1473. else if (torddef(ld).typ in [s64bit,u64bit]) then
  1474. begin
  1475. result := first_add64bitint;
  1476. if assigned(result) then
  1477. exit;
  1478. if nodetype in [addn,subn,muln,andn,orn,xorn] then
  1479. location.loc := LOC_REGISTER
  1480. else
  1481. location.loc := LOC_JUMP;
  1482. calcregisters(self,2,0,0)
  1483. end
  1484. { is there a cardinal? }
  1485. else if (torddef(ld).typ=u32bit) then
  1486. begin
  1487. if nodetype in [addn,subn,muln,andn,orn,xorn] then
  1488. location.loc := LOC_REGISTER
  1489. else
  1490. location.loc := LOC_FLAGS;
  1491. calcregisters(self,1,0,0);
  1492. { for unsigned mul we need an extra register }
  1493. if nodetype=muln then
  1494. inc(registers32);
  1495. end
  1496. { generic s32bit conversion }
  1497. else
  1498. begin
  1499. if nodetype in [addn,subn,muln,andn,orn,xorn] then
  1500. location.loc := LOC_REGISTER
  1501. else
  1502. location.loc := LOC_FLAGS;
  1503. calcregisters(self,1,0,0);
  1504. end;
  1505. end
  1506. { left side a setdef, must be before string processing,
  1507. else array constructor can be seen as array of char (PFV) }
  1508. else if (ld.deftype=setdef) then
  1509. begin
  1510. if tsetdef(ld).settype=smallset then
  1511. begin
  1512. location.loc:=LOC_REGISTER;
  1513. { are we adding set elements ? }
  1514. if right.nodetype=setelementn then
  1515. calcregisters(self,2,0,0)
  1516. else
  1517. calcregisters(self,1,0,0);
  1518. end
  1519. else
  1520. begin
  1521. result := first_addset;
  1522. if assigned(result) then
  1523. exit;
  1524. location.loc:=LOC_CREFERENCE;
  1525. calcregisters(self,0,0,0);
  1526. { here we call SET... }
  1527. if assigned(procinfo) then
  1528. procinfo.flags:=procinfo.flags or pi_do_call;
  1529. end;
  1530. end
  1531. { compare pchar by addresses like BP/Delphi }
  1532. else if is_pchar(ld) then
  1533. begin
  1534. location.loc:=LOC_REGISTER;
  1535. calcregisters(self,1,0,0);
  1536. end
  1537. { is one of the operands a string }
  1538. else if (ld.deftype=stringdef) then
  1539. begin
  1540. if is_widestring(ld) then
  1541. begin
  1542. { we use reference counted widestrings so no fast exit here }
  1543. if assigned(procinfo) then
  1544. procinfo.no_fast_exit:=true;
  1545. { this is only for add, the comparisaion is handled later }
  1546. location.loc:=LOC_REGISTER;
  1547. end
  1548. else if is_ansistring(ld) then
  1549. begin
  1550. { we use ansistrings so no fast exit here }
  1551. if assigned(procinfo) then
  1552. procinfo.no_fast_exit:=true;
  1553. { this is only for add, the comparisaion is handled later }
  1554. location.loc:=LOC_REGISTER;
  1555. end
  1556. else if is_longstring(ld) then
  1557. begin
  1558. { this is only for add, the comparisaion is handled later }
  1559. location.loc:=LOC_CREFERENCE;
  1560. end
  1561. else
  1562. begin
  1563. if canbeaddsstringcharoptnode(self) then
  1564. begin
  1565. hp := genaddsstringcharoptnode(self);
  1566. firstpass(hp);
  1567. pass_1 := hp;
  1568. exit;
  1569. end
  1570. else
  1571. begin
  1572. { Fix right to be shortstring }
  1573. if is_char(right.resulttype.def) then
  1574. begin
  1575. inserttypeconv(right,cshortstringtype);
  1576. firstpass(right);
  1577. end;
  1578. end;
  1579. if canbeaddsstringcsstringoptnode(self) then
  1580. begin
  1581. hp := genaddsstringcsstringoptnode(self);
  1582. firstpass(hp);
  1583. pass_1 := hp;
  1584. exit;
  1585. end;
  1586. end;
  1587. { otherwise, let addstring convert everything }
  1588. result := first_addstring;
  1589. exit;
  1590. end
  1591. { is one a real float ? }
  1592. else if (rd.deftype=floatdef) or (ld.deftype=floatdef) then
  1593. begin
  1594. result := first_addfloat;
  1595. if assigned(result) then
  1596. exit;
  1597. location.loc:=LOC_FPUREGISTER;
  1598. calcregisters(self,0,1,0);
  1599. { an add node always first loads both the left and the }
  1600. { right in the fpu before doing the calculation. However, }
  1601. { calcregisters(0,2,0) will overestimate the number of }
  1602. { necessary registers (it will make it 3 in case one of }
  1603. { the operands is already in the fpu) (JM) }
  1604. if ((left.location.loc <> LOC_FPUREGISTER) or
  1605. (right.location.loc <> LOC_FPUREGISTER)) and
  1606. (registersfpu < 2) then
  1607. inc(registersfpu);
  1608. end
  1609. { pointer comperation and subtraction }
  1610. else if (ld.deftype=pointerdef) then
  1611. begin
  1612. location.loc:=LOC_REGISTER;
  1613. calcregisters(self,1,0,0);
  1614. end
  1615. else if is_class_or_interface(ld) then
  1616. begin
  1617. location.loc:=LOC_REGISTER;
  1618. calcregisters(self,1,0,0);
  1619. end
  1620. else if (ld.deftype=classrefdef) then
  1621. begin
  1622. location.loc:=LOC_REGISTER;
  1623. calcregisters(self,1,0,0);
  1624. end
  1625. { support procvar=nil,procvar<>nil }
  1626. else if ((ld.deftype=procvardef) and (rt=niln)) or
  1627. ((rd.deftype=procvardef) and (lt=niln)) then
  1628. begin
  1629. location.loc:=LOC_REGISTER;
  1630. calcregisters(self,1,0,0);
  1631. end
  1632. {$ifdef SUPPORT_MMX}
  1633. { mmx support, this must be before the zero based array
  1634. check }
  1635. else if (cs_mmx in aktlocalswitches) and is_mmx_able_array(ld) and
  1636. is_mmx_able_array(rd) then
  1637. begin
  1638. location.loc:=LOC_MMXREGISTER;
  1639. calcregisters(self,0,0,1);
  1640. end
  1641. {$endif SUPPORT_MMX}
  1642. else if (rd.deftype=pointerdef) or (ld.deftype=pointerdef) then
  1643. begin
  1644. location.loc:=LOC_REGISTER;
  1645. calcregisters(self,1,0,0);
  1646. end
  1647. else if (rd.deftype=procvardef) and (ld.deftype=procvardef) and is_equal(rd,ld) then
  1648. begin
  1649. location.loc:=LOC_REGISTER;
  1650. calcregisters(self,1,0,0);
  1651. end
  1652. else if (ld.deftype=enumdef) then
  1653. begin
  1654. location.loc := LOC_FLAGS;
  1655. calcregisters(self,1,0,0);
  1656. end
  1657. {$ifdef SUPPORT_MMX}
  1658. else if (cs_mmx in aktlocalswitches) and
  1659. is_mmx_able_array(ld) and
  1660. is_mmx_able_array(rd) then
  1661. begin
  1662. location.loc:=LOC_MMXREGISTER;
  1663. calcregisters(self,0,0,1);
  1664. end
  1665. {$endif SUPPORT_MMX}
  1666. { the general solution is to convert to 32 bit int }
  1667. else
  1668. begin
  1669. location.loc:=LOC_REGISTER;
  1670. calcregisters(self,1,0,0);
  1671. end;
  1672. end;
  1673. {$ifdef state_tracking}
  1674. function Taddnode.track_state_pass(exec_known:boolean):boolean;
  1675. var factval:Tnode;
  1676. begin
  1677. track_state_pass:=false;
  1678. if left.track_state_pass(exec_known) then
  1679. begin
  1680. track_state_pass:=true;
  1681. left.resulttype.def:=nil;
  1682. do_resulttypepass(left);
  1683. end;
  1684. factval:=aktstate.find_fact(left);
  1685. if factval<>nil then
  1686. begin
  1687. track_state_pass:=true;
  1688. left.destroy;
  1689. left:=factval.getcopy;
  1690. end;
  1691. if right.track_state_pass(exec_known) then
  1692. begin
  1693. track_state_pass:=true;
  1694. right.resulttype.def:=nil;
  1695. do_resulttypepass(right);
  1696. end;
  1697. factval:=aktstate.find_fact(right);
  1698. if factval<>nil then
  1699. begin
  1700. track_state_pass:=true;
  1701. right.destroy;
  1702. right:=factval.getcopy;
  1703. end;
  1704. end;
  1705. {$endif}
  1706. begin
  1707. caddnode:=taddnode;
  1708. end.
  1709. {
  1710. $Log$
  1711. Revision 1.63 2002-09-04 19:32:56 jonas
  1712. * changed some ctypeconvnode/toggleflag(nf_explizit) combo's to
  1713. ctypeconvnode.create_explicit() statements
  1714. Revision 1.62 2002/08/17 09:23:34 florian
  1715. * first part of procinfo rewrite
  1716. Revision 1.61 2002/08/15 15:15:55 carl
  1717. * jmpbuf size allocation for exceptions is now cpu specific (as it should)
  1718. * more generic nodes for maths
  1719. * several fixes for better m68k support
  1720. Revision 1.60 2002/08/12 15:08:39 carl
  1721. + stab register indexes for powerpc (moved from gdb to cpubase)
  1722. + tprocessor enumeration moved to cpuinfo
  1723. + linker in target_info is now a class
  1724. * many many updates for m68k (will soon start to compile)
  1725. - removed some ifdef or correct them for correct cpu
  1726. Revision 1.59 2002/08/02 07:44:30 jonas
  1727. * made assigned() handling generic
  1728. * add nodes now can also evaluate constant expressions at compile time
  1729. that contain nil nodes
  1730. Revision 1.58 2002/07/26 11:17:52 jonas
  1731. * the optimization of converting a multiplication with a power of two to
  1732. a shl is moved from n386add/secondpass to nadd/resulttypepass
  1733. Revision 1.57 2002/07/23 13:08:16 jonas
  1734. * fixed constant set evaluation of new set handling for non-commutative
  1735. operators
  1736. Revision 1.56 2002/07/23 12:34:29 daniel
  1737. * Readded old set code. To use it define 'oldset'. Activated by default
  1738. for ppc.
  1739. Revision 1.55 2002/07/22 11:48:04 daniel
  1740. * Sets are now internally sets.
  1741. Revision 1.54 2002/07/20 11:57:53 florian
  1742. * types.pas renamed to defbase.pas because D6 contains a types
  1743. unit so this would conflicts if D6 programms are compiled
  1744. + Willamette/SSE2 instructions to assembler added
  1745. Revision 1.53 2002/07/19 11:41:34 daniel
  1746. * State tracker work
  1747. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1748. allows the state tracker to change while nodes automatically into
  1749. repeat nodes.
  1750. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1751. 'not(a>b)' is optimized into 'a<=b'.
  1752. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1753. by removing the notn and later switchting the true and falselabels. The
  1754. same is done with 'repeat until not a'.
  1755. Revision 1.52 2002/07/14 18:00:43 daniel
  1756. + Added the beginning of a state tracker. This will track the values of
  1757. variables through procedures and optimize things away.
  1758. Revision 1.51 2002/05/18 13:34:08 peter
  1759. * readded missing revisions
  1760. Revision 1.50 2002/05/16 19:46:37 carl
  1761. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1762. + try to fix temp allocation (still in ifdef)
  1763. + generic constructor calls
  1764. + start of tassembler / tmodulebase class cleanup
  1765. Revision 1.48 2002/05/13 19:54:36 peter
  1766. * removed n386ld and n386util units
  1767. * maybe_save/maybe_restore added instead of the old maybe_push
  1768. Revision 1.47 2002/05/12 16:53:06 peter
  1769. * moved entry and exitcode to ncgutil and cgobj
  1770. * foreach gets extra argument for passing local data to the
  1771. iterator function
  1772. * -CR checks also class typecasts at runtime by changing them
  1773. into as
  1774. * fixed compiler to cycle with the -CR option
  1775. * fixed stabs with elf writer, finally the global variables can
  1776. be watched
  1777. * removed a lot of routines from cga unit and replaced them by
  1778. calls to cgobj
  1779. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  1780. u32bit then the other is typecasted also to u32bit without giving
  1781. a rangecheck warning/error.
  1782. * fixed pascal calling method with reversing also the high tree in
  1783. the parast, detected by tcalcst3 test
  1784. Revision 1.46 2002/04/23 19:16:34 peter
  1785. * add pinline unit that inserts compiler supported functions using
  1786. one or more statements
  1787. * moved finalize and setlength from ninl to pinline
  1788. Revision 1.45 2002/04/04 19:05:56 peter
  1789. * removed unused units
  1790. * use tlocation.size in cg.a_*loc*() routines
  1791. Revision 1.44 2002/04/02 17:11:28 peter
  1792. * tlocation,treference update
  1793. * LOC_CONSTANT added for better constant handling
  1794. * secondadd splitted in multiple routines
  1795. * location_force_reg added for loading a location to a register
  1796. of a specified size
  1797. * secondassignment parses now first the right and then the left node
  1798. (this is compatible with Kylix). This saves a lot of push/pop especially
  1799. with string operations
  1800. * adapted some routines to use the new cg methods
  1801. Revision 1.43 2002/03/30 23:12:09 carl
  1802. * avoid crash with procinfo ('merged')
  1803. }