aasm.pas 28 KB

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