aasm.pas 28 KB

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