n386flw.pas 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. Generate i386 assembler for nodes that influence the flow
  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 n386flw;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. node,nflw;
  23. type
  24. ti386whilerepeatnode = class(twhilerepeatnode)
  25. procedure pass_2;override;
  26. end;
  27. ti386ifnode = class(tifnode)
  28. procedure pass_2;override;
  29. end;
  30. ti386fornode = class(tfornode)
  31. procedure pass_2;override;
  32. end;
  33. ti386exitnode = class(texitnode)
  34. procedure pass_2;override;
  35. end;
  36. ti386breaknode = class(tbreaknode)
  37. procedure pass_2;override;
  38. end;
  39. ti386continuenode = class(tcontinuenode)
  40. procedure pass_2;override;
  41. end;
  42. ti386gotonode = class(tgotonode)
  43. procedure pass_2;override;
  44. end;
  45. ti386labelnode = class(tlabelnode)
  46. procedure pass_2;override;
  47. end;
  48. ti386raisenode = class(traisenode)
  49. procedure pass_2;override;
  50. end;
  51. ti386tryexceptnode = class(ttryexceptnode)
  52. procedure pass_2;override;
  53. end;
  54. ti386tryfinallynode = class(ttryfinallynode)
  55. procedure pass_2;override;
  56. end;
  57. ti386onnode = class(tonnode)
  58. procedure pass_2;override;
  59. end;
  60. ti386failnode = class(tfailnode)
  61. procedure pass_2;override;
  62. end;
  63. implementation
  64. uses
  65. verbose,globtype,globals,systems,
  66. symconst,symdef,symsym,aasm,types,
  67. hcodegen,temp_gen,pass_2,
  68. cpubase,cpuasm,
  69. pass_1,nld,ncon,
  70. cgai386,tgcpu,n386util,regvars;
  71. {*****************************************************************************
  72. Second_While_RepeatN
  73. *****************************************************************************}
  74. procedure ti386whilerepeatnode.pass_2;
  75. var
  76. lcont,lbreak,lloop,
  77. oldclabel,oldblabel : tasmlabel;
  78. otlabel,oflabel : tasmlabel;
  79. //start_regvars_loaded,
  80. //then_regvars_loaded: regvar_booleanarray;
  81. begin
  82. getlabel(lloop);
  83. getlabel(lcont);
  84. getlabel(lbreak);
  85. { arrange continue and breaklabels: }
  86. oldclabel:=aktcontinuelabel;
  87. oldblabel:=aktbreaklabel;
  88. load_all_regvars(exprasmlist);
  89. { handling code at the end as it is much more efficient, and makes
  90. while equal to repeat loop, only the end true/false is swapped (PFV) }
  91. if nodetype=whilen then
  92. emitjmp(C_None,lcont);
  93. { align loop target }
  94. if not(cs_littlesize in aktglobalswitches) then
  95. begin
  96. if (cs_align in aktglobalswitches) then
  97. exprasmList.concat(Tai_align.Create_op(16,$90))
  98. else
  99. exprasmList.concat(Tai_align.Create_op(4,$90))
  100. end;
  101. emitlab(lloop);
  102. aktcontinuelabel:=lcont;
  103. aktbreaklabel:=lbreak;
  104. cleartempgen;
  105. if assigned(right) then
  106. secondpass(right);
  107. load_all_regvars(exprasmlist);
  108. emitlab(lcont);
  109. otlabel:=truelabel;
  110. oflabel:=falselabel;
  111. if nodetype=whilen then
  112. begin
  113. truelabel:=lloop;
  114. falselabel:=lbreak;
  115. end
  116. { repeatn }
  117. else
  118. begin
  119. truelabel:=lbreak;
  120. falselabel:=lloop;
  121. end;
  122. cleartempgen;
  123. secondpass(left);
  124. load_all_regvars(exprasmlist);
  125. maketojumpbool(left);
  126. emitlab(lbreak);
  127. truelabel:=otlabel;
  128. falselabel:=oflabel;
  129. aktcontinuelabel:=oldclabel;
  130. aktbreaklabel:=oldblabel;
  131. { a break/continue in a while/repeat block can't be seen outside }
  132. flowcontrol:=flowcontrol-[fc_break,fc_continue];
  133. end;
  134. {*****************************************************************************
  135. TI386IFNODE
  136. *****************************************************************************}
  137. procedure ti386ifnode.pass_2;
  138. var
  139. hl,otlabel,oflabel : tasmlabel;
  140. begin
  141. otlabel:=truelabel;
  142. oflabel:=falselabel;
  143. getlabel(truelabel);
  144. getlabel(falselabel);
  145. cleartempgen;
  146. secondpass(left);
  147. load_all_regvars(exprasmlist);
  148. maketojumpbool(left);
  149. if assigned(right) then
  150. begin
  151. emitlab(truelabel);
  152. cleartempgen;
  153. secondpass(right);
  154. { automatically done for blocks, but not for statements (JM) }
  155. load_all_regvars(exprasmlist);
  156. end;
  157. if assigned(t1) then
  158. begin
  159. if assigned(right) then
  160. begin
  161. getlabel(hl);
  162. { do go back to if line !! }
  163. aktfilepos:=exprasmList.getlasttaifilepos^;
  164. emitjmp(C_None,hl);
  165. end;
  166. emitlab(falselabel);
  167. cleartempgen;
  168. secondpass(t1);
  169. load_all_regvars(exprasmlist);
  170. if assigned(right) then
  171. emitlab(hl);
  172. end
  173. else
  174. begin
  175. emitlab(falselabel);
  176. end;
  177. if not(assigned(right)) then
  178. begin
  179. emitlab(truelabel);
  180. end;
  181. truelabel:=otlabel;
  182. falselabel:=oflabel;
  183. end;
  184. {*****************************************************************************
  185. SecondFor
  186. *****************************************************************************}
  187. procedure ti386fornode.pass_2;
  188. var
  189. l3,oldclabel,oldblabel : tasmlabel;
  190. omitfirstcomp,temptovalue : boolean;
  191. hs : byte;
  192. temp1 : treference;
  193. hop : tasmop;
  194. hcond : tasmcond;
  195. cmpreg,cmp32 : tregister;
  196. opsize : topsize;
  197. count_var_is_signed : boolean;
  198. begin
  199. oldclabel:=aktcontinuelabel;
  200. oldblabel:=aktbreaklabel;
  201. getlabel(aktcontinuelabel);
  202. getlabel(aktbreaklabel);
  203. getlabel(l3);
  204. { could we spare the first comparison ? }
  205. omitfirstcomp:=false;
  206. if right.nodetype=ordconstn then
  207. if tassignmentnode(left).right.nodetype=ordconstn then
  208. omitfirstcomp:=((nf_backward in flags) and
  209. (tordconstnode(tassignmentnode(left).right).value>=tordconstnode(right).value))
  210. or (not(nf_backward in flags) and
  211. (tordconstnode(tassignmentnode(left).right).value<=tordconstnode(right).value));
  212. { only calculate reference }
  213. cleartempgen;
  214. secondpass(t2);
  215. hs:=t2.resulttype.def.size;
  216. if t2.location.loc <> LOC_CREGISTER then
  217. cmp32:=getregister32;
  218. case hs of
  219. 1 : begin
  220. opsize:=S_B;
  221. if t2.location.loc <> LOC_CREGISTER then
  222. cmpreg:=reg32toreg8(cmp32);
  223. end;
  224. 2 : begin
  225. opsize:=S_W;
  226. if t2.location.loc <> LOC_CREGISTER then
  227. cmpreg:=reg32toreg16(cmp32);
  228. end;
  229. 4 : begin
  230. opsize:=S_L;
  231. if t2.location.loc <> LOC_CREGISTER then
  232. cmpreg:=cmp32;
  233. end;
  234. end;
  235. { first set the to value
  236. because the count var can be in the expression !! }
  237. cleartempgen;
  238. secondpass(right);
  239. { calculate pointer value and check if changeable and if so }
  240. { load into temporary variable }
  241. if right.nodetype<>ordconstn then
  242. begin
  243. temp1.symbol:=nil;
  244. gettempofsizereference(hs,temp1);
  245. temptovalue:=true;
  246. if (right.location.loc=LOC_REGISTER) or
  247. (right.location.loc=LOC_CREGISTER) then
  248. begin
  249. emit_reg_ref(A_MOV,opsize,right.location.register,
  250. newreference(temp1));
  251. end
  252. else
  253. concatcopy(right.location.reference,temp1,hs,false,false);
  254. end
  255. else
  256. temptovalue:=false;
  257. { produce start assignment }
  258. cleartempgen;
  259. secondpass(left);
  260. count_var_is_signed:=is_signed(torddef(t2.resulttype.def));
  261. if temptovalue then
  262. begin
  263. if t2.location.loc=LOC_CREGISTER then
  264. begin
  265. emit_ref_reg(A_CMP,opsize,newreference(temp1),
  266. t2.location.register);
  267. end
  268. else
  269. begin
  270. emit_ref_reg(A_MOV,opsize,newreference(t2.location.reference),
  271. cmpreg);
  272. emit_ref_reg(A_CMP,opsize,newreference(temp1),
  273. cmpreg);
  274. { temp register not necessary anymore currently (JM) }
  275. ungetregister32(cmp32);
  276. end;
  277. end
  278. else
  279. begin
  280. if not(omitfirstcomp) then
  281. begin
  282. if t2.location.loc=LOC_CREGISTER then
  283. emit_const_reg(A_CMP,opsize,tordconstnode(right).value,
  284. t2.location.register)
  285. else
  286. emit_const_ref(A_CMP,opsize,tordconstnode(right).value,
  287. newreference(t2.location.reference));
  288. end;
  289. end;
  290. if nf_backward in flags then
  291. if count_var_is_signed then
  292. hcond:=C_L
  293. else
  294. hcond:=C_B
  295. else
  296. if count_var_is_signed then
  297. hcond:=C_G
  298. else
  299. hcond:=C_A;
  300. load_all_regvars(exprasmlist);
  301. if not(omitfirstcomp) or temptovalue then
  302. emitjmp(hcond,aktbreaklabel);
  303. { align loop target }
  304. if not(cs_littlesize in aktglobalswitches) then
  305. begin
  306. if (cs_align in aktglobalswitches) then
  307. exprasmList.concat(Tai_align.Create_op(16,$90))
  308. else
  309. exprasmList.concat(Tai_align.Create_op(4,$90))
  310. end;
  311. emitlab(l3);
  312. { help register must not be in instruction block }
  313. cleartempgen;
  314. if assigned(t1) then
  315. begin
  316. secondpass(t1);
  317. load_all_regvars(exprasmlist);
  318. end;
  319. emitlab(aktcontinuelabel);
  320. { makes no problems there }
  321. cleartempgen;
  322. if (t2.location.loc <> LOC_CREGISTER) then
  323. begin
  324. { demand help register again }
  325. cmp32:=getregister32;
  326. case hs of
  327. 1 : cmpreg:=reg32toreg8(cmp32);
  328. 2 : cmpreg:=reg32toreg16(cmp32);
  329. 4 : cmpreg:=cmp32;
  330. end;
  331. end;
  332. { produce comparison and the corresponding }
  333. { jump }
  334. if temptovalue then
  335. begin
  336. if t2.location.loc=LOC_CREGISTER then
  337. begin
  338. emit_ref_reg(A_CMP,opsize,newreference(temp1),
  339. t2.location.register);
  340. end
  341. else
  342. begin
  343. emit_ref_reg(A_MOV,opsize,newreference(t2.location.reference),
  344. cmpreg);
  345. emit_ref_reg(A_CMP,opsize,newreference(temp1),
  346. cmpreg);
  347. end;
  348. end
  349. else
  350. begin
  351. if t2.location.loc=LOC_CREGISTER then
  352. emit_const_reg(A_CMP,opsize,tordconstnode(right).value,
  353. t2.location.register)
  354. else
  355. emit_const_ref(A_CMP,opsize,tordconstnode(right).value,
  356. newreference(t2.location.reference));
  357. end;
  358. if nf_backward in flags then
  359. if count_var_is_signed then
  360. hcond:=C_LE
  361. else
  362. hcond:=C_BE
  363. else
  364. if count_var_is_signed then
  365. hcond:=C_GE
  366. else
  367. hcond:=C_AE;
  368. load_all_regvars(exprasmlist);
  369. emitjmp(hcond,aktbreaklabel);
  370. { according to count direction DEC or INC... }
  371. { must be after the test because of 0 to 255 for bytes !! }
  372. if nf_backward in flags then
  373. hop:=A_DEC
  374. else
  375. hop:=A_INC;
  376. if t2.location.loc=LOC_CREGISTER then
  377. emit_reg(hop,opsize,t2.location.register)
  378. else
  379. emit_ref(hop,opsize,newreference(t2.location.reference));
  380. emitjmp(C_None,l3);
  381. if (t2.location.loc <> LOC_CREGISTER) then
  382. ungetregister32(cmp32);
  383. if temptovalue then
  384. ungetiftemp(temp1);
  385. { this is the break label: }
  386. emitlab(aktbreaklabel);
  387. aktcontinuelabel:=oldclabel;
  388. aktbreaklabel:=oldblabel;
  389. { a break/continue in a for block can't be seen outside }
  390. flowcontrol:=flowcontrol-[fc_break,fc_continue];
  391. end;
  392. {*****************************************************************************
  393. SecondExitN
  394. *****************************************************************************}
  395. procedure ti386exitnode.pass_2;
  396. var
  397. {op : tasmop;
  398. s : topsize;}
  399. otlabel,oflabel : tasmlabel;
  400. r : preference;
  401. is_mem,
  402. allocated_eax,
  403. allocated_edx: boolean;
  404. procedure cleanleft;
  405. begin
  406. if is_mem then
  407. begin
  408. del_reference(left.location.reference);
  409. ungetiftemp(left.location.reference);
  410. end
  411. else
  412. begin
  413. ungetregister(left.location.register);
  414. if left.location.registerhigh <> R_NO then
  415. ungetregister(left.location.registerhigh);
  416. end;
  417. end;
  418. label
  419. do_jmp;
  420. begin
  421. load_all_regvars(exprasmlist);
  422. include(flowcontrol,fc_exit);
  423. if assigned(left) then
  424. if left.nodetype=assignn then
  425. begin
  426. { just do a normal assignment followed by exit }
  427. secondpass(left);
  428. emitjmp(C_None,aktexitlabel);
  429. end
  430. else
  431. begin
  432. allocated_eax := false;
  433. allocated_edx := false;
  434. otlabel:=truelabel;
  435. oflabel:=falselabel;
  436. getlabel(truelabel);
  437. getlabel(falselabel);
  438. secondpass(left);
  439. case left.location.loc of
  440. LOC_FPU : goto do_jmp;
  441. LOC_MEM,
  442. LOC_REFERENCE : is_mem:=true;
  443. LOC_CREGISTER,
  444. LOC_REGISTER : is_mem:=false;
  445. LOC_FLAGS : begin
  446. exprasmlist.concat(tairegalloc.alloc(R_EAX));
  447. allocated_eax := true;
  448. emit_flag2reg(left.location.resflags,R_AL);
  449. goto do_jmp;
  450. end;
  451. LOC_JUMP : begin
  452. exprasmlist.concat(tairegalloc.alloc(R_EAX));
  453. allocated_eax := true;
  454. emitlab(truelabel);
  455. emit_const_reg(A_MOV,S_B,1,R_AL);
  456. emitjmp(C_None,aktexit2label);
  457. emitlab(falselabel);
  458. emit_reg_reg(A_XOR,S_B,R_AL,R_AL);
  459. goto do_jmp;
  460. end;
  461. else
  462. internalerror(2001);
  463. end;
  464. case procinfo^.returntype.def.deftype of
  465. pointerdef,
  466. procvardef : begin
  467. cleanleft;
  468. exprasmlist.concat(tairegalloc.alloc(R_EAX));
  469. allocated_eax := true;
  470. if is_mem then
  471. emit_ref_reg(A_MOV,S_L,
  472. newreference(left.location.reference),R_EAX)
  473. else
  474. emit_reg_reg(A_MOV,S_L,
  475. left.location.register,R_EAX);
  476. end;
  477. floatdef : begin
  478. cleanleft;
  479. if is_mem then
  480. floatload(tfloatdef(procinfo^.returntype.def).typ,left.location.reference);
  481. end;
  482. { orddef,
  483. enumdef : }
  484. else
  485. { it can be anything shorter than 4 bytes PM
  486. this caused form bug 711 }
  487. begin
  488. cleanleft;
  489. exprasmlist.concat(tairegalloc.alloc(R_EAX));
  490. allocated_eax := true;
  491. case procinfo^.returntype.def.size of
  492. { it can be a qword/int64 too ... }
  493. 8 : if is_mem then
  494. begin
  495. emit_ref_reg(A_MOV,S_L,
  496. newreference(left.location.reference),R_EAX);
  497. r:=newreference(left.location.reference);
  498. inc(r^.offset,4);
  499. exprasmlist.concat(tairegalloc.alloc(R_EDX));
  500. allocated_edx := true;
  501. emit_ref_reg(A_MOV,S_L,r,R_EDX);
  502. end
  503. else
  504. begin
  505. emit_reg_reg(A_MOV,S_L,left.location.registerlow,R_EAX);
  506. exprasmlist.concat(tairegalloc.alloc(R_EDX));
  507. allocated_edx := true;
  508. emit_reg_reg(A_MOV,S_L,left.location.registerhigh,R_EDX);
  509. end;
  510. { if its 3 bytes only we can still
  511. copy one of garbage ! PM }
  512. 4,3 : if is_mem then
  513. emit_ref_reg(A_MOV,S_L,
  514. newreference(left.location.reference),R_EAX)
  515. else
  516. emit_reg_reg(A_MOV,S_L,left.location.register,R_EAX);
  517. 2 : if is_mem then
  518. emit_ref_reg(A_MOV,S_W,
  519. newreference(left.location.reference),R_AX)
  520. else
  521. emit_reg_reg(A_MOV,S_W,makereg16(left.location.register),R_AX);
  522. 1 : if is_mem then
  523. emit_ref_reg(A_MOV,S_B,
  524. newreference(left.location.reference),R_AL)
  525. else
  526. emit_reg_reg(A_MOV,S_B,makereg8(left.location.register),R_AL);
  527. else internalerror(605001);
  528. end;
  529. end;
  530. end;
  531. do_jmp:
  532. truelabel:=otlabel;
  533. falselabel:=oflabel;
  534. emitjmp(C_None,aktexit2label);
  535. if allocated_eax then
  536. exprasmlist.concat(tairegalloc.dealloc(R_EAX));
  537. if allocated_edx then
  538. exprasmlist.concat(tairegalloc.dealloc(R_EDX));
  539. end
  540. else
  541. emitjmp(C_None,aktexitlabel);
  542. end;
  543. {*****************************************************************************
  544. SecondBreakN
  545. *****************************************************************************}
  546. procedure ti386breaknode.pass_2;
  547. begin
  548. include(flowcontrol,fc_break);
  549. if aktbreaklabel<>nil then
  550. begin
  551. load_all_regvars(exprasmlist);
  552. emitjmp(C_None,aktbreaklabel)
  553. end
  554. else
  555. CGMessage(cg_e_break_not_allowed);
  556. end;
  557. {*****************************************************************************
  558. SecondContinueN
  559. *****************************************************************************}
  560. procedure ti386continuenode.pass_2;
  561. begin
  562. include(flowcontrol,fc_continue);
  563. if aktcontinuelabel<>nil then
  564. begin
  565. load_all_regvars(exprasmlist);
  566. emitjmp(C_None,aktcontinuelabel)
  567. end
  568. else
  569. CGMessage(cg_e_continue_not_allowed);
  570. end;
  571. {*****************************************************************************
  572. SecondGoto
  573. *****************************************************************************}
  574. procedure ti386gotonode.pass_2;
  575. begin
  576. load_all_regvars(exprasmlist);
  577. emitjmp(C_None,labelnr);
  578. end;
  579. {*****************************************************************************
  580. SecondLabel
  581. *****************************************************************************}
  582. procedure ti386labelnode.pass_2;
  583. begin
  584. load_all_regvars(exprasmlist);
  585. emitlab(labelnr);
  586. cleartempgen;
  587. secondpass(left);
  588. end;
  589. {*****************************************************************************
  590. SecondRaise
  591. *****************************************************************************}
  592. procedure ti386raisenode.pass_2;
  593. var
  594. a : tasmlabel;
  595. begin
  596. if assigned(left) then
  597. begin
  598. { multiple parameters? }
  599. if assigned(right) then
  600. begin
  601. { push frame }
  602. if assigned(frametree) then
  603. begin
  604. secondpass(frametree);
  605. if codegenerror then
  606. exit;
  607. emit_push_loc(frametree.location);
  608. end
  609. else
  610. emit_const(A_PUSH,S_L,0);
  611. { push address }
  612. secondpass(right);
  613. if codegenerror then
  614. exit;
  615. emit_push_loc(right.location);
  616. end
  617. else
  618. begin
  619. getaddrlabel(a);
  620. emitlab(a);
  621. emit_reg(A_PUSH,S_L,R_EBP);
  622. emit_sym(A_PUSH,S_L,a);
  623. end;
  624. { push object }
  625. secondpass(left);
  626. if codegenerror then
  627. exit;
  628. emit_push_loc(left.location);
  629. emitcall('FPC_RAISEEXCEPTION');
  630. end
  631. else
  632. begin
  633. emitcall('FPC_POPADDRSTACK');
  634. emitcall('FPC_RERAISE');
  635. end;
  636. end;
  637. {*****************************************************************************
  638. SecondTryExcept
  639. *****************************************************************************}
  640. var
  641. endexceptlabel : tasmlabel;
  642. { does the necessary things to clean up the object stack }
  643. { in the except block }
  644. procedure cleanupobjectstack;
  645. begin
  646. emitcall('FPC_POPOBJECTSTACK');
  647. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  648. emit_reg(A_PUSH,S_L,R_EAX);
  649. emitcall('FPC_DESTROYEXCEPTION');
  650. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  651. maybe_loadself;
  652. end;
  653. { pops one element from the exception address stack }
  654. { and removes the flag }
  655. procedure cleanupaddrstack;
  656. begin
  657. emitcall('FPC_POPADDRSTACK');
  658. { allocate eax }
  659. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  660. emit_reg(A_POP,S_L,R_EAX);
  661. { deallocate eax }
  662. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  663. end;
  664. procedure ti386tryexceptnode.pass_2;
  665. var
  666. exceptlabel,doexceptlabel,oldendexceptlabel,
  667. lastonlabel,
  668. exitexceptlabel,
  669. continueexceptlabel,
  670. breakexceptlabel,
  671. exittrylabel,
  672. continuetrylabel,
  673. breaktrylabel,
  674. doobjectdestroy,
  675. doobjectdestroyandreraise,
  676. oldaktexitlabel,
  677. oldaktexit2label,
  678. oldaktcontinuelabel,
  679. oldaktbreaklabel : tasmlabel;
  680. oldflowcontrol,tryflowcontrol,
  681. exceptflowcontrol : tflowcontrol;
  682. tempbuf,tempaddr : treference;
  683. label
  684. errorexit;
  685. begin
  686. oldflowcontrol:=flowcontrol;
  687. flowcontrol:=[];
  688. { this can be called recursivly }
  689. oldendexceptlabel:=endexceptlabel;
  690. { we modify EAX }
  691. usedinproc:=usedinproc or ($80 shr byte(R_EAX));
  692. { save the old labels for control flow statements }
  693. oldaktexitlabel:=aktexitlabel;
  694. oldaktexit2label:=aktexit2label;
  695. if assigned(aktbreaklabel) then
  696. begin
  697. oldaktcontinuelabel:=aktcontinuelabel;
  698. oldaktbreaklabel:=aktbreaklabel;
  699. end;
  700. { get new labels for the control flow statements }
  701. getlabel(exittrylabel);
  702. getlabel(exitexceptlabel);
  703. if assigned(aktbreaklabel) then
  704. begin
  705. getlabel(breaktrylabel);
  706. getlabel(continuetrylabel);
  707. getlabel(breakexceptlabel);
  708. getlabel(continueexceptlabel);
  709. end;
  710. getlabel(exceptlabel);
  711. getlabel(doexceptlabel);
  712. getlabel(endexceptlabel);
  713. getlabel(lastonlabel);
  714. gettempofsizereferencepersistant(24,tempbuf);
  715. gettempofsizereferencepersistant(12,tempaddr);
  716. emitpushreferenceaddr(tempaddr);
  717. emitpushreferenceaddr(tempbuf);
  718. push_int (1); { push type of exceptionframe }
  719. emitcall('FPC_PUSHEXCEPTADDR');
  720. { allocate eax }
  721. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  722. emit_reg(A_PUSH,S_L,R_EAX);
  723. emitcall('FPC_SETJMP');
  724. emit_reg(A_PUSH,S_L,R_EAX);
  725. emit_reg_reg(A_TEST,S_L,R_EAX,R_EAX);
  726. { deallocate eax }
  727. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  728. emitjmp(C_NE,exceptlabel);
  729. { try block }
  730. { set control flow labels for the try block }
  731. aktexitlabel:=exittrylabel;
  732. aktexit2label:=exittrylabel;
  733. if assigned(oldaktbreaklabel) then
  734. begin
  735. aktcontinuelabel:=continuetrylabel;
  736. aktbreaklabel:=breaktrylabel;
  737. end;
  738. flowcontrol:=[];
  739. secondpass(left);
  740. tryflowcontrol:=flowcontrol;
  741. if codegenerror then
  742. goto errorexit;
  743. emitlab(exceptlabel);
  744. emitcall('FPC_POPADDRSTACK');
  745. ungetpersistanttempreference(tempaddr);
  746. ungetpersistanttempreference(tempbuf);
  747. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  748. emit_reg(A_POP,S_L,R_EAX);
  749. emit_reg_reg(A_TEST,S_L,R_EAX,R_EAX);
  750. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  751. emitjmp(C_E,endexceptlabel);
  752. emitlab(doexceptlabel);
  753. { set control flow labels for the except block }
  754. { and the on statements }
  755. aktexitlabel:=exitexceptlabel;
  756. aktexit2label:=exitexceptlabel;
  757. if assigned(oldaktbreaklabel) then
  758. begin
  759. aktcontinuelabel:=continueexceptlabel;
  760. aktbreaklabel:=breakexceptlabel;
  761. end;
  762. flowcontrol:=[];
  763. { on statements }
  764. if assigned(right) then
  765. secondpass(right);
  766. emitlab(lastonlabel);
  767. { default handling except handling }
  768. if assigned(t1) then
  769. begin
  770. { FPC_CATCHES must be called with
  771. 'default handler' flag (=-1)
  772. }
  773. push_int (-1);
  774. emitcall('FPC_CATCHES');
  775. maybe_loadself;
  776. { the destruction of the exception object must be also }
  777. { guarded by an exception frame }
  778. getlabel(doobjectdestroy);
  779. getlabel(doobjectdestroyandreraise);
  780. gettempofsizereferencepersistant(12,tempaddr);
  781. gettempofsizereferencepersistant(24,tempbuf);
  782. emitpushreferenceaddr(tempaddr);
  783. emitpushreferenceaddr(tempbuf);
  784. exprasmList.concat(Taicpu.Op_const(A_PUSH,S_L,1));
  785. emitcall('FPC_PUSHEXCEPTADDR');
  786. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  787. exprasmList.concat(Taicpu.op_reg(A_PUSH,S_L,R_EAX));
  788. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  789. emitcall('FPC_SETJMP');
  790. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  791. exprasmList.concat(Taicpu.op_reg(A_PUSH,S_L,R_EAX));
  792. exprasmList.concat(Taicpu.op_reg_reg(A_TEST,S_L,R_EAX,R_EAX));
  793. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  794. emitjmp(C_NE,doobjectdestroyandreraise);
  795. { here we don't have to reset flowcontrol }
  796. { the default and on flowcontrols are handled equal }
  797. secondpass(t1);
  798. exceptflowcontrol:=flowcontrol;
  799. emitlab(doobjectdestroyandreraise);
  800. emitcall('FPC_POPADDRSTACK');
  801. ungetpersistanttempreference(tempaddr);
  802. ungetpersistanttempreference(tempbuf);
  803. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  804. exprasmList.concat(Taicpu.op_reg(A_POP,S_L,R_EAX));
  805. exprasmList.concat(Taicpu.op_reg_reg(A_TEST,S_L,R_EAX,R_EAX));
  806. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  807. emitjmp(C_E,doobjectdestroy);
  808. emitcall('FPC_POPSECONDOBJECTSTACK');
  809. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  810. emit_reg(A_PUSH,S_L,R_EAX);
  811. emitcall('FPC_DESTROYEXCEPTION');
  812. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  813. { we don't need to restore esi here because reraise never }
  814. { returns }
  815. emitcall('FPC_RERAISE');
  816. emitlab(doobjectdestroy);
  817. cleanupobjectstack;
  818. emitjmp(C_None,endexceptlabel);
  819. end
  820. else
  821. begin
  822. emitcall('FPC_RERAISE');
  823. exceptflowcontrol:=flowcontrol;
  824. end;
  825. if fc_exit in exceptflowcontrol then
  826. begin
  827. { do some magic for exit in the try block }
  828. emitlab(exitexceptlabel);
  829. { we must also destroy the address frame which guards }
  830. { exception object }
  831. cleanupaddrstack;
  832. cleanupobjectstack;
  833. emitjmp(C_None,oldaktexitlabel);
  834. end;
  835. if fc_break in exceptflowcontrol then
  836. begin
  837. emitlab(breakexceptlabel);
  838. { we must also destroy the address frame which guards }
  839. { exception object }
  840. cleanupaddrstack;
  841. cleanupobjectstack;
  842. emitjmp(C_None,oldaktbreaklabel);
  843. end;
  844. if fc_continue in exceptflowcontrol then
  845. begin
  846. emitlab(continueexceptlabel);
  847. { we must also destroy the address frame which guards }
  848. { exception object }
  849. cleanupaddrstack;
  850. cleanupobjectstack;
  851. emitjmp(C_None,oldaktcontinuelabel);
  852. end;
  853. if fc_exit in tryflowcontrol then
  854. begin
  855. { do some magic for exit in the try block }
  856. emitlab(exittrylabel);
  857. cleanupaddrstack;
  858. emitjmp(C_None,oldaktexitlabel);
  859. end;
  860. if fc_break in tryflowcontrol then
  861. begin
  862. emitlab(breaktrylabel);
  863. cleanupaddrstack;
  864. emitjmp(C_None,oldaktbreaklabel);
  865. end;
  866. if fc_continue in tryflowcontrol then
  867. begin
  868. emitlab(continuetrylabel);
  869. cleanupaddrstack;
  870. emitjmp(C_None,oldaktcontinuelabel);
  871. end;
  872. emitlab(endexceptlabel);
  873. errorexit:
  874. { restore all saved labels }
  875. endexceptlabel:=oldendexceptlabel;
  876. { restore the control flow labels }
  877. aktexitlabel:=oldaktexitlabel;
  878. aktexit2label:=oldaktexit2label;
  879. if assigned(oldaktbreaklabel) then
  880. begin
  881. aktcontinuelabel:=oldaktcontinuelabel;
  882. aktbreaklabel:=oldaktbreaklabel;
  883. end;
  884. { return all used control flow statements }
  885. flowcontrol:=oldflowcontrol+exceptflowcontrol+
  886. tryflowcontrol;
  887. end;
  888. procedure ti386onnode.pass_2;
  889. var
  890. nextonlabel,
  891. exitonlabel,
  892. continueonlabel,
  893. breakonlabel,
  894. oldaktexitlabel,
  895. oldaktexit2label,
  896. oldaktcontinuelabel,
  897. doobjectdestroyandreraise,
  898. doobjectdestroy,
  899. oldaktbreaklabel : tasmlabel;
  900. ref : treference;
  901. oldflowcontrol : tflowcontrol;
  902. tempbuf,tempaddr : treference;
  903. begin
  904. oldflowcontrol:=flowcontrol;
  905. flowcontrol:=[];
  906. getlabel(nextonlabel);
  907. { push the vmt }
  908. emit_sym(A_PUSH,S_L,
  909. newasmsymbol(excepttype.vmt_mangledname));
  910. emitcall('FPC_CATCHES');
  911. { allocate eax }
  912. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  913. emit_reg_reg(A_TEST,S_L,R_EAX,R_EAX);
  914. emitjmp(C_E,nextonlabel);
  915. ref.symbol:=nil;
  916. gettempofsizereference(4,ref);
  917. { what a hack ! }
  918. if assigned(exceptsymtable) then
  919. tvarsym(exceptsymtable.symindex.first).address:=ref.offset;
  920. emit_reg_ref(A_MOV,S_L,
  921. R_EAX,newreference(ref));
  922. { deallocate eax }
  923. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  924. { in the case that another exception is risen }
  925. { we've to destroy the old one }
  926. getlabel(doobjectdestroyandreraise);
  927. gettempofsizereferencepersistant(12,tempaddr);
  928. gettempofsizereferencepersistant(24,tempbuf);
  929. emitpushreferenceaddr(tempaddr);
  930. emitpushreferenceaddr(tempbuf);
  931. exprasmList.concat(Taicpu.Op_const(A_PUSH,S_L,1));
  932. emitcall('FPC_PUSHEXCEPTADDR');
  933. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  934. exprasmList.concat(Taicpu.op_reg(A_PUSH,S_L,R_EAX));
  935. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  936. emitcall('FPC_SETJMP');
  937. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  938. exprasmList.concat(Taicpu.op_reg(A_PUSH,S_L,R_EAX));
  939. exprasmList.concat(Taicpu.op_reg_reg(A_TEST,S_L,R_EAX,R_EAX));
  940. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  941. emitjmp(C_NE,doobjectdestroyandreraise);
  942. if assigned(right) then
  943. begin
  944. oldaktexitlabel:=aktexitlabel;
  945. oldaktexit2label:=aktexit2label;
  946. getlabel(exitonlabel);
  947. aktexitlabel:=exitonlabel;
  948. aktexit2label:=exitonlabel;
  949. if assigned(aktbreaklabel) then
  950. begin
  951. oldaktcontinuelabel:=aktcontinuelabel;
  952. oldaktbreaklabel:=aktbreaklabel;
  953. getlabel(breakonlabel);
  954. getlabel(continueonlabel);
  955. aktcontinuelabel:=continueonlabel;
  956. aktbreaklabel:=breakonlabel;
  957. end;
  958. { esi is destroyed by FPC_CATCHES }
  959. maybe_loadself;
  960. secondpass(right);
  961. end;
  962. getlabel(doobjectdestroy);
  963. emitlab(doobjectdestroyandreraise);
  964. emitcall('FPC_POPADDRSTACK');
  965. ungetpersistanttempreference(tempaddr);
  966. ungetpersistanttempreference(tempbuf);
  967. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  968. exprasmList.concat(Taicpu.op_reg(A_POP,S_L,R_EAX));
  969. exprasmList.concat(Taicpu.op_reg_reg(A_TEST,S_L,R_EAX,R_EAX));
  970. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  971. emitjmp(C_E,doobjectdestroy);
  972. emitcall('FPC_POPSECONDOBJECTSTACK');
  973. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  974. emit_reg(A_PUSH,S_L,R_EAX);
  975. emitcall('FPC_DESTROYEXCEPTION');
  976. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  977. { we don't need to restore esi here because reraise never }
  978. { returns }
  979. emitcall('FPC_RERAISE');
  980. emitlab(doobjectdestroy);
  981. cleanupobjectstack;
  982. { clear some stuff }
  983. ungetiftemp(ref);
  984. emitjmp(C_None,endexceptlabel);
  985. if assigned(right) then
  986. begin
  987. { special handling for control flow instructions }
  988. if fc_exit in flowcontrol then
  989. begin
  990. { the address and object pop does secondtryexcept }
  991. emitlab(exitonlabel);
  992. emitjmp(C_None,oldaktexitlabel);
  993. end;
  994. if fc_break in flowcontrol then
  995. begin
  996. { the address and object pop does secondtryexcept }
  997. emitlab(breakonlabel);
  998. emitjmp(C_None,oldaktbreaklabel);
  999. end;
  1000. if fc_continue in flowcontrol then
  1001. begin
  1002. { the address and object pop does secondtryexcept }
  1003. emitlab(continueonlabel);
  1004. emitjmp(C_None,oldaktcontinuelabel);
  1005. end;
  1006. aktexitlabel:=oldaktexitlabel;
  1007. aktexit2label:=oldaktexit2label;
  1008. if assigned(oldaktbreaklabel) then
  1009. begin
  1010. aktcontinuelabel:=oldaktcontinuelabel;
  1011. aktbreaklabel:=oldaktbreaklabel;
  1012. end;
  1013. end;
  1014. emitlab(nextonlabel);
  1015. flowcontrol:=oldflowcontrol+flowcontrol;
  1016. { next on node }
  1017. if assigned(left) then
  1018. begin
  1019. cleartempgen;
  1020. secondpass(left);
  1021. end;
  1022. end;
  1023. {*****************************************************************************
  1024. SecondTryFinally
  1025. *****************************************************************************}
  1026. procedure ti386tryfinallynode.pass_2;
  1027. var
  1028. reraiselabel,
  1029. finallylabel,
  1030. endfinallylabel,
  1031. exitfinallylabel,
  1032. continuefinallylabel,
  1033. breakfinallylabel,
  1034. oldaktexitlabel,
  1035. oldaktexit2label,
  1036. oldaktcontinuelabel,
  1037. oldaktbreaklabel : tasmlabel;
  1038. oldflowcontrol,tryflowcontrol : tflowcontrol;
  1039. decconst : longint;
  1040. tempbuf,tempaddr : treference;
  1041. begin
  1042. { check if child nodes do a break/continue/exit }
  1043. oldflowcontrol:=flowcontrol;
  1044. flowcontrol:=[];
  1045. { we modify EAX }
  1046. usedinproc:=usedinproc or ($80 shr byte(R_EAX));
  1047. getlabel(finallylabel);
  1048. getlabel(endfinallylabel);
  1049. getlabel(reraiselabel);
  1050. { the finally block must catch break, continue and exit }
  1051. { statements }
  1052. oldaktexitlabel:=aktexitlabel;
  1053. oldaktexit2label:=aktexit2label;
  1054. getlabel(exitfinallylabel);
  1055. aktexitlabel:=exitfinallylabel;
  1056. aktexit2label:=exitfinallylabel;
  1057. if assigned(aktbreaklabel) then
  1058. begin
  1059. oldaktcontinuelabel:=aktcontinuelabel;
  1060. oldaktbreaklabel:=aktbreaklabel;
  1061. getlabel(breakfinallylabel);
  1062. getlabel(continuefinallylabel);
  1063. aktcontinuelabel:=continuefinallylabel;
  1064. aktbreaklabel:=breakfinallylabel;
  1065. end;
  1066. gettempofsizereferencepersistant(12,tempaddr);
  1067. gettempofsizereferencepersistant(24,tempbuf);
  1068. emitpushreferenceaddr(tempaddr);
  1069. emitpushreferenceaddr(tempbuf);
  1070. push_int(1); { Type of stack-frame must be pushed}
  1071. emitcall('FPC_PUSHEXCEPTADDR');
  1072. { allocate eax }
  1073. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  1074. emit_reg(A_PUSH,S_L,R_EAX);
  1075. emitcall('FPC_SETJMP');
  1076. emit_reg(A_PUSH,S_L,R_EAX);
  1077. emit_reg_reg(A_TEST,S_L,R_EAX,R_EAX);
  1078. { deallocate eax }
  1079. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  1080. emitjmp(C_NE,finallylabel);
  1081. { try code }
  1082. if assigned(left) then
  1083. begin
  1084. secondpass(left);
  1085. tryflowcontrol:=flowcontrol;
  1086. if codegenerror then
  1087. exit;
  1088. end;
  1089. emitlab(finallylabel);
  1090. emitcall('FPC_POPADDRSTACK');
  1091. ungetpersistanttempreference(tempaddr);
  1092. ungetpersistanttempreference(tempbuf);
  1093. { finally code }
  1094. flowcontrol:=[];
  1095. secondpass(right);
  1096. if flowcontrol<>[] then
  1097. CGMessage(cg_e_control_flow_outside_finally);
  1098. if codegenerror then
  1099. exit;
  1100. { allocate eax }
  1101. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  1102. emit_reg(A_POP,S_L,R_EAX);
  1103. emit_reg_reg(A_TEST,S_L,R_EAX,R_EAX);
  1104. emitjmp(C_E,endfinallylabel);
  1105. emit_reg(A_DEC,S_L,R_EAX);
  1106. emitjmp(C_Z,reraiselabel);
  1107. if fc_exit in tryflowcontrol then
  1108. begin
  1109. emit_reg(A_DEC,S_L,R_EAX);
  1110. emitjmp(C_Z,oldaktexitlabel);
  1111. decconst:=1;
  1112. end
  1113. else
  1114. decconst:=2;
  1115. if fc_break in tryflowcontrol then
  1116. begin
  1117. emit_const_reg(A_SUB,S_L,decconst,R_EAX);
  1118. emitjmp(C_Z,oldaktbreaklabel);
  1119. decconst:=1;
  1120. end
  1121. else
  1122. inc(decconst);
  1123. if fc_continue in tryflowcontrol then
  1124. begin
  1125. emit_const_reg(A_SUB,S_L,decconst,R_EAX);
  1126. emitjmp(C_Z,oldaktcontinuelabel);
  1127. end;
  1128. { deallocate eax }
  1129. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  1130. emitlab(reraiselabel);
  1131. emitcall('FPC_RERAISE');
  1132. { do some magic for exit,break,continue in the try block }
  1133. if fc_exit in tryflowcontrol then
  1134. begin
  1135. emitlab(exitfinallylabel);
  1136. { allocate eax }
  1137. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  1138. emit_reg(A_POP,S_L,R_EAX);
  1139. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  1140. emit_const(A_PUSH,S_L,2);
  1141. emitjmp(C_NONE,finallylabel);
  1142. end;
  1143. if fc_break in tryflowcontrol then
  1144. begin
  1145. emitlab(breakfinallylabel);
  1146. { allocate eax }
  1147. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  1148. emit_reg(A_POP,S_L,R_EAX);
  1149. { deallocate eax }
  1150. exprasmList.concat(Tairegalloc.DeAlloc(R_EAX));
  1151. emit_const(A_PUSH,S_L,3);
  1152. emitjmp(C_NONE,finallylabel);
  1153. end;
  1154. if fc_continue in tryflowcontrol then
  1155. begin
  1156. emitlab(continuefinallylabel);
  1157. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  1158. emit_reg(A_POP,S_L,R_EAX);
  1159. exprasmList.concat(Tairegalloc.Alloc(R_EAX));
  1160. emit_const(A_PUSH,S_L,4);
  1161. emitjmp(C_NONE,finallylabel);
  1162. end;
  1163. emitlab(endfinallylabel);
  1164. aktexitlabel:=oldaktexitlabel;
  1165. aktexit2label:=oldaktexit2label;
  1166. if assigned(aktbreaklabel) then
  1167. begin
  1168. aktcontinuelabel:=oldaktcontinuelabel;
  1169. aktbreaklabel:=oldaktbreaklabel;
  1170. end;
  1171. flowcontrol:=oldflowcontrol+tryflowcontrol;
  1172. end;
  1173. {*****************************************************************************
  1174. SecondFail
  1175. *****************************************************************************}
  1176. procedure ti386failnode.pass_2;
  1177. begin
  1178. emitjmp(C_None,faillabel);
  1179. end;
  1180. begin
  1181. cwhilerepeatnode:=ti386whilerepeatnode;
  1182. cifnode:=ti386ifnode;
  1183. cfornode:=ti386fornode;
  1184. cexitnode:=ti386exitnode;
  1185. cbreaknode:=ti386breaknode;
  1186. ccontinuenode:=ti386continuenode;
  1187. cgotonode:=ti386gotonode;
  1188. clabelnode:=ti386labelnode;
  1189. craisenode:=ti386raisenode;
  1190. ctryexceptnode:=ti386tryexceptnode;
  1191. ctryfinallynode:=ti386tryfinallynode;
  1192. connode:=ti386onnode;
  1193. cfailnode:=ti386failnode;
  1194. end.
  1195. {
  1196. $Log$
  1197. Revision 1.12 2001-04-15 09:48:31 peter
  1198. * fixed crash in labelnode
  1199. * easier detection of goto and label in try blocks
  1200. Revision 1.11 2001/04/14 14:07:11 peter
  1201. * moved more code from pass_1 to det_resulttype
  1202. Revision 1.10 2001/04/13 01:22:19 peter
  1203. * symtable change to classes
  1204. * range check generation and errors fixed, make cycle DEBUG=1 works
  1205. * memory leaks fixed
  1206. Revision 1.9 2001/04/02 21:20:37 peter
  1207. * resulttype rewrite
  1208. Revision 1.8 2001/01/27 21:29:35 florian
  1209. * behavior -Oa optimized
  1210. Revision 1.7 2001/01/06 23:35:05 jonas
  1211. * fixed webbug 1323
  1212. Revision 1.6 2001/01/05 17:36:58 florian
  1213. * the info about exception frames is stored now on the stack
  1214. instead on the heap
  1215. Revision 1.5 2000/12/25 00:07:32 peter
  1216. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  1217. tlinkedlist objects)
  1218. Revision 1.4 2000/12/05 11:44:33 jonas
  1219. + new integer regvar handling, should be much more efficient
  1220. Revision 1.3 2000/11/29 00:30:47 florian
  1221. * unused units removed from uses clause
  1222. * some changes for widestrings
  1223. Revision 1.2 2000/10/31 22:02:56 peter
  1224. * symtable splitted, no real code changes
  1225. Revision 1.1 2000/10/15 09:33:31 peter
  1226. * moved n386*.pas to i386/ cpu_target dir
  1227. Revision 1.1 2000/10/14 10:14:48 peter
  1228. * moehrendorf oct 2000 rewrite
  1229. }