cg386mem.pas 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl
  4. Generate i386 assembler for in memory related nodes
  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 cg386mem;
  19. interface
  20. uses
  21. tree;
  22. procedure secondloadvmt(var p : ptree);
  23. procedure secondhnewn(var p : ptree);
  24. procedure secondnewn(var p : ptree);
  25. procedure secondhdisposen(var p : ptree);
  26. procedure secondsimplenewdispose(var p : ptree);
  27. procedure secondaddr(var p : ptree);
  28. procedure seconddoubleaddr(var p : ptree);
  29. procedure secondderef(var p : ptree);
  30. procedure secondsubscriptn(var p : ptree);
  31. procedure secondvecn(var p : ptree);
  32. procedure secondselfn(var p : ptree);
  33. procedure secondwith(var p : ptree);
  34. implementation
  35. uses
  36. cobjects,verbose,globals,systems,
  37. symtable,aasm,types,
  38. hcodegen,temp_gen,pass_2,
  39. i386,cgai386,tgeni386;
  40. {*****************************************************************************
  41. SecondLoadVMT
  42. *****************************************************************************}
  43. procedure secondloadvmt(var p : ptree);
  44. begin
  45. p^.location.register:=getregister32;
  46. exprasmlist^.concat(new(pai386,op_csymbol_reg(A_MOV,
  47. S_L,newcsymbol(pobjectdef(pclassrefdef(p^.resulttype)^.definition)^.vmt_mangledname,0),
  48. p^.location.register)));
  49. end;
  50. {*****************************************************************************
  51. SecondHNewN
  52. *****************************************************************************}
  53. procedure secondhnewn(var p : ptree);
  54. begin
  55. end;
  56. {*****************************************************************************
  57. SecondNewN
  58. *****************************************************************************}
  59. procedure secondnewn(var p : ptree);
  60. begin
  61. secondpass(p^.left);
  62. if codegenerror then
  63. exit;
  64. p^.location.register:=p^.left^.location.register;
  65. end;
  66. {*****************************************************************************
  67. SecondDisposeN
  68. *****************************************************************************}
  69. procedure secondhdisposen(var p : ptree);
  70. begin
  71. secondpass(p^.left);
  72. if codegenerror then
  73. exit;
  74. clear_reference(p^.location.reference);
  75. case p^.left^.location.loc of
  76. LOC_REGISTER,
  77. LOC_CREGISTER:
  78. begin
  79. p^.location.reference.index:=getregister32;
  80. exprasmlist^.concat(new(pai386,op_reg_reg(A_MOV,S_L,
  81. p^.left^.location.register,
  82. p^.location.reference.index)));
  83. end;
  84. LOC_MEM,LOC_REFERENCE :
  85. begin
  86. del_reference(p^.left^.location.reference);
  87. p^.location.reference.index:=getregister32;
  88. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,newreference(p^.left^.location.reference),
  89. p^.location.reference.index)));
  90. end;
  91. end;
  92. end;
  93. {*****************************************************************************
  94. SecondNewDispose
  95. *****************************************************************************}
  96. procedure secondsimplenewdispose(var p : ptree);
  97. var
  98. pushed : tpushed;
  99. r : preference;
  100. begin
  101. secondpass(p^.left);
  102. if codegenerror then
  103. exit;
  104. pushusedregisters(pushed,$ff);
  105. { determines the size of the mem block }
  106. push_int(ppointerdef(p^.left^.resulttype)^.definition^.size);
  107. { push pointer adress }
  108. case p^.left^.location.loc of
  109. LOC_CREGISTER : exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,
  110. p^.left^.location.register)));
  111. LOC_REFERENCE:
  112. emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
  113. end;
  114. { call the mem handling procedures }
  115. case p^.treetype of
  116. simpledisposen:
  117. begin
  118. if ppointerdef(p^.left^.resulttype)^.definition^.needs_inittable then
  119. begin
  120. new(r);
  121. reset_reference(r^);
  122. r^.symbol:=stringdup(lab2str(ppointerdef(p^.left^.resulttype)^.definition^.get_rtti_label));
  123. emitpushreferenceaddr(exprasmlist,r^);
  124. { push pointer adress }
  125. case p^.left^.location.loc of
  126. LOC_CREGISTER : exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,
  127. p^.left^.location.register)));
  128. LOC_REFERENCE:
  129. emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
  130. end;
  131. emitcall('FPC_FINALIZE',true);
  132. end;
  133. emitcall('FPC_FREEMEM',true);
  134. end;
  135. simplenewn:
  136. begin
  137. emitcall('FPC_GETMEM',true);
  138. if ppointerdef(p^.left^.resulttype)^.definition^.needs_inittable then
  139. begin
  140. new(r);
  141. reset_reference(r^);
  142. r^.symbol:=stringdup(lab2str(ppointerdef(p^.left^.resulttype)^.definition^.get_rtti_label));
  143. emitpushreferenceaddr(exprasmlist,r^);
  144. { push pointer adress }
  145. case p^.left^.location.loc of
  146. LOC_CREGISTER : exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,
  147. p^.left^.location.register)));
  148. LOC_REFERENCE:
  149. emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
  150. end;
  151. emitcall('FPC_INITIALIZE',true);
  152. end;
  153. end;
  154. end;
  155. popusedregisters(pushed);
  156. { may be load ESI }
  157. maybe_loadesi;
  158. end;
  159. {*****************************************************************************
  160. SecondAddr
  161. *****************************************************************************}
  162. procedure secondaddr(var p : ptree);
  163. begin
  164. secondpass(p^.left);
  165. p^.location.loc:=LOC_REGISTER;
  166. del_reference(p^.left^.location.reference);
  167. p^.location.register:=getregister32;
  168. {@ on a procvar means returning an address to the procedure that
  169. is stored in it.}
  170. { yes but p^.left^.symtableentry can be nil
  171. for example on @self !! }
  172. { symtableentry can be also invalid, if left is no tree node }
  173. if (p^.left^.treetype=loadn) and
  174. assigned(p^.left^.symtableentry) and
  175. (p^.left^.symtableentry^.typ=varsym) and
  176. (pvarsym(p^.left^.symtableentry)^.definition^.deftype=procvardef) then
  177. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
  178. newreference(p^.left^.location.reference),
  179. p^.location.register)))
  180. else
  181. exprasmlist^.concat(new(pai386,op_ref_reg(A_LEA,S_L,
  182. newreference(p^.left^.location.reference),
  183. p^.location.register)));
  184. { for use of other segments }
  185. if p^.left^.location.reference.segment<>R_DEFAULT_SEG then
  186. p^.location.segment:=p^.left^.location.reference.segment;
  187. end;
  188. {*****************************************************************************
  189. SecondDoubleAddr
  190. *****************************************************************************}
  191. procedure seconddoubleaddr(var p : ptree);
  192. begin
  193. secondpass(p^.left);
  194. p^.location.loc:=LOC_REGISTER;
  195. del_reference(p^.left^.location.reference);
  196. p^.location.register:=getregister32;
  197. exprasmlist^.concat(new(pai386,op_ref_reg(A_LEA,S_L,
  198. newreference(p^.left^.location.reference),
  199. p^.location.register)));
  200. end;
  201. {*****************************************************************************
  202. SecondDeRef
  203. *****************************************************************************}
  204. procedure secondderef(var p : ptree);
  205. var
  206. hr : tregister;
  207. begin
  208. secondpass(p^.left);
  209. clear_reference(p^.location.reference);
  210. case p^.left^.location.loc of
  211. LOC_REGISTER:
  212. p^.location.reference.base:=p^.left^.location.register;
  213. LOC_CREGISTER:
  214. begin
  215. { ... and reserve one for the pointer }
  216. hr:=getregister32;
  217. emit_reg_reg(A_MOV,S_L,p^.left^.location.register,hr);
  218. p^.location.reference.base:=hr;
  219. end;
  220. else
  221. begin
  222. { free register }
  223. del_reference(p^.left^.location.reference);
  224. { ...and reserve one for the pointer }
  225. hr:=getregister32;
  226. exprasmlist^.concat(new(pai386,op_ref_reg(
  227. A_MOV,S_L,newreference(p^.left^.location.reference),
  228. hr)));
  229. p^.location.reference.base:=hr;
  230. end;
  231. end;
  232. end;
  233. {*****************************************************************************
  234. SecondSubScriptN
  235. *****************************************************************************}
  236. procedure secondsubscriptn(var p : ptree);
  237. var
  238. hr : tregister;
  239. begin
  240. secondpass(p^.left);
  241. if codegenerror then
  242. exit;
  243. { classes must be dereferenced implicit }
  244. if (p^.left^.resulttype^.deftype=objectdef) and
  245. pobjectdef(p^.left^.resulttype)^.isclass then
  246. begin
  247. clear_reference(p^.location.reference);
  248. case p^.left^.location.loc of
  249. LOC_REGISTER:
  250. p^.location.reference.base:=p^.left^.location.register;
  251. LOC_CREGISTER:
  252. begin
  253. { ... and reserve one for the pointer }
  254. hr:=getregister32;
  255. emit_reg_reg(A_MOV,S_L,p^.left^.location.register,hr);
  256. p^.location.reference.base:=hr;
  257. end;
  258. else
  259. begin
  260. { free register }
  261. del_reference(p^.left^.location.reference);
  262. { ... and reserve one for the pointer }
  263. hr:=getregister32;
  264. exprasmlist^.concat(new(pai386,op_ref_reg(
  265. A_MOV,S_L,newreference(p^.left^.location.reference),
  266. hr)));
  267. p^.location.reference.base:=hr;
  268. end;
  269. end;
  270. end
  271. else
  272. set_location(p^.location,p^.left^.location);
  273. inc(p^.location.reference.offset,p^.vs^.address);
  274. end;
  275. {*****************************************************************************
  276. SecondVecN
  277. *****************************************************************************}
  278. procedure secondvecn(var p : ptree);
  279. var
  280. is_pushed : boolean;
  281. ind,hr : tregister;
  282. _p : ptree;
  283. function get_mul_size:longint;
  284. begin
  285. if p^.memindex then
  286. get_mul_size:=1
  287. else
  288. get_mul_size:=p^.resulttype^.size;
  289. end;
  290. procedure calc_emit_mul;
  291. var
  292. l1,l2 : longint;
  293. begin
  294. l1:=get_mul_size;
  295. case l1 of
  296. 1,2,4,8 : p^.location.reference.scalefactor:=l1;
  297. else
  298. begin
  299. if ispowerof2(l1,l2) then
  300. exprasmlist^.concat(new(pai386,op_const_reg(A_SHL,S_L,l2,ind)))
  301. else
  302. exprasmlist^.concat(new(pai386,op_const_reg(A_IMUL,S_L,l1,ind)));
  303. end;
  304. end;
  305. end;
  306. var
  307. extraoffset : longint;
  308. t : ptree;
  309. hp : preference;
  310. tai : Pai386;
  311. pushed : tpushed;
  312. begin
  313. secondpass(p^.left);
  314. { we load the array reference to p^.location }
  315. { an ansistring needs to be dereferenced }
  316. if is_ansistring(p^.left^.resulttype) or
  317. is_widestring(p^.left^.resulttype) then
  318. begin
  319. reset_reference(p^.location.reference);
  320. p^.location.loc:=LOC_REFERENCE;
  321. if is_ansistring(p^.left^.resulttype) then
  322. begin
  323. if p^.callunique then
  324. begin
  325. pushusedregisters(pushed,$ff);
  326. emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
  327. emitcall('FPC_UNIQUE_ANSISTRING',true);
  328. maybe_loadesi;
  329. popusedregisters(pushed);
  330. end;
  331. end
  332. else
  333. begin
  334. if p^.callunique then
  335. begin
  336. pushusedregisters(pushed,$ff);
  337. emitpushreferenceaddr(exprasmlist,p^.left^.location.reference);
  338. emitcall('FPC_UNIQUE_WIDESTRING',true);
  339. maybe_loadesi;
  340. popusedregisters(pushed);
  341. end;
  342. end;
  343. del_reference(p^.left^.location.reference);
  344. p^.location.reference.base:=getregister32;
  345. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
  346. newreference(p^.left^.location.reference),
  347. p^.location.reference.base)));
  348. if is_ansistring(p^.left^.resulttype) then
  349. begin
  350. { in ansistrings S[1] is pchar(S)[0] !! }
  351. dec(p^.location.reference.offset);
  352. { this is necessary for ansistrings with constant index }
  353. dec(p^.left^.location.reference.offset);
  354. end
  355. else
  356. begin
  357. { in widestrings S[1] is pwchar(S)[0] !! }
  358. dec(p^.location.reference.offset,2);
  359. { this is necessary for ansistrings with constant index }
  360. dec(p^.left^.location.reference.offset,2);
  361. exprasmlist^.concat(new(pai386,op_const_reg(A_SHL,S_L,
  362. 2,p^.location.reference.base)));
  363. end;
  364. end
  365. else
  366. set_location(p^.location,p^.left^.location);
  367. { offset can only differ from 0 if arraydef }
  368. if p^.left^.resulttype^.deftype=arraydef then
  369. dec(p^.location.reference.offset,
  370. get_mul_size*parraydef(p^.left^.resulttype)^.lowrange);
  371. if p^.right^.treetype=ordconstn then
  372. begin
  373. { offset can only differ from 0 if arraydef }
  374. if (p^.left^.resulttype^.deftype=arraydef) then
  375. begin
  376. if not(is_open_array(p^.left^.resulttype)) then
  377. begin
  378. if (p^.right^.value>parraydef(p^.left^.resulttype)^.highrange) or
  379. (p^.right^.value<parraydef(p^.left^.resulttype)^.lowrange) then
  380. CGMessage(parser_e_range_check_error);
  381. dec(p^.left^.location.reference.offset,
  382. get_mul_size*parraydef(p^.left^.resulttype)^.lowrange);
  383. end
  384. else
  385. begin
  386. { range checking for open arrays }
  387. end;
  388. end;
  389. inc(p^.left^.location.reference.offset,
  390. get_mul_size*p^.right^.value);
  391. if p^.memseg then
  392. p^.left^.location.reference.segment:=R_FS;
  393. p^.left^.resulttype:=p^.resulttype;
  394. disposetree(p^.right);
  395. _p:=p^.left;
  396. putnode(p);
  397. p:=_p;
  398. end
  399. else
  400. begin
  401. { quick hack, to overcome Delphi 2 }
  402. if (cs_regalloc in aktglobalswitches) and
  403. (p^.left^.resulttype^.deftype=arraydef) then
  404. begin
  405. extraoffset:=0;
  406. if (p^.right^.treetype=addn) then
  407. begin
  408. if p^.right^.right^.treetype=ordconstn then
  409. begin
  410. extraoffset:=p^.right^.right^.value;
  411. t:=p^.right^.left;
  412. putnode(p^.right);
  413. putnode(p^.right^.right);
  414. p^.right:=t
  415. end
  416. else if p^.right^.left^.treetype=ordconstn then
  417. begin
  418. extraoffset:=p^.right^.left^.value;
  419. t:=p^.right^.right;
  420. putnode(p^.right);
  421. putnode(p^.right^.left);
  422. p^.right:=t
  423. end;
  424. end
  425. else if (p^.right^.treetype=subn) then
  426. begin
  427. if p^.right^.right^.treetype=ordconstn then
  428. begin
  429. extraoffset:=p^.right^.right^.value;
  430. t:=p^.right^.left;
  431. putnode(p^.right);
  432. putnode(p^.right^.right);
  433. p^.right:=t
  434. end
  435. else if p^.right^.left^.treetype=ordconstn then
  436. begin
  437. extraoffset:=p^.right^.left^.value;
  438. t:=p^.right^.right;
  439. putnode(p^.right);
  440. putnode(p^.right^.left);
  441. p^.right:=t
  442. end;
  443. end;
  444. inc(p^.location.reference.offset,
  445. get_mul_size*extraoffset);
  446. end;
  447. { calculate from left to right }
  448. if (p^.location.loc<>LOC_REFERENCE) and
  449. (p^.location.loc<>LOC_MEM) then
  450. CGMessage(cg_e_illegal_expression);
  451. is_pushed:=maybe_push(p^.right^.registers32,p);
  452. secondpass(p^.right);
  453. if is_pushed then restore(p);
  454. case p^.right^.location.loc of
  455. LOC_REGISTER:
  456. begin
  457. ind:=p^.right^.location.register;
  458. case p^.right^.resulttype^.size of
  459. 1:
  460. begin
  461. hr:=reg8toreg32(ind);
  462. emit_reg_reg(A_MOVZX,S_BL,ind,hr);
  463. ind:=hr;
  464. end;
  465. 2:
  466. begin
  467. hr:=reg16toreg32(ind);
  468. emit_reg_reg(A_MOVZX,S_WL,ind,hr);
  469. ind:=hr;
  470. end;
  471. end;
  472. end;
  473. LOC_CREGISTER:
  474. begin
  475. ind:=getregister32;
  476. case p^.right^.resulttype^.size of
  477. 1:
  478. emit_reg_reg(A_MOVZX,S_BL,p^.right^.location.register,ind);
  479. 2:
  480. emit_reg_reg(A_MOVZX,S_WL,p^.right^.location.register,ind);
  481. 4:
  482. emit_reg_reg(A_MOV,S_L,p^.right^.location.register,ind);
  483. end;
  484. end;
  485. LOC_FLAGS:
  486. begin
  487. ind:=getregister32;
  488. exprasmlist^.concat(new(pai386,op_reg(flag_2_set[p^.right^.location.resflags],S_B,reg32toreg8(ind))));
  489. emit_reg_reg(A_MOVZX,S_BL,reg32toreg8(ind),ind);
  490. end
  491. else
  492. begin
  493. del_reference(p^.right^.location.reference);
  494. ind:=getregister32;
  495. { Booleans are stored in an 8 bit memory location, so
  496. the use of MOVL is not correct }
  497. case p^.right^.resulttype^.size of
  498. 1:
  499. tai:=new(pai386,op_ref_reg(A_MOVZX,S_BL,newreference(p^.right^.location.reference),ind));
  500. 2:
  501. tai:=new(Pai386,op_ref_reg(A_MOVZX,S_WL,newreference(p^.right^.location.reference),ind));
  502. 4:
  503. tai:=new(Pai386,op_ref_reg(A_MOV,S_L,newreference(p^.right^.location.reference),ind));
  504. end;
  505. exprasmlist^.concat(tai);
  506. end;
  507. end;
  508. { produce possible range check code: }
  509. if cs_check_range in aktlocalswitches then
  510. begin
  511. if p^.left^.resulttype^.deftype=arraydef then
  512. begin
  513. hp:=new_reference(R_NO,0);
  514. parraydef(p^.left^.resulttype)^.genrangecheck;
  515. hp^.symbol:=stringdup(parraydef(p^.left^.resulttype)^.getrangecheckstring);
  516. exprasmlist^.concat(new(pai386,op_reg_ref(A_BOUND,S_L,ind,hp)));
  517. end;
  518. end;
  519. if p^.location.reference.index=R_NO then
  520. begin
  521. p^.location.reference.index:=ind;
  522. calc_emit_mul;
  523. end
  524. else
  525. begin
  526. if p^.location.reference.base=R_NO then
  527. begin
  528. case p^.location.reference.scalefactor of
  529. 2 : exprasmlist^.concat(new(pai386,op_const_reg(A_SHL,S_L,1,p^.location.reference.index)));
  530. 4 : exprasmlist^.concat(new(pai386,op_const_reg(A_SHL,S_L,2,p^.location.reference.index)));
  531. 8 : exprasmlist^.concat(new(pai386,op_const_reg(A_SHL,S_L,3,p^.location.reference.index)));
  532. end;
  533. calc_emit_mul;
  534. p^.location.reference.base:=p^.location.reference.index;
  535. p^.location.reference.index:=ind;
  536. end
  537. else
  538. begin
  539. exprasmlist^.concat(new(pai386,op_ref_reg(
  540. A_LEA,S_L,newreference(p^.location.reference),
  541. p^.location.reference.index)));
  542. ungetregister32(p^.location.reference.base);
  543. { the symbol offset is loaded, }
  544. { so release the symbol name and set symbol }
  545. { to nil }
  546. stringdispose(p^.location.reference.symbol);
  547. p^.location.reference.offset:=0;
  548. calc_emit_mul;
  549. p^.location.reference.base:=p^.location.reference.index;
  550. p^.location.reference.index:=ind;
  551. end;
  552. end;
  553. if p^.memseg then
  554. p^.location.reference.segment:=R_FS;
  555. end;
  556. end;
  557. {*****************************************************************************
  558. SecondSelfN
  559. *****************************************************************************}
  560. procedure secondselfn(var p : ptree);
  561. begin
  562. clear_reference(p^.location.reference);
  563. if (p^.resulttype^.deftype=classrefdef) or
  564. ((p^.resulttype^.deftype=objectdef)
  565. and pobjectdef(p^.resulttype)^.isclass
  566. ) then
  567. p^.location.register:=R_ESI
  568. else
  569. p^.location.reference.base:=R_ESI;
  570. end;
  571. {*****************************************************************************
  572. SecondWithN
  573. *****************************************************************************}
  574. procedure secondwith(var p : ptree);
  575. var
  576. ref : treference;
  577. symtable : psymtable;
  578. i : longint;
  579. begin
  580. if assigned(p^.left) then
  581. begin
  582. secondpass(p^.left);
  583. ref.symbol:=nil;
  584. gettempofsizereference(4,ref);
  585. if (p^.left^.resulttype^.deftype=objectdef) and
  586. pobjectdef(p^.left^.resulttype)^.isclass then
  587. exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
  588. newreference(p^.left^.location.reference),R_EDI)))
  589. else
  590. exprasmlist^.concat(new(pai386,op_ref_reg(A_LEA,S_L,
  591. newreference(p^.left^.location.reference),R_EDI)));
  592. exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,
  593. R_EDI,newreference(ref))));
  594. del_reference(p^.left^.location.reference);
  595. { the offset relative to (%ebp) is only needed here! }
  596. symtable:=p^.withsymtable;
  597. for i:=1 to p^.tablecount do
  598. begin
  599. symtable^.datasize:=ref.offset;
  600. symtable:=symtable^.next;
  601. end;
  602. { p^.right can be optimize out !!! }
  603. if p^.right<>nil then
  604. secondpass(p^.right);
  605. { clear some stuff }
  606. ungetiftemp(ref);
  607. end;
  608. end;
  609. end.
  610. {
  611. $Log$
  612. Revision 1.14 1998-10-02 07:20:37 florian
  613. * range checking in units doesn't work if the units are smartlinked, fixed
  614. Revision 1.13 1998/09/27 10:16:23 florian
  615. * type casts pchar<->ansistring fixed
  616. * ansistring[..] calls does now an unique call
  617. Revision 1.12 1998/09/23 15:46:36 florian
  618. * problem with with and classes fixed
  619. Revision 1.11 1998/09/17 09:42:18 peter
  620. + pass_2 for cg386
  621. * Message() -> CGMessage() for pass_1/pass_2
  622. Revision 1.10 1998/09/14 10:43:52 peter
  623. * all internal RTL functions start with FPC_
  624. Revision 1.9 1998/09/03 16:03:15 florian
  625. + rtti generation
  626. * init table generation changed
  627. Revision 1.8 1998/08/23 21:04:34 florian
  628. + rtti generation for classes added
  629. + new/dispose do now also a call to INITIALIZE/FINALIZE, if necessaray
  630. Revision 1.7 1998/08/20 11:27:40 michael
  631. * Applied Peters Fix
  632. Revision 1.6 1998/08/10 14:49:49 peter
  633. + localswitches, moduleswitches, globalswitches splitting
  634. Revision 1.5 1998/07/26 21:58:58 florian
  635. + better support for switch $H
  636. + index access to ansi strings added
  637. + assigment of data (records/arrays) containing ansi strings
  638. Revision 1.4 1998/07/24 22:16:55 florian
  639. * internal error 10 together with array access fixed. I hope
  640. that's the final fix.
  641. Revision 1.3 1998/06/25 08:48:09 florian
  642. * first version of rtti support
  643. Revision 1.2 1998/06/08 13:13:35 pierre
  644. + temporary variables now in temp_gen.pas unit
  645. because it is processor independent
  646. * mppc68k.bat modified to undefine i386 and support_mmx
  647. (which are defaults for i386)
  648. Revision 1.1 1998/06/05 17:44:13 peter
  649. * splitted cgi386
  650. }