ncgbas.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. {
  2. Copyright (c) 2000-2002 by Florian Klaempfl
  3. This unit implements some basic nodes
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit ncgbas;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. aasmtai,aasmdata,
  23. cpubase,cgutils,
  24. node,nbas;
  25. type
  26. tcgnothingnode = class(tnothingnode)
  27. procedure pass_generate_code;override;
  28. end;
  29. tcgasmnode = class(tasmnode)
  30. protected
  31. procedure ResolveRef(const filepos: tfileposinfo; var op:toper); virtual;
  32. public
  33. procedure pass_generate_code;override;
  34. end;
  35. tcgstatementnode = class(tstatementnode)
  36. procedure pass_generate_code;override;
  37. end;
  38. tcgblocknode = class(tblocknode)
  39. procedure pass_generate_code;override;
  40. end;
  41. tcgtempcreatenode = class(ttempcreatenode)
  42. procedure pass_generate_code;override;
  43. end;
  44. tcgtemprefnode = class(ttemprefnode)
  45. procedure pass_generate_code;override;
  46. { Changes the location of this temp to ref. Useful when assigning }
  47. { another temp to this one. The current location will be freed. }
  48. { Can only be called in pass 2 (since earlier, the temp location }
  49. { isn't known yet) }
  50. procedure changelocation(const ref: treference);
  51. end;
  52. tcgtempdeletenode = class(ttempdeletenode)
  53. procedure pass_generate_code;override;
  54. end;
  55. implementation
  56. uses
  57. globals,systems,
  58. cutils,verbose,
  59. aasmbase,aasmcpu,
  60. symsym,symconst,symdef,defutil,
  61. nflw,pass_2,ncgutil,
  62. cgbase,cgobj,hlcgobj,
  63. procinfo,
  64. cpuinfo,
  65. tgobj
  66. ;
  67. {*****************************************************************************
  68. TNOTHING
  69. *****************************************************************************}
  70. procedure tcgnothingnode.pass_generate_code;
  71. begin
  72. location_reset(location,LOC_VOID,OS_NO);
  73. { avoid an abstract rte }
  74. end;
  75. {*****************************************************************************
  76. TSTATEMENTNODE
  77. *****************************************************************************}
  78. procedure tcgstatementnode.pass_generate_code;
  79. var
  80. hp : tstatementnode;
  81. begin
  82. location_reset(location,LOC_VOID,OS_NO);
  83. hp:=self;
  84. while assigned(hp) do
  85. begin
  86. if assigned(hp.left) then
  87. begin
  88. secondpass(hp.left);
  89. { Compiler inserted blocks can return values }
  90. location_copy(hp.location,hp.left.location);
  91. end;
  92. hp:=tstatementnode(hp.right);
  93. end;
  94. end;
  95. {*****************************************************************************
  96. TASMNODE
  97. *****************************************************************************}
  98. procedure tcgasmnode.ResolveRef(const filepos: tfileposinfo; var op:toper);
  99. var
  100. sym : tabstractnormalvarsym;
  101. {$ifdef x86}
  102. scale : byte;
  103. {$endif x86}
  104. forceref,
  105. getoffset : boolean;
  106. indexreg : tregister;
  107. sofs : longint;
  108. begin
  109. if (op.typ=top_local) then
  110. begin
  111. sofs:=op.localoper^.localsymofs;
  112. indexreg:=op.localoper^.localindexreg;
  113. {$ifdef x86}
  114. scale:=op.localoper^.localscale;
  115. {$endif x86}
  116. getoffset:=op.localoper^.localgetoffset;
  117. forceref:=op.localoper^.localforceref;
  118. sym:=tabstractnormalvarsym(pointer(op.localoper^.localsym));
  119. dispose(op.localoper);
  120. case sym.localloc.loc of
  121. LOC_REFERENCE :
  122. begin
  123. if getoffset then
  124. begin
  125. if indexreg=NR_NO then
  126. begin
  127. op.typ:=top_const;
  128. op.val:=sym.localloc.reference.offset+sofs;
  129. end
  130. else
  131. begin
  132. op.typ:=top_ref;
  133. new(op.ref);
  134. reference_reset_base(op.ref^,indexreg,sym.localloc.reference.offset+sofs,
  135. newalignment(sym.localloc.reference.alignment,sofs));
  136. end;
  137. end
  138. else
  139. begin
  140. op.typ:=top_ref;
  141. new(op.ref);
  142. reference_reset_base(op.ref^,sym.localloc.reference.base,sym.localloc.reference.offset+sofs,
  143. newalignment(sym.localloc.reference.alignment,sofs));
  144. op.ref^.index:=indexreg;
  145. {$ifdef x86}
  146. op.ref^.scalefactor:=scale;
  147. {$endif x86}
  148. end;
  149. end;
  150. LOC_REGISTER :
  151. begin
  152. if getoffset then
  153. MessagePos(filepos,asmr_e_invalid_reference_syntax);
  154. { Subscribed access }
  155. if forceref or
  156. (sofs<>0) then
  157. begin
  158. op.typ:=top_ref;
  159. new(op.ref);
  160. { no idea about the actual alignment }
  161. reference_reset_base(op.ref^,sym.localloc.register,sofs,1);
  162. op.ref^.index:=indexreg;
  163. {$ifdef x86}
  164. op.ref^.scalefactor:=scale;
  165. {$endif x86}
  166. end
  167. else
  168. begin
  169. op.typ:=top_reg;
  170. op.reg:=sym.localloc.register;
  171. end;
  172. end;
  173. LOC_FPUREGISTER,
  174. LOC_MMXREGISTER,
  175. LOC_MMREGISTER :
  176. begin
  177. op.typ:=top_reg;
  178. op.reg:=NR_NO;
  179. if getoffset then
  180. MessagePos(filepos,asmr_e_invalid_reference_syntax);
  181. { Using an MM/FPU register in a reference is not possible }
  182. if forceref or (sofs<>0) then
  183. MessagePos1(filepos,asmr_e_invalid_ref_register,std_regname(sym.localloc.register))
  184. else
  185. op.reg:=sym.localloc.register;
  186. end;
  187. LOC_INVALID :
  188. begin
  189. { in "assembler; nostackframe;" routines, the
  190. funcret loc is set to LOC_INVALID in case the
  191. result is returned via a complex location
  192. (more than one register, ...) }
  193. if (vo_is_funcret in tabstractvarsym(sym).varoptions) then
  194. MessagePos(filepos,asmr_e_complex_function_result_location)
  195. else
  196. internalerror(2012082101);
  197. { recover }
  198. op.typ:=top_reg;
  199. op.reg:=NR_FUNCTION_RETURN_REG;
  200. end;
  201. else
  202. internalerror(201001031);
  203. end;
  204. end;
  205. end;
  206. procedure tcgasmnode.pass_generate_code;
  207. procedure ReLabel(var p:tasmsymbol);
  208. begin
  209. { Only relabel local tasmlabels }
  210. if (p.bind = AB_LOCAL) and
  211. (p is tasmlabel) then
  212. begin
  213. if not assigned(p.altsymbol) then
  214. current_asmdata.GenerateAltSymbol(p);
  215. p:=p.altsymbol;
  216. p.increfs;
  217. end;
  218. end;
  219. var
  220. hp,hp2 : tai;
  221. i : longint;
  222. begin
  223. location_reset(location,LOC_VOID,OS_NO);
  224. if (nf_get_asm_position in flags) then
  225. begin
  226. { Add a marker, to be sure the list is not empty }
  227. current_asmdata.CurrAsmList.concat(tai_marker.create(mark_Position));
  228. currenttai:=tai(current_asmdata.CurrAsmList.last);
  229. exit;
  230. end;
  231. { Switch to the CPU instruction set, specified by the $ASMCPU directive }
  232. current_asmdata.CurrAsmList.Concat(tai_directive.create(asd_cpu,cputypestr[current_settings.asmcputype]));
  233. { Allocate registers used in the assembler block }
  234. { has_registerlist=true means that registers are specified and already allocated }
  235. if (not has_registerlist) then
  236. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  237. if (po_inline in current_procinfo.procdef.procoptions) then
  238. begin
  239. hp:=tai(p_asm.first);
  240. while assigned(hp) do
  241. begin
  242. hp2:=tai(hp.getcopy);
  243. case hp2.typ of
  244. ait_label :
  245. ReLabel(tasmsymbol(tai_label(hp2).labsym));
  246. ait_const :
  247. begin
  248. if assigned(tai_const(hp2).sym) then
  249. ReLabel(tai_const(hp2).sym);
  250. if assigned(tai_const(hp2).endsym) then
  251. ReLabel(tai_const(hp2).endsym);
  252. end;
  253. ait_instruction :
  254. begin
  255. { remove cached insentry, because the new code can
  256. require another less optimized instruction }
  257. {$ifdef i386}
  258. {$ifndef NOAG386BIN}
  259. taicpu(hp2).ResetPass1;
  260. {$endif}
  261. {$endif}
  262. { fixup the references }
  263. for i:=1 to taicpu(hp2).ops do
  264. begin
  265. ResolveRef(taicpu(hp2).fileinfo,taicpu(hp2).oper[i-1]^);
  266. with taicpu(hp2).oper[i-1]^ do
  267. begin
  268. case typ of
  269. top_ref :
  270. begin
  271. if assigned(ref^.symbol) then
  272. ReLabel(ref^.symbol);
  273. if assigned(ref^.relsymbol) then
  274. ReLabel(ref^.relsymbol);
  275. end;
  276. end;
  277. end;
  278. end;
  279. {$ifdef x86}
  280. { can only be checked now that all local operands }
  281. { have been resolved }
  282. taicpu(hp2).CheckIfValid;
  283. {$endif x86}
  284. end;
  285. end;
  286. current_asmdata.CurrAsmList.concat(hp2);
  287. hp:=tai(hp.next);
  288. end;
  289. { restore used symbols }
  290. current_asmdata.ResetAltSymbols;
  291. end
  292. else
  293. begin
  294. hp:=tai(p_asm.first);
  295. while assigned(hp) do
  296. begin
  297. case hp.typ of
  298. ait_instruction :
  299. begin
  300. { remove cached insentry, because the new code can
  301. require another less optimized instruction }
  302. {$ifdef i386}
  303. {$ifndef NOAG386BIN}
  304. taicpu(hp).ResetPass1;
  305. {$endif}
  306. {$endif}
  307. { fixup the references }
  308. for i:=1 to taicpu(hp).ops do
  309. ResolveRef(taicpu(hp).fileinfo,taicpu(hp).oper[i-1]^);
  310. {$ifdef x86}
  311. { can only be checked now that all local operands }
  312. { have been resolved }
  313. taicpu(hp).CheckIfValid;
  314. {$endif x86}
  315. end;
  316. end;
  317. hp:=tai(hp.next);
  318. end;
  319. { insert the list }
  320. current_asmdata.CurrAsmList.concatlist(p_asm);
  321. end;
  322. { Release register used in the assembler block }
  323. if (not has_registerlist) then
  324. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  325. { Switch back to the CPU instruction set of the target CPU }
  326. current_asmdata.CurrAsmList.Concat(tai_directive.create(asd_cpu,cputypestr[current_settings.cputype]));
  327. end;
  328. {*****************************************************************************
  329. TBLOCKNODE
  330. *****************************************************************************}
  331. procedure tcgblocknode.pass_generate_code;
  332. var
  333. hp : tstatementnode;
  334. oldexitlabel : tasmlabel;
  335. oldflowcontrol : tflowcontrol;
  336. begin
  337. location_reset(location,LOC_VOID,OS_NO);
  338. oldflowcontrol:=[];
  339. oldexitlabel:=nil;
  340. { replace exitlabel? }
  341. if nf_block_with_exit in flags then
  342. begin
  343. oldexitlabel:=current_procinfo.CurrExitLabel;
  344. current_asmdata.getjumplabel(current_procinfo.CurrExitLabel);
  345. oldflowcontrol:=flowcontrol;
  346. { the nested block will not span an exit statement of the parent }
  347. exclude(flowcontrol,fc_exit);
  348. end;
  349. { do second pass on left node }
  350. if assigned(left) then
  351. begin
  352. hp:=tstatementnode(left);
  353. while assigned(hp) do
  354. begin
  355. if assigned(hp.left) then
  356. begin
  357. secondpass(hp.left);
  358. location_copy(hp.location,hp.left.location);
  359. end;
  360. location_copy(location,hp.location);
  361. hp:=tstatementnode(hp.right);
  362. end;
  363. end;
  364. { write exitlabel }
  365. if nf_block_with_exit in flags then
  366. begin
  367. cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrExitLabel);
  368. current_procinfo.CurrExitLabel:=oldexitlabel;
  369. { the exit statements inside this block are not exit statements }
  370. { out of the parent }
  371. flowcontrol:=oldflowcontrol+(flowcontrol - [fc_exit]);
  372. end;
  373. end;
  374. {*****************************************************************************
  375. TTEMPCREATENODE
  376. *****************************************************************************}
  377. procedure tcgtempcreatenode.pass_generate_code;
  378. begin
  379. location_reset(location,LOC_VOID,OS_NO);
  380. { if we're secondpassing the same tcgtempcreatenode twice, we have a bug }
  381. if (ti_valid in tempflags) then
  382. internalerror(200108222);
  383. { in case of ti_reference, the location will be initialised using the
  384. location of the tempinitnode once the first temprefnode is processed }
  385. if not(ti_reference in tempflags) then
  386. begin
  387. { get a (persistent) temp }
  388. if is_managed_type(tempinfo^.typedef) and
  389. not(ti_const in tempflags) then
  390. begin
  391. location_reset_ref(tempinfo^.location,LOC_REFERENCE,def_cgsize(tempinfo^.typedef),0);
  392. tg.gethltempmanaged(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.temptype,tempinfo^.location.reference);
  393. if not(ti_nofini in tempflags) then
  394. hlcg.g_finalize(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.location.reference);
  395. end
  396. else if (ti_may_be_in_reg in tempflags) then
  397. begin
  398. location_allocate_register(current_asmdata.CurrAsmList,tempinfo^.location,tempinfo^.typedef,tempinfo^.temptype = tt_persistent);
  399. end
  400. else
  401. begin
  402. location_reset_ref(tempinfo^.location,LOC_REFERENCE,def_cgsize(tempinfo^.typedef),0);
  403. tg.gethltemp(current_asmdata.CurrAsmList,tempinfo^.typedef,size,tempinfo^.temptype,tempinfo^.location.reference);
  404. end;
  405. end;
  406. includetempflag(ti_valid);
  407. if assigned(tempinfo^.tempinitcode) then
  408. includetempflag(ti_executeinitialisation);
  409. end;
  410. {*****************************************************************************
  411. TTEMPREFNODE
  412. *****************************************************************************}
  413. procedure tcgtemprefnode.pass_generate_code;
  414. begin
  415. if ti_executeinitialisation in tempflags then
  416. begin
  417. { avoid recursion }
  418. excludetempflag(ti_executeinitialisation);
  419. secondpass(tempinfo^.tempinitcode);
  420. if (ti_reference in tempflags) then
  421. begin
  422. case tempinfo^.tempinitcode.location.loc of
  423. LOC_CREGISTER,
  424. LOC_CFPUREGISTER,
  425. LOC_CMMREGISTER,
  426. LOC_CSUBSETREG:
  427. begin
  428. { although it's ok if we need this value multiple times
  429. for reading, it's not in case of writing (because the
  430. register could change due to SSA -> storing to the saved
  431. register afterwards would be wrong). }
  432. if not(ti_readonly in tempflags) then
  433. internalerror(2011031407);
  434. end;
  435. { in case reference contains CREGISTERS, that doesn't matter:
  436. we want to write to the location indicated by the current
  437. value of those registers, and we can save those values }
  438. end;
  439. hlcg.g_reference_loc(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.tempinitcode.location,tempinfo^.location);
  440. end;
  441. end;
  442. { check if the temp is valid }
  443. if not(ti_valid in tempflags) then
  444. internalerror(200108231);
  445. location:=tempinfo^.location;
  446. case tempinfo^.location.loc of
  447. LOC_REFERENCE:
  448. begin
  449. { ti_valid should be excluded if it's a normal temp }
  450. end;
  451. LOC_REGISTER,
  452. LOC_FPUREGISTER,
  453. LOC_MMREGISTER :
  454. excludetempflag(ti_valid);
  455. end;
  456. end;
  457. procedure tcgtemprefnode.changelocation(const ref: treference);
  458. begin
  459. { check if the temp is valid }
  460. if not(ti_valid in tempflags) then
  461. internalerror(200306081);
  462. if (tempinfo^.location.loc<>LOC_REFERENCE) then
  463. internalerror(2004020203);
  464. if (tempinfo^.temptype = tt_persistent) then
  465. tg.ChangeTempType(current_asmdata.CurrAsmList,tempinfo^.location.reference,tt_normal);
  466. tg.ungettemp(current_asmdata.CurrAsmList,tempinfo^.location.reference);
  467. tempinfo^.location.reference := ref;
  468. tg.ChangeTempType(current_asmdata.CurrAsmList,tempinfo^.location.reference,tempinfo^.temptype);
  469. { adapt location }
  470. location.reference := ref;
  471. end;
  472. {*****************************************************************************
  473. TTEMPDELETENODE
  474. *****************************************************************************}
  475. procedure tcgtempdeletenode.pass_generate_code;
  476. begin
  477. if ti_reference in tempflags then
  478. begin
  479. { release_to_normal means that the temp will be freed the next
  480. time it's used. However, reference temps reference some other
  481. location that is not managed by this temp and hence cannot be
  482. freed }
  483. if release_to_normal then
  484. internalerror(2011052205);
  485. { so we only mark this temp location as "no longer valid" when
  486. it's deleted (ttempdeletenodes are also used during getcopy, so
  487. we really do need one) }
  488. excludetempflag(ti_valid);
  489. exit;
  490. end;
  491. location_reset(location,LOC_VOID,OS_NO);
  492. { see comments at ti_const declaration: if we initialised this temp with
  493. the value of another temp, that other temp was not freed because the
  494. ti_const flag was set }
  495. if (ti_const in tempflags) and
  496. assigned(tempinfo^.tempinitcode) then
  497. begin
  498. if tempinfo^.tempinitcode.nodetype<>assignn then
  499. internalerror(2016081201);
  500. if tbinarynode(tempinfo^.tempinitcode).right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
  501. tg.ungetiftemp(current_asmdata.CurrAsmList,tbinarynode(tempinfo^.tempinitcode).right.location.reference);
  502. end;
  503. case tempinfo^.location.loc of
  504. LOC_REFERENCE:
  505. begin
  506. if release_to_normal then
  507. tg.ChangeTempType(current_asmdata.CurrAsmList,tempinfo^.location.reference,tt_normal)
  508. else
  509. begin
  510. tg.UnGetTemp(current_asmdata.CurrAsmList,tempinfo^.location.reference);
  511. excludetempflag(ti_valid);
  512. end;
  513. end;
  514. LOC_CREGISTER,
  515. LOC_REGISTER:
  516. begin
  517. if (not(cs_opt_regvar in current_settings.optimizerswitches) or
  518. (pi_has_label in current_procinfo.flags)) and not(ti_no_final_regsync in tempflags) then
  519. begin
  520. { make sure the register allocator doesn't reuse the }
  521. { register e.g. in the middle of a loop }
  522. {$if defined(cpu32bitalu)}
  523. if tempinfo^.location.size in [OS_64,OS_S64] then
  524. begin
  525. cg.a_reg_sync(current_asmdata.CurrAsmList,tempinfo^.location.register64.reghi);
  526. cg.a_reg_sync(current_asmdata.CurrAsmList,tempinfo^.location.register64.reglo);
  527. end
  528. else
  529. {$elseif defined(cpu16bitalu)}
  530. if tempinfo^.location.size in [OS_64,OS_S64] then
  531. begin
  532. cg.a_reg_sync(current_asmdata.CurrAsmList,tempinfo^.location.register64.reghi);
  533. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(tempinfo^.location.register64.reghi));
  534. cg.a_reg_sync(current_asmdata.CurrAsmList,tempinfo^.location.register64.reglo);
  535. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(tempinfo^.location.register64.reglo));
  536. end
  537. else
  538. if tempinfo^.location.size in [OS_32,OS_S32] then
  539. begin
  540. cg.a_reg_sync(current_asmdata.CurrAsmList,tempinfo^.location.register);
  541. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(tempinfo^.location.register));
  542. end
  543. else
  544. {$elseif defined(cpu8bitalu)}
  545. if tempinfo^.location.size in [OS_64,OS_S64] then
  546. begin
  547. cg.a_reg_sync(current_asmdata.CurrAsmList,tempinfo^.location.register64.reghi);
  548. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(tempinfo^.location.register64.reghi));
  549. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(GetNextReg(tempinfo^.location.register64.reghi)));
  550. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(GetNextReg(GetNextReg(tempinfo^.location.register64.reghi))));
  551. cg.a_reg_sync(current_asmdata.CurrAsmList,tempinfo^.location.register64.reglo);
  552. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(tempinfo^.location.register64.reglo));
  553. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(GetNextReg(tempinfo^.location.register64.reglo)));
  554. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(GetNextReg(GetNextReg(tempinfo^.location.register64.reglo))));
  555. end
  556. else
  557. if tempinfo^.location.size in [OS_32,OS_S32] then
  558. begin
  559. cg.a_reg_sync(current_asmdata.CurrAsmList,tempinfo^.location.register);
  560. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(tempinfo^.location.register));
  561. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(GetNextReg(tempinfo^.location.register)));
  562. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(GetNextReg(GetNextReg(tempinfo^.location.register))));
  563. end
  564. else
  565. if tempinfo^.location.size in [OS_16,OS_S16] then
  566. begin
  567. cg.a_reg_sync(current_asmdata.CurrAsmList,tempinfo^.location.register);
  568. cg.a_reg_sync(current_asmdata.CurrAsmList,GetNextReg(tempinfo^.location.register));
  569. end
  570. else
  571. {$endif}
  572. cg.a_reg_sync(current_asmdata.CurrAsmList,tempinfo^.location.register);
  573. end;
  574. if release_to_normal then
  575. tempinfo^.location.loc := LOC_REGISTER
  576. else
  577. excludetempflag(ti_valid);
  578. end;
  579. LOC_CFPUREGISTER,
  580. LOC_FPUREGISTER:
  581. begin
  582. if (not(cs_opt_regvar in current_settings.optimizerswitches) or
  583. (pi_has_label in current_procinfo.flags)) and not(ti_no_final_regsync in tempflags) then
  584. begin
  585. { make sure the register allocator doesn't reuse the }
  586. { register e.g. in the middle of a loop }
  587. cg.a_reg_sync(current_asmdata.CurrAsmList,tempinfo^.location.register);
  588. end;
  589. if release_to_normal then
  590. tempinfo^.location.loc := LOC_FPUREGISTER
  591. else
  592. excludetempflag(ti_valid);
  593. end;
  594. LOC_CMMREGISTER,
  595. LOC_MMREGISTER:
  596. begin
  597. if (not(cs_opt_regvar in current_settings.optimizerswitches) or
  598. (pi_has_label in current_procinfo.flags)) and not(ti_no_final_regsync in tempflags) then
  599. begin
  600. { make sure the register allocator doesn't reuse the }
  601. { register e.g. in the middle of a loop }
  602. cg.a_reg_sync(current_asmdata.CurrAsmList,tempinfo^.location.register);
  603. end;
  604. if release_to_normal then
  605. tempinfo^.location.loc := LOC_MMREGISTER
  606. else
  607. excludetempflag(ti_valid);
  608. end;
  609. else
  610. internalerror(200507161);
  611. end;
  612. end;
  613. begin
  614. cnothingnode:=tcgnothingnode;
  615. casmnode:=tcgasmnode;
  616. cstatementnode:=tcgstatementnode;
  617. cblocknode:=tcgblocknode;
  618. ctempcreatenode:=tcgtempcreatenode;
  619. ctemprefnode:=tcgtemprefnode;
  620. ctempdeletenode:=tcgtempdeletenode;
  621. end.