ncgcon.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate assembler for constant nodes which are the same for
  4. 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 ncgcon;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. node,ncon;
  23. type
  24. tcgdataconstnode = class(tdataconstnode)
  25. procedure pass_generate_code;override;
  26. end;
  27. tcgrealconstnode = class(trealconstnode)
  28. procedure pass_generate_code;override;
  29. end;
  30. tcgordconstnode = class(tordconstnode)
  31. procedure pass_generate_code;override;
  32. end;
  33. tcgpointerconstnode = class(tpointerconstnode)
  34. procedure pass_generate_code;override;
  35. end;
  36. tcgstringconstnode = class(tstringconstnode)
  37. procedure pass_generate_code;override;
  38. end;
  39. tcgsetconstnode = class(tsetconstnode)
  40. procedure pass_generate_code;override;
  41. end;
  42. tcgnilnode = class(tnilnode)
  43. procedure pass_generate_code;override;
  44. end;
  45. tcgguidconstnode = class(tguidconstnode)
  46. procedure pass_generate_code;override;
  47. end;
  48. implementation
  49. uses
  50. globtype,widestr,systems,
  51. verbose,globals,cutils,
  52. symconst,symdef,aasmbase,aasmtai,aasmdata,aasmcpu,defutil,
  53. cpuinfo,cpubase,
  54. cgbase,cgobj,cgutils,
  55. ncgutil, cclasses
  56. ;
  57. {*****************************************************************************
  58. TCGREALCONSTNODE
  59. *****************************************************************************}
  60. procedure tcgdataconstnode.pass_generate_code;
  61. var
  62. l : tasmlabel;
  63. i : longint;
  64. b : byte;
  65. begin
  66. location_reset_ref(location,LOC_CREFERENCE,OS_NO,const_align(maxalign));
  67. current_asmdata.getdatalabel(l);
  68. maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
  69. new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata,l.name,const_align(maxalign));
  70. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l));
  71. data.seek(0);
  72. for i:=0 to data.size-1 do
  73. begin
  74. data.read(b,1);
  75. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_8bit(b));
  76. end;
  77. location.reference.symbol:=l;
  78. end;
  79. {*****************************************************************************
  80. TCGREALCONSTNODE
  81. *****************************************************************************}
  82. procedure tcgrealconstnode.pass_generate_code;
  83. { I suppose the parser/pass_1 must make sure the generated real }
  84. { constants are actually supported by the target processor? (JM) }
  85. const
  86. floattype2ait:array[tfloattype] of taitype=
  87. (ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_comp_64bit,ait_real_128bit);
  88. var
  89. hp1 : tai;
  90. lastlabel : tasmlabel;
  91. realait : taitype;
  92. {$ifdef ARM}
  93. hiloswapped : boolean;
  94. {$endif ARM}
  95. begin
  96. location_reset_ref(location,LOC_CREFERENCE,def_cgsize(resultdef),const_align(resultdef.alignment));
  97. lastlabel:=nil;
  98. realait:=floattype2ait[tfloatdef(resultdef).floattype];
  99. {$ifdef ARM}
  100. hiloswapped:=is_double_hilo_swapped;
  101. {$endif ARM}
  102. { const already used ? }
  103. if not assigned(lab_real) then
  104. begin
  105. { tries to find an old entry }
  106. hp1:=tai(current_asmdata.asmlists[al_typedconsts].first);
  107. while assigned(hp1) do
  108. begin
  109. if hp1.typ=ait_label then
  110. lastlabel:=tai_label(hp1).labsym
  111. else
  112. begin
  113. if (hp1.typ=realait) and (lastlabel<>nil) then
  114. begin
  115. if is_number_float(value_real) and
  116. (
  117. ((realait=ait_real_32bit) and (tai_real_32bit(hp1).value=value_real) and is_number_float(tai_real_32bit(hp1).value) and (get_real_sign(value_real) = get_real_sign(tai_real_32bit(hp1).value))) or
  118. ((realait=ait_real_64bit) and
  119. {$ifdef ARM}
  120. ((tai_real_64bit(hp1).formatoptions=fo_hiloswapped)=hiloswapped) and
  121. {$endif ARM}
  122. (tai_real_64bit(hp1).value=value_real) and is_number_float(tai_real_64bit(hp1).value) and (get_real_sign(value_real) = get_real_sign(tai_real_64bit(hp1).value))) or
  123. ((realait=ait_real_80bit) and (tai_real_80bit(hp1).value=value_real) and is_number_float(tai_real_80bit(hp1).value) and (get_real_sign(value_real) = get_real_sign(tai_real_80bit(hp1).value))) or
  124. {$ifdef cpufloat128}
  125. ((realait=ait_real_128bit) and (tai_real_128bit(hp1).value=value_real) and is_number_float(tai_real_128bit(hp1).value) and (get_real_sign(value_real) = get_real_sign(tai_real_128bit(hp1).value))) or
  126. {$endif cpufloat128}
  127. ((realait=ait_comp_64bit) and (tai_comp_64bit(hp1).value=value_real) and is_number_float(tai_comp_64bit(hp1).value) and (get_real_sign(value_real) = get_real_sign(tai_comp_64bit(hp1).value)))
  128. ) then
  129. begin
  130. { found! }
  131. lab_real:=lastlabel;
  132. break;
  133. end;
  134. end;
  135. lastlabel:=nil;
  136. end;
  137. hp1:=tai(hp1.next);
  138. end;
  139. { :-(, we must generate a new entry }
  140. if not assigned(lab_real) then
  141. begin
  142. current_asmdata.getdatalabel(lastlabel);
  143. lab_real:=lastlabel;
  144. maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
  145. new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,lastlabel.name,const_align(resultdef.alignment));
  146. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
  147. case realait of
  148. ait_real_32bit :
  149. begin
  150. current_asmdata.asmlists[al_typedconsts].concat(Tai_real_32bit.Create(ts32real(value_real)));
  151. { range checking? }
  152. if floating_point_range_check_error and
  153. (tai_real_32bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
  154. Message(parser_e_range_check_error);
  155. end;
  156. ait_real_64bit :
  157. begin
  158. {$ifdef ARM}
  159. if hiloswapped then
  160. current_asmdata.asmlists[al_typedconsts].concat(Tai_real_64bit.Create_hiloswapped(ts64real(value_real)))
  161. else
  162. {$endif ARM}
  163. current_asmdata.asmlists[al_typedconsts].concat(Tai_real_64bit.Create(ts64real(value_real)));
  164. { range checking? }
  165. if floating_point_range_check_error and
  166. (tai_real_64bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
  167. Message(parser_e_range_check_error);
  168. end;
  169. ait_real_80bit :
  170. begin
  171. current_asmdata.asmlists[al_typedconsts].concat(Tai_real_80bit.Create(value_real));
  172. { range checking? }
  173. if floating_point_range_check_error and
  174. (tai_real_80bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
  175. Message(parser_e_range_check_error);
  176. end;
  177. {$ifdef cpufloat128}
  178. ait_real_128bit :
  179. begin
  180. current_asmdata.asmlists[al_typedconsts].concat(Tai_real_128bit.Create(value_real));
  181. { range checking? }
  182. if floating_point_range_check_error and
  183. (tai_real_128bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
  184. Message(parser_e_range_check_error);
  185. end;
  186. {$endif cpufloat128}
  187. { the round is necessary for native compilers where comp isn't a float }
  188. ait_comp_64bit :
  189. if (value_real>9223372036854775807.0) or (value_real<-9223372036854775808.0) then
  190. message(parser_e_range_check_error)
  191. else
  192. current_asmdata.asmlists[al_typedconsts].concat(Tai_comp_64bit.Create(round(value_real)));
  193. else
  194. internalerror(10120);
  195. end;
  196. end;
  197. end;
  198. location.reference.symbol:=lab_real;
  199. end;
  200. {*****************************************************************************
  201. TCGORDCONSTNODE
  202. *****************************************************************************}
  203. procedure tcgordconstnode.pass_generate_code;
  204. begin
  205. location_reset(location,LOC_CONSTANT,def_cgsize(resultdef));
  206. {$ifdef cpu64bitalu}
  207. location.value:=value.svalue;
  208. {$else cpu64bitalu}
  209. location.value64:=value.svalue;
  210. {$endif cpu64bitalu}
  211. end;
  212. {*****************************************************************************
  213. TCGPOINTERCONSTNODE
  214. *****************************************************************************}
  215. procedure tcgpointerconstnode.pass_generate_code;
  216. begin
  217. { an integer const. behaves as a memory reference }
  218. location_reset(location,LOC_CONSTANT,OS_ADDR);
  219. location.value:=aint(value);
  220. end;
  221. {*****************************************************************************
  222. TCGSTRINGCONSTNODE
  223. *****************************************************************************}
  224. procedure tcgstringconstnode.pass_generate_code;
  225. var
  226. l1,
  227. lastlabel : tasmlabel;
  228. pc : pchar;
  229. l,i : longint;
  230. href: treference;
  231. pooltype: TConstPoolType;
  232. pool: THashSet;
  233. entry: PHashSetItem;
  234. const
  235. PoolMap: array[tconststringtype] of TConstPoolType = (
  236. sp_conststr,
  237. sp_shortstr,
  238. sp_longstr,
  239. sp_ansistr,
  240. sp_widestr,
  241. sp_unicodestr
  242. );
  243. begin
  244. { for empty ansistrings we could return a constant 0 }
  245. if (cst_type in [cst_ansistring,cst_widestring,cst_unicodestring]) and (len=0) then
  246. begin
  247. location_reset(location,LOC_CONSTANT,OS_ADDR);
  248. location.value:=0;
  249. exit;
  250. end;
  251. { const already used ? }
  252. if not assigned(lab_str) then
  253. begin
  254. pooltype := PoolMap[cst_type];
  255. if current_asmdata.ConstPools[pooltype] = nil then
  256. current_asmdata.ConstPools[pooltype] := THashSet.Create(64, True, False);
  257. pool := current_asmdata.ConstPools[pooltype];
  258. if cst_type in [cst_widestring, cst_unicodestring] then
  259. entry := pool.FindOrAdd(pcompilerwidestring(value_str)^.data, len*cwidechartype.size)
  260. else
  261. entry := pool.FindOrAdd(value_str, len);
  262. lab_str := TAsmLabel(entry^.Data); // is it needed anymore?
  263. { :-(, we must generate a new entry }
  264. if not assigned(entry^.Data) then
  265. begin
  266. current_asmdata.getdatalabel(lastlabel);
  267. lab_str:=lastlabel;
  268. entry^.Data := lastlabel;
  269. maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
  270. if (len=0) or
  271. not(cst_type in [cst_ansistring,cst_widestring,cst_unicodestring]) then
  272. new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,lastlabel.name,const_align(sizeof(pint)))
  273. else
  274. new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata,lastlabel.name,const_align(sizeof(pint)));
  275. { generate an ansi string ? }
  276. case cst_type of
  277. cst_ansistring:
  278. begin
  279. if len=0 then
  280. InternalError(2008032301) { empty string should be handled above }
  281. else
  282. begin
  283. current_asmdata.getdatalabel(l1);
  284. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l1));
  285. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_pint(-1));
  286. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_pint(len));
  287. { make sure the string doesn't get dead stripped if the header is referenced }
  288. if (target_info.system in systems_darwin) then
  289. current_asmdata.asmlists[al_typedconsts].concat(tai_directive.create(asd_reference,lastlabel.name));
  290. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
  291. { ... and vice versa }
  292. if (target_info.system in systems_darwin) then
  293. current_asmdata.asmlists[al_typedconsts].concat(tai_directive.create(asd_reference,l1.name));
  294. { include also terminating zero }
  295. getmem(pc,len+1);
  296. move(value_str^,pc^,len);
  297. pc[len]:=#0;
  298. current_asmdata.asmlists[al_typedconsts].concat(Tai_string.Create_pchar(pc,len+1));
  299. end;
  300. end;
  301. cst_unicodestring,
  302. cst_widestring:
  303. begin
  304. if len=0 then
  305. InternalError(2008032302) { empty string should be handled above }
  306. else
  307. begin
  308. current_asmdata.getdatalabel(l1);
  309. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l1));
  310. { we use always UTF-16 coding for constants }
  311. { at least for now }
  312. { Consts.concat(Tai_const.Create_8bit(2)); }
  313. if (cst_type=cst_widestring) and (tf_winlikewidestring in target_info.flags) then
  314. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit(len*cwidechartype.size))
  315. else
  316. begin
  317. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_pint(-1));
  318. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_pint(len*cwidechartype.size));
  319. end;
  320. { make sure the string doesn't get dead stripped if the header is referenced }
  321. if (target_info.system in systems_darwin) then
  322. current_asmdata.asmlists[al_typedconsts].concat(tai_directive.create(asd_reference,lastlabel.name));
  323. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
  324. { ... and vice versa }
  325. if (target_info.system in systems_darwin) then
  326. current_asmdata.asmlists[al_typedconsts].concat(tai_directive.create(asd_reference,l1.name));
  327. for i:=0 to len-1 do
  328. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(pcompilerwidestring(value_str)^.data[i]));
  329. { terminating zero }
  330. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(0));
  331. end;
  332. end;
  333. cst_shortstring:
  334. begin
  335. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
  336. { truncate strings larger than 255 chars }
  337. if len>255 then
  338. l:=255
  339. else
  340. l:=len;
  341. { include length and terminating zero for quick conversion to pchar }
  342. getmem(pc,l+2);
  343. move(value_str^,pc[1],l);
  344. pc[0]:=chr(l);
  345. pc[l+1]:=#0;
  346. current_asmdata.asmlists[al_typedconsts].concat(Tai_string.Create_pchar(pc,l+2));
  347. end;
  348. cst_conststring:
  349. begin
  350. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
  351. { include terminating zero }
  352. getmem(pc,len+1);
  353. move(value_str^,pc[0],len);
  354. pc[len]:=#0;
  355. current_asmdata.asmlists[al_typedconsts].concat(Tai_string.Create_pchar(pc,len+1));
  356. end;
  357. end;
  358. end;
  359. end;
  360. if cst_type in [cst_ansistring, cst_widestring, cst_unicodestring] then
  361. begin
  362. location_reset(location, LOC_REGISTER, OS_ADDR);
  363. reference_reset_symbol(href, lab_str, 0, const_align(sizeof(pint)));
  364. location.register:=cg.getaddressregister(current_asmdata.CurrAsmList);
  365. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,href,location.register);
  366. end
  367. else
  368. begin
  369. location_reset_ref(location, LOC_CREFERENCE, def_cgsize(resultdef), const_align(sizeof(pint)));
  370. location.reference.symbol:=lab_str;
  371. end;
  372. end;
  373. {*****************************************************************************
  374. TCGSETCONSTNODE
  375. *****************************************************************************}
  376. procedure tcgsetconstnode.pass_generate_code;
  377. type
  378. setbytes=array[0..31] of byte;
  379. Psetbytes=^setbytes;
  380. procedure smallsetconst;
  381. begin
  382. location_reset(location,LOC_CONSTANT,int_cgsize(resultdef.size));
  383. if (source_info.endian=target_info.endian) then
  384. begin
  385. {$if defined(FPC_NEW_BIGENDIAN_SETS) or defined(FPC_LITTLE_ENDIAN)}
  386. { not plongint, because that will "sign extend" the set on 64 bit platforms }
  387. { if changed to "paword", please also modify "32-resultdef.size*8" and }
  388. { cross-endian code below }
  389. { Extra aint type cast to avoid range errors }
  390. location.value:=aint(pCardinal(value_set)^)
  391. {$else}
  392. location.value:=reverse_byte(Psetbytes(value_set)^[0]);
  393. location.value:=location.value or (reverse_byte(Psetbytes(value_set)^[1]) shl 8);
  394. location.value:=location.value or (reverse_byte(Psetbytes(value_set)^[2]) shl 16);
  395. location.value:=location.value or (reverse_byte(Psetbytes(value_set)^[3]) shl 24);
  396. {$endif}
  397. end
  398. else
  399. begin
  400. location.value:=swapendian(Pcardinal(value_set)^);
  401. location.value:= reverse_byte (location.value and $ff) or
  402. (reverse_byte((location.value shr 8) and $ff) shl 8) or
  403. (reverse_byte((location.value shr 16) and $ff) shl 16) or
  404. (reverse_byte((location.value shr 24) and $ff) shl 24);
  405. end;
  406. if (target_info.endian=endian_big) then
  407. location.value:=location.value shr (32-resultdef.size*8);
  408. end;
  409. procedure varsetconst;
  410. var
  411. hp1 : tai;
  412. lastlabel : tasmlabel;
  413. i : longint;
  414. neededtyp : taiconst_type;
  415. begin
  416. location_reset_ref(location,LOC_CREFERENCE,OS_NO,const_align(8));
  417. neededtyp:=aitconst_8bit;
  418. lastlabel:=nil;
  419. { const already used ? }
  420. if not assigned(lab_set) then
  421. begin
  422. { tries to found an old entry }
  423. hp1:=tai(current_asmdata.asmlists[al_typedconsts].first);
  424. while assigned(hp1) do
  425. begin
  426. if hp1.typ=ait_label then
  427. lastlabel:=tai_label(hp1).labsym
  428. else
  429. begin
  430. if (lastlabel<>nil) and
  431. (hp1.typ=ait_const) and
  432. (tai_const(hp1).consttype=neededtyp) then
  433. begin
  434. if (tai_const(hp1).consttype=aitconst_8bit) then
  435. begin
  436. { compare normal set }
  437. i:=0;
  438. while assigned(hp1) and (i<32) do
  439. begin
  440. if (source_info.endian=target_info.endian) then
  441. begin
  442. {$if defined(FPC_NEW_BIGENDIAN_SETS) or defined(FPC_LITTLE_ENDIAN)}
  443. if tai_const(hp1).value<>Psetbytes(value_set)^[i ] then
  444. {$else}
  445. if tai_const(hp1).value<>reverse_byte(Psetbytes(value_set)^[i xor 3]) then
  446. {$endif}
  447. break
  448. end
  449. else if tai_const(hp1).value<>reverse_byte(Psetbytes(value_set)^[i]) then
  450. break;
  451. inc(i);
  452. hp1:=tai(hp1.next);
  453. end;
  454. if i=32 then
  455. begin
  456. { found! }
  457. lab_set:=lastlabel;
  458. break;
  459. end;
  460. { leave when the end of consts is reached, so no
  461. hp1.next is done }
  462. if not assigned(hp1) then
  463. break;
  464. end
  465. else
  466. begin
  467. { compare small set }
  468. if paint(value_set)^=tai_const(hp1).value then
  469. begin
  470. { found! }
  471. lab_set:=lastlabel;
  472. break;
  473. end;
  474. end;
  475. end;
  476. lastlabel:=nil;
  477. end;
  478. hp1:=tai(hp1.next);
  479. end;
  480. { :-(, we must generate a new entry }
  481. if not assigned(lab_set) then
  482. begin
  483. current_asmdata.getdatalabel(lastlabel);
  484. lab_set:=lastlabel;
  485. maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
  486. new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata_norel,lastlabel.name,const_align(8));
  487. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
  488. if (source_info.endian=target_info.endian) then
  489. {$if defined(FPC_NEW_BIGENDIAN_SETS) or defined(FPC_LITTLE_ENDIAN)}
  490. for i:=0 to 31 do
  491. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_8bit(Psetbytes(value_set)^[i]))
  492. {$else}
  493. for i:=0 to 31 do
  494. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_8bit(reverse_byte(Psetbytes(value_set)^[i xor 3])))
  495. {$endif}
  496. else
  497. for i:=0 to 31 do
  498. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_8bit(reverse_byte(Psetbytes(value_set)^[i])));
  499. end;
  500. end;
  501. location.reference.symbol:=lab_set;
  502. end;
  503. begin
  504. adjustforsetbase;
  505. { small sets are loaded as constants }
  506. if is_smallset(resultdef) then
  507. smallsetconst
  508. else
  509. varsetconst;
  510. end;
  511. {*****************************************************************************
  512. TCGNILNODE
  513. *****************************************************************************}
  514. procedure tcgnilnode.pass_generate_code;
  515. begin
  516. location_reset(location,LOC_CONSTANT,OS_ADDR);
  517. location.value:=0;
  518. end;
  519. {*****************************************************************************
  520. TCGPOINTERCONSTNODE
  521. *****************************************************************************}
  522. procedure tcgguidconstnode.pass_generate_code;
  523. var
  524. tmplabel : TAsmLabel;
  525. i : integer;
  526. begin
  527. location_reset_ref(location,LOC_CREFERENCE,OS_NO,const_align(16));
  528. { label for GUID }
  529. current_asmdata.getdatalabel(tmplabel);
  530. current_asmdata.asmlists[al_typedconsts].concat(tai_align.create(const_align(16)));
  531. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(tmplabel));
  532. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit(longint(value.D1)));
  533. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(value.D2));
  534. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(value.D3));
  535. for i:=low(value.D4) to high(value.D4) do
  536. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_8bit(value.D4[i]));
  537. location.reference.symbol:=tmplabel;
  538. end;
  539. begin
  540. cdataconstnode:=tcgdataconstnode;
  541. crealconstnode:=tcgrealconstnode;
  542. cordconstnode:=tcgordconstnode;
  543. cpointerconstnode:=tcgpointerconstnode;
  544. cstringconstnode:=tcgstringconstnode;
  545. csetconstnode:=tcgsetconstnode;
  546. cnilnode:=tcgnilnode;
  547. cguidconstnode:=tcgguidconstnode;
  548. end.