aasmdata.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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. function get_frame_start: TAsmLabel;virtual;
  154. function get_cfa_list : TAsmList;virtual;
  155. end;
  156. TAsmCFIClass=class of TAsmCFI;
  157. { TAsmData }
  158. TAsmData = class
  159. private
  160. { Symbols }
  161. FAsmSymbolDict : TFPHashObjectList;
  162. FAltSymbolList : TFPObjectList;
  163. FNextAltNr : longint;
  164. FNextLabelNr : array[TAsmLabeltype] of longint;
  165. { Call Frame Information for stack unwinding}
  166. FAsmCFI : TAsmCFI;
  167. FConstPools : array[TConstPoolType] of THashSet;
  168. function GetConstPools(APoolType: TConstPoolType): THashSet;
  169. protected
  170. function DefineAsmSymbolByClassBase(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef; out wasdefined: boolean) : TAsmSymbol;
  171. public
  172. name : pshortstring; { owned by tmodule }
  173. NextVTEntryNr : longint;
  174. { Assembler lists }
  175. AsmLists : array[TAsmListType] of TAsmList;
  176. CurrAsmList : TAsmList;
  177. WideInits : TLinkedList;
  178. ResStrInits : TLinkedList;
  179. constructor create(n: pshortstring);
  180. destructor destroy;override;
  181. { asmsymbol }
  182. function DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol; virtual;
  183. function DefineAsmSymbol(const s : TSymStr;_bind:TAsmSymBind;_typ:Tasmsymtype; def: tdef) : TAsmSymbol;
  184. function WeakRefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype) : TAsmSymbol;
  185. function RefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype;indirect:boolean=false) : TAsmSymbol;
  186. function GetAsmSymbol(const s : TSymStr) : TAsmSymbol;
  187. { create new assembler label }
  188. procedure getlabel(out l : TAsmLabel;alt:TAsmLabeltype);
  189. procedure getjumplabel(out l : TAsmLabel);
  190. procedure getglobaljumplabel(out l : TAsmLabel);
  191. procedure getaddrlabel(out l : TAsmLabel);
  192. { visible from outside current object }
  193. procedure getglobaldatalabel(out l : TAsmLabel);
  194. { visible only inside current object, but doesn't start with
  195. target_asm.label_prefix (treated the Darwin linker as the start of a
  196. dead-strippable data block) }
  197. procedure getstaticdatalabel(out l : TAsmLabel);
  198. { visible only inside the current object and does start with
  199. target_asm.label_prefix (not treated by the Darwin linker as the start
  200. of a dead-strippable data block, and references to such labels are
  201. also ignored to determine whether a data block should be live) }
  202. procedure getlocaldatalabel(out l : TAsmLabel);
  203. { generate an alternative (duplicate) symbol }
  204. procedure GenerateAltSymbol(p:TAsmSymbol);
  205. procedure ResetAltSymbols;
  206. property AsmSymbolDict:TFPHashObjectList read FAsmSymbolDict;
  207. property AsmCFI:TAsmCFI read FAsmCFI;
  208. { hash tables for reusing constant storage }
  209. property ConstPools[APoolType:TConstPoolType]: THashSet read GetConstPools;
  210. end;
  211. TAsmDataClass = class of TAsmData;
  212. TTCInitItem = class(TLinkedListItem)
  213. sym: tsym;
  214. offset: aint;
  215. datalabel: TAsmSymbol;
  216. datadef: TDef;
  217. constructor Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol; alabeldef: tdef);
  218. end;
  219. var
  220. casmdata: TAsmDataClass;
  221. var
  222. CAsmCFI : TAsmCFIClass;
  223. current_asmdata : TAsmData;
  224. implementation
  225. uses
  226. verbose,
  227. symconst,
  228. aasmtai;
  229. {$ifdef MEMDEBUG}
  230. var
  231. memasmsymbols,
  232. memasmcfi,
  233. memasmlists : TMemDebug;
  234. {$endif MEMDEBUG}
  235. {*****************************************************************************
  236. TAsmCFI
  237. *****************************************************************************}
  238. constructor TAsmCFI.create;
  239. begin
  240. end;
  241. destructor TAsmCFI.destroy;
  242. begin
  243. end;
  244. procedure TAsmCFI.generate_code(list:TAsmList);
  245. begin
  246. end;
  247. procedure TAsmCFI.start_frame(list:TAsmList);
  248. begin
  249. end;
  250. procedure TAsmCFI.end_frame(list:TAsmList);
  251. begin
  252. end;
  253. procedure TAsmCFI.outmost_frame(list: TAsmList);
  254. begin
  255. end;
  256. procedure TAsmCFI.cfa_offset(list:TAsmList;reg:tregister;ofs:longint);
  257. begin
  258. end;
  259. procedure TAsmCFI.cfa_restore(list:TAsmList;reg:tregister);
  260. begin
  261. end;
  262. procedure TAsmCFI.cfa_def_cfa_register(list:TAsmList;reg:tregister);
  263. begin
  264. end;
  265. procedure TAsmCFI.cfa_def_cfa_offset(list:TAsmList;ofs:longint);
  266. begin
  267. end;
  268. function TAsmCFI.get_frame_start: TAsmLabel;
  269. begin
  270. Result:=nil;
  271. end;
  272. function TAsmCFI.get_cfa_list: TAsmList;
  273. begin
  274. Result:=nil;
  275. end;
  276. {*****************************************************************************
  277. TTCInitItem
  278. *****************************************************************************}
  279. constructor TTCInitItem.Create(asym: tsym; aoffset: aint; alabel: TAsmSymbol; alabeldef: tdef);
  280. begin
  281. inherited Create;
  282. sym:=asym;
  283. offset:=aoffset;
  284. datalabel:=alabel;
  285. datadef:=alabeldef;
  286. end;
  287. {*****************************************************************************
  288. TAsmList
  289. *****************************************************************************}
  290. constructor TAsmList.create;
  291. begin
  292. inherited create;
  293. end;
  294. function TAsmList.getlasttaifilepos : pfileposinfo;
  295. var
  296. hp : tlinkedlistitem;
  297. begin
  298. getlasttaifilepos := nil;
  299. if assigned(last) then
  300. begin
  301. { find the last file information record }
  302. if not (tai(last).typ in SkipLineInfo) then
  303. getlasttaifilepos:=@tailineinfo(last).fileinfo
  304. else
  305. { go through list backwards to find the first entry
  306. with line information
  307. }
  308. begin
  309. hp:=tai(last);
  310. while assigned(hp) and (tai(hp).typ in SkipLineInfo) do
  311. hp:=hp.Previous;
  312. { found entry }
  313. if assigned(hp) then
  314. getlasttaifilepos:=@tailineinfo(hp).fileinfo
  315. end;
  316. end;
  317. end;
  318. procedure TAsmList.insertList(p : TLinkedList);
  319. begin
  320. inherited insertList(p);
  321. inc(section_count,TAsmList(p).section_count);
  322. TAsmList(p).section_count:=0;
  323. end;
  324. procedure TAsmList.insertListBefore(Item : TLinkedListItem; p : TLinkedList);
  325. begin
  326. inherited insertListBefore(Item,p);
  327. inc(section_count,TAsmList(p).section_count);
  328. TAsmList(p).section_count:=0;
  329. end;
  330. procedure TAsmList.insertListAfter(Item : TLinkedListItem; p : TLinkedList);
  331. begin
  332. inherited insertListAfter(Item,p);
  333. inc(section_count,TAsmList(p).section_count);
  334. TAsmList(p).section_count:=0;
  335. end;
  336. procedure TAsmList.concatList(p : TLinkedList);
  337. begin
  338. inherited concatList(p);
  339. inc(section_count,TAsmList(p).section_count);
  340. TAsmList(p).section_count:=0;
  341. end;
  342. procedure TAsmList.insertListcopy(p : TLinkedList);
  343. begin
  344. inherited insertListcopy(p);
  345. inc(section_count,TAsmList(p).section_count);
  346. end;
  347. procedure TAsmList.concatListcopy(p : TLinkedList);
  348. begin
  349. inherited concatListcopy(p);
  350. inc(section_count,TAsmList(p).section_count);
  351. end;
  352. procedure TAsmList.RemoveAll;
  353. begin
  354. inherited RemoveAll;
  355. section_count:=0;
  356. end;
  357. {****************************************************************************
  358. TAsmData
  359. ****************************************************************************}
  360. function TAsmData.GetConstPools(APoolType: TConstPoolType): THashSet;
  361. begin
  362. if FConstPools[APoolType] = nil then
  363. case APoolType of
  364. sp_ansistr: FConstPools[APoolType] := TTagHashSet.Create(64, True, False);
  365. else
  366. FConstPools[APoolType] := THashSet.Create(64, True, False);
  367. end;
  368. Result := FConstPools[APoolType];
  369. end;
  370. function TAsmData.DefineAsmSymbolByClassBase(symclass: TAsmSymbolClass; const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef; out wasdefined: boolean): TAsmSymbol;
  371. var
  372. hp : TAsmSymbol;
  373. namestr : TSymStr;
  374. begin
  375. { this difference is only necessary to determine whether we always need
  376. indirect references or not }
  377. if _typ in [AT_DATA_FORCEINDIRECT,AT_DATA_NOINDIRECT] then
  378. _typ:=AT_DATA;
  379. namestr:=s;
  380. if _bind in asmsymbindindirect then
  381. namestr:=namestr+suffix_indirect;
  382. hp:=TAsmSymbol(FAsmSymbolDict.Find(namestr));
  383. if assigned(hp) then
  384. begin
  385. { Redefine is allowed, but the types must be the same. The redefine
  386. is needed for Darwin where the labels are first allocated }
  387. wasdefined:=not(hp.bind in [AB_EXTERNAL,AB_WEAK_EXTERNAL]);
  388. if wasdefined then
  389. begin
  390. if (hp.bind<>_bind) and
  391. (hp.typ<>_typ) then
  392. internalerror(200603261);
  393. end;
  394. hp.typ:=_typ;
  395. { Changing bind from AB_GLOBAL to AB_LOCAL is wrong
  396. if bind is already AB_GLOBAL or AB_EXTERNAL,
  397. GOT might have been used, so change might be harmful. }
  398. if (_bind<>hp.bind) and (hp.getrefs>0) then
  399. begin
  400. {$ifdef extdebug}
  401. { the changes that matter must become internalerrors, the rest
  402. should be ignored; a used cannot change anything about this,
  403. so printing a warning/hint is not useful }
  404. if (_bind=AB_LOCAL) then
  405. Message3(asmw_w_changing_bind_type,namestr,asmsymbindname[hp.bind],asmsymbindname[_bind])
  406. else
  407. Message3(asmw_h_changing_bind_type,namestr,asmsymbindname[hp.bind],asmsymbindname[_bind]);
  408. {$endif extdebug}
  409. end;
  410. hp.bind:=_bind;
  411. end
  412. else
  413. begin
  414. wasdefined:=false;
  415. { Not found, insert it. }
  416. hp:=symclass.create(AsmSymbolDict,namestr,_bind,_typ);
  417. end;
  418. result:=hp;
  419. end;
  420. constructor TAsmData.create(n:pshortstring);
  421. var
  422. alt : TAsmLabelType;
  423. hal : TAsmListType;
  424. begin
  425. inherited create;
  426. name:=n;
  427. { symbols }
  428. FAsmSymbolDict:=TFPHashObjectList.create(true);
  429. FAltSymbolList:=TFPObjectList.Create(false);
  430. { labels }
  431. FNextAltNr:=1;
  432. for alt:=low(TAsmLabelType) to high(TAsmLabelType) do
  433. FNextLabelNr[alt]:=1;
  434. { AsmLists }
  435. CurrAsmList:=TAsmList.create;
  436. for hal:=low(TAsmListType) to high(TAsmListType) do
  437. AsmLists[hal]:=TAsmList.create;
  438. WideInits :=TAsmList.create;
  439. ResStrInits:=TAsmList.create;
  440. { CFI }
  441. FAsmCFI:=CAsmCFI.Create;
  442. end;
  443. destructor TAsmData.destroy;
  444. var
  445. hal : TAsmListType;
  446. hp : TConstPoolType;
  447. begin
  448. { Symbols }
  449. {$ifdef MEMDEBUG}
  450. memasmsymbols.start;
  451. {$endif}
  452. FAltSymbolList.free;
  453. FAsmSymbolDict.free;
  454. {$ifdef MEMDEBUG}
  455. memasmsymbols.stop;
  456. {$endif}
  457. { CFI }
  458. {$ifdef MEMDEBUG}
  459. memasmcfi.start;
  460. {$endif}
  461. FAsmCFI.free;
  462. {$ifdef MEMDEBUG}
  463. memasmcfi.stop;
  464. {$endif}
  465. { Lists }
  466. {$ifdef MEMDEBUG}
  467. memasmlists.start;
  468. {$endif}
  469. ResStrInits.free;
  470. WideInits.free;
  471. for hal:=low(TAsmListType) to high(TAsmListType) do
  472. AsmLists[hal].free;
  473. CurrAsmList.free;
  474. {$ifdef MEMDEBUG}
  475. memasmlists.stop;
  476. {$endif}
  477. for hp := low(TConstPoolType) to high(TConstPoolType) do
  478. FConstPools[hp].Free;
  479. end;
  480. function TAsmData.DefineAsmSymbolByClass(symclass: TAsmSymbolClass; const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef): TAsmSymbol;
  481. var
  482. wasdefined: boolean;
  483. begin
  484. result:=DefineAsmSymbolByClassBase(symclass,s,_bind,_typ,def,wasdefined);
  485. end;
  486. function TAsmData.DefineAsmSymbol(const s: TSymStr; _bind: TAsmSymBind; _typ: Tasmsymtype; def: tdef): TAsmSymbol;
  487. begin
  488. result:=DefineAsmSymbolByClass(TAsmSymbol,s,_bind,_typ,def);
  489. end;
  490. function TAsmData.RefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype;indirect:boolean) : TAsmSymbol;
  491. var
  492. namestr : TSymStr;
  493. bind : tasmsymbind;
  494. begin
  495. namestr:=s;
  496. if indirect then
  497. begin
  498. namestr:=namestr+suffix_indirect;
  499. bind:=AB_EXTERNAL_INDIRECT;
  500. end
  501. else
  502. begin
  503. bind:=AB_EXTERNAL;
  504. end;
  505. result:=TAsmSymbol(FAsmSymbolDict.Find(namestr));
  506. if not assigned(result) then
  507. result:=TAsmSymbol.create(AsmSymbolDict,namestr,bind,_typ)
  508. { one normal reference removes the "weak" character of a symbol }
  509. else if (result.bind=AB_WEAK_EXTERNAL) then
  510. result.bind:=bind;
  511. end;
  512. function TAsmData.WeakRefAsmSymbol(const s : TSymStr;_typ:Tasmsymtype) : TAsmSymbol;
  513. begin
  514. result:=TAsmSymbol(FAsmSymbolDict.Find(s));
  515. if not assigned(result) then
  516. result:=TAsmSymbol.create(AsmSymbolDict,s,AB_WEAK_EXTERNAL,_typ);
  517. end;
  518. function TAsmData.GetAsmSymbol(const s : TSymStr) : TAsmSymbol;
  519. begin
  520. result:=TAsmSymbol(FAsmSymbolDict.Find(s));
  521. end;
  522. procedure TAsmData.GenerateAltSymbol(p:TAsmSymbol);
  523. begin
  524. if not assigned(p.altsymbol) then
  525. begin
  526. p.altsymbol:=p.getaltcopy(AsmSymbolDict,FNextAltNr);
  527. FAltSymbolList.Add(p);
  528. end;
  529. end;
  530. procedure TAsmData.ResetAltSymbols;
  531. var
  532. i : longint;
  533. begin
  534. for i:=0 to FAltSymbolList.Count-1 do
  535. TAsmSymbol(FAltSymbolList[i]).altsymbol:=nil;
  536. FAltSymbolList.Clear;
  537. end;
  538. procedure TAsmData.getlabel(out l : TAsmLabel;alt:TAsmLabeltype);
  539. begin
  540. if (target_info.system in (systems_linux + systems_bsd + systems_android)) and
  541. { the next condition was
  542. (cs_create_smart in current_settings.moduleswitches) and
  543. but if we create_smartlink_sections, this is useless }
  544. (create_smartlink_library) and
  545. (alt = alt_dbgline) then
  546. l:=TAsmLabel.createglobal(AsmSymbolDict,name^,FNextLabelNr[alt],alt)
  547. else
  548. l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt],alt);
  549. inc(FNextLabelNr[alt]);
  550. end;
  551. procedure TAsmData.getjumplabel(out l : TAsmLabel);
  552. begin
  553. l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt_jump],alt_jump);
  554. inc(FNextLabelNr[alt_jump]);
  555. end;
  556. procedure TAsmData.getglobaljumplabel(out l : TAsmLabel);
  557. begin
  558. l:=TAsmLabel.createglobal(AsmSymbolDict,name^,FNextLabelNr[alt_jump],alt_jump);
  559. inc(FNextLabelNr[alt_jump]);
  560. end;
  561. procedure TAsmData.getglobaldatalabel(out l : TAsmLabel);
  562. begin
  563. l:=TAsmLabel.createglobal(AsmSymbolDict,name^,FNextLabelNr[alt_data],alt_data);
  564. inc(FNextLabelNr[alt_data]);
  565. end;
  566. procedure TAsmData.getstaticdatalabel(out l : TAsmLabel);
  567. begin
  568. l:=TAsmLabel.createstatic(AsmSymbolDict,FNextLabelNr[alt_data],alt_data);
  569. inc(FNextLabelNr[alt_data]);
  570. end;
  571. procedure TAsmData.getlocaldatalabel(out l: TAsmLabel);
  572. begin
  573. l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt_data],alt_data);
  574. inc(FNextLabelNr[alt_data]);
  575. end;
  576. procedure TAsmData.getaddrlabel(out l : TAsmLabel);
  577. begin
  578. l:=TAsmLabel.createlocal(AsmSymbolDict,FNextLabelNr[alt_addr],alt_addr);
  579. inc(FNextLabelNr[alt_addr]);
  580. end;
  581. initialization
  582. {$ifdef MEMDEBUG}
  583. memasmsymbols:=TMemDebug.create('AsmSymbols');
  584. memasmsymbols.stop;
  585. memasmcfi:=TMemDebug.create('AsmCFI');
  586. memasmcfi.stop;
  587. memasmlists:=TMemDebug.create('AsmLists');
  588. memasmlists.stop;
  589. {$endif MEMDEBUG}
  590. if not(assigned(CAsmCFI)) then
  591. CAsmCFI:=TAsmCFI;
  592. finalization
  593. {$ifdef MEMDEBUG}
  594. memasmsymbols.free;
  595. memasmcfi.free;
  596. memasmlists.free;
  597. {$endif MEMDEBUG}
  598. end.