aasm.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  1. {
  2. $Id$
  3. Copyright (c) 1996-98 by Florian Klaempfl
  4. This unit implements an abstract asmoutput class for all processor types
  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 aasm;
  19. interface
  20. uses
  21. cobjects,files,globals;
  22. type
  23. {$ifdef i386}
  24. {$ifndef VER0_99_5}
  25. bestreal = extended;
  26. {$else}
  27. bestreal = double;
  28. {$endif}
  29. {$endif}
  30. {$ifdef m68k}
  31. bestreal = real;
  32. {$endif}
  33. pbestreal=^bestreal;
  34. tait = (
  35. ait_string,
  36. ait_label,
  37. ait_direct,
  38. ait_labeled_instruction,
  39. ait_comment,
  40. ait_instruction,
  41. ait_datablock,
  42. ait_symbol,
  43. ait_const_32bit,
  44. ait_const_16bit,
  45. ait_const_8bit,
  46. ait_const_symbol,
  47. ait_const_symbol_offset,
  48. ait_real_64bit,
  49. ait_real_32bit,
  50. ait_real_extended,
  51. ait_comp,
  52. ait_external,
  53. ait_align,
  54. ait_section,
  55. { the following is only used by the win32 version of the compiler }
  56. { and only the GNU AS Win32 is able to write it }
  57. ait_const_rva,
  58. ait_stabn,
  59. ait_stabs,
  60. ait_stab_function_name,
  61. ait_cut, { used to split into tiny assembler files }
  62. ait_regalloc,
  63. ait_regdealloc,
  64. ait_marker,
  65. { never used, makes insertation of new ait_ easier to type }
  66. ait_dummy);
  67. type
  68. { the short name makes typing easier }
  69. pai = ^tai;
  70. tai = object(tlinkedlist_item)
  71. typ : tait;
  72. fileinfo : tfileposinfo;
  73. constructor init;
  74. end;
  75. pai_string = ^tai_string;
  76. tai_string = object(tai)
  77. str : pchar;
  78. { extra len so the string can contain an \0 }
  79. len : longint;
  80. constructor init(const _str : string);
  81. constructor init_pchar(_str : pchar);
  82. constructor init_length_pchar(_str : pchar;length : longint);
  83. destructor done;virtual;
  84. end;
  85. { generates a common label }
  86. pai_symbol = ^tai_symbol;
  87. tai_symbol = object(tai)
  88. name : pchar;
  89. is_global : boolean;
  90. constructor init(const _name : string);
  91. constructor init_global(const _name : string);
  92. destructor done;virtual;
  93. end;
  94. { external types defined for TASM }
  95. { EXT_ANY for search purposes }
  96. texternal_typ = (EXT_ANY,EXT_NEAR, EXT_FAR, EXT_PROC, EXT_BYTE,
  97. EXT_WORD, EXT_DWORD, EXT_CODEPTR, EXT_DATAPTR,
  98. EXT_FWORD, EXT_PWORD, EXT_QWORD, EXT_TBYTE, EXT_ABS);
  99. { generates an symbol which is marked as external }
  100. pai_external = ^tai_external;
  101. tai_external = object(tai)
  102. name : pchar;
  103. exttyp : texternal_typ;
  104. constructor init(const _name : string;exttype : texternal_typ);
  105. destructor done; virtual;
  106. end;
  107. { type for a temporary label test if used for dispose of
  108. unnecessary labels }
  109. plabel = ^tlabel;
  110. tlabel = record
  111. nb : longint;
  112. is_data : boolean;
  113. is_used : boolean;
  114. is_set : boolean;
  115. refcount : word;
  116. end;
  117. pai_label = ^tai_label;
  118. tai_label = object(tai)
  119. l : plabel;
  120. constructor init(_l : plabel);
  121. destructor done; virtual;
  122. end;
  123. pai_direct = ^tai_direct;
  124. tai_direct = object(tai)
  125. str : pchar;
  126. constructor init(_str : pchar);
  127. destructor done; virtual;
  128. end;
  129. { to insert a comment into the generated assembler file }
  130. pai_asm_comment = ^tai_asm_comment;
  131. tai_asm_comment = object(tai)
  132. str : pchar;
  133. constructor init(_str : pchar);
  134. destructor done; virtual;
  135. end;
  136. { alignment for operator }
  137. pai_align = ^tai_align;
  138. tai_align = object(tai)
  139. aligntype: byte; { 1 = no align, 2 = word align, 4 = dword align }
  140. op: byte; { value to fill with - optional }
  141. constructor init(b:byte);
  142. constructor init_op(b: byte; use_op: byte);
  143. destructor done;virtual;
  144. end;
  145. tsection=(sec_none,sec_code,sec_data,sec_bss,sec_idata);
  146. { Insert a section/segment directive }
  147. pai_section = ^tai_section;
  148. tai_section = object(tai)
  149. sec : tsection;
  150. idataidx : longint;
  151. constructor init(s : tsection);
  152. constructor init_idata(i:longint);
  153. destructor done;virtual;
  154. end;
  155. { generates an uninitializised data block }
  156. pai_datablock = ^tai_datablock;
  157. tai_datablock = object(tai)
  158. size : longint;
  159. name : pchar;
  160. is_global : boolean;
  161. constructor init(const _name : string;_size : longint);
  162. constructor init_global(const _name : string;_size : longint);
  163. destructor done; virtual;
  164. end;
  165. { generates a long integer (32 bit) }
  166. pai_const = ^tai_const;
  167. tai_const = object(tai)
  168. value : longint;
  169. constructor init_32bit(_value : longint);
  170. constructor init_16bit(_value : word);
  171. constructor init_8bit(_value : byte);
  172. constructor init_symbol(p : pchar);
  173. constructor init_rva(p : pchar);
  174. destructor done;virtual;
  175. end;
  176. pai_const_symbol_offset = ^tai_const_symbol_offset;
  177. tai_const_symbol_offset= object(tai)
  178. name : pchar;
  179. offset : longint;
  180. constructor init(p : pchar; l : longint);
  181. destructor done;virtual;
  182. end;
  183. { generates a double (64 bit real) }
  184. pai_double = ^tai_double;
  185. tai_double = object(tai)
  186. value : double;
  187. constructor init(_value : double);
  188. end;
  189. { generates an comp (integer over 64 bits) }
  190. pai_comp = ^tai_comp;
  191. tai_comp = object(tai)
  192. value : bestreal;
  193. constructor init(_value : bestreal);
  194. { usefull for 64 bits apps, maybe later }
  195. constructor init_comp(_value : comp);
  196. end;
  197. { generates a single (32 bit real) }
  198. pai_single = ^tai_single;
  199. tai_single = object(tai)
  200. value : single;
  201. constructor init(_value : single);
  202. end;
  203. { generates an extended (80 bit real) }
  204. pai_extended = ^tai_extended;
  205. tai_extended = object(tai)
  206. value : bestreal;
  207. constructor init(_value : bestreal);
  208. end;
  209. { insert a cut to split into several smaller files }
  210. pai_cut = ^tai_cut;
  211. tai_cut = object(tai)
  212. endname : boolean;
  213. constructor init;
  214. constructor init_end;
  215. end;
  216. TMarker = (NoPropInfoStart, NoPropInfoEnd);
  217. pai_marker = ^tai_marker;
  218. tai_marker = object(tai)
  219. Kind: TMarker;
  220. Constructor init(_Kind: TMarker);
  221. end;
  222. { for each processor define the best precision }
  223. { bestreal is defined in globals }
  224. {$ifdef i386}
  225. const
  226. ait_bestreal = ait_real_extended;
  227. type
  228. pai_bestreal = pai_extended;
  229. tai_bestreal = tai_extended;
  230. {$endif i386}
  231. {$ifdef m68k}
  232. const
  233. ait_bestreal = ait_real_32bit;
  234. type
  235. pai_bestreal = pai_single;
  236. tai_bestreal = tai_single;
  237. {$endif m68k}
  238. paasmoutput = ^taasmoutput;
  239. taasmoutput = object(tlinkedlist)
  240. function getlasttaifilepos : pfileposinfo;
  241. end;
  242. var
  243. { temporary lists }
  244. exprasmlist,
  245. { default lists }
  246. datasegment,codesegment,bsssegment,
  247. internals,externals,debuglist,consts,
  248. importssection,exportssection,
  249. resourcesection,rttilist : paasmoutput;
  250. { external symbols without repetition }
  251. function search_assembler_symbol(pl : paasmoutput;const _name : string;exttype : texternal_typ) : pai_external;
  252. procedure concat_external(const _name : string;exttype : texternal_typ);
  253. procedure concat_internal(const _name : string;exttype : texternal_typ);
  254. { label functions }
  255. const
  256. nextlabelnr : longint = 1;
  257. countlabelref : boolean = true;
  258. { convert label to string}
  259. function lab2str(l : plabel) : string;
  260. { make l as a new label }
  261. procedure getlabel(var l : plabel);
  262. { make l as a new label and flag is_data }
  263. procedure getdatalabel(var l : plabel);
  264. { frees the label if unused }
  265. procedure freelabel(var l : plabel);
  266. { make a new zero label }
  267. procedure getzerolabel(var l : plabel);
  268. { reset a label to a zero label }
  269. procedure setzerolabel(var l : plabel);
  270. {just get a label number }
  271. procedure getlabelnr(var l : longint);
  272. implementation
  273. uses
  274. strings,verbose,systems;
  275. {****************************************************************************
  276. TAI
  277. ****************************************************************************}
  278. constructor tai.init;
  279. begin
  280. fileinfo:=aktfilepos;
  281. end;
  282. {****************************************************************************
  283. TAI_SECTION
  284. ****************************************************************************}
  285. constructor tai_section.init(s : tsection);
  286. begin
  287. inherited init;
  288. typ:=ait_section;
  289. sec:=s;
  290. idataidx:=0;
  291. end;
  292. constructor tai_section.init_idata(i:longint);
  293. begin
  294. inherited init;
  295. typ:=ait_section;
  296. sec:=sec_idata;
  297. idataidx:=i;
  298. end;
  299. destructor tai_section.done;
  300. begin
  301. inherited done;
  302. end;
  303. {****************************************************************************
  304. TAI_DATABLOCK
  305. ****************************************************************************}
  306. constructor tai_datablock.init(const _name : string;_size : longint);
  307. begin
  308. inherited init;
  309. typ:=ait_datablock;
  310. name:=strpnew(_name);
  311. concat_internal(_name,EXT_ANY);
  312. size:=_size;
  313. is_global:=false;
  314. end;
  315. constructor tai_datablock.init_global(const _name : string;_size : longint);
  316. begin
  317. inherited init;
  318. typ:=ait_datablock;
  319. name:=strpnew(_name);
  320. concat_internal(_name,EXT_ANY);
  321. size:=_size;
  322. is_global:=true;
  323. end;
  324. destructor tai_datablock.done;
  325. begin
  326. strdispose(name);
  327. inherited done;
  328. end;
  329. {****************************************************************************
  330. TAI_SYMBOL
  331. ****************************************************************************}
  332. constructor tai_symbol.init(const _name : string);
  333. begin
  334. inherited init;
  335. typ:=ait_symbol;
  336. name:=strpnew(_name);
  337. concat_internal(_name,EXT_ANY);
  338. is_global:=false;
  339. end;
  340. constructor tai_symbol.init_global(const _name : string);
  341. begin
  342. inherited init;
  343. typ:=ait_symbol;
  344. name:=strpnew(_name);
  345. concat_internal(_name,EXT_ANY);
  346. is_global:=true;
  347. end;
  348. destructor tai_symbol.done;
  349. begin
  350. strdispose(name);
  351. inherited done;
  352. end;
  353. {****************************************************************************
  354. TAI_EXTERNAL
  355. ****************************************************************************}
  356. constructor tai_external.init(const _name : string;exttype : texternal_typ);
  357. begin
  358. inherited init;
  359. typ:=ait_external;
  360. exttyp:=exttype;
  361. name:=strpnew(_name);
  362. end;
  363. destructor tai_external.done;
  364. begin
  365. strdispose(name);
  366. inherited done;
  367. end;
  368. {****************************************************************************
  369. TAI_CONST
  370. ****************************************************************************}
  371. constructor tai_const.init_32bit(_value : longint);
  372. begin
  373. inherited init;
  374. typ:=ait_const_32bit;
  375. value:=_value;
  376. end;
  377. constructor tai_const.init_16bit(_value : word);
  378. begin
  379. inherited init;
  380. typ:=ait_const_16bit;
  381. value:=_value;
  382. end;
  383. constructor tai_const.init_8bit(_value : byte);
  384. begin
  385. inherited init;
  386. typ:=ait_const_8bit;
  387. value:=_value;
  388. end;
  389. constructor tai_const.init_symbol(p : pchar);
  390. begin
  391. inherited init;
  392. typ:=ait_const_symbol;
  393. value:=longint(p);
  394. end;
  395. constructor tai_const.init_rva(p : pchar);
  396. begin
  397. inherited init;
  398. typ:=ait_const_rva;
  399. value:=longint(p);
  400. end;
  401. destructor tai_const.done;
  402. begin
  403. if typ=ait_const_symbol then
  404. strdispose(pchar(value));
  405. inherited done;
  406. end;
  407. {****************************************************************************
  408. TAI_CONST_SYMBOL_OFFSET
  409. ****************************************************************************}
  410. constructor tai_const_symbol_offset.init(p : pchar; l : longint);
  411. begin
  412. inherited init;
  413. typ:=ait_const_symbol_offset;
  414. name:=p;
  415. offset:=l;
  416. end;
  417. destructor tai_const_symbol_offset.done;
  418. begin
  419. strdispose(name);
  420. inherited done;
  421. end;
  422. {****************************************************************************
  423. TAI_DOUBLE
  424. ****************************************************************************}
  425. constructor tai_double.init(_value : double);
  426. begin
  427. inherited init;
  428. typ:=ait_real_64bit;
  429. value:=_value;
  430. end;
  431. {****************************************************************************
  432. TAI_SINGLE
  433. ****************************************************************************}
  434. constructor tai_single.init(_value : single);
  435. begin
  436. inherited init;
  437. typ:=ait_real_32bit;
  438. value:=_value;
  439. end;
  440. {****************************************************************************
  441. TAI_EXTENDED
  442. ****************************************************************************}
  443. constructor tai_extended.init(_value : bestreal);
  444. begin
  445. inherited init;
  446. typ:=ait_real_extended;
  447. value:=_value;
  448. end;
  449. {****************************************************************************
  450. TAI_COMP
  451. ****************************************************************************}
  452. constructor tai_comp.init(_value : bestreal);
  453. begin
  454. inherited init;
  455. typ:=ait_comp;
  456. value:=_value;
  457. end;
  458. constructor tai_comp.init_comp(_value : comp);
  459. begin
  460. inherited init;
  461. typ:=ait_comp;
  462. value:=_value;
  463. end;
  464. {****************************************************************************
  465. TAI_STRING
  466. ****************************************************************************}
  467. constructor tai_string.init(const _str : string);
  468. begin
  469. inherited init;
  470. typ:=ait_string;
  471. getmem(str,length(_str)+1);
  472. strpcopy(str,_str);
  473. len:=length(_str);
  474. end;
  475. constructor tai_string.init_pchar(_str : pchar);
  476. begin
  477. inherited init;
  478. typ:=ait_string;
  479. str:=_str;
  480. len:=strlen(_str);
  481. end;
  482. constructor tai_string.init_length_pchar(_str : pchar;length : longint);
  483. begin
  484. inherited init;
  485. typ:=ait_string;
  486. str:=_str;
  487. len:=length;
  488. end;
  489. destructor tai_string.done;
  490. begin
  491. { you can have #0 inside the strings so }
  492. if str<>nil then
  493. freemem(str,len+1);
  494. inherited done;
  495. end;
  496. {****************************************************************************
  497. TAI_LABEL
  498. ****************************************************************************}
  499. constructor tai_label.init(_l : plabel);
  500. begin
  501. inherited init;
  502. typ:=ait_label;
  503. l:=_l;
  504. l^.is_set:=true;
  505. end;
  506. destructor tai_label.done;
  507. begin
  508. if (l^.refcount>0) then
  509. { can now be disposed by a tai_labeled instruction !! }
  510. l^.is_set:=false
  511. else
  512. dispose(l);
  513. inherited done;
  514. end;
  515. {****************************************************************************
  516. TAI_DIRECT
  517. ****************************************************************************}
  518. constructor tai_direct.init(_str : pchar);
  519. begin
  520. inherited init;
  521. typ:=ait_direct;
  522. str:=_str;
  523. end;
  524. destructor tai_direct.done;
  525. begin
  526. strdispose(str);
  527. inherited done;
  528. end;
  529. {****************************************************************************
  530. TAI_ASM_COMMENT comment to be inserted in the assembler file
  531. ****************************************************************************}
  532. constructor tai_asm_comment.init(_str : pchar);
  533. begin
  534. inherited init;
  535. typ:=ait_comment;
  536. str:=_str;
  537. end;
  538. destructor tai_asm_comment.done;
  539. begin
  540. strdispose(str);
  541. inherited done;
  542. end;
  543. {****************************************************************************
  544. TAI_ALIGN
  545. ****************************************************************************}
  546. constructor tai_align.init(b: byte);
  547. begin
  548. inherited init;
  549. typ:=ait_align;
  550. if b in [1,2,4,8,16] then
  551. aligntype := b
  552. else
  553. aligntype := 1;
  554. op:=0;
  555. end;
  556. constructor tai_align.init_op(b: byte; use_op: byte);
  557. begin
  558. inherited init;
  559. typ:=ait_align;
  560. if b in [1,2,4,8,16] then
  561. aligntype := b
  562. else
  563. aligntype := 1;
  564. op:=use_op;
  565. end;
  566. destructor tai_align.done;
  567. begin
  568. inherited done;
  569. end;
  570. {****************************************************************************
  571. TAI_CUT
  572. ****************************************************************************}
  573. constructor tai_cut.init;
  574. begin
  575. inherited init;
  576. typ:=ait_cut;
  577. endname:=false;
  578. end;
  579. constructor tai_cut.init_end;
  580. begin
  581. inherited init;
  582. typ:=ait_cut;
  583. endname:=true;
  584. end;
  585. {****************************************************************************
  586. Tai_Marker
  587. ****************************************************************************}
  588. Constructor Tai_Marker.Init(_Kind: TMarker);
  589. Begin
  590. Inherited Init;
  591. typ := ait_marker;
  592. Kind := _Kind;
  593. End;
  594. {*****************************************************************************
  595. External Helpers
  596. *****************************************************************************}
  597. function search_assembler_symbol(pl : paasmoutput;const _name : string;exttype : texternal_typ) : pai_external;
  598. var
  599. p : pai;
  600. begin
  601. search_assembler_symbol:=nil;
  602. if pl=nil then
  603. internalerror(2001)
  604. else
  605. begin
  606. p:=pai(pl^.first);
  607. while (p<>nil) and
  608. (p<>pai(pl^.last)) do
  609. { if we get the same name with a different typ }
  610. { there is probably an error }
  611. if (p^.typ=ait_external) and
  612. ((exttype=EXT_ANY) or (pai_external(p)^.exttyp=exttype)) and
  613. (strpas(pai_external(p)^.name)=_name) then
  614. begin
  615. search_assembler_symbol:=pai_external(p);
  616. exit;
  617. end
  618. else
  619. p:=pai(p^.next);
  620. if (p<>nil) and
  621. (p^.typ=ait_external) and
  622. (pai_external(p)^.exttyp=exttype) and
  623. (strpas(pai_external(p)^.name)=_name) then
  624. begin
  625. search_assembler_symbol:=pai_external(p);
  626. exit;
  627. end;
  628. end;
  629. end;
  630. { insert each need external only once }
  631. procedure concat_external(const _name : string;exttype : texternal_typ);
  632. begin
  633. if not target_asm.externals then
  634. exit;
  635. if search_assembler_symbol(externals,_name,exttype)=nil then
  636. externals^.concat(new(pai_external,init(_name,exttype)));
  637. end;
  638. { insert each need internal only once }
  639. procedure concat_internal(const _name : string;exttype : texternal_typ);
  640. begin
  641. if not target_asm.externals then
  642. exit;
  643. if search_assembler_symbol(internals,_name,exttype)=nil then
  644. internals^.concat(new(pai_external,init(_name,exttype)));
  645. end;
  646. {*****************************************************************************
  647. Label Helpers
  648. *****************************************************************************}
  649. function lab2str(l : plabel) : string;
  650. begin
  651. if (l=nil) or (l^.nb=0) then
  652. begin
  653. {$ifdef EXTDEBUG}
  654. lab2str:='ILLEGAL'
  655. {$else EXTDEBUG}
  656. internalerror(2000);
  657. {$endif EXTDEBUG}
  658. end
  659. else
  660. begin
  661. if (l^.is_data) and (cs_smartlink in aktmoduleswitches) then
  662. lab2str:='_$'+current_module^.modulename^+'$_L'+tostr(l^.nb)
  663. else
  664. lab2str:=target_asm.labelprefix+tostr(l^.nb);
  665. end;
  666. { inside the WriteTree we must not count the refs PM }
  667. {$ifndef HEAPTRC}
  668. if countlabelref then
  669. inc(l^.refcount);
  670. {$endif HEAPTRC}
  671. l^.is_used:=true;
  672. end;
  673. procedure getlabel(var l : plabel);
  674. begin
  675. new(l);
  676. l^.nb:=nextlabelnr;
  677. l^.is_used:=false;
  678. l^.is_set:=false;
  679. l^.is_data:=false;
  680. l^.refcount:=0;
  681. inc(nextlabelnr);
  682. end;
  683. procedure getdatalabel(var l : plabel);
  684. begin
  685. new(l);
  686. l^.nb:=nextlabelnr;
  687. l^.is_used:=false;
  688. l^.is_set:=false;
  689. l^.is_data:=true;
  690. l^.refcount:=0;
  691. inc(nextlabelnr);
  692. end;
  693. procedure freelabel(var l : plabel);
  694. begin
  695. if (l<>nil) and (not l^.is_set) and (not l^.is_used) then
  696. dispose(l);
  697. l:=nil;
  698. end;
  699. procedure setzerolabel(var l : plabel);
  700. begin
  701. with l^ do
  702. begin
  703. nb:=0;
  704. is_used:=false;
  705. is_set:=false;
  706. is_data:=false;
  707. refcount:=0;
  708. end;
  709. end;
  710. procedure getzerolabel(var l : plabel);
  711. begin
  712. new(l);
  713. l^.nb:=0;
  714. l^.is_used:=false;
  715. l^.is_set:=false;
  716. l^.is_data:=false;
  717. l^.refcount:=0;
  718. end;
  719. procedure getlabelnr(var l : longint);
  720. begin
  721. l:=nextlabelnr;
  722. inc(nextlabelnr);
  723. end;
  724. function taasmoutput.getlasttaifilepos : pfileposinfo;
  725. begin
  726. if assigned(last) then
  727. getlasttaifilepos:=@pai(last)^.fileinfo
  728. else
  729. getlasttaifilepos:=nil;
  730. end;
  731. end.
  732. {
  733. $Log$
  734. Revision 1.22 1998-10-12 12:20:38 pierre
  735. + added tai_const_symbol_offset
  736. for r : pointer = @var.field;
  737. * better message for different arg names on implementation
  738. of function
  739. Revision 1.21 1998/10/08 17:17:07 pierre
  740. * current_module old scanner tagged as invalid if unit is recompiled
  741. + added ppheap for better info on tracegetmem of heaptrc
  742. (adds line column and file index)
  743. * several memory leaks removed ith help of heaptrc !!
  744. Revision 1.20 1998/10/06 17:16:31 pierre
  745. * some memory leaks fixed (thanks to Peter for heaptrc !)
  746. Revision 1.19 1998/10/01 20:19:11 jonas
  747. + ait_marker support
  748. Revision 1.18 1998/09/20 17:11:25 jonas
  749. * released REGALLOC
  750. Revision 1.17 1998/09/07 18:33:31 peter
  751. + smartlinking for win95 imports
  752. Revision 1.16 1998/09/03 17:08:37 pierre
  753. * better lines for stabs
  754. (no scroll back to if before else part
  755. no return to case line at jump outside case)
  756. + source lines also if not in order
  757. Revision 1.15 1998/08/11 15:31:36 peter
  758. * write extended to ppu file
  759. * new version 0.99.7
  760. Revision 1.14 1998/08/10 23:56:03 peter
  761. * fixed extended writing
  762. Revision 1.13 1998/08/10 14:49:33 peter
  763. + localswitches, moduleswitches, globalswitches splitting
  764. Revision 1.12 1998/07/14 14:46:36 peter
  765. * released NEWINPUT
  766. Revision 1.11 1998/07/07 11:19:50 peter
  767. + NEWINPUT for a better inputfile and scanner object
  768. Revision 1.10 1998/06/08 22:59:41 peter
  769. * smartlinking works for win32
  770. * some defines to exclude some compiler parts
  771. Revision 1.9 1998/06/04 23:51:26 peter
  772. * m68k compiles
  773. + .def file creation moved to gendef.pas so it could also be used
  774. for win32
  775. Revision 1.8 1998/05/23 01:20:53 peter
  776. + aktasmmode, aktoptprocessor, aktoutputformat
  777. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  778. + $LIBNAME to set the library name where the unit will be put in
  779. * splitted cgi386 a bit (codeseg to large for bp7)
  780. * nasm, tasm works again. nasm moved to ag386nsm.pas
  781. Revision 1.7 1998/05/07 00:16:59 peter
  782. * smartlinking for sets
  783. + consts labels are now concated/generated in hcodegen
  784. * moved some cpu code to cga and some none cpu depended code from cga
  785. to tree and hcodegen and cleanup of hcodegen
  786. * assembling .. output reduced for smartlinking ;)
  787. Revision 1.6 1998/05/06 18:36:53 peter
  788. * tai_section extended with code,data,bss sections and enumerated type
  789. * ident 'compiled by FPC' moved to pmodules
  790. * small fix for smartlink
  791. Revision 1.5 1998/05/01 07:43:52 florian
  792. + basics for rtti implemented
  793. + switch $m (generate rtti for published sections)
  794. Revision 1.4 1998/04/29 10:33:40 pierre
  795. + added some code for ansistring (not complete nor working yet)
  796. * corrected operator overloading
  797. * corrected nasm output
  798. + started inline procedures
  799. + added starstarn : use ** for exponentiation (^ gave problems)
  800. + started UseTokenInfo cond to get accurate positions
  801. Revision 1.3 1998/04/27 23:10:27 peter
  802. + new scanner
  803. * $makelib -> if smartlink
  804. * small filename fixes pmodule.setfilename
  805. * moved import from files.pas -> import.pas
  806. Revision 1.2 1998/04/09 15:46:37 florian
  807. + register allocation tracing stuff added
  808. }