ncgflw.pas 64 KB

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