ncgflw.pas 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate assembler for nodes that influence the flow which are
  5. the same for all (most?) processors
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit ncgflw;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. node,nflw;
  24. type
  25. tcgwhilerepeatnode = class(twhilerepeatnode)
  26. procedure pass_2;override;
  27. end;
  28. tcgifnode = class(tifnode)
  29. procedure pass_2;override;
  30. end;
  31. tcgfornode = class(tfornode)
  32. procedure pass_2;override;
  33. end;
  34. tcgexitnode = class(texitnode)
  35. procedure pass_2;override;
  36. end;
  37. tcgbreaknode = class(tbreaknode)
  38. procedure pass_2;override;
  39. end;
  40. tcgcontinuenode = class(tcontinuenode)
  41. procedure pass_2;override;
  42. end;
  43. tcggotonode = class(tgotonode)
  44. procedure pass_2;override;
  45. end;
  46. tcglabelnode = class(tlabelnode)
  47. procedure pass_2;override;
  48. end;
  49. tcgfailnode = class(tfailnode)
  50. procedure pass_2;override;
  51. end;
  52. tcgraisenode = class(traisenode)
  53. procedure pass_2;override;
  54. end;
  55. tcgtryexceptnode = class(ttryexceptnode)
  56. procedure pass_2;override;
  57. end;
  58. tcgtryfinallynode = class(ttryfinallynode)
  59. procedure pass_2;override;
  60. end;
  61. tcgonnode = class(tonnode)
  62. procedure pass_2;override;
  63. end;
  64. implementation
  65. uses
  66. verbose,globals,systems,globtype,
  67. symconst,symsym,aasmbase,aasmtai,aasmcpu,defbase,
  68. cginfo,cgbase,pass_2,
  69. cpubase,cpuinfo,
  70. nld,ncon,
  71. ncgutil,
  72. tgobj,rgobj,paramgr,
  73. regvars,cgobj,cgcpu
  74. {$ifndef cpu64bit}
  75. ,cg64f32
  76. {$endif cpu64bit}
  77. ;
  78. const
  79. EXCEPT_BUF_SIZE = 12;
  80. {*****************************************************************************
  81. Second_While_RepeatN
  82. *****************************************************************************}
  83. procedure tcgwhilerepeatnode.pass_2;
  84. var
  85. lcont,lbreak,lloop,
  86. oldclabel,oldblabel : tasmlabel;
  87. otlabel,oflabel : tasmlabel;
  88. begin
  89. objectlibrary.getlabel(lloop);
  90. objectlibrary.getlabel(lcont);
  91. objectlibrary.getlabel(lbreak);
  92. { arrange continue and breaklabels: }
  93. oldclabel:=aktcontinuelabel;
  94. oldblabel:=aktbreaklabel;
  95. load_all_regvars(exprasmlist);
  96. { handling code at the end as it is much more efficient, and makes
  97. while equal to repeat loop, only the end true/false is swapped (PFV) }
  98. if nf_testatbegin in flags then
  99. cg.a_jmp_always(exprasmlist,lcont);
  100. if not(cs_littlesize in aktglobalswitches) then
  101. { align loop target }
  102. exprasmList.concat(Tai_align.Create(aktalignment.loopalign));
  103. cg.a_label(exprasmlist,lloop);
  104. aktcontinuelabel:=lcont;
  105. aktbreaklabel:=lbreak;
  106. rg.cleartempgen;
  107. if assigned(right) then
  108. secondpass(right);
  109. load_all_regvars(exprasmlist);
  110. cg.a_label(exprasmlist,lcont);
  111. otlabel:=truelabel;
  112. oflabel:=falselabel;
  113. if nf_checknegate in flags then
  114. begin
  115. truelabel:=lbreak;
  116. falselabel:=lloop;
  117. end
  118. else
  119. begin
  120. truelabel:=lloop;
  121. falselabel:=lbreak;
  122. end;
  123. rg.cleartempgen;
  124. secondpass(left);
  125. maketojumpbool(exprasmlist,left,lr_load_regvars);
  126. cg.a_label(exprasmlist,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. tcgIFNODE
  136. *****************************************************************************}
  137. procedure tcgifnode.pass_2;
  138. var
  139. hl,otlabel,oflabel : tasmlabel;
  140. org_regvar_loaded,
  141. then_regvar_loaded,
  142. else_regvar_loaded : regvar_booleanarray;
  143. org_list,
  144. then_list,
  145. else_list : taasmoutput;
  146. begin
  147. otlabel:=truelabel;
  148. oflabel:=falselabel;
  149. objectlibrary.getlabel(truelabel);
  150. objectlibrary.getlabel(falselabel);
  151. rg.cleartempgen;
  152. secondpass(left);
  153. { save regvars loaded in the beginning so that we can restore them }
  154. { when processing the else-block }
  155. if cs_regalloc in aktglobalswitches then
  156. begin
  157. org_list := exprasmlist;
  158. exprasmlist := taasmoutput.create;
  159. end;
  160. maketojumpbool(exprasmlist,left,lr_dont_load_regvars);
  161. if cs_regalloc in aktglobalswitches then
  162. org_regvar_loaded := rg.regvar_loaded;
  163. if assigned(right) then
  164. begin
  165. cg.a_label(exprasmlist,truelabel);
  166. rg.cleartempgen;
  167. secondpass(right);
  168. end;
  169. { save current asmlist (previous instructions + then-block) and }
  170. { loaded regvar state and create new clean ones }
  171. if cs_regalloc in aktglobalswitches then
  172. begin
  173. then_regvar_loaded := rg.regvar_loaded;
  174. rg.regvar_loaded := org_regvar_loaded;
  175. then_list := exprasmlist;
  176. exprasmlist := taasmoutput.create;
  177. end;
  178. if assigned(t1) then
  179. begin
  180. if assigned(right) then
  181. begin
  182. objectlibrary.getlabel(hl);
  183. { do go back to if line !! }
  184. if not(cs_regalloc in aktglobalswitches) then
  185. aktfilepos:=exprasmList.getlasttaifilepos^
  186. else
  187. aktfilepos:=then_list.getlasttaifilepos^;
  188. cg.a_jmp_always(exprasmlist,hl);
  189. end;
  190. cg.a_label(exprasmlist,falselabel);
  191. rg.cleartempgen;
  192. secondpass(t1);
  193. { save current asmlist (previous instructions + else-block) }
  194. { and loaded regvar state and create a new clean list }
  195. if cs_regalloc in aktglobalswitches then
  196. begin
  197. else_regvar_loaded := rg.regvar_loaded;
  198. else_list := exprasmlist;
  199. exprasmlist := taasmoutput.create;
  200. end;
  201. if assigned(right) then
  202. cg.a_label(exprasmlist,hl);
  203. end
  204. else
  205. begin
  206. if cs_regalloc in aktglobalswitches then
  207. begin
  208. else_regvar_loaded := rg.regvar_loaded;
  209. else_list := exprasmlist;
  210. exprasmlist := taasmoutput.create;
  211. end;
  212. cg.a_label(exprasmlist,falselabel);
  213. end;
  214. if not(assigned(right)) then
  215. begin
  216. cg.a_label(exprasmlist,truelabel);
  217. end;
  218. if cs_regalloc in aktglobalswitches then
  219. begin
  220. { add loads of regvars at the end of the then- and else-blocks }
  221. { so that at the end of both blocks the same regvars are loaded }
  222. { no else block? }
  223. if not assigned(t1) then
  224. sync_regvars(org_list,then_list,org_regvar_loaded,
  225. then_regvar_loaded)
  226. { no then block? }
  227. else if not assigned(right) then
  228. sync_regvars(org_list,else_list,org_regvar_loaded,
  229. else_regvar_loaded)
  230. { both else and then blocks }
  231. else
  232. sync_regvars(then_list,else_list,then_regvar_loaded,
  233. else_regvar_loaded);
  234. { add all lists together }
  235. org_list.concatlist(then_list);
  236. then_list.free;
  237. org_list.concatlist(else_list);
  238. else_list.free;
  239. org_list.concatlist(exprasmlist);
  240. exprasmlist.free;
  241. exprasmlist := org_list;
  242. end;
  243. truelabel:=otlabel;
  244. falselabel:=oflabel;
  245. end;
  246. {*****************************************************************************
  247. SecondFor
  248. *****************************************************************************}
  249. procedure tcgfornode.pass_2;
  250. var
  251. l3,oldclabel,oldblabel : tasmlabel;
  252. temptovalue : boolean;
  253. hs : byte;
  254. temp1 : treference;
  255. hop : topcg;
  256. hcond : topcmp;
  257. opsize : tcgsize;
  258. count_var_is_signed : boolean;
  259. begin
  260. oldclabel:=aktcontinuelabel;
  261. oldblabel:=aktbreaklabel;
  262. objectlibrary.getlabel(aktcontinuelabel);
  263. objectlibrary.getlabel(aktbreaklabel);
  264. objectlibrary.getlabel(l3);
  265. { only calculate reference }
  266. rg.cleartempgen;
  267. secondpass(t2);
  268. hs := t2.resulttype.def.size;
  269. opsize := def_cgsize(t2.resulttype.def);
  270. { first set the to value
  271. because the count var can be in the expression !! }
  272. rg.cleartempgen;
  273. secondpass(right);
  274. { calculate pointer value and check if changeable and if so }
  275. { load into temporary variable }
  276. if right.nodetype<>ordconstn then
  277. begin
  278. tg.GetTemp(exprasmlist,hs,tt_normal,temp1);
  279. temptovalue:=true;
  280. if (right.location.loc=LOC_REGISTER) or
  281. (right.location.loc=LOC_CREGISTER) then
  282. begin
  283. cg.a_load_reg_ref(exprasmlist,opsize,
  284. right.location.register,temp1);
  285. rg.ungetregister(exprasmlist,right.location.register);
  286. end
  287. else
  288. cg.g_concatcopy(exprasmlist,right.location.reference,temp1,
  289. hs,true,false);
  290. end
  291. else
  292. temptovalue:=false;
  293. { produce start assignment }
  294. rg.cleartempgen;
  295. secondpass(left);
  296. count_var_is_signed:=is_signed(t2.resulttype.def);
  297. if nf_backward in flags then
  298. if count_var_is_signed then
  299. hcond:=OC_LT
  300. else
  301. hcond:=OC_B
  302. else
  303. if count_var_is_signed then
  304. hcond:=OC_GT
  305. else
  306. hcond:=OC_A;
  307. load_all_regvars(exprasmlist);
  308. if temptovalue then
  309. begin
  310. cg.a_cmp_ref_loc_label(exprasmlist,opsize,hcond,
  311. temp1,t2.location,aktbreaklabel);
  312. end
  313. else
  314. begin
  315. if nf_testatbegin in flags then
  316. begin
  317. cg.a_cmp_const_loc_label(exprasmlist,opsize,hcond,
  318. aword(tordconstnode(right).value),
  319. t2.location,aktbreaklabel);
  320. end;
  321. end;
  322. if nf_backward in flags then
  323. hop:=OP_ADD
  324. else
  325. hop:=OP_SUB;
  326. cg.a_op_const_loc(exprasmlist,hop,1,t2.location);
  327. if not(cs_littlesize in aktglobalswitches) then
  328. { align loop target }
  329. exprasmList.concat(Tai_align.Create(aktalignment.loopalign));
  330. cg.a_label(exprasmlist,l3);
  331. { according to count direction DEC or INC... }
  332. if nf_backward in flags then
  333. hop:=OP_SUB
  334. else
  335. hop:=OP_ADD;
  336. cg.a_op_const_loc(exprasmlist,hop,1,t2.location);
  337. { help register must not be in instruction block }
  338. rg.cleartempgen;
  339. if assigned(t1) then
  340. begin
  341. secondpass(t1);
  342. load_all_regvars(exprasmlist);
  343. end;
  344. cg.a_label(exprasmlist,aktcontinuelabel);
  345. { makes no problems there }
  346. rg.cleartempgen;
  347. if nf_backward in flags then
  348. if count_var_is_signed then
  349. hcond:=OC_GT
  350. else
  351. hcond:=OC_A
  352. else
  353. if count_var_is_signed then
  354. hcond:=OC_LT
  355. else
  356. hcond:=OC_B;
  357. load_all_regvars(exprasmlist);
  358. { produce comparison and the corresponding }
  359. { jump }
  360. if temptovalue then
  361. begin
  362. cg.a_cmp_ref_loc_label(exprasmlist,opsize,hcond,temp1,
  363. t2.location,l3);
  364. end
  365. else
  366. begin
  367. cg.a_cmp_const_loc_label(exprasmlist,opsize,hcond,
  368. aword(tordconstnode(right).value),t2.location,l3);
  369. end;
  370. if temptovalue then
  371. tg.ungetiftemp(exprasmlist,temp1);
  372. { this is the break label: }
  373. cg.a_label(exprasmlist,aktbreaklabel);
  374. aktcontinuelabel:=oldclabel;
  375. aktbreaklabel:=oldblabel;
  376. { a break/continue in a for block can't be seen outside }
  377. flowcontrol:=flowcontrol-[fc_break,fc_continue];
  378. end;
  379. {*****************************************************************************
  380. SecondExitN
  381. *****************************************************************************}
  382. procedure tcgexitnode.pass_2;
  383. var
  384. {op : tasmop;
  385. s : topsize;}
  386. otlabel,oflabel : tasmlabel;
  387. cgsize : tcgsize;
  388. hreg : tregister;
  389. allocated_acc,
  390. allocated_acchigh: boolean;
  391. label
  392. do_jmp;
  393. begin
  394. include(flowcontrol,fc_exit);
  395. if assigned(left) then
  396. begin
  397. if onlyassign then
  398. begin
  399. { just do a normal assignment followed by exit }
  400. secondpass(left);
  401. cg.a_jmp_always(exprasmlist,aktexitlabel);
  402. end
  403. else
  404. begin
  405. allocated_acc := false;
  406. allocated_acchigh := false;
  407. otlabel:=truelabel;
  408. oflabel:=falselabel;
  409. objectlibrary.getlabel(truelabel);
  410. objectlibrary.getlabel(falselabel);
  411. secondpass(left);
  412. { increment reference counter, this is
  413. useless for string constants }
  414. if (left.resulttype.def.needs_inittable) and
  415. (left.nodetype<>stringconstn) then
  416. cg.g_incrrefcount(exprasmlist,left.resulttype.def,left.location.reference);
  417. { the result of left is not needed anymore after this
  418. node }
  419. location_freetemp(exprasmlist,left.location);
  420. location_release(exprasmlist,left.location);
  421. case left.location.loc of
  422. LOC_FPUREGISTER :
  423. goto do_jmp;
  424. {$ifdef cpuflags}
  425. LOC_FLAGS :
  426. begin
  427. cg.a_reg_alloc(exprasmlist,accumulator);
  428. allocated_acc := true;
  429. cg.g_flags2reg(exprasmlist,OS_INT,left.location.resflags,accumulator);
  430. goto do_jmp;
  431. end;
  432. {$endif cpuflags}
  433. LOC_JUMP :
  434. begin
  435. cg.a_reg_alloc(exprasmlist,accumulator);
  436. { get an 8-bit register }
  437. hreg:=rg.makeregsize(accumulator,OS_8);
  438. allocated_acc := true;
  439. cg.a_label(exprasmlist,truelabel);
  440. cg.a_load_const_reg(exprasmlist,OS_8,1,hreg);
  441. cg.a_jmp_always(exprasmlist,aktexit2label);
  442. cg.a_label(exprasmlist,falselabel);
  443. cg.a_load_const_reg(exprasmlist,OS_8,0,hreg);
  444. goto do_jmp;
  445. end;
  446. end;
  447. case aktprocdef.rettype.def.deftype of
  448. pointerdef,
  449. procvardef :
  450. begin
  451. cg.a_reg_alloc(exprasmlist,accumulator);
  452. allocated_acc := true;
  453. cg.a_load_loc_reg(exprasmlist,left.location,accumulator);
  454. end;
  455. floatdef :
  456. begin
  457. {$ifndef i386}
  458. cg.a_reg_alloc(exprasmlist,FPU_RESULT_REG);
  459. {$endif not i386}
  460. cg.a_loadfpu_loc_reg(exprasmlist,left.location,FPU_RESULT_REG);
  461. end;
  462. else
  463. begin
  464. cgsize:=def_cgsize(aktprocdef.rettype.def);
  465. cg.a_reg_alloc(exprasmlist,accumulator);
  466. allocated_acc := true;
  467. {$ifndef cpu64bit}
  468. if cgsize in [OS_64,OS_S64] then
  469. begin
  470. cg.a_reg_alloc(exprasmlist,accumulatorhigh);
  471. allocated_acchigh := true;
  472. cg64.a_load64_loc_reg(exprasmlist,left.location,
  473. joinreg64(accumulator,accumulatorhigh));
  474. end
  475. else
  476. {$endif cpu64bit}
  477. begin
  478. hreg:=rg.makeregsize(accumulator,cgsize);
  479. cg.a_load_loc_reg(exprasmlist,left.location,hreg);
  480. end;
  481. end;
  482. end;
  483. do_jmp:
  484. truelabel:=otlabel;
  485. falselabel:=oflabel;
  486. cg.a_jmp_always(exprasmlist,aktexit2label);
  487. if allocated_acc then
  488. cg.a_reg_dealloc(exprasmlist,accumulator);
  489. {$ifndef cpu64bit}
  490. if allocated_acchigh then
  491. cg.a_reg_dealloc(exprasmlist,accumulatorhigh);
  492. {$endif cpu64bit}
  493. {$ifndef i386}
  494. if (aktprocdef.rettype.def.deftype = floatdef) then
  495. cg.a_reg_dealloc(exprasmlist,FPU_RESULT_REG);
  496. {$endif not i386}
  497. end;
  498. end
  499. else
  500. cg.a_jmp_always(exprasmlist,aktexitlabel);
  501. end;
  502. {*****************************************************************************
  503. SecondBreakN
  504. *****************************************************************************}
  505. procedure tcgbreaknode.pass_2;
  506. begin
  507. include(flowcontrol,fc_break);
  508. if aktbreaklabel<>nil then
  509. begin
  510. load_all_regvars(exprasmlist);
  511. cg.a_jmp_always(exprasmlist,aktbreaklabel)
  512. end
  513. else
  514. CGMessage(cg_e_break_not_allowed);
  515. end;
  516. {*****************************************************************************
  517. SecondContinueN
  518. *****************************************************************************}
  519. procedure tcgcontinuenode.pass_2;
  520. begin
  521. include(flowcontrol,fc_continue);
  522. if aktcontinuelabel<>nil then
  523. begin
  524. load_all_regvars(exprasmlist);
  525. cg.a_jmp_always(exprasmlist,aktcontinuelabel)
  526. end
  527. else
  528. CGMessage(cg_e_continue_not_allowed);
  529. end;
  530. {*****************************************************************************
  531. SecondGoto
  532. *****************************************************************************}
  533. procedure tcggotonode.pass_2;
  534. begin
  535. load_all_regvars(exprasmlist);
  536. cg.a_jmp_always(exprasmlist,labsym.lab)
  537. end;
  538. {*****************************************************************************
  539. SecondLabel
  540. *****************************************************************************}
  541. procedure tcglabelnode.pass_2;
  542. begin
  543. load_all_regvars(exprasmlist);
  544. cg.a_label(exprasmlist,labelnr);
  545. rg.cleartempgen;
  546. secondpass(left);
  547. end;
  548. {*****************************************************************************
  549. SecondFail
  550. *****************************************************************************}
  551. procedure tcgfailnode.pass_2;
  552. begin
  553. cg.a_jmp_always(exprasmlist,faillabel);
  554. end;
  555. {*****************************************************************************
  556. SecondRaise
  557. *****************************************************************************}
  558. procedure tcgraisenode.pass_2;
  559. var
  560. a : tasmlabel;
  561. href : treference;
  562. href2: treference;
  563. begin
  564. if assigned(left) then
  565. begin
  566. { multiple parameters? }
  567. if assigned(right) then
  568. begin
  569. { push frame }
  570. if assigned(frametree) then
  571. begin
  572. secondpass(frametree);
  573. if codegenerror then
  574. exit;
  575. cg.a_param_loc(exprasmlist,frametree.location,paramanager.getintparaloc(2));
  576. end
  577. else
  578. cg.a_param_const(exprasmlist,OS_INT,0,paramanager.getintparaloc(2));
  579. { push address }
  580. secondpass(right);
  581. if codegenerror then
  582. exit;
  583. cg.a_param_loc(exprasmlist,right.location,paramanager.getintparaloc(1));
  584. end
  585. else
  586. begin
  587. { get current address }
  588. objectlibrary.getaddrlabel(a);
  589. cg.a_label(exprasmlist,a);
  590. reference_reset_symbol(href2,a,0);
  591. { push current frame }
  592. cg.a_param_reg(exprasmlist,OS_ADDR,FRAME_POINTER_REG,paramanager.getintparaloc(2));
  593. { push current address }
  594. cg.a_paramaddr_ref(exprasmlist,href2,paramanager.getintparaloc(1));
  595. end;
  596. { push object }
  597. secondpass(left);
  598. if codegenerror then
  599. exit;
  600. cg.a_param_loc(exprasmlist,left.location,paramanager.getintparaloc(1));
  601. cg.a_call_name(exprasmlist,'FPC_RAISEEXCEPTION');
  602. end
  603. else
  604. begin
  605. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  606. cg.a_call_name(exprasmlist,'FPC_RERAISE');
  607. end;
  608. end;
  609. {*****************************************************************************
  610. SecondTryExcept
  611. *****************************************************************************}
  612. var
  613. endexceptlabel : tasmlabel;
  614. procedure try_new_exception(list : taasmoutput;var jmpbuf,envbuf, href : treference;
  615. a : aword; exceptlabel : tasmlabel);
  616. begin
  617. tg.GetTemp(list,EXCEPT_BUF_SIZE,tt_persistant,envbuf);
  618. tg.GetTemp(list,JMP_BUF_SIZE,tt_persistant,jmpbuf);
  619. tg.GetTemp(list,sizeof(aword),tt_persistant,href);
  620. new_exception(list, jmpbuf,envbuf, href, a, exceptlabel);
  621. end;
  622. procedure try_free_exception(list : taasmoutput;var jmpbuf, envbuf, href : treference;
  623. a : aword ; endexceptlabel : tasmlabel; onlyfree : boolean);
  624. begin
  625. free_exception(list, jmpbuf, envbuf, href, a, endexceptlabel, onlyfree);
  626. tg.ungettemp(list,href);
  627. tg.Ungettemp(list,jmpbuf);
  628. tg.ungettemp(list,envbuf);
  629. end;
  630. { does the necessary things to clean up the object stack }
  631. { in the except block }
  632. procedure cleanupobjectstack;
  633. begin
  634. cg.a_call_name(exprasmlist,'FPC_POPOBJECTSTACK');
  635. cg.a_param_reg(exprasmlist,OS_ADDR,accumulator,paramanager.getintparaloc(1));
  636. cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
  637. cg.g_maybe_loadself(exprasmlist);
  638. end;
  639. procedure tcgtryexceptnode.pass_2;
  640. var
  641. exceptlabel,doexceptlabel,oldendexceptlabel,
  642. lastonlabel,
  643. exitexceptlabel,
  644. continueexceptlabel,
  645. breakexceptlabel,
  646. exittrylabel,
  647. continuetrylabel,
  648. breaktrylabel,
  649. doobjectdestroy,
  650. doobjectdestroyandreraise,
  651. oldaktexitlabel,
  652. oldaktexit2label,
  653. oldaktcontinuelabel,
  654. oldaktbreaklabel : tasmlabel;
  655. oldflowcontrol,tryflowcontrol,
  656. exceptflowcontrol : tflowcontrol;
  657. tempbuf,tempaddr : treference;
  658. href : treference;
  659. label
  660. errorexit;
  661. begin
  662. oldflowcontrol:=flowcontrol;
  663. flowcontrol:=[];
  664. { this can be called recursivly }
  665. oldendexceptlabel:=endexceptlabel;
  666. { save the old labels for control flow statements }
  667. oldaktexitlabel:=aktexitlabel;
  668. oldaktexit2label:=aktexit2label;
  669. if assigned(aktbreaklabel) then
  670. begin
  671. oldaktcontinuelabel:=aktcontinuelabel;
  672. oldaktbreaklabel:=aktbreaklabel;
  673. end;
  674. { get new labels for the control flow statements }
  675. objectlibrary.getlabel(exittrylabel);
  676. objectlibrary.getlabel(exitexceptlabel);
  677. if assigned(aktbreaklabel) then
  678. begin
  679. objectlibrary.getlabel(breaktrylabel);
  680. objectlibrary.getlabel(continuetrylabel);
  681. objectlibrary.getlabel(breakexceptlabel);
  682. objectlibrary.getlabel(continueexceptlabel);
  683. end;
  684. objectlibrary.getlabel(exceptlabel);
  685. objectlibrary.getlabel(doexceptlabel);
  686. objectlibrary.getlabel(endexceptlabel);
  687. objectlibrary.getlabel(lastonlabel);
  688. try_new_exception(exprasmlist,tempbuf,tempaddr,href,1,exceptlabel);
  689. { try block }
  690. { set control flow labels for the try block }
  691. aktexitlabel:=exittrylabel;
  692. aktexit2label:=exittrylabel;
  693. if assigned(oldaktbreaklabel) then
  694. begin
  695. aktcontinuelabel:=continuetrylabel;
  696. aktbreaklabel:=breaktrylabel;
  697. end;
  698. flowcontrol:=[];
  699. secondpass(left);
  700. tryflowcontrol:=flowcontrol;
  701. if codegenerror then
  702. goto errorexit;
  703. cg.a_label(exprasmlist,exceptlabel);
  704. try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,endexceptlabel,false);
  705. cg.a_label(exprasmlist,doexceptlabel);
  706. { set control flow labels for the except block }
  707. { and the on statements }
  708. aktexitlabel:=exitexceptlabel;
  709. aktexit2label:=exitexceptlabel;
  710. if assigned(oldaktbreaklabel) then
  711. begin
  712. aktcontinuelabel:=continueexceptlabel;
  713. aktbreaklabel:=breakexceptlabel;
  714. end;
  715. flowcontrol:=[];
  716. { on statements }
  717. if assigned(right) then
  718. secondpass(right);
  719. cg.a_label(exprasmlist,lastonlabel);
  720. { default handling except handling }
  721. if assigned(t1) then
  722. begin
  723. { FPC_CATCHES must be called with
  724. 'default handler' flag (=-1)
  725. }
  726. cg.a_param_const(exprasmlist,OS_ADDR,aword(-1),paramanager.getintparaloc(1));
  727. cg.a_call_name(exprasmlist,'FPC_CATCHES');
  728. cg.g_maybe_loadself(exprasmlist);
  729. { the destruction of the exception object must be also }
  730. { guarded by an exception frame }
  731. objectlibrary.getlabel(doobjectdestroy);
  732. objectlibrary.getlabel(doobjectdestroyandreraise);
  733. try_new_exception(exprasmlist,tempbuf,tempaddr,href,1,doobjectdestroyandreraise);
  734. { here we don't have to reset flowcontrol }
  735. { the default and on flowcontrols are handled equal }
  736. secondpass(t1);
  737. exceptflowcontrol:=flowcontrol;
  738. cg.a_label(exprasmlist,doobjectdestroyandreraise);
  739. try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
  740. cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
  741. cg.a_param_reg(exprasmlist, OS_ADDR, accumulator, paramanager.getintparaloc(1));
  742. cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
  743. { we don't need to restore esi here because reraise never }
  744. { returns }
  745. cg.a_call_name(exprasmlist,'FPC_RERAISE');
  746. cg.a_label(exprasmlist,doobjectdestroy);
  747. cleanupobjectstack;
  748. cg.a_jmp_always(exprasmlist,endexceptlabel);
  749. end
  750. else
  751. begin
  752. cg.a_call_name(exprasmlist,'FPC_RERAISE');
  753. exceptflowcontrol:=flowcontrol;
  754. end;
  755. if fc_exit in exceptflowcontrol then
  756. begin
  757. { do some magic for exit in the try block }
  758. cg.a_label(exprasmlist,exitexceptlabel);
  759. { we must also destroy the address frame which guards }
  760. { exception object }
  761. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  762. cg.g_exception_reason_load(exprasmlist,href);
  763. cleanupobjectstack;
  764. cg.a_jmp_always(exprasmlist,oldaktexitlabel);
  765. end;
  766. if fc_break in exceptflowcontrol then
  767. begin
  768. cg.a_label(exprasmlist,breakexceptlabel);
  769. { we must also destroy the address frame which guards }
  770. { exception object }
  771. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  772. cg.g_exception_reason_load(exprasmlist,href);
  773. cleanupobjectstack;
  774. cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
  775. end;
  776. if fc_continue in exceptflowcontrol then
  777. begin
  778. cg.a_label(exprasmlist,continueexceptlabel);
  779. { we must also destroy the address frame which guards }
  780. { exception object }
  781. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  782. cg.g_exception_reason_load(exprasmlist,href);
  783. cleanupobjectstack;
  784. cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
  785. end;
  786. if fc_exit in tryflowcontrol then
  787. begin
  788. { do some magic for exit in the try block }
  789. cg.a_label(exprasmlist,exittrylabel);
  790. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  791. cg.g_exception_reason_load(exprasmlist,href);
  792. cg.a_jmp_always(exprasmlist,oldaktexitlabel);
  793. end;
  794. if fc_break in tryflowcontrol then
  795. begin
  796. cg.a_label(exprasmlist,breaktrylabel);
  797. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  798. cg.g_exception_reason_load(exprasmlist,href);
  799. cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
  800. end;
  801. if fc_continue in tryflowcontrol then
  802. begin
  803. cg.a_label(exprasmlist,continuetrylabel);
  804. cg.a_call_name(exprasmlist,'FPC_POPADDRSTACK');
  805. cg.g_exception_reason_load(exprasmlist,href);
  806. cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
  807. end;
  808. cg.a_label(exprasmlist,endexceptlabel);
  809. errorexit:
  810. { restore all saved labels }
  811. endexceptlabel:=oldendexceptlabel;
  812. { restore the control flow labels }
  813. aktexitlabel:=oldaktexitlabel;
  814. aktexit2label:=oldaktexit2label;
  815. if assigned(oldaktbreaklabel) then
  816. begin
  817. aktcontinuelabel:=oldaktcontinuelabel;
  818. aktbreaklabel:=oldaktbreaklabel;
  819. end;
  820. { return all used control flow statements }
  821. flowcontrol:=oldflowcontrol+exceptflowcontrol+
  822. tryflowcontrol;
  823. end;
  824. procedure tcgonnode.pass_2;
  825. var
  826. nextonlabel,
  827. exitonlabel,
  828. continueonlabel,
  829. breakonlabel,
  830. oldaktexitlabel,
  831. oldaktexit2label,
  832. oldaktcontinuelabel,
  833. doobjectdestroyandreraise,
  834. doobjectdestroy,
  835. oldaktbreaklabel : tasmlabel;
  836. ref : treference;
  837. oldflowcontrol : tflowcontrol;
  838. tempbuf,tempaddr : treference;
  839. href : treference;
  840. href2: treference;
  841. begin
  842. oldflowcontrol:=flowcontrol;
  843. flowcontrol:=[];
  844. objectlibrary.getlabel(nextonlabel);
  845. { send the vmt parameter }
  846. reference_reset_symbol(href2,objectlibrary.newasmsymbol(excepttype.vmt_mangledname),0);
  847. cg.a_paramaddr_ref(exprasmlist,href2,paramanager.getintparaloc(1));
  848. cg.a_call_name(exprasmlist,'FPC_CATCHES');
  849. { is it this catch? No. go to next onlabel }
  850. cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,accumulator,nextonlabel);
  851. ref.symbol:=nil;
  852. tg.GetTemp(exprasmlist,pointer_size,tt_normal,ref);
  853. { what a hack ! }
  854. if assigned(exceptsymtable) then
  855. tvarsym(exceptsymtable.symindex.first).address:=ref.offset;
  856. cg.a_load_reg_ref(exprasmlist, OS_ADDR, accumulator, ref);
  857. { in the case that another exception is risen }
  858. { we've to destroy the old one }
  859. objectlibrary.getlabel(doobjectdestroyandreraise);
  860. { call setjmp, and jump to finally label on non-zero result }
  861. try_new_exception(exprasmlist,tempbuf,tempaddr,href,1,doobjectdestroyandreraise);
  862. if assigned(right) then
  863. begin
  864. oldaktexitlabel:=aktexitlabel;
  865. oldaktexit2label:=aktexit2label;
  866. objectlibrary.getlabel(exitonlabel);
  867. aktexitlabel:=exitonlabel;
  868. aktexit2label:=exitonlabel;
  869. if assigned(aktbreaklabel) then
  870. begin
  871. oldaktcontinuelabel:=aktcontinuelabel;
  872. oldaktbreaklabel:=aktbreaklabel;
  873. objectlibrary.getlabel(breakonlabel);
  874. objectlibrary.getlabel(continueonlabel);
  875. aktcontinuelabel:=continueonlabel;
  876. aktbreaklabel:=breakonlabel;
  877. end;
  878. { esi is destroyed by FPC_CATCHES }
  879. cg.g_maybe_loadself(exprasmlist);
  880. secondpass(right);
  881. end;
  882. objectlibrary.getlabel(doobjectdestroy);
  883. cg.a_label(exprasmlist,doobjectdestroyandreraise);
  884. try_free_exception(exprasmlist,tempbuf,tempaddr,href,0,doobjectdestroy,false);
  885. cg.a_call_name(exprasmlist,'FPC_POPSECONDOBJECTSTACK');
  886. cg.a_param_reg(exprasmlist, OS_ADDR, accumulator, paramanager.getintparaloc(1));
  887. cg.a_call_name(exprasmlist,'FPC_DESTROYEXCEPTION');
  888. { we don't need to restore esi here because reraise never }
  889. { returns }
  890. cg.a_call_name(exprasmlist,'FPC_RERAISE');
  891. cg.a_label(exprasmlist,doobjectdestroy);
  892. cleanupobjectstack;
  893. { clear some stuff }
  894. tg.ungetiftemp(exprasmlist,ref);
  895. cg.a_jmp_always(exprasmlist,endexceptlabel);
  896. if assigned(right) then
  897. begin
  898. { special handling for control flow instructions }
  899. if fc_exit in flowcontrol then
  900. begin
  901. { the address and object pop does secondtryexcept }
  902. cg.a_label(exprasmlist,exitonlabel);
  903. cg.a_jmp_always(exprasmlist,oldaktexitlabel);
  904. end;
  905. if fc_break in flowcontrol then
  906. begin
  907. { the address and object pop does secondtryexcept }
  908. cg.a_label(exprasmlist,breakonlabel);
  909. cg.a_jmp_always(exprasmlist,oldaktbreaklabel);
  910. end;
  911. if fc_continue in flowcontrol then
  912. begin
  913. { the address and object pop does secondtryexcept }
  914. cg.a_label(exprasmlist,continueonlabel);
  915. cg.a_jmp_always(exprasmlist,oldaktcontinuelabel);
  916. end;
  917. aktexitlabel:=oldaktexitlabel;
  918. aktexit2label:=oldaktexit2label;
  919. if assigned(oldaktbreaklabel) then
  920. begin
  921. aktcontinuelabel:=oldaktcontinuelabel;
  922. aktbreaklabel:=oldaktbreaklabel;
  923. end;
  924. end;
  925. cg.a_label(exprasmlist,nextonlabel);
  926. flowcontrol:=oldflowcontrol+flowcontrol;
  927. { next on node }
  928. if assigned(left) then
  929. begin
  930. rg.cleartempgen;
  931. secondpass(left);
  932. end;
  933. end;
  934. {*****************************************************************************
  935. SecondTryFinally
  936. *****************************************************************************}
  937. procedure tcgtryfinallynode.pass_2;
  938. var
  939. reraiselabel,
  940. finallylabel,
  941. endfinallylabel,
  942. exitfinallylabel,
  943. continuefinallylabel,
  944. breakfinallylabel,
  945. oldaktexitlabel,
  946. oldaktexit2label,
  947. oldaktcontinuelabel,
  948. oldaktbreaklabel : tasmlabel;
  949. oldflowcontrol,tryflowcontrol : tflowcontrol;
  950. decconst : longint;
  951. tempbuf,tempaddr : treference;
  952. href : treference;
  953. begin
  954. { check if child nodes do a break/continue/exit }
  955. oldflowcontrol:=flowcontrol;
  956. flowcontrol:=[];
  957. objectlibrary.getlabel(finallylabel);
  958. objectlibrary.getlabel(endfinallylabel);
  959. objectlibrary.getlabel(reraiselabel);
  960. { the finally block must catch break, continue and exit }
  961. { statements }
  962. oldaktexitlabel:=aktexitlabel;
  963. oldaktexit2label:=aktexit2label;
  964. objectlibrary.getlabel(exitfinallylabel);
  965. aktexitlabel:=exitfinallylabel;
  966. aktexit2label:=exitfinallylabel;
  967. if assigned(aktbreaklabel) then
  968. begin
  969. oldaktcontinuelabel:=aktcontinuelabel;
  970. oldaktbreaklabel:=aktbreaklabel;
  971. objectlibrary.getlabel(breakfinallylabel);
  972. objectlibrary.getlabel(continuefinallylabel);
  973. aktcontinuelabel:=continuefinallylabel;
  974. aktbreaklabel:=breakfinallylabel;
  975. end;
  976. { call setjmp, and jump to finally label on non-zero result }
  977. try_new_exception(exprasmlist,tempbuf,tempaddr,href,1,finallylabel);
  978. { try code }
  979. if assigned(left) then
  980. begin
  981. secondpass(left);
  982. tryflowcontrol:=flowcontrol;
  983. if codegenerror then
  984. exit;
  985. end;
  986. cg.a_label(exprasmlist,finallylabel);
  987. { just free the frame information }
  988. try_free_exception(exprasmlist,tempbuf,tempaddr,href,1,finallylabel,true);
  989. { finally code }
  990. flowcontrol:=[];
  991. secondpass(right);
  992. if flowcontrol<>[] then
  993. CGMessage(cg_e_control_flow_outside_finally);
  994. if codegenerror then
  995. exit;
  996. { the value should now be in the exception handler }
  997. cg.g_exception_reason_load(exprasmlist,href);
  998. cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,accumulator,endfinallylabel);
  999. cg.a_op_const_reg(exprasmlist,OP_SUB,1,accumulator);
  1000. cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,accumulator,reraiselabel);
  1001. if fc_exit in tryflowcontrol then
  1002. begin
  1003. cg.a_op_const_reg(exprasmlist,OP_SUB,1,accumulator);
  1004. cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,accumulator,oldaktexitlabel);
  1005. decconst:=1;
  1006. end
  1007. else
  1008. decconst:=2;
  1009. if fc_break in tryflowcontrol then
  1010. begin
  1011. cg.a_op_const_reg(exprasmlist,OP_SUB,decconst,accumulator);
  1012. cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,accumulator,oldaktbreaklabel);
  1013. decconst:=1;
  1014. end
  1015. else
  1016. inc(decconst);
  1017. if fc_continue in tryflowcontrol then
  1018. begin
  1019. cg.a_op_const_reg(exprasmlist,OP_SUB,decconst,accumulator);
  1020. cg.a_cmp_const_reg_label(exprasmlist,OS_S32,OC_EQ,0,accumulator,oldaktcontinuelabel);
  1021. end;
  1022. cg.a_label(exprasmlist,reraiselabel);
  1023. cg.a_call_name(exprasmlist,'FPC_RERAISE');
  1024. { do some magic for exit,break,continue in the try block }
  1025. if fc_exit in tryflowcontrol then
  1026. begin
  1027. cg.a_label(exprasmlist,exitfinallylabel);
  1028. cg.g_exception_reason_load(exprasmlist,href);
  1029. cg.g_exception_reason_save_const(exprasmlist,href,2);
  1030. cg.a_jmp_always(exprasmlist,finallylabel);
  1031. end;
  1032. if fc_break in tryflowcontrol then
  1033. begin
  1034. cg.a_label(exprasmlist,breakfinallylabel);
  1035. cg.g_exception_reason_load(exprasmlist,href);
  1036. cg.g_exception_reason_save_const(exprasmlist,href,3);
  1037. cg.a_jmp_always(exprasmlist,finallylabel);
  1038. end;
  1039. if fc_continue in tryflowcontrol then
  1040. begin
  1041. cg.a_label(exprasmlist,continuefinallylabel);
  1042. cg.g_exception_reason_load(exprasmlist,href);
  1043. cg.g_exception_reason_save_const(exprasmlist,href,4);
  1044. cg.a_jmp_always(exprasmlist,finallylabel);
  1045. end;
  1046. cg.a_label(exprasmlist,endfinallylabel);
  1047. aktexitlabel:=oldaktexitlabel;
  1048. aktexit2label:=oldaktexit2label;
  1049. if assigned(aktbreaklabel) then
  1050. begin
  1051. aktcontinuelabel:=oldaktcontinuelabel;
  1052. aktbreaklabel:=oldaktbreaklabel;
  1053. end;
  1054. flowcontrol:=oldflowcontrol+tryflowcontrol;
  1055. end;
  1056. begin
  1057. cwhilerepeatnode:=tcgwhilerepeatnode;
  1058. cifnode:=tcgifnode;
  1059. cfornode:=tcgfornode;
  1060. cexitnode:=tcgexitnode;
  1061. cbreaknode:=tcgbreaknode;
  1062. ccontinuenode:=tcgcontinuenode;
  1063. cgotonode:=tcggotonode;
  1064. clabelnode:=tcglabelnode;
  1065. cfailnode:=tcgfailnode;
  1066. craisenode:=tcgraisenode;
  1067. ctryexceptnode:=tcgtryexceptnode;
  1068. ctryfinallynode:=tcgtryfinallynode;
  1069. connode:=tcgonnode;
  1070. end.
  1071. {
  1072. $Log$
  1073. Revision 1.43 2002-09-30 07:00:45 florian
  1074. * fixes to common code to get the alpha compiler compiled applied
  1075. Revision 1.42 2002/09/07 15:25:02 peter
  1076. * old logs removed and tabs fixed
  1077. Revision 1.41 2002/09/01 18:47:00 peter
  1078. * assignn check in exitnode changed to use a separate boolean as the
  1079. assignn can be changed to a calln
  1080. Revision 1.40 2002/09/01 14:41:47 peter
  1081. * increase refcount in exit(arg) for arg
  1082. Revision 1.39 2002/08/24 18:41:52 peter
  1083. * fixed wrong label in jump of except block (was also in n386flw wrong)
  1084. * fixed wrong pushing of raise parameters
  1085. * fixed wrong compare in finally
  1086. Revision 1.38 2002/08/23 16:14:48 peter
  1087. * tempgen cleanup
  1088. * tt_noreuse temp type added that will be used in genentrycode
  1089. Revision 1.37 2002/08/19 19:36:43 peter
  1090. * More fixes for cross unit inlining, all tnodes are now implemented
  1091. * Moved pocall_internconst to po_internconst because it is not a
  1092. calling type at all and it conflicted when inlining of these small
  1093. functions was requested
  1094. Revision 1.36 2002/08/15 15:15:55 carl
  1095. * jmpbuf size allocation for exceptions is now cpu specific (as it should)
  1096. * more generic nodes for maths
  1097. * several fixes for better m68k support
  1098. Revision 1.35 2002/08/13 18:01:52 carl
  1099. * rename swatoperands to swapoperands
  1100. + m68k first compilable version (still needs a lot of testing):
  1101. assembler generator, system information , inline
  1102. assembler reader.
  1103. Revision 1.34 2002/08/11 14:32:26 peter
  1104. * renamed current_library to objectlibrary
  1105. Revision 1.33 2002/08/11 13:24:11 peter
  1106. * saving of asmsymbols in ppu supported
  1107. * asmsymbollist global is removed and moved into a new class
  1108. tasmlibrarydata that will hold the info of a .a file which
  1109. corresponds with a single module. Added librarydata to tmodule
  1110. to keep the library info stored for the module. In the future the
  1111. objectfiles will also be stored to the tasmlibrarydata class
  1112. * all getlabel/newasmsymbol and friends are moved to the new class
  1113. Revision 1.32 2002/08/09 19:10:59 carl
  1114. * fixed generic exception management
  1115. Revision 1.31 2002/08/04 19:06:41 carl
  1116. + added generic exception support (still does not work!)
  1117. + more documentation
  1118. Revision 1.30 2002/07/27 19:53:51 jonas
  1119. + generic implementation of tcg.g_flags2ref()
  1120. * tcg.flags2xxx() now also needs a size parameter
  1121. Revision 1.29 2002/07/25 17:56:29 carl
  1122. + FPURESULTREG -> FPU_RESULT_REG
  1123. Revision 1.28 2002/07/21 06:58:49 daniel
  1124. * Changed booleans into flags
  1125. Revision 1.27 2002/07/20 12:54:53 daniel
  1126. * Optimized the code generated for for nodes. The shootout/nestloop benchmark
  1127. now runs 5% faster on my computer.
  1128. Revision 1.26 2002/07/20 11:57:54 florian
  1129. * types.pas renamed to defbase.pas because D6 contains a types
  1130. unit so this would conflicts if D6 programms are compiled
  1131. + Willamette/SSE2 instructions to assembler added
  1132. Revision 1.25 2002/07/20 11:15:51 daniel
  1133. * The for node does a check if the first comparision can be skipped. I moved
  1134. the check from the second pass to the resulttype pass. The advantage is
  1135. that the state tracker can now decide to skip the first comparision too.
  1136. Revision 1.24 2002/07/20 08:14:24 daniel
  1137. * Loops should not be aligned when optimizing for size
  1138. Revision 1.23 2002/07/19 11:41:35 daniel
  1139. * State tracker work
  1140. * The whilen and repeatn are now completely unified into whilerepeatn. This
  1141. allows the state tracker to change while nodes automatically into
  1142. repeat nodes.
  1143. * Resulttypepass improvements to the notn. 'not not a' is optimized away and
  1144. 'not(a>b)' is optimized into 'a<=b'.
  1145. * Resulttypepass improvements to the whilerepeatn. 'while not a' is optimized
  1146. by removing the notn and later switchting the true and falselabels. The
  1147. same is done with 'repeat until not a'.
  1148. Revision 1.22 2002/07/04 20:43:01 florian
  1149. * first x86-64 patches
  1150. }