nadd.pas 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 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 defines.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. end;
  29. var
  30. { caddnode is used to create nodes of the add type }
  31. { the virtual constructor allows to assign }
  32. { another class type to caddnode => processor }
  33. { specific node types can be created }
  34. caddnode : class of taddnode;
  35. implementation
  36. uses
  37. globtype,systems,
  38. cutils,verbose,globals,widestr,
  39. symconst,symtype,symdef,types,
  40. cpuinfo,
  41. {$ifdef newcg}
  42. cgbase,
  43. {$else newcg}
  44. hcodegen,
  45. {$endif newcg}
  46. htypechk,pass_1,
  47. nmat,ncnv,nld,ncon,nset,nopt,
  48. cpubase;
  49. {*****************************************************************************
  50. TADDNODE
  51. *****************************************************************************}
  52. {$ifdef fpc}
  53. {$maxfpuregisters 0}
  54. {$endif fpc}
  55. constructor taddnode.create(tt : tnodetype;l,r : tnode);
  56. begin
  57. inherited create(tt,l,r);
  58. end;
  59. function taddnode.det_resulttype:tnode;
  60. var
  61. hp,t : tnode;
  62. lt,rt : tnodetype;
  63. rd,ld : tdef;
  64. htype : ttype;
  65. ot : tnodetype;
  66. concatstrings : boolean;
  67. resultset : pconstset;
  68. i : longint;
  69. b : boolean;
  70. s1,s2 : pchar;
  71. ws1,ws2 : pcompilerwidestring;
  72. l1,l2 : longint;
  73. rv,lv : tconstexprint;
  74. rvd,lvd : bestreal;
  75. begin
  76. result:=nil;
  77. { first do the two subtrees }
  78. resulttypepass(left);
  79. resulttypepass(right);
  80. { both left and right need to be valid }
  81. set_varstate(left,true);
  82. set_varstate(right,true);
  83. if codegenerror then
  84. exit;
  85. { convert array constructors to sets, because there is no other operator
  86. possible for array constructors }
  87. if is_array_constructor(left.resulttype.def) then
  88. begin
  89. arrayconstructor_to_set(tarrayconstructornode(left));
  90. resulttypepass(left);
  91. end;
  92. if is_array_constructor(right.resulttype.def) then
  93. begin
  94. arrayconstructor_to_set(tarrayconstructornode(right));
  95. resulttypepass(right);
  96. end;
  97. { allow operator overloading }
  98. hp:=self;
  99. if isbinaryoverloaded(hp) then
  100. begin
  101. resulttypepass(hp);
  102. result:=hp;
  103. exit;
  104. end;
  105. { Kylix allows enum+ordconstn in an enum declaration (blocktype
  106. is bt_type), we need to do the conversion here before the
  107. constant folding }
  108. if (m_delphi in aktmodeswitches) and
  109. (blocktype=bt_type) then
  110. begin
  111. if (left.resulttype.def.deftype=enumdef) and
  112. (right.resulttype.def.deftype=orddef) then
  113. begin
  114. { insert explicit typecast to s32bit }
  115. left:=ctypeconvnode.create(left,s32bittype);
  116. include(left.flags,nf_explizit);
  117. resulttypepass(left);
  118. end
  119. else
  120. if (left.resulttype.def.deftype=orddef) and
  121. (right.resulttype.def.deftype=enumdef) then
  122. begin
  123. { insert explicit typecast to s32bit }
  124. right:=ctypeconvnode.create(right,s32bittype);
  125. include(right.flags,nf_explizit);
  126. resulttypepass(right);
  127. end;
  128. end;
  129. { is one a real float, then both need to be floats, this
  130. need to be done before the constant folding so constant
  131. operation on a float and int are also handled }
  132. if (right.resulttype.def.deftype=floatdef) or (left.resulttype.def.deftype=floatdef) then
  133. begin
  134. inserttypeconv(right,pbestrealtype^);
  135. inserttypeconv(left,pbestrealtype^);
  136. end;
  137. { if one operand is a widechar or a widestring, both operands }
  138. { are converted to widestring. This must be done before constant }
  139. { folding to allow char+widechar etc. }
  140. if is_widestring(right.resulttype.def) or
  141. is_widestring(left.resulttype.def) or
  142. is_widechar(right.resulttype.def) or
  143. is_widechar(left.resulttype.def) then
  144. begin
  145. inserttypeconv(right,cwidestringtype);
  146. inserttypeconv(left,cwidestringtype);
  147. end;
  148. { load easier access variables }
  149. rd:=right.resulttype.def;
  150. ld:=left.resulttype.def;
  151. rt:=right.nodetype;
  152. lt:=left.nodetype;
  153. { both are int constants }
  154. if (((is_constintnode(left) and is_constintnode(right)) or
  155. (is_constboolnode(left) and is_constboolnode(right) and
  156. (nodetype in [ltn,lten,gtn,gten,equaln,unequaln,andn,xorn,orn])))) or
  157. { support pointer arithmetics on constants (JM) }
  158. ((lt = pointerconstn) and is_constintnode(right) and
  159. (nodetype in [addn,subn])) or
  160. ((lt = pointerconstn) and (rt = pointerconstn) and
  161. (nodetype in [ltn,lten,gtn,gten,equaln,unequaln,subn])) then
  162. begin
  163. { when comparing/substracting pointers, make sure they are }
  164. { of the same type (JM) }
  165. if (lt = pointerconstn) and (rt = pointerconstn) then
  166. begin
  167. if not(cs_extsyntax in aktmoduleswitches) and
  168. not(nodetype in [equaln,unequaln]) then
  169. CGMessage(type_e_mismatch)
  170. else
  171. if (nodetype <> subn) and
  172. is_voidpointer(rd) then
  173. inserttypeconv(right,left.resulttype)
  174. else if (nodetype <> subn) and
  175. is_voidpointer(ld) then
  176. inserttypeconv(left,right.resulttype)
  177. else if not(is_equal(ld,rd)) then
  178. CGMessage(type_e_mismatch);
  179. end
  180. else if (lt=ordconstn) and (rt=ordconstn) then
  181. begin
  182. { make left const type the biggest, this type will be used
  183. for orn,andn,xorn }
  184. if rd.size>ld.size then
  185. inserttypeconv(left,right.resulttype);
  186. end;
  187. { load values }
  188. if (lt = ordconstn) then
  189. lv:=tordconstnode(left).value
  190. else
  191. lv:=tpointerconstnode(left).value;
  192. if (rt = ordconstn) then
  193. rv:=tordconstnode(right).value
  194. else
  195. rv:=tpointerconstnode(right).value;
  196. if (lt = pointerconstn) and
  197. (rt <> pointerconstn) then
  198. rv := rv * tpointerdef(left.resulttype.def).pointertype.def.size;
  199. if (rt = pointerconstn) and
  200. (lt <> pointerconstn) then
  201. lv := lv * tpointerdef(right.resulttype.def).pointertype.def.size;
  202. case nodetype of
  203. addn :
  204. if (lt <> pointerconstn) then
  205. t := genintconstnode(lv+rv)
  206. else
  207. t := cpointerconstnode.create(lv+rv,left.resulttype);
  208. subn :
  209. if (lt <> pointerconstn) or (rt = pointerconstn) then
  210. t := genintconstnode(lv-rv)
  211. else
  212. t := cpointerconstnode.create(lv-rv,left.resulttype);
  213. muln :
  214. t:=genintconstnode(lv*rv);
  215. xorn :
  216. t:=cordconstnode.create(lv xor rv,left.resulttype);
  217. orn :
  218. t:=cordconstnode.create(lv or rv,left.resulttype);
  219. andn :
  220. t:=cordconstnode.create(lv and rv,left.resulttype);
  221. ltn :
  222. t:=cordconstnode.create(ord(lv<rv),booltype);
  223. lten :
  224. t:=cordconstnode.create(ord(lv<=rv),booltype);
  225. gtn :
  226. t:=cordconstnode.create(ord(lv>rv),booltype);
  227. gten :
  228. t:=cordconstnode.create(ord(lv>=rv),booltype);
  229. equaln :
  230. t:=cordconstnode.create(ord(lv=rv),booltype);
  231. unequaln :
  232. t:=cordconstnode.create(ord(lv<>rv),booltype);
  233. slashn :
  234. begin
  235. { int/int becomes a real }
  236. if int(rv)=0 then
  237. begin
  238. Message(parser_e_invalid_float_operation);
  239. t:=crealconstnode.create(0,pbestrealtype^);
  240. end
  241. else
  242. t:=crealconstnode.create(int(lv)/int(rv),pbestrealtype^);
  243. end;
  244. else
  245. CGMessage(type_e_mismatch);
  246. end;
  247. resulttypepass(t);
  248. result:=t;
  249. exit;
  250. end;
  251. { both real constants ? }
  252. if (lt=realconstn) and (rt=realconstn) then
  253. begin
  254. lvd:=trealconstnode(left).value_real;
  255. rvd:=trealconstnode(right).value_real;
  256. case nodetype of
  257. addn :
  258. t:=crealconstnode.create(lvd+rvd,pbestrealtype^);
  259. subn :
  260. t:=crealconstnode.create(lvd-rvd,pbestrealtype^);
  261. muln :
  262. t:=crealconstnode.create(lvd*rvd,pbestrealtype^);
  263. starstarn,
  264. caretn :
  265. begin
  266. if lvd<0 then
  267. begin
  268. Message(parser_e_invalid_float_operation);
  269. t:=crealconstnode.create(0,pbestrealtype^);
  270. end
  271. else if lvd=0 then
  272. t:=crealconstnode.create(1.0,pbestrealtype^)
  273. else
  274. t:=crealconstnode.create(exp(ln(lvd)*rvd),pbestrealtype^);
  275. end;
  276. slashn :
  277. begin
  278. if rvd=0 then
  279. begin
  280. Message(parser_e_invalid_float_operation);
  281. t:=crealconstnode.create(0,pbestrealtype^);
  282. end
  283. else
  284. t:=crealconstnode.create(lvd/rvd,pbestrealtype^);
  285. end;
  286. ltn :
  287. t:=cordconstnode.create(ord(lvd<rvd),booltype);
  288. lten :
  289. t:=cordconstnode.create(ord(lvd<=rvd),booltype);
  290. gtn :
  291. t:=cordconstnode.create(ord(lvd>rvd),booltype);
  292. gten :
  293. t:=cordconstnode.create(ord(lvd>=rvd),booltype);
  294. equaln :
  295. t:=cordconstnode.create(ord(lvd=rvd),booltype);
  296. unequaln :
  297. t:=cordconstnode.create(ord(lvd<>rvd),booltype);
  298. else
  299. CGMessage(type_e_mismatch);
  300. end;
  301. resulttypepass(t);
  302. result:=t;
  303. exit;
  304. end;
  305. { first, we handle widestrings, so we can check later for }
  306. { stringconstn only }
  307. { widechars are converted above to widestrings too }
  308. { this isn't veryy efficient, but I don't think }
  309. { that it does matter that much (FK) }
  310. if (lt=stringconstn) and (rt=stringconstn) and
  311. (tstringconstnode(left).st_type=st_widestring) and
  312. (tstringconstnode(right).st_type=st_widestring) then
  313. begin
  314. initwidestring(ws1);
  315. initwidestring(ws2);
  316. copywidestring(pcompilerwidestring(tstringconstnode(left).value_str),ws1);
  317. copywidestring(pcompilerwidestring(tstringconstnode(right).value_str),ws2);
  318. case nodetype of
  319. addn :
  320. begin
  321. concatwidestrings(ws1,ws2);
  322. t:=cstringconstnode.createwstr(ws1);
  323. end;
  324. ltn :
  325. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<0),booltype);
  326. lten :
  327. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<=0),booltype);
  328. gtn :
  329. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)>0),booltype);
  330. gten :
  331. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)>=0),booltype);
  332. equaln :
  333. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)=0),booltype);
  334. unequaln :
  335. t:=cordconstnode.create(byte(comparewidestrings(ws1,ws2)<>0),booltype);
  336. end;
  337. donewidestring(ws1);
  338. donewidestring(ws2);
  339. resulttypepass(t);
  340. result:=t;
  341. exit;
  342. end;
  343. { concating strings ? }
  344. concatstrings:=false;
  345. s1:=nil;
  346. s2:=nil;
  347. if (lt=ordconstn) and (rt=ordconstn) and
  348. is_char(ld) and is_char(rd) then
  349. begin
  350. s1:=strpnew(char(byte(tordconstnode(left).value)));
  351. s2:=strpnew(char(byte(tordconstnode(right).value)));
  352. l1:=1;
  353. l2:=1;
  354. concatstrings:=true;
  355. end
  356. else
  357. if (lt=stringconstn) and (rt=ordconstn) and is_char(rd) then
  358. begin
  359. s1:=tstringconstnode(left).getpcharcopy;
  360. l1:=tstringconstnode(left).len;
  361. s2:=strpnew(char(byte(tordconstnode(right).value)));
  362. l2:=1;
  363. concatstrings:=true;
  364. end
  365. else
  366. if (lt=ordconstn) and (rt=stringconstn) and is_char(ld) then
  367. begin
  368. s1:=strpnew(char(byte(tordconstnode(left).value)));
  369. l1:=1;
  370. s2:=tstringconstnode(right).getpcharcopy;
  371. l2:=tstringconstnode(right).len;
  372. concatstrings:=true;
  373. end
  374. else if (lt=stringconstn) and (rt=stringconstn) then
  375. begin
  376. s1:=tstringconstnode(left).getpcharcopy;
  377. l1:=tstringconstnode(left).len;
  378. s2:=tstringconstnode(right).getpcharcopy;
  379. l2:=tstringconstnode(right).len;
  380. concatstrings:=true;
  381. end;
  382. if concatstrings then
  383. begin
  384. case nodetype of
  385. addn :
  386. t:=cstringconstnode.createpchar(concatansistrings(s1,s2,l1,l2),l1+l2);
  387. ltn :
  388. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<0),booltype);
  389. lten :
  390. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<=0),booltype);
  391. gtn :
  392. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)>0),booltype);
  393. gten :
  394. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)>=0),booltype);
  395. equaln :
  396. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)=0),booltype);
  397. unequaln :
  398. t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<>0),booltype);
  399. end;
  400. ansistringdispose(s1,l1);
  401. ansistringdispose(s2,l2);
  402. resulttypepass(t);
  403. result:=t;
  404. exit;
  405. end;
  406. { set constant evaluation }
  407. if (right.nodetype=setconstn) and
  408. not assigned(tsetconstnode(right).left) and
  409. (left.nodetype=setconstn) and
  410. not assigned(tsetconstnode(left).left) then
  411. begin
  412. { check types }
  413. inserttypeconv(left,right.resulttype);
  414. if codegenerror then
  415. begin
  416. { recover by only returning the left part }
  417. result:=left;
  418. left:=nil;
  419. exit;
  420. end;
  421. new(resultset);
  422. case nodetype of
  423. addn :
  424. begin
  425. for i:=0 to 31 do
  426. resultset^[i]:=tsetconstnode(right).value_set^[i] or tsetconstnode(left).value_set^[i];
  427. t:=csetconstnode.create(resultset,left.resulttype);
  428. end;
  429. muln :
  430. begin
  431. for i:=0 to 31 do
  432. resultset^[i]:=tsetconstnode(right).value_set^[i] and tsetconstnode(left).value_set^[i];
  433. t:=csetconstnode.create(resultset,left.resulttype);
  434. end;
  435. subn :
  436. begin
  437. for i:=0 to 31 do
  438. resultset^[i]:=tsetconstnode(left).value_set^[i] and not(tsetconstnode(right).value_set^[i]);
  439. t:=csetconstnode.create(resultset,left.resulttype);
  440. end;
  441. symdifn :
  442. begin
  443. for i:=0 to 31 do
  444. resultset^[i]:=tsetconstnode(left).value_set^[i] xor tsetconstnode(right).value_set^[i];
  445. t:=csetconstnode.create(resultset,left.resulttype);
  446. end;
  447. unequaln :
  448. begin
  449. b:=true;
  450. for i:=0 to 31 do
  451. if tsetconstnode(right).value_set^[i]=tsetconstnode(left).value_set^[i] then
  452. begin
  453. b:=false;
  454. break;
  455. end;
  456. t:=cordconstnode.create(ord(b),booltype);
  457. end;
  458. equaln :
  459. begin
  460. b:=true;
  461. for i:=0 to 31 do
  462. if tsetconstnode(right).value_set^[i]<>tsetconstnode(left).value_set^[i] then
  463. begin
  464. b:=false;
  465. break;
  466. end;
  467. t:=cordconstnode.create(ord(b),booltype);
  468. end;
  469. lten :
  470. begin
  471. b := true;
  472. For i := 0 to 31 Do
  473. If (tsetconstnode(right).value_set^[i] And tsetconstnode(left).value_set^[i]) <>
  474. tsetconstnode(left).value_set^[i] Then
  475. Begin
  476. b := false;
  477. Break
  478. End;
  479. t := cordconstnode.create(ord(b),booltype);
  480. End;
  481. gten :
  482. Begin
  483. b := true;
  484. For i := 0 to 31 Do
  485. If (tsetconstnode(left).value_set^[i] And tsetconstnode(right).value_set^[i]) <>
  486. tsetconstnode(right).value_set^[i] Then
  487. Begin
  488. b := false;
  489. Break
  490. End;
  491. t := cordconstnode.create(ord(b),booltype);
  492. End;
  493. end;
  494. dispose(resultset);
  495. resulttypepass(t);
  496. result:=t;
  497. exit;
  498. end;
  499. { but an int/int gives real/real! }
  500. if nodetype=slashn then
  501. begin
  502. CGMessage(type_h_use_div_for_int);
  503. inserttypeconv(right,pbestrealtype^);
  504. inserttypeconv(left,pbestrealtype^);
  505. end
  506. { if both are orddefs then check sub types }
  507. else if (ld.deftype=orddef) and (rd.deftype=orddef) then
  508. begin
  509. { 2 booleans? Make them equal to the largest boolean }
  510. if is_boolean(ld) and is_boolean(rd) then
  511. begin
  512. if torddef(left.resulttype.def).size>torddef(right.resulttype.def).size then
  513. begin
  514. inserttypeconv(right,left.resulttype);
  515. ttypeconvnode(right).convtype:=tc_bool_2_int;
  516. include(right.flags,nf_explizit);
  517. end
  518. else if torddef(left.resulttype.def).size<torddef(right.resulttype.def).size then
  519. begin
  520. inserttypeconv(left,right.resulttype);
  521. ttypeconvnode(left).convtype:=tc_bool_2_int;
  522. include(left.flags,nf_explizit);
  523. end;
  524. case nodetype of
  525. xorn,
  526. ltn,
  527. lten,
  528. gtn,
  529. gten,
  530. andn,
  531. orn:
  532. begin
  533. end;
  534. unequaln,
  535. equaln:
  536. begin
  537. if not(cs_full_boolean_eval in aktlocalswitches) then
  538. begin
  539. { Remove any compares with constants }
  540. if (left.nodetype=ordconstn) then
  541. begin
  542. hp:=right;
  543. b:=(tordconstnode(left).value<>0);
  544. ot:=nodetype;
  545. left.free;
  546. left:=nil;
  547. right:=nil;
  548. if (not(b) and (ot=equaln)) or
  549. (b and (ot=unequaln)) then
  550. begin
  551. hp:=cnotnode.create(hp);
  552. resulttypepass(hp);
  553. end;
  554. result:=hp;
  555. exit;
  556. end;
  557. if (right.nodetype=ordconstn) then
  558. begin
  559. hp:=left;
  560. b:=(tordconstnode(right).value<>0);
  561. ot:=nodetype;
  562. right.free;
  563. right:=nil;
  564. left:=nil;
  565. if (not(b) and (ot=equaln)) or
  566. (b and (ot=unequaln)) then
  567. begin
  568. hp:=cnotnode.create(hp);
  569. resulttypepass(hp);
  570. end;
  571. result:=hp;
  572. exit;
  573. end;
  574. end;
  575. end;
  576. else
  577. CGMessage(type_e_mismatch);
  578. end;
  579. end
  580. { Both are chars? }
  581. else if is_char(rd) and is_char(ld) then
  582. begin
  583. if nodetype=addn then
  584. begin
  585. resulttype:=cshortstringtype;
  586. if not(is_constcharnode(left) and is_constcharnode(right)) then
  587. begin
  588. inserttypeconv(left,cshortstringtype);
  589. hp := genaddsstringcharoptnode(self);
  590. resulttypepass(hp);
  591. result := hp;
  592. exit;
  593. end;
  594. end;
  595. end
  596. { is there a signed 64 bit type ? }
  597. else if ((torddef(rd).typ=s64bit) or (torddef(ld).typ=s64bit)) then
  598. begin
  599. if (torddef(ld).typ<>s64bit) then
  600. inserttypeconv(left,cs64bittype);
  601. if (torddef(rd).typ<>s64bit) then
  602. inserttypeconv(right,cs64bittype);
  603. end
  604. { is there a unsigned 64 bit type ? }
  605. else if ((torddef(rd).typ=u64bit) or (torddef(ld).typ=u64bit)) then
  606. begin
  607. if (torddef(ld).typ<>u64bit) then
  608. inserttypeconv(left,cu64bittype);
  609. if (torddef(rd).typ<>u64bit) then
  610. inserttypeconv(right,cu64bittype);
  611. end
  612. { is there a cardinal? }
  613. else if ((torddef(rd).typ=u32bit) or (torddef(ld).typ=u32bit)) then
  614. begin
  615. if is_signed(ld) and
  616. { then rd = u32bit }
  617. { convert positive constants to u32bit }
  618. not(is_constintnode(left) and
  619. (tordconstnode(left).value >= 0)) and
  620. { range/overflow checking on mixed signed/cardinal expressions }
  621. { is only possible if you convert everything to 64bit (JM) }
  622. ((aktlocalswitches * [cs_check_overflow,cs_check_range] <> []) and
  623. (nodetype in [addn,subn,muln])) then
  624. begin
  625. { perform the operation in 64bit }
  626. CGMessage(type_w_mixed_signed_unsigned);
  627. inserttypeconv(left,cs64bittype);
  628. inserttypeconv(right,cs64bittype);
  629. end
  630. else
  631. begin
  632. if is_signed(ld) and
  633. not(is_constintnode(left) and
  634. (tordconstnode(left).value >= 0)) and
  635. (cs_check_range in aktlocalswitches) then
  636. CGMessage(type_w_mixed_signed_unsigned2);
  637. inserttypeconv(left,u32bittype);
  638. if is_signed(rd) and
  639. { then ld = u32bit }
  640. { convert positive constants to u32bit }
  641. not(is_constintnode(right) and
  642. (tordconstnode(right).value >= 0)) and
  643. ((aktlocalswitches * [cs_check_overflow,cs_check_range] <> []) and
  644. (nodetype in [addn,subn,muln])) then
  645. begin
  646. { perform the operation in 64bit }
  647. CGMessage(type_w_mixed_signed_unsigned);
  648. inserttypeconv(left,cs64bittype);
  649. inserttypeconv(right,cs64bittype);
  650. end
  651. else
  652. begin
  653. if is_signed(rd) and
  654. not(is_constintnode(right) and
  655. (tordconstnode(right).value >= 0)) and
  656. (cs_check_range in aktlocalswitches) then
  657. CGMessage(type_w_mixed_signed_unsigned2);
  658. inserttypeconv(right,u32bittype);
  659. end;
  660. end;
  661. end
  662. { generic ord conversion is s32bit }
  663. else
  664. begin
  665. inserttypeconv(right,s32bittype);
  666. inserttypeconv(left,s32bittype);
  667. end;
  668. end
  669. { if both are floatdefs, conversion is already done before constant folding }
  670. else if (ld.deftype=floatdef) then
  671. begin
  672. { already converted }
  673. end
  674. { left side a setdef, must be before string processing,
  675. else array constructor can be seen as array of char (PFV) }
  676. else if (ld.deftype=setdef) then
  677. begin
  678. { trying to add a set element? }
  679. if (nodetype=addn) and (rd.deftype<>setdef) then
  680. begin
  681. if (rt=setelementn) then
  682. begin
  683. if not(is_equal(tsetdef(ld).elementtype.def,rd)) then
  684. CGMessage(type_e_set_element_are_not_comp);
  685. end
  686. else
  687. CGMessage(type_e_mismatch)
  688. end
  689. else
  690. begin
  691. if not(nodetype in [addn,subn,symdifn,muln,equaln,unequaln,lten,gten]) then
  692. CGMessage(type_e_set_operation_unknown);
  693. { right def must be a also be set }
  694. if (rd.deftype<>setdef) or not(is_equal(rd,ld)) then
  695. CGMessage(type_e_set_element_are_not_comp);
  696. end;
  697. { ranges require normsets }
  698. if (tsetdef(ld).settype=smallset) and
  699. (rt=setelementn) and
  700. assigned(tsetelementnode(right).right) then
  701. begin
  702. { generate a temporary normset def, it'll be destroyed
  703. when the symtable is unloaded }
  704. htype.setdef(tsetdef.create(tsetdef(ld).elementtype,255));
  705. inserttypeconv(left,htype);
  706. end;
  707. end
  708. { compare pchar to char arrays by addresses like BP/Delphi }
  709. else if (is_pchar(ld) and is_chararray(rd)) or
  710. (is_pchar(rd) and is_chararray(ld)) then
  711. begin
  712. if is_chararray(rd) then
  713. inserttypeconv(right,left.resulttype)
  714. else
  715. inserttypeconv(left,right.resulttype);
  716. end
  717. { is one of the operands a string?,
  718. chararrays are also handled as strings (after conversion), also take
  719. care of chararray+chararray and chararray+char }
  720. else if (rd.deftype=stringdef) or (ld.deftype=stringdef) or
  721. ((is_chararray(rd) or is_char(rd)) and
  722. (is_chararray(ld) or is_char(ld))) then
  723. begin
  724. if is_widestring(rd) or is_widestring(ld) then
  725. begin
  726. if not(is_widestring(rd)) then
  727. inserttypeconv(right,cwidestringtype);
  728. if not(is_widestring(ld)) then
  729. inserttypeconv(left,cwidestringtype);
  730. end
  731. else if is_ansistring(rd) or is_ansistring(ld) then
  732. begin
  733. if not(is_ansistring(rd)) then
  734. inserttypeconv(right,cansistringtype);
  735. if not(is_ansistring(ld)) then
  736. inserttypeconv(left,cansistringtype);
  737. end
  738. else if is_longstring(rd) or is_longstring(ld) then
  739. begin
  740. if not(is_longstring(rd)) then
  741. inserttypeconv(right,clongstringtype);
  742. if not(is_longstring(ld)) then
  743. inserttypeconv(left,clongstringtype);
  744. location.loc:=LOC_MEM;
  745. end
  746. else
  747. begin
  748. if not(is_shortstring(ld)) then
  749. inserttypeconv(left,cshortstringtype);
  750. { don't convert char, that can be handled by the optimized node }
  751. if not(is_shortstring(rd) or is_char(rd)) then
  752. inserttypeconv(right,cshortstringtype);
  753. end;
  754. end
  755. { pointer comparision and subtraction }
  756. else if (rd.deftype=pointerdef) and (ld.deftype=pointerdef) then
  757. begin
  758. case nodetype of
  759. equaln,unequaln :
  760. begin
  761. if is_voidpointer(right.resulttype.def) then
  762. inserttypeconv(right,left.resulttype)
  763. else if is_voidpointer(left.resulttype.def) then
  764. inserttypeconv(left,right.resulttype)
  765. else if not(is_equal(ld,rd)) then
  766. CGMessage(type_e_mismatch);
  767. end;
  768. ltn,lten,gtn,gten:
  769. begin
  770. if (cs_extsyntax in aktmoduleswitches) then
  771. begin
  772. if is_voidpointer(right.resulttype.def) then
  773. inserttypeconv(right,left.resulttype)
  774. else if is_voidpointer(left.resulttype.def) then
  775. inserttypeconv(left,right.resulttype)
  776. else if not(is_equal(ld,rd)) then
  777. CGMessage(type_e_mismatch);
  778. end
  779. else
  780. CGMessage(type_e_mismatch);
  781. end;
  782. subn:
  783. begin
  784. if (cs_extsyntax in aktmoduleswitches) then
  785. begin
  786. if is_voidpointer(right.resulttype.def) then
  787. inserttypeconv(right,left.resulttype)
  788. else if is_voidpointer(left.resulttype.def) then
  789. inserttypeconv(left,right.resulttype)
  790. else if not(is_equal(ld,rd)) then
  791. CGMessage(type_e_mismatch);
  792. end
  793. else
  794. CGMessage(type_e_mismatch);
  795. resulttype:=s32bittype;
  796. exit;
  797. end;
  798. addn:
  799. begin
  800. if (cs_extsyntax in aktmoduleswitches) then
  801. begin
  802. if is_voidpointer(right.resulttype.def) then
  803. inserttypeconv(right,left.resulttype)
  804. else if is_voidpointer(left.resulttype.def) then
  805. inserttypeconv(left,right.resulttype)
  806. else if not(is_equal(ld,rd)) then
  807. CGMessage(type_e_mismatch);
  808. end
  809. else
  810. CGMessage(type_e_mismatch);
  811. resulttype:=s32bittype;
  812. exit;
  813. end;
  814. else
  815. CGMessage(type_e_mismatch);
  816. end;
  817. end
  818. { class or interface equation }
  819. else if is_class_or_interface(rd) or is_class_or_interface(ld) then
  820. begin
  821. if is_class_or_interface(rd) and is_class_or_interface(ld) then
  822. begin
  823. if tobjectdef(rd).is_related(tobjectdef(ld)) then
  824. inserttypeconv(right,left.resulttype)
  825. else
  826. inserttypeconv(left,right.resulttype);
  827. end
  828. else if is_class_or_interface(rd) then
  829. inserttypeconv(left,right.resulttype)
  830. else
  831. inserttypeconv(right,left.resulttype);
  832. if not(nodetype in [equaln,unequaln]) then
  833. CGMessage(type_e_mismatch);
  834. end
  835. else if (rd.deftype=classrefdef) and (ld.deftype=classrefdef) then
  836. begin
  837. if tobjectdef(tclassrefdef(rd).pointertype.def).is_related(
  838. tobjectdef(tclassrefdef(ld).pointertype.def)) then
  839. inserttypeconv(right,left.resulttype)
  840. else
  841. inserttypeconv(left,right.resulttype);
  842. if not(nodetype in [equaln,unequaln]) then
  843. CGMessage(type_e_mismatch);
  844. end
  845. { allows comperasion with nil pointer }
  846. else if is_class_or_interface(rd) or (rd.deftype=classrefdef) then
  847. begin
  848. inserttypeconv(left,right.resulttype);
  849. if not(nodetype in [equaln,unequaln]) then
  850. CGMessage(type_e_mismatch);
  851. end
  852. else if is_class_or_interface(ld) or (ld.deftype=classrefdef) then
  853. begin
  854. inserttypeconv(right,left.resulttype);
  855. if not(nodetype in [equaln,unequaln]) then
  856. CGMessage(type_e_mismatch);
  857. end
  858. { support procvar=nil,procvar<>nil }
  859. else if ((ld.deftype=procvardef) and (rt=niln)) or
  860. ((rd.deftype=procvardef) and (lt=niln)) then
  861. begin
  862. if not(nodetype in [equaln,unequaln]) then
  863. CGMessage(type_e_mismatch);
  864. end
  865. {$ifdef SUPPORT_MMX}
  866. { mmx support, this must be before the zero based array
  867. check }
  868. else if (cs_mmx in aktlocalswitches) and
  869. is_mmx_able_array(ld) and
  870. is_mmx_able_array(rd) and
  871. is_equal(ld,rd) then
  872. begin
  873. case nodetype of
  874. addn,subn,xorn,orn,andn:
  875. ;
  876. { mul is a little bit restricted }
  877. muln:
  878. if not(mmx_type(ld) in [mmxu16bit,mmxs16bit,mmxfixed16]) then
  879. CGMessage(type_e_mismatch);
  880. else
  881. CGMessage(type_e_mismatch);
  882. end;
  883. end
  884. {$endif SUPPORT_MMX}
  885. { this is a little bit dangerous, also the left type }
  886. { pointer to should be checked! This broke the mmx support }
  887. else if (rd.deftype=pointerdef) or is_zero_based_array(rd) then
  888. begin
  889. if is_zero_based_array(rd) then
  890. begin
  891. resulttype.setdef(tpointerdef.create(tarraydef(rd).elementtype));
  892. inserttypeconv(right,resulttype);
  893. end;
  894. inserttypeconv(left,s32bittype);
  895. if nodetype=addn then
  896. begin
  897. if not(cs_extsyntax in aktmoduleswitches) or
  898. (not(is_pchar(ld)) and not(m_add_pointer in aktmodeswitches)) then
  899. CGMessage(type_e_mismatch);
  900. if (rd.deftype=pointerdef) and
  901. (tpointerdef(rd).pointertype.def.size>1) then
  902. left:=caddnode.create(muln,left,cordconstnode.create(tpointerdef(rd).pointertype.def.size,s32bittype));
  903. end
  904. else
  905. CGMessage(type_e_mismatch);
  906. end
  907. else if (ld.deftype=pointerdef) or is_zero_based_array(ld) then
  908. begin
  909. if is_zero_based_array(ld) then
  910. begin
  911. resulttype.setdef(tpointerdef.create(tarraydef(ld).elementtype));
  912. inserttypeconv(left,resulttype);
  913. end;
  914. inserttypeconv(right,s32bittype);
  915. if nodetype in [addn,subn] then
  916. begin
  917. if not(cs_extsyntax in aktmoduleswitches) or
  918. (not(is_pchar(ld)) and not(m_add_pointer in aktmodeswitches)) then
  919. CGMessage(type_e_mismatch);
  920. if (ld.deftype=pointerdef) and
  921. (tpointerdef(ld).pointertype.def.size>1) then
  922. right:=caddnode.create(muln,right,cordconstnode.create(tpointerdef(ld).pointertype.def.size,s32bittype));
  923. end
  924. else
  925. CGMessage(type_e_mismatch);
  926. end
  927. else if (rd.deftype=procvardef) and (ld.deftype=procvardef) and is_equal(rd,ld) then
  928. begin
  929. if not (nodetype in [equaln,unequaln]) then
  930. CGMessage(type_e_mismatch);
  931. end
  932. { enums }
  933. else if (ld.deftype=enumdef) and (rd.deftype=enumdef) then
  934. begin
  935. if not(is_equal(ld,rd)) then
  936. inserttypeconv(right,left.resulttype);
  937. if not(nodetype in [equaln,unequaln,ltn,lten,gtn,gten]) then
  938. CGMessage(type_e_mismatch);
  939. end
  940. { generic conversion, this is for error recovery }
  941. else
  942. begin
  943. inserttypeconv(left,s32bittype);
  944. inserttypeconv(right,s32bittype);
  945. end;
  946. { set resulttype if not already done }
  947. if not assigned(resulttype.def) then
  948. begin
  949. case nodetype of
  950. ltn,lten,gtn,gten,equaln,unequaln :
  951. resulttype:=booltype;
  952. slashn :
  953. resulttype:=pbestrealtype^;
  954. addn:
  955. begin
  956. { for strings, return is always a 255 char string }
  957. if is_shortstring(left.resulttype.def) then
  958. resulttype:=cshortstringtype
  959. else
  960. resulttype:=left.resulttype;
  961. end;
  962. else
  963. resulttype:=left.resulttype;
  964. end;
  965. end;
  966. end;
  967. function taddnode.pass_1 : tnode;
  968. var
  969. hp : tnode;
  970. lt,rt : tnodetype;
  971. rd,ld : tdef;
  972. begin
  973. result:=nil;
  974. { first do the two subtrees }
  975. firstpass(left);
  976. firstpass(right);
  977. if codegenerror then
  978. exit;
  979. { load easier access variables }
  980. rd:=right.resulttype.def;
  981. ld:=left.resulttype.def;
  982. rt:=right.nodetype;
  983. lt:=left.nodetype;
  984. { int/int gives real/real! }
  985. if nodetype=slashn then
  986. begin
  987. { maybe we need an integer register to save }
  988. { a reference }
  989. if ((left.location.loc<>LOC_FPU) or
  990. (right.location.loc<>LOC_FPU)) and
  991. (left.registers32=right.registers32) then
  992. calcregisters(self,1,1,0)
  993. else
  994. calcregisters(self,0,1,0);
  995. location.loc:=LOC_FPU;
  996. end
  997. { if both are orddefs then check sub types }
  998. else if (ld.deftype=orddef) and (rd.deftype=orddef) then
  999. begin
  1000. { 2 booleans ? }
  1001. if is_boolean(ld) and is_boolean(rd) then
  1002. begin
  1003. if not(cs_full_boolean_eval in aktlocalswitches) and
  1004. (nodetype in [andn,orn]) then
  1005. begin
  1006. calcregisters(self,0,0,0);
  1007. location.loc:=LOC_JUMP;
  1008. end
  1009. else
  1010. begin
  1011. if (left.location.loc in [LOC_JUMP,LOC_FLAGS]) and
  1012. (left.location.loc in [LOC_JUMP,LOC_FLAGS]) then
  1013. calcregisters(self,2,0,0)
  1014. else
  1015. calcregisters(self,1,0,0);
  1016. end;
  1017. end
  1018. else
  1019. { Both are chars? only convert to shortstrings for addn }
  1020. if is_char(ld) then
  1021. begin
  1022. if nodetype=addn then
  1023. internalerror(200103291);
  1024. calcregisters(self,1,0,0);
  1025. end
  1026. { is there a 64 bit type ? }
  1027. else if (torddef(ld).typ in [s64bit,u64bit]) then
  1028. calcregisters(self,2,0,0)
  1029. { is there a cardinal? }
  1030. else if (torddef(ld).typ=u32bit) then
  1031. begin
  1032. calcregisters(self,1,0,0);
  1033. { for unsigned mul we need an extra register }
  1034. if nodetype=muln then
  1035. inc(registers32);
  1036. end
  1037. { generic s32bit conversion }
  1038. else
  1039. calcregisters(self,1,0,0);
  1040. end
  1041. { left side a setdef, must be before string processing,
  1042. else array constructor can be seen as array of char (PFV) }
  1043. else if (ld.deftype=setdef) then
  1044. begin
  1045. if tsetdef(ld).settype=smallset then
  1046. begin
  1047. { are we adding set elements ? }
  1048. if right.nodetype=setelementn then
  1049. calcregisters(self,2,0,0)
  1050. else
  1051. calcregisters(self,1,0,0);
  1052. location.loc:=LOC_REGISTER;
  1053. end
  1054. else
  1055. begin
  1056. calcregisters(self,0,0,0);
  1057. { here we call SET... }
  1058. procinfo^.flags:=procinfo^.flags or pi_do_call;
  1059. location.loc:=LOC_MEM;
  1060. end;
  1061. end
  1062. { compare pchar by addresses like BP/Delphi }
  1063. else if is_pchar(ld) then
  1064. begin
  1065. location.loc:=LOC_REGISTER;
  1066. calcregisters(self,1,0,0);
  1067. end
  1068. { is one of the operands a string }
  1069. else if (ld.deftype=stringdef) then
  1070. begin
  1071. if is_widestring(ld) then
  1072. begin
  1073. { we use reference counted widestrings so no fast exit here }
  1074. procinfo^.no_fast_exit:=true;
  1075. { this is only for add, the comparisaion is handled later }
  1076. location.loc:=LOC_REGISTER;
  1077. end
  1078. else if is_ansistring(ld) then
  1079. begin
  1080. { we use ansistrings so no fast exit here }
  1081. procinfo^.no_fast_exit:=true;
  1082. { this is only for add, the comparisaion is handled later }
  1083. location.loc:=LOC_REGISTER;
  1084. end
  1085. else if is_longstring(ld) then
  1086. begin
  1087. { this is only for add, the comparisaion is handled later }
  1088. location.loc:=LOC_MEM;
  1089. end
  1090. else
  1091. begin
  1092. if canbeaddsstringcharoptnode(self) then
  1093. begin
  1094. hp := genaddsstringcharoptnode(self);
  1095. firstpass(hp);
  1096. pass_1 := hp;
  1097. exit;
  1098. end
  1099. else
  1100. begin
  1101. { Fix right to be shortstring }
  1102. if is_char(right.resulttype.def) then
  1103. begin
  1104. inserttypeconv(right,cshortstringtype);
  1105. firstpass(right);
  1106. end;
  1107. end;
  1108. if canbeaddsstringcsstringoptnode(self) then
  1109. begin
  1110. hp := genaddsstringcsstringoptnode(self);
  1111. firstpass(hp);
  1112. pass_1 := hp;
  1113. exit;
  1114. end;
  1115. { this is only for add, the comparisaion is handled later }
  1116. location.loc:=LOC_MEM;
  1117. end;
  1118. { here we call STRCONCAT or STRCMP or STRCOPY }
  1119. procinfo^.flags:=procinfo^.flags or pi_do_call;
  1120. if location.loc=LOC_MEM then
  1121. calcregisters(self,0,0,0)
  1122. else
  1123. calcregisters(self,1,0,0);
  1124. end
  1125. { is one a real float ? }
  1126. else if (rd.deftype=floatdef) or (ld.deftype=floatdef) then
  1127. begin
  1128. calcregisters(self,0,1,0);
  1129. location.loc:=LOC_FPU;
  1130. end
  1131. { pointer comperation and subtraction }
  1132. else if (ld.deftype=pointerdef) then
  1133. begin
  1134. location.loc:=LOC_REGISTER;
  1135. calcregisters(self,1,0,0);
  1136. end
  1137. else if is_class_or_interface(ld) then
  1138. begin
  1139. location.loc:=LOC_REGISTER;
  1140. calcregisters(self,1,0,0);
  1141. end
  1142. else if (ld.deftype=classrefdef) then
  1143. begin
  1144. location.loc:=LOC_REGISTER;
  1145. calcregisters(self,1,0,0);
  1146. end
  1147. { support procvar=nil,procvar<>nil }
  1148. else if ((ld.deftype=procvardef) and (rt=niln)) or
  1149. ((rd.deftype=procvardef) and (lt=niln)) then
  1150. begin
  1151. calcregisters(self,1,0,0);
  1152. location.loc:=LOC_REGISTER;
  1153. end
  1154. {$ifdef SUPPORT_MMX}
  1155. { mmx support, this must be before the zero based array
  1156. check }
  1157. else if (cs_mmx in aktlocalswitches) and is_mmx_able_array(ld) and
  1158. is_mmx_able_array(rd) then
  1159. begin
  1160. location.loc:=LOC_MMXREGISTER;
  1161. calcregisters(self,0,0,1);
  1162. end
  1163. {$endif SUPPORT_MMX}
  1164. else if (rd.deftype=pointerdef) or (ld.deftype=pointerdef) then
  1165. begin
  1166. location.loc:=LOC_REGISTER;
  1167. calcregisters(self,1,0,0);
  1168. end
  1169. else if (rd.deftype=procvardef) and (ld.deftype=procvardef) and is_equal(rd,ld) then
  1170. begin
  1171. calcregisters(self,1,0,0);
  1172. location.loc:=LOC_REGISTER;
  1173. end
  1174. else if (ld.deftype=enumdef) then
  1175. begin
  1176. calcregisters(self,1,0,0);
  1177. end
  1178. {$ifdef SUPPORT_MMX}
  1179. else if (cs_mmx in aktlocalswitches) and
  1180. is_mmx_able_array(ld) and
  1181. is_mmx_able_array(rd) then
  1182. begin
  1183. location.loc:=LOC_MMXREGISTER;
  1184. calcregisters(self,0,0,1);
  1185. end
  1186. {$endif SUPPORT_MMX}
  1187. { the general solution is to convert to 32 bit int }
  1188. else
  1189. begin
  1190. calcregisters(self,1,0,0);
  1191. location.loc:=LOC_REGISTER;
  1192. end;
  1193. case nodetype of
  1194. ltn,lten,gtn,gten,equaln,unequaln:
  1195. begin
  1196. if is_64bitint(left.resulttype.def) then
  1197. location.loc:=LOC_JUMP
  1198. else
  1199. location.loc:=LOC_FLAGS;
  1200. end;
  1201. xorn:
  1202. begin
  1203. location.loc:=LOC_REGISTER;
  1204. end;
  1205. end;
  1206. end;
  1207. begin
  1208. caddnode:=taddnode;
  1209. end.
  1210. {
  1211. $Log$
  1212. Revision 1.31 2001-07-08 21:00:14 peter
  1213. * various widestring updates, it works now mostly without charset
  1214. mapping supported
  1215. Revision 1.30 2001/06/04 21:41:26 peter
  1216. * readded generic conversion to s32bit that i removed yesterday. It
  1217. is still used for error recovery, added a small note about that
  1218. Revision 1.29 2001/06/04 18:13:53 peter
  1219. * Support kylix hack of having enum+integer in a enum declaration.
  1220. Revision 1.28 2001/05/27 14:30:55 florian
  1221. + some widestring stuff added
  1222. Revision 1.27 2001/05/19 21:11:50 peter
  1223. * first check for overloaded operator before doing inserting any
  1224. typeconvs
  1225. Revision 1.26 2001/05/19 12:53:52 peter
  1226. * check set types when doing constant set evaluation
  1227. Revision 1.25 2001/04/13 01:22:08 peter
  1228. * symtable change to classes
  1229. * range check generation and errors fixed, make cycle DEBUG=1 works
  1230. * memory leaks fixed
  1231. Revision 1.24 2001/04/04 22:42:39 peter
  1232. * move constant folding into det_resulttype
  1233. Revision 1.23 2001/04/02 21:20:30 peter
  1234. * resulttype rewrite
  1235. Revision 1.22 2001/02/04 11:12:17 jonas
  1236. * fixed web bug 1377 & const pointer arithmtic
  1237. Revision 1.21 2001/01/14 22:13:13 peter
  1238. * constant calculation fixed. The type of the new constant is now
  1239. defined after the calculation is done. This should remove a lot
  1240. of wrong warnings (and errors with -Cr).
  1241. Revision 1.20 2000/12/31 11:14:10 jonas
  1242. + implemented/fixed docompare() mathods for all nodes (not tested)
  1243. + nopt.pas, nadd.pas, i386/n386opt.pas: optimized nodes for adding strings
  1244. and constant strings/chars together
  1245. * n386add.pas: don't copy temp strings (of size 256) to another temp string
  1246. when adding
  1247. Revision 1.19 2000/12/16 15:55:32 jonas
  1248. + warning when there is a chance to get a range check error because of
  1249. automatic type conversion to u32bit
  1250. * arithmetic operations with a cardinal and a signed operand are carried
  1251. out in 64bit when range checking is on ("merged" from fixes branch)
  1252. Revision 1.18 2000/11/29 00:30:31 florian
  1253. * unused units removed from uses clause
  1254. * some changes for widestrings
  1255. Revision 1.17 2000/11/20 15:30:42 jonas
  1256. * changed types of values used for constant expression evaluation to
  1257. tconstexprint
  1258. Revision 1.16 2000/11/13 11:30:55 florian
  1259. * some bugs with interfaces and NIL fixed
  1260. Revision 1.15 2000/11/04 14:25:20 florian
  1261. + merged Attila's changes for interfaces, not tested yet
  1262. Revision 1.14 2000/10/31 22:02:47 peter
  1263. * symtable splitted, no real code changes
  1264. Revision 1.13 2000/10/14 10:14:50 peter
  1265. * moehrendorf oct 2000 rewrite
  1266. Revision 1.12 2000/10/01 19:48:23 peter
  1267. * lot of compile updates for cg11
  1268. Revision 1.11 2000/09/30 16:08:45 peter
  1269. * more cg11 updates
  1270. Revision 1.10 2000/09/28 19:49:52 florian
  1271. *** empty log message ***
  1272. Revision 1.9 2000/09/27 21:33:22 florian
  1273. * finally nadd.pas compiles
  1274. Revision 1.8 2000/09/27 20:25:44 florian
  1275. * more stuff fixed
  1276. Revision 1.7 2000/09/27 18:14:31 florian
  1277. * fixed a lot of syntax errors in the n*.pas stuff
  1278. Revision 1.6 2000/09/24 15:06:19 peter
  1279. * use defines.inc
  1280. Revision 1.5 2000/09/22 22:42:52 florian
  1281. * more fixes
  1282. Revision 1.4 2000/09/21 12:22:42 jonas
  1283. * put piece of code between -dnewoptimizations2 since it wasn't
  1284. necessary otherwise
  1285. + support for full boolean evaluation (from tcadd)
  1286. Revision 1.3 2000/09/20 21:50:59 florian
  1287. * updated
  1288. Revision 1.2 2000/08/29 08:24:45 jonas
  1289. * some modifications to -dcardinalmulfix code
  1290. Revision 1.1 2000/08/26 12:24:20 florian
  1291. * initial release
  1292. }