ncgflw.pas 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate assembler for nodes that influence the flow which are
  5. the same for all (most?) processors
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit ncgflw;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. node,nflw;
  24. type
  25. tcgwhilerepeatnode = class(twhilerepeatnode)
  26. procedure pass_2;override;
  27. end;
  28. tcgifnode = class(tifnode)
  29. procedure pass_2;override;
  30. end;
  31. tcgfornode = class(tfornode)
  32. procedure pass_2;override;
  33. end;
  34. tcgexitnode = class(texitnode)
  35. procedure pass_2;override;
  36. end;
  37. tcgbreaknode = class(tbreaknode)
  38. procedure pass_2;override;
  39. end;
  40. tcgcontinuenode = class(tcontinuenode)
  41. procedure pass_2;override;
  42. end;
  43. tcggotonode = class(tgotonode)
  44. procedure pass_2;override;
  45. end;
  46. tcglabelnode = class(tlabelnode)
  47. procedure pass_2;override;
  48. end;
  49. tcgraisenode = class(traisenode)
  50. procedure pass_2;override;
  51. end;
  52. tcgtryexceptnode = class(ttryexceptnode)
  53. procedure pass_2;override;
  54. end;
  55. tcgtryfinallynode = class(ttryfinallynode)
  56. procedure pass_2;override;
  57. end;
  58. tcgonnode = class(tonnode)
  59. procedure pass_2;override;
  60. end;
  61. implementation
  62. uses
  63. verbose,globals,systems,globtype,
  64. symconst,symdef,symsym,aasmbase,aasmtai,aasmcpu,defutil,
  65. procinfo,cgbase,pass_2,
  66. cpubase,cpuinfo,
  67. nld,ncon,
  68. ncgutil,
  69. tgobj,paramgr,
  70. regvars,cgobj
  71. {$ifndef cpu64bit}
  72. ,cg64f32
  73. {$endif cpu64bit}
  74. ;
  75. const
  76. EXCEPT_BUF_SIZE = 12;
  77. {*****************************************************************************
  78. Second_While_RepeatN
  79. *****************************************************************************}
  80. procedure tcgwhilerepeatnode.pass_2;
  81. var
  82. lcont,lbreak,lloop,
  83. oldclabel,oldblabel : tasmlabel;
  84. otlabel,oflabel : tasmlabel;
  85. oldflowcontrol : tflowcontrol;
  86. begin
  87. location_reset(location,LOC_VOID,OS_NO);
  88. objectlibrary.getlabel(lloop);
  89. objectlibrary.getlabel(lcont);
  90. objectlibrary.getlabel(lbreak);
  91. { arrange continue and breaklabels: }
  92. oldflowcontrol:=flowcontrol;
  93. oldclabel:=aktcontinuelabel;
  94. oldblabel:=aktbreaklabel;
  95. {$ifdef OLDREGVARS}
  96. load_all_regvars(exprasmlist);
  97. {$endif OLDREGVARS}
  98. { handling code at the end as it is much more efficient, and makes
  99. while equal to repeat loop, only the end true/false is swapped (PFV) }
  100. if lnf_testatbegin in loopflags then
  101. cg.a_jmp_always(exprasmlist,lcont);
  102. if not(cs_littlesize in aktglobalswitches) then
  103. { align loop target }
  104. exprasmList.concat(Tai_align.Create(aktalignment.loopalign));
  105. cg.a_label(exprasmlist,lloop);
  106. aktcontinuelabel:=lcont;
  107. aktbreaklabel:=lbreak;
  108. if assigned(right) then
  109. secondpass(right);
  110. {$ifdef OLDREGVARS}
  111. load_all_regvars(exprasmlist);
  112. {$endif OLDREGVARS}
  113. cg.a_label(exprasmlist,lcont);
  114. otlabel:=truelabel;
  115. oflabel:=falselabel;
  116. if lnf_checknegate in loopflags then
  117. begin
  118. truelabel:=lbreak;
  119. falselabel:=lloop;
  120. end
  121. else
  122. begin
  123. truelabel:=lloop;
  124. falselabel:=lbreak;
  125. end;
  126. secondpass(left);
  127. maketojumpbool(exprasmlist,left,lr_load_regvars);
  128. cg.a_label(exprasmlist,lbreak);
  129. truelabel:=otlabel;
  130. falselabel:=oflabel;
  131. aktcontinuelabel:=oldclabel;
  132. aktbreaklabel:=oldblabel;
  133. { a break/continue in a while/repeat block can't be seen outside }
  134. flowcontrol:=oldflowcontrol+(flowcontrol-[fc_break,fc_continue]);
  135. end;
  136. {*****************************************************************************
  137. tcgIFNODE
  138. *****************************************************************************}
  139. procedure tcgifnode.pass_2;
  140. var
  141. hl,otlabel,oflabel : tasmlabel;
  142. (*
  143. org_regvar_loaded_other,
  144. then_regvar_loaded_other,
  145. else_regvar_loaded_other : regvarother_booleanarray;
  146. org_regvar_loaded_int,
  147. then_regvar_loaded_int,
  148. else_regvar_loaded_int : Tsuperregisterset;
  149. org_list,
  150. then_list,
  151. else_list : taasmoutput;
  152. *)
  153. begin
  154. location_reset(location,LOC_VOID,OS_NO);
  155. otlabel:=truelabel;
  156. oflabel:=falselabel;
  157. objectlibrary.getlabel(truelabel);
  158. objectlibrary.getlabel(falselabel);
  159. secondpass(left);
  160. (*
  161. { save regvars loaded in the beginning so that we can restore them }
  162. { when processing the else-block }
  163. if cs_regvars in aktglobalswitches then
  164. begin
  165. org_list := exprasmlist;
  166. exprasmlist := taasmoutput.create;
  167. end;
  168. *)
  169. maketojumpbool(exprasmlist,left,lr_dont_load_regvars);
  170. (*
  171. if cs_regvars in aktglobalswitches then
  172. begin
  173. org_regvar_loaded_int := rg.regvar_loaded_int;
  174. org_regvar_loaded_other := rg.regvar_loaded_other;
  175. end;
  176. *)
  177. if assigned(right) then
  178. begin
  179. cg.a_label(exprasmlist,truelabel);
  180. secondpass(right);
  181. end;
  182. { save current asmlist (previous instructions + then-block) and }
  183. { loaded regvar state and create new clean ones }
  184. if cs_regvars in aktglobalswitches then
  185. begin
  186. { then_regvar_loaded_int := rg.regvar_loaded_int;
  187. then_regvar_loaded_other := rg.regvar_loaded_other;
  188. rg.regvar_loaded_int := org_regvar_loaded_int;
  189. rg.regvar_loaded_other := org_regvar_loaded_other;
  190. then_list := exprasmlist;
  191. exprasmlist := taasmoutput.create;}
  192. end;
  193. if assigned(t1) then
  194. begin
  195. if assigned(right) then
  196. begin
  197. objectlibrary.getlabel(hl);
  198. { do go back to if line !! }
  199. (*
  200. if not(cs_regvars in aktglobalswitches) then
  201. *)
  202. aktfilepos:=exprasmList.getlasttaifilepos^
  203. (*
  204. else
  205. aktfilepos:=then_list.getlasttaifilepos^
  206. *)
  207. ;
  208. cg.a_jmp_always(exprasmlist,hl);
  209. end;
  210. cg.a_label(exprasmlist,falselabel);
  211. secondpass(t1);
  212. (*
  213. { save current asmlist (previous instructions + else-block) }
  214. { and loaded regvar state and create a new clean list }
  215. if cs_regvars in aktglobalswitches then
  216. begin
  217. { else_regvar_loaded_int := rg.regvar_loaded_int;
  218. else_regvar_loaded_other := rg.regvar_loaded_other;}
  219. else_list := exprasmlist;
  220. exprasmlist := taasmoutput.create;
  221. end;
  222. *)
  223. if assigned(right) then
  224. cg.a_label(exprasmlist,hl);
  225. end
  226. else
  227. begin
  228. (*
  229. if cs_regvars in aktglobalswitches then
  230. begin
  231. { else_regvar_loaded_int := rg.regvar_loaded_int;
  232. else_regvar_loaded_other := rg.regvar_loaded_other;}
  233. else_list := exprasmlist;
  234. exprasmlist := taasmoutput.create;
  235. end;
  236. *)
  237. cg.a_label(exprasmlist,falselabel);
  238. end;
  239. if not(assigned(right)) then
  240. begin
  241. cg.a_label(exprasmlist,truelabel);
  242. end;
  243. (*
  244. if cs_regvars in aktglobalswitches then
  245. begin
  246. { add loads of regvars at the end of the then- and else-blocks }
  247. { so that at the end of both blocks the same regvars are loaded }
  248. { no else block? }
  249. if not assigned(t1) then
  250. begin
  251. sync_regvars_int(org_list,then_list,org_regvar_loaded_int,then_regvar_loaded_int);
  252. sync_regvars_other(org_list,then_list,org_regvar_loaded_other,then_regvar_loaded_other);
  253. end
  254. { no then block? }
  255. else if not assigned(right) then
  256. begin
  257. sync_regvars_int(org_list,else_list,org_regvar_loaded_int,else_regvar_loaded_int);
  258. sync_regvars_other(org_list,else_list,org_regvar_loaded_other,else_regvar_loaded_other);
  259. end
  260. { both else and then blocks }
  261. else
  262. begin
  263. sync_regvars_int(then_list,else_list,then_regvar_loaded_int,else_regvar_loaded_int);
  264. sync_regvars_other(then_list,else_list,then_regvar_loaded_other,else_regvar_loaded_other);
  265. end;
  266. { add all lists together }
  267. org_list.concatlist(then_list);
  268. then_list.free;
  269. org_list.concatlist(else_list);
  270. else_list.free;
  271. org_list.concatlist(exprasmlist);
  272. exprasmlist.free;
  273. exprasmlist := org_list;
  274. end;
  275. *)
  276. truelabel:=otlabel;
  277. falselabel:=oflabel;
  278. end;
  279. {*****************************************************************************
  280. SecondFor
  281. *****************************************************************************}
  282. procedure tcgfornode.pass_2;
  283. var
  284. l3,oldclabel,oldblabel : tasmlabel;
  285. temptovalue : boolean;
  286. hs : byte;
  287. temp1 : treference;
  288. hop : topcg;
  289. hcond : topcmp;
  290. opsize : tcgsize;
  291. count_var_is_signed,do_loopvar_at_end : boolean;
  292. cmp_const:Tconstexprint;
  293. oldflowcontrol : tflowcontrol;
  294. begin
  295. location_reset(location,LOC_VOID,OS_NO);
  296. oldflowcontrol:=flowcontrol;
  297. oldclabel:=aktcontinuelabel;
  298. oldblabel:=aktbreaklabel;
  299. objectlibrary.getlabel(aktcontinuelabel);
  300. objectlibrary.getlabel(aktbreaklabel);
  301. objectlibrary.getlabel(l3);
  302. { only calculate reference }
  303. secondpass(t2);
  304. hs := t2.resulttype.def.size;
  305. opsize := def_cgsize(t2.resulttype.def);
  306. { first set the to value
  307. because the count var can be in the expression !! }
  308. do_loopvar_at_end:=lnf_dont_mind_loopvar_on_exit in loopflags;
  309. secondpass(right);
  310. { calculate pointer value and check if changeable and if so }
  311. { load into temporary variable }
  312. if right.nodetype<>ordconstn then
  313. begin
  314. do_loopvar_at_end:=false;
  315. tg.GetTemp(exprasmlist,hs,tt_normal,temp1);
  316. temptovalue:=true;
  317. if (right.location.loc=LOC_REGISTER) or
  318. (right.location.loc=LOC_CREGISTER) then
  319. begin
  320. cg.a_load_reg_ref(exprasmlist,opsize,opsize,right.location.register,temp1);
  321. cg.ungetregister(exprasmlist,right.location.register);
  322. end
  323. else
  324. cg.g_concatcopy(exprasmlist,right.location.reference,temp1,
  325. hs,true,false);
  326. end
  327. else
  328. temptovalue:=false;
  329. { produce start assignment }
  330. secondpass(left);
  331. count_var_is_signed:=is_signed(t2.resulttype.def);
  332. if lnf_backward in loopflags then
  333. if count_var_is_signed then
  334. hcond:=OC_LT
  335. else
  336. hcond:=OC_B
  337. else
  338. if count_var_is_signed then
  339. hcond:=OC_GT
  340. else
  341. hcond:=OC_A;
  342. {$ifdef OLDREGVARS}
  343. load_all_regvars(exprasmlist);
  344. {$endif OLDREGVARS}
  345. if temptovalue then
  346. begin
  347. cg.a_cmp_ref_loc_label(exprasmlist,opsize,hcond,
  348. temp1,t2.location,aktbreaklabel);
  349. end
  350. else
  351. begin
  352. if lnf_testatbegin in loopflags then
  353. begin
  354. cg.a_cmp_const_loc_label(exprasmlist,opsize,hcond,
  355. aword(tordconstnode(right).value),
  356. t2.location,aktbreaklabel);
  357. end;
  358. end;
  359. {If the loopvar doesn't mind on exit, we avoid this ugly
  360. dec instruction and do the loopvar inc/dec after the loop
  361. body.}
  362. if not do_loopvar_at_end then
  363. begin
  364. if lnf_backward in loopflags then
  365. hop:=OP_ADD
  366. else
  367. hop:=OP_SUB;
  368. cg.a_op_const_loc(exprasmlist,hop,1,t2.location);
  369. end;
  370. if not(cs_littlesize in aktglobalswitches) then
  371. { align loop target }
  372. exprasmList.concat(Tai_align.Create(aktalignment.loopalign));
  373. cg.a_label(exprasmlist,l3);
  374. {If the loopvar doesn't mind on exit, we avoid the loopvar inc/dec
  375. after the loop body instead of here.}
  376. if not do_loopvar_at_end then
  377. begin
  378. { according to count direction DEC or INC... }
  379. if lnf_backward in loopflags then
  380. hop:=OP_SUB
  381. else
  382. hop:=OP_ADD;
  383. cg.a_op_const_loc(exprasmlist,hop,1,t2.location);
  384. end;
  385. { help register must not be in instruction block }
  386. if assigned(t1) then
  387. begin
  388. secondpass(t1);
  389. {$ifdef OLDREGVARS}
  390. load_all_regvars(exprasmlist);
  391. {$endif OLDREGVARS}
  392. end;
  393. {If the loopvar doesn't mind on exit, we do the loopvar inc/dec
  394. after the loop body instead of here.}
  395. if do_loopvar_at_end then
  396. begin
  397. { according to count direction DEC or INC... }
  398. if lnf_backward in loopflags then
  399. hop:=OP_SUB
  400. else
  401. hop:=OP_ADD;
  402. cg.a_op_const_loc(exprasmlist,hop,1,t2.location);
  403. end;
  404. cg.a_label(exprasmlist,aktcontinuelabel);
  405. if do_loopvar_at_end then
  406. if lnf_backward in loopflags then
  407. if count_var_is_signed then
  408. hcond:=OC_GTE
  409. else
  410. hcond:=OC_AE
  411. else
  412. if count_var_is_signed then
  413. hcond:=OC_LTE
  414. else
  415. hcond:=OC_BE
  416. else
  417. if lnf_backward in loopflags then
  418. if count_var_is_signed then
  419. hcond:=OC_GT
  420. else
  421. hcond:=OC_A
  422. else
  423. if count_var_is_signed then
  424. hcond:=OC_LT
  425. else
  426. hcond:=OC_B;
  427. {$ifdef OLDREGVARS}
  428. load_all_regvars(exprasmlist);
  429. {$endif OLDREGVARS}
  430. cmp_const:=Tordconstnode(right).value;
  431. if do_loopvar_at_end then
  432. begin
  433. {Watch out for wrap around 255 -> 0.}
  434. {Ugly: This code is way to long... Use tables?}
  435. case opsize of
  436. OS_8:
  437. begin
  438. if lnf_backward in loopflags then
  439. begin
  440. if byte(cmp_const)=low(byte) then
  441. begin
  442. hcond:=OC_NE;
  443. cmp_const:=high(byte);
  444. end
  445. end
  446. else
  447. begin
  448. if byte(cmp_const)=high(byte) then
  449. begin
  450. hcond:=OC_NE;
  451. cmp_const:=low(byte);
  452. end
  453. end
  454. end;
  455. OS_16:
  456. begin
  457. if lnf_backward in loopflags then
  458. begin
  459. if word(cmp_const)=high(word) then
  460. begin
  461. hcond:=OC_NE;
  462. cmp_const:=low(word);
  463. end
  464. end
  465. else
  466. begin
  467. if word(cmp_const)=low(word) then
  468. begin
  469. hcond:=OC_NE;
  470. cmp_const:=high(word);
  471. end
  472. end
  473. end;
  474. OS_32:
  475. begin
  476. if lnf_backward in loopflags then
  477. begin
  478. if cardinal(cmp_const)=high(cardinal) then
  479. begin
  480. hcond:=OC_NE;
  481. cmp_const:=low(cardinal);
  482. end
  483. end
  484. else
  485. begin
  486. if cardinal(cmp_const)=low(cardinal) then
  487. begin
  488. hcond:=OC_NE;
  489. cmp_const:=high(cardinal);
  490. end
  491. end
  492. end;
  493. OS_64:
  494. begin
  495. if lnf_backward in loopflags then
  496. begin
  497. if qword(cmp_const)=high(qword) then
  498. begin
  499. hcond:=OC_NE;
  500. cmp_const:=low(qword);
  501. end
  502. end
  503. else
  504. begin
  505. if qword(cmp_const)=low(qword) then
  506. begin
  507. hcond:=OC_NE;
  508. cmp_const:=high(qword);
  509. end
  510. end
  511. end;
  512. OS_S8:
  513. begin
  514. if lnf_backward in loopflags then
  515. begin
  516. if shortint(cmp_const)=low(shortint) then
  517. begin
  518. hcond:=OC_NE;
  519. cmp_const:=high(shortint);
  520. end
  521. end
  522. else
  523. begin
  524. if shortint(cmp_const)=high(shortint) then
  525. begin
  526. hcond:=OC_NE;
  527. cmp_const:=low(shortint);
  528. end
  529. end
  530. end;
  531. OS_S16:
  532. begin
  533. if lnf_backward in loopflags then
  534. begin
  535. if integer(cmp_const)=high(integer) then
  536. begin
  537. hcond:=OC_NE;
  538. cmp_const:=low(integer);
  539. end
  540. end
  541. else
  542. begin
  543. if integer(cmp_const)=low(integer) then
  544. begin
  545. hcond:=OC_NE;
  546. cmp_const:=high(integer);
  547. end
  548. end
  549. end;
  550. OS_S32:
  551. begin
  552. if lnf_backward in loopflags then
  553. begin
  554. if longint(cmp_const)=high(longint) then
  555. begin
  556. hcond:=OC_NE;
  557. cmp_const:=low(longint);
  558. end
  559. end
  560. else
  561. begin
  562. if longint(cmp_const)=low(longint) then
  563. begin
  564. hcond:=OC_NE;
  565. cmp_const:=high(longint);
  566. end
  567. end
  568. end;
  569. OS_S64:
  570. begin
  571. if lnf_backward in loopflags then
  572. begin
  573. if int64(cmp_const)=high(int64) then
  574. begin
  575. hcond:=OC_NE;
  576. cmp_const:=low(int64);
  577. end
  578. end
  579. else
  580. begin
  581. if int64(cmp_const)=low(int64) then
  582. begin
  583. hcond:=OC_NE;
  584. cmp_const:=high(int64);
  585. end
  586. end
  587. end;
  588. else
  589. internalerror(200201021);
  590. end;
  591. end;
  592. { produce comparison and the corresponding }
  593. { jump }
  594. if temptovalue then
  595. begin
  596. cg.a_cmp_ref_loc_label(exprasmlist,opsize,hcond,temp1,
  597. t2.location,l3);
  598. end
  599. else
  600. begin
  601. cg.a_cmp_const_loc_label(exprasmlist,opsize,hcond,
  602. cmp_const,t2.location,l3);
  603. end;
  604. if temptovalue then
  605. tg.ungetiftemp(exprasmlist,temp1);
  606. { this is the break label: }
  607. cg.a_label(exprasmlist,aktbreaklabel);
  608. aktcontinuelabel:=oldclabel;
  609. aktbreaklabel:=oldblabel;
  610. { a break/continue in a while/repeat block can't be seen outside }
  611. flowcontrol:=oldflowcontrol+(flowcontrol-[fc_break,fc_continue]);
  612. end;
  613. {*****************************************************************************
  614. SecondExitN
  615. *****************************************************************************}
  616. procedure tcgexitnode.pass_2;
  617. begin
  618. location_reset(location,LOC_VOID,OS_NO);
  619. include(flowcontrol,fc_exit);
  620. if assigned(left) then
  621. secondpass(left);
  622. cg.a_jmp_always(exprasmlist,current_procinfo.aktexitlabel);
  623. end;
  624. {*****************************************************************************
  625. SecondBreakN
  626. *****************************************************************************}
  627. procedure tcgbreaknode.pass_2;
  628. begin
  629. location_reset(location,LOC_VOID,OS_NO);
  630. include(flowcontrol,fc_break);
  631. if aktbreaklabel<>nil then
  632. begin
  633. {$ifdef OLDREGVARS}
  634. load_all_regvars(exprasmlist);
  635. {$endif OLDREGVARS}
  636. cg.a_jmp_always(exprasmlist,aktbreaklabel)
  637. end
  638. else
  639. CGMessage(cg_e_break_not_allowed);
  640. end;
  641. {*****************************************************************************
  642. SecondContinueN
  643. *****************************************************************************}
  644. procedure tcgcontinuenode.pass_2;
  645. begin
  646. location_reset(location,LOC_VOID,OS_NO);
  647. include(flowcontrol,fc_continue);
  648. if aktcontinuelabel<>nil then
  649. begin
  650. {$ifdef OLDREGVARS}
  651. load_all_regvars(exprasmlist);
  652. {$endif OLDREGVARS}
  653. cg.a_jmp_always(exprasmlist,aktcontinuelabel)
  654. end
  655. else
  656. CGMessage(cg_e_continue_not_allowed);
  657. end;
  658. {*****************************************************************************
  659. SecondGoto
  660. *****************************************************************************}
  661. procedure tcggotonode.pass_2;
  662. begin
  663. location_reset(location,LOC_VOID,OS_NO);
  664. {$ifdef OLDREGVARS}
  665. load_all_regvars(exprasmlist);
  666. {$endif OLDREGVARS}
  667. cg.a_jmp_always(exprasmlist,labsym.lab)
  668. end;
  669. {*****************************************************************************
  670. SecondLabel
  671. *****************************************************************************}
  672. procedure tcglabelnode.pass_2;
  673. begin
  674. location_reset(location,LOC_VOID,OS_NO);
  675. {$ifdef OLDREGVARS}
  676. load_all_regvars(exprasmlist);
  677. {$endif OLDREGVARS}
  678. cg.a_label(exprasmlist,labelnr);
  679. secondpass(left);
  680. end;
  681. {*****************************************************************************
  682. SecondRaise
  683. *****************************************************************************}
  684. procedure tcgraisenode.pass_2;
  685. var
  686. a : tasmlabel;
  687. href2: treference;
  688. paraloc1,paraloc2,paraloc3 : tparalocation;
  689. begin
  690. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  691. paraloc2:=paramanager.getintparaloc(pocall_default,2);
  692. paraloc3:=paramanager.getintparaloc(pocall_default,3);
  693. location_reset(location,LOC_VOID,OS_NO);
  694. if assigned(left) then
  695. begin
  696. { multiple parameters? }
  697. if assigned(right) then
  698. begin
  699. if assigned(frametree) then
  700. secondpass(frametree);
  701. secondpass(right);
  702. end;
  703. secondpass(left);
  704. if codegenerror then
  705. exit;
  706. { Push parameters }
  707. if assigned(right) then
  708. begin
  709. paramanager.allocparaloc(exprasmlist,paraloc3);
  710. if assigned(frametree) then
  711. begin
  712. location_release(exprasmlist,frametree.location);
  713. cg.a_param_loc(exprasmlist,frametree.location,paraloc3)
  714. end
  715. else
  716. cg.a_param_const(exprasmlist,OS_INT,0,paraloc3);
  717. { push address }
  718. location_release(exprasmlist,right.location);
  719. paramanager.allocparaloc(exprasmlist,paraloc2);
  720. cg.a_param_loc(exprasmlist,right.location,paraloc2);
  721. end
  722. else
  723. begin
  724. { get current address }
  725. objectlibrary.getaddrlabel(a);
  726. cg.a_label(exprasmlist,a);
  727. reference_reset_symbol(href2,a,0);
  728. { push current frame }
  729. paramanager.allocparaloc(exprasmlist,paraloc3);
  730. cg.a_param_reg(exprasmlist,OS_ADDR,NR_FRAME_POINTER_REG,paraloc3);
  731. { push current address }
  732. paramanager.allocparaloc(exprasmlist,paraloc2);
  733. if target_info.system <> system_powerpc_macos then
  734. cg.a_paramaddr_ref(exprasmlist,href2,paraloc2)
  735. else
  736. cg.a_param_const(exprasmlist,OS_INT,0,paraloc2);
  737. end;
  738. location_release(exprasmlist,left.location);
  739. paramanager.allocparaloc(exprasmlist,paraloc1);
  740. cg.a_param_loc(exprasmlist,left.location,paraloc1);
  741. paramanager.freeparaloc(exprasmlist,paraloc1);
  742. paramanager.freeparaloc(exprasmlist,paraloc2);
  743. paramanager.freeparaloc(exprasmlist,paraloc3);
  744. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  745. cg.a_call_name(exprasmlist,'FPC_RAISEEXCEPTION');
  746. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  747. end
  748. else
  749. begin
  750. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  751. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  752. cg.a_call_name(exprasmlist,'FPC_RERAISE');
  753. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  754. end;
  755. end;
  756. {*****************************************************************************
  757. SecondTryExcept
  758. *****************************************************************************}
  759. var
  760. endexceptlabel : tasmlabel;
  761. procedure try_new_exception(list : taasmoutput;var jmpbuf,envbuf, href : treference;
  762. a : aword; exceptlabel : tasmlabel);
  763. begin
  764. tg.GetTemp(list,EXCEPT_BUF_SIZE,tt_persistent,envbuf);
  765. tg.GetTemp(list,JMP_BUF_SIZE,tt_persistent,jmpbuf);
  766. tg.GetTemp(list,sizeof(aword),tt_persistent,href);
  767. new_exception(list, jmpbuf,envbuf, href, a, exceptlabel);
  768. end;
  769. procedure try_free_exception(list : taasmoutput;var jmpbuf, envbuf : treference;const href : treference;
  770. a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
  771. begin
  772. free_exception(list, jmpbuf, envbuf, href, a, endexceptlabel, onlyfree);
  773. tg.Ungettemp(list,jmpbuf);
  774. tg.ungettemp(list,envbuf);
  775. end;
  776. { does the necessary things to clean up the object stack }
  777. { in the except block }
  778. procedure cleanupobjectstack;
  779. var
  780. paraloc1 : tparalocation;
  781. begin
  782. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  783. cg.a_call_name(exprasmlist,'FPC_POPOBJECTSTACK');
  784. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  785. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  786. paramanager.allocparaloc(exprasmlist,paraloc1);
  787. cg.a_param_reg(exprasmlist,OS_ADDR,NR_FUNCTION_RESULT_REG,paraloc1);
  788. paramanager.freeparaloc(exprasmlist,paraloc1);
  789. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  790. cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
  791. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  792. end;
  793. procedure tcgtryexceptnode.pass_2;
  794. var
  795. exceptlabel,doexceptlabel,oldendexceptlabel,
  796. lastonlabel,
  797. exitexceptlabel,
  798. continueexceptlabel,
  799. breakexceptlabel,
  800. exittrylabel,
  801. continuetrylabel,
  802. breaktrylabel,
  803. doobjectdestroy,
  804. doobjectdestroyandreraise,
  805. oldaktexitlabel,
  806. oldaktcontinuelabel,
  807. oldaktbreaklabel : tasmlabel;
  808. oldflowcontrol,tryflowcontrol,
  809. exceptflowcontrol : tflowcontrol;
  810. tempbuf,tempaddr : treference;
  811. href : treference;
  812. paraloc1 : tparalocation;
  813. label
  814. errorexit;
  815. begin
  816. location_reset(location,LOC_VOID,OS_NO);
  817. oldflowcontrol:=flowcontrol;
  818. flowcontrol:=[];
  819. { this can be called recursivly }
  820. oldendexceptlabel:=endexceptlabel;
  821. { save the old labels for control flow statements }
  822. oldaktexitlabel:=current_procinfo.aktexitlabel;
  823. if assigned(aktbreaklabel) then
  824. begin
  825. oldaktcontinuelabel:=aktcontinuelabel;
  826. oldaktbreaklabel:=aktbreaklabel;
  827. end;
  828. { get new labels for the control flow statements }
  829. objectlibrary.getlabel(exittrylabel);
  830. objectlibrary.getlabel(exitexceptlabel);
  831. if assigned(aktbreaklabel) then
  832. begin
  833. objectlibrary.getlabel(breaktrylabel);
  834. objectlibrary.getlabel(continuetrylabel);
  835. objectlibrary.getlabel(breakexceptlabel);
  836. objectlibrary.getlabel(continueexceptlabel);
  837. end;
  838. objectlibrary.getlabel(exceptlabel);
  839. objectlibrary.getlabel(doexceptlabel);
  840. objectlibrary.getlabel(endexceptlabel);
  841. objectlibrary.getlabel(lastonlabel);
  842. try_new_exception(exprasmlist,tempbuf,tempaddr,href,1,exceptlabel);
  843. { try block }
  844. { set control flow labels for the try block }
  845. current_procinfo.aktexitlabel:=exittrylabel;
  846. if assigned(oldaktbreaklabel) then
  847. begin
  848. aktcontinuelabel:=continuetrylabel;
  849. aktbreaklabel:=breaktrylabel;
  850. end;
  851. flowcontrol:=[];
  852. secondpass(left);
  853. tryflowcontrol:=flowcontrol;
  854. if codegenerror then
  855. goto errorexit;
  856. cg.a_label(exprasmlist,exceptlabel);
  857. try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,endexceptlabel,false);
  858. cg.a_label(exprasmlist,doexceptlabel);
  859. { set control flow labels for the except block }
  860. { and the on statements }
  861. current_procinfo.aktexitlabel:=exitexceptlabel;
  862. if assigned(oldaktbreaklabel) then
  863. begin
  864. aktcontinuelabel:=continueexceptlabel;
  865. aktbreaklabel:=breakexceptlabel;
  866. end;
  867. flowcontrol:=[];
  868. { on statements }
  869. if assigned(right) then
  870. secondpass(right);
  871. cg.a_label(exprasmlist,lastonlabel);
  872. { default handling except handling }
  873. if assigned(t1) then
  874. begin
  875. { FPC_CATCHES must be called with
  876. 'default handler' flag (=-1)
  877. }
  878. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  879. paramanager.allocparaloc(exprasmlist,paraloc1);
  880. cg.a_param_const(exprasmlist,OS_ADDR,aword(-1),paraloc1);
  881. paramanager.freeparaloc(exprasmlist,paraloc1);
  882. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  883. cg.a_call_name(exprasmlist,'FPC_CATCHES');
  884. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  885. { the destruction of the exception object must be also }
  886. { guarded by an exception frame }
  887. objectlibrary.getlabel(doobjectdestroy);
  888. objectlibrary.getlabel(doobjectdestroyandreraise);
  889. try_new_exception(exprasmlist,tempbuf,tempaddr,href,1,doobjectdestroyandreraise);
  890. { here we don't have to reset flowcontrol }
  891. { the default and on flowcontrols are handled equal }
  892. secondpass(t1);
  893. exceptflowcontrol:=flowcontrol;
  894. cg.a_label(exprasmlist,doobjectdestroyandreraise);
  895. try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
  896. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  897. cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
  898. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  899. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  900. paramanager.allocparaloc(exprasmlist,paraloc1);
  901. cg.a_param_reg(exprasmlist, OS_ADDR, NR_FUNCTION_RESULT_REG, paraloc1);
  902. paramanager.freeparaloc(exprasmlist,paraloc1);
  903. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  904. cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
  905. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  906. { we don't need to restore esi here because reraise never }
  907. { returns }
  908. cg.a_call_name(exprasmlist,'FPC_RERAISE');
  909. cg.a_label(exprasmlist,doobjectdestroy);
  910. cleanupobjectstack;
  911. cg.a_jmp_always(exprasmlist,endexceptlabel);
  912. end
  913. else
  914. begin
  915. cg.a_call_name(exprasmlist,'FPC_RERAISE');
  916. exceptflowcontrol:=flowcontrol;
  917. end;
  918. if fc_exit in exceptflowcontrol then
  919. begin
  920. { do some magic for exit in the try block }
  921. cg.a_label(exprasmlist,exitexceptlabel);
  922. { we must also destroy the address frame which guards }
  923. { exception object }
  924. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  925. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  926. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  927. cg.g_exception_reason_load(exprasmlist,href);
  928. cleanupobjectstack;
  929. cg.a_jmp_always(exprasmlist,oldaktexitlabel);
  930. end;
  931. if fc_break in exceptflowcontrol then
  932. begin
  933. cg.a_label(exprasmlist,breakexceptlabel);
  934. { we must also destroy the address frame which guards }
  935. { exception object }
  936. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  937. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  938. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  939. cg.g_exception_reason_load(exprasmlist,href);
  940. cleanupobjectstack;
  941. cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
  942. end;
  943. if fc_continue in exceptflowcontrol then
  944. begin
  945. cg.a_label(exprasmlist,continueexceptlabel);
  946. { we must also destroy the address frame which guards }
  947. { exception object }
  948. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  949. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  950. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  951. cg.g_exception_reason_load(exprasmlist,href);
  952. cleanupobjectstack;
  953. cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
  954. end;
  955. if fc_exit in tryflowcontrol then
  956. begin
  957. { do some magic for exit in the try block }
  958. cg.a_label(exprasmlist,exittrylabel);
  959. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  960. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  961. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  962. cg.g_exception_reason_load(exprasmlist,href);
  963. cg.a_jmp_always(exprasmlist,oldaktexitlabel);
  964. end;
  965. if fc_break in tryflowcontrol then
  966. begin
  967. cg.a_label(exprasmlist,breaktrylabel);
  968. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  969. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  970. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  971. cg.g_exception_reason_load(exprasmlist,href);
  972. cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
  973. end;
  974. if fc_continue in tryflowcontrol then
  975. begin
  976. cg.a_label(exprasmlist,continuetrylabel);
  977. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  978. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  979. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  980. cg.g_exception_reason_load(exprasmlist,href);
  981. cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
  982. end;
  983. tg.ungettemp(exprasmlist,href);
  984. cg.a_label(exprasmlist,endexceptlabel);
  985. errorexit:
  986. { restore all saved labels }
  987. endexceptlabel:=oldendexceptlabel;
  988. { restore the control flow labels }
  989. current_procinfo.aktexitlabel:=oldaktexitlabel;
  990. if assigned(oldaktbreaklabel) then
  991. begin
  992. aktcontinuelabel:=oldaktcontinuelabel;
  993. aktbreaklabel:=oldaktbreaklabel;
  994. end;
  995. { return all used control flow statements }
  996. flowcontrol:=oldflowcontrol+exceptflowcontrol+
  997. tryflowcontrol;
  998. end;
  999. procedure tcgonnode.pass_2;
  1000. var
  1001. nextonlabel,
  1002. exitonlabel,
  1003. continueonlabel,
  1004. breakonlabel,
  1005. oldaktexitlabel,
  1006. oldaktcontinuelabel,
  1007. doobjectdestroyandreraise,
  1008. doobjectdestroy,
  1009. oldaktbreaklabel : tasmlabel;
  1010. oldflowcontrol : tflowcontrol;
  1011. exceptref,
  1012. tempbuf,tempaddr : treference;
  1013. href : treference;
  1014. href2: treference;
  1015. paraloc1 : tparalocation;
  1016. begin
  1017. location_reset(location,LOC_VOID,OS_NO);
  1018. oldflowcontrol:=flowcontrol;
  1019. flowcontrol:=[];
  1020. objectlibrary.getlabel(nextonlabel);
  1021. { send the vmt parameter }
  1022. reference_reset_symbol(href2,objectlibrary.newasmsymboldata(excepttype.vmt_mangledname),0);
  1023. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1024. paramanager.allocparaloc(exprasmlist,paraloc1);
  1025. cg.a_paramaddr_ref(exprasmlist,href2,paraloc1);
  1026. paramanager.freeparaloc(exprasmlist,paraloc1);
  1027. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1028. cg.a_call_name(exprasmlist,'FPC_CATCHES');
  1029. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1030. { is it this catch? No. go to next onlabel }
  1031. cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,NR_FUNCTION_RESULT_REG,nextonlabel);
  1032. { what a hack ! }
  1033. if assigned(exceptsymtable) then
  1034. begin
  1035. tvarsym(exceptsymtable.symindex.first).localloc.loc:=LOC_REFERENCE;
  1036. tg.GetLocal(exprasmlist,POINTER_SIZE,voidpointertype.def,
  1037. tvarsym(exceptsymtable.symindex.first).localloc.reference);
  1038. reference_reset_base(href,tvarsym(exceptsymtable.symindex.first).localloc.reference.index,
  1039. tvarsym(exceptsymtable.symindex.first).localloc.reference.offset);
  1040. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,href);
  1041. end
  1042. else
  1043. begin
  1044. tg.GetTemp(exprasmlist,POINTER_SIZE,tt_normal,exceptref);
  1045. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,exceptref);
  1046. end;
  1047. { in the case that another exception is risen }
  1048. { we've to destroy the old one }
  1049. objectlibrary.getlabel(doobjectdestroyandreraise);
  1050. { call setjmp, and jump to finally label on non-zero result }
  1051. try_new_exception(exprasmlist,tempbuf,tempaddr,href,1,doobjectdestroyandreraise);
  1052. if assigned(right) then
  1053. begin
  1054. oldaktexitlabel:=current_procinfo.aktexitlabel;
  1055. objectlibrary.getlabel(exitonlabel);
  1056. current_procinfo.aktexitlabel:=exitonlabel;
  1057. if assigned(aktbreaklabel) then
  1058. begin
  1059. oldaktcontinuelabel:=aktcontinuelabel;
  1060. oldaktbreaklabel:=aktbreaklabel;
  1061. objectlibrary.getlabel(breakonlabel);
  1062. objectlibrary.getlabel(continueonlabel);
  1063. aktcontinuelabel:=continueonlabel;
  1064. aktbreaklabel:=breakonlabel;
  1065. end;
  1066. secondpass(right);
  1067. end;
  1068. objectlibrary.getlabel(doobjectdestroy);
  1069. cg.a_label(exprasmlist,doobjectdestroyandreraise);
  1070. try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
  1071. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1072. cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
  1073. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1074. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  1075. paramanager.allocparaloc(exprasmlist,paraloc1);
  1076. cg.a_param_reg(exprasmlist, OS_ADDR, NR_FUNCTION_RESULT_REG, paraloc1);
  1077. paramanager.freeparaloc(exprasmlist,paraloc1);
  1078. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1079. cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
  1080. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  1081. { we don't need to restore esi here because reraise never }
  1082. { returns }
  1083. cg.a_call_name(exprasmlist,'FPC_RERAISE');
  1084. cg.a_label(exprasmlist,doobjectdestroy);
  1085. cleanupobjectstack;
  1086. { clear some stuff }
  1087. if assigned(exceptsymtable) then
  1088. begin
  1089. tg.UngetLocal(exprasmlist,tvarsym(exceptsymtable.symindex.first).localloc.reference);
  1090. tvarsym(exceptsymtable.symindex.first).localloc.loc:=LOC_INVALID;
  1091. end
  1092. else
  1093. tg.Ungettemp(exprasmlist,exceptref);
  1094. cg.a_jmp_always(exprasmlist,endexceptlabel);
  1095. if assigned(right) then
  1096. begin
  1097. { special handling for control flow instructions }
  1098. if fc_exit in flowcontrol then
  1099. begin
  1100. { the address and object pop does secondtryexcept }
  1101. cg.a_label(exprasmlist,exitonlabel);
  1102. cg.a_jmp_always(exprasmlist,oldaktexitlabel);
  1103. end;
  1104. if fc_break in flowcontrol then
  1105. begin
  1106. { the address and object pop does secondtryexcept }
  1107. cg.a_label(exprasmlist,breakonlabel);
  1108. cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
  1109. end;
  1110. if fc_continue in flowcontrol then
  1111. begin
  1112. { the address and object pop does secondtryexcept }
  1113. cg.a_label(exprasmlist,continueonlabel);
  1114. cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
  1115. end;
  1116. current_procinfo.aktexitlabel:=oldaktexitlabel;
  1117. if assigned(oldaktbreaklabel) then
  1118. begin
  1119. aktcontinuelabel:=oldaktcontinuelabel;
  1120. aktbreaklabel:=oldaktbreaklabel;
  1121. end;
  1122. end;
  1123. cg.a_label(exprasmlist,nextonlabel);
  1124. flowcontrol:=oldflowcontrol+flowcontrol;
  1125. { next on node }
  1126. if assigned(left) then
  1127. secondpass(left);
  1128. end;
  1129. {*****************************************************************************
  1130. SecondTryFinally
  1131. *****************************************************************************}
  1132. procedure tcgtryfinallynode.pass_2;
  1133. var
  1134. reraiselabel,
  1135. finallylabel,
  1136. endfinallylabel,
  1137. exitfinallylabel,
  1138. continuefinallylabel,
  1139. breakfinallylabel,
  1140. oldaktexitlabel,
  1141. oldaktcontinuelabel,
  1142. oldaktbreaklabel : tasmlabel;
  1143. oldflowcontrol,tryflowcontrol : tflowcontrol;
  1144. decconst : longint;
  1145. tempbuf,tempaddr : treference;
  1146. href : treference;
  1147. begin
  1148. location_reset(location,LOC_VOID,OS_NO);
  1149. { check if child nodes do a break/continue/exit }
  1150. oldflowcontrol:=flowcontrol;
  1151. flowcontrol:=[];
  1152. objectlibrary.getlabel(finallylabel);
  1153. objectlibrary.getlabel(endfinallylabel);
  1154. objectlibrary.getlabel(reraiselabel);
  1155. { the finally block must catch break, continue and exit }
  1156. { statements }
  1157. oldaktexitlabel:=current_procinfo.aktexitlabel;
  1158. if implicitframe then
  1159. exitfinallylabel:=finallylabel
  1160. else
  1161. objectlibrary.getlabel(exitfinallylabel);
  1162. current_procinfo.aktexitlabel:=exitfinallylabel;
  1163. if assigned(aktbreaklabel) then
  1164. begin
  1165. oldaktcontinuelabel:=aktcontinuelabel;
  1166. oldaktbreaklabel:=aktbreaklabel;
  1167. if implicitframe then
  1168. begin
  1169. breakfinallylabel:=finallylabel;
  1170. continuefinallylabel:=finallylabel;
  1171. end
  1172. else
  1173. begin
  1174. objectlibrary.getlabel(breakfinallylabel);
  1175. objectlibrary.getlabel(continuefinallylabel);
  1176. end;
  1177. aktcontinuelabel:=continuefinallylabel;
  1178. aktbreaklabel:=breakfinallylabel;
  1179. end;
  1180. { call setjmp, and jump to finally label on non-zero result }
  1181. try_new_exception(exprasmlist,tempbuf,tempaddr,href,1,finallylabel);
  1182. { try code }
  1183. if assigned(left) then
  1184. begin
  1185. secondpass(left);
  1186. tryflowcontrol:=flowcontrol;
  1187. if codegenerror then
  1188. exit;
  1189. end;
  1190. cg.a_label(exprasmlist,finallylabel);
  1191. { just free the frame information }
  1192. try_free_exception(exprasmlist,tempbuf,tempaddr,href,1,finallylabel,true);
  1193. { finally code }
  1194. flowcontrol:=[];
  1195. secondpass(right);
  1196. if flowcontrol<>[] then
  1197. CGMessage(cg_e_control_flow_outside_finally);
  1198. if codegenerror then
  1199. exit;
  1200. { the value should now be in the exception handler }
  1201. cg.g_exception_reason_load(exprasmlist,href);
  1202. if implicitframe then
  1203. begin
  1204. cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,endfinallylabel);
  1205. { finally code only needed to be executed on exception }
  1206. flowcontrol:=[];
  1207. secondpass(t1);
  1208. if flowcontrol<>[] then
  1209. CGMessage(cg_e_control_flow_outside_finally);
  1210. if codegenerror then
  1211. exit;
  1212. cg.a_call_name(exprasmlist,'FPC_RERAISE');
  1213. end
  1214. else
  1215. begin
  1216. cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,endfinallylabel);
  1217. cg.a_op_const_reg(exprasmlist,OP_SUB,OS_INT,1,NR_FUNCTION_RESULT_REG);
  1218. cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,reraiselabel);
  1219. if fc_exit in tryflowcontrol then
  1220. begin
  1221. cg.a_op_const_reg(exprasmlist,OP_SUB,OS_INT,1,NR_FUNCTION_RESULT_REG);
  1222. cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,oldaktexitlabel);
  1223. decconst:=1;
  1224. end
  1225. else
  1226. decconst:=2;
  1227. if fc_break in tryflowcontrol then
  1228. begin
  1229. cg.a_op_const_reg(exprasmlist,OP_SUB,OS_INT,decconst,NR_FUNCTION_RESULT_REG);
  1230. cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,oldaktbreaklabel);
  1231. decconst:=1;
  1232. end
  1233. else
  1234. inc(decconst);
  1235. if fc_continue in tryflowcontrol then
  1236. begin
  1237. cg.a_op_const_reg(exprasmlist,OP_SUB,OS_INT,decconst,NR_FUNCTION_RESULT_REG);
  1238. cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,oldaktcontinuelabel);
  1239. end;
  1240. cg.a_label(exprasmlist,reraiselabel);
  1241. cg.a_call_name(exprasmlist,'FPC_RERAISE');
  1242. { do some magic for exit,break,continue in the try block }
  1243. if fc_exit in tryflowcontrol then
  1244. begin
  1245. cg.a_label(exprasmlist,exitfinallylabel);
  1246. cg.g_exception_reason_load(exprasmlist,href);
  1247. cg.g_exception_reason_save_const(exprasmlist,href,2);
  1248. cg.a_jmp_always(exprasmlist,finallylabel);
  1249. end;
  1250. if fc_break in tryflowcontrol then
  1251. begin
  1252. cg.a_label(exprasmlist,breakfinallylabel);
  1253. cg.g_exception_reason_load(exprasmlist,href);
  1254. cg.g_exception_reason_save_const(exprasmlist,href,3);
  1255. cg.a_jmp_always(exprasmlist,finallylabel);
  1256. end;
  1257. if fc_continue in tryflowcontrol then
  1258. begin
  1259. cg.a_label(exprasmlist,continuefinallylabel);
  1260. cg.g_exception_reason_load(exprasmlist,href);
  1261. cg.g_exception_reason_save_const(exprasmlist,href,4);
  1262. cg.a_jmp_always(exprasmlist,finallylabel);
  1263. end;
  1264. end;
  1265. cg.a_label(exprasmlist,endfinallylabel);
  1266. tg.ungettemp(exprasmlist,href);
  1267. current_procinfo.aktexitlabel:=oldaktexitlabel;
  1268. if assigned(aktbreaklabel) then
  1269. begin
  1270. aktcontinuelabel:=oldaktcontinuelabel;
  1271. aktbreaklabel:=oldaktbreaklabel;
  1272. end;
  1273. flowcontrol:=oldflowcontrol+tryflowcontrol;
  1274. end;
  1275. begin
  1276. cwhilerepeatnode:=tcgwhilerepeatnode;
  1277. cifnode:=tcgifnode;
  1278. cfornode:=tcgfornode;
  1279. cexitnode:=tcgexitnode;
  1280. cbreaknode:=tcgbreaknode;
  1281. ccontinuenode:=tcgcontinuenode;
  1282. cgotonode:=tcggotonode;
  1283. clabelnode:=tcglabelnode;
  1284. craisenode:=tcgraisenode;
  1285. ctryexceptnode:=tcgtryexceptnode;
  1286. ctryfinallynode:=tcgtryfinallynode;
  1287. connode:=tcgonnode;
  1288. end.
  1289. {
  1290. $Log$
  1291. Revision 1.91 2004-02-05 18:28:37 peter
  1292. * x86_64 fixes for opsize
  1293. Revision 1.90 2004/01/31 17:45:17 peter
  1294. * Change several $ifdef i386 to x86
  1295. * Change several OS_32 to OS_INT/OS_ADDR
  1296. Revision 1.89 2004/01/12 22:11:38 peter
  1297. * use localalign info for alignment for locals and temps
  1298. * sparc fpu flags branching added
  1299. * moved powerpc copy_valye_openarray to generic
  1300. Revision 1.88 2004/01/01 17:23:16 florian
  1301. * fixed wrong temp. usage in generic exception handling
  1302. Revision 1.87 2003/12/06 01:15:22 florian
  1303. * reverted Peter's alloctemp patch; hopefully properly
  1304. Revision 1.86 2003/12/03 23:13:20 peter
  1305. * delayed paraloc allocation, a_param_*() gets extra parameter
  1306. if it needs to allocate temp or real paralocation
  1307. * optimized/simplified int-real loading
  1308. Revision 1.85 2003/10/17 14:38:32 peter
  1309. * 64k registers supported
  1310. * fixed some memory leaks
  1311. Revision 1.84 2003/10/10 17:48:13 peter
  1312. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  1313. * tregisteralloctor renamed to trgobj
  1314. * removed rgobj from a lot of units
  1315. * moved location_* and reference_* to cgobj
  1316. * first things for mmx register allocation
  1317. Revision 1.83 2003/10/09 21:31:37 daniel
  1318. * Register allocator splitted, ans abstract now
  1319. Revision 1.82 2003/10/01 20:34:48 peter
  1320. * procinfo unit contains tprocinfo
  1321. * cginfo renamed to cgbase
  1322. * moved cgmessage to verbose
  1323. * fixed ppc and sparc compiles
  1324. Revision 1.81 2003/09/23 17:56:05 peter
  1325. * locals and paras are allocated in the code generation
  1326. * tvarsym.localloc contains the location of para/local when
  1327. generating code for the current procedure
  1328. Revision 1.80 2003/09/10 08:31:47 marco
  1329. * Patch from Peter for paraloc
  1330. Revision 1.79 2003/09/07 22:09:35 peter
  1331. * preparations for different default calling conventions
  1332. * various RA fixes
  1333. Revision 1.78 2003/09/03 15:55:00 peter
  1334. * NEWRA branch merged
  1335. Revision 1.77 2003/09/03 11:18:36 florian
  1336. * fixed arm concatcopy
  1337. + arm support in the common compiler sources added
  1338. * moved some generic cg code around
  1339. + tfputype added
  1340. * ...
  1341. Revision 1.76.2.4 2003/09/02 17:48:28 peter
  1342. * first process all parameters for raise before pushing the values
  1343. Revision 1.76.2.3 2003/08/31 21:07:44 daniel
  1344. * callparatemp ripped
  1345. Revision 1.76.2.2 2003/08/29 17:28:59 peter
  1346. * next batch of updates
  1347. Revision 1.76.2.1 2003/08/27 20:23:55 peter
  1348. * remove old ra code
  1349. Revision 1.76 2003/08/24 21:38:43 olle
  1350. * made FPC_RAISEEXCEPTION compatible with MacOS
  1351. Revision 1.75 2003/08/10 17:25:23 peter
  1352. * fixed some reported bugs
  1353. Revision 1.74 2003/08/09 18:56:54 daniel
  1354. * cs_regalloc renamed to cs_regvars to avoid confusion with register
  1355. allocator
  1356. * Some preventive changes to i386 spillinh code
  1357. Revision 1.73 2003/07/23 11:01:14 jonas
  1358. * several rg.allocexplicitregistersint/rg.deallocexplicitregistersint
  1359. pairs round calls to helpers
  1360. Revision 1.72 2003/06/13 21:19:30 peter
  1361. * current_procdef removed, use current_procinfo.procdef instead
  1362. Revision 1.71 2003/06/09 14:38:52 jonas
  1363. * fixed for callparatemp
  1364. Revision 1.70 2003/06/09 12:23:30 peter
  1365. * init/final of procedure data splitted from genentrycode
  1366. * use asmnode getposition to insert final at the correct position
  1367. als for the implicit try...finally
  1368. Revision 1.69 2003/06/07 18:57:04 jonas
  1369. + added freeintparaloc
  1370. * ppc get/freeintparaloc now check whether the parameter regs are
  1371. properly allocated/deallocated (and get an extra list para)
  1372. * ppc a_call_* now internalerrors if pi_do_call is not yet set
  1373. * fixed lot of missing pi_do_call's
  1374. Revision 1.68 2003/06/03 21:11:09 peter
  1375. * cg.a_load_* get a from and to size specifier
  1376. * makeregsize only accepts newregister
  1377. * i386 uses generic tcgnotnode,tcgunaryminus
  1378. Revision 1.67 2003/06/01 21:38:06 peter
  1379. * getregisterfpu size parameter added
  1380. * op_const_reg size parameter added
  1381. * sparc updates
  1382. Revision 1.66 2003/05/30 23:57:08 peter
  1383. * more sparc cleanup
  1384. * accumulator removed, splitted in function_return_reg (called) and
  1385. function_result_reg (caller)
  1386. Revision 1.65 2003/05/30 18:55:21 jonas
  1387. * fixed several regvar related bugs for non-i386. make cycle with -Or now
  1388. works for ppc
  1389. Revision 1.64 2003/05/26 21:17:17 peter
  1390. * procinlinenode removed
  1391. * aktexit2label removed, fast exit removed
  1392. + tcallnode.inlined_pass_2 added
  1393. Revision 1.63 2003/05/23 14:27:35 peter
  1394. * remove some unit dependencies
  1395. * current_procinfo changes to store more info
  1396. Revision 1.62 2003/05/17 13:30:08 jonas
  1397. * changed tt_persistant to tt_persistent :)
  1398. * tempcreatenode now doesn't accept a boolean anymore for persistent
  1399. temps, but a ttemptype, so you can also create ansistring temps etc
  1400. Revision 1.61 2003/05/16 14:33:31 peter
  1401. * regvar fixes
  1402. Revision 1.60 2003/05/13 19:14:41 peter
  1403. * failn removed
  1404. * inherited result code check moven to pexpr
  1405. Revision 1.59 2003/05/11 21:37:03 peter
  1406. * moved implicit exception frame from ncgutil to psub
  1407. * constructor/destructor helpers moved from cobj/ncgutil to psub
  1408. Revision 1.58 2003/04/30 15:45:35 florian
  1409. * merged more x86-64/i386 code
  1410. Revision 1.57 2003/04/29 07:29:14 michael
  1411. + Patch from peter to fix wrong pushing of ansistring function results in open array
  1412. Revision 1.56 2003/04/27 11:21:33 peter
  1413. * aktprocdef renamed to current_procinfo.procdef
  1414. * procinfo renamed to current_procinfo
  1415. * procinfo will now be stored in current_module so it can be
  1416. cleaned up properly
  1417. * gen_main_procsym changed to create_main_proc and release_main_proc
  1418. to also generate a tprocinfo structure
  1419. * fixed unit implicit initfinal
  1420. Revision 1.55 2003/04/22 23:50:22 peter
  1421. * firstpass uses expectloc
  1422. * checks if there are differences between the expectloc and
  1423. location.loc from secondpass in EXTDEBUG
  1424. Revision 1.54 2003/04/17 07:50:24 daniel
  1425. * Some work on interference graph construction
  1426. Revision 1.53 2003/04/06 21:11:23 olle
  1427. * changed newasmsymbol to newasmsymboldata for data symbols
  1428. Revision 1.52 2003/03/28 19:16:56 peter
  1429. * generic constructor working for i386
  1430. * remove fixed self register
  1431. * esi added as address register for i386
  1432. Revision 1.51 2003/02/19 22:00:14 daniel
  1433. * Code generator converted to new register notation
  1434. - Horribily outdated todo.txt removed
  1435. Revision 1.50 2003/02/15 22:17:38 carl
  1436. * bugfix of FPU emulation code
  1437. Revision 1.49 2003/01/08 18:43:56 daniel
  1438. * Tregister changed into a record
  1439. Revision 1.48 2003/01/03 09:51:58 daniel
  1440. * Compiler now cycles with var_notification
  1441. Revision 1.47 2003/01/02 15:29:25 daniel
  1442. * Some debugging on for loop optimization
  1443. Revision 1.46 2002/12/31 09:55:58 daniel
  1444. + Notification implementation complete
  1445. + Add for loop code optimization using notifications
  1446. results in 1.5-1.9% speed improvement in nestloop benchmark
  1447. Optimization incomplete, compiler does not cycle yet with
  1448. notifications enabled.
  1449. Revision 1.45 2002/11/28 11:17:01 florian
  1450. * loop node flags from node flags splitted
  1451. Revision 1.44 2002/11/25 17:43:17 peter
  1452. * splitted defbase in defutil,symutil,defcmp
  1453. * merged isconvertable and is_equal into compare_defs(_ext)
  1454. * made operator search faster by walking the list only once
  1455. Revision 1.43 2002/09/30 07:00:45 florian
  1456. * fixes to common code to get the alpha compiler compiled applied
  1457. Revision 1.42 2002/09/07 15:25:02 peter
  1458. * old logs removed and tabs fixed
  1459. Revision 1.41 2002/09/01 18:47:00 peter
  1460. * assignn check in exitnode changed to use a separate boolean as the
  1461. assignn can be changed to a calln
  1462. Revision 1.40 2002/09/01 14:41:47 peter
  1463. * increase refcount in exit(arg) for arg
  1464. Revision 1.39 2002/08/24 18:41:52 peter
  1465. * fixed wrong label in jump of except block (was also in n386flw wrong)
  1466. * fixed wrong pushing of raise parameters
  1467. * fixed wrong compare in finally
  1468. Revision 1.38 2002/08/23 16:14:48 peter
  1469. * tempgen cleanup
  1470. * tt_noreuse temp type added that will be used in genentrycode
  1471. Revision 1.37 2002/08/19 19:36:43 peter
  1472. * More fixes for cross unit inlining, all tnodes are now implemented
  1473. * Moved pocall_internconst to po_internconst because it is not a
  1474. calling type at all and it conflicted when inlining of these small
  1475. functions was requested
  1476. Revision 1.36 2002/08/15 15:15:55 carl
  1477. * jmpbuf size allocation for exceptions is now cpu specific (as it should)
  1478. * more generic nodes for maths
  1479. * several fixes for better m68k support
  1480. Revision 1.35 2002/08/13 18:01:52 carl
  1481. * rename swatoperands to swapoperands
  1482. + m68k first compilable version (still needs a lot of testing):
  1483. assembler generator, system information , inline
  1484. assembler reader.
  1485. Revision 1.34 2002/08/11 14:32:26 peter
  1486. * renamed current_library to objectlibrary
  1487. Revision 1.33 2002/08/11 13:24:11 peter
  1488. * saving of asmsymbols in ppu supported
  1489. * asmsymbollist global is removed and moved into a new class
  1490. tasmlibrarydata that will hold the info of a .a file which
  1491. corresponds with a single module. Added librarydata to tmodule
  1492. to keep the library info stored for the module. In the future the
  1493. objectfiles will also be stored to the tasmlibrarydata class
  1494. * all getlabel/newasmsymbol and friends are moved to the new class
  1495. Revision 1.32 2002/08/09 19:10:59 carl
  1496. * fixed generic exception management
  1497. Revision 1.31 2002/08/04 19:06:41 carl
  1498. + added generic exception support (still does not work!)
  1499. + more documentation
  1500. Revision 1.30 2002/07/27 19:53:51 jonas
  1501. + generic implementation of tcg.g_flags2ref()
  1502. * tcg.flags2xxx() now also needs a size parameter
  1503. Revision 1.29 2002/07/25 17:56:29 carl
  1504. + FPURESULTREG -> FPU_RESULT_REG
  1505. Revision 1.28 2002/07/21 06:58:49 daniel
  1506. * Changed booleans into flags
  1507. Revision 1.27 2002/07/20 12:54:53 daniel
  1508. * Optimized the code generated for for nodes. The shootout/nestloop benchmark
  1509. now runs 5% faster on my computer.
  1510. Revision 1.26 2002/07/20 11:57:54 florian
  1511. * types.pas renamed to defbase.pas because D6 contains a types
  1512. unit so this would conflicts if D6 programms are compiled
  1513. + Willamette/SSE2 instructions to assembler added
  1514. Revision 1.25 2002/07/20 11:15:51 daniel
  1515. * The for node does a check if the first comparision can be skipped. I moved
  1516. the check from the second pass to the resulttype pass. The advantage is
  1517. that the state tracker can now decide to skip the first comparision too.
  1518. Revision 1.24 2002/07/20 08:14:24 daniel
  1519. * Loops should not be aligned when optimizing for size
  1520. Revision 1.23 2002/07/19 11:41:35 daniel
  1521. * State tracker work
  1522. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1523. allows the state tracker to change while nodes automatically into
  1524. repeat nodes.
  1525. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1526. 'not(a>b)' is optimized into 'a<=b'.
  1527. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1528. by removing the notn and later switchting the true and falselabels. The
  1529. same is done with 'repeat until not a'.
  1530. Revision 1.22 2002/07/04 20:43:01 florian
  1531. * first x86-64 patches
  1532. }