ncgcon.pas 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Generate assembler for constant nodes which are the same for
  5. 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 ncgcon;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. node,ncon;
  24. type
  25. tcgrealconstnode = class(trealconstnode)
  26. procedure pass_2;override;
  27. end;
  28. tcgordconstnode = class(tordconstnode)
  29. procedure pass_2;override;
  30. end;
  31. tcgpointerconstnode = class(tpointerconstnode)
  32. procedure pass_2;override;
  33. end;
  34. tcgstringconstnode = class(tstringconstnode)
  35. procedure pass_2;override;
  36. end;
  37. tcgsetconstnode = class(tsetconstnode)
  38. procedure pass_2;override;
  39. end;
  40. tcgnilnode = class(tnilnode)
  41. procedure pass_2;override;
  42. end;
  43. tcgguidconstnode = class(tguidconstnode)
  44. procedure pass_2;override;
  45. end;
  46. implementation
  47. uses
  48. globtype,widestr,systems,
  49. verbose,globals,
  50. symconst,symdef,aasmbase,aasmtai,aasmcpu,defutil,
  51. cpuinfo,cpubase,
  52. cgbase,cgobj,
  53. {$ifdef delphi}
  54. ,dmisc
  55. {$endif}
  56. ncgutil
  57. ;
  58. {*****************************************************************************
  59. TCGREALCONSTNODE
  60. *****************************************************************************}
  61. procedure tcgrealconstnode.pass_2;
  62. { I suppose the parser/pass_1 must make sure the generated real }
  63. { constants are actually supported by the target processor? (JM) }
  64. const
  65. floattype2ait:array[tfloattype] of taitype=
  66. (ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit,ait_comp_64bit,ait_real_128bit);
  67. var
  68. hp1 : tai;
  69. lastlabel : tasmlabel;
  70. realait : taitype;
  71. {$ifdef ARM}
  72. hiloswapped : boolean;
  73. {$endif ARM}
  74. begin
  75. location_reset(location,LOC_CREFERENCE,def_cgsize(resulttype.def));
  76. lastlabel:=nil;
  77. realait:=floattype2ait[tfloatdef(resulttype.def).typ];
  78. {$ifdef ARM}
  79. hiloswapped:=aktfputype in [fpu_fpa,fpu_fpa10,fpu_fpa11];
  80. {$endif ARM}
  81. { const already used ? }
  82. if not assigned(lab_real) then
  83. begin
  84. { tries to find an old entry }
  85. hp1:=tai(Consts.first);
  86. while assigned(hp1) do
  87. begin
  88. if hp1.typ=ait_label then
  89. lastlabel:=tai_label(hp1).l
  90. else
  91. begin
  92. if (hp1.typ=realait) and (lastlabel<>nil) then
  93. begin
  94. if is_number_float(value_real) and
  95. (
  96. ((realait=ait_real_32bit) and (tai_real_32bit(hp1).value=value_real) and is_number_float(tai_real_32bit(hp1).value)) or
  97. ((realait=ait_real_64bit) and
  98. {$ifdef ARM}
  99. ((tai_real_64bit(hp1).formatoptions=fo_hiloswapped)=hiloswapped) and
  100. {$endif ARM}
  101. (tai_real_64bit(hp1).value=value_real) and is_number_float(tai_real_64bit(hp1).value)) or
  102. ((realait=ait_real_80bit) and (tai_real_80bit(hp1).value=value_real) and is_number_float(tai_real_80bit(hp1).value)) or
  103. {$ifdef cpufloat128}
  104. ((realait=ait_real_128bit) and (tai_real_128bit(hp1).value=value_real) and is_number_float(tai_real_128bit(hp1).value)) or
  105. {$endif cpufloat128}
  106. ((realait=ait_comp_64bit) and (tai_comp_64bit(hp1).value=value_real) and is_number_float(tai_comp_64bit(hp1).value))
  107. ) then
  108. begin
  109. { found! }
  110. lab_real:=lastlabel;
  111. break;
  112. end;
  113. end;
  114. lastlabel:=nil;
  115. end;
  116. hp1:=tai(hp1.next);
  117. end;
  118. { :-(, we must generate a new entry }
  119. if not assigned(lab_real) then
  120. begin
  121. objectlibrary.getdatalabel(lastlabel);
  122. lab_real:=lastlabel;
  123. maybe_new_object_file(consts);
  124. new_section(consts,sec_rodata,lastlabel.name,const_align(resulttype.def.size));
  125. Consts.concat(Tai_label.Create(lastlabel));
  126. case realait of
  127. ait_real_32bit :
  128. Consts.concat(Tai_real_32bit.Create(ts32real(value_real)));
  129. ait_real_64bit :
  130. {$ifdef ARM}
  131. if hiloswapped then
  132. Consts.concat(Tai_real_64bit.Create_hiloswapped(ts64real(value_real)))
  133. else
  134. {$endif ARM}
  135. Consts.concat(Tai_real_64bit.Create(ts64real(value_real)));
  136. ait_real_80bit :
  137. Consts.concat(Tai_real_80bit.Create(value_real));
  138. {$ifdef cpufloat128}
  139. ait_real_128bit :
  140. Consts.concat(Tai_real_128bit.Create(value_real));
  141. {$endif cpufloat128}
  142. {$ifdef ver1_0}
  143. ait_comp_64bit :
  144. Consts.concat(Tai_comp_64bit.Create(value_real));
  145. {$else ver1_0}
  146. { the round is necessary for native compilers where comp isn't a float }
  147. ait_comp_64bit :
  148. begin
  149. if (value_real>9223372036854775807.0) or (value_real<-9223372036854775808.0) then
  150. Message(parser_e_range_check_error)
  151. else
  152. Consts.concat(Tai_comp_64bit.Create(round(value_real)));
  153. end;
  154. {$endif ver1_0}
  155. else
  156. internalerror(10120);
  157. end;
  158. end;
  159. end;
  160. location.reference.symbol:=lab_real;
  161. end;
  162. {*****************************************************************************
  163. TCGORDCONSTNODE
  164. *****************************************************************************}
  165. procedure tcgordconstnode.pass_2;
  166. begin
  167. location_reset(location,LOC_CONSTANT,def_cgsize(resulttype.def));
  168. {$ifdef cpu64bit}
  169. location.value:=value;
  170. {$else cpu64bit}
  171. location.value64:=int64(value);
  172. {$endif cpu64bit}
  173. end;
  174. {*****************************************************************************
  175. TCGPOINTERCONSTNODE
  176. *****************************************************************************}
  177. procedure tcgpointerconstnode.pass_2;
  178. begin
  179. { an integer const. behaves as a memory reference }
  180. location_reset(location,LOC_CONSTANT,OS_ADDR);
  181. location.value:=aint(value);
  182. end;
  183. {*****************************************************************************
  184. TCGSTRINGCONSTNODE
  185. *****************************************************************************}
  186. procedure tcgstringconstnode.pass_2;
  187. var
  188. hp1,hp2 : tai;
  189. l1,l2,
  190. lastlabel : tasmlabel;
  191. lastlabelhp : tai;
  192. pc : pchar;
  193. same_string : boolean;
  194. l,j,
  195. i,mylength : longint;
  196. begin
  197. { for empty ansistrings we could return a constant 0 }
  198. {$ifdef ansistring_bits}
  199. if (st_type in [st_ansistring16,st_ansistring32,st_ansistring64,st_widestring]) and (len=0) then
  200. {$else}
  201. if (st_type in [st_ansistring,st_widestring]) and (len=0) then
  202. {$endif}
  203. begin
  204. location_reset(location,LOC_CONSTANT,OS_ADDR);
  205. location.value:=0;
  206. exit;
  207. end;
  208. { return a constant reference in memory }
  209. location_reset(location,LOC_CREFERENCE,def_cgsize(resulttype.def));
  210. { const already used ? }
  211. lastlabel:=nil;
  212. lastlabelhp:=nil;
  213. if not assigned(lab_str) then
  214. begin
  215. if is_shortstring(resulttype.def) then
  216. mylength:=len+2
  217. else
  218. mylength:=len+1;
  219. { widestrings can't be reused yet }
  220. if not(is_widestring(resulttype.def)) then
  221. begin
  222. { tries to found an old entry }
  223. hp1:=tai(Consts.first);
  224. while assigned(hp1) do
  225. begin
  226. if hp1.typ=ait_label then
  227. begin
  228. lastlabel:=tai_label(hp1).l;
  229. lastlabelhp:=hp1;
  230. end
  231. else
  232. begin
  233. same_string:=false;
  234. if (hp1.typ=ait_string) and
  235. (lastlabel<>nil) and
  236. (tai_string(hp1).len=mylength) then
  237. begin
  238. { if shortstring then check the length byte first and
  239. set the start index to 1 }
  240. case st_type of
  241. st_shortstring:
  242. begin
  243. if len=ord(tai_string(hp1).str[0]) then
  244. begin
  245. j:=1;
  246. same_string:=true;
  247. if len>0 then
  248. begin
  249. for i:=0 to len-1 do
  250. begin
  251. if tai_string(hp1).str[j]<>value_str[i] then
  252. begin
  253. same_string:=false;
  254. break;
  255. end;
  256. inc(j);
  257. end;
  258. end;
  259. end;
  260. end;
  261. {$ifdef ansistring_bits}
  262. st_ansistring16:
  263. begin
  264. { before the string the following sequence must be found:
  265. <label>
  266. constsymbol <datalabel>
  267. const32 <len>
  268. const32 <len>
  269. const32 -1
  270. we must then return <label> to reuse
  271. }
  272. hp2:=tai(lastlabelhp.previous);
  273. if assigned(hp2) and
  274. (hp2.typ=ait_const_16bit) and
  275. (tai_const(hp2).value=aword(-1)) and
  276. assigned(hp2.previous) and
  277. (tai(hp2.previous).typ=ait_const_16bit) and
  278. (tai_const(hp2.previous).value=len) and
  279. assigned(hp2.previous.previous) and
  280. (tai(hp2.previous.previous).typ=ait_const_16bit) and
  281. (tai_const(hp2.previous.previous).value=len) and
  282. assigned(hp2.previous.previous.previous) and
  283. (tai(hp2.previous.previous.previous).typ=ait_const_symbol) and
  284. assigned(hp2.previous.previous.previous.previous) and
  285. (tai(hp2.previous.previous.previous.previous).typ=ait_label) then
  286. begin
  287. lastlabel:=tai_label(hp2.previous.previous.previous.previous).l;
  288. same_string:=true;
  289. j:=0;
  290. if len>0 then
  291. begin
  292. for i:=0 to len-1 do
  293. begin
  294. if tai_string(hp1).str[j]<>value_str[i] then
  295. begin
  296. same_string:=false;
  297. break;
  298. end;
  299. inc(j);
  300. end;
  301. end;
  302. end;
  303. end;
  304. {$endif}
  305. {$ifdef ansistring_bits}
  306. st_ansistring32,
  307. {$else}
  308. st_ansistring,
  309. {$endif}
  310. st_widestring :
  311. begin
  312. { before the string the following sequence must be found:
  313. <label>
  314. constsymbol <datalabel>
  315. constint -1
  316. constint <len>
  317. we must then return <label> to reuse
  318. }
  319. hp2:=tai(lastlabelhp.previous);
  320. if assigned(hp2) and
  321. (hp2.typ=ait_const_aint) and
  322. (tai_const(hp2).value=-1) and
  323. assigned(hp2.previous) and
  324. (tai(hp2.previous).typ=ait_const_aint) and
  325. (tai_const(hp2.previous).value=len) and
  326. assigned(hp2.previous.previous) and
  327. (tai(hp2.previous.previous).typ=ait_const_ptr) and
  328. assigned(hp2.previous.previous.previous) and
  329. (tai(hp2.previous.previous.previous).typ=ait_label) then
  330. begin
  331. lastlabel:=tai_label(hp2.previous.previous.previous).l;
  332. same_string:=true;
  333. j:=0;
  334. if len>0 then
  335. begin
  336. for i:=0 to len-1 do
  337. begin
  338. if tai_string(hp1).str[j]<>value_str[i] then
  339. begin
  340. same_string:=false;
  341. break;
  342. end;
  343. inc(j);
  344. end;
  345. end;
  346. end;
  347. end;
  348. {$ifdef ansistring_bits}
  349. st_ansistring64:
  350. begin
  351. { before the string the following sequence must be found:
  352. <label>
  353. constsymbol <datalabel>
  354. const32 <len>
  355. const32 <len>
  356. const32 -1
  357. we must then return <label> to reuse
  358. }
  359. hp2:=tai(lastlabelhp.previous);
  360. if assigned(hp2) and
  361. (hp2.typ=ait_const_64bit) and
  362. (tai_const(hp2).value=aword(-1)) and
  363. assigned(hp2.previous) and
  364. (tai(hp2.previous).typ=ait_const_64bit) and
  365. (tai_const(hp2.previous).value=len) and
  366. assigned(hp2.previous.previous) and
  367. (tai(hp2.previous.previous).typ=ait_const_64bit) and
  368. (tai_const(hp2.previous.previous).value=len) and
  369. assigned(hp2.previous.previous.previous) and
  370. (tai(hp2.previous.previous.previous).typ=ait_const_symbol) and
  371. assigned(hp2.previous.previous.previous.previous) and
  372. (tai(hp2.previous.previous.previous.previous).typ=ait_label) then
  373. begin
  374. lastlabel:=tai_label(hp2.previous.previous.previous.previous).l;
  375. same_string:=true;
  376. j:=0;
  377. if len>0 then
  378. begin
  379. for i:=0 to len-1 do
  380. begin
  381. if tai_string(hp1).str[j]<>value_str[i] then
  382. begin
  383. same_string:=false;
  384. break;
  385. end;
  386. inc(j);
  387. end;
  388. end;
  389. end;
  390. end;
  391. {$endif}
  392. end;
  393. { found ? }
  394. if same_string then
  395. begin
  396. lab_str:=lastlabel;
  397. break;
  398. end;
  399. end;
  400. lastlabel:=nil;
  401. end;
  402. hp1:=tai(hp1.next);
  403. end;
  404. end;
  405. { :-(, we must generate a new entry }
  406. if not assigned(lab_str) then
  407. begin
  408. objectlibrary.getdatalabel(lastlabel);
  409. lab_str:=lastlabel;
  410. maybe_new_object_file(consts);
  411. new_section(consts,sec_rodata,lastlabel.name,const_align(sizeof(aint)));
  412. Consts.concat(Tai_label.Create(lastlabel));
  413. { generate an ansi string ? }
  414. case st_type of
  415. {$ifdef ansistring_bits}
  416. st_ansistring16:
  417. begin
  418. { an empty ansi string is nil! }
  419. if len=0 then
  420. Consts.concat(Tai_const.Create_ptr(0))
  421. else
  422. begin
  423. objectlibrary.getdatalabel(l1);
  424. objectlibrary.getdatalabel(l2);
  425. Consts.concat(Tai_label.Create(l2));
  426. Consts.concat(Tai_const_symbol.Create(l1));
  427. Consts.concat(Tai_const.Create_32bit(-1));
  428. Consts.concat(Tai_const.Create_32bit(len));
  429. Consts.concat(Tai_label.Create(l1));
  430. getmem(pc,len+2);
  431. move(value_str^,pc^,len);
  432. pc[len]:=#0;
  433. { to overcome this problem we set the length explicitly }
  434. { with the ending null char }
  435. Consts.concat(Tai_string.Create_length_pchar(pc,len+1));
  436. { return the offset of the real string }
  437. lab_str:=l2;
  438. end;
  439. end;
  440. {$endif}
  441. {$ifdef ansistring_bits}st_ansistring32:{$else}st_ansistring:{$endif}
  442. begin
  443. { an empty ansi string is nil! }
  444. if len=0 then
  445. Consts.concat(Tai_const.Create_sym(nil))
  446. else
  447. begin
  448. objectlibrary.getdatalabel(l1);
  449. objectlibrary.getdatalabel(l2);
  450. Consts.concat(Tai_label.Create(l2));
  451. Consts.concat(Tai_const.Create_sym(l1));
  452. Consts.concat(Tai_const.Create_aint(-1));
  453. Consts.concat(Tai_const.Create_aint(len));
  454. Consts.concat(Tai_label.Create(l1));
  455. getmem(pc,len+2);
  456. move(value_str^,pc^,len);
  457. pc[len]:=#0;
  458. { to overcome this problem we set the length explicitly }
  459. { with the ending null char }
  460. Consts.concat(Tai_string.Create_length_pchar(pc,len+1));
  461. { return the offset of the real string }
  462. lab_str:=l2;
  463. end;
  464. end;
  465. {$ifdef ansistring_bits}
  466. st_ansistring64:
  467. begin
  468. { an empty ansi string is nil! }
  469. if len=0 then
  470. Consts.concat(Tai_const.Create_ptr(0))
  471. else
  472. begin
  473. objectlibrary.getdatalabel(l1);
  474. objectlibrary.getdatalabel(l2);
  475. Consts.concat(Tai_label.Create(l2));
  476. Consts.concat(Tai_const_symbol.Create(l1));
  477. Consts.concat(Tai_const.Create_32bit(-1));
  478. Consts.concat(Tai_const.Create_32bit(len));
  479. Consts.concat(Tai_label.Create(l1));
  480. getmem(pc,len+2);
  481. move(value_str^,pc^,len);
  482. pc[len]:=#0;
  483. { to overcome this problem we set the length explicitly }
  484. { with the ending null char }
  485. Consts.concat(Tai_string.Create_length_pchar(pc,len+1));
  486. { return the offset of the real string }
  487. lab_str:=l2;
  488. end;
  489. end;
  490. {$endif}
  491. st_widestring:
  492. begin
  493. { an empty wide string is nil! }
  494. if len=0 then
  495. Consts.concat(Tai_const.Create_sym(nil))
  496. else
  497. begin
  498. objectlibrary.getdatalabel(l1);
  499. objectlibrary.getdatalabel(l2);
  500. Consts.concat(Tai_label.Create(l2));
  501. Consts.concat(Tai_const.Create_sym(l1));
  502. { we use always UTF-16 coding for constants }
  503. { at least for now }
  504. { Consts.concat(Tai_const.Create_8bit(2)); }
  505. Consts.concat(Tai_const.Create_aint(-1));
  506. Consts.concat(Tai_const.Create_aint(len));
  507. Consts.concat(Tai_label.Create(l1));
  508. for i:=0 to len-1 do
  509. Consts.concat(Tai_const.Create_16bit(pcompilerwidestring(value_str)^.data[i]));
  510. { terminating zero }
  511. Consts.concat(Tai_const.Create_16bit(0));
  512. { return the offset of the real string }
  513. lab_str:=l2;
  514. end;
  515. end;
  516. st_shortstring:
  517. begin
  518. { truncate strings larger than 255 chars }
  519. if len>255 then
  520. l:=255
  521. else
  522. l:=len;
  523. { also length and terminating zero }
  524. getmem(pc,l+3);
  525. move(value_str^,pc[1],l+1);
  526. pc[0]:=chr(l);
  527. { to overcome this problem we set the length explicitly }
  528. { with the ending null char }
  529. pc[l+1]:=#0;
  530. Consts.concat(Tai_string.Create_length_pchar(pc,l+2));
  531. end;
  532. end;
  533. end;
  534. end;
  535. location.reference.symbol:=lab_str;
  536. end;
  537. {*****************************************************************************
  538. TCGSETCONSTNODE
  539. *****************************************************************************}
  540. procedure tcgsetconstnode.pass_2;
  541. var
  542. hp1 : tai;
  543. lastlabel : tasmlabel;
  544. i : longint;
  545. neededtyp : taitype;
  546. indexadjust : longint;
  547. type
  548. setbytes=array[0..31] of byte;
  549. Psetbytes=^setbytes;
  550. begin
  551. { xor indexadjust with indexes in a set typecasted to an array of }
  552. { bytes to get the correct locations, also when endianess of source }
  553. { and destiantion differs (JM) }
  554. if (source_info.endian = target_info.endian) then
  555. indexadjust := 0
  556. else
  557. indexadjust := 3;
  558. { small sets are loaded as constants }
  559. if tsetdef(resulttype.def).settype=smallset then
  560. begin
  561. location_reset(location,LOC_CONSTANT,OS_32);
  562. location.value:=PAInt(value_set)^;
  563. exit;
  564. end;
  565. location_reset(location,LOC_CREFERENCE,OS_NO);
  566. neededtyp:=ait_const_8bit;
  567. lastlabel:=nil;
  568. { const already used ? }
  569. if not assigned(lab_set) then
  570. begin
  571. { tries to found an old entry }
  572. hp1:=tai(Consts.first);
  573. while assigned(hp1) do
  574. begin
  575. if hp1.typ=ait_label then
  576. lastlabel:=tai_label(hp1).l
  577. else
  578. begin
  579. if (lastlabel<>nil) and (hp1.typ=neededtyp) then
  580. begin
  581. if (hp1.typ=ait_const_8bit) then
  582. begin
  583. { compare normal set }
  584. i:=0;
  585. while assigned(hp1) and (i<32) do
  586. begin
  587. if tai_const(hp1).value<>Psetbytes(value_set)^[i xor indexadjust] then
  588. break;
  589. inc(i);
  590. hp1:=tai(hp1.next);
  591. end;
  592. if i=32 then
  593. begin
  594. { found! }
  595. lab_set:=lastlabel;
  596. break;
  597. end;
  598. { leave when the end of consts is reached, so no
  599. hp1.next is done }
  600. if not assigned(hp1) then
  601. break;
  602. end
  603. else
  604. begin
  605. { compare small set }
  606. if paint(value_set)^=tai_const(hp1).value then
  607. begin
  608. { found! }
  609. lab_set:=lastlabel;
  610. break;
  611. end;
  612. end;
  613. end;
  614. lastlabel:=nil;
  615. end;
  616. hp1:=tai(hp1.next);
  617. end;
  618. { :-(, we must generate a new entry }
  619. if not assigned(lab_set) then
  620. begin
  621. objectlibrary.getdatalabel(lastlabel);
  622. lab_set:=lastlabel;
  623. maybe_new_object_file(consts);
  624. new_section(consts,sec_rodata,lastlabel.name,const_align(sizeof(aint)));
  625. Consts.concat(Tai_label.Create(lastlabel));
  626. { already handled at the start of this method?? (JM)
  627. if tsetdef(resulttype.def).settype=smallset then
  628. begin
  629. move(value_set^,i,sizeof(longint));
  630. Consts.concat(Tai_const.Create_32bit(i));
  631. end
  632. else
  633. }
  634. begin
  635. for i:=0 to 31 do
  636. Consts.concat(Tai_const.Create_8bit(Psetbytes(value_set)^[i xor indexadjust]));
  637. end;
  638. end;
  639. end;
  640. location.reference.symbol:=lab_set;
  641. end;
  642. {*****************************************************************************
  643. TCGNILNODE
  644. *****************************************************************************}
  645. procedure tcgnilnode.pass_2;
  646. begin
  647. location_reset(location,LOC_CONSTANT,OS_ADDR);
  648. location.value:=0;
  649. end;
  650. {*****************************************************************************
  651. TCGPOINTERCONSTNODE
  652. *****************************************************************************}
  653. procedure tcgguidconstnode.pass_2;
  654. var
  655. tmplabel : TAsmLabel;
  656. i : integer;
  657. begin
  658. location_reset(location,LOC_CREFERENCE,OS_NO);
  659. { label for GUID }
  660. objectlibrary.getdatalabel(tmplabel);
  661. consts.concat(tai_align.create(const_align(16)));
  662. consts.concat(Tai_label.Create(tmplabel));
  663. consts.concat(Tai_const.Create_32bit(value.D1));
  664. consts.concat(Tai_const.Create_16bit(value.D2));
  665. consts.concat(Tai_const.Create_16bit(value.D3));
  666. for i:=Low(value.D4) to High(value.D4) do
  667. consts.concat(Tai_const.Create_8bit(value.D4[i]));
  668. location.reference.symbol:=tmplabel;
  669. end;
  670. begin
  671. crealconstnode:=tcgrealconstnode;
  672. cordconstnode:=tcgordconstnode;
  673. cpointerconstnode:=tcgpointerconstnode;
  674. cstringconstnode:=tcgstringconstnode;
  675. csetconstnode:=tcgsetconstnode;
  676. cnilnode:=tcgnilnode;
  677. cguidconstnode:=tcgguidconstnode;
  678. end.
  679. {
  680. $Log$
  681. Revision 1.44 2004-07-12 17:58:19 peter
  682. * remove maxlen field from ansistring/widestrings
  683. Revision 1.43 2004/06/20 08:55:29 florian
  684. * logs truncated
  685. Revision 1.42 2004/06/18 15:16:46 peter
  686. * remove obsolete cardinal() typecasts
  687. Revision 1.41 2004/06/16 20:07:08 florian
  688. * dwarf branch merged
  689. Revision 1.40 2004/04/29 19:56:37 daniel
  690. * Prepare compiler infrastructure for multiple ansistring types
  691. Revision 1.39.2.9 2004/06/13 10:51:16 florian
  692. * fixed several register allocator problems (sparc/arm)
  693. Revision 1.39.2.8 2004/06/12 17:01:01 florian
  694. * fixed compilation of arm compiler
  695. }