aasm.pas 28 KB

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