nmat.pas 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
  1. {
  2. Copyright (c) 2000-2005 by Florian Klaempfl
  3. Type checking and register allocation for math nodes
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit nmat;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node;
  22. type
  23. tmoddivnode = class(tbinopnode)
  24. function pass_1 : tnode;override;
  25. function pass_typecheck:tnode;override;
  26. function simplify(forinline : boolean) : tnode;override;
  27. protected
  28. { override the following if you want to implement }
  29. { parts explicitely in the code generator (JM) }
  30. function use_moddiv64bitint_helper: boolean; virtual;
  31. function first_moddiv64bitint: tnode; virtual;
  32. function firstoptimize: tnode; virtual;
  33. function first_moddivint: tnode; virtual;
  34. end;
  35. tmoddivnodeclass = class of tmoddivnode;
  36. tshlshrnode = class(tbinopnode)
  37. function pass_1 : tnode;override;
  38. function pass_typecheck:tnode;override;
  39. function simplify(forinline : boolean) : tnode;override;
  40. {$if not defined(cpu64bitalu) and not defined(cpuhighleveltarget)}
  41. { override the following if you want to implement }
  42. { parts explicitely in the code generator (CEC)
  43. Should return nil, if everything will be handled
  44. in the code generator
  45. }
  46. function first_shlshr64bitint: tnode; virtual;
  47. {$endif not cpu64bitalu and not cpuhighleveltarget}
  48. end;
  49. tshlshrnodeclass = class of tshlshrnode;
  50. tunaryminusnode = class(tunarynode)
  51. constructor create(expr : tnode);virtual;
  52. function pass_1 : tnode;override;
  53. function pass_typecheck:tnode;override;
  54. function simplify(forinline : boolean) : tnode;override;
  55. end;
  56. tunaryminusnodeclass = class of tunaryminusnode;
  57. tunaryplusnode = class(tunarynode)
  58. constructor create(expr : tnode);virtual;
  59. function pass_1 : tnode;override;
  60. function pass_typecheck:tnode;override;
  61. end;
  62. tunaryplusnodeclass = class of tunaryplusnode;
  63. tnotnode = class(tunarynode)
  64. constructor create(expr : tnode);virtual;
  65. function pass_1 : tnode;override;
  66. function pass_typecheck:tnode;override;
  67. function simplify(forinline : boolean) : tnode;override;
  68. {$ifdef state_tracking}
  69. function track_state_pass(exec_known:boolean):boolean;override;
  70. {$endif}
  71. end;
  72. tnotnodeclass = class of tnotnode;
  73. var
  74. cmoddivnode : tmoddivnodeclass = tmoddivnode;
  75. cshlshrnode : tshlshrnodeclass = tshlshrnode;
  76. cunaryminusnode : tunaryminusnodeclass = tunaryminusnode;
  77. cunaryplusnode : tunaryplusnodeclass = tunaryplusnode;
  78. cnotnode : tnotnodeclass = tnotnode;
  79. implementation
  80. uses
  81. systems,
  82. verbose,globals,cutils,compinnr,
  83. globtype,constexp,
  84. symconst,symtype,symdef,
  85. defcmp,defutil,
  86. htypechk,pass_1,
  87. cgbase,
  88. ncon,ncnv,ncal,nadd,nld,nbas,nflw,ninl,
  89. nutils;
  90. {****************************************************************************
  91. TMODDIVNODE
  92. ****************************************************************************}
  93. function tmoddivnode.simplify(forinline : boolean):tnode;
  94. var
  95. rv,lv : tconstexprint;
  96. begin
  97. result:=nil;
  98. if is_constintnode(right) then
  99. begin
  100. rv:=tordconstnode(right).value;
  101. if rv = 1 then
  102. begin
  103. case nodetype of
  104. modn:
  105. result := cordconstnode.create(0,left.resultdef,true);
  106. divn:
  107. result := left.getcopy;
  108. else
  109. internalerror(2019050518);
  110. end;
  111. exit;
  112. end;
  113. if rv = 0 then
  114. begin
  115. Message(parser_e_division_by_zero);
  116. { recover }
  117. tordconstnode(right).value := 1;
  118. end;
  119. { the following simplification is also required for correctness
  120. on x86, as its transformation of divisions by constants to
  121. multiplications and shifts does not handle -1 correctly }
  122. if (rv=-1) and
  123. (nodetype=divn) then
  124. begin
  125. result:=cunaryminusnode.create(left);
  126. left:=nil;
  127. exit;
  128. end;
  129. if (nf_isomod in flags) and
  130. (rv<=0) then
  131. begin
  132. Message(cg_e_mod_only_defined_for_pos_quotient);
  133. { recover }
  134. tordconstnode(right).value := 1;
  135. end;
  136. end;
  137. if is_constintnode(right) and is_constintnode(left) then
  138. begin
  139. rv:=tordconstnode(right).value;
  140. lv:=tordconstnode(left).value;
  141. case nodetype of
  142. modn:
  143. if nf_isomod in flags then
  144. begin
  145. if lv>=0 then
  146. result:=create_simplified_ord_const(lv mod rv,resultdef,forinline,false)
  147. else
  148. if ((-lv) mod rv)=0 then
  149. result:=create_simplified_ord_const((-lv) mod rv,resultdef,forinline,false)
  150. else
  151. result:=create_simplified_ord_const(rv-((-lv) mod rv),resultdef,forinline,false);
  152. end
  153. else
  154. result:=create_simplified_ord_const(lv mod rv,resultdef,forinline,false);
  155. divn:
  156. result:=create_simplified_ord_const(lv div rv,resultdef,forinline,cs_check_overflow in localswitches);
  157. else
  158. internalerror(2019050519);
  159. end;
  160. end;
  161. end;
  162. function tmoddivnode.use_moddiv64bitint_helper: boolean;
  163. begin
  164. { not with an ifdef around the call to this routine, because e.g. the
  165. Java VM has a signed 64 bit division opcode, but not an unsigned
  166. one }
  167. {$if defined(cpu64bitalu) or defined(cpuhighleveltarget)}
  168. result:=false;
  169. {$else cpu64bitalu or cpuhighleveltarget}
  170. result:=
  171. (left.resultdef.typ=orddef) and
  172. (right.resultdef.typ=orddef) and
  173. { include currency as well }
  174. (is_64bit(left.resultdef) or is_64bit(right.resultdef));
  175. {$endif cpu64bitalu or cpuhighleveltarget}
  176. end;
  177. function tmoddivnode.pass_typecheck:tnode;
  178. var
  179. else_block,
  180. hp,t : tnode;
  181. rd,ld : torddef;
  182. else_statements,
  183. statements : tstatementnode;
  184. result_data : ttempcreatenode;
  185. nd : torddef;
  186. begin
  187. result:=nil;
  188. typecheckpass(left);
  189. typecheckpass(right);
  190. { avoid any problems with type parameters later on }
  191. if is_typeparam(left.resultdef) or is_typeparam(right.resultdef) then
  192. begin
  193. resultdef:=cundefinedtype;
  194. exit;
  195. end;
  196. set_varstate(left,vs_read,[vsf_must_be_valid]);
  197. set_varstate(right,vs_read,[vsf_must_be_valid]);
  198. if codegenerror then
  199. exit;
  200. { tp procvar support }
  201. maybe_call_procvar(left,true);
  202. maybe_call_procvar(right,true);
  203. { allow operator overloading }
  204. t:=self;
  205. if isbinaryoverloaded(t,[]) then
  206. begin
  207. result:=t;
  208. exit;
  209. end;
  210. { we need 2 orddefs always }
  211. if (left.resultdef.typ<>orddef) then
  212. inserttypeconv(left,sinttype);
  213. if (right.resultdef.typ<>orddef) then
  214. inserttypeconv(right,sinttype);
  215. if codegenerror then
  216. exit;
  217. { Try only now to simply constant
  218. as otherwise you might create
  219. tconstnode with return type that are
  220. not compatible with tconst node
  221. as in bug report 21566 PM }
  222. result:=simplify(false);
  223. if assigned(result) then
  224. exit;
  225. rd:=torddef(right.resultdef);
  226. ld:=torddef(left.resultdef);
  227. { if one operand is a cardinal and the other is a positive constant, convert the }
  228. { constant to a cardinal as well so we don't have to do a 64bit division (JM) }
  229. { Do the same for qwords and positive constants as well, otherwise things like }
  230. { "qword mod 10" are evaluated with int64 as result, which is wrong if the }
  231. { "qword" was > high(int64) (JM) }
  232. { Additionally, do the same for cardinal/qwords and other positive types, but }
  233. { always in a way that a smaller type is converted to a bigger type }
  234. { (webtbs/tw8870) }
  235. if (rd.ordtype in [u8bit,u16bit,u32bit,u64bit]) and
  236. ((is_constintnode(left) and
  237. (tordconstnode(left).value >= 0) and
  238. (tordconstnode(left).value <= get_max_value(rd))) or
  239. (not is_signed(ld) and
  240. (rd.size >= ld.size))) then
  241. begin
  242. inserttypeconv(left,right.resultdef);
  243. ld:=torddef(left.resultdef);
  244. end;
  245. if (ld.ordtype in [u8bit,u16bit,u32bit,u64bit]) and
  246. ((is_constintnode(right) and
  247. (tordconstnode(right).value >= 0) and
  248. (tordconstnode(right).value <= get_max_value(ld))) or
  249. (not is_signed(rd) and
  250. (ld.size >= rd.size))) then
  251. begin
  252. inserttypeconv(right,left.resultdef);
  253. rd:=torddef(right.resultdef);
  254. end;
  255. { when there is one currency value, everything is done
  256. using currency }
  257. if (ld.ordtype=scurrency) or
  258. (rd.ordtype=scurrency) then
  259. begin
  260. if (ld.ordtype<>scurrency) then
  261. inserttypeconv(left,s64currencytype);
  262. if (rd.ordtype<>scurrency) then
  263. inserttypeconv(right,s64currencytype);
  264. resultdef:=left.resultdef;
  265. end
  266. else
  267. { when there is one 64bit value, everything is done
  268. in 64bit }
  269. if (is_64bitint(left.resultdef) or
  270. is_64bitint(right.resultdef)) then
  271. begin
  272. if is_signed(rd) or is_signed(ld) then
  273. begin
  274. if (ld.ordtype<>s64bit) then
  275. inserttypeconv(left,s64inttype);
  276. if (rd.ordtype<>s64bit) then
  277. inserttypeconv(right,s64inttype);
  278. end
  279. else
  280. begin
  281. if (ld.ordtype<>u64bit) then
  282. inserttypeconv(left,u64inttype);
  283. if (rd.ordtype<>u64bit) then
  284. inserttypeconv(right,u64inttype);
  285. end;
  286. resultdef:=left.resultdef;
  287. end
  288. else
  289. { is there a larger than the native int? }
  290. if is_oversizedint(ld) or is_oversizedint(rd) then
  291. begin
  292. nd:=get_common_intdef(ld,rd,false);
  293. if (ld.ordtype<>nd.ordtype) then
  294. inserttypeconv(left,nd);
  295. if (rd.ordtype<>nd.ordtype) then
  296. inserttypeconv(right,nd);
  297. resultdef:=left.resultdef;
  298. end
  299. else
  300. { when mixing unsigned and signed native ints, convert everything to a larger signed type (JM) }
  301. if (is_nativeuint(rd) and
  302. is_signed(ld)) or
  303. (is_nativeuint(ld) and
  304. is_signed(rd)) then
  305. begin
  306. CGMessage(type_h_mixed_signed_unsigned);
  307. { get a signed int, larger than the native int }
  308. nd:=get_common_intdef(torddef(sinttype),torddef(uinttype),false);
  309. if (ld.ordtype<>nd.ordtype) then
  310. inserttypeconv(left,nd);
  311. if (rd.ordtype<>nd.ordtype) then
  312. inserttypeconv(right,nd);
  313. resultdef:=left.resultdef;
  314. end
  315. else
  316. begin
  317. { Make everything always default singed int }
  318. if not(rd.ordtype in [torddef(sinttype).ordtype,torddef(uinttype).ordtype]) then
  319. inserttypeconv(right,sinttype);
  320. if not(ld.ordtype in [torddef(sinttype).ordtype,torddef(uinttype).ordtype]) then
  321. inserttypeconv(left,sinttype);
  322. resultdef:=right.resultdef;
  323. end;
  324. { when the result is currency we need some extra code for
  325. division. this should not be done when the divn node is
  326. created internally }
  327. if (nodetype=divn) and
  328. not(nf_is_currency in flags) and
  329. is_currency(resultdef) then
  330. begin
  331. hp:=caddnode.create(muln,getcopy,cordconstnode.create(10000,s64currencytype,false));
  332. include(hp.flags,nf_is_currency);
  333. result:=hp;
  334. end;
  335. if (nodetype=modn) and (nf_isomod in flags) then
  336. begin
  337. result:=internalstatements(statements);
  338. else_block:=internalstatements(else_statements);
  339. result_data:=ctempcreatenode.create(resultdef,resultdef.size,tt_persistent,true);
  340. { right <=0? }
  341. addstatement(statements,cifnode.create_internal(caddnode.create_internal(lten,right.getcopy,cordconstnode.create(0,resultdef,false)),
  342. { then: result:=left mod right }
  343. ccallnode.createintern('fpc_divbyzero',nil),
  344. nil
  345. ));
  346. { prepare else block }
  347. { result:=(-left) mod right }
  348. addstatement(else_statements,cassignmentnode.create(ctemprefnode.create(result_data),cmoddivnode.create(modn,cunaryminusnode.create(left.getcopy),right.getcopy)));
  349. { result<>0? }
  350. addstatement(else_statements,cifnode.create_internal(caddnode.create_internal(unequaln,ctemprefnode.create(result_data),cordconstnode.create(0,resultdef,false)),
  351. { then: result:=right-result }
  352. cassignmentnode.create_internal(ctemprefnode.create(result_data),caddnode.create_internal(subn,right.getcopy,ctemprefnode.create(result_data))),
  353. nil
  354. ));
  355. addstatement(statements,result_data);
  356. { if left>=0 }
  357. addstatement(statements,cifnode.create_internal(caddnode.create_internal(gten,left.getcopy,cordconstnode.create(0,resultdef,false)),
  358. { then: result:=left mod right }
  359. cassignmentnode.create_internal(ctemprefnode.create(result_data),cmoddivnode.create(modn,left.getcopy,right.getcopy)),
  360. { else block }
  361. else_block
  362. ));
  363. addstatement(statements,ctempdeletenode.create_normal_temp(result_data));
  364. addstatement(statements,ctemprefnode.create(result_data));
  365. end;
  366. end;
  367. function tmoddivnode.first_moddivint: tnode;
  368. {$ifdef cpuneedsdivhelper}
  369. var
  370. procname: string[31];
  371. begin
  372. result := nil;
  373. { otherwise create a call to a helper }
  374. if nodetype = divn then
  375. procname := 'fpc_div_'
  376. else
  377. procname := 'fpc_mod_';
  378. { only qword needs the unsigned code, the
  379. signed code is also used for currency }
  380. case torddef(resultdef).ordtype of
  381. u8bit:
  382. procname := procname + 'byte';
  383. s8bit:
  384. procname := procname + 'shortint';
  385. u16bit:
  386. procname := procname + 'word';
  387. s16bit:
  388. procname := procname + 'smallint';
  389. u32bit:
  390. procname := procname + 'dword';
  391. s32bit:
  392. procname := procname + 'longint';
  393. scurrency:
  394. procname := procname + 'currency';
  395. else
  396. internalerror(2015070501);
  397. end;
  398. result := ccallnode.createintern(procname,ccallparanode.create(left,
  399. ccallparanode.create(right,nil)));
  400. left := nil;
  401. right := nil;
  402. firstpass(result);
  403. if result.resultdef.typ<>orddef then
  404. internalerror(2013031701);
  405. if resultdef.typ<>orddef then
  406. internalerror(2013031701);
  407. if torddef(result.resultdef).ordtype <> torddef(resultdef).ordtype then
  408. inserttypeconv(result,resultdef);
  409. end;
  410. {$else cpuneedsdivhelper}
  411. begin
  412. result:=nil;
  413. end;
  414. {$endif cpuneedsdiv32helper}
  415. function tmoddivnode.first_moddiv64bitint: tnode;
  416. var
  417. procname: string[31];
  418. begin
  419. result := nil;
  420. { when currency is used set the result of the
  421. parameters to s64bit, so they are not converted }
  422. if is_currency(resultdef) then
  423. begin
  424. left.resultdef:=s64inttype;
  425. right.resultdef:=s64inttype;
  426. end;
  427. { otherwise create a call to a helper }
  428. if nodetype = divn then
  429. procname := 'fpc_div_'
  430. else
  431. procname := 'fpc_mod_';
  432. { only qword needs the unsigned code, the
  433. signed code is also used for currency }
  434. if is_signed(resultdef) then
  435. procname := procname + 'int64'
  436. else
  437. procname := procname + 'qword';
  438. result := ccallnode.createintern(procname,ccallparanode.create(left,
  439. ccallparanode.create(right,nil)));
  440. left := nil;
  441. right := nil;
  442. firstpass(result);
  443. end;
  444. function tmoddivnode.firstoptimize: tnode;
  445. var
  446. power,shiftval : longint;
  447. statements : tstatementnode;
  448. temp,resulttemp : ttempcreatenode;
  449. masknode : tnode;
  450. invertsign: Boolean;
  451. begin
  452. result := nil;
  453. { divide/mod a number by a constant which is a power of 2? }
  454. if (right.nodetype = ordconstn) and
  455. isabspowerof2(tordconstnode(right).value,power) and
  456. {$if defined(cpu64bitalu) or defined(cpuhighleveltarget)}
  457. { for 64 bit, we leave the optimization to the cg }
  458. (not is_signed(resultdef)) then
  459. {$else cpu64bitalu or cpuhighleveltarget}
  460. (((nodetype=divn) and is_oversizedord(resultdef)) or
  461. (nodetype=modn) or
  462. not is_signed(resultdef)) then
  463. {$endif cpu64bitalu or cpuhighleveltarget}
  464. begin
  465. if nodetype=divn then
  466. begin
  467. if is_signed(resultdef) then
  468. begin
  469. invertsign:=tordconstnode(right).value<0;
  470. if is_64bitint(left.resultdef) then
  471. if not (cs_opt_size in current_settings.optimizerswitches) then
  472. shiftval:=63
  473. else
  474. { the shift code is a lot bigger than the call to }
  475. { the divide helper }
  476. exit
  477. else
  478. shiftval:=left.resultdef.size*8-1;
  479. result:=internalstatements(statements);
  480. temp:=ctempcreatenode.create(left.resultdef,left.resultdef.size,tt_persistent,true);
  481. resulttemp:=ctempcreatenode.create(resultdef,resultdef.size,tt_persistent,true);
  482. addstatement(statements,resulttemp);
  483. addstatement(statements,temp);
  484. addstatement(statements,cassignmentnode.create(ctemprefnode.create(temp),
  485. left));
  486. left:=nil;
  487. { masknode is (sar(temp,shiftval) and ((1 shl power)-1))
  488. for power=1 (i.e. division by 2), masknode is simply (temp shr shiftval)}
  489. if power=1 then
  490. masknode:=
  491. cshlshrnode.create(shrn,
  492. ctemprefnode.create(temp),
  493. cordconstnode.create(shiftval,u8inttype,false)
  494. )
  495. else
  496. masknode:=
  497. caddnode.create(andn,
  498. cinlinenode.create(in_sar_x_y,false,
  499. ccallparanode.create(cordconstnode.create(shiftval,u8inttype,false),
  500. ccallparanode.create(ctemprefnode.create(temp),nil))
  501. ),
  502. cordconstnode.create(tcgint((qword(1) shl power)-1),
  503. right.resultdef,false)
  504. );
  505. if invertsign then
  506. addstatement(statements,cassignmentnode.create(ctemprefnode.create(resulttemp),
  507. cunaryminusnode.create(
  508. cinlinenode.create(in_sar_x_y,false,
  509. ccallparanode.create(cordconstnode.create(power,u8inttype,false),
  510. ccallparanode.create(caddnode.create(addn,ctemprefnode.create(temp),
  511. masknode),nil
  512. )))))
  513. )
  514. else
  515. addstatement(statements,cassignmentnode.create(ctemprefnode.create(resulttemp),
  516. cinlinenode.create(in_sar_x_y,false,
  517. ccallparanode.create(cordconstnode.create(power,u8inttype,false),
  518. ccallparanode.create(caddnode.create(addn,ctemprefnode.create(temp),
  519. masknode),nil
  520. ))))
  521. );
  522. addstatement(statements,ctempdeletenode.create(temp));
  523. addstatement(statements,ctempdeletenode.create_normal_temp(resulttemp));
  524. addstatement(statements,ctemprefnode.create(resulttemp));
  525. right.Free;
  526. end
  527. else
  528. begin
  529. tordconstnode(right).value:=power;
  530. result:=cshlshrnode.create(shrn,left,right)
  531. end;
  532. end
  533. else if is_signed(resultdef) then { signed modulus }
  534. begin
  535. if (cs_opt_size in current_settings.optimizerswitches) then
  536. exit;
  537. shiftval:=left.resultdef.size*8-1;
  538. tordconstnode(right).value.uvalue:=qword((qword(1) shl power)-1);
  539. result:=internalstatements(statements);
  540. temp:=ctempcreatenode.create(left.resultdef,left.resultdef.size,tt_persistent,true);
  541. resulttemp:=ctempcreatenode.create(resultdef,resultdef.size,tt_persistent,true);
  542. addstatement(statements,resulttemp);
  543. addstatement(statements,temp);
  544. addstatement(statements,cassignmentnode.create(ctemprefnode.create(temp),left));
  545. { mask:=sar(left,sizeof(left)*8-1) and ((1 shl power)-1); }
  546. if power=1 then
  547. masknode:=
  548. cshlshrnode.create(shrn,
  549. ctemprefnode.create(temp),
  550. cordconstnode.create(shiftval,u8inttype,false)
  551. )
  552. else
  553. masknode:=
  554. caddnode.create(andn,
  555. cinlinenode.create(in_sar_x_y,false,
  556. ccallparanode.create(cordconstnode.create(shiftval,u8inttype,false),
  557. ccallparanode.create(ctemprefnode.create(temp),nil))
  558. ),
  559. cordconstnode.create(tcgint((qword(1) shl power)-1),
  560. right.resultdef,false)
  561. );
  562. addstatement(statements,cassignmentnode.create(ctemprefnode.create(resulttemp),masknode));
  563. { result:=((left+mask) and right)-mask; }
  564. addstatement(statements,cassignmentnode.create(ctemprefnode.create(resulttemp),
  565. caddnode.create(subn,
  566. caddnode.create(andn,
  567. right,
  568. caddnode.create(addn,
  569. ctemprefnode.create(temp),
  570. ctemprefnode.create(resulttemp))),
  571. ctemprefnode.create(resulttemp))
  572. ));
  573. addstatement(statements,ctempdeletenode.create(temp));
  574. addstatement(statements,ctempdeletenode.create_normal_temp(resulttemp));
  575. addstatement(statements,ctemprefnode.create(resulttemp));
  576. end
  577. else
  578. begin
  579. tordconstnode(right).value.uvalue:=qword((qword(1) shl power)-1);
  580. result := caddnode.create(andn,left,right);
  581. end;
  582. { left and right are reused }
  583. left := nil;
  584. right := nil;
  585. firstpass(result);
  586. exit;
  587. end;
  588. end;
  589. function tmoddivnode.pass_1 : tnode;
  590. begin
  591. result:=nil;
  592. firstpass(left);
  593. firstpass(right);
  594. if codegenerror then
  595. exit;
  596. { Try to optimize mod/div }
  597. result := firstoptimize;
  598. if assigned(result) then
  599. exit;
  600. { 64bit }
  601. if use_moddiv64bitint_helper then
  602. begin
  603. result := first_moddiv64bitint;
  604. if assigned(result) then
  605. exit;
  606. expectloc:=LOC_REGISTER;
  607. end
  608. else
  609. begin
  610. result := first_moddivint;
  611. if assigned(result) then
  612. exit;
  613. end;
  614. expectloc:=LOC_REGISTER;
  615. end;
  616. {****************************************************************************
  617. TSHLSHRNODE
  618. ****************************************************************************}
  619. function tshlshrnode.simplify(forinline : boolean):tnode;
  620. var
  621. lvalue, rvalue, mask : Tconstexprint;
  622. rangedef: tdef;
  623. size: longint;
  624. begin
  625. result:=nil;
  626. { constant folding }
  627. if is_constintnode(right) then
  628. begin
  629. if forinline then
  630. begin
  631. case resultdef.size of
  632. 1,2,4:
  633. rvalue:=tordconstnode(right).value and byte($1f);
  634. 8:
  635. rvalue:=tordconstnode(right).value and byte($3f);
  636. else
  637. internalerror(2013122302);
  638. end;
  639. end
  640. else
  641. rvalue:=tordconstnode(right).value;
  642. if is_constintnode(left) then
  643. begin
  644. lvalue:=tordconstnode(left).value;
  645. getrangedefmasksize(resultdef, rangedef, mask, size);
  646. { shr is an unsigned operation, so cut off upper bits }
  647. if forinline then
  648. lvalue:=lvalue and mask;
  649. case nodetype of
  650. shrn:
  651. lvalue:=lvalue shr rvalue;
  652. shln:
  653. lvalue:=lvalue shl rvalue;
  654. else
  655. internalerror(2019050517);
  656. end;
  657. { discard shifted-out bits (shl never triggers overflow/range errors) }
  658. if forinline and
  659. (nodetype=shln) then
  660. lvalue:=lvalue and mask;
  661. result:=create_simplified_ord_const(lvalue,resultdef,forinline,false);
  662. end
  663. else if rvalue=0 then
  664. begin
  665. result:=left;
  666. left:=nil;
  667. end;
  668. end
  669. else if is_constintnode(left) then
  670. begin
  671. lvalue:=tordconstnode(left).value;
  672. if forinline then
  673. begin
  674. getrangedefmasksize(resultdef, rangedef, mask, size);
  675. lvalue:=lvalue and mask;
  676. end;
  677. { '0 shl x' and '0 shr x' are 0 }
  678. if (lvalue=0) and
  679. ((cs_opt_level4 in current_settings.optimizerswitches) or
  680. not might_have_sideeffects(right)) then
  681. result:=cordconstnode.create(0,resultdef,true);
  682. end;
  683. end;
  684. function tshlshrnode.pass_typecheck:tnode;
  685. var
  686. t : tnode;
  687. begin
  688. result:=nil;
  689. typecheckpass(left);
  690. typecheckpass(right);
  691. { avoid any problems with type parameters later on }
  692. if is_typeparam(left.resultdef) or is_typeparam(right.resultdef) then
  693. begin
  694. resultdef:=cundefinedtype;
  695. exit;
  696. end;
  697. set_varstate(right,vs_read,[vsf_must_be_valid]);
  698. set_varstate(left,vs_read,[vsf_must_be_valid]);
  699. if codegenerror then
  700. exit;
  701. { tp procvar support }
  702. maybe_call_procvar(left,true);
  703. maybe_call_procvar(right,true);
  704. { allow operator overloading }
  705. t:=self;
  706. if isbinaryoverloaded(t,[]) then
  707. begin
  708. result:=t;
  709. exit;
  710. end;
  711. {$ifdef SUPPORT_MMX}
  712. if (cs_mmx in current_settings.localswitches) and
  713. is_mmx_able_array(left.resultdef) and
  714. ((is_mmx_able_array(right.resultdef) and
  715. equal_defs(left.resultdef,right.resultdef)
  716. ) or is_constintnode(right)) then
  717. begin
  718. if not(mmx_type(left.resultdef) in [mmxu16bit,mmxs16bit,mmxfixed16,mmxu32bit,mmxs32bit,mmxu64bit,mmxs64bit]) then
  719. CGMessage3(type_e_operator_not_supported_for_types,node2opstr(nodetype),left.resultdef.typename,right.resultdef.typename);
  720. if not(is_mmx_able_array(right.resultdef)) then
  721. inserttypeconv(right,sinttype);
  722. end
  723. else
  724. {$endif SUPPORT_MMX}
  725. begin
  726. { calculations for ordinals < 32 bit have to be done in
  727. 32 bit for backwards compatibility. That way 'shl 33' is
  728. the same as 'shl 1'. It's ugly but compatible with delphi/tp/gcc }
  729. if (not is_64bit(left.resultdef)) and
  730. (torddef(left.resultdef).ordtype<>u32bit) then
  731. begin
  732. { keep singness of orignal type }
  733. if is_signed(left.resultdef) then
  734. begin
  735. {$if defined(cpu64bitalu) or defined(cpu32bitalu)}
  736. inserttypeconv(left,s32inttype)
  737. {$elseif defined(cpu16bitalu) or defined(cpu8bitalu)}
  738. inserttypeconv(left,get_common_intdef(torddef(left.resultdef),torddef(sinttype),true));
  739. {$else}
  740. internalerror(2013031301);
  741. {$endif}
  742. end
  743. else
  744. begin
  745. {$if defined(cpu64bitalu) or defined(cpu32bitalu)}
  746. inserttypeconv(left,u32inttype);
  747. {$elseif defined(cpu16bitalu) or defined(cpu8bitalu)}
  748. inserttypeconv(left,get_common_intdef(torddef(left.resultdef),torddef(uinttype),true));
  749. {$else}
  750. internalerror(2013031301);
  751. {$endif}
  752. end
  753. end;
  754. inserttypeconv(right,sinttype);
  755. end;
  756. resultdef:=left.resultdef;
  757. result:=simplify(false);
  758. if assigned(result) then
  759. exit;
  760. end;
  761. {$if not defined(cpu64bitalu) and not defined(cpuhighleveltarget)}
  762. function tshlshrnode.first_shlshr64bitint: tnode;
  763. var
  764. procname: string[31];
  765. begin
  766. result := nil;
  767. { Normally already done below, but called again,
  768. just in case it is called directly }
  769. firstpass(left);
  770. { otherwise create a call to a helper }
  771. if is_signed(left.resultdef) then
  772. procname:='int64'
  773. else
  774. procname:='qword';
  775. if nodetype = shln then
  776. procname := 'fpc_shl_'+procname
  777. else
  778. procname := 'fpc_shr_'+procname;
  779. { this order of parameters works at least for the arm,
  780. however it should work for any calling conventions (FK) }
  781. result := ccallnode.createintern(procname,ccallparanode.create(right,
  782. ccallparanode.create(left,nil)));
  783. left := nil;
  784. right := nil;
  785. firstpass(result);
  786. end;
  787. {$endif not cpu64bitalu and not cpuhighleveltarget}
  788. function tshlshrnode.pass_1 : tnode;
  789. begin
  790. result:=nil;
  791. firstpass(left);
  792. firstpass(right);
  793. if codegenerror then
  794. exit;
  795. expectloc:=LOC_REGISTER;
  796. {$if not defined(cpu64bitalu) and not defined(cpuhighleveltarget)}
  797. { 64 bit ints have their own shift handling }
  798. if is_64bit(left.resultdef) then
  799. result := first_shlshr64bitint;
  800. {$endif not cpu64bitalu and not cpuhighleveltarget}
  801. end;
  802. {****************************************************************************
  803. TUNARYMINUSNODE
  804. ****************************************************************************}
  805. constructor tunaryminusnode.create(expr : tnode);
  806. begin
  807. inherited create(unaryminusn,expr);
  808. end;
  809. function tunaryminusnode.simplify(forinline : boolean):tnode;
  810. begin
  811. result:=nil;
  812. { constant folding }
  813. if is_constintnode(left) then
  814. begin
  815. result:=create_simplified_ord_const(-tordconstnode(left).value,resultdef,forinline,cs_check_overflow in localswitches);
  816. exit;
  817. end;
  818. if is_constrealnode(left) then
  819. begin
  820. trealconstnode(left).value_real:=-trealconstnode(left).value_real;
  821. { Avoid integer overflow on x86_64 CPU for currency value }
  822. { i386 uses fildll/fchs/fistll instructions which never seem
  823. to raise any coprocessor flags .. }
  824. {$push}{$Q-}
  825. trealconstnode(left).value_currency:=-trealconstnode(left).value_currency;
  826. result:=left;
  827. {$pop}
  828. left:=nil;
  829. exit;
  830. end;
  831. end;
  832. function tunaryminusnode.pass_typecheck : tnode;
  833. var
  834. t : tnode;
  835. begin
  836. result:=nil;
  837. typecheckpass(left);
  838. { avoid any problems with type parameters later on }
  839. if is_typeparam(left.resultdef) then
  840. begin
  841. resultdef:=cundefinedtype;
  842. exit;
  843. end;
  844. set_varstate(left,vs_read,[vsf_must_be_valid]);
  845. if codegenerror then
  846. exit;
  847. result:=simplify(false);
  848. if assigned(result) then
  849. exit;
  850. resultdef:=left.resultdef;
  851. if (left.resultdef.typ=floatdef) or
  852. is_currency(left.resultdef) then
  853. begin
  854. end
  855. {$ifdef SUPPORT_MMX}
  856. else if (cs_mmx in current_settings.localswitches) and
  857. is_mmx_able_array(left.resultdef) then
  858. begin
  859. { if saturation is on, left.resultdef isn't
  860. "mmx able" (FK)
  861. if (cs_mmx_saturation in current_settings.localswitches^) and
  862. (torddef(tarraydef(resultdef).definition).typ in
  863. [s32bit,u32bit]) then
  864. CGMessage(type_e_mismatch);
  865. }
  866. end
  867. {$endif SUPPORT_MMX}
  868. else if is_oversizedord(left.resultdef) then
  869. begin
  870. if is_64bit(left.resultdef) then
  871. inserttypeconv(left,s64inttype)
  872. else if is_32bit(left.resultdef) then
  873. inserttypeconv(left,s32inttype)
  874. else if is_16bit(left.resultdef) then
  875. inserttypeconv(left,s16inttype)
  876. else
  877. internalerror(2013040701);
  878. resultdef:=left.resultdef;
  879. end
  880. else if (left.resultdef.typ=orddef) then
  881. begin
  882. inserttypeconv(left,sinttype);
  883. resultdef:=left.resultdef
  884. end
  885. else
  886. begin
  887. { allow operator overloading }
  888. t:=self;
  889. if isunaryoverloaded(t,[]) then
  890. begin
  891. result:=t;
  892. exit;
  893. end;
  894. CGMessage(type_e_mismatch);
  895. end;
  896. end;
  897. { generic code }
  898. { overridden by: }
  899. { i386 }
  900. function tunaryminusnode.pass_1 : tnode;
  901. var
  902. procname: string[31];
  903. begin
  904. result:=nil;
  905. firstpass(left);
  906. if codegenerror then
  907. exit;
  908. if (cs_fp_emulation in current_settings.moduleswitches) and (left.resultdef.typ=floatdef) then
  909. begin
  910. if not(target_info.system in systems_wince) then
  911. begin
  912. expectloc:=LOC_REGISTER;
  913. exit;
  914. end
  915. else
  916. begin
  917. case tfloatdef(resultdef).floattype of
  918. s32real:
  919. procname:='negs';
  920. s64real:
  921. procname:='negd';
  922. {!!! not yet implemented
  923. s128real:
  924. }
  925. else
  926. internalerror(2005082802);
  927. end;
  928. result:=ccallnode.createintern(procname,ccallparanode.create(left,nil));
  929. end;
  930. left:=nil;
  931. end
  932. else
  933. begin
  934. if (left.resultdef.typ=floatdef) then
  935. expectloc:=LOC_FPUREGISTER
  936. {$ifdef SUPPORT_MMX}
  937. else if (cs_mmx in current_settings.localswitches) and
  938. is_mmx_able_array(left.resultdef) then
  939. expectloc:=LOC_MMXREGISTER
  940. {$endif SUPPORT_MMX}
  941. else if (left.resultdef.typ=orddef) then
  942. expectloc:=LOC_REGISTER;
  943. end;
  944. end;
  945. {****************************************************************************
  946. TUNARYPLUSNODE
  947. ****************************************************************************}
  948. constructor tunaryplusnode.create(expr: tnode);
  949. begin
  950. inherited create(unaryplusn,expr);
  951. end;
  952. function tunaryplusnode.pass_1: tnode;
  953. begin
  954. result:=nil;
  955. { can never happen because all the conversions happen
  956. in pass_typecheck }
  957. internalerror(201012250);
  958. end;
  959. function tunaryplusnode.pass_typecheck: tnode;
  960. var
  961. t:tnode;
  962. begin
  963. result:=nil;
  964. typecheckpass(left);
  965. { avoid any problems with type parameters later on }
  966. if is_typeparam(left.resultdef) then
  967. begin
  968. resultdef:=cundefinedtype;
  969. exit;
  970. end;
  971. set_varstate(left,vs_read,[vsf_must_be_valid]);
  972. if codegenerror then
  973. exit;
  974. if is_constintnode(left) or
  975. is_constrealnode(left) or
  976. (left.resultdef.typ=floatdef) or
  977. is_currency(left.resultdef)
  978. {$ifdef SUPPORT_MMX}
  979. or ((cs_mmx in current_settings.localswitches) and
  980. is_mmx_able_array(left.resultdef))
  981. {$endif SUPPORT_MMX}
  982. then
  983. begin
  984. result:=left;
  985. left:=nil;
  986. end
  987. else if is_oversizedord(left.resultdef) then
  988. begin
  989. if is_64bit(left.resultdef) then
  990. inserttypeconv(left,s64inttype)
  991. else if is_32bit(left.resultdef) then
  992. inserttypeconv(left,s32inttype)
  993. else if is_16bit(left.resultdef) then
  994. inserttypeconv(left,s16inttype)
  995. else
  996. internalerror(2013040702);
  997. result:=left;
  998. left:=nil;
  999. end
  1000. else if (left.resultdef.typ=orddef) then
  1001. begin
  1002. inserttypeconv(left,sinttype);
  1003. result:=left;
  1004. left:=nil;
  1005. end
  1006. else
  1007. begin
  1008. { allow operator overloading }
  1009. t:=self;
  1010. if isunaryoverloaded(t,[]) then
  1011. begin
  1012. result:=t;
  1013. exit;
  1014. end;
  1015. CGMessage(type_e_mismatch);
  1016. end;
  1017. end;
  1018. {****************************************************************************
  1019. TNOTNODE
  1020. ****************************************************************************}
  1021. const
  1022. boolean_reverse:array[ltn..unequaln] of Tnodetype=(
  1023. gten,gtn,lten,ltn,unequaln,equaln
  1024. );
  1025. constructor tnotnode.create(expr : tnode);
  1026. begin
  1027. inherited create(notn,expr);
  1028. end;
  1029. function tnotnode.simplify(forinline : boolean):tnode;
  1030. var
  1031. v : tconstexprint;
  1032. t : tnode;
  1033. def : tdef;
  1034. begin
  1035. result:=nil;
  1036. { Try optmimizing ourself away }
  1037. if left.nodetype=notn then
  1038. begin
  1039. { Double not. Remove both }
  1040. result:=Tnotnode(left).left;
  1041. tnotnode(left).left:=nil;
  1042. exit;
  1043. end;
  1044. if (left.nodetype in [ltn,lten,equaln,unequaln,gtn,gten]) then
  1045. begin
  1046. { Not of boolean expression. Turn around the operator and remove
  1047. the not. This is not allowed for sets with the gten/lten,
  1048. because there is no ltn/gtn support }
  1049. if (taddnode(left).left.resultdef.typ<>setdef) or
  1050. (left.nodetype in [equaln,unequaln]) then
  1051. begin
  1052. result:=left;
  1053. left.nodetype:=boolean_reverse[left.nodetype];
  1054. left:=nil;
  1055. exit;
  1056. end;
  1057. end;
  1058. { constant folding }
  1059. if (left.nodetype=ordconstn) and
  1060. (left.resultdef.typ=orddef) then
  1061. begin
  1062. v:=tordconstnode(left).value;
  1063. def:=left.resultdef;
  1064. case torddef(left.resultdef).ordtype of
  1065. pasbool1,
  1066. pasbool8,
  1067. pasbool16,
  1068. pasbool32,
  1069. pasbool64:
  1070. v:=byte(not(boolean(int64(v))));
  1071. bool8bit,
  1072. bool16bit,
  1073. bool32bit,
  1074. bool64bit:
  1075. begin
  1076. if v=0 then
  1077. v:=-1
  1078. else
  1079. v:=0;
  1080. end;
  1081. uchar,
  1082. uwidechar,
  1083. u8bit,
  1084. s8bit,
  1085. u16bit,
  1086. s16bit,
  1087. s32bit,
  1088. u32bit,
  1089. s64bit,
  1090. u64bit:
  1091. begin
  1092. { unsigned, equal or bigger than the native int size? }
  1093. if (torddef(left.resultdef).ordtype in [u64bit,u32bit,u16bit,u8bit,uchar,uwidechar]) and
  1094. (is_nativeord(left.resultdef) or is_oversizedord(left.resultdef)) then
  1095. begin
  1096. { Delphi-compatible: not dword = dword (not word = longint) }
  1097. { Extension: not qword = qword }
  1098. v:=qword(not qword(v));
  1099. { will be truncated by the ordconstnode for u32bit }
  1100. end
  1101. else
  1102. begin
  1103. v:=int64(not int64(v));
  1104. def:=get_common_intdef(torddef(left.resultdef),torddef(sinttype),false);
  1105. end;
  1106. end;
  1107. else
  1108. CGMessage(type_e_mismatch);
  1109. end;
  1110. { not-nodes are not range checked by the code generator -> also
  1111. don't range check while inlining; the resultdef is a bit tricky
  1112. though: the node's resultdef gets changed in most cases compared
  1113. to left, but the not-operation itself is caried out in the code
  1114. generator using the size of left
  1115. }
  1116. if not(forinline) then
  1117. t:=cordconstnode.create(v,def,false)
  1118. else
  1119. begin
  1120. { cut off the value if necessary }
  1121. t:=cordconstnode.create(v,left.resultdef,false);
  1122. { now convert to node's resultdef }
  1123. inserttypeconv_explicit(t,def);
  1124. end;
  1125. result:=t;
  1126. exit;
  1127. end;
  1128. end;
  1129. function tnotnode.pass_typecheck : tnode;
  1130. var
  1131. t : tnode;
  1132. begin
  1133. result:=nil;
  1134. typecheckpass(left);
  1135. { avoid any problems with type parameters later on }
  1136. if is_typeparam(left.resultdef) then
  1137. begin
  1138. resultdef:=cundefinedtype;
  1139. exit;
  1140. end;
  1141. set_varstate(left,vs_read,[vsf_must_be_valid]);
  1142. if codegenerror then
  1143. exit;
  1144. { tp procvar support }
  1145. maybe_call_procvar(left,true);
  1146. resultdef:=left.resultdef;
  1147. result:=simplify(false);
  1148. if assigned(result) then
  1149. exit;
  1150. if is_boolean(resultdef) then
  1151. begin
  1152. end
  1153. else
  1154. {$ifdef SUPPORT_MMX}
  1155. if (cs_mmx in current_settings.localswitches) and
  1156. is_mmx_able_array(left.resultdef) then
  1157. begin
  1158. end
  1159. else
  1160. {$endif SUPPORT_MMX}
  1161. {$ifndef cpu64bitaddr}
  1162. if is_64bitint(left.resultdef) then
  1163. begin
  1164. end
  1165. else
  1166. {$endif not cpu64bitaddr}
  1167. if is_integer(left.resultdef) then
  1168. begin
  1169. end
  1170. else
  1171. begin
  1172. { allow operator overloading }
  1173. t:=self;
  1174. if isunaryoverloaded(t,[]) then
  1175. begin
  1176. result:=t;
  1177. exit;
  1178. end;
  1179. CGMessage(type_e_mismatch);
  1180. end;
  1181. end;
  1182. function tnotnode.pass_1 : tnode;
  1183. begin
  1184. result:=nil;
  1185. firstpass(left);
  1186. if codegenerror then
  1187. exit;
  1188. expectloc:=left.expectloc;
  1189. if is_boolean(resultdef) then
  1190. begin
  1191. if (expectloc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
  1192. expectloc:=LOC_REGISTER;
  1193. { before loading it into flags we need to load it into
  1194. a register thus 1 register is need PM }
  1195. {$ifdef cpuflags}
  1196. if left.expectloc<>LOC_JUMP then
  1197. expectloc:=LOC_FLAGS;
  1198. {$endif def cpuflags}
  1199. end
  1200. else
  1201. {$ifdef SUPPORT_MMX}
  1202. if (cs_mmx in current_settings.localswitches) and
  1203. is_mmx_able_array(left.resultdef) then
  1204. expectloc:=LOC_MMXREGISTER
  1205. else
  1206. {$endif SUPPORT_MMX}
  1207. {$if not defined(cpu64bitalu) and not defined(cpuhighleveltarget)}
  1208. if is_64bit(left.resultdef) then
  1209. begin
  1210. if (expectloc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
  1211. expectloc:=LOC_REGISTER;
  1212. end
  1213. else
  1214. {$endif not cpu64bitalu and not cpuhighleveltarget}
  1215. if is_integer(left.resultdef) then
  1216. expectloc:=LOC_REGISTER;
  1217. end;
  1218. {$ifdef state_tracking}
  1219. function Tnotnode.track_state_pass(exec_known:boolean):boolean;
  1220. begin
  1221. track_state_pass:=true;
  1222. if left.track_state_pass(exec_known) then
  1223. begin
  1224. left.resultdef:=nil;
  1225. do_typecheckpass(left);
  1226. end;
  1227. end;
  1228. {$endif}
  1229. end.