aasmdata.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. {
  2. Copyright (c) 1998-2006 by Florian Klaempfl
  3. This unit implements an abstract asmoutput class for all processor types
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. { @abstract(This unit implements an abstract asm output class for all processor types)
  18. This unit implements an abstract assembler output class for all processors, these
  19. are then overridden for each assembler writer to actually write the data in these
  20. classes to an assembler file.
  21. }
  22. unit aasmdata;
  23. {$i fpcdefs.inc}
  24. interface
  25. uses
  26. cutils,cclasses,
  27. globtype,systems,
  28. cgbase,
  29. symtype,
  30. aasmbase;
  31. type
  32. { Type of AsmLists. The order is important for the layout of the
  33. information in the .o file. The stabs for the types must be defined
  34. before they can be referenced and therefor they need to be written
  35. first (PFV) }
  36. TAsmListType=(
  37. al_start,
  38. al_stabs,
  39. { pure assembler routines }
  40. al_pure_assembler,
  41. al_procedures,
  42. al_globals,
  43. al_const,
  44. al_typedconsts,
  45. al_rotypedconsts,
  46. al_threadvars,
  47. al_imports,
  48. al_exports,
  49. al_resources,
  50. al_rtti,
  51. { all symbols with indirect suffix }
  52. al_indirectglobals,
  53. al_dwarf_frame,
  54. al_dwarf_info,
  55. al_dwarf_abbrev,
  56. al_dwarf_line,
  57. al_dwarf_aranges,
  58. al_dwarf_ranges,
  59. al_picdata,
  60. al_indirectpicdata,
  61. al_resourcestrings,
  62. { Objective-C related sections }
  63. al_objc_data,
  64. { keep pool data separate, so we can generate new pool entries
  65. while emitting other data }
  66. al_objc_pools,
  67. al_end
  68. );
  69. { Type of constant 'pools'. Mostly for string types, but usable for
  70. floating point and large set constants, too. }
  71. TConstPoolType = (
  72. sp_invalid,
  73. sp_conststr,
  74. sp_shortstr,
  75. sp_longstr,
  76. sp_ansistr,
  77. sp_widestr,
  78. sp_unicodestr,
  79. sp_objcclassnamerefs,
  80. sp_varnamerefs,
  81. sp_objcclassnames,
  82. sp_objcvarnames,
  83. sp_objcvartypes,
  84. sp_objcprotocolrefs,
  85. sp_varsets,
  86. sp_floats,
  87. sp_guids,
  88. sp_paraloc
  89. );
  90. const
  91. AsmListTypeStr : array[TAsmListType] of string[24] =(
  92. 'al_begin',
  93. 'al_stabs',
  94. 'al_pure_assembler',
  95. 'al_procedures',
  96. 'al_globals',
  97. 'al_const',
  98. 'al_typedconsts',
  99. 'al_rotypedconsts',
  100. 'al_threadvars',
  101. 'al_imports',
  102. 'al_exports',
  103. 'al_resources',
  104. 'al_rtti',
  105. 'al_indirectglobals',
  106. 'al_dwarf_frame',
  107. 'al_dwarf_info',
  108. 'al_dwarf_abbrev',
  109. 'al_dwarf_line',
  110. 'al_dwarf_aranges',
  111. 'al_dwarf_ranges',
  112. 'al_picdata',
  113. 'al_indirectpicdata',
  114. 'al_resourcestrings',
  115. 'al_objc_data',
  116. 'al_objc_pools',
  117. 'al_end'
  118. );
  119. type
  120. TAsmList = class(tlinkedlist)
  121. section_count : longint;
  122. constructor create;
  123. function getlasttaifilepos : pfileposinfo;
  124. { inserts another List at the begin and make this List empty }
  125. procedure insertList(p : TLinkedList); override;
  126. { inserts another List before the provided item and make this List empty }
  127. procedure insertListBefore(Item:TLinkedListItem;p : TLinkedList); override;
  128. { inserts another List after the provided item and make this List empty }
  129. procedure insertListAfter(Item:TLinkedListItem;p : TLinkedList); override;
  130. { concats another List at the end and make this List empty }
  131. procedure concatList(p : TLinkedList); override;
  132. { concats another List at the start and makes a copy
  133. the list is ordered in reverse.
  134. }
  135. procedure insertListcopy(p : TLinkedList); override;
  136. { concats another List at the end and makes a copy }
  137. procedure concatListcopy(p : TLinkedList); override;
  138. { removes all items from the list, the items are not freed }
  139. procedure RemoveAll; override;
  140. end;
  141. TAsmCFI=class
  142. public
  143. constructor create;virtual;
  144. destructor destroy;override;
  145. procedure generate_code(list:TAsmList);virtual;
  146. procedure start_frame(list:TAsmList);virtual;
  147. procedure end_frame(list:TAsmList);virtual;
  148. procedure outmost_frame(list:TAsmList);virtual;
  149. procedure cfa_offset(list:TAsmList;reg:tregister;ofs:longint);virtual;
  150. procedure cfa_restore(list:TAsmList;reg:tregister);virtual;
  151. procedure cfa_def_cfa_register(list:TAsmList;reg:tregister);virtual;
  152. procedure cfa_def_cfa_offset(list:TAsmList;ofs:longint);virtual;
  153. end;
  154. TAsmCFIClass=class of TAsmCFI;
  155. { TAsmData }
  156. TAsmData = class
  157. private
  158. { Symbols }
  159. FAsmSymbolDict : TFPHashObjectList;
  160. FAltSymbolList : TFPObjectList;
  161. FNextAltNr : longint;
  162. FNextLabelNr : array[TAsmLabeltype] of longint;
  163. { Call Frame Information for stack unwinding}
  164. FAsmCFI : TAsmCFI;
  165. FConstPools : array[TConstPoolType] of THashSet;
  166. function GetConstPools(APoolType: TConstPoolType): THashSet;
  167. protected
  168. function DefineAsmSymbolByClassBase(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef; out wasdefined: boolean) : TAsmSymbol;
  169. public
  170. name : pshortstring; { owned by tmodule }
  171. NextVTEntryNr : longint;
  172. { Assembler lists }
  173. AsmLists : array[TAsmListType] of TAsmList;
  174. CurrAsmList : TAsmList;
  175. WideInits : TLinkedList;
  176. ResStrInits : TLinkedList;
  177. constructor create(n: pshortstring);
  178. destructor destroy;override;
  179. { asmsymbol }
  180. function DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol; virtual;
  181. function DefineAsmSymbol(const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol;
  182. function WeakRefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype) : TAsmSymbol;
  183. function RefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype;indirect:boolean=false) : TAsmSymbol;
  184. function GetAsmSymbol(const s : TSymStr) : TAsmSymbol;
  185. { create new assembler label }
  186. procedure getlabel(out l : TAsmLabel;alt:TAsmLabeltype);
  187. procedure getjumplabel(out l : TAsmLabel);
  188. procedure getglobaljumplabel(out l : TAsmLabel);
  189. procedure getaddrlabel(out l : TAsmLabel);
  190. { visible from outside current object }
  191. procedure getglobaldatalabel(out l : TAsmLabel);
  192. { visible only inside current object, but doesn't start with
  193. target_asm.label_prefix (treated the Darwin linker as the start of a
  194. dead-strippable data block) }
  195. procedure getstaticdatalabel(out l : TAsmLabel);
  196. { visible only inside the current object and does start with
  197. target_asm.label_prefix (not treated by the Darwin linker as the start
  198. of a dead-strippable data block, and references to such labels are
  199. also ignored to determine whether a data block should be live) }
  200. procedure getlocaldatalabel(out l : TAsmLabel);
  201. { generate an alternative (duplicate) symbol }
  202. procedure GenerateAltSymbol(p:TAsmSymbol);
  203. procedure ResetAltSymbols;
  204. property AsmSymbolDict:TFPHashObjectList read FAsmSymbolDict;
  205. property AsmCFI:TAsmCFI read FAsmCFI;
  206. { hash tables for reusing constant storage }
  207. property ConstPools[APoolType:TConstPoolType]: THashSet read GetConstPools;
  208. end;
  209. TAsmDataClass = class of TAsmData;
  210. TTCInitItem = class(TLinkedListItem)
  211. sym: tsym;
  212. offset: aint;
  213. datalabel: TAsmSymbol;
  214. datadef: TDef;
  215. constructor Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol; alabeldef: tdef);
  216. end;
  217. var
  218. casmdata: TAsmDataClass;
  219. var
  220. CAsmCFI : TAsmCFIClass;
  221. current_asmdata : TAsmData;
  222. implementation
  223. uses
  224. verbose,
  225. symconst,
  226. aasmtai;
  227. {$ifdef MEMDEBUG}
  228. var
  229. memasmsymbols,
  230. memasmcfi,
  231. memasmlists : TMemDebug;
  232. {$endif MEMDEBUG}
  233. {*****************************************************************************
  234. TAsmCFI
  235. *****************************************************************************}
  236. constructor TAsmCFI.create;
  237. begin
  238. end;
  239. destructor TAsmCFI.destroy;
  240. begin
  241. end;
  242. procedure TAsmCFI.generate_code(list:TAsmList);
  243. begin
  244. end;
  245. procedure TAsmCFI.start_frame(list:TAsmList);
  246. begin
  247. end;
  248. procedure TAsmCFI.end_frame(list:TAsmList);
  249. begin
  250. end;
  251. procedure TAsmCFI.outmost_frame(list: TAsmList);
  252. begin
  253. end;
  254. procedure TAsmCFI.cfa_offset(list:TAsmList;reg:tregister;ofs:longint);
  255. begin
  256. end;
  257. procedure TAsmCFI.cfa_restore(list:TAsmList;reg:tregister);
  258. begin
  259. end;
  260. procedure TAsmCFI.cfa_def_cfa_register(list:TAsmList;reg:tregister);
  261. begin
  262. end;
  263. procedure TAsmCFI.cfa_def_cfa_offset(list:TAsmList;ofs:longint);
  264. begin
  265. end;
  266. {*****************************************************************************
  267. TTCInitItem
  268. *****************************************************************************}
  269. constructor TTCInitItem.Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol; alabeldef: tdef);
  270. begin
  271. inherited Create;
  272. sym:=asym;
  273. offset:=aoffset;
  274. datalabel:=alabel;
  275. datadef:=alabeldef;
  276. end;
  277. {*****************************************************************************
  278. TAsmList
  279. *****************************************************************************}
  280. constructor TAsmList.create;
  281. begin
  282. inherited create;
  283. end;
  284. function TAsmList.getlasttaifilepos : pfileposinfo;
  285. var
  286. hp : tlinkedlistitem;
  287. begin
  288. getlasttaifilepos := nil;
  289. if assigned(last) then
  290. begin
  291. { find the last file information record }
  292. if not (tai(last).typ in SkipLineInfo) then
  293. getlasttaifilepos:=@tailineinfo(last).fileinfo
  294. else
  295. { go through list backwards to find the first entry
  296. with line information
  297. }
  298. begin
  299. hp:=tai(last);
  300. while assigned(hp) and (tai(hp).typ in SkipLineInfo) do
  301. hp:=hp.Previous;
  302. { found entry }
  303. if assigned(hp) then
  304. getlasttaifilepos:=@tailineinfo(hp).fileinfo
  305. end;
  306. end;
  307. end;
  308. procedure TAsmList.insertList(p : TLinkedList);
  309. begin
  310. inherited insertList(p);
  311. inc(section_count,TAsmList(p).section_count);
  312. TAsmList(p).section_count:=0;
  313. end;
  314. procedure TAsmList.insertListBefore(Item : TLinkedListItem; p : TLinkedList);
  315. begin
  316. inherited insertListBefore(Item,p);
  317. inc(section_count,TAsmList(p).section_count);
  318. TAsmList(p).section_count:=0;
  319. end;
  320. procedure TAsmList.insertListAfter(Item : TLinkedListItem; p : TLinkedList);
  321. begin
  322. inherited insertListAfter(Item,p);
  323. inc(section_count,TAsmList(p).section_count);
  324. TAsmList(p).section_count:=0;
  325. end;
  326. procedure TAsmList.concatList(p : TLinkedList);
  327. begin
  328. inherited concatList(p);
  329. inc(section_count,TAsmList(p).section_count);
  330. TAsmList(p).section_count:=0;
  331. end;
  332. procedure TAsmList.insertListcopy(p : TLinkedList);
  333. begin
  334. inherited insertListcopy(p);
  335. inc(section_count,TAsmList(p).section_count);
  336. end;
  337. procedure TAsmList.concatListcopy(p : TLinkedList);
  338. begin
  339. inherited concatListcopy(p);
  340. inc(section_count,TAsmList(p).section_count);
  341. end;
  342. procedure TAsmList.RemoveAll;
  343. begin
  344. inherited RemoveAll;
  345. section_count:=0;
  346. end;
  347. {****************************************************************************
  348. TAsmData
  349. ****************************************************************************}
  350. function TAsmData.GetConstPools(APoolType: TConstPoolType): THashSet;
  351. begin
  352. if FConstPools[APoolType] = nil then
  353. case APoolType of
  354. sp_ansistr: FConstPools[APoolType] := TTagHashSet.Create(64, True, False);
  355. else
  356. FConstPools[APoolType] := THashSet.Create(64, True, False);
  357. end;
  358. Result := FConstPools[APoolType];
  359. end;
  360. function TAsmData.DefineAsmSymbolByClassBase(symclass: TAsmSymbolClass; const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef; out wasdefined: boolean): TAsmSymbol;
  361. var
  362. hp : TAsmSymbol;
  363. namestr : TSymStr;
  364. begin
  365. { this difference is only necessary to determine whether we always need
  366. indirect references or not }
  367. if _typ in [AT_DATA_FORCEINDIRECT,AT_DATA_NOINDIRECT] then
  368. _typ:=AT_DATA;
  369. namestr:=s;
  370. if _bind in asmsymbindindirect then
  371. namestr:=namestr+suffix_indirect;
  372. hp:=TAsmSymbol(FAsmSymbolDict.Find(namestr));
  373. if assigned(hp) then
  374. begin
  375. { Redefine is allowed, but the types must be the same. The redefine
  376. is needed for Darwin where the labels are first allocated }
  377. wasdefined:=not(hp.bind in [AB_EXTERNAL,AB_WEAK_EXTERNAL]);
  378. if wasdefined then
  379. begin
  380. if (hp.bind<>_bind) and
  381. (hp.typ<>_typ) then
  382. internalerror(200603261);
  383. end;
  384. hp.typ:=_typ;
  385. { Changing bind from AB_GLOBAL to AB_LOCAL is wrong
  386. if bind is already AB_GLOBAL or AB_EXTERNAL,
  387. GOT might have been used, so change might be harmful. }
  388. if (_bind<>hp.bind) and (hp.getrefs>0) then
  389. begin
  390. {$ifdef extdebug}
  391. { the changes that matter must become internalerrors, the rest
  392. should be ignored; a used cannot change anything about this,
  393. so printing a warning/hint is not useful }
  394. if (_bind=AB_LOCAL) then
  395. Message3(asmw_w_changing_bind_type,namestr,asmsymbindname[hp.bind],asmsymbindname[_bind])
  396. else
  397. Message3(asmw_h_changing_bind_type,namestr,asmsymbindname[hp.bind],asmsymbindname[_bind]);
  398. {$endif extdebug}
  399. end;
  400. hp.bind:=_bind;
  401. end
  402. else
  403. begin
  404. wasdefined:=false;
  405. { Not found, insert it. }
  406. hp:=symclass.create(AsmSymbolDict,namestr,_bind,_typ);
  407. end;
  408. result:=hp;
  409. end;
  410. constructor TAsmData.create(n:pshortstring);
  411. var
  412. alt : TAsmLabelType;
  413. hal : TAsmListType;
  414. begin
  415. inherited create;
  416. name:=n;
  417. { symbols }
  418. FAsmSymbolDict:=TFPHashObjectList.create(true);
  419. FAltSymbolList:=TFPObjectList.Create(false);
  420. { labels }
  421. FNextAltNr:=1;
  422. for alt:=low(TAsmLabelType) to high(TAsmLabelType) do
  423. FNextLabelNr[alt]:=1;
  424. { AsmLists }
  425. CurrAsmList:=TAsmList.create;
  426. for hal:=low(TAsmListType) to high(TAsmListType) do
  427. AsmLists[hal]:=TAsmList.create;
  428. WideInits :=TAsmList.create;
  429. ResStrInits:=TAsmList.create;
  430. { CFI }
  431. FAsmCFI:=CAsmCFI.Create;
  432. end;
  433. destructor TAsmData.destroy;
  434. var
  435. hal : TAsmListType;
  436. hp : TConstPoolType;
  437. begin
  438. { Symbols }
  439. {$ifdef MEMDEBUG}
  440. memasmsymbols.start;
  441. {$endif}
  442. FAltSymbolList.free;
  443. FAsmSymbolDict.free;
  444. {$ifdef MEMDEBUG}
  445. memasmsymbols.stop;
  446. {$endif}
  447. { CFI }
  448. {$ifdef MEMDEBUG}
  449. memasmcfi.start;
  450. {$endif}
  451. FAsmCFI.free;
  452. {$ifdef MEMDEBUG}
  453. memasmcfi.stop;
  454. {$endif}
  455. { Lists }
  456. {$ifdef MEMDEBUG}
  457. memasmlists.start;
  458. {$endif}
  459. ResStrInits.free;
  460. WideInits.free;
  461. for hal:=low(TAsmListType) to high(TAsmListType) do
  462. AsmLists[hal].free;
  463. CurrAsmList.free;
  464. {$ifdef MEMDEBUG}
  465. memasmlists.stop;
  466. {$endif}
  467. for hp := low(TConstPoolType) to high(TConstPoolType) do
  468. FConstPools[hp].Free;
  469. end;
  470. function TAsmData.DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef): TAsmSymbol;
  471. var
  472. wasdefined: boolean;
  473. begin
  474. result:=DefineAsmSymbolByClassBase(symclass,s,_bind,_typ,def,wasdefined);
  475. end;
  476. function TAsmData.DefineAsmSymbol(const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef): TAsmSymbol;
  477. begin
  478. result:=DefineAsmSymbolByClass(TAsmSymbol,s,_bind,_typ,def);
  479. end;
  480. function TAsmData.RefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype;indirect:boolean) : TAsmSymbol;
  481. var
  482. namestr : TSymStr;
  483. bind : tasmsymbind;
  484. begin
  485. namestr:=s;
  486. if indirect then
  487. begin
  488. namestr:=namestr+suffix_indirect;
  489. bind:=AB_EXTERNAL_INDIRECT;
  490. end
  491. else
  492. begin
  493. bind:=AB_EXTERNAL;
  494. end;
  495. result:=TAsmSymbol(FAsmSymbolDict.Find(namestr));
  496. if not assigned(result) then
  497. result:=TAsmSymbol.create(AsmSymbolDict,namestr,bind,_typ)
  498. { one normal reference removes the "weak" character of a symbol }
  499. else if (result.bind=AB_WEAK_EXTERNAL) then
  500. result.bind:=bind;
  501. end;
  502. function TAsmData.WeakRefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype) : TAsmSymbol;
  503. begin
  504. result:=TAsmSymbol(FAsmSymbolDict.Find(s));
  505. if not assigned(result) then
  506. result:=TAsmSymbol.create(AsmSymbolDict,s,AB_WEAK_EXTERNAL,_typ);
  507. end;
  508. function TAsmData.GetAsmSymbol(const s : TSymStr) : TAsmSymbol;
  509. begin
  510. result:=TAsmSymbol(FAsmSymbolDict.Find(s));
  511. end;
  512. procedure TAsmData.GenerateAltSymbol(p:TAsmSymbol);
  513. begin
  514. if not assigned(p.altsymbol) then
  515. begin
  516. p.altsymbol:=p.getaltcopy(AsmSymbolDict,FNextAltNr);
  517. FAltSymbolList.Add(p);
  518. end;
  519. end;
  520. procedure TAsmData.ResetAltSymbols;
  521. var
  522. i : longint;
  523. begin
  524. for i:=0 to FAltSymbolList.Count-1 do
  525. TAsmSymbol(FAltSymbolList[i]).altsymbol:=nil;
  526. FAltSymbolList.Clear;
  527. end;
  528. procedure TAsmData.getlabel(out l : TAsmLabel;alt:TAsmLabeltype);
  529. begin
  530. if (target_info.system in (systems_linux + systems_bsd + systems_android)) and
  531. { the next condition was
  532. (cs_create_smart in current_settings.moduleswitches) and
  533. but if we create_smartlink_sections, this is useless }
  534. (create_smartlink_library) and
  535. (alt = alt_dbgline) then
  536. l:=TAsmLabel.createglobal(AsmSymbolDict,name^,FNextLabelNr[alt],alt)
  537. else
  538. l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt],alt);
  539. inc(FNextLabelNr[alt]);
  540. end;
  541. procedure TAsmData.getjumplabel(out l : TAsmLabel);
  542. begin
  543. l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt_jump],alt_jump);
  544. inc(FNextLabelNr[alt_jump]);
  545. end;
  546. procedure TAsmData.getglobaljumplabel(out l : TAsmLabel);
  547. begin
  548. l:=TAsmLabel.createglobal(AsmSymbolDict,name^,FNextLabelNr[alt_jump],alt_jump);
  549. inc(FNextLabelNr[alt_jump]);
  550. end;
  551. procedure TAsmData.getglobaldatalabel(out l : TAsmLabel);
  552. begin
  553. l:=TAsmLabel.createglobal(AsmSymbolDict,name^,FNextLabelNr[alt_data],alt_data);
  554. inc(FNextLabelNr[alt_data]);
  555. end;
  556. procedure TAsmData.getstaticdatalabel(out l : TAsmLabel);
  557. begin
  558. l:=TAsmLabel.createstatic(AsmSymbolDict,FNextLabelNr[alt_data],alt_data);
  559. inc(FNextLabelNr[alt_data]);
  560. end;
  561. procedure TAsmData.getlocaldatalabel(out l: TAsmLabel);
  562. begin
  563. l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt_data],alt_data);
  564. inc(FNextLabelNr[alt_data]);
  565. end;
  566. procedure TAsmData.getaddrlabel(out l : TAsmLabel);
  567. begin
  568. l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt_addr],alt_addr);
  569. inc(FNextLabelNr[alt_addr]);
  570. end;
  571. initialization
  572. {$ifdef MEMDEBUG}
  573. memasmsymbols:=TMemDebug.create('AsmSymbols');
  574. memasmsymbols.stop;
  575. memasmcfi:=TMemDebug.create('AsmCFI');
  576. memasmcfi.stop;
  577. memasmlists:=TMemDebug.create('AsmLists');
  578. memasmlists.stop;
  579. {$endif MEMDEBUG}
  580. if not(assigned(CAsmCFI)) then
  581. CAsmCFI:=TAsmCFI;
  582. finalization
  583. {$ifdef MEMDEBUG}
  584. memasmsymbols.free;
  585. memasmcfi.free;
  586. memasmlists.free;
  587. {$endif MEMDEBUG}
  588. end.