ncgld.pas 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate assembler for nodes that handle loads and assignments which
  5. are the same for all (most) processors
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit ncgld;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. node,nld;
  24. type
  25. tcgloadnode = class(tloadnode)
  26. procedure pass_2;override;
  27. procedure generate_picvaraccess;virtual;
  28. end;
  29. tcgassignmentnode = class(tassignmentnode)
  30. procedure pass_2;override;
  31. end;
  32. tcgarrayconstructornode = class(tarrayconstructornode)
  33. procedure pass_2;override;
  34. end;
  35. implementation
  36. uses
  37. cutils,
  38. systems,
  39. verbose,globtype,globals,
  40. symconst,symtype,symdef,symsym,defutil,paramgr,
  41. ncnv,ncon,nmem,nbas,
  42. aasmbase,aasmtai,aasmcpu,
  43. cgbase,pass_2,
  44. procinfo,
  45. cpubase,cpuinfo,
  46. tgobj,ncgutil,
  47. cgutils,cgobj,
  48. ncgbas;
  49. {*****************************************************************************
  50. SecondLoad
  51. *****************************************************************************}
  52. procedure tcgloadnode.generate_picvaraccess;
  53. begin
  54. location.reference.base:=current_procinfo.got;
  55. location.reference.symbol:=objectlibrary.newasmsymbol(tvarsym(symtableentry).mangledname+'@GOT',AB_EXTERNAL,AT_DATA);
  56. end;
  57. procedure tcgloadnode.pass_2;
  58. var
  59. hregister : tregister;
  60. symtabletype : tsymtabletype;
  61. href : treference;
  62. newsize : tcgsize;
  63. endrelocatelab,
  64. norelocatelab : tasmlabel;
  65. paraloc1 : tparalocation;
  66. begin
  67. { we don't know the size of all arrays }
  68. newsize:=def_cgsize(resulttype.def);
  69. location_reset(location,LOC_REFERENCE,newsize);
  70. case symtableentry.typ of
  71. absolutesym :
  72. begin
  73. { this is only for toasm and toaddr }
  74. case tabsolutesym(symtableentry).abstyp of
  75. toaddr :
  76. begin
  77. {$ifdef i386}
  78. if tabsolutesym(symtableentry).absseg then
  79. location.reference.segment:=NR_FS;
  80. {$endif i386}
  81. location.reference.offset:=tabsolutesym(symtableentry).fieldoffset;
  82. end;
  83. toasm :
  84. location.reference.symbol:=objectlibrary.newasmsymbol(tabsolutesym(symtableentry).mangledname,AB_EXTERNAL,AT_DATA);
  85. else
  86. internalerror(200310283);
  87. end;
  88. end;
  89. constsym:
  90. begin
  91. if tconstsym(symtableentry).consttyp=constresourcestring then
  92. begin
  93. location_reset(location,LOC_CREFERENCE,OS_ADDR);
  94. location.reference.symbol:=objectlibrary.newasmsymbol(make_mangledname('RESOURCESTRINGLIST',tconstsym(symtableentry).owner,''),AB_EXTERNAL,AT_DATA);
  95. location.reference.offset:=tconstsym(symtableentry).resstrindex*16+8;
  96. end
  97. else
  98. internalerror(22798);
  99. end;
  100. varsym :
  101. begin
  102. if (tvarsym(symtableentry).varspez=vs_const) then
  103. location_reset(location,LOC_CREFERENCE,newsize);
  104. symtabletype:=symtable.symtabletype;
  105. hregister:=NR_NO;
  106. { C variable }
  107. if (vo_is_C_var in tvarsym(symtableentry).varoptions) then
  108. begin
  109. location.reference.symbol:=objectlibrary.newasmsymbol(tvarsym(symtableentry).mangledname,AB_EXTERNAL,AT_DATA);
  110. end
  111. { DLL variable }
  112. else if (vo_is_dll_var in tvarsym(symtableentry).varoptions) then
  113. begin
  114. if target_info.system=system_powerpc_darwin then
  115. begin
  116. generate_picvaraccess;
  117. if not(pi_needs_got in current_procinfo.flags) then
  118. internalerror(200403022);
  119. end
  120. else
  121. begin
  122. hregister:=cg.getaddressregister(exprasmlist);
  123. location.reference.symbol:=objectlibrary.newasmsymbol(tvarsym(symtableentry).mangledname,AB_EXTERNAL,AT_DATA);
  124. cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,location.reference,hregister);
  125. reference_reset_base(location.reference,hregister,0);
  126. end;
  127. end
  128. { external variable }
  129. else if (vo_is_external in tvarsym(symtableentry).varoptions) then
  130. begin
  131. location.reference.symbol:=objectlibrary.newasmsymbol(tvarsym(symtableentry).mangledname,AB_EXTERNAL,AT_DATA);
  132. end
  133. { thread variable }
  134. else if (vo_is_thread_var in tvarsym(symtableentry).varoptions) then
  135. begin
  136. {
  137. Thread var loading is optimized to first check if
  138. a relocate function is available. When the function
  139. is available it is called to retrieve the address.
  140. Otherwise the address is loaded with the symbol
  141. The code needs to be in the order to first handle the
  142. call and then the address load to be sure that the
  143. register that is used for returning is the same (PFV)
  144. }
  145. objectlibrary.getlabel(norelocatelab);
  146. objectlibrary.getlabel(endrelocatelab);
  147. { make sure hregister can't allocate the register necessary for the parameter }
  148. paraloc1:=paramanager.getintparaloc(pocall_default,1);
  149. hregister:=cg.getaddressregister(exprasmlist);
  150. reference_reset_symbol(href,objectlibrary.newasmsymbol('FPC_THREADVAR_RELOCATE',AB_EXTERNAL,AT_DATA),0);
  151. cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,href,hregister);
  152. cg.ungetregister(exprasmlist,hregister);
  153. cg.a_cmp_const_reg_label(exprasmlist,OS_ADDR,OC_EQ,0,hregister,norelocatelab);
  154. { don't save the allocated register else the result will be destroyed later }
  155. reference_reset_symbol(href,objectlibrary.newasmsymbol(tvarsym(symtableentry).mangledname,AB_EXTERNAL,AT_DATA),0);
  156. paramanager.allocparaloc(exprasmlist,paraloc1);
  157. cg.a_param_ref(exprasmlist,OS_ADDR,href,paraloc1);
  158. paramanager.freeparaloc(exprasmlist,paraloc1);
  159. cg.allocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  160. cg.a_call_reg(exprasmlist,hregister);
  161. cg.deallocexplicitregisters(exprasmlist,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_default));
  162. cg.getexplicitregister(exprasmlist,NR_FUNCTION_RESULT_REG);
  163. cg.ungetregister(exprasmlist,NR_FUNCTION_RESULT_REG);
  164. hregister:=cg.getaddressregister(exprasmlist);
  165. cg.a_load_reg_reg(exprasmlist,OS_INT,OS_ADDR,NR_FUNCTION_RESULT_REG,hregister);
  166. cg.a_jmp_always(exprasmlist,endrelocatelab);
  167. cg.a_label(exprasmlist,norelocatelab);
  168. { no relocation needed, load the address of the variable only, the
  169. layout of a threadvar is (4 bytes pointer):
  170. 0 - Threadvar index
  171. 4 - Threadvar value in single threading }
  172. reference_reset_symbol(href,objectlibrary.newasmsymbol(tvarsym(symtableentry).mangledname,AB_EXTERNAL,AT_DATA),POINTER_SIZE);
  173. cg.a_loadaddr_ref_reg(exprasmlist,href,hregister);
  174. cg.a_label(exprasmlist,endrelocatelab);
  175. location.reference.base:=hregister;
  176. end
  177. { nested variable }
  178. else if assigned(left) then
  179. begin
  180. if not(symtabletype in [localsymtable,parasymtable]) then
  181. internalerror(200309285);
  182. secondpass(left);
  183. if left.location.loc<>LOC_REGISTER then
  184. internalerror(200309286);
  185. hregister:=left.location.register;
  186. location.reference.base:=hregister;
  187. location.reference.offset:=tvarsym(symtableentry).localloc.reference.offset;
  188. end
  189. { normal variable }
  190. else
  191. begin
  192. { in case it is a register variable: }
  193. if tvarsym(symtableentry).localloc.loc in [LOC_REGISTER,LOC_FPUREGISTER] then
  194. begin
  195. case getregtype(tvarsym(symtableentry).localloc.register) of
  196. R_FPUREGISTER :
  197. begin
  198. location_reset(location,LOC_CFPUREGISTER,def_cgsize(resulttype.def));
  199. location.register:=tvarsym(symtableentry).localloc.register;
  200. end;
  201. R_INTREGISTER :
  202. begin
  203. location_reset(location,LOC_CREGISTER,def_cgsize(resulttype.def));
  204. location.register:=tvarsym(symtableentry).localloc.register;
  205. hregister := location.register;
  206. end;
  207. else
  208. internalerror(200301172);
  209. end;
  210. end
  211. else
  212. begin
  213. case symtabletype of
  214. localsymtable,
  215. parasymtable :
  216. begin
  217. if tvarsym(symtableentry).localloc.loc<>LOC_REFERENCE then
  218. internalerror(2003091816);
  219. location.reference.base:=tvarsym(symtableentry).localloc.reference.index;
  220. location.reference.offset:=tvarsym(symtableentry).localloc.reference.offset;
  221. end;
  222. globalsymtable,
  223. staticsymtable :
  224. begin
  225. if cs_create_pic in aktmoduleswitches then
  226. begin
  227. generate_picvaraccess;
  228. if not(pi_needs_got in current_procinfo.flags) then
  229. internalerror(200403023);
  230. end
  231. else
  232. location.reference.symbol:=objectlibrary.newasmsymbol(tvarsym(symtableentry).mangledname,AB_EXTERNAL,AT_DATA);
  233. end;
  234. stt_exceptsymtable:
  235. begin
  236. if tvarsym(symtableentry).localloc.loc<>LOC_REFERENCE then
  237. internalerror(2003091817);
  238. location.reference.base:=tvarsym(symtableentry).localloc.reference.index;
  239. location.reference.offset:=tvarsym(symtableentry).localloc.reference.offset;
  240. end;
  241. else
  242. internalerror(200305102);
  243. end;
  244. end;
  245. end;
  246. { handle call by reference variables when they are not
  247. alreayd copied to local copies. Also ignore the reference
  248. when we need to load the self pointer for objects }
  249. if (symtabletype=parasymtable) and
  250. not(vo_has_local_copy in tvarsym(symtableentry).varoptions) and
  251. not(nf_load_self_pointer in flags) and
  252. paramanager.push_addr_param(tvarsym(symtableentry).varspez,tvarsym(symtableentry).vartype.def,tprocdef(symtable.defowner).proccalloption) then
  253. begin
  254. if hregister=NR_NO then
  255. hregister:=cg.getaddressregister(exprasmlist);
  256. { we need to load only an address }
  257. location.size:=OS_ADDR;
  258. cg.a_load_loc_reg(exprasmlist,location.size,location,hregister);
  259. if tvarsym(symtableentry).varspez=vs_const then
  260. location_reset(location,LOC_CREFERENCE,newsize)
  261. else
  262. location_reset(location,LOC_REFERENCE,newsize);
  263. location.reference.base:=hregister;
  264. end;
  265. end;
  266. procsym:
  267. begin
  268. if not assigned(procdef) then
  269. internalerror(200312011);
  270. if assigned(left) then
  271. begin
  272. {
  273. THIS IS A TERRIBLE HACK!!!!!! WHICH WILL NOT WORK
  274. ON 64-BIT SYSTEMS: SINCE PROCSYM FOR METHODS
  275. CONSISTS OF TWO OS_ADDR, so you cannot set it
  276. to OS_64 - how to solve?? Carl
  277. Solved. Florian
  278. }
  279. if (sizeof(aword) = 4) then
  280. location_reset(location,LOC_CREFERENCE,OS_64)
  281. else if (sizeof(aword) = 8) then
  282. location_reset(location,LOC_CREFERENCE,OS_128)
  283. else
  284. internalerror(20020520);
  285. tg.GetTemp(exprasmlist,2*POINTER_SIZE,tt_normal,location.reference);
  286. secondpass(left);
  287. { load class instance address }
  288. case left.location.loc of
  289. LOC_CREGISTER,
  290. LOC_REGISTER:
  291. begin
  292. { this is not possible for objects }
  293. if is_object(left.resulttype.def) then
  294. internalerror(200304234);
  295. hregister:=left.location.register;
  296. end;
  297. LOC_CREFERENCE,
  298. LOC_REFERENCE:
  299. begin
  300. location_release(exprasmlist,left.location);
  301. hregister:=cg.getaddressregister(exprasmlist);
  302. if is_class_or_interface(left.resulttype.def) then
  303. cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,left.location.reference,hregister)
  304. else
  305. cg.a_loadaddr_ref_reg(exprasmlist,left.location.reference,hregister);
  306. location_freetemp(exprasmlist,left.location);
  307. end;
  308. else
  309. internalerror(26019);
  310. end;
  311. { store the class instance address }
  312. href:=location.reference;
  313. inc(href.offset,POINTER_SIZE);
  314. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,href);
  315. { virtual method ? }
  316. if (po_virtualmethod in procdef.procoptions) then
  317. begin
  318. { load vmt pointer }
  319. reference_reset_base(href,hregister,0);
  320. reference_release(exprasmlist,href);
  321. hregister:=cg.getaddressregister(exprasmlist);
  322. cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,href,hregister);
  323. reference_reset_base(href,hregister,
  324. procdef._class.vmtmethodoffset(procdef.extnumber));
  325. reference_release(exprasmlist,href);
  326. { load method address }
  327. hregister:=cg.getaddressregister(exprasmlist);
  328. cg.a_load_ref_reg(exprasmlist,OS_ADDR,OS_ADDR,href,hregister);
  329. { ... and store it }
  330. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference);
  331. cg.ungetregister(exprasmlist,hregister);
  332. end
  333. else
  334. begin
  335. { we don't use the hregister }
  336. cg.ungetregister(exprasmlist,hregister);
  337. { load address of the function }
  338. reference_reset_symbol(href,objectlibrary.newasmsymbol(procdef.mangledname,AB_EXTERNAL,AT_FUNCTION),0);
  339. hregister:=cg.getaddressregister(exprasmlist);
  340. cg.a_loadaddr_ref_reg(exprasmlist,href,hregister);
  341. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,hregister,location.reference);
  342. cg.ungetregister(exprasmlist,hregister);
  343. end;
  344. end
  345. else
  346. begin
  347. {!!!!! Be aware, work on virtual methods too }
  348. location.reference.symbol:=objectlibrary.newasmsymbol(procdef.mangledname,AB_EXTERNAL,AT_FUNCTION);
  349. end;
  350. end;
  351. typedconstsym :
  352. begin
  353. location.reference.symbol:=objectlibrary.newasmsymbol(ttypedconstsym(symtableentry).mangledname,AB_EXTERNAL,AT_DATA);
  354. end;
  355. else internalerror(4);
  356. end;
  357. end;
  358. {*****************************************************************************
  359. SecondAssignment
  360. *****************************************************************************}
  361. procedure tcgassignmentnode.pass_2;
  362. var
  363. otlabel,hlabel,oflabel : tasmlabel;
  364. fputyp : tfloattype;
  365. href : treference;
  366. old_allow_multi_pass2,
  367. releaseright : boolean;
  368. cgsize : tcgsize;
  369. r:Tregister;
  370. begin
  371. location_reset(location,LOC_VOID,OS_NO);
  372. otlabel:=truelabel;
  373. oflabel:=falselabel;
  374. objectlibrary.getlabel(truelabel);
  375. objectlibrary.getlabel(falselabel);
  376. {
  377. in most cases we can process first the right node which contains
  378. the most complex code. But not when the result is in the flags, then
  379. loading the left node afterwards can destroy the flags.
  380. when the right node returns as LOC_JUMP then we will generate
  381. the following code:
  382. rightnode
  383. true:
  384. leftnode
  385. assign 1
  386. false:
  387. leftnode
  388. assign 0
  389. }
  390. { Try to determine which side to calculate first, }
  391. if (right.expectloc<>LOC_FLAGS) and
  392. ((right.expectloc=LOC_JUMP) or
  393. (right.nodetype=calln) or
  394. (right.registersint>=left.registersint)) then
  395. begin
  396. secondpass(right);
  397. { increment source reference counter, this is
  398. useless for string constants}
  399. if (right.resulttype.def.needs_inittable) and
  400. (right.nodetype<>stringconstn) then
  401. cg.g_incrrefcount(exprasmlist,right.resulttype.def,right.location.reference,false);
  402. if codegenerror then
  403. exit;
  404. { We skip the generation of the left node when it's a jump, see
  405. explanation above }
  406. if (right.location.loc<>LOC_JUMP) and
  407. not(nf_concat_string in flags) then
  408. begin
  409. { left can't be never a 64 bit LOC_REGISTER, so the 3. arg }
  410. { can be false }
  411. secondpass(left);
  412. { decrement destination reference counter }
  413. if (left.resulttype.def.needs_inittable) then
  414. cg.g_decrrefcount(exprasmlist,left.resulttype.def,left.location.reference,false);
  415. if codegenerror then
  416. exit;
  417. end;
  418. end
  419. else
  420. begin
  421. { calculate left sides }
  422. { don't do it yet if it's a crgister (JM) }
  423. if not(nf_concat_string in flags) then
  424. begin
  425. secondpass(left);
  426. { decrement destination reference counter }
  427. if (left.resulttype.def.needs_inittable) then
  428. cg.g_decrrefcount(exprasmlist,left.resulttype.def,left.location.reference,false);
  429. if codegenerror then
  430. exit;
  431. end;
  432. { left can't be never a 64 bit LOC_REGISTER, so the 3. arg }
  433. { can be false }
  434. secondpass(right);
  435. { increment source reference counter, this is
  436. useless for string constants}
  437. if (right.resulttype.def.needs_inittable) and
  438. (right.nodetype<>stringconstn) then
  439. cg.g_incrrefcount(exprasmlist,right.resulttype.def,right.location.reference,false);
  440. if codegenerror then
  441. exit;
  442. end;
  443. releaseright:=true;
  444. { optimize temp to temp copies }
  445. if (left.nodetype = temprefn) and
  446. { we may store certain temps in registers in the future, then this }
  447. { optimization will have to be adapted }
  448. (left.location.loc = LOC_REFERENCE) and
  449. (right.location.loc = LOC_REFERENCE) and
  450. tg.istemp(right.location.reference) and
  451. (tg.sizeoftemp(exprasmlist,right.location.reference) = tg.sizeoftemp(exprasmlist,left.location.reference)) then
  452. begin
  453. { in theory, we should also make sure the left temp type is }
  454. { already more or less of the same kind (ie. we must not }
  455. { assign an ansistring to a normaltemp). In practice, the }
  456. { assignment node will have already taken care of this for us }
  457. tcgtemprefnode(left).changelocation(right.location.reference);
  458. end
  459. { shortstring assignments are handled separately }
  460. else if is_shortstring(left.resulttype.def) then
  461. begin
  462. {
  463. we can get here only in the following situations
  464. for the right node:
  465. - empty constant string
  466. - char
  467. }
  468. { empty constant string }
  469. if (right.nodetype=stringconstn) and
  470. (tstringconstnode(right).len=0) then
  471. begin
  472. cg.a_load_const_ref(exprasmlist,OS_8,0,left.location.reference);
  473. end
  474. { char loading }
  475. else if is_char(right.resulttype.def) then
  476. begin
  477. if right.nodetype=ordconstn then
  478. begin
  479. if (target_info.endian = endian_little) then
  480. cg.a_load_const_ref(exprasmlist,OS_16,(tordconstnode(right).value shl 8) or 1,
  481. left.location.reference)
  482. else
  483. cg.a_load_const_ref(exprasmlist,OS_16,tordconstnode(right).value or (1 shl 8),
  484. left.location.reference);
  485. end
  486. else
  487. begin
  488. href:=left.location.reference;
  489. cg.a_load_const_ref(exprasmlist,OS_8,1,href);
  490. inc(href.offset,1);
  491. case right.location.loc of
  492. LOC_REGISTER,
  493. LOC_CREGISTER :
  494. begin
  495. r:=cg.makeregsize(right.location.register,OS_8);
  496. cg.a_load_reg_ref(exprasmlist,OS_8,OS_8,r,href);
  497. end;
  498. LOC_REFERENCE,
  499. LOC_CREFERENCE :
  500. cg.a_load_ref_ref(exprasmlist,OS_8,OS_8,right.location.reference,href);
  501. else
  502. internalerror(200205111);
  503. end;
  504. end;
  505. end
  506. else
  507. internalerror(200204249);
  508. end
  509. else
  510. begin
  511. case right.location.loc of
  512. LOC_CONSTANT :
  513. begin
  514. if right.location.size in [OS_64,OS_S64] then
  515. cg64.a_load64_const_loc(exprasmlist,
  516. right.location.valueqword,left.location)
  517. else
  518. cg.a_load_const_loc(exprasmlist,right.location.value,left.location);
  519. end;
  520. LOC_REFERENCE,
  521. LOC_CREFERENCE :
  522. begin
  523. case left.location.loc of
  524. LOC_CREGISTER :
  525. begin
  526. cgsize:=def_cgsize(left.resulttype.def);
  527. if cgsize in [OS_64,OS_S64] then
  528. begin
  529. cg64.a_load64_ref_reg(exprasmlist,
  530. right.location.reference,left.location.register64);
  531. location_release(exprasmlist,right.location);
  532. end
  533. else
  534. begin
  535. location_release(exprasmlist,right.location);
  536. cg.a_load_ref_reg(exprasmlist,cgsize,cgsize,
  537. right.location.reference,left.location.register);
  538. end;
  539. end;
  540. LOC_CFPUREGISTER :
  541. begin
  542. cg.a_loadfpu_ref_reg(exprasmlist,
  543. def_cgsize(right.resulttype.def),
  544. right.location.reference,
  545. left.location.register);
  546. end;
  547. LOC_REFERENCE,
  548. LOC_CREFERENCE :
  549. begin
  550. cg.g_concatcopy(exprasmlist,right.location.reference,
  551. left.location.reference,left.resulttype.def.size,true,false);
  552. { right.location is already released by concatcopy }
  553. releaseright:=false;
  554. end;
  555. else
  556. internalerror(200203284);
  557. end;
  558. end;
  559. {$ifdef SUPPORT_MMX}
  560. LOC_CMMXREGISTER,
  561. LOC_MMXREGISTER:
  562. begin
  563. if left.location.loc=LOC_CMMXREGISTER then
  564. cg.a_loadmm_reg_reg(exprasmlist,right.location.register,left.location.register)
  565. else
  566. cg.a_loadmm_reg_ref(exprasmlist,right.location.register,left.location.reference);
  567. end;
  568. {$endif SUPPORT_MMX}
  569. LOC_MMREGISTER,
  570. LOC_CMMREGISTER:
  571. begin
  572. if left.resulttype.def.deftype=arraydef then
  573. begin
  574. end
  575. else
  576. begin
  577. cgsize:=def_cgsize(left.resulttype.def);
  578. if left.location.loc=LOC_CMMREGISTER then
  579. cg.a_loadmm_reg_reg(exprasmlist,right.location.size,left.location.size,right.location.register,left.location.register,mms_movescalar)
  580. else
  581. cg.a_loadmm_reg_ref(exprasmlist,right.location.size,left.location.size,right.location.register,left.location.reference,mms_movescalar);
  582. end;
  583. end;
  584. LOC_REGISTER,
  585. LOC_CREGISTER :
  586. begin
  587. cgsize:=def_cgsize(left.resulttype.def);
  588. if cgsize in [OS_64,OS_S64] then
  589. cg64.a_load64_reg_loc(exprasmlist,
  590. right.location.register64,left.location)
  591. else
  592. cg.a_load_reg_loc(exprasmlist,right.location.size,right.location.register,left.location);
  593. end;
  594. LOC_FPUREGISTER,LOC_CFPUREGISTER :
  595. begin
  596. if (left.resulttype.def.deftype=floatdef) then
  597. fputyp:=tfloatdef(left.resulttype.def).typ
  598. else
  599. if (right.resulttype.def.deftype=floatdef) then
  600. fputyp:=tfloatdef(right.resulttype.def).typ
  601. else
  602. if (right.nodetype=typeconvn) and
  603. (ttypeconvnode(right).left.resulttype.def.deftype=floatdef) then
  604. fputyp:=tfloatdef(ttypeconvnode(right).left.resulttype.def).typ
  605. else
  606. fputyp:=s32real;
  607. cg.a_loadfpu_reg_loc(exprasmlist,
  608. tfloat2tcgsize[fputyp],
  609. right.location.register,left.location);
  610. end;
  611. LOC_JUMP :
  612. begin
  613. cgsize:=def_cgsize(left.resulttype.def);
  614. objectlibrary.getlabel(hlabel);
  615. { generate the leftnode for the true case, and
  616. release the location }
  617. cg.a_label(exprasmlist,truelabel);
  618. secondpass(left);
  619. if codegenerror then
  620. exit;
  621. cg.a_load_const_loc(exprasmlist,1,left.location);
  622. location_release(exprasmlist,left.location);
  623. cg.a_jmp_always(exprasmlist,hlabel);
  624. { generate the leftnode for the false case }
  625. cg.a_label(exprasmlist,falselabel);
  626. old_allow_multi_pass2:=allow_multi_pass2;
  627. allow_multi_pass2:=true;
  628. secondpass(left);
  629. allow_multi_pass2:=old_allow_multi_pass2;
  630. if codegenerror then
  631. exit;
  632. cg.a_load_const_loc(exprasmlist,0,left.location);
  633. cg.a_label(exprasmlist,hlabel);
  634. end;
  635. {$ifdef cpuflags}
  636. LOC_FLAGS :
  637. begin
  638. {This can be a wordbool or longbool too, no?}
  639. if left.location.loc=LOC_CREGISTER then
  640. cg.g_flags2reg(exprasmlist,def_cgsize(left.resulttype.def),right.location.resflags,left.location.register)
  641. else
  642. begin
  643. if not(left.location.loc = LOC_REFERENCE) then
  644. internalerror(200203273);
  645. cg.g_flags2ref(exprasmlist,def_cgsize(left.resulttype.def),right.location.resflags,left.location.reference);
  646. end;
  647. end;
  648. {$endif cpuflags}
  649. end;
  650. end;
  651. if releaseright then
  652. location_release(exprasmlist,right.location);
  653. location_release(exprasmlist,left.location);
  654. truelabel:=otlabel;
  655. falselabel:=oflabel;
  656. end;
  657. {*****************************************************************************
  658. SecondArrayConstruct
  659. *****************************************************************************}
  660. const
  661. vtInteger = 0;
  662. vtBoolean = 1;
  663. vtChar = 2;
  664. vtExtended = 3;
  665. vtString = 4;
  666. vtPointer = 5;
  667. vtPChar = 6;
  668. vtObject = 7;
  669. vtClass = 8;
  670. vtWideChar = 9;
  671. vtPWideChar = 10;
  672. vtAnsiString = 11;
  673. vtCurrency = 12;
  674. vtVariant = 13;
  675. vtInterface = 14;
  676. vtWideString = 15;
  677. vtInt64 = 16;
  678. vtQWord = 17;
  679. procedure tcgarrayconstructornode.pass_2;
  680. var
  681. hp : tarrayconstructornode;
  682. href : treference;
  683. lt : tdef;
  684. vaddr : boolean;
  685. vtype : longint;
  686. freetemp,
  687. dovariant : boolean;
  688. elesize : longint;
  689. tmpreg : tregister;
  690. paraloc : tparalocation;
  691. begin
  692. dovariant:=(nf_forcevaria in flags) or tarraydef(resulttype.def).isvariant;
  693. if dovariant then
  694. elesize:=8
  695. else
  696. elesize:=tarraydef(resulttype.def).elesize;
  697. location_reset(location,LOC_CREFERENCE,OS_NO);
  698. fillchar(paraloc,sizeof(paraloc),0);
  699. { Allocate always a temp, also if no elements are required, to
  700. be sure that location is valid (PFV) }
  701. if tarraydef(resulttype.def).highrange=-1 then
  702. tg.GetTemp(exprasmlist,elesize,tt_normal,location.reference)
  703. else
  704. tg.GetTemp(exprasmlist,(tarraydef(resulttype.def).highrange+1)*elesize,tt_normal,location.reference);
  705. href:=location.reference;
  706. { Process nodes in array constructor }
  707. hp:=self;
  708. while assigned(hp) do
  709. begin
  710. if assigned(hp.left) then
  711. begin
  712. freetemp:=true;
  713. secondpass(hp.left);
  714. if codegenerror then
  715. exit;
  716. { Move flags and jump in register }
  717. if hp.left.location.loc in [LOC_FLAGS,LOC_JUMP] then
  718. location_force_reg(exprasmlist,hp.left.location,def_cgsize(hp.left.resulttype.def),false);
  719. if dovariant then
  720. begin
  721. { find the correct vtype value }
  722. vtype:=$ff;
  723. vaddr:=false;
  724. lt:=hp.left.resulttype.def;
  725. case lt.deftype of
  726. enumdef,
  727. orddef :
  728. begin
  729. if is_64bit(lt) then
  730. begin
  731. case torddef(lt).typ of
  732. s64bit:
  733. vtype:=vtInt64;
  734. u64bit:
  735. vtype:=vtQWord;
  736. end;
  737. freetemp:=false;
  738. vaddr:=true;
  739. end
  740. else if (lt.deftype=enumdef) or
  741. is_integer(lt) then
  742. vtype:=vtInteger
  743. else
  744. if is_boolean(lt) then
  745. vtype:=vtBoolean
  746. else
  747. if (lt.deftype=orddef) then
  748. begin
  749. case torddef(lt).typ of
  750. uchar:
  751. vtype:=vtChar;
  752. uwidechar:
  753. vtype:=vtWideChar;
  754. end;
  755. end;
  756. end;
  757. floatdef :
  758. begin
  759. vtype:=vtExtended;
  760. freetemp:=false;
  761. vaddr:=true;
  762. end;
  763. procvardef,
  764. pointerdef :
  765. begin
  766. if is_pchar(lt) then
  767. vtype:=vtPChar
  768. else
  769. vtype:=vtPointer;
  770. end;
  771. variantdef :
  772. begin
  773. vtype:=vtVariant;
  774. vaddr:=true;
  775. freetemp:=false;
  776. end;
  777. classrefdef :
  778. vtype:=vtClass;
  779. objectdef :
  780. vtype:=vtObject;
  781. stringdef :
  782. begin
  783. if is_shortstring(lt) then
  784. begin
  785. vtype:=vtString;
  786. vaddr:=true;
  787. freetemp:=false;
  788. end
  789. else
  790. if is_ansistring(lt) then
  791. begin
  792. vtype:=vtAnsiString;
  793. freetemp:=false;
  794. end
  795. else
  796. if is_widestring(lt) then
  797. begin
  798. vtype:=vtWideString;
  799. freetemp:=false;
  800. end;
  801. end;
  802. end;
  803. if vtype=$ff then
  804. internalerror(14357);
  805. { write changing field update href to the next element }
  806. inc(href.offset,4);
  807. if vaddr then
  808. begin
  809. location_force_mem(exprasmlist,hp.left.location);
  810. location_release(exprasmlist,hp.left.location);
  811. tmpreg:=cg.getaddressregister(exprasmlist);
  812. cg.a_loadaddr_ref_reg(exprasmlist,hp.left.location.reference,tmpreg);
  813. cg.ungetregister(exprasmlist,tmpreg);
  814. cg.a_load_reg_ref(exprasmlist,OS_ADDR,OS_ADDR,tmpreg,href);
  815. if freetemp then
  816. location_freetemp(exprasmlist,hp.left.location);
  817. end
  818. else
  819. begin
  820. location_release(exprasmlist,hp.left.location);
  821. cg.a_load_loc_ref(exprasmlist,OS_ADDR,hp.left.location,href);
  822. end;
  823. { update href to the vtype field and write it }
  824. dec(href.offset,4);
  825. cg.a_load_const_ref(exprasmlist, OS_INT,vtype,href);
  826. { goto next array element }
  827. inc(href.offset,8);
  828. end
  829. else
  830. { normal array constructor of the same type }
  831. begin
  832. if is_ansistring(left.resulttype.def) or
  833. is_widestring(left.resulttype.def) or
  834. (left.resulttype.def.deftype=variantdef) then
  835. freetemp:=false;
  836. case hp.left.location.loc of
  837. LOC_FPUREGISTER,
  838. LOC_CFPUREGISTER :
  839. begin
  840. location_release(exprasmlist,hp.left.location);
  841. cg.a_loadfpu_reg_ref(exprasmlist,hp.left.location.size,hp.left.location.register,href);
  842. end;
  843. LOC_REFERENCE,
  844. LOC_CREFERENCE :
  845. begin
  846. location_release(exprasmlist,hp.left.location);
  847. if is_shortstring(hp.left.resulttype.def) then
  848. cg.g_copyshortstring(exprasmlist,hp.left.location.reference,href,
  849. Tstringdef(hp.left.resulttype.def).len,freetemp,false)
  850. else
  851. cg.g_concatcopy(exprasmlist,hp.left.location.reference,href,elesize,freetemp,false);
  852. end;
  853. else
  854. begin
  855. if hp.left.location.size in [OS_64,OS_S64] then
  856. begin
  857. cg64.a_load64_loc_ref(exprasmlist,hp.left.location,href);
  858. location_release(exprasmlist,hp.left.location);
  859. end
  860. else
  861. begin
  862. location_release(exprasmlist,hp.left.location);
  863. cg.a_load_loc_ref(exprasmlist,hp.left.location.size,hp.left.location,href);
  864. end;
  865. end;
  866. end;
  867. inc(href.offset,elesize);
  868. end;
  869. end;
  870. { load next entry }
  871. hp:=tarrayconstructornode(hp.right);
  872. end;
  873. end;
  874. begin
  875. cloadnode:=tcgloadnode;
  876. cassignmentnode:=tcgassignmentnode;
  877. carrayconstructornode:=tcgarrayconstructornode;
  878. end.
  879. {
  880. $Log$
  881. Revision 1.114 2004-03-02 17:32:12 florian
  882. * make cycle fixed
  883. + pic support for darwin
  884. + support of importing vars from shared libs on darwin implemented
  885. Revision 1.113 2004/03/02 00:36:33 olle
  886. * big transformation of Tai_[const_]Symbol.Create[data]name*
  887. Revision 1.112 2004/02/27 10:21:05 florian
  888. * top_symbol killed
  889. + refaddr to treference added
  890. + refsymbol to treference added
  891. * top_local stuff moved to an extra record to save memory
  892. + aint introduced
  893. * tppufile.get/putint64/aint implemented
  894. Revision 1.111 2004/02/22 16:48:09 florian
  895. * x86_64 uses generic concatcopy_valueopenarray for now
  896. Revision 1.110 2004/02/22 16:30:37 florian
  897. * fixed
  898. + second_cmpfloatsse
  899. Revision 1.109 2004/02/20 19:49:21 daniel
  900. * Message system uses open arrays internally
  901. * Bugfix for string handling in array constructor node
  902. * Micro code reductions in pdecl.pas
  903. Revision 1.108 2004/02/08 17:45:53 jonas
  904. * fixed regvars
  905. Revision 1.107 2004/02/05 01:24:08 florian
  906. * several fixes to compile x86-64 system
  907. Revision 1.106 2004/02/03 22:32:54 peter
  908. * renamed xNNbittype to xNNinttype
  909. * renamed registers32 to registersint
  910. * replace some s32bit,u32bit with torddef([su]inttype).def.typ
  911. Revision 1.105 2004/02/02 20:41:59 florian
  912. + added prefetch(const mem) support
  913. Revision 1.104 2003/12/25 01:07:09 florian
  914. + $fputype directive support
  915. + single data type operations with sse unit
  916. * fixed more x86-64 stuff
  917. Revision 1.103 2003/12/24 00:10:02 florian
  918. - delete parameter in cg64 methods removed
  919. Revision 1.102 2003/12/06 01:15:22 florian
  920. * reverted Peter's alloctemp patch; hopefully properly
  921. Revision 1.101 2003/12/03 23:13:20 peter
  922. * delayed paraloc allocation, a_param_*() gets extra parameter
  923. if it needs to allocate temp or real paralocation
  924. * optimized/simplified int-real loading
  925. Revision 1.100 2003/12/01 18:44:15 peter
  926. * fixed some crashes
  927. * fixed varargs and register calling probs
  928. Revision 1.99 2003/11/23 17:39:33 peter
  929. * removed obsolete nf_cargs flag
  930. Revision 1.98 2003/10/29 19:48:50 peter
  931. * renamed mangeldname_prefix to make_mangledname and made it more
  932. generic
  933. * make_mangledname is now also used for internal threadvar/resstring
  934. lists
  935. * Add P$ in front of program modulename to prevent duplicated symbols
  936. at assembler level, because the main program can have the same name
  937. as a unit, see webtbs/tw1251b
  938. Revision 1.97 2003/10/28 15:36:01 peter
  939. * absolute to object field supported, fixes tb0458
  940. Revision 1.96 2003/10/17 14:38:32 peter
  941. * 64k registers supported
  942. * fixed some memory leaks
  943. Revision 1.95 2003/10/14 00:30:48 florian
  944. + some code for PIC support added
  945. Revision 1.94 2003/10/11 16:06:42 florian
  946. * fixed some MMX<->SSE
  947. * started to fix ppc, needs an overhaul
  948. + stabs info improve for spilling, not sure if it works correctly/completly
  949. - MMX_SUPPORT removed from Makefile.fpc
  950. Revision 1.93 2003/10/10 17:48:13 peter
  951. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  952. * tregisteralloctor renamed to trgobj
  953. * removed rgobj from a lot of units
  954. * moved location_* and reference_* to cgobj
  955. * first things for mmx register allocation
  956. Revision 1.92 2003/10/09 21:31:37 daniel
  957. * Register allocator splitted, ans abstract now
  958. Revision 1.91 2003/10/07 15:17:07 peter
  959. * inline supported again, LOC_REFERENCEs are used to pass the
  960. parameters
  961. * inlineparasymtable,inlinelocalsymtable removed
  962. * exitlabel inserting fixed
  963. Revision 1.90 2003/10/05 21:21:52 peter
  964. * c style array of const generates callparanodes
  965. * varargs paraloc fixes
  966. Revision 1.89 2003/10/01 20:34:48 peter
  967. * procinfo unit contains tprocinfo
  968. * cginfo renamed to cgbase
  969. * moved cgmessage to verbose
  970. * fixed ppc and sparc compiles
  971. Revision 1.88 2003/09/29 20:58:56 peter
  972. * optimized releasing of registers
  973. Revision 1.87 2003/09/28 21:46:18 peter
  974. * fix allocation of threadvar parameter
  975. Revision 1.86 2003/09/28 17:55:03 peter
  976. * parent framepointer changed to hidden parameter
  977. * tloadparentfpnode added
  978. Revision 1.85 2003/09/28 13:39:38 peter
  979. * optimized releasing of registers
  980. Revision 1.84 2003/09/25 21:27:31 peter
  981. * rearranged threadvar code so the result register is the same
  982. for the relocated and address loaded variables
  983. Revision 1.83 2003/09/23 17:56:05 peter
  984. * locals and paras are allocated in the code generation
  985. * tvarsym.localloc contains the location of para/local when
  986. generating code for the current procedure
  987. Revision 1.82 2003/09/16 16:17:01 peter
  988. * varspez in calls to push_addr_param
  989. Revision 1.81 2003/09/14 12:57:10 peter
  990. * save destroyed registers when calling threadvar helper
  991. Revision 1.80 2003/09/10 08:31:47 marco
  992. * Patch from Peter for paraloc
  993. Revision 1.79 2003/09/03 15:55:00 peter
  994. * NEWRA branch merged
  995. Revision 1.78 2003/09/03 11:18:37 florian
  996. * fixed arm concatcopy
  997. + arm support in the common compiler sources added
  998. * moved some generic cg code around
  999. + tfputype added
  1000. * ...
  1001. Revision 1.77.2.2 2003/08/31 15:46:26 peter
  1002. * more updates for tregister
  1003. Revision 1.77.2.1 2003/08/29 17:28:59 peter
  1004. * next batch of updates
  1005. Revision 1.77 2003/08/20 20:13:08 daniel
  1006. * Fixed the fixed trouble
  1007. Revision 1.76 2003/08/20 20:11:24 daniel
  1008. * Fixed some R_NO trouble
  1009. Revision 1.75 2003/07/20 16:26:43 jonas
  1010. * fix for threadvars with -dnewra
  1011. Revision 1.74 2003/07/06 17:58:22 peter
  1012. * framepointer fixes for sparc
  1013. * parent framepointer code more generic
  1014. Revision 1.73 2003/07/06 15:25:54 jonas
  1015. * newra fix for threadvars
  1016. Revision 1.72 2003/06/15 15:13:12 jonas
  1017. * fixed register allocation for threadvar loads with newra
  1018. Revision 1.71 2003/06/13 21:19:30 peter
  1019. * current_procdef removed, use current_procinfo.procdef instead
  1020. Revision 1.70 2003/06/12 16:43:07 peter
  1021. * newra compiles for sparc
  1022. Revision 1.69 2003/06/09 16:41:52 jonas
  1023. * fixed regvar optimization for call_by_reference parameters (no need
  1024. to load address in another register)
  1025. Revision 1.68 2003/06/08 18:27:15 jonas
  1026. + ability to change the location of a ttempref node with changelocation()
  1027. method. Useful to use instead of copying the contents from one temp to
  1028. another
  1029. + some shortstring optimizations in tassignmentnode that avoid some
  1030. copying (required some shortstring optimizations to be moved from
  1031. resulttype to firstpass, because they work on callnodes and string
  1032. addnodes are only changed to callnodes in the firstpass)
  1033. * allow setting/changing the funcretnode of callnodes after the
  1034. resulttypepass has been done, funcretnode is now a property
  1035. (all of the above should have a quite big effect on callparatemp)
  1036. Revision 1.67 2003/06/07 18:57:04 jonas
  1037. + added freeintparaloc
  1038. * ppc get/freeintparaloc now check whether the parameter regs are
  1039. properly allocated/deallocated (and get an extra list para)
  1040. * ppc a_call_* now internalerrors if pi_do_call is not yet set
  1041. * fixed lot of missing pi_do_call's
  1042. Revision 1.66 2003/06/03 21:11:09 peter
  1043. * cg.a_load_* get a from and to size specifier
  1044. * makeregsize only accepts newregister
  1045. * i386 uses generic tcgnotnode,tcgunaryminus
  1046. Revision 1.65 2003/06/03 13:01:59 daniel
  1047. * Register allocator finished
  1048. Revision 1.64 2003/05/30 23:57:08 peter
  1049. * more sparc cleanup
  1050. * accumulator removed, splitted in function_return_reg (called) and
  1051. function_result_reg (caller)
  1052. Revision 1.63 2003/05/30 23:54:08 jonas
  1053. * forgot to commit, a_load_loc_reg change
  1054. Revision 1.62 2003/05/26 19:38:28 peter
  1055. * generic fpc_shorstr_concat
  1056. + fpc_shortstr_append_shortstr optimization
  1057. Revision 1.61 2003/05/24 11:47:27 jonas
  1058. * fixed framepointer storage: it's now always stored at r1+12, which is
  1059. a place in the link area reserved for compiler use.
  1060. Revision 1.60 2003/05/23 14:27:35 peter
  1061. * remove some unit dependencies
  1062. * current_procinfo changes to store more info
  1063. Revision 1.59 2003/05/15 18:58:53 peter
  1064. * removed selfpointer_offset, vmtpointer_offset
  1065. * tvarsym.adjusted_address
  1066. * address in localsymtable is now in the real direction
  1067. * removed some obsolete globals
  1068. Revision 1.58 2003/05/12 17:22:00 jonas
  1069. * fixed (last?) remaining -tvarsym(X).address to
  1070. tg.direction*tvarsym(X).address...
  1071. Revision 1.57 2003/05/11 21:37:03 peter
  1072. * moved implicit exception frame from ncgutil to psub
  1073. * constructor/destructor helpers moved from cobj/ncgutil to psub
  1074. Revision 1.56 2003/05/11 14:45:12 peter
  1075. * tloadnode does not support objectsymtable,withsymtable anymore
  1076. * withnode cleanup
  1077. * direct with rewritten to use temprefnode
  1078. Revision 1.55 2003/04/29 07:29:14 michael
  1079. + Patch from peter to fix wrong pushing of ansistring function results in open array
  1080. Revision 1.54 2003/04/27 11:21:33 peter
  1081. * aktprocdef renamed to current_procinfo.procdef
  1082. * procinfo renamed to current_procinfo
  1083. * procinfo will now be stored in current_module so it can be
  1084. cleaned up properly
  1085. * gen_main_procsym changed to create_main_proc and release_main_proc
  1086. to also generate a tprocinfo structure
  1087. * fixed unit implicit initfinal
  1088. Revision 1.53 2003/04/27 07:29:50 peter
  1089. * current_procinfo.procdef cleanup, current_procdef is now always nil when parsing
  1090. a new procdef declaration
  1091. * aktprocsym removed
  1092. * lexlevel removed, use symtable.symtablelevel instead
  1093. * implicit init/final code uses the normal genentry/genexit
  1094. * funcret state checking updated for new funcret handling
  1095. Revision 1.52 2003/04/25 20:59:33 peter
  1096. * removed funcretn,funcretsym, function result is now in varsym
  1097. and aliases for result and function name are added using absolutesym
  1098. * vs_hidden parameter for funcret passed in parameter
  1099. * vs_hidden fixes
  1100. * writenode changed to printnode and released from extdebug
  1101. * -vp option added to generate a tree.log with the nodetree
  1102. * nicer printnode for statements, callnode
  1103. Revision 1.51 2003/04/23 20:16:04 peter
  1104. + added currency support based on int64
  1105. + is_64bit for use in cg units instead of is_64bitint
  1106. * removed cgmessage from n386add, replace with internalerrors
  1107. Revision 1.50 2003/04/23 10:12:14 peter
  1108. * allow multi pass2 changed to global boolean instead of node flag
  1109. Revision 1.49 2003/04/22 23:50:22 peter
  1110. * firstpass uses expectloc
  1111. * checks if there are differences between the expectloc and
  1112. location.loc from secondpass in EXTDEBUG
  1113. Revision 1.48 2003/04/22 10:09:35 daniel
  1114. + Implemented the actual register allocator
  1115. + Scratch registers unavailable when new register allocator used
  1116. + maybe_save/maybe_restore unavailable when new register allocator used
  1117. Revision 1.47 2003/04/06 21:11:23 olle
  1118. * changed newasmsymbol to newasmsymboldata for data symbols
  1119. Revision 1.46 2003/03/28 19:16:56 peter
  1120. * generic constructor working for i386
  1121. * remove fixed self register
  1122. * esi added as address register for i386
  1123. Revision 1.45 2003/02/19 22:00:14 daniel
  1124. * Code generator converted to new register notation
  1125. - Horribily outdated todo.txt removed
  1126. Revision 1.44 2003/01/08 18:43:56 daniel
  1127. * Tregister changed into a record
  1128. Revision 1.43 2003/01/05 22:44:14 peter
  1129. * remove a lot of code to support typen in loadn-procsym
  1130. Revision 1.42 2002/12/20 18:13:46 peter
  1131. * fixes for fpu values in arrayconstructor
  1132. Revision 1.41 2002/11/27 20:04:39 peter
  1133. * cdecl array of const fixes
  1134. Revision 1.40 2002/11/25 17:43:18 peter
  1135. * splitted defbase in defutil,symutil,defcmp
  1136. * merged isconvertable and is_equal into compare_defs(_ext)
  1137. * made operator search faster by walking the list only once
  1138. Revision 1.39 2002/11/22 16:22:45 jonas
  1139. * fixed error in my previous commit (the size of the location of the
  1140. funcretnode must be based on the current resulttype of the node and not
  1141. the resulttype defined by the function; these can be different in case
  1142. of "absolute" declarations)
  1143. Revision 1.38 2002/11/18 17:31:54 peter
  1144. * pass proccalloption to ret_in_xxx and push_xxx functions
  1145. Revision 1.37 2002/11/15 21:16:39 jonas
  1146. * proper fix for tw2110, also fixes tb0416 (funcretnode of parent
  1147. function was handled wrong inside nested functions/procedures)
  1148. Revision 1.36 2002/11/15 01:58:51 peter
  1149. * merged changes from 1.0.7 up to 04-11
  1150. - -V option for generating bug report tracing
  1151. - more tracing for option parsing
  1152. - errors for cdecl and high()
  1153. - win32 import stabs
  1154. - win32 records<=8 are returned in eax:edx (turned off by default)
  1155. - heaptrc update
  1156. - more info for temp management in .s file with EXTDEBUG
  1157. Revision 1.35 2002/10/14 19:44:13 peter
  1158. * (hacked) new threadvar relocate code
  1159. Revision 1.34 2002/10/13 11:22:06 florian
  1160. * fixed threadvars
  1161. Revision 1.33 2002/10/03 21:32:02 carl
  1162. * bugfix for 2110 (without -Or), wrong checking was done in returntype
  1163. Revision 1.32 2002/09/30 07:00:46 florian
  1164. * fixes to common code to get the alpha compiler compiled applied
  1165. Revision 1.31 2002/09/26 15:02:05 florian
  1166. + support of passing variants to "array of const"
  1167. Revision 1.30 2002/09/17 18:54:02 jonas
  1168. * a_load_reg_reg() now has two size parameters: source and dest. This
  1169. allows some optimizations on architectures that don't encode the
  1170. register size in the register name.
  1171. Revision 1.29 2002/09/07 15:25:03 peter
  1172. * old logs removed and tabs fixed
  1173. Revision 1.28 2002/09/01 19:26:32 peter
  1174. * fixed register variable loading from parasymtable, the call by
  1175. reference code was moved wrong
  1176. Revision 1.27 2002/09/01 12:15:40 peter
  1177. * fixed loading of procvar of object when the object is initialized
  1178. with 0
  1179. Revision 1.26 2002/08/25 19:25:18 peter
  1180. * sym.insert_in_data removed
  1181. * symtable.insertvardata/insertconstdata added
  1182. * removed insert_in_data call from symtable.insert, it needs to be
  1183. called separatly. This allows to deref the address calculation
  1184. * procedures now calculate the parast addresses after the procedure
  1185. directives are parsed. This fixes the cdecl parast problem
  1186. * push_addr_param has an extra argument that specifies if cdecl is used
  1187. or not
  1188. Revision 1.25 2002/08/23 16:14:48 peter
  1189. * tempgen cleanup
  1190. * tt_noreuse temp type added that will be used in genentrycode
  1191. Revision 1.24 2002/08/17 09:23:35 florian
  1192. * first part of procinfo rewrite
  1193. Revision 1.23 2002/08/14 18:13:28 jonas
  1194. * adapted previous fix to Peter's asmsymbol patch
  1195. Revision 1.22 2002/08/14 18:00:42 jonas
  1196. * fixed tb0403
  1197. Revision 1.21 2002/08/13 21:40:56 florian
  1198. * more fixes for ppc calling conventions
  1199. Revision 1.20 2002/08/11 14:32:26 peter
  1200. * renamed current_library to objectlibrary
  1201. Revision 1.19 2002/08/11 13:24:12 peter
  1202. * saving of asmsymbols in ppu supported
  1203. * asmsymbollist global is removed and moved into a new class
  1204. tasmlibrarydata that will hold the info of a .a file which
  1205. corresponds with a single module. Added librarydata to tmodule
  1206. to keep the library info stored for the module. In the future the
  1207. objectfiles will also be stored to the tasmlibrarydata class
  1208. * all getlabel/newasmsymbol and friends are moved to the new class
  1209. Revision 1.18 2002/08/06 20:55:21 florian
  1210. * first part of ppc calling conventions fix
  1211. Revision 1.17 2002/07/28 09:25:37 carl
  1212. + correct size of parameter (64-bit portability)
  1213. Revision 1.16 2002/07/27 19:53:51 jonas
  1214. + generic implementation of tcg.g_flags2ref()
  1215. * tcg.flags2xxx() now also needs a size parameter
  1216. Revision 1.15 2002/07/20 11:57:54 florian
  1217. * types.pas renamed to defbase.pas because D6 contains a types
  1218. unit so this would conflicts if D6 programms are compiled
  1219. + Willamette/SSE2 instructions to assembler added
  1220. Revision 1.14 2002/07/16 09:17:44 florian
  1221. * threadvar relocation result wasn't handled properly, it could cause
  1222. a crash
  1223. Revision 1.13 2002/07/11 14:41:28 florian
  1224. * start of the new generic parameter handling
  1225. Revision 1.12 2002/07/07 09:52:32 florian
  1226. * powerpc target fixed, very simple units can be compiled
  1227. * some basic stuff for better callparanode handling, far from being finished
  1228. Revision 1.11 2002/07/01 18:46:23 peter
  1229. * internal linker
  1230. * reorganized aasm layer
  1231. Revision 1.10 2002/07/01 16:23:53 peter
  1232. * cg64 patch
  1233. * basics for currency
  1234. * asnode updates for class and interface (not finished)
  1235. Revision 1.9 2002/05/20 13:30:40 carl
  1236. * bugfix of hdisponen (base must be set, not index)
  1237. * more portability fixes
  1238. }