ncgflw.pas 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate assembler for nodes that influence the flow which are
  4. the same for all (most?) processors
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit ncgflw;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. aasmbase,node,nflw,ncgutil;
  23. type
  24. tcgwhilerepeatnode = class(twhilerepeatnode)
  25. usedregvars: tusedregvars;
  26. procedure pass_generate_code;override;
  27. procedure sync_regvars(checkusedregvars: boolean);
  28. end;
  29. tcgifnode = class(tifnode)
  30. procedure pass_generate_code;override;
  31. end;
  32. tcgfornode = class(tfornode)
  33. usedregvars: tusedregvars;
  34. procedure pass_generate_code;override;
  35. procedure sync_regvars(checkusedregvars: boolean);
  36. end;
  37. tcgexitnode = class(texitnode)
  38. procedure pass_generate_code;override;
  39. end;
  40. tcgbreaknode = class(tbreaknode)
  41. procedure pass_generate_code;override;
  42. end;
  43. tcgcontinuenode = class(tcontinuenode)
  44. procedure pass_generate_code;override;
  45. end;
  46. tcggotonode = class(tgotonode)
  47. procedure pass_generate_code;override;
  48. end;
  49. tcglabelnode = class(tlabelnode)
  50. private
  51. asmlabel : tasmlabel;
  52. public
  53. function getasmlabel : tasmlabel;
  54. procedure pass_generate_code;override;
  55. end;
  56. tcgraisenode = class(traisenode)
  57. procedure pass_generate_code;override;
  58. end;
  59. tcgtryexceptnode = class(ttryexceptnode)
  60. procedure pass_generate_code;override;
  61. end;
  62. tcgtryfinallynode = class(ttryfinallynode)
  63. procedure pass_generate_code;override;
  64. end;
  65. tcgonnode = class(tonnode)
  66. procedure pass_generate_code;override;
  67. end;
  68. implementation
  69. uses
  70. verbose,globals,systems,globtype,constexp,
  71. symconst,symdef,symsym,aasmtai,aasmdata,aasmcpu,defutil,
  72. procinfo,cgbase,pass_2,parabase,
  73. cpubase,cpuinfo,
  74. nld,ncon,
  75. tgobj,paramgr,
  76. regvars,
  77. cgutils,cgobj
  78. ;
  79. {*****************************************************************************
  80. Second_While_RepeatN
  81. *****************************************************************************}
  82. procedure tcgwhilerepeatnode.sync_regvars(checkusedregvars: boolean);
  83. begin
  84. if (cs_opt_regvar in current_settings.optimizerswitches) and
  85. not(pi_has_goto in current_procinfo.flags) then
  86. begin
  87. if checkusedregvars then
  88. begin
  89. usedregvars.intregvars.init;
  90. usedregvars.fpuregvars.init;
  91. usedregvars.mmregvars.init;
  92. { we have to synchronise both the regvars used in the loop }
  93. { and the ones in the while/until condition }
  94. get_used_regvars(self,usedregvars);
  95. gen_sync_regvars(current_asmdata.CurrAsmList,usedregvars);
  96. end
  97. else
  98. begin
  99. gen_sync_regvars(current_asmdata.CurrAsmList,usedregvars);
  100. usedregvars.intregvars.done;
  101. usedregvars.fpuregvars.done;
  102. usedregvars.mmregvars.done;
  103. end;
  104. end;
  105. end;
  106. procedure tcgwhilerepeatnode.pass_generate_code;
  107. var
  108. lcont,lbreak,lloop,
  109. oldclabel,oldblabel : tasmlabel;
  110. otlabel,oflabel : tasmlabel;
  111. oldflowcontrol : tflowcontrol;
  112. oldexecutionweight : longint;
  113. begin
  114. location_reset(location,LOC_VOID,OS_NO);
  115. current_asmdata.getjumplabel(lloop);
  116. current_asmdata.getjumplabel(lcont);
  117. current_asmdata.getjumplabel(lbreak);
  118. { arrange continue and breaklabels: }
  119. oldflowcontrol:=flowcontrol;
  120. oldclabel:=current_procinfo.CurrContinueLabel;
  121. oldblabel:=current_procinfo.CurrBreakLabel;
  122. include(flowcontrol,fc_inflowcontrol);
  123. sync_regvars(true);
  124. {$ifdef OLDREGVARS}
  125. load_all_regvars(current_asmdata.CurrAsmList);
  126. {$endif OLDREGVARS}
  127. { handling code at the end as it is much more efficient, and makes
  128. while equal to repeat loop, only the end true/false is swapped (PFV) }
  129. if lnf_testatbegin in loopflags then
  130. cg.a_jmp_always(current_asmdata.CurrAsmList,lcont);
  131. if not(cs_opt_size in current_settings.optimizerswitches) then
  132. { align loop target }
  133. current_asmdata.CurrAsmList.concat(Tai_align.Create(current_settings.alignment.loopalign));
  134. cg.a_label(current_asmdata.CurrAsmList,lloop);
  135. current_procinfo.CurrContinueLabel:=lcont;
  136. current_procinfo.CurrBreakLabel:=lbreak;
  137. if assigned(right) then
  138. begin
  139. { calc register weight }
  140. oldexecutionweight:=cg.executionweight;
  141. cg.executionweight:=cg.executionweight*8;
  142. secondpass(right);
  143. cg.executionweight:=oldexecutionweight;
  144. end;
  145. {$ifdef OLDREGVARS}
  146. load_all_regvars(current_asmdata.CurrAsmList);
  147. {$endif OLDREGVARS}
  148. cg.a_label(current_asmdata.CurrAsmList,lcont);
  149. otlabel:=current_procinfo.CurrTrueLabel;
  150. oflabel:=current_procinfo.CurrFalseLabel;
  151. if lnf_checknegate in loopflags then
  152. begin
  153. current_procinfo.CurrTrueLabel:=lbreak;
  154. current_procinfo.CurrFalseLabel:=lloop;
  155. end
  156. else
  157. begin
  158. current_procinfo.CurrTrueLabel:=lloop;
  159. current_procinfo.CurrFalseLabel:=lbreak;
  160. end;
  161. secondpass(left);
  162. maketojumpbool(current_asmdata.CurrAsmList,left,lr_load_regvars);
  163. cg.a_label(current_asmdata.CurrAsmList,lbreak);
  164. sync_regvars(false);
  165. current_procinfo.CurrTrueLabel:=otlabel;
  166. current_procinfo.CurrFalseLabel:=oflabel;
  167. current_procinfo.CurrContinueLabel:=oldclabel;
  168. current_procinfo.CurrBreakLabel:=oldblabel;
  169. { a break/continue in a while/repeat block can't be seen outside }
  170. flowcontrol:=oldflowcontrol+(flowcontrol-[fc_break,fc_continue,fc_inflowcontrol]);
  171. end;
  172. {*****************************************************************************
  173. tcgIFNODE
  174. *****************************************************************************}
  175. procedure tcgifnode.pass_generate_code;
  176. var
  177. hl,otlabel,oflabel : tasmlabel;
  178. oldflowcontrol: tflowcontrol;
  179. oldexecutionweight : longint;
  180. (*
  181. org_regvar_loaded_other,
  182. then_regvar_loaded_other,
  183. else_regvar_loaded_other : regvarother_booleanarray;
  184. org_regvar_loaded_int,
  185. then_regvar_loaded_int,
  186. else_regvar_loaded_int : Tsuperregisterset;
  187. org_list,
  188. then_list,
  189. else_list : TAsmList;
  190. *)
  191. begin
  192. location_reset(location,LOC_VOID,OS_NO);
  193. oldflowcontrol := flowcontrol;
  194. include(flowcontrol,fc_inflowcontrol);
  195. otlabel:=current_procinfo.CurrTrueLabel;
  196. oflabel:=current_procinfo.CurrFalseLabel;
  197. current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
  198. current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
  199. secondpass(left);
  200. (*
  201. { save regvars loaded in the beginning so that we can restore them }
  202. { when processing the else-block }
  203. if cs_opt_regvar in current_settings.optimizerswitches then
  204. begin
  205. org_list := current_asmdata.CurrAsmList;
  206. current_asmdata.CurrAsmList := TAsmList.create;
  207. end;
  208. *)
  209. maketojumpbool(current_asmdata.CurrAsmList,left,lr_dont_load_regvars);
  210. (*
  211. if cs_opt_regvar in current_settings.optimizerswitches then
  212. begin
  213. org_regvar_loaded_int := rg.regvar_loaded_int;
  214. org_regvar_loaded_other := rg.regvar_loaded_other;
  215. end;
  216. *)
  217. { determines registers weigths }
  218. oldexecutionweight:=cg.executionweight;
  219. cg.executionweight:=cg.executionweight div 2;
  220. if cg.executionweight<1 then
  221. cg.executionweight:=1;
  222. if assigned(right) then
  223. begin
  224. cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
  225. secondpass(right);
  226. end;
  227. { save current asmlist (previous instructions + then-block) and }
  228. { loaded regvar state and create new clean ones }
  229. {
  230. if cs_opt_regvar in current_settings.optimizerswitches then
  231. begin
  232. then_regvar_loaded_int := rg.regvar_loaded_int;
  233. then_regvar_loaded_other := rg.regvar_loaded_other;
  234. rg.regvar_loaded_int := org_regvar_loaded_int;
  235. rg.regvar_loaded_other := org_regvar_loaded_other;
  236. then_list := current_asmdata.CurrAsmList;
  237. current_asmdata.CurrAsmList := TAsmList.create;
  238. end;
  239. }
  240. if assigned(t1) then
  241. begin
  242. if assigned(right) then
  243. begin
  244. current_asmdata.getjumplabel(hl);
  245. { do go back to if line !! }
  246. (*
  247. if not(cs_opt_regvar in current_settings.optimizerswitches) then
  248. *)
  249. current_filepos:=current_asmdata.CurrAsmList.getlasttaifilepos^
  250. (*
  251. else
  252. current_filepos:=then_list.getlasttaifilepos^
  253. *)
  254. ;
  255. cg.a_jmp_always(current_asmdata.CurrAsmList,hl);
  256. end;
  257. cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
  258. secondpass(t1);
  259. (*
  260. { save current asmlist (previous instructions + else-block) }
  261. { and loaded regvar state and create a new clean list }
  262. if cs_opt_regvar in current_settings.optimizerswitches then
  263. begin
  264. { else_regvar_loaded_int := rg.regvar_loaded_int;
  265. else_regvar_loaded_other := rg.regvar_loaded_other;}
  266. else_list := current_asmdata.CurrAsmList;
  267. current_asmdata.CurrAsmList := TAsmList.create;
  268. end;
  269. *)
  270. if assigned(right) then
  271. cg.a_label(current_asmdata.CurrAsmList,hl);
  272. end
  273. else
  274. begin
  275. (*
  276. if cs_opt_regvar in current_settings.optimizerswitches then
  277. begin
  278. { else_regvar_loaded_int := rg.regvar_loaded_int;
  279. else_regvar_loaded_other := rg.regvar_loaded_other;}
  280. else_list := current_asmdata.CurrAsmList;
  281. current_asmdata.CurrAsmList := TAsmList.create;
  282. end;
  283. *)
  284. cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
  285. end;
  286. if not(assigned(right)) then
  287. begin
  288. cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
  289. end;
  290. (*
  291. if cs_opt_regvar in current_settings.optimizerswitches then
  292. begin
  293. { add loads of regvars at the end of the then- and else-blocks }
  294. { so that at the end of both blocks the same regvars are loaded }
  295. { no else block? }
  296. if not assigned(t1) then
  297. begin
  298. sync_regvars_int(org_list,then_list,org_regvar_loaded_int,then_regvar_loaded_int);
  299. sync_regvars_other(org_list,then_list,org_regvar_loaded_other,then_regvar_loaded_other);
  300. end
  301. { no then block? }
  302. else if not assigned(right) then
  303. begin
  304. sync_regvars_int(org_list,else_list,org_regvar_loaded_int,else_regvar_loaded_int);
  305. sync_regvars_other(org_list,else_list,org_regvar_loaded_other,else_regvar_loaded_other);
  306. end
  307. { both else and then blocks }
  308. else
  309. begin
  310. sync_regvars_int(then_list,else_list,then_regvar_loaded_int,else_regvar_loaded_int);
  311. sync_regvars_other(then_list,else_list,then_regvar_loaded_other,else_regvar_loaded_other);
  312. end;
  313. { add all lists together }
  314. org_list.concatlist(then_list);
  315. then_list.free;
  316. org_list.concatlist(else_list);
  317. else_list.free;
  318. org_list.concatlist(current_asmdata.CurrAsmList);
  319. current_asmdata.CurrAsmList.free;
  320. current_asmdata.CurrAsmList := org_list;
  321. end;
  322. *)
  323. cg.executionweight:=oldexecutionweight;
  324. current_procinfo.CurrTrueLabel:=otlabel;
  325. current_procinfo.CurrFalseLabel:=oflabel;
  326. flowcontrol := oldflowcontrol + (flowcontrol - [fc_inflowcontrol]);
  327. end;
  328. {*****************************************************************************
  329. SecondFor
  330. *****************************************************************************}
  331. procedure tcgfornode.sync_regvars(checkusedregvars: boolean);
  332. begin
  333. if (cs_opt_regvar in current_settings.optimizerswitches) and
  334. not(pi_has_goto in current_procinfo.flags) then
  335. begin
  336. if checkusedregvars then
  337. begin
  338. usedregvars.intregvars.init;
  339. usedregvars.fpuregvars.init;
  340. usedregvars.mmregvars.init;
  341. { We have to synchronise the loop variable and loop body. }
  342. { The loop end is not necessary, unless it's a register }
  343. { variable. The start value also doesn't matter. }
  344. { loop var }
  345. get_used_regvars(right,usedregvars);
  346. { loop body }
  347. get_used_regvars(t2,usedregvars);
  348. { end value (t1) is not necessary (it cannot be a regvar, }
  349. { see webtbs/tw8883) }
  350. gen_sync_regvars(current_asmdata.CurrAsmList,usedregvars);
  351. end
  352. else
  353. begin
  354. gen_sync_regvars(current_asmdata.CurrAsmList,usedregvars);
  355. usedregvars.intregvars.done;
  356. usedregvars.fpuregvars.done;
  357. usedregvars.mmregvars.done;
  358. end;
  359. end;
  360. end;
  361. procedure tcgfornode.pass_generate_code;
  362. var
  363. l3,oldclabel,oldblabel : tasmlabel;
  364. temptovalue : boolean;
  365. hop : topcg;
  366. hcond : topcmp;
  367. opsize : tcgsize;
  368. count_var_is_signed,do_loopvar_at_end : boolean;
  369. cmp_const:Tconstexprint;
  370. oldflowcontrol : tflowcontrol;
  371. oldexecutionweight : longint;
  372. begin
  373. location_reset(location,LOC_VOID,OS_NO);
  374. oldclabel:=current_procinfo.CurrContinueLabel;
  375. oldblabel:=current_procinfo.CurrBreakLabel;
  376. current_asmdata.getjumplabel(current_procinfo.CurrContinueLabel);
  377. current_asmdata.getjumplabel(current_procinfo.CurrBreakLabel);
  378. current_asmdata.getjumplabel(l3);
  379. { only calculate reference }
  380. opsize := def_cgsize(left.resultdef);
  381. count_var_is_signed:=is_signed(left.resultdef);
  382. { first set the to value
  383. because the count var can be in the expression ! }
  384. do_loopvar_at_end:=(lnf_dont_mind_loopvar_on_exit in loopflags)
  385. { if the loop is unrolled and there is a jump into the loop,
  386. then we can't do the trick with incrementing the loop var only at the
  387. end
  388. }
  389. and not(assigned(entrylabel));
  390. secondpass(t1);
  391. { calculate pointer value and check if changeable and if so }
  392. { load into temporary variable }
  393. if t1.nodetype<>ordconstn then
  394. begin
  395. do_loopvar_at_end:=false;
  396. location_force_reg(current_asmdata.CurrAsmList,t1.location,t1.location.size,false);
  397. temptovalue:=true;
  398. end
  399. else
  400. temptovalue:=false;
  401. { load loopvar, prefer loopvar being a register variable }
  402. oldexecutionweight:=cg.executionweight;
  403. inc(cg.executionweight,8);
  404. secondpass(left);
  405. cg.executionweight:=oldexecutionweight;
  406. { load from value }
  407. secondpass(right);
  408. maybechangeloadnodereg(current_asmdata.CurrAsmList,left,false);
  409. oldflowcontrol:=flowcontrol;
  410. include(flowcontrol,fc_inflowcontrol);
  411. { produce start assignment }
  412. case left.location.loc of
  413. LOC_REFERENCE,
  414. LOC_CREFERENCE :
  415. cg.a_load_loc_ref(current_asmdata.CurrAsmList,left.location.size,right.location,left.location.reference);
  416. LOC_REGISTER,
  417. LOC_CREGISTER:
  418. cg.a_load_loc_reg(current_asmdata.CurrAsmList,left.location.size,right.location,left.location.register);
  419. LOC_SUBSETREG,
  420. LOC_CSUBSETREG :
  421. cg.a_load_loc_subsetreg(current_asmdata.CurrAsmList,left.location.size,right.location,left.location.sreg);
  422. else
  423. internalerror(200501311);
  424. end;
  425. if lnf_backward in loopflags then
  426. if count_var_is_signed then
  427. hcond:=OC_LT
  428. else
  429. hcond:=OC_B
  430. else
  431. if count_var_is_signed then
  432. hcond:=OC_GT
  433. else
  434. hcond:=OC_A;
  435. sync_regvars(true);
  436. {$ifdef OLDREGVARS}
  437. load_all_regvars(current_asmdata.CurrAsmList);
  438. {$endif OLDREGVARS}
  439. if temptovalue then
  440. begin
  441. cg.a_cmp_reg_loc_label(current_asmdata.CurrAsmList,opsize,hcond,
  442. t1.location.register,left.location,current_procinfo.CurrBreakLabel);
  443. end
  444. else
  445. begin
  446. if lnf_testatbegin in loopflags then
  447. begin
  448. cg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,opsize,hcond,
  449. tordconstnode(t1).value.svalue,
  450. left.location,current_procinfo.CurrBreakLabel);
  451. end;
  452. end;
  453. {If the loopvar doesn't mind on exit, we avoid this ugly
  454. dec instruction and do the loopvar inc/dec after the loop
  455. body.}
  456. if not do_loopvar_at_end then
  457. begin
  458. if lnf_backward in loopflags then
  459. hop:=OP_ADD
  460. else
  461. hop:=OP_SUB;
  462. cg.a_op_const_loc(current_asmdata.CurrAsmList,hop,1,left.location);
  463. end;
  464. if assigned(entrylabel) then
  465. cg.a_jmp_always(current_asmdata.CurrAsmList,tcglabelnode(entrylabel).getasmlabel);
  466. { align loop target }
  467. if not(cs_opt_size in current_settings.optimizerswitches) then
  468. current_asmdata.CurrAsmList.concat(Tai_align.Create(current_settings.alignment.loopalign));
  469. cg.a_label(current_asmdata.CurrAsmList,l3);
  470. {If the loopvar doesn't mind on exit, we avoid the loopvar inc/dec
  471. after the loop body instead of here.}
  472. if not do_loopvar_at_end then
  473. begin
  474. { according to count direction DEC or INC... }
  475. if lnf_backward in loopflags then
  476. hop:=OP_SUB
  477. else
  478. hop:=OP_ADD;
  479. cg.a_op_const_loc(current_asmdata.CurrAsmList,hop,1,left.location);
  480. end;
  481. if assigned(t2) then
  482. begin
  483. { Calc register weight }
  484. oldexecutionweight:=cg.executionweight;
  485. cg.executionweight:=cg.executionweight*8;
  486. secondpass(t2);
  487. cg.executionweight:=oldexecutionweight;
  488. {$ifdef OLDREGVARS}
  489. load_all_regvars(current_asmdata.CurrAsmList);
  490. {$endif OLDREGVARS}
  491. end;
  492. {If the loopvar doesn't mind on exit, we do the loopvar inc/dec
  493. after the loop body instead of here.}
  494. if do_loopvar_at_end then
  495. begin
  496. { according to count direction DEC or INC... }
  497. if lnf_backward in loopflags then
  498. hop:=OP_SUB
  499. else
  500. hop:=OP_ADD;
  501. cg.a_op_const_loc(current_asmdata.CurrAsmList,hop,1,left.location);
  502. end;
  503. cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrContinueLabel);
  504. if do_loopvar_at_end then
  505. if lnf_backward in loopflags then
  506. if count_var_is_signed then
  507. hcond:=OC_GTE
  508. else
  509. hcond:=OC_AE
  510. else
  511. if count_var_is_signed then
  512. hcond:=OC_LTE
  513. else
  514. hcond:=OC_BE
  515. else
  516. if lnf_backward in loopflags then
  517. if count_var_is_signed then
  518. hcond:=OC_GT
  519. else
  520. hcond:=OC_A
  521. else
  522. if count_var_is_signed then
  523. hcond:=OC_LT
  524. else
  525. hcond:=OC_B;
  526. {$ifdef OLDREGVARS}
  527. load_all_regvars(current_asmdata.CurrAsmList);
  528. {$endif OLDREGVARS}
  529. { produce comparison and the corresponding }
  530. { jump }
  531. if temptovalue then
  532. begin
  533. cg.a_cmp_reg_loc_label(current_asmdata.CurrAsmList,opsize,hcond,t1.location.register,
  534. left.location,l3);
  535. end
  536. else
  537. begin
  538. cmp_const:=Tordconstnode(t1).value;
  539. if do_loopvar_at_end then
  540. begin
  541. {Watch out for wrap around 255 -> 0.}
  542. {Ugly: This code is way to long... Use tables?}
  543. case opsize of
  544. OS_8:
  545. begin
  546. if lnf_backward in loopflags then
  547. begin
  548. if byte(cmp_const.svalue)=low(byte) then
  549. begin
  550. hcond:=OC_NE;
  551. cmp_const:=high(byte);
  552. end
  553. end
  554. else
  555. begin
  556. if byte(cmp_const.svalue)=high(byte) then
  557. begin
  558. hcond:=OC_NE;
  559. cmp_const:=low(byte);
  560. end
  561. end
  562. end;
  563. OS_16:
  564. begin
  565. if lnf_backward in loopflags then
  566. begin
  567. if word(cmp_const.svalue)=high(word) then
  568. begin
  569. hcond:=OC_NE;
  570. cmp_const:=low(word);
  571. end
  572. end
  573. else
  574. begin
  575. if word(cmp_const.svalue)=low(word) then
  576. begin
  577. hcond:=OC_NE;
  578. cmp_const:=high(word);
  579. end
  580. end
  581. end;
  582. OS_32:
  583. begin
  584. if lnf_backward in loopflags then
  585. begin
  586. if cardinal(cmp_const.svalue)=high(cardinal) then
  587. begin
  588. hcond:=OC_NE;
  589. cmp_const:=low(cardinal);
  590. end
  591. end
  592. else
  593. begin
  594. if cardinal(cmp_const.svalue)=low(cardinal) then
  595. begin
  596. hcond:=OC_NE;
  597. cmp_const:=high(cardinal);
  598. end
  599. end
  600. end;
  601. OS_64:
  602. begin
  603. if lnf_backward in loopflags then
  604. begin
  605. if qword(cmp_const.uvalue)=high(qword) then
  606. begin
  607. hcond:=OC_NE;
  608. cmp_const:=low(qword);
  609. end
  610. end
  611. else
  612. begin
  613. if qword(cmp_const.uvalue)=low(qword) then
  614. begin
  615. hcond:=OC_NE;
  616. cmp_const:=high(qword);
  617. end
  618. end
  619. end;
  620. OS_S8:
  621. begin
  622. if lnf_backward in loopflags then
  623. begin
  624. if shortint(cmp_const.svalue)=low(shortint) then
  625. begin
  626. hcond:=OC_NE;
  627. cmp_const:=high(shortint);
  628. end
  629. end
  630. else
  631. begin
  632. if shortint(cmp_const.svalue)=high(shortint) then
  633. begin
  634. hcond:=OC_NE;
  635. cmp_const:=int64(low(shortint));
  636. end
  637. end
  638. end;
  639. OS_S16:
  640. begin
  641. if lnf_backward in loopflags then
  642. begin
  643. if integer(cmp_const.svalue)=high(smallint) then
  644. begin
  645. hcond:=OC_NE;
  646. cmp_const:=int64(low(smallint));
  647. end
  648. end
  649. else
  650. begin
  651. if integer(cmp_const.svalue)=low(smallint) then
  652. begin
  653. hcond:=OC_NE;
  654. cmp_const:=int64(high(smallint));
  655. end
  656. end
  657. end;
  658. OS_S32:
  659. begin
  660. if lnf_backward in loopflags then
  661. begin
  662. if longint(cmp_const.svalue)=high(longint) then
  663. begin
  664. hcond:=OC_NE;
  665. cmp_const:=int64(low(longint));
  666. end
  667. end
  668. else
  669. begin
  670. if longint(cmp_const.svalue)=low(longint) then
  671. begin
  672. hcond:=OC_NE;
  673. cmp_const:=int64(high(longint));
  674. end
  675. end
  676. end;
  677. OS_S64:
  678. begin
  679. if lnf_backward in loopflags then
  680. begin
  681. if int64(cmp_const.svalue)=high(int64) then
  682. begin
  683. hcond:=OC_NE;
  684. cmp_const:=low(int64);
  685. end
  686. end
  687. else
  688. begin
  689. if int64(cmp_const.svalue)=low(int64) then
  690. begin
  691. hcond:=OC_NE;
  692. cmp_const:=high(int64);
  693. end
  694. end
  695. end;
  696. else
  697. internalerror(200201021);
  698. end;
  699. end;
  700. cg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,opsize,hcond,
  701. aint(cmp_const.svalue),left.location,l3);
  702. end;
  703. { this is the break label: }
  704. cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrBreakLabel);
  705. sync_regvars(false);
  706. current_procinfo.CurrContinueLabel:=oldclabel;
  707. current_procinfo.CurrBreakLabel:=oldblabel;
  708. { a break/continue in a while/repeat block can't be seen outside }
  709. flowcontrol:=oldflowcontrol+(flowcontrol-[fc_break,fc_continue,fc_inflowcontrol]);
  710. end;
  711. {*****************************************************************************
  712. SecondExitN
  713. *****************************************************************************}
  714. procedure tcgexitnode.pass_generate_code;
  715. begin
  716. location_reset(location,LOC_VOID,OS_NO);
  717. include(flowcontrol,fc_exit);
  718. if assigned(left) then
  719. secondpass(left);
  720. cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrExitLabel);
  721. end;
  722. {*****************************************************************************
  723. SecondBreakN
  724. *****************************************************************************}
  725. procedure tcgbreaknode.pass_generate_code;
  726. begin
  727. location_reset(location,LOC_VOID,OS_NO);
  728. include(flowcontrol,fc_break);
  729. if current_procinfo.CurrBreakLabel<>nil then
  730. begin
  731. {$ifdef OLDREGVARS}
  732. load_all_regvars(current_asmdata.CurrAsmList);
  733. {$endif OLDREGVARS}
  734. cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrBreakLabel)
  735. end
  736. else
  737. CGMessage(cg_e_break_not_allowed);
  738. end;
  739. {*****************************************************************************
  740. SecondContinueN
  741. *****************************************************************************}
  742. procedure tcgcontinuenode.pass_generate_code;
  743. begin
  744. location_reset(location,LOC_VOID,OS_NO);
  745. include(flowcontrol,fc_continue);
  746. if current_procinfo.CurrContinueLabel<>nil then
  747. begin
  748. {$ifdef OLDREGVARS}
  749. load_all_regvars(current_asmdata.CurrAsmList);
  750. {$endif OLDREGVARS}
  751. cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrContinueLabel)
  752. end
  753. else
  754. CGMessage(cg_e_continue_not_allowed);
  755. end;
  756. {*****************************************************************************
  757. SecondGoto
  758. *****************************************************************************}
  759. procedure tcggotonode.pass_generate_code;
  760. begin
  761. location_reset(location,LOC_VOID,OS_NO);
  762. include(flowcontrol,fc_gotolabel);
  763. {$ifdef OLDREGVARS}
  764. load_all_regvars(current_asmdata.CurrAsmList);
  765. {$endif OLDREGVARS}
  766. cg.a_jmp_always(current_asmdata.CurrAsmList,tcglabelnode(labelnode).getasmlabel)
  767. end;
  768. {*****************************************************************************
  769. SecondLabel
  770. *****************************************************************************}
  771. function tcglabelnode.getasmlabel : tasmlabel;
  772. begin
  773. if not(assigned(asmlabel)) then
  774. { labsym is not set in inlined procedures, but since assembler }
  775. { routines can't be inlined, that shouldn't matter }
  776. if assigned(labsym) and
  777. labsym.nonlocal then
  778. current_asmdata.getglobaljumplabel(asmlabel)
  779. else
  780. current_asmdata.getjumplabel(asmlabel);
  781. result:=asmlabel
  782. end;
  783. procedure tcglabelnode.pass_generate_code;
  784. begin
  785. location_reset(location,LOC_VOID,OS_NO);
  786. include(flowcontrol,fc_gotolabel);
  787. {$ifdef OLDREGVARS}
  788. load_all_regvars(current_asmdata.CurrAsmList);
  789. {$endif OLDREGVARS}
  790. cg.a_label(current_asmdata.CurrAsmList,getasmlabel);
  791. { Write also extra label if this label was referenced from
  792. assembler block }
  793. if assigned(labsym) and
  794. assigned(labsym.asmblocklabel) then
  795. cg.a_label(current_asmdata.CurrAsmList,labsym.asmblocklabel);
  796. secondpass(left);
  797. end;
  798. {*****************************************************************************
  799. SecondRaise
  800. *****************************************************************************}
  801. procedure tcgraisenode.pass_generate_code;
  802. var
  803. a : tasmlabel;
  804. href2: treference;
  805. paraloc1,paraloc2,paraloc3 : tcgpara;
  806. begin
  807. paraloc1.init;
  808. paraloc2.init;
  809. paraloc3.init;
  810. paramanager.getintparaloc(pocall_default,1,paraloc1);
  811. paramanager.getintparaloc(pocall_default,2,paraloc2);
  812. paramanager.getintparaloc(pocall_default,3,paraloc3);
  813. location_reset(location,LOC_VOID,OS_NO);
  814. if assigned(left) then
  815. begin
  816. { multiple parameters? }
  817. if assigned(right) then
  818. begin
  819. { frame tree }
  820. if assigned(third) then
  821. secondpass(third);
  822. secondpass(right);
  823. end;
  824. secondpass(left);
  825. if codegenerror then
  826. exit;
  827. { Push parameters }
  828. if assigned(right) then
  829. begin
  830. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc3);
  831. { frame tree }
  832. if assigned(third) then
  833. cg.a_param_loc(current_asmdata.CurrAsmList,third.location,paraloc3)
  834. else
  835. cg.a_param_const(current_asmdata.CurrAsmList,OS_INT,0,paraloc3);
  836. { push address }
  837. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc2);
  838. cg.a_param_loc(current_asmdata.CurrAsmList,right.location,paraloc2);
  839. end
  840. else
  841. begin
  842. { get current address }
  843. current_asmdata.getaddrlabel(a);
  844. cg.a_label(current_asmdata.CurrAsmList,a);
  845. reference_reset_symbol(href2,a,0,1);
  846. { push current frame }
  847. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc3);
  848. cg.a_param_reg(current_asmdata.CurrAsmList,OS_ADDR,NR_FRAME_POINTER_REG,paraloc3);
  849. { push current address }
  850. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc2);
  851. if target_info.system <> system_powerpc_macos then
  852. cg.a_paramaddr_ref(current_asmdata.CurrAsmList,href2,paraloc2)
  853. else
  854. cg.a_param_const(current_asmdata.CurrAsmList,OS_INT,0,paraloc2);
  855. end;
  856. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc1);
  857. cg.a_param_loc(current_asmdata.CurrAsmList,left.location,paraloc1);
  858. paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc1);
  859. paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc2);
  860. paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc3);
  861. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  862. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_RAISEEXCEPTION',false);
  863. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  864. end
  865. else
  866. begin
  867. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  868. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_POPADDRSTACK',false);
  869. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_RERAISE',false);
  870. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  871. end;
  872. paraloc1.done;
  873. paraloc2.done;
  874. paraloc3.done;
  875. end;
  876. {*****************************************************************************
  877. SecondTryExcept
  878. *****************************************************************************}
  879. var
  880. endexceptlabel : tasmlabel;
  881. { does the necessary things to clean up the object stack }
  882. { in the except block }
  883. procedure cleanupobjectstack;
  884. var
  885. paraloc1 : tcgpara;
  886. begin
  887. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  888. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_POPOBJECTSTACK',false);
  889. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  890. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  891. paraloc1.init;
  892. paramanager.getintparaloc(pocall_default,1,paraloc1);
  893. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc1);
  894. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  895. cg.a_param_reg(current_asmdata.CurrAsmList,OS_ADDR,NR_FUNCTION_RESULT_REG,paraloc1);
  896. paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc1);
  897. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  898. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_DESTROYEXCEPTION',false);
  899. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  900. paraloc1.done;
  901. end;
  902. procedure tcgtryexceptnode.pass_generate_code;
  903. var
  904. exceptlabel,doexceptlabel,oldendexceptlabel,
  905. lastonlabel,
  906. exitexceptlabel,
  907. continueexceptlabel,
  908. breakexceptlabel,
  909. exittrylabel,
  910. continuetrylabel,
  911. breaktrylabel,
  912. doobjectdestroy,
  913. doobjectdestroyandreraise,
  914. oldCurrExitLabel,
  915. oldContinueLabel,
  916. oldBreakLabel : tasmlabel;
  917. oldflowcontrol,tryflowcontrol,
  918. exceptflowcontrol : tflowcontrol;
  919. destroytemps,
  920. excepttemps : texceptiontemps;
  921. paraloc1 : tcgpara;
  922. label
  923. errorexit;
  924. begin
  925. location_reset(location,LOC_VOID,OS_NO);
  926. oldflowcontrol:=flowcontrol;
  927. flowcontrol:=[fc_inflowcontrol];
  928. { this can be called recursivly }
  929. oldBreakLabel:=nil;
  930. oldContinueLabel:=nil;
  931. oldendexceptlabel:=endexceptlabel;
  932. { save the old labels for control flow statements }
  933. oldCurrExitLabel:=current_procinfo.CurrExitLabel;
  934. if assigned(current_procinfo.CurrBreakLabel) then
  935. begin
  936. oldContinueLabel:=current_procinfo.CurrContinueLabel;
  937. oldBreakLabel:=current_procinfo.CurrBreakLabel;
  938. end;
  939. { get new labels for the control flow statements }
  940. current_asmdata.getjumplabel(exittrylabel);
  941. current_asmdata.getjumplabel(exitexceptlabel);
  942. if assigned(current_procinfo.CurrBreakLabel) then
  943. begin
  944. current_asmdata.getjumplabel(breaktrylabel);
  945. current_asmdata.getjumplabel(continuetrylabel);
  946. current_asmdata.getjumplabel(breakexceptlabel);
  947. current_asmdata.getjumplabel(continueexceptlabel);
  948. end;
  949. current_asmdata.getjumplabel(exceptlabel);
  950. current_asmdata.getjumplabel(doexceptlabel);
  951. current_asmdata.getjumplabel(endexceptlabel);
  952. current_asmdata.getjumplabel(lastonlabel);
  953. get_exception_temps(current_asmdata.CurrAsmList,excepttemps);
  954. new_exception(current_asmdata.CurrAsmList,excepttemps,exceptlabel);
  955. { try block }
  956. { set control flow labels for the try block }
  957. current_procinfo.CurrExitLabel:=exittrylabel;
  958. if assigned(oldBreakLabel) then
  959. begin
  960. current_procinfo.CurrContinueLabel:=continuetrylabel;
  961. current_procinfo.CurrBreakLabel:=breaktrylabel;
  962. end;
  963. flowcontrol:=[fc_inflowcontrol];
  964. secondpass(left);
  965. tryflowcontrol:=flowcontrol;
  966. if codegenerror then
  967. goto errorexit;
  968. cg.a_label(current_asmdata.CurrAsmList,exceptlabel);
  969. free_exception(current_asmdata.CurrAsmList, excepttemps, 0, endexceptlabel, false);
  970. cg.a_label(current_asmdata.CurrAsmList,doexceptlabel);
  971. { set control flow labels for the except block }
  972. { and the on statements }
  973. current_procinfo.CurrExitLabel:=exitexceptlabel;
  974. if assigned(oldBreakLabel) then
  975. begin
  976. current_procinfo.CurrContinueLabel:=continueexceptlabel;
  977. current_procinfo.CurrBreakLabel:=breakexceptlabel;
  978. end;
  979. flowcontrol:=[fc_inflowcontrol];
  980. { on statements }
  981. if assigned(right) then
  982. secondpass(right);
  983. cg.a_label(current_asmdata.CurrAsmList,lastonlabel);
  984. { default handling except handling }
  985. if assigned(t1) then
  986. begin
  987. { FPC_CATCHES must be called with
  988. 'default handler' flag (=-1)
  989. }
  990. paraloc1.init;
  991. paramanager.getintparaloc(pocall_default,1,paraloc1);
  992. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc1);
  993. cg.a_param_const(current_asmdata.CurrAsmList,OS_ADDR,-1,paraloc1);
  994. paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc1);
  995. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  996. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_CATCHES',false);
  997. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  998. paraloc1.done;
  999. { the destruction of the exception object must be also }
  1000. { guarded by an exception frame }
  1001. current_asmdata.getjumplabel(doobjectdestroy);
  1002. current_asmdata.getjumplabel(doobjectdestroyandreraise);
  1003. get_exception_temps(current_asmdata.CurrAsmList,destroytemps);
  1004. new_exception(current_asmdata.CurrAsmList,destroytemps,doobjectdestroyandreraise);
  1005. { here we don't have to reset flowcontrol }
  1006. { the default and on flowcontrols are handled equal }
  1007. secondpass(t1);
  1008. exceptflowcontrol:=flowcontrol;
  1009. cg.a_label(current_asmdata.CurrAsmList,doobjectdestroyandreraise);
  1010. free_exception(current_asmdata.CurrAsmList,destroytemps,0,doobjectdestroy,false);
  1011. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  1012. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_POPSECONDOBJECTSTACK',false);
  1013. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  1014. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1015. paraloc1.init;
  1016. paramanager.getintparaloc(pocall_default,1,paraloc1);
  1017. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1018. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc1);
  1019. cg.a_param_reg(current_asmdata.CurrAsmList, OS_ADDR, NR_FUNCTION_RESULT_REG, paraloc1);
  1020. paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc1);
  1021. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  1022. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_DESTROYEXCEPTION',false);
  1023. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  1024. paraloc1.done;
  1025. { we don't need to restore esi here because reraise never }
  1026. { returns }
  1027. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_RERAISE',false);
  1028. cg.a_label(current_asmdata.CurrAsmList,doobjectdestroy);
  1029. cleanupobjectstack;
  1030. unget_exception_temps(current_asmdata.CurrAsmList,destroytemps);
  1031. cg.a_jmp_always(current_asmdata.CurrAsmList,endexceptlabel);
  1032. end
  1033. else
  1034. begin
  1035. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_RERAISE',false);
  1036. exceptflowcontrol:=flowcontrol;
  1037. end;
  1038. if fc_exit in exceptflowcontrol then
  1039. begin
  1040. { do some magic for exit in the try block }
  1041. cg.a_label(current_asmdata.CurrAsmList,exitexceptlabel);
  1042. { we must also destroy the address frame which guards }
  1043. { exception object }
  1044. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  1045. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_POPADDRSTACK',false);
  1046. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  1047. cg.g_exception_reason_load(current_asmdata.CurrAsmList,excepttemps.reasonbuf);
  1048. cleanupobjectstack;
  1049. cg.a_jmp_always(current_asmdata.CurrAsmList,oldCurrExitLabel);
  1050. { from g_exception_reason_load }
  1051. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1052. end;
  1053. if fc_break in exceptflowcontrol then
  1054. begin
  1055. cg.a_label(current_asmdata.CurrAsmList,breakexceptlabel);
  1056. { we must also destroy the address frame which guards }
  1057. { exception object }
  1058. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  1059. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_POPADDRSTACK',false);
  1060. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  1061. cg.g_exception_reason_load(current_asmdata.CurrAsmList,excepttemps.reasonbuf);
  1062. cleanupobjectstack;
  1063. cg.a_jmp_always(current_asmdata.CurrAsmList,oldBreakLabel);
  1064. { from g_exception_reason_load }
  1065. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1066. end;
  1067. if fc_continue in exceptflowcontrol then
  1068. begin
  1069. cg.a_label(current_asmdata.CurrAsmList,continueexceptlabel);
  1070. { we must also destroy the address frame which guards }
  1071. { exception object }
  1072. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  1073. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_POPADDRSTACK',false);
  1074. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  1075. cg.g_exception_reason_load(current_asmdata.CurrAsmList,excepttemps.reasonbuf);
  1076. cleanupobjectstack;
  1077. cg.a_jmp_always(current_asmdata.CurrAsmList,oldContinueLabel);
  1078. { from g_exception_reason_load }
  1079. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1080. end;
  1081. if fc_exit in tryflowcontrol then
  1082. begin
  1083. { do some magic for exit in the try block }
  1084. cg.a_label(current_asmdata.CurrAsmList,exittrylabel);
  1085. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  1086. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_POPADDRSTACK',false);
  1087. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  1088. cg.g_exception_reason_load(current_asmdata.CurrAsmList,excepttemps.reasonbuf);
  1089. cg.a_jmp_always(current_asmdata.CurrAsmList,oldCurrExitLabel);
  1090. { from g_exception_reason_load }
  1091. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1092. end;
  1093. if fc_break in tryflowcontrol then
  1094. begin
  1095. cg.a_label(current_asmdata.CurrAsmList,breaktrylabel);
  1096. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  1097. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_POPADDRSTACK',false);
  1098. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  1099. cg.g_exception_reason_load(current_asmdata.CurrAsmList,excepttemps.reasonbuf);
  1100. cg.a_jmp_always(current_asmdata.CurrAsmList,oldBreakLabel);
  1101. { from g_exception_reason_load }
  1102. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1103. end;
  1104. if fc_continue in tryflowcontrol then
  1105. begin
  1106. cg.a_label(current_asmdata.CurrAsmList,continuetrylabel);
  1107. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  1108. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_POPADDRSTACK',false);
  1109. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  1110. cg.g_exception_reason_load(current_asmdata.CurrAsmList,excepttemps.reasonbuf);
  1111. cg.a_jmp_always(current_asmdata.CurrAsmList,oldContinueLabel);
  1112. { from g_exception_reason_load }
  1113. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1114. end;
  1115. unget_exception_temps(current_asmdata.CurrAsmList,excepttemps);
  1116. cg.a_label(current_asmdata.CurrAsmList,endexceptlabel);
  1117. errorexit:
  1118. { restore all saved labels }
  1119. endexceptlabel:=oldendexceptlabel;
  1120. { restore the control flow labels }
  1121. current_procinfo.CurrExitLabel:=oldCurrExitLabel;
  1122. if assigned(oldBreakLabel) then
  1123. begin
  1124. current_procinfo.CurrContinueLabel:=oldContinueLabel;
  1125. current_procinfo.CurrBreakLabel:=oldBreakLabel;
  1126. end;
  1127. { return all used control flow statements }
  1128. flowcontrol:=oldflowcontrol+(exceptflowcontrol +
  1129. tryflowcontrol - [fc_inflowcontrol]);
  1130. end;
  1131. procedure tcgonnode.pass_generate_code;
  1132. var
  1133. nextonlabel,
  1134. exitonlabel,
  1135. continueonlabel,
  1136. breakonlabel,
  1137. oldCurrExitLabel,
  1138. oldContinueLabel,
  1139. doobjectdestroyandreraise,
  1140. doobjectdestroy,
  1141. oldBreakLabel : tasmlabel;
  1142. oldflowcontrol : tflowcontrol;
  1143. excepttemps : texceptiontemps;
  1144. exceptref,
  1145. href2: treference;
  1146. paraloc1 : tcgpara;
  1147. exceptvarsym : tlocalvarsym;
  1148. begin
  1149. paraloc1.init;
  1150. location_reset(location,LOC_VOID,OS_NO);
  1151. oldflowcontrol:=flowcontrol;
  1152. flowcontrol:=[fc_inflowcontrol];
  1153. current_asmdata.getjumplabel(nextonlabel);
  1154. { send the vmt parameter }
  1155. reference_reset_symbol(href2,current_asmdata.RefAsmSymbol(excepttype.vmt_mangledname),0,sizeof(pint));
  1156. paramanager.getintparaloc(pocall_default,1,paraloc1);
  1157. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc1);
  1158. cg.a_paramaddr_ref(current_asmdata.CurrAsmList,href2,paraloc1);
  1159. paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc1);
  1160. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  1161. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_CATCHES',false);
  1162. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  1163. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1164. { is it this catch? No. go to next onlabel }
  1165. cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_ADDR,OC_EQ,0,NR_FUNCTION_RESULT_REG,nextonlabel);
  1166. { Retrieve exception variable }
  1167. if assigned(excepTSymtable) then
  1168. exceptvarsym:=tlocalvarsym(excepTSymtable.SymList[0])
  1169. else
  1170. exceptvarsym:=nil;
  1171. if assigned(exceptvarsym) then
  1172. begin
  1173. exceptvarsym.localloc.loc:=LOC_REFERENCE;
  1174. exceptvarsym.localloc.size:=OS_ADDR;
  1175. tg.GetLocal(current_asmdata.CurrAsmList,sizeof(pint),voidpointertype,exceptvarsym.localloc.reference);
  1176. cg.a_load_reg_ref(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,exceptvarsym.localloc.reference);
  1177. end
  1178. else
  1179. begin
  1180. tg.GetTemp(current_asmdata.CurrAsmList,sizeof(pint),sizeof(pint),tt_normal,exceptref);
  1181. cg.a_load_reg_ref(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,NR_FUNCTION_RESULT_REG,exceptref);
  1182. end;
  1183. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1184. { in the case that another exception is risen
  1185. we've to destroy the old one }
  1186. current_asmdata.getjumplabel(doobjectdestroyandreraise);
  1187. { call setjmp, and jump to finally label on non-zero result }
  1188. get_exception_temps(current_asmdata.CurrAsmList,excepttemps);
  1189. new_exception(current_asmdata.CurrAsmList,excepttemps,doobjectdestroyandreraise);
  1190. oldBreakLabel:=nil;
  1191. oldContinueLabel:=nil;
  1192. if assigned(right) then
  1193. begin
  1194. oldCurrExitLabel:=current_procinfo.CurrExitLabel;
  1195. current_asmdata.getjumplabel(exitonlabel);
  1196. current_procinfo.CurrExitLabel:=exitonlabel;
  1197. if assigned(current_procinfo.CurrBreakLabel) then
  1198. begin
  1199. oldContinueLabel:=current_procinfo.CurrContinueLabel;
  1200. oldBreakLabel:=current_procinfo.CurrBreakLabel;
  1201. current_asmdata.getjumplabel(breakonlabel);
  1202. current_asmdata.getjumplabel(continueonlabel);
  1203. current_procinfo.CurrContinueLabel:=continueonlabel;
  1204. current_procinfo.CurrBreakLabel:=breakonlabel;
  1205. end;
  1206. secondpass(right);
  1207. end;
  1208. current_asmdata.getjumplabel(doobjectdestroy);
  1209. cg.a_label(current_asmdata.CurrAsmList,doobjectdestroyandreraise);
  1210. free_exception(current_asmdata.CurrAsmList,excepttemps,0,doobjectdestroy,false);
  1211. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  1212. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_POPSECONDOBJECTSTACK',false);
  1213. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  1214. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1215. paramanager.getintparaloc(pocall_default,1,paraloc1);
  1216. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1217. paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc1);
  1218. cg.a_param_reg(current_asmdata.CurrAsmList, OS_ADDR, NR_FUNCTION_RESULT_REG, paraloc1);
  1219. paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc1);
  1220. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  1221. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_DESTROYEXCEPTION',false);
  1222. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  1223. { we don't need to store/restore registers here because reraise never
  1224. returns }
  1225. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_RERAISE',false);
  1226. cg.a_label(current_asmdata.CurrAsmList,doobjectdestroy);
  1227. cleanupobjectstack;
  1228. { clear some stuff }
  1229. if assigned(exceptvarsym) then
  1230. begin
  1231. tg.UngetLocal(current_asmdata.CurrAsmList,exceptvarsym.localloc.reference);
  1232. exceptvarsym.localloc.loc:=LOC_INVALID;
  1233. end
  1234. else
  1235. tg.Ungettemp(current_asmdata.CurrAsmList,exceptref);
  1236. cg.a_jmp_always(current_asmdata.CurrAsmList,endexceptlabel);
  1237. if assigned(right) then
  1238. begin
  1239. { special handling for control flow instructions }
  1240. if fc_exit in flowcontrol then
  1241. begin
  1242. { the address and object pop does secondtryexcept }
  1243. cg.a_label(current_asmdata.CurrAsmList,exitonlabel);
  1244. cg.a_jmp_always(current_asmdata.CurrAsmList,oldCurrExitLabel);
  1245. end;
  1246. if fc_break in flowcontrol then
  1247. begin
  1248. { the address and object pop does secondtryexcept }
  1249. cg.a_label(current_asmdata.CurrAsmList,breakonlabel);
  1250. cg.a_jmp_always(current_asmdata.CurrAsmList,oldBreakLabel);
  1251. end;
  1252. if fc_continue in flowcontrol then
  1253. begin
  1254. { the address and object pop does secondtryexcept }
  1255. cg.a_label(current_asmdata.CurrAsmList,continueonlabel);
  1256. cg.a_jmp_always(current_asmdata.CurrAsmList,oldContinueLabel);
  1257. end;
  1258. current_procinfo.CurrExitLabel:=oldCurrExitLabel;
  1259. if assigned(oldBreakLabel) then
  1260. begin
  1261. current_procinfo.CurrContinueLabel:=oldContinueLabel;
  1262. current_procinfo.CurrBreakLabel:=oldBreakLabel;
  1263. end;
  1264. end;
  1265. unget_exception_temps(current_asmdata.CurrAsmList,excepttemps);
  1266. cg.a_label(current_asmdata.CurrAsmList,nextonlabel);
  1267. flowcontrol:=oldflowcontrol+(flowcontrol-[fc_inflowcontrol]);
  1268. paraloc1.done;
  1269. { next on node }
  1270. if assigned(left) then
  1271. secondpass(left);
  1272. end;
  1273. {*****************************************************************************
  1274. SecondTryFinally
  1275. *****************************************************************************}
  1276. procedure tcgtryfinallynode.pass_generate_code;
  1277. var
  1278. reraiselabel,
  1279. finallylabel,
  1280. endfinallylabel,
  1281. exitfinallylabel,
  1282. continuefinallylabel,
  1283. breakfinallylabel,
  1284. oldCurrExitLabel,
  1285. oldContinueLabel,
  1286. oldBreakLabel : tasmlabel;
  1287. oldflowcontrol,tryflowcontrol : tflowcontrol;
  1288. decconst : longint;
  1289. excepttemps : texceptiontemps;
  1290. begin
  1291. location_reset(location,LOC_VOID,OS_NO);
  1292. { check if child nodes do a break/continue/exit }
  1293. oldflowcontrol:=flowcontrol;
  1294. flowcontrol:=[fc_inflowcontrol];
  1295. current_asmdata.getjumplabel(finallylabel);
  1296. current_asmdata.getjumplabel(endfinallylabel);
  1297. current_asmdata.getjumplabel(reraiselabel);
  1298. { the finally block must catch break, continue and exit }
  1299. { statements }
  1300. oldCurrExitLabel:=current_procinfo.CurrExitLabel;
  1301. if implicitframe then
  1302. exitfinallylabel:=finallylabel
  1303. else
  1304. current_asmdata.getjumplabel(exitfinallylabel);
  1305. current_procinfo.CurrExitLabel:=exitfinallylabel;
  1306. if assigned(current_procinfo.CurrBreakLabel) then
  1307. begin
  1308. oldContinueLabel:=current_procinfo.CurrContinueLabel;
  1309. oldBreakLabel:=current_procinfo.CurrBreakLabel;
  1310. if implicitframe then
  1311. begin
  1312. breakfinallylabel:=finallylabel;
  1313. continuefinallylabel:=finallylabel;
  1314. end
  1315. else
  1316. begin
  1317. current_asmdata.getjumplabel(breakfinallylabel);
  1318. current_asmdata.getjumplabel(continuefinallylabel);
  1319. end;
  1320. current_procinfo.CurrContinueLabel:=continuefinallylabel;
  1321. current_procinfo.CurrBreakLabel:=breakfinallylabel;
  1322. end;
  1323. { call setjmp, and jump to finally label on non-zero result }
  1324. get_exception_temps(current_asmdata.CurrAsmList,excepttemps);
  1325. new_exception(current_asmdata.CurrAsmList,excepttemps,finallylabel);
  1326. { try code }
  1327. if assigned(left) then
  1328. begin
  1329. secondpass(left);
  1330. tryflowcontrol:=flowcontrol;
  1331. if codegenerror then
  1332. exit;
  1333. end;
  1334. cg.a_label(current_asmdata.CurrAsmList,finallylabel);
  1335. { just free the frame information }
  1336. free_exception(current_asmdata.CurrAsmList,excepttemps,1,finallylabel,true);
  1337. { finally code }
  1338. flowcontrol:=[fc_inflowcontrol];
  1339. secondpass(right);
  1340. { goto is allowed if it stays inside the finally block,
  1341. this is checked using the exception block number }
  1342. if (flowcontrol-[fc_gotolabel])<>[fc_inflowcontrol] then
  1343. CGMessage(cg_e_control_flow_outside_finally);
  1344. if codegenerror then
  1345. exit;
  1346. { the value should now be in the exception handler }
  1347. cg.g_exception_reason_load(current_asmdata.CurrAsmList,excepttemps.reasonbuf);
  1348. if implicitframe then
  1349. begin
  1350. cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,endfinallylabel);
  1351. { from g_exception_reason_load }
  1352. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1353. { finally code only needed to be executed on exception }
  1354. flowcontrol:=[fc_inflowcontrol];
  1355. secondpass(t1);
  1356. if flowcontrol<>[fc_inflowcontrol] then
  1357. CGMessage(cg_e_control_flow_outside_finally);
  1358. if codegenerror then
  1359. exit;
  1360. {$if defined(x86) or defined(arm)}
  1361. if (target_info.system in system_all_windows) and
  1362. (current_procinfo.procdef.proccalloption=pocall_safecall) then
  1363. begin
  1364. { Remove and destroy the last exception object }
  1365. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_POPOBJECTSTACK',false);
  1366. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_DESTROYEXCEPTION',false);
  1367. { Set return value of safecall procedure to indicate exception. }
  1368. { Exception will be raised after procedure exit based on return value }
  1369. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1370. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_ADDR,aint($8000FFFF),NR_FUNCTION_RETURN_REG);
  1371. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1372. end
  1373. else
  1374. {$endif}
  1375. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_RERAISE',false);
  1376. end
  1377. else
  1378. begin
  1379. cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,endfinallylabel);
  1380. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SUB,OS_INT,1,NR_FUNCTION_RESULT_REG);
  1381. cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,reraiselabel);
  1382. if fc_exit in tryflowcontrol then
  1383. begin
  1384. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SUB,OS_INT,1,NR_FUNCTION_RESULT_REG);
  1385. cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,oldCurrExitLabel);
  1386. decconst:=1;
  1387. end
  1388. else
  1389. decconst:=2;
  1390. if fc_break in tryflowcontrol then
  1391. begin
  1392. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SUB,OS_INT,decconst,NR_FUNCTION_RESULT_REG);
  1393. cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,oldBreakLabel);
  1394. decconst:=1;
  1395. end
  1396. else
  1397. inc(decconst);
  1398. if fc_continue in tryflowcontrol then
  1399. begin
  1400. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SUB,OS_INT,decconst,NR_FUNCTION_RESULT_REG);
  1401. cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_EQ,0,NR_FUNCTION_RESULT_REG,oldContinueLabel);
  1402. end;
  1403. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1404. cg.a_label(current_asmdata.CurrAsmList,reraiselabel);
  1405. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_RERAISE',false);
  1406. { do some magic for exit,break,continue in the try block }
  1407. if fc_exit in tryflowcontrol then
  1408. begin
  1409. cg.a_label(current_asmdata.CurrAsmList,exitfinallylabel);
  1410. cg.g_exception_reason_load(current_asmdata.CurrAsmList,excepttemps.reasonbuf);
  1411. cg.g_exception_reason_save_const(current_asmdata.CurrAsmList,excepttemps.reasonbuf,2);
  1412. cg.a_jmp_always(current_asmdata.CurrAsmList,finallylabel);
  1413. { from g_exception_reason_load }
  1414. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1415. end;
  1416. if fc_break in tryflowcontrol then
  1417. begin
  1418. cg.a_label(current_asmdata.CurrAsmList,breakfinallylabel);
  1419. cg.g_exception_reason_load(current_asmdata.CurrAsmList,excepttemps.reasonbuf);
  1420. cg.g_exception_reason_save_const(current_asmdata.CurrAsmList,excepttemps.reasonbuf,3);
  1421. cg.a_jmp_always(current_asmdata.CurrAsmList,finallylabel);
  1422. { from g_exception_reason_load }
  1423. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1424. end;
  1425. if fc_continue in tryflowcontrol then
  1426. begin
  1427. cg.a_label(current_asmdata.CurrAsmList,continuefinallylabel);
  1428. cg.g_exception_reason_load(current_asmdata.CurrAsmList,excepttemps.reasonbuf);
  1429. cg.g_exception_reason_save_const(current_asmdata.CurrAsmList,excepttemps.reasonbuf,4);
  1430. cg.a_jmp_always(current_asmdata.CurrAsmList,finallylabel);
  1431. { from g_exception_reason_load }
  1432. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_FUNCTION_RESULT_REG);
  1433. end;
  1434. end;
  1435. unget_exception_temps(current_asmdata.CurrAsmList,excepttemps);
  1436. cg.a_label(current_asmdata.CurrAsmList,endfinallylabel);
  1437. current_procinfo.CurrExitLabel:=oldCurrExitLabel;
  1438. if assigned(current_procinfo.CurrBreakLabel) then
  1439. begin
  1440. current_procinfo.CurrContinueLabel:=oldContinueLabel;
  1441. current_procinfo.CurrBreakLabel:=oldBreakLabel;
  1442. end;
  1443. flowcontrol:=oldflowcontrol+(tryflowcontrol-[fc_inflowcontrol]);
  1444. end;
  1445. begin
  1446. cwhilerepeatnode:=tcgwhilerepeatnode;
  1447. cifnode:=tcgifnode;
  1448. cfornode:=tcgfornode;
  1449. cexitnode:=tcgexitnode;
  1450. cbreaknode:=tcgbreaknode;
  1451. ccontinuenode:=tcgcontinuenode;
  1452. cgotonode:=tcggotonode;
  1453. clabelnode:=tcglabelnode;
  1454. craisenode:=tcgraisenode;
  1455. ctryexceptnode:=tcgtryexceptnode;
  1456. ctryfinallynode:=tcgtryfinallynode;
  1457. connode:=tcgonnode;
  1458. end.