ncgcon.pas 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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,
  52. symconst,symdef,aasmbase,aasmtai,aasmdata,aasmcpu,defutil,
  53. cpuinfo,cpubase,
  54. cgbase,cgobj,cgutils,
  55. ncgutil
  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(location,LOC_CREFERENCE,OS_NO);
  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(location,LOC_CREFERENCE,def_cgsize(resultdef));
  97. lastlabel:=nil;
  98. realait:=floattype2ait[tfloatdef(resultdef).floattype];
  99. {$ifdef ARM}
  100. hiloswapped:=(current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
  101. not(cs_fp_emulation in current_settings.moduleswitches);
  102. {$endif ARM}
  103. { const already used ? }
  104. if not assigned(lab_real) then
  105. begin
  106. { tries to find an old entry }
  107. hp1:=tai(current_asmdata.asmlists[al_typedconsts].first);
  108. while assigned(hp1) do
  109. begin
  110. if hp1.typ=ait_label then
  111. lastlabel:=tai_label(hp1).labsym
  112. else
  113. begin
  114. if (hp1.typ=realait) and (lastlabel<>nil) then
  115. begin
  116. if is_number_float(value_real) and
  117. (
  118. ((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
  119. ((realait=ait_real_64bit) and
  120. {$ifdef ARM}
  121. ((tai_real_64bit(hp1).formatoptions=fo_hiloswapped)=hiloswapped) and
  122. {$endif ARM}
  123. (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
  124. ((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
  125. {$ifdef cpufloat128}
  126. ((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
  127. {$endif cpufloat128}
  128. ((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)))
  129. ) then
  130. begin
  131. { found! }
  132. lab_real:=lastlabel;
  133. break;
  134. end;
  135. end;
  136. lastlabel:=nil;
  137. end;
  138. hp1:=tai(hp1.next);
  139. end;
  140. { :-(, we must generate a new entry }
  141. if not assigned(lab_real) then
  142. begin
  143. current_asmdata.getdatalabel(lastlabel);
  144. lab_real:=lastlabel;
  145. maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
  146. new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata,lastlabel.name,const_align(resultdef.size));
  147. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
  148. case realait of
  149. ait_real_32bit :
  150. begin
  151. current_asmdata.asmlists[al_typedconsts].concat(Tai_real_32bit.Create(ts32real(value_real)));
  152. { range checking? }
  153. if ((cs_check_range in current_settings.localswitches) or
  154. (cs_check_overflow in current_settings.localswitches)) and
  155. (tai_real_32bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
  156. Message(parser_e_range_check_error);
  157. end;
  158. ait_real_64bit :
  159. begin
  160. {$ifdef ARM}
  161. if hiloswapped then
  162. current_asmdata.asmlists[al_typedconsts].concat(Tai_real_64bit.Create_hiloswapped(ts64real(value_real)))
  163. else
  164. {$endif ARM}
  165. current_asmdata.asmlists[al_typedconsts].concat(Tai_real_64bit.Create(ts64real(value_real)));
  166. { range checking? }
  167. if ((cs_check_range in current_settings.localswitches) or
  168. (cs_check_overflow in current_settings.localswitches)) and
  169. (tai_real_64bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
  170. Message(parser_e_range_check_error);
  171. end;
  172. ait_real_80bit :
  173. begin
  174. current_asmdata.asmlists[al_typedconsts].concat(Tai_real_80bit.Create(value_real));
  175. { range checking? }
  176. if ((cs_check_range in current_settings.localswitches) or
  177. (cs_check_overflow in current_settings.localswitches)) and
  178. (tai_real_80bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
  179. Message(parser_e_range_check_error);
  180. end;
  181. {$ifdef cpufloat128}
  182. ait_real_128bit :
  183. begin
  184. current_asmdata.asmlists[al_typedconsts].concat(Tai_real_128bit.Create(value_real));
  185. { range checking? }
  186. if ((cs_check_range in current_settings.localswitches) or
  187. (cs_check_overflow in current_settings.localswitches)) and
  188. (tai_real_128bit(current_asmdata.asmlists[al_typedconsts].last).value=MathInf.Value) then
  189. Message(parser_e_range_check_error);
  190. end;
  191. {$endif cpufloat128}
  192. { the round is necessary for native compilers where comp isn't a float }
  193. ait_comp_64bit :
  194. if (value_real>9223372036854775807.0) or (value_real<-9223372036854775808.0) then
  195. message(parser_e_range_check_error)
  196. else
  197. current_asmdata.asmlists[al_typedconsts].concat(Tai_comp_64bit.Create(round(value_real)));
  198. else
  199. internalerror(10120);
  200. end;
  201. end;
  202. end;
  203. location.reference.symbol:=lab_real;
  204. end;
  205. {*****************************************************************************
  206. TCGORDCONSTNODE
  207. *****************************************************************************}
  208. procedure tcgordconstnode.pass_generate_code;
  209. begin
  210. location_reset(location,LOC_CONSTANT,def_cgsize(resultdef));
  211. {$ifdef cpu64bit}
  212. location.value:=value;
  213. {$else cpu64bit}
  214. location.value64:=int64(value);
  215. {$endif cpu64bit}
  216. end;
  217. {*****************************************************************************
  218. TCGPOINTERCONSTNODE
  219. *****************************************************************************}
  220. procedure tcgpointerconstnode.pass_generate_code;
  221. begin
  222. { an integer const. behaves as a memory reference }
  223. location_reset(location,LOC_CONSTANT,OS_ADDR);
  224. location.value:=aint(value);
  225. end;
  226. {*****************************************************************************
  227. TCGSTRINGCONSTNODE
  228. *****************************************************************************}
  229. procedure tcgstringconstnode.pass_generate_code;
  230. var
  231. hp1,hp2 : tai;
  232. l1,l2,
  233. lastlabel : tasmlabel;
  234. lastlabelhp : tai;
  235. pc : pchar;
  236. same_string : boolean;
  237. l,j,
  238. i,mylength : longint;
  239. begin
  240. { for empty ansistrings we could return a constant 0 }
  241. if (cst_type in [cst_ansistring,cst_widestring]) and (len=0) then
  242. begin
  243. location_reset(location,LOC_CONSTANT,OS_ADDR);
  244. location.value:=0;
  245. exit;
  246. end;
  247. { return a constant reference in memory }
  248. location_reset(location,LOC_CREFERENCE,def_cgsize(resultdef));
  249. { const already used ? }
  250. lastlabel:=nil;
  251. lastlabelhp:=nil;
  252. if not assigned(lab_str) then
  253. begin
  254. if is_shortstring(resultdef) then
  255. mylength:=len+2
  256. else
  257. mylength:=len+1;
  258. { widestrings can't be reused yet }
  259. if not(is_widestring(resultdef)) then
  260. begin
  261. { tries to find an old entry }
  262. hp1:=tai(current_asmdata.asmlists[al_typedconsts].first);
  263. while assigned(hp1) do
  264. begin
  265. if hp1.typ=ait_label then
  266. begin
  267. lastlabel:=tai_label(hp1).labsym;
  268. lastlabelhp:=hp1;
  269. end
  270. else
  271. begin
  272. same_string:=false;
  273. if (hp1.typ=ait_string) and
  274. (lastlabel<>nil) and
  275. (tai_string(hp1).len=mylength) then
  276. begin
  277. case cst_type of
  278. cst_conststring:
  279. begin
  280. j:=0;
  281. same_string:=true;
  282. if len>0 then
  283. begin
  284. for i:=0 to len-1 do
  285. begin
  286. if tai_string(hp1).str[j]<>value_str[i] then
  287. begin
  288. same_string:=false;
  289. break;
  290. end;
  291. inc(j);
  292. end;
  293. end;
  294. end;
  295. cst_shortstring:
  296. begin
  297. { if shortstring then check the length byte first and
  298. set the start index to 1 }
  299. if len=ord(tai_string(hp1).str[0]) then
  300. begin
  301. j:=1;
  302. same_string:=true;
  303. if len>0 then
  304. begin
  305. for i:=0 to len-1 do
  306. begin
  307. if tai_string(hp1).str[j]<>value_str[i] then
  308. begin
  309. same_string:=false;
  310. break;
  311. end;
  312. inc(j);
  313. end;
  314. end;
  315. end;
  316. end;
  317. cst_ansistring,
  318. cst_widestring :
  319. begin
  320. { before the string the following sequence must be found:
  321. <label>
  322. constsymbol <datalabel>
  323. constint -1
  324. constint <len>
  325. we must then return <label> to reuse
  326. }
  327. hp2:=tai(lastlabelhp.previous);
  328. if assigned(hp2) and
  329. (hp2.typ=ait_const) and
  330. (tai_const(hp2).consttype=aitconst_aint) and
  331. (tai_const(hp2).value=len) and
  332. assigned(hp2.previous) and
  333. (tai(hp2.previous).typ=ait_const) and
  334. (tai_const(hp2.previous).consttype=aitconst_aint) and
  335. (tai_const(hp2.previous).value=-1) and
  336. assigned(hp2.previous.previous) and
  337. (tai(hp2.previous.previous).typ=ait_const) and
  338. (tai_const(hp2.previous.previous).consttype=aitconst_ptr) and
  339. assigned(hp2.previous.previous.previous) and
  340. (tai(hp2.previous.previous.previous).typ=ait_label) then
  341. begin
  342. lastlabel:=tai_label(hp2.previous.previous.previous).labsym;
  343. same_string:=true;
  344. j:=0;
  345. if len>0 then
  346. begin
  347. for i:=0 to len-1 do
  348. begin
  349. if tai_string(hp1).str[j]<>value_str[i] then
  350. begin
  351. same_string:=false;
  352. break;
  353. end;
  354. inc(j);
  355. end;
  356. end;
  357. end;
  358. end;
  359. end;
  360. { found ? }
  361. if same_string then
  362. begin
  363. lab_str:=lastlabel;
  364. break;
  365. end;
  366. end;
  367. lastlabel:=nil;
  368. end;
  369. hp1:=tai(hp1.next);
  370. end;
  371. end;
  372. { :-(, we must generate a new entry }
  373. if not assigned(lab_str) then
  374. begin
  375. current_asmdata.getdatalabel(lastlabel);
  376. lab_str:=lastlabel;
  377. maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
  378. new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata,lastlabel.name,const_align(sizeof(aint)));
  379. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
  380. { generate an ansi string ? }
  381. case cst_type of
  382. cst_ansistring:
  383. begin
  384. { an empty ansi string is nil! }
  385. if len=0 then
  386. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_sym(nil))
  387. else
  388. begin
  389. current_asmdata.getdatalabel(l1);
  390. current_asmdata.getdatalabel(l2);
  391. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l2));
  392. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_sym(l1));
  393. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_aint(-1));
  394. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_aint(len));
  395. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l1));
  396. { include also terminating zero }
  397. getmem(pc,len+1);
  398. move(value_str^,pc^,len);
  399. pc[len]:=#0;
  400. current_asmdata.asmlists[al_typedconsts].concat(Tai_string.Create_pchar(pc,len+1));
  401. { return the offset of the real string }
  402. lab_str:=l2;
  403. end;
  404. end;
  405. cst_widestring:
  406. begin
  407. { an empty wide string is nil! }
  408. if len=0 then
  409. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_sym(nil))
  410. else
  411. begin
  412. current_asmdata.getdatalabel(l1);
  413. current_asmdata.getdatalabel(l2);
  414. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l2));
  415. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_sym(l1));
  416. { we use always UTF-16 coding for constants }
  417. { at least for now }
  418. { Consts.concat(Tai_const.Create_8bit(2)); }
  419. if tf_winlikewidestring in target_info.flags then
  420. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit(len*cwidechartype.size))
  421. else
  422. begin
  423. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_aint(-1));
  424. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_aint(len*cwidechartype.size));
  425. end;
  426. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(l1));
  427. for i:=0 to len-1 do
  428. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(pcompilerwidestring(value_str)^.data[i]));
  429. { terminating zero }
  430. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(0));
  431. { return the offset of the real string }
  432. lab_str:=l2;
  433. end;
  434. end;
  435. cst_shortstring:
  436. begin
  437. { truncate strings larger than 255 chars }
  438. if len>255 then
  439. l:=255
  440. else
  441. l:=len;
  442. { include length and terminating zero for quick conversion to pchar }
  443. getmem(pc,l+2);
  444. move(value_str^,pc[1],l);
  445. pc[0]:=chr(l);
  446. pc[l+1]:=#0;
  447. current_asmdata.asmlists[al_typedconsts].concat(Tai_string.Create_pchar(pc,l+2));
  448. end;
  449. cst_conststring:
  450. begin
  451. { include terminating zero }
  452. getmem(pc,len+1);
  453. move(value_str^,pc[0],len);
  454. pc[len]:=#0;
  455. current_asmdata.asmlists[al_typedconsts].concat(Tai_string.Create_pchar(pc,len+1));
  456. end;
  457. end;
  458. end;
  459. end;
  460. location.reference.symbol:=lab_str;
  461. end;
  462. {*****************************************************************************
  463. TCGSETCONSTNODE
  464. *****************************************************************************}
  465. procedure tcgsetconstnode.pass_generate_code;
  466. var
  467. hp1 : tai;
  468. lastlabel : tasmlabel;
  469. i : longint;
  470. neededtyp : taiconst_type;
  471. indexadjust : longint;
  472. type
  473. setbytes=array[0..31] of byte;
  474. Psetbytes=^setbytes;
  475. begin
  476. { xor indexadjust with indexes in a set typecasted to an array of }
  477. { bytes to get the correct locations, also when endianess of source }
  478. { and destiantion differs (JM) }
  479. if (source_info.endian = target_info.endian) then
  480. indexadjust := 0
  481. else
  482. indexadjust := 3;
  483. { small sets are loaded as constants }
  484. if tsetdef(resultdef).settype=smallset then
  485. begin
  486. location_reset(location,LOC_CONSTANT,OS_32);
  487. location.value:=pLongint(value_set)^;
  488. exit;
  489. end;
  490. location_reset(location,LOC_CREFERENCE,OS_NO);
  491. neededtyp:=aitconst_8bit;
  492. lastlabel:=nil;
  493. { const already used ? }
  494. if not assigned(lab_set) then
  495. begin
  496. { tries to found an old entry }
  497. hp1:=tai(current_asmdata.asmlists[al_typedconsts].first);
  498. while assigned(hp1) do
  499. begin
  500. if hp1.typ=ait_label then
  501. lastlabel:=tai_label(hp1).labsym
  502. else
  503. begin
  504. if (lastlabel<>nil) and
  505. (hp1.typ=ait_const) and
  506. (tai_const(hp1).consttype=neededtyp) then
  507. begin
  508. if (tai_const(hp1).consttype=aitconst_8bit) then
  509. begin
  510. { compare normal set }
  511. i:=0;
  512. while assigned(hp1) and (i<32) do
  513. begin
  514. if tai_const(hp1).value<>Psetbytes(value_set)^[i xor indexadjust] then
  515. break;
  516. inc(i);
  517. hp1:=tai(hp1.next);
  518. end;
  519. if i=32 then
  520. begin
  521. { found! }
  522. lab_set:=lastlabel;
  523. break;
  524. end;
  525. { leave when the end of consts is reached, so no
  526. hp1.next is done }
  527. if not assigned(hp1) then
  528. break;
  529. end
  530. else
  531. begin
  532. { compare small set }
  533. if paint(value_set)^=tai_const(hp1).value then
  534. begin
  535. { found! }
  536. lab_set:=lastlabel;
  537. break;
  538. end;
  539. end;
  540. end;
  541. lastlabel:=nil;
  542. end;
  543. hp1:=tai(hp1.next);
  544. end;
  545. { :-(, we must generate a new entry }
  546. if not assigned(lab_set) then
  547. begin
  548. current_asmdata.getdatalabel(lastlabel);
  549. lab_set:=lastlabel;
  550. maybe_new_object_file(current_asmdata.asmlists[al_typedconsts]);
  551. new_section(current_asmdata.asmlists[al_typedconsts],sec_rodata,lastlabel.name,const_align(sizeof(aint)));
  552. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(lastlabel));
  553. { already handled at the start of this method?? (JM)
  554. if tsetdef(resultdef).settype=smallset then
  555. begin
  556. move(value_set^,i,sizeof(longint));
  557. Consts.concat(Tai_const.Create_32bit(i));
  558. end
  559. else
  560. }
  561. begin
  562. for i:=0 to 31 do
  563. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_8bit(Psetbytes(value_set)^[i xor indexadjust]));
  564. end;
  565. end;
  566. end;
  567. location.reference.symbol:=lab_set;
  568. end;
  569. {*****************************************************************************
  570. TCGNILNODE
  571. *****************************************************************************}
  572. procedure tcgnilnode.pass_generate_code;
  573. begin
  574. location_reset(location,LOC_CONSTANT,OS_ADDR);
  575. location.value:=0;
  576. end;
  577. {*****************************************************************************
  578. TCGPOINTERCONSTNODE
  579. *****************************************************************************}
  580. procedure tcgguidconstnode.pass_generate_code;
  581. var
  582. tmplabel : TAsmLabel;
  583. i : integer;
  584. begin
  585. location_reset(location,LOC_CREFERENCE,OS_NO);
  586. { label for GUID }
  587. current_asmdata.getdatalabel(tmplabel);
  588. current_asmdata.asmlists[al_typedconsts].concat(tai_align.create(const_align(16)));
  589. current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(tmplabel));
  590. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_32bit(longint(value.D1)));
  591. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(value.D2));
  592. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(value.D3));
  593. for i:=low(value.D4) to high(value.D4) do
  594. current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_8bit(value.D4[i]));
  595. location.reference.symbol:=tmplabel;
  596. end;
  597. begin
  598. cdataconstnode:=tcgdataconstnode;
  599. crealconstnode:=tcgrealconstnode;
  600. cordconstnode:=tcgordconstnode;
  601. cpointerconstnode:=tcgpointerconstnode;
  602. cstringconstnode:=tcgstringconstnode;
  603. csetconstnode:=tcgsetconstnode;
  604. cnilnode:=tcgnilnode;
  605. cguidconstnode:=tcgguidconstnode;
  606. end.