cfidwarf.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. {
  2. Copyright (c) 2003-2004 by Peter Vreman and Florian Klaempfl
  3. This units contains special support for DWARF debug info
  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. unit cfidwarf;
  18. {$i fpcdefs.inc}
  19. { $define debug_eh}
  20. interface
  21. uses
  22. cclasses,
  23. globtype,
  24. cgbase,cpubase,
  25. aasmbase,aasmcfi,aasmtai,aasmdata;
  26. const
  27. maxdwarfops = 2;
  28. type
  29. tdwarfoperenc=(doe_uleb,doe_sleb,doe_ptr,doe_32bit,doe_16bit,doe_8bit);
  30. tdwarfopertype=(dop_reg,dop_const,dop_sym,dop_reloffset);
  31. tdwarfoper=record
  32. enc : tdwarfoperenc;
  33. case typ:tdwarfopertype of
  34. dop_reg : (register:tregister);
  35. dop_const : (value:int64);
  36. dop_sym : (sym:tasmsymbol);
  37. dop_reloffset : (beginsym,endsym:tasmsymbol);
  38. end;
  39. tdwarfitem=class(TLinkedListItem)
  40. op : byte;
  41. ops : byte;
  42. oper : array[0..maxdwarfops-1] of tdwarfoper;
  43. constructor create(aop:byte);
  44. constructor create_reg(aop:byte;enc1:tdwarfoperenc;reg:tregister);
  45. constructor create_const(aop:byte;enc1:tdwarfoperenc;val:int64);
  46. constructor create_sym(aop: byte; enc1: tdwarfoperenc; sym: TAsmSymbol);
  47. constructor create_reloffset(aop:byte;enc1:tdwarfoperenc;beginlab,endlab:tasmsymbol);
  48. constructor create_reg_const(aop:byte;enc1:tdwarfoperenc;reg:tregister;enc2:tdwarfoperenc;val:longint);
  49. procedure generate_code(list:TAsmList);
  50. end;
  51. TDwarfAsmCFI=class(TAsmCFI)
  52. use_eh_frame : boolean;
  53. constructor create;override;
  54. end;
  55. TDwarfAsmCFILowLevel=class(TDwarfAsmCFI)
  56. private
  57. FDwarfList : TLinkedList;
  58. FFrameStartLabel,
  59. FFrameEndLabel,
  60. FLastloclabel : tasmlabel;
  61. procedure cfa_advance_loc(list:TAsmList);
  62. procedure generate_initial_instructions(list:TAsmList);virtual;
  63. protected
  64. code_alignment_factor,
  65. data_alignment_factor : shortint;
  66. property DwarfList:TlinkedList read FDwarfList;
  67. public
  68. constructor create;override;
  69. destructor destroy;override;
  70. procedure generate_code(list:TAsmList);override;
  71. function get_frame_start: TAsmLabel;override;
  72. function get_cfa_list : TAsmList;override;
  73. { operations }
  74. procedure start_frame(list:TAsmList);override;
  75. procedure end_frame(list:TAsmList);override;
  76. procedure outmost_frame(list: TAsmList);override;
  77. procedure cfa_offset(list:TAsmList;reg:tregister;ofs:longint);override;
  78. procedure cfa_restore(list:TAsmList;reg:tregister);override;
  79. procedure cfa_def_cfa_register(list:TAsmList;reg:tregister);override;
  80. procedure cfa_def_cfa_offset(list:TAsmList;ofs:longint);override;
  81. end;
  82. TDwarfAsmCFIHighLevel=class(TDwarfAsmCFILowLevel)
  83. public
  84. procedure generate_code(list:TAsmList);override;
  85. { operations }
  86. procedure start_frame(list:TAsmList);override;
  87. procedure end_frame(list:TAsmList);override;
  88. procedure outmost_frame(list: TAsmList);override;
  89. procedure cfa_offset(list:TAsmList;reg:tregister;ofs:longint);override;
  90. procedure cfa_restore(list:TAsmList;reg:tregister);override;
  91. procedure cfa_def_cfa_register(list:TAsmList;reg:tregister);override;
  92. procedure cfa_def_cfa_offset(list:TAsmList;ofs:longint);override;
  93. end;
  94. implementation
  95. uses
  96. systems,
  97. cutils,
  98. verbose,
  99. dwarfbase;
  100. {****************************************************************************
  101. TDWARFITEM
  102. ****************************************************************************}
  103. constructor tdwarfitem.create(aop:byte);
  104. begin
  105. inherited create;
  106. op:=aop;
  107. ops:=0;
  108. end;
  109. constructor tdwarfitem.create_reg(aop:byte;enc1:tdwarfoperenc;reg:tregister);
  110. begin
  111. inherited create;
  112. op:=aop;
  113. ops:=1;
  114. oper[0].typ:=dop_reg;
  115. oper[0].enc:=enc1;
  116. oper[0].register:=reg;
  117. end;
  118. constructor tdwarfitem.create_const(aop:byte;enc1:tdwarfoperenc;val:int64);
  119. begin
  120. inherited create;
  121. op:=aop;
  122. ops:=1;
  123. oper[0].typ:=dop_const;
  124. oper[0].enc:=enc1;
  125. oper[0].value:=val;
  126. end;
  127. constructor tdwarfitem.create_sym(aop:byte;enc1:tdwarfoperenc;sym:TAsmSymbol);
  128. begin
  129. inherited create;
  130. op:=aop;
  131. ops:=1;
  132. oper[0].typ:=dop_sym;
  133. oper[0].enc:=enc1;
  134. oper[0].sym:=sym;
  135. end;
  136. constructor tdwarfitem.create_reloffset(aop:byte;enc1:tdwarfoperenc;beginlab,endlab:tasmsymbol);
  137. begin
  138. inherited create;
  139. op:=aop;
  140. ops:=1;
  141. { relative offsets are passed }
  142. oper[0].typ:=dop_reloffset;
  143. oper[0].enc:=enc1;
  144. oper[0].beginsym:=beginlab;
  145. oper[0].endsym:=endlab;
  146. end;
  147. constructor tdwarfitem.create_reg_const(aop:byte;enc1:tdwarfoperenc;reg:tregister;enc2:tdwarfoperenc;val:longint);
  148. begin
  149. inherited create;
  150. op:=aop;
  151. ops:=2;
  152. oper[0].typ:=dop_reg;
  153. oper[0].enc:=enc1;
  154. oper[0].register:=reg;
  155. oper[1].typ:=dop_const;
  156. oper[1].enc:=enc2;
  157. oper[1].value:=val;
  158. end;
  159. procedure tdwarfitem.generate_code(list:TAsmList);
  160. const
  161. enc2ait_const : array[tdwarfoperenc] of taiconst_type = (
  162. aitconst_uleb128bit,aitconst_sleb128bit,aitconst_ptr,
  163. aitconst_32bit,aitconst_16bit,aitconst_8bit
  164. );
  165. var
  166. i : integer;
  167. begin
  168. list.concat(tai_const.create_8bit(op));
  169. for i:=0 to ops-1 do
  170. begin
  171. case oper[i].typ of
  172. dop_const :
  173. list.concat(tai_const.create(enc2ait_const[oper[i].enc],oper[i].value));
  174. dop_sym :
  175. begin
  176. if oper[i].enc<>doe_ptr then
  177. internalerror(200404127);
  178. list.concat(tai_const.create_sym(oper[i].sym));
  179. end;
  180. dop_reloffset :
  181. list.concat(tai_const.create_rel_sym(enc2ait_const[oper[i].enc],oper[i].beginsym,oper[i].endsym));
  182. dop_reg :
  183. list.concat(tai_const.create(enc2ait_const[oper[i].enc],dwarf_reg(oper[i].register)));
  184. end;
  185. end;
  186. end;
  187. {****************************************************************************
  188. TDwarfAsmCFI
  189. ****************************************************************************}
  190. constructor TDwarfAsmCFI.create;
  191. begin
  192. inherited;
  193. if tf_use_psabieh in target_info.flags then
  194. use_eh_frame:=true;
  195. end;
  196. {****************************************************************************
  197. TDwarfAsmCFILowLevel
  198. ****************************************************************************}
  199. constructor TDwarfAsmCFILowLevel.create;
  200. begin
  201. inherited create;
  202. FFrameStartLabel:=nil;
  203. FFrameEndLabel:=nil;
  204. FLastLocLabel:=nil;
  205. code_alignment_factor:=1;
  206. data_alignment_factor:=-4;
  207. FDwarfList:=TAsmList.Create;
  208. end;
  209. destructor TDwarfAsmCFILowLevel.destroy;
  210. begin
  211. FDwarfList.Free;
  212. end;
  213. {$if defined(i386)}
  214. { if more cpu dependend stuff is implemented, this needs more refactoring }
  215. procedure TDwarfAsmCFILowLevel.generate_initial_instructions(list:TAsmList);
  216. begin
  217. list.concat(tai_const.create_8bit(DW_CFA_def_cfa));
  218. list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_STACK_POINTER_REG)));
  219. list.concat(tai_const.create_uleb128bit(sizeof(aint)));
  220. list.concat(tai_const.create_8bit(DW_CFA_offset_extended));
  221. list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_RETURN_ADDRESS_REG)));
  222. list.concat(tai_const.create_uleb128bit((-sizeof(aint)) div data_alignment_factor));
  223. end;
  224. {$elseif defined(avr)}
  225. procedure TDwarfAsmCFILowLevel.generate_initial_instructions(list:TAsmList);
  226. begin
  227. list.concat(tai_const.create_8bit(DW_CFA_def_cfa));
  228. list.concat(tai_const.create_uleb128bit(32));
  229. list.concat(tai_const.create_uleb128bit(2));
  230. list.concat(tai_const.create_8bit(DW_CFA_offset_extended));
  231. list.concat(tai_const.create_uleb128bit(36));
  232. list.concat(tai_const.create_uleb128bit((-1) div data_alignment_factor));
  233. end;
  234. {$else}
  235. { if more cpu dependend stuff is implemented, this needs more refactoring }
  236. procedure TDwarfAsmCFILowLevel.generate_initial_instructions(list:TAsmList);
  237. begin
  238. list.concat(tai_const.create_8bit(DW_CFA_def_cfa));
  239. list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_STACK_POINTER_REG)));
  240. list.concat(tai_const.create_uleb128bit(sizeof(aint)));
  241. list.concat(tai_const.create_8bit(DW_CFA_offset_extended));
  242. list.concat(tai_const.create_uleb128bit(dwarf_reg(NR_RETURN_ADDRESS_REG)));
  243. list.concat(tai_const.create_uleb128bit((-sizeof(aint)) div data_alignment_factor));
  244. end;
  245. {$endif i386}
  246. procedure TDwarfAsmCFILowLevel.generate_code(list:TAsmList);
  247. var
  248. hp : tdwarfitem;
  249. CurrentLSDALabel,
  250. cielabel,
  251. lenstartlabel,
  252. lenendlabel,
  253. augendlabel,
  254. augstartlabel,
  255. fdeofslabel, curpos: tasmlabel;
  256. tc : tai_const;
  257. begin
  258. CurrentLSDALabel:=nil;
  259. if use_eh_frame then
  260. new_section(list,sec_eh_frame,'',0)
  261. else
  262. new_section(list,sec_debug_frame,'',0);
  263. { debug_frame:
  264. CIE
  265. DWORD length
  266. DWORD CIE_Id = 0xffffffff
  267. BYTE version = 1
  268. STRING augmentation = "" = BYTE 0
  269. ULEB128 code alignment factor = 1
  270. ULEB128 data alignment factor = -1
  271. BYTE return address register
  272. <...> augmentation
  273. <...> start sequence
  274. eh_frame:
  275. CIE
  276. DWORD length
  277. DWORD CIE_Id = 0
  278. BYTE version = 1
  279. STRING augmentation = 'zPLR'#0
  280. ULEB128 code alignment factor = 1
  281. ULEB128 data alignment factor = -1
  282. BYTE return address register
  283. <...> start sequence
  284. }
  285. current_asmdata.getlabel(cielabel,alt_dbgframe);
  286. list.concat(tai_label.create(cielabel));
  287. current_asmdata.getlabel(lenstartlabel,alt_dbgframe);
  288. current_asmdata.getlabel(lenendlabel,alt_dbgframe);
  289. list.concat(tai_const.create_rel_sym(aitconst_32bit,lenstartlabel,lenendlabel));
  290. list.concat(tai_label.create(lenstartlabel));
  291. if use_eh_frame then
  292. begin
  293. list.concat(tai_const.create_32bit(0));
  294. list.concat(tai_const.create_8bit(1));
  295. list.concat(tai_const.create_8bit(ord('z')));
  296. list.concat(tai_const.create_8bit(ord('P')));
  297. list.concat(tai_const.create_8bit(ord('L')));
  298. list.concat(tai_const.create_8bit(ord('R')));
  299. list.concat(tai_const.create_8bit(0));
  300. end
  301. else
  302. begin
  303. list.concat(tai_const.create_32bit(longint($ffffffff)));
  304. list.concat(tai_const.create_8bit(1));
  305. list.concat(tai_const.create_8bit(0)); { empty string }
  306. end;
  307. list.concat(tai_const.create_uleb128bit(code_alignment_factor));
  308. list.concat(tai_const.create_sleb128bit(data_alignment_factor));
  309. list.concat(tai_const.create_8bit(dwarf_reg(NR_RETURN_ADDRESS_REG)));
  310. { augmentation data }
  311. if use_eh_frame then
  312. begin
  313. current_asmdata.getlabel(augstartlabel,alt_dbgframe);
  314. current_asmdata.getlabel(augendlabel,alt_dbgframe);
  315. { size of augmentation data ('z') }
  316. list.concat(tai_const.create_rel_sym(aitconst_uleb128bit,augstartlabel,augendlabel));
  317. list.concat(tai_label.create(augstartlabel));
  318. { personality function ('P') }
  319. { encoding }
  320. list.concat(tai_const.create_8bit({DW_EH_PE_indirect or DW_EH_PE_pcrel or} DW_EH_PE_sdata4));
  321. { address of personality function }
  322. list.concat(tai_const.Createname('_FPC_psabieh_personality_v0',AT_FUNCTION,0));
  323. { LSDA encoding ('L')}
  324. list.concat(tai_const.create_8bit({DW_EH_PE_pcrel or }DW_EH_PE_sdata4));
  325. { FDE encoding ('R') }
  326. list.concat(tai_const.create_8bit({DW_EH_PE_pcrel or }DW_EH_PE_sdata4));
  327. list.concat(tai_label.create(augendlabel));
  328. end;
  329. { Generate standard code
  330. def_cfa(stackpointer,sizeof(aint))
  331. cfa_offset_extended(returnaddres,-sizeof(aint))
  332. }
  333. generate_initial_instructions(list);
  334. list.concat(cai_align.create_zeros(4));
  335. list.concat(tai_label.create(lenendlabel));
  336. lenstartlabel:=nil;
  337. lenendlabel:=nil;
  338. hp:=TDwarfItem(DwarfList.first);
  339. while assigned(hp) do
  340. begin
  341. case hp.op of
  342. DW_CFA_Start_Frame :
  343. begin
  344. if assigned(lenstartlabel) then
  345. internalerror(200404125);
  346. if (hp.ops<>1) or
  347. (hp.oper[0].typ<>dop_reloffset) then
  348. internalerror(200404126);
  349. current_asmdata.getlabel(lenstartlabel,alt_dbgframe);
  350. current_asmdata.getlabel(lenendlabel,alt_dbgframe);
  351. { FDE
  352. DWORD length
  353. DWORD CIE-pointer = cielabel relative to section start
  354. PTRSIZE initial location = oper[0]
  355. PTRSIZE function size = oper[1]
  356. }
  357. list.concat(tai_const.create_rel_sym(aitconst_32bit,lenstartlabel,lenendlabel));
  358. list.concat(tai_label.create(lenstartlabel));
  359. if use_eh_frame then
  360. begin
  361. { relative offset to the CIE }
  362. current_asmdata.getlabel(fdeofslabel,alt_dbgframe);
  363. list.concat(tai_label.create(fdeofslabel));
  364. list.concat(tai_const.create_rel_sym(aitconst_32bit,cielabel,fdeofslabel));
  365. end
  366. else
  367. begin
  368. tc:=tai_const.create_sym(cielabel);
  369. { force label offset to secrel32 for windows systems }
  370. if (target_info.system in systems_windows+systems_wince) then
  371. tc.consttype:=aitconst_secrel32_symbol;
  372. list.concat(tc);
  373. end;
  374. current_asmdata.getlabel(curpos,alt_dbgframe);
  375. list.concat(tai_label.create(curpos));
  376. list.concat(tai_const.Create_sym(hp.oper[0].beginsym));
  377. list.concat(tai_const.create_rel_sym(aitconst_ptr,hp.oper[0].beginsym,hp.oper[0].endsym));
  378. { we wrote a 'z' into the CIE augmentation data }
  379. if use_eh_frame then
  380. begin
  381. { size of augmentation }
  382. list.concat(tai_const.create_8bit(sizeof(pint)));
  383. {$ifdef debug_eh}
  384. list.concat(tai_comment.Create(strpnew('LSDA')));
  385. {$endif debug_eh}
  386. { address of LSDA}
  387. list.concat(tai_const.Create_sym(CurrentLSDALabel));
  388. { do not reuse LSDA label }
  389. CurrentLSDALabel:=nil;
  390. end;
  391. end;
  392. DW_CFA_End_Frame :
  393. begin
  394. list.concat(cai_align.create_zeros(4));
  395. list.concat(tai_label.create(lenendlabel));
  396. lenstartlabel:=nil;
  397. lenendlabel:=nil;
  398. end;
  399. DW_Set_LSDALabel:
  400. CurrentLSDALabel:=hp.oper[0].sym as TAsmLabel;
  401. else
  402. hp.generate_code(list);
  403. end;
  404. hp:=TDwarfItem(hp.next);
  405. end;
  406. { Check for open frames }
  407. if assigned(lenstartlabel) then
  408. internalerror(2004041210);
  409. { DwarfList is processed, remove items }
  410. DwarfList.Clear;
  411. end;
  412. procedure TDwarfAsmCFILowLevel.start_frame(list:TAsmList);
  413. begin
  414. current_asmdata.getlabel(FFrameEndLabel,alt_dbgframe);
  415. FLastloclabel:=get_frame_start;
  416. list.concat(tai_label.create(get_frame_start));
  417. DwarfList.concat(tdwarfitem.create_reloffset(DW_CFA_start_frame,doe_32bit,get_frame_start,FFrameEndLabel));
  418. end;
  419. function TDwarfAsmCFILowLevel.get_frame_start : TAsmLabel;
  420. begin
  421. if not(assigned(FFrameStartLabel)) then
  422. current_asmdata.getlabel(FFrameStartLabel,alt_dbgframe);
  423. Result:=FFrameStartLabel;
  424. end;
  425. function TDwarfAsmCFILowLevel.get_cfa_list: TAsmList;
  426. begin
  427. Result:=TAsmList(DwarfList);
  428. end;
  429. procedure TDwarfAsmCFILowLevel.outmost_frame(list: TAsmList);
  430. begin
  431. cfa_advance_loc(list);
  432. DwarfList.concat(tdwarfitem.create_reg(DW_CFA_undefined,doe_uleb,NR_RETURN_ADDRESS_REG));
  433. end;
  434. procedure TDwarfAsmCFILowLevel.end_frame(list:TAsmList);
  435. begin
  436. if not assigned(FFrameStartLabel) then
  437. internalerror(2004041213);
  438. DwarfList.concat(tdwarfitem.create(DW_CFA_end_frame));
  439. list.concat(tai_label.create(FFrameEndLabel));
  440. FFrameStartLabel:=nil;
  441. FFrameEndLabel:=nil;
  442. FLastLocLabel:=nil;
  443. end;
  444. procedure TDwarfAsmCFILowLevel.cfa_advance_loc(list:TAsmList);
  445. var
  446. currloclabel : tasmlabel;
  447. begin
  448. if FLastloclabel=nil then
  449. internalerror(200404082);
  450. current_asmdata.getlabel(currloclabel,alt_dbgframe);
  451. list.concat(tai_label.create(currloclabel));
  452. DwarfList.concat(tdwarfitem.create_reloffset(DW_CFA_advance_loc4,doe_32bit,FLastloclabel,currloclabel));
  453. FLastloclabel:=currloclabel;
  454. end;
  455. procedure TDwarfAsmCFILowLevel.cfa_offset(list:TAsmList;reg:tregister;ofs:longint);
  456. begin
  457. cfa_advance_loc(list);
  458. { TODO: check if ref is a temp}
  459. { offset must be positive }
  460. DwarfList.concat(tdwarfitem.create_reg_const(DW_CFA_offset_extended,doe_uleb,reg,doe_uleb,ofs div data_alignment_factor));
  461. end;
  462. procedure TDwarfAsmCFILowLevel.cfa_restore(list:TAsmList;reg:tregister);
  463. begin
  464. cfa_advance_loc(list);
  465. DwarfList.concat(tdwarfitem.create_reg(DW_CFA_restore_extended,doe_uleb,reg));
  466. end;
  467. procedure TDwarfAsmCFILowLevel.cfa_def_cfa_register(list:TAsmList;reg:tregister);
  468. begin
  469. cfa_advance_loc(list);
  470. DwarfList.concat(tdwarfitem.create_reg(DW_CFA_def_cfa_register,doe_uleb,reg));
  471. end;
  472. procedure TDwarfAsmCFILowLevel.cfa_def_cfa_offset(list:TAsmList;ofs:longint);
  473. begin
  474. cfa_advance_loc(list);
  475. DwarfList.concat(tdwarfitem.create_const(DW_CFA_def_cfa_offset,doe_uleb,ofs));
  476. end;
  477. {****************************************************************************
  478. TDwarfAsmCFILowLevel
  479. ****************************************************************************}
  480. procedure TDwarfAsmCFIHighLevel.generate_code(list: TAsmList);
  481. begin
  482. if not(tf_use_hlcfi in target_info.flags) then
  483. begin
  484. inherited;
  485. exit;
  486. end;
  487. end;
  488. procedure TDwarfAsmCFIHighLevel.start_frame(list: TAsmList);
  489. begin
  490. if not(tf_use_hlcfi in target_info.flags) then
  491. begin
  492. inherited;
  493. exit;
  494. end;
  495. list.concat(tai_cfi_op_none.create(cfi_startproc));
  496. end;
  497. procedure TDwarfAsmCFIHighLevel.end_frame(list: TAsmList);
  498. begin
  499. if not(tf_use_hlcfi in target_info.flags) then
  500. begin
  501. inherited;
  502. exit;
  503. end;
  504. list.concat(tai_cfi_op_none.create(cfi_endproc));
  505. end;
  506. procedure TDwarfAsmCFIHighLevel.outmost_frame(list: TAsmList);
  507. begin
  508. if not(tf_use_hlcfi in target_info.flags) then
  509. begin
  510. inherited;
  511. exit;
  512. end;
  513. list.concat(tai_cfi_op_reg.create(cfi_undefined,NR_RETURN_ADDRESS_REG));
  514. end;
  515. procedure TDwarfAsmCFIHighLevel.cfa_offset(list: TAsmList; reg: tregister; ofs: longint);
  516. begin
  517. if not(tf_use_hlcfi in target_info.flags) then
  518. begin
  519. inherited;
  520. exit;
  521. end;
  522. list.concat(tai_cfi_op_reg_val.create(cfi_offset,reg,ofs));
  523. end;
  524. procedure TDwarfAsmCFIHighLevel.cfa_restore(list: TAsmList; reg: tregister);
  525. begin
  526. if not(tf_use_hlcfi in target_info.flags) then
  527. begin
  528. inherited;
  529. exit;
  530. end;
  531. list.concat(tai_cfi_op_reg.create(cfi_restore,reg));
  532. end;
  533. procedure TDwarfAsmCFIHighLevel.cfa_def_cfa_register(list: TAsmList; reg: tregister);
  534. begin
  535. if not(tf_use_hlcfi in target_info.flags) then
  536. begin
  537. inherited;
  538. exit;
  539. end;
  540. list.concat(tai_cfi_op_reg.create(cfi_def_cfa_register,reg));
  541. end;
  542. procedure TDwarfAsmCFIHighLevel.cfa_def_cfa_offset(list: TAsmList; ofs: longint);
  543. begin
  544. if not(tf_use_hlcfi in target_info.flags) then
  545. begin
  546. inherited;
  547. exit;
  548. end;
  549. list.concat(tai_cfi_op_val.create(cfi_def_cfa_offset,ofs));
  550. end;
  551. begin
  552. CAsmCFI:=TDwarfAsmCFIHighLevel;
  553. end.