ncgmem.pas 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate assembler for memory related nodes which are
  4. the same for all (most?) processors
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit ncgmem;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. globtype,cgbase,cpuinfo,cpubase,
  23. node,nmem;
  24. type
  25. tcgloadvmtaddrnode = class(tloadvmtaddrnode)
  26. procedure pass_generate_code;override;
  27. end;
  28. tcgloadparentfpnode = class(tloadparentfpnode)
  29. procedure pass_generate_code;override;
  30. end;
  31. tcgaddrnode = class(taddrnode)
  32. procedure pass_generate_code;override;
  33. end;
  34. tcgderefnode = class(tderefnode)
  35. procedure pass_generate_code;override;
  36. end;
  37. tcgsubscriptnode = class(tsubscriptnode)
  38. procedure pass_generate_code;override;
  39. end;
  40. tcgwithnode = class(twithnode)
  41. procedure pass_generate_code;override;
  42. end;
  43. tcgvecnode = class(tvecnode)
  44. function get_mul_size : aint;
  45. private
  46. procedure rangecheck_array;
  47. procedure rangecheck_string;
  48. protected
  49. {# This routine is used to calculate the address of the reference.
  50. On entry reg contains the index in the array,
  51. and l contains the size of each element in the array.
  52. This routine should update location.reference correctly,
  53. so it points to the correct address.
  54. }
  55. procedure update_reference_reg_mul(maybe_const_reg:tregister;l:aint);virtual;
  56. procedure update_reference_reg_packed(maybe_const_reg:tregister;l:aint);virtual;
  57. procedure second_wideansistring;virtual;
  58. procedure second_dynamicarray;virtual;
  59. public
  60. procedure pass_generate_code;override;
  61. end;
  62. implementation
  63. uses
  64. systems,
  65. cutils,cclasses,verbose,globals,constexp,
  66. symconst,symbase,symtype,symdef,symsym,symcpu,symtable,defutil,paramgr,
  67. aasmbase,aasmtai,aasmdata,
  68. procinfo,pass_2,parabase,
  69. pass_1,nld,ncon,nadd,ncnv,nutils,
  70. cgutils,cgobj,hlcgobj,
  71. tgobj,ncgutil,objcgutl,
  72. defcmp
  73. ;
  74. {*****************************************************************************
  75. TCGLOADVMTADDRNODE
  76. *****************************************************************************}
  77. procedure tcgloadvmtaddrnode.pass_generate_code;
  78. var
  79. href : treference;
  80. pool : THashSet;
  81. entry : PHashSetItem;
  82. begin
  83. location_reset(location,LOC_REGISTER,def_cgsize(voidpointertype));
  84. if (left.nodetype=typen) then
  85. begin
  86. location.register:=hlcg.getaddressregister(current_asmdata.CurrAsmList,voidpointertype);
  87. if not is_objcclass(left.resultdef) then
  88. begin
  89. reference_reset_symbol(href,
  90. current_asmdata.RefAsmSymbol(tobjectdef(tclassrefdef(resultdef).pointeddef).vmt_mangledname,AT_DATA),0,
  91. voidpointertype.size);
  92. hlcg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,voidpointertype,voidpointertype,href,location.register);
  93. end
  94. else
  95. begin
  96. pool:=current_asmdata.ConstPools[sp_objcclassnamerefs];
  97. entry:=pool.FindOrAdd(@tobjectdef(left.resultdef).objextname^[1],length(tobjectdef(left.resultdef).objextname^));
  98. if (target_info.system in systems_objc_nfabi) then
  99. begin
  100. { find/add necessary classref/classname pool entries }
  101. objcfinishclassrefnfpoolentry(entry,tobjectdef(left.resultdef));
  102. end
  103. else
  104. begin
  105. { find/add necessary classref/classname pool entries }
  106. objcfinishstringrefpoolentry(entry,sp_objcclassnames,sec_objc_cls_refs,sec_objc_class_names);
  107. end;
  108. reference_reset_symbol(href,tasmlabel(entry^.Data),0,voidpointertype.size);
  109. hlcg.a_load_ref_reg(current_asmdata.CurrAsmList,voidpointertype,voidpointertype,href,location.register);
  110. end;
  111. end
  112. else
  113. begin
  114. { left contains self, load vmt from self }
  115. secondpass(left);
  116. gen_load_vmt_register(current_asmdata.CurrAsmList,tobjectdef(left.resultdef),left.location,location.register);
  117. end;
  118. end;
  119. {*****************************************************************************
  120. TCGLOADPARENTFPNODE
  121. *****************************************************************************}
  122. procedure tcgloadparentfpnode.pass_generate_code;
  123. var
  124. currpi : tprocinfo;
  125. hsym : tparavarsym;
  126. href : treference;
  127. begin
  128. if (current_procinfo.procdef.parast.symtablelevel=parentpd.parast.symtablelevel) then
  129. begin
  130. location_reset(location,LOC_REGISTER,def_cgsize(parentfpvoidpointertype));
  131. location.register:=current_procinfo.framepointer;
  132. end
  133. else
  134. begin
  135. currpi:=current_procinfo;
  136. location_reset(location,LOC_REGISTER,def_cgsize(parentfpvoidpointertype));
  137. location.register:=hlcg.getaddressregister(current_asmdata.CurrAsmList,parentfpvoidpointertype);
  138. { load framepointer of current proc }
  139. hsym:=tparavarsym(currpi.procdef.parast.Find('parentfp'));
  140. if not assigned(hsym) then
  141. internalerror(200309281);
  142. hlcg.a_load_loc_reg(current_asmdata.CurrAsmList,parentfpvoidpointertype,parentfpvoidpointertype,hsym.localloc,location.register);
  143. { walk parents }
  144. while (currpi.procdef.owner.symtablelevel>parentpd.parast.symtablelevel) do
  145. begin
  146. currpi:=currpi.parent;
  147. if not assigned(currpi) then
  148. internalerror(200311201);
  149. hsym:=tparavarsym(currpi.procdef.parast.Find('parentfp'));
  150. if not assigned(hsym) then
  151. internalerror(200309282);
  152. if hsym.localloc.loc<>LOC_REFERENCE then
  153. internalerror(200309283);
  154. hlcg.reference_reset_base(href,parentfpvoidpointertype,location.register,hsym.localloc.reference.offset,sizeof(pint));
  155. hlcg.a_load_ref_reg(current_asmdata.CurrAsmList,parentfpvoidpointertype,parentfpvoidpointertype,href,location.register);
  156. end;
  157. end;
  158. end;
  159. {*****************************************************************************
  160. TCGADDRNODE
  161. *****************************************************************************}
  162. procedure tcgaddrnode.pass_generate_code;
  163. begin
  164. secondpass(left);
  165. location_reset(location,LOC_REGISTER,int_cgsize(resultdef.size));
  166. location.register:=hlcg.getaddressregister(current_asmdata.CurrAsmList,resultdef);
  167. if not(left.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  168. { on x86_64-win64, array of chars can be returned in registers, however,
  169. when passing these arrays to other functions, the compiler wants to take
  170. the address of the array so when the addrnode has been created internally,
  171. we have to force the data into memory, see also tw14388.pp
  172. }
  173. if nf_internal in flags then
  174. hlcg.location_force_mem(current_asmdata.CurrAsmList,left.location,left.resultdef)
  175. else
  176. internalerror(2006111510);
  177. hlcg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.resultdef,resultdef,left.location.reference,location.register);
  178. end;
  179. {*****************************************************************************
  180. TCGDEREFNODE
  181. *****************************************************************************}
  182. procedure tcgderefnode.pass_generate_code;
  183. var
  184. paraloc1 : tcgpara;
  185. pd : tprocdef;
  186. sym : tsym;
  187. st : tsymtable;
  188. hp : pnode;
  189. hp2 : tnode;
  190. extraoffset : tcgint;
  191. begin
  192. sym:=nil;
  193. { assume natural alignment, except for packed records }
  194. if not(resultdef.typ in [recorddef,objectdef]) or
  195. (tabstractrecordsymtable(tabstractrecorddef(resultdef).symtable).usefieldalignment<>1) then
  196. location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),resultdef.alignment)
  197. else
  198. location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),1);
  199. { can we fold an add/sub node into the offset of the deref node? }
  200. extraoffset:=0;
  201. hp:=actualtargetnode(@left);
  202. if (hp^.nodetype=subn) and is_constintnode(taddnode(hp^).right) then
  203. begin
  204. extraoffset:=-tcgint(tordconstnode(taddnode(hp^).right).value);
  205. replacenode(hp^,taddnode(hp^).left);
  206. end
  207. else if (hp^.nodetype=addn) and is_constintnode(taddnode(hp^).right) then
  208. begin
  209. extraoffset:=tcgint(tordconstnode(taddnode(hp^).right).value);
  210. replacenode(hp^,taddnode(hp^).left);
  211. end
  212. else if (hp^.nodetype=addn) and is_constintnode(taddnode(hp^).left) then
  213. begin
  214. extraoffset:=tcgint(tordconstnode(taddnode(hp^).left).value);
  215. replacenode(hp^,taddnode(hp^).right);
  216. end;
  217. secondpass(left);
  218. if not(left.location.loc in [LOC_CREGISTER,LOC_REGISTER,LOC_CREFERENCE,LOC_REFERENCE,LOC_CONSTANT]) then
  219. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  220. case left.location.loc of
  221. LOC_CREGISTER,
  222. LOC_REGISTER:
  223. begin
  224. hlcg.maybe_change_load_node_reg(current_asmdata.CurrAsmList,left,true);
  225. {$ifdef cpu_uses_separate_address_registers}
  226. if getregtype(left.location.register)<>R_ADDRESSREGISTER then
  227. begin
  228. location.reference.base := cg.getaddressregister(current_asmdata.CurrAsmList);
  229. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,left.location.register,
  230. location.reference.base);
  231. end
  232. else
  233. {$endif}
  234. location.reference.base := left.location.register;
  235. end;
  236. LOC_CREFERENCE,
  237. LOC_REFERENCE:
  238. begin
  239. location.reference.base:=cg.getaddressregister(current_asmdata.CurrAsmList);
  240. hlcg.a_load_loc_reg(current_asmdata.CurrAsmList,left.resultdef,left.resultdef,left.location,location.reference.base);
  241. end;
  242. LOC_CONSTANT:
  243. begin
  244. location.reference.offset:=left.location.value;
  245. end;
  246. else
  247. internalerror(200507031);
  248. end;
  249. location.reference.offset:=location.reference.offset+extraoffset;
  250. if (cs_use_heaptrc in current_settings.globalswitches) and
  251. (cs_checkpointer in current_settings.localswitches) and
  252. not(cs_compilesystem in current_settings.moduleswitches) and
  253. {$ifdef x86}
  254. (tcpupointerdef(left.resultdef).x86pointertyp = tcpupointerdefclass(cpointerdef).default_x86_data_pointer_type) and
  255. {$endif x86}
  256. not(nf_no_checkpointer in flags) and
  257. { can be NR_NO in case of LOC_CONSTANT }
  258. (location.reference.base<>NR_NO) then
  259. begin
  260. if not searchsym_in_named_module('HEAPTRC','CHECKPOINTER',sym,st) or
  261. (sym.typ<>procsym) then
  262. internalerror(2012010601);
  263. pd:=tprocdef(tprocsym(sym).ProcdefList[0]);
  264. paraloc1.init;
  265. paramanager.getintparaloc(pd,1,paraloc1);
  266. hlcg.a_load_reg_cgpara(current_asmdata.CurrAsmList,left.resultdef,location.reference.base,paraloc1);
  267. paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
  268. paraloc1.done;
  269. hlcg.allocallcpuregisters(current_asmdata.CurrAsmList);
  270. hlcg.a_call_name(current_asmdata.CurrAsmList,pd,'FPC_CHECKPOINTER',nil,false);
  271. hlcg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  272. end;
  273. end;
  274. {*****************************************************************************
  275. TCGSUBSCRIPTNODE
  276. *****************************************************************************}
  277. procedure tcgsubscriptnode.pass_generate_code;
  278. var
  279. asmsym: tasmsymbol;
  280. paraloc1 : tcgpara;
  281. tmpref: treference;
  282. sref: tsubsetreference;
  283. offsetcorrection : aint;
  284. pd : tprocdef;
  285. sym : tsym;
  286. st : tsymtable;
  287. begin
  288. sym:=nil;
  289. secondpass(left);
  290. if codegenerror then
  291. exit;
  292. paraloc1.init;
  293. { several object types must be dereferenced implicitly }
  294. if is_implicit_pointer_object_type(left.resultdef) then
  295. begin
  296. if (not is_managed_type(left.resultdef)) or
  297. is_class(left.resultdef) or
  298. (target_info.system in systems_garbage_collected_managed_types) then
  299. begin
  300. { the contents of a class are aligned to a sizeof(pointer) }
  301. location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),voidpointertype.size);
  302. case left.location.loc of
  303. LOC_CREGISTER,
  304. LOC_REGISTER:
  305. begin
  306. {$ifdef cpu_uses_separate_address_registers}
  307. if getregtype(left.location.register)<>R_ADDRESSREGISTER then
  308. begin
  309. location.reference.base:=rg.getaddressregister(current_asmdata.CurrAsmList);
  310. hlcg.a_load_reg_reg(current_asmdata.CurrAsmList,left.resultdef,left.resultdef,
  311. left.location.register,location.reference.base);
  312. end
  313. else
  314. {$endif}
  315. hlcg.reference_reset_base(location.reference,left.resultdef,left.location.register,0,location.reference.alignment);
  316. end;
  317. LOC_CREFERENCE,
  318. LOC_REFERENCE,
  319. { tricky type casting of parameters can cause these locations, see tb0592.pp on x86_64-linux }
  320. LOC_SUBSETREG,
  321. LOC_CSUBSETREG,
  322. LOC_SUBSETREF,
  323. LOC_CSUBSETREF:
  324. begin
  325. hlcg.reference_reset_base(location.reference,left.resultdef,
  326. hlcg.getaddressregister(current_asmdata.CurrAsmList,left.resultdef),0,location.reference.alignment);
  327. hlcg.a_load_loc_reg(current_asmdata.CurrAsmList,left.resultdef,left.resultdef,left.location,location.reference.base);
  328. end;
  329. LOC_CONSTANT:
  330. begin
  331. { can happen with @classtype(pointerconst).field }
  332. location.reference.offset:=left.location.value;
  333. end;
  334. else
  335. internalerror(2009092401);
  336. end;
  337. { implicit deferencing }
  338. if (cs_use_heaptrc in current_settings.globalswitches) and
  339. (cs_checkpointer in current_settings.localswitches) and
  340. not(cs_compilesystem in current_settings.moduleswitches) then
  341. begin
  342. if not searchsym_in_named_module('HEAPTRC','CHECKPOINTER',sym,st) or
  343. (sym.typ<>procsym) then
  344. internalerror(2012010602);
  345. pd:=tprocdef(tprocsym(sym).ProcdefList[0]);
  346. paramanager.getintparaloc(pd,1,paraloc1);
  347. hlcg.a_load_reg_cgpara(current_asmdata.CurrAsmList,left.resultdef,location.reference.base,paraloc1);
  348. paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
  349. hlcg.allocallcpuregisters(current_asmdata.CurrAsmList);
  350. hlcg.a_call_name(current_asmdata.CurrAsmList,pd,'FPC_CHECKPOINTER',nil,false);
  351. hlcg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  352. end;
  353. end
  354. else
  355. { reference-counted implicit pointer object types don't have
  356. fields -> cannot be subscripted (calls are handled via call
  357. nodes) }
  358. internalerror(2011011901);
  359. end
  360. else
  361. begin
  362. location_copy(location,left.location);
  363. { some abi's require that functions return (some) records in }
  364. { registers }
  365. case location.loc of
  366. LOC_REFERENCE,
  367. LOC_CREFERENCE:
  368. ;
  369. LOC_CONSTANT,
  370. LOC_REGISTER,
  371. LOC_CREGISTER,
  372. { if a floating point value is casted into a record, it
  373. can happen that we get here an fpu or mm register }
  374. LOC_MMREGISTER,
  375. LOC_FPUREGISTER,
  376. LOC_CMMREGISTER,
  377. LOC_CFPUREGISTER:
  378. begin
  379. { in case the result is not something that can be put
  380. into an integer register (e.g.
  381. function_returning_record().non_regable_field, or
  382. a function returning a value > sizeof(intreg))
  383. -> force to memory
  384. }
  385. if not tstoreddef(left.resultdef).is_intregable or
  386. not tstoreddef(resultdef).is_intregable or
  387. { if the field spans multiple registers, we must force the record into
  388. memory as well }
  389. ((left.location.size in [OS_PAIR,OS_SPAIR]) and
  390. (vs.fieldoffset div sizeof(aword)<>(vs.fieldoffset+vs.getsize-1) div sizeof(aword))) or
  391. (location.loc in [LOC_MMREGISTER,LOC_FPUREGISTER,LOC_CMMREGISTER,LOC_CFPUREGISTER,
  392. { actually, we should be able to "subscript" a constant, but this would require some code
  393. which enables dumping and reading constants from a temporary memory buffer. This
  394. must be done a CPU dependent way, so it is not easy and probably not worth the effort (FK)
  395. }
  396. LOC_CONSTANT]) then
  397. hlcg.location_force_mem(current_asmdata.CurrAsmList,location,left.resultdef)
  398. else
  399. begin
  400. if (left.location.loc = LOC_REGISTER) then
  401. location.loc := LOC_SUBSETREG
  402. else
  403. location.loc := LOC_CSUBSETREG;
  404. location.size:=def_cgsize(resultdef);
  405. offsetcorrection:=0;
  406. if (left.location.size in [OS_PAIR,OS_SPAIR]) then
  407. begin
  408. if (vs.fieldoffset>=sizeof(aword)) then
  409. begin
  410. location.sreg.subsetreg := left.location.registerhi;
  411. offsetcorrection:=sizeof(aword)*8;
  412. end
  413. else
  414. location.sreg.subsetreg := left.location.register;
  415. location.sreg.subsetregsize := OS_INT;
  416. end
  417. else
  418. begin
  419. location.sreg.subsetreg := left.location.register;
  420. location.sreg.subsetregsize := left.location.size;
  421. end;
  422. if not is_packed_record_or_object(left.resultdef) then
  423. begin
  424. if (target_info.endian = ENDIAN_BIG) then
  425. location.sreg.startbit := (tcgsize2size[location.sreg.subsetregsize] - tcgsize2size[location.size] - vs.fieldoffset) * 8+offsetcorrection
  426. else
  427. location.sreg.startbit := (vs.fieldoffset * 8)-offsetcorrection;
  428. location.sreg.bitlen := tcgsize2size[location.size] * 8;
  429. end
  430. else
  431. begin
  432. location.sreg.bitlen := resultdef.packedbitsize;
  433. if (target_info.endian = ENDIAN_BIG) then
  434. location.sreg.startbit := (tcgsize2size[location.sreg.subsetregsize]*8 - location.sreg.bitlen) - vs.fieldoffset+offsetcorrection
  435. else
  436. location.sreg.startbit := vs.fieldoffset-offsetcorrection;
  437. end;
  438. end;
  439. end;
  440. LOC_SUBSETREG,
  441. LOC_CSUBSETREG:
  442. begin
  443. location.size:=def_cgsize(resultdef);
  444. if not is_packed_record_or_object(left.resultdef) then
  445. begin
  446. if (target_info.endian = ENDIAN_BIG) then
  447. inc(location.sreg.startbit, (left.resultdef.size - tcgsize2size[location.size] - vs.fieldoffset) * 8)
  448. else
  449. inc(location.sreg.startbit, vs.fieldoffset * 8);
  450. location.sreg.bitlen := tcgsize2size[location.size] * 8;
  451. end
  452. else
  453. begin
  454. location.sreg.bitlen := resultdef.packedbitsize;
  455. if (target_info.endian = ENDIAN_BIG) then
  456. inc(location.sreg.startbit, left.location.sreg.bitlen - location.sreg.bitlen - vs.fieldoffset)
  457. else
  458. inc(location.sreg.startbit, vs.fieldoffset);
  459. end;
  460. end;
  461. else
  462. internalerror(2006031901);
  463. end;
  464. end;
  465. if is_objc_class_or_protocol(left.resultdef) and
  466. (target_info.system in systems_objc_nfabi) then
  467. begin
  468. if (location.loc<>LOC_REFERENCE) or
  469. (location.reference.index<>NR_NO) then
  470. internalerror(2009092402);
  471. { the actual field offset is stored in memory (to solve the
  472. "fragile base class" problem: this way the layout of base
  473. classes can be changed without breaking programs compiled against
  474. earlier versions)
  475. }
  476. asmsym:=current_asmdata.RefAsmSymbol(vs.mangledname);
  477. reference_reset_symbol(tmpref,asmsym,0,sizeof(pint));
  478. location.reference.index:=cg.getaddressregister(current_asmdata.CurrAsmList);
  479. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,tmpref,location.reference.index);
  480. { always packrecords C -> natural alignment }
  481. location.reference.alignment:=vs.vardef.alignment;
  482. end
  483. else if is_java_class_or_interface(left.resultdef) or
  484. ((target_info.system in systems_jvm) and
  485. (left.resultdef.typ=recorddef)) then
  486. begin
  487. if (location.loc<>LOC_REFERENCE) or
  488. (location.reference.index<>NR_NO) or
  489. assigned(location.reference.symbol) then
  490. internalerror(2011011301);
  491. location.reference.symbol:=current_asmdata.RefAsmSymbol(vs.mangledname);
  492. end
  493. else if (location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  494. begin
  495. if not is_packed_record_or_object(left.resultdef) then
  496. begin
  497. inc(location.reference.offset,vs.fieldoffset);
  498. location.reference.alignment:=newalignment(location.reference.alignment,vs.fieldoffset);
  499. end
  500. else if (vs.fieldoffset mod 8 = 0) and
  501. (resultdef.packedbitsize mod 8 = 0) and
  502. { is different in case of e.g. packenum 2 and an enum }
  503. { which fits in 8 bits }
  504. (resultdef.size*8 = resultdef.packedbitsize) then
  505. begin
  506. inc(location.reference.offset,vs.fieldoffset div 8);
  507. location.reference.alignment:=newalignment(location.reference.alignment,vs.fieldoffset div 8);
  508. end
  509. else
  510. begin
  511. sref.ref:=location.reference;
  512. sref.ref.alignment:=1;
  513. sref.bitindexreg:=NR_NO;
  514. inc(sref.ref.offset,vs.fieldoffset div 8);
  515. sref.startbit:=vs.fieldoffset mod 8;
  516. sref.bitlen:=resultdef.packedbitsize;
  517. if (left.location.loc=LOC_REFERENCE) then
  518. location.loc:=LOC_SUBSETREF
  519. else
  520. location.loc:=LOC_CSUBSETREF;
  521. location.sref:=sref;
  522. end;
  523. { also update the size of the location }
  524. location.size:=def_cgsize(resultdef);
  525. end;
  526. paraloc1.done;
  527. end;
  528. {*****************************************************************************
  529. TCGWITHNODE
  530. *****************************************************************************}
  531. procedure tcgwithnode.pass_generate_code;
  532. begin
  533. location_reset(location,LOC_VOID,OS_NO);
  534. if assigned(left) then
  535. secondpass(left);
  536. end;
  537. {*****************************************************************************
  538. TCGVECNODE
  539. *****************************************************************************}
  540. function tcgvecnode.get_mul_size : aint;
  541. begin
  542. if nf_memindex in flags then
  543. get_mul_size:=1
  544. else
  545. begin
  546. if (left.resultdef.typ=arraydef) then
  547. if not is_packed_array(left.resultdef) then
  548. get_mul_size:=tarraydef(left.resultdef).elesize
  549. else
  550. get_mul_size:=tarraydef(left.resultdef).elepackedbitsize
  551. else
  552. get_mul_size:=resultdef.size;
  553. end
  554. end;
  555. { this routine must, like any other routine, not change the contents }
  556. { of base/index registers of references, as these may be regvars. }
  557. { The register allocator can coalesce one LOC_REGISTER being moved }
  558. { into another (as their live ranges won't overlap), but not a }
  559. { LOC_CREGISTER moved into a LOC_(C)REGISTER most of the time (as }
  560. { the live range of the LOC_CREGISTER will most likely overlap the }
  561. { the live range of the target LOC_(C)REGISTER) }
  562. { The passed register may be a LOC_CREGISTER as well. }
  563. procedure tcgvecnode.update_reference_reg_mul(maybe_const_reg:tregister;l:aint);
  564. var
  565. hreg: tregister;
  566. begin
  567. if l<>1 then
  568. begin
  569. hreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
  570. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_IMUL,OS_ADDR,l,maybe_const_reg,hreg);
  571. maybe_const_reg:=hreg;
  572. end;
  573. if location.reference.base=NR_NO then
  574. location.reference.base:=maybe_const_reg
  575. else if location.reference.index=NR_NO then
  576. location.reference.index:=maybe_const_reg
  577. else
  578. begin
  579. hreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
  580. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,location.reference,hreg);
  581. reference_reset_base(location.reference,hreg,0,location.reference.alignment);
  582. { insert new index register }
  583. location.reference.index:=maybe_const_reg;
  584. end;
  585. { update alignment }
  586. if (location.reference.alignment=0) then
  587. internalerror(2009020704);
  588. location.reference.alignment:=newalignment(location.reference.alignment,l);
  589. end;
  590. { see remarks for tcgvecnode.update_reference_reg_mul above }
  591. procedure tcgvecnode.update_reference_reg_packed(maybe_const_reg:tregister;l:aint);
  592. var
  593. sref: tsubsetreference;
  594. offsetreg, hreg: tregister;
  595. alignpower: aint;
  596. temp : longint;
  597. begin
  598. { only orddefs are bitpacked. Even then we only need special code in }
  599. { case the bitpacked *byte size* is not a power of two, otherwise }
  600. { everything can be handled using the the regular array code. }
  601. if ((l mod 8) = 0) and
  602. (ispowerof2(l div 8,temp) or
  603. not is_ordinal(resultdef)
  604. {$ifndef cpu64bitalu}
  605. or is_64bitint(resultdef)
  606. {$endif not cpu64bitalu}
  607. ) then
  608. begin
  609. update_reference_reg_mul(maybe_const_reg,l div 8);
  610. exit;
  611. end;
  612. if (l > 8*sizeof(aint)) then
  613. internalerror(200608051);
  614. sref.ref := location.reference;
  615. hreg := cg.getaddressregister(current_asmdata.CurrAsmList);
  616. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SUB,OS_INT,tarraydef(left.resultdef).lowrange,maybe_const_reg,hreg);
  617. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_IMUL,OS_INT,l,hreg);
  618. { keep alignment for index }
  619. sref.ref.alignment := left.resultdef.alignment;
  620. if not ispowerof2(sref.ref.alignment,temp) then
  621. internalerror(2006081201);
  622. alignpower:=temp;
  623. offsetreg := cg.getaddressregister(current_asmdata.CurrAsmList);
  624. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SHR,OS_ADDR,3+alignpower,hreg,offsetreg);
  625. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SHL,OS_ADDR,alignpower,offsetreg);
  626. if (sref.ref.base = NR_NO) then
  627. sref.ref.base := offsetreg
  628. else if (sref.ref.index = NR_NO) then
  629. sref.ref.index := offsetreg
  630. else
  631. begin
  632. cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_ADD,OS_ADDR,sref.ref.base,offsetreg);
  633. sref.ref.base := offsetreg;
  634. end;
  635. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_AND,OS_INT,(1 shl (3+alignpower))-1,hreg);
  636. sref.bitindexreg := hreg;
  637. sref.startbit := 0;
  638. sref.bitlen := resultdef.packedbitsize;
  639. if (left.location.loc = LOC_REFERENCE) then
  640. location.loc := LOC_SUBSETREF
  641. else
  642. location.loc := LOC_CSUBSETREF;
  643. location.sref := sref;
  644. end;
  645. procedure tcgvecnode.second_wideansistring;
  646. begin
  647. end;
  648. procedure tcgvecnode.second_dynamicarray;
  649. begin
  650. end;
  651. procedure tcgvecnode.rangecheck_array;
  652. var
  653. hightree : tnode;
  654. poslabel,
  655. neglabel : tasmlabel;
  656. hreg : tregister;
  657. paraloc1,paraloc2 : tcgpara;
  658. pd : tprocdef;
  659. begin
  660. { omit range checking when this is an array access to a pointer which has been
  661. typecasted from an array }
  662. if (ado_isconvertedpointer in tarraydef(left.resultdef).arrayoptions) then
  663. exit;
  664. paraloc1.init;
  665. paraloc2.init;
  666. if is_open_array(left.resultdef) or
  667. is_array_of_const(left.resultdef) then
  668. begin
  669. { cdecl functions don't have high() so we can not check the range }
  670. { (can't use current_procdef, since it may be a nested procedure) }
  671. if not(tprocdef(tparasymtable(tparavarsym(tloadnode(get_open_const_array(left)).symtableentry).owner).defowner).proccalloption in cdecl_pocalls) then
  672. begin
  673. { Get high value }
  674. hightree:=load_high_value_node(tparavarsym(tloadnode(get_open_const_array(left)).symtableentry));
  675. { it must be available }
  676. if not assigned(hightree) then
  677. internalerror(200212201);
  678. firstpass(hightree);
  679. secondpass(hightree);
  680. { generate compares }
  681. if (right.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
  682. hreg:=cg.makeregsize(current_asmdata.CurrAsmList,right.location.register,OS_INT)
  683. else
  684. begin
  685. hreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
  686. hlcg.a_load_loc_reg(current_asmdata.CurrAsmList,right.resultdef,osuinttype,right.location,hreg);
  687. end;
  688. current_asmdata.getjumplabel(neglabel);
  689. current_asmdata.getjumplabel(poslabel);
  690. cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_LT,0,hreg,poslabel);
  691. cg.a_cmp_loc_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_BE,hightree.location,hreg,neglabel);
  692. cg.a_label(current_asmdata.CurrAsmList,poslabel);
  693. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_RANGEERROR',false);
  694. cg.a_label(current_asmdata.CurrAsmList,neglabel);
  695. { release hightree }
  696. hightree.free;
  697. end;
  698. end
  699. else
  700. if is_dynamic_array(left.resultdef) then
  701. begin
  702. pd:=search_system_proc('fpc_dynarray_rangecheck');
  703. paramanager.getintparaloc(pd,1,paraloc1);
  704. paramanager.getintparaloc(pd,2,paraloc2);
  705. if pd.is_pushleftright then
  706. begin
  707. cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,left.location,paraloc1);
  708. cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,right.location,paraloc2);
  709. end
  710. else
  711. begin
  712. cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,right.location,paraloc2);
  713. cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,left.location,paraloc1);
  714. end;
  715. paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
  716. paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc2);
  717. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  718. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_DYNARRAY_RANGECHECK',false);
  719. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  720. end;
  721. { for regular arrays, we don't have to do anything because the index has been
  722. type converted to the index type, which already inserted a range check if
  723. necessary }
  724. paraloc1.done;
  725. paraloc2.done;
  726. end;
  727. procedure tcgvecnode.rangecheck_string;
  728. var
  729. paraloc1,
  730. paraloc2: tcgpara;
  731. helpername: TIDString;
  732. pd: tprocdef;
  733. begin
  734. paraloc1.init;
  735. paraloc2.init;
  736. case tstringdef(left.resultdef).stringtype of
  737. { it's the same for ansi- and wide strings }
  738. st_unicodestring,
  739. st_widestring,
  740. st_ansistring:
  741. begin
  742. helpername:='fpc_'+tstringdef(left.resultdef).stringtypname+'_rangecheck';
  743. pd:=search_system_proc(helpername);
  744. paramanager.getintparaloc(pd,1,paraloc1);
  745. paramanager.getintparaloc(pd,2,paraloc2);
  746. if pd.is_pushleftright then
  747. begin
  748. cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,left.location,paraloc1);
  749. cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,right.location,paraloc2);
  750. end
  751. else
  752. begin
  753. cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,right.location,paraloc2);
  754. cg.a_load_loc_cgpara(current_asmdata.CurrAsmList,left.location,paraloc1);
  755. end;
  756. paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc1);
  757. paramanager.freecgpara(current_asmdata.CurrAsmList,paraloc2);
  758. cg.allocallcpuregisters(current_asmdata.CurrAsmList);
  759. cg.a_call_name(current_asmdata.CurrAsmList,helpername,false);
  760. cg.deallocallcpuregisters(current_asmdata.CurrAsmList);
  761. end;
  762. st_shortstring:
  763. begin
  764. {!!!!!!!!!!!!!!!!!}
  765. { if this one is implemented making use of the high parameter for openshortstrings, update ncgutils.do_get_used_regvars() too (JM) }
  766. end;
  767. st_longstring:
  768. begin
  769. {!!!!!!!!!!!!!!!!!}
  770. end;
  771. end;
  772. paraloc1.done;
  773. paraloc2.done;
  774. end;
  775. procedure tcgvecnode.pass_generate_code;
  776. var
  777. offsetdec,
  778. extraoffset : aint;
  779. rightp : pnode;
  780. otl,ofl : tasmlabel;
  781. newsize : tcgsize;
  782. mulsize,
  783. bytemulsize,
  784. alignpow : aint;
  785. isjump : boolean;
  786. paraloc1,
  787. paraloc2 : tcgpara;
  788. subsetref : tsubsetreference;
  789. temp : longint;
  790. begin
  791. paraloc1.init;
  792. paraloc2.init;
  793. mulsize:=get_mul_size;
  794. if not is_packed_array(left.resultdef) then
  795. bytemulsize:=mulsize
  796. else
  797. bytemulsize:=mulsize div 8;
  798. newsize:=def_cgsize(resultdef);
  799. secondpass(left);
  800. if left.location.loc=LOC_CREFERENCE then
  801. location_reset_ref(location,LOC_CREFERENCE,newsize,left.location.reference.alignment)
  802. else
  803. location_reset_ref(location,LOC_REFERENCE,newsize,left.location.reference.alignment);
  804. { an ansistring needs to be dereferenced }
  805. if is_ansistring(left.resultdef) or
  806. is_wide_or_unicode_string(left.resultdef) then
  807. begin
  808. if nf_callunique in flags then
  809. internalerror(200304236);
  810. {DM!!!!!}
  811. case left.location.loc of
  812. LOC_REGISTER,
  813. LOC_CREGISTER :
  814. begin
  815. {$ifdef m68k}
  816. location.reference.base:=cg.getaddressregister(current_asmdata.CurrAsmList);
  817. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,left.location.register,location.reference.base);
  818. {$else m68k}
  819. hlcg.reference_reset_base(location.reference,left.resultdef,left.location.register,0,location.reference.alignment);
  820. {$endif m68k}
  821. end;
  822. LOC_CREFERENCE,
  823. LOC_REFERENCE :
  824. begin
  825. hlcg.reference_reset_base(location.reference,left.resultdef,hlcg.getaddressregister(current_asmdata.CurrAsmList,left.resultdef),0,location.reference.alignment);
  826. hlcg.a_load_ref_reg(current_asmdata.CurrAsmList,left.resultdef,left.resultdef,left.location.reference,location.reference.base);
  827. end;
  828. LOC_CONSTANT:
  829. begin
  830. hlcg.reference_reset_base(location.reference,left.resultdef,NR_NO,left.location.value,location.reference.alignment);
  831. end;
  832. else
  833. internalerror(2002032218);
  834. end;
  835. if is_ansistring(left.resultdef) then
  836. offsetdec:=1
  837. else
  838. offsetdec:=2;
  839. location.reference.alignment:=offsetdec;
  840. { in ansistrings/widestrings S[1] is p<w>char(S)[0] }
  841. if not(cs_zerobasedstrings in current_settings.localswitches) then
  842. dec(location.reference.offset,offsetdec);
  843. end
  844. else if is_dynamic_array(left.resultdef) then
  845. begin
  846. case left.location.loc of
  847. LOC_REGISTER,
  848. LOC_CREGISTER :
  849. hlcg.reference_reset_base(location.reference,left.resultdef,left.location.register,0,location.reference.alignment);
  850. LOC_REFERENCE,
  851. LOC_CREFERENCE :
  852. begin
  853. hlcg.reference_reset_base(location.reference,left.resultdef,hlcg.getaddressregister(current_asmdata.CurrAsmList,left.resultdef),0,location.reference.alignment);
  854. hlcg.a_load_ref_reg(current_asmdata.CurrAsmList,left.resultdef,left.resultdef,
  855. left.location.reference,location.reference.base);
  856. end;
  857. else
  858. internalerror(2002032219);
  859. end;
  860. { a dynarray points to the start of a memory block, which
  861. we assume to be always aligned to a multiple of the
  862. pointer size
  863. }
  864. location.reference.alignment:=voidpointertype.size;
  865. end
  866. else
  867. begin
  868. { may happen in case of function results }
  869. case left.location.loc of
  870. LOC_CREGISTER,
  871. LOC_CMMREGISTER,
  872. LOC_REGISTER,
  873. LOC_MMREGISTER:
  874. hlcg.location_force_mem(current_asmdata.CurrAsmList,left.location,left.resultdef);
  875. end;
  876. location_copy(location,left.location);
  877. end;
  878. { location must be memory }
  879. if not(location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  880. internalerror(200411013);
  881. { offset can only differ from 0 if arraydef }
  882. if (left.resultdef.typ=arraydef) and
  883. not(is_dynamic_array(left.resultdef)) and
  884. (not(is_packed_array(left.resultdef)) or
  885. ((mulsize mod 8 = 0) and
  886. ispowerof2(mulsize div 8,temp)) or
  887. { only orddefs are bitpacked }
  888. not is_ordinal(resultdef)
  889. {$ifndef cpu64bitalu}
  890. or is_64bitint(resultdef)
  891. {$endif not cpu64bitalu}
  892. ) then
  893. dec(location.reference.offset,bytemulsize*tarraydef(left.resultdef).lowrange);
  894. if right.nodetype=ordconstn then
  895. begin
  896. { offset can only differ from 0 if arraydef }
  897. if cs_check_range in current_settings.localswitches then
  898. begin
  899. secondpass(right);
  900. case left.resultdef.typ of
  901. arraydef :
  902. rangecheck_array;
  903. stringdef :
  904. rangecheck_string;
  905. end;
  906. end;
  907. if not(is_packed_array(left.resultdef)) or
  908. ((mulsize mod 8 = 0) and
  909. (ispowerof2(mulsize div 8,temp) or
  910. { only orddefs are bitpacked }
  911. not is_ordinal(resultdef))) then
  912. begin
  913. extraoffset:=bytemulsize*tordconstnode(right).value.svalue;
  914. inc(location.reference.offset,extraoffset);
  915. { adjust alignment after to this change }
  916. location.reference.alignment:=newalignment(location.reference.alignment,extraoffset);
  917. { don't do this for floats etc.; needed to properly set the }
  918. { size for bitpacked arrays (e.g. a bitpacked array of }
  919. { enums who are size 2 but fit in one byte -> in the array }
  920. { they will be one byte and have to be stored like that) }
  921. if is_packed_array(left.resultdef) and
  922. (tcgsize2size[newsize] <> bytemulsize) then
  923. newsize:=int_cgsize(bytemulsize);
  924. end
  925. else
  926. begin
  927. subsetref.ref := location.reference;
  928. subsetref.ref.alignment := left.resultdef.alignment;
  929. if not ispowerof2(subsetref.ref.alignment,temp) then
  930. internalerror(2006081212);
  931. alignpow:=temp;
  932. inc(subsetref.ref.offset,((mulsize * (tordconstnode(right).value.svalue-tarraydef(left.resultdef).lowrange)) shr (3+alignpow)) shl alignpow);
  933. subsetref.bitindexreg := NR_NO;
  934. subsetref.startbit := (mulsize * (tordconstnode(right).value.svalue-tarraydef(left.resultdef).lowrange)) and ((1 shl (3+alignpow))-1);
  935. subsetref.bitlen := resultdef.packedbitsize;
  936. if (left.location.loc = LOC_REFERENCE) then
  937. location.loc := LOC_SUBSETREF
  938. else
  939. location.loc := LOC_CSUBSETREF;
  940. location.sref := subsetref;
  941. end;
  942. end
  943. else
  944. { not nodetype=ordconstn }
  945. begin
  946. if (cs_opt_level1 in current_settings.optimizerswitches) and
  947. { if we do range checking, we don't }
  948. { need that fancy code (it would be }
  949. { buggy) }
  950. not(cs_check_range in current_settings.localswitches) and
  951. (left.resultdef.typ=arraydef) and
  952. not is_packed_array(left.resultdef) then
  953. begin
  954. extraoffset:=0;
  955. rightp:=actualtargetnode(@right);
  956. if rightp^.nodetype=addn then
  957. begin
  958. if taddnode(rightp^).right.nodetype=ordconstn then
  959. begin
  960. extraoffset:=tordconstnode(taddnode(rightp^).right).value.svalue;
  961. replacenode(rightp^,taddnode(rightp^).left);
  962. end
  963. else if taddnode(rightp^).left.nodetype=ordconstn then
  964. begin
  965. extraoffset:=tordconstnode(taddnode(rightp^).left).value.svalue;
  966. replacenode(rightp^,taddnode(rightp^).right);
  967. end;
  968. end
  969. else if rightp^.nodetype=subn then
  970. begin
  971. if taddnode(rightp^).right.nodetype=ordconstn then
  972. begin
  973. extraoffset:=-tordconstnode(taddnode(rightp^).right).value.svalue;
  974. replacenode(rightp^,taddnode(rightp^).left);
  975. end;
  976. end;
  977. inc(location.reference.offset,
  978. mulsize*extraoffset);
  979. end;
  980. { calculate from left to right }
  981. if not(location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
  982. internalerror(200304237);
  983. isjump:=(right.expectloc=LOC_JUMP);
  984. otl:=nil;
  985. ofl:=nil;
  986. if isjump then
  987. begin
  988. otl:=current_procinfo.CurrTrueLabel;
  989. current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
  990. ofl:=current_procinfo.CurrFalseLabel;
  991. current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
  992. end;
  993. secondpass(right);
  994. { if mulsize = 1, we won't have to modify the index }
  995. if not(right.location.loc in [LOC_CREGISTER,LOC_REGISTER]) or (right.location.size<>OS_ADDR) then
  996. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,ptruinttype,true);
  997. if isjump then
  998. begin
  999. current_procinfo.CurrTrueLabel:=otl;
  1000. current_procinfo.CurrFalseLabel:=ofl;
  1001. end
  1002. else if (right.location.loc = LOC_JUMP) then
  1003. internalerror(2006010801);
  1004. { produce possible range check code: }
  1005. if cs_check_range in current_settings.localswitches then
  1006. begin
  1007. if left.resultdef.typ=arraydef then
  1008. rangecheck_array
  1009. else if (left.resultdef.typ=stringdef) then
  1010. rangecheck_string;
  1011. end;
  1012. { insert the register and the multiplication factor in the
  1013. reference }
  1014. if not is_packed_array(left.resultdef) then
  1015. update_reference_reg_mul(right.location.register,mulsize)
  1016. else
  1017. update_reference_reg_packed(right.location.register,mulsize);
  1018. end;
  1019. location.size:=newsize;
  1020. paraloc1.done;
  1021. paraloc2.done;
  1022. end;
  1023. begin
  1024. cloadvmtaddrnode:=tcgloadvmtaddrnode;
  1025. cloadparentfpnode:=tcgloadparentfpnode;
  1026. caddrnode:=tcgaddrnode;
  1027. cderefnode:=tcgderefnode;
  1028. csubscriptnode:=tcgsubscriptnode;
  1029. cwithnode:=tcgwithnode;
  1030. cvecnode:=tcgvecnode;
  1031. end.