agas.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. {
  2. $Id$
  3. Copyright (c) 1997 by Florian Klaempfl
  4. This unit implements an asm for the PowerPC
  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 agas;
  19. interface
  20. uses
  21. dos,globals,systems,errors,cobjects,aasm,alpha,strings,files
  22. {$ifdef GDB}
  23. ,gdb
  24. {$endif GDB}
  25. ;
  26. type
  27. palphaattasmlist=^talphaattasmlist;
  28. talphaattasmlist=object(tasmlist)
  29. procedure WriteTree(p:paasmoutput);virtual;
  30. procedure WriteAsmList;virtual;
  31. {$ifdef GDB}
  32. procedure WriteFileLineInfo(var fileinfo : tfileposinfo);
  33. {$endif}
  34. end;
  35. implementation
  36. const
  37. op2str : array[tasmop] of string[14] = ('<none>',
  38. 'add','add_','addo','addo_','addc','addc_','addco','addco_,
  39. 'adde','adde_','addeo','addeo_','addi','addic','addic_','addis,
  40. 'addme','addme_','addmeo','addmeo_','addze','addze_','addzeo,
  41. 'addzeo_','and','and_','andc','andc_','andi_','andis_','b,
  42. 'ba','bl','bla','bc','bca','bcl','bcla','bcctr','bcctrl','bclr,
  43. 'bclrl','cmp','cmpi','cmpl','cmpli','cntlzw','cntlzw_','crand,
  44. 'crandc','creqv','crnand','crnor','cror','crorc','crxor','dcba,
  45. 'dcbf','dcbi','dcbst','dcbt','divw','divw_','divwo','divwo_,
  46. 'divwu','divwu_','divwuo','divwuo_','eciwx','ecowx','eieio','eqv,
  47. 'eqv_','extsb','extsb_','extsh','extsh_','fabs','fabs_','fadd,
  48. 'fadd_','fadds','fadds_','fcompo','fcmpu','fctiw','fctw_','fctwz,
  49. 'fctwz_','fdiv','fdiv_','fdivs','fdivs_','fmadd','fmadd_','fmadds,
  50. 'fmadds_','fmr','fmsub','fmsub_','fmsubs','fmsubs_','fmul','fmul_,
  51. 'fmuls','fmuls_','fnabs','fnabs_','fneg','fneg_','fnmadd,
  52. 'fnmadd_','fnmadds','fnmadds_','fnmsub','fnmsub_','fnmsubs,
  53. 'fnmsubs_','fres','fres_','frsp','frsp_','frsqrte','frsqrte_,
  54. 'fsel','fsel_','fsqrt','fsqrt_','fsqrts','fsqrts_','fsub','fsub_,
  55. 'fsubs','fsubs_','icbi','isync','lbz','lbzu','lbzux','lbzx,
  56. 'lfd','lfdu','lfdux','lfdx','lfs','lfsu','lfsux','lfsx','lha,
  57. 'lhau','lhaux','lhax','hbrx','lhz','lhzu','lhzux','lhzx','lmw,
  58. 'lswi','lswx','lwarx','lwbrx','lwz','lwzu','lwzux','lwzx','mcrf,
  59. 'mcrfs','lcrxe','mfcr','mffs','maffs_','mfmsr','mfspr','mfsr,
  60. 'mfsrin','mftb','mtfcrf','mtfd0','mtfsb1','mtfsf','mtfsf_,
  61. 'mtfsfi','mtfsfi_','mtmsr','mtspr','mtsr','mtsrin','mulhw,
  62. 'mulhw_','mulhwu','mulhwu_','mulli','mullh','mullw_','mullwo,
  63. 'mullwo_','nand','nand_','neg','neg_','nego','nego_','nor','nor_,
  64. 'or','or_','orc','orc_','ori','oris', 'rfi', 'rlwimi', 'rlwimi_',
  65. 'rlwinm', 'tlwinm_','rlwnm','sc','slw', 'slw_', 'sraw', 'sraw_,
  66. 'srawi', 'srawi_','srw', 'srw_', 'stb', 'stbu', 'stbux','stbx','stfd',
  67. 'stfdu', 'stfdux', 'stfdx', 'stfiwx', 'stfs', 'stfsu', 'stfsux', 'stfsx',
  68. 'sth', 'sthbrx', 'sthu', 'sthux', 'sthx', 'stmw', 'stswi', 'stswx', 'stw',
  69. 'stwbrx', 'stwx_', 'stwu', 'stwux', 'stwx', 'subf', 'subf_', 'subfo',
  70. 'subfo_', 'subfc', 'subc_', 'subfco', 'subfco_', 'subfe', 'subfe_',
  71. 'subfeo', 'subfeo_', 'subfic', 'subfme', 'subfme_', 'subfmeo', 'subfmeo_,
  72. 'subfze', 'subfze_', 'subfzeo', 'subfzeo_', 'sync', 'tlbia', 'tlbie,
  73. 'tlbsync', 'tw', 'twi', 'xor', 'xor_', 'xori', 'xoris',
  74. { some simplified mnemonics }
  75. 'subi', 'subis', 'subic', 'subic_', 'sub', 'sub_', 'subo', 'subo_',
  76. 'subc', 'subc_', 'subco', '_subco_', 'cmpwi', 'cmpw', 'cmplwi', 'cmplw',
  77. 'extlwi', 'extlwi_', 'extrwi', 'extrwi_', 'inslwi', 'inslwi_', 'insrwi',
  78. 'insrwi_', 'rotlwi', 'rotlwi_', 'rotlw', 'rotlw_', 'slwi', 'slwi_',
  79. 'srwi', 'srwi_', 'clrlwi', 'clrlwi_', 'clrrwi', 'clrrwi_', 'clrslwi',
  80. 'clrslwi_', 'blr', 'bctr', 'blrl', 'bctrl', 'crset', 'crclr', 'crmove',
  81. 'crnot', 'mt', 'mf','nop', 'li', 'la', 'mr','not', 'mtcr');
  82. {$ifdef GDB}
  83. procedure talphaattasmlist.WriteFileLineInfo(var fileinfo : tfileposinfo);
  84. var
  85. curr_n : byte;
  86. begin
  87. if not (cs_debuginfo in aktmoduleswitches) then
  88. exit;
  89. { file changed ? (must be before line info) }
  90. if (fileinfo.fileindex<>0) and
  91. (stabslastfileinfo.fileindex<>fileinfo.fileindex) then
  92. begin
  93. infile:=current_module^.sourcefiles^.get_file(fileinfo.fileindex);
  94. if includecount=0 then
  95. curr_n:=n_sourcefile
  96. else
  97. curr_n:=n_includefile;
  98. if (infile^.path^<>'') then
  99. begin
  100. AsmWriteLn(#9'.stabs "'+lower(BsToSlash(FixPath(infile^.path^,false)))+'",'+
  101. tostr(curr_n)+',0,0,'+'Ltext'+ToStr(IncludeCount));
  102. end;
  103. AsmWriteLn(#9'.stabs "'+lower(FixFileName(infile^.name^))+'",'+
  104. tostr(curr_n)+',0,0,'+'Ltext'+ToStr(IncludeCount));
  105. AsmWriteLn('Ltext'+ToStr(IncludeCount)+':');
  106. inc(includecount);
  107. end;
  108. { line changed ? }
  109. if (stabslastfileinfo.line<>fileinfo.line) and (fileinfo.line<>0) then
  110. begin
  111. if (n_line=n_textline) and assigned(funcname) and
  112. (target_os.use_function_relative_addresses) then
  113. begin
  114. AsmWriteLn(target_asm.labelprefix+'l'+tostr(linecount)+':');
  115. AsmWrite(#9'.stabn '+tostr(n_line)+',0,'+tostr(fileinfo.line)+','+
  116. target_asm.labelprefix+'l'+tostr(linecount)+' - ');
  117. AsmWritePChar(FuncName);
  118. AsmLn;
  119. inc(linecount);
  120. end
  121. else
  122. AsmWriteLn(#9'.stabd'#9+tostr(n_line)+',0,'+tostr(fileinfo.line));
  123. end;
  124. stabslastfileinfo:=fileinfo;
  125. end;
  126. {$endif GDB}
  127. procedure talphaattasmlist.WriteTree(p:paasmoutput);
  128. const
  129. allocstr : array[boolean] of string[10]=(' released',' allocated');
  130. type
  131. t64bitarray = array[0..7] of byte;
  132. t32bitarray = array[0..3] of byte;
  133. var
  134. ch : char;
  135. hp : pai;
  136. consttyp : tait;
  137. s : string;
  138. found : boolean;
  139. i,pos,l : longint;
  140. co : comp;
  141. sin : single;
  142. d : double;
  143. e : extended;
  144. op : tasmop;
  145. calljmp,
  146. do_line : boolean;
  147. sep : char;
  148. begin
  149. if not assigned(p) then
  150. exit;
  151. do_line:=(cs_debuginfo in aktmoduleswitches) or (cs_asm_source in aktglobalswitches);
  152. hp:=pai(p^.first);
  153. while assigned(hp) do
  154. begin
  155. aktfilepos:=hp^.fileinfo;
  156. if do_line then
  157. begin
  158. { I think it is better to write stabs before source line PM }
  159. {$ifdef GDB}
  160. { write stabs }
  161. if cs_debuginfo in aktmoduleswitches then
  162. begin
  163. if not (hp^.typ in [
  164. ait_label,
  165. ait_regalloc,ait_tempalloc,
  166. ait_stabn,ait_stabs,ait_section,
  167. ait_cut,ait_marker,ait_align,ait_stab_function_name]) then
  168. begin
  169. WriteFileLineInfo(hp^.fileinfo);
  170. end;
  171. end;
  172. {$endif GDB}
  173. { load infile }
  174. if lastfileinfo.fileindex<>hp^.fileinfo.fileindex then
  175. begin
  176. infile:=current_module^.sourcefiles^.get_file(hp^.fileinfo.fileindex);
  177. { open only if needed !! }
  178. if (cs_asm_source in aktglobalswitches) then
  179. infile^.open;
  180. { avoid unnecessary reopens of the same file !! }
  181. lastfileinfo.fileindex:=hp^.fileinfo.fileindex;
  182. { be sure to change line !! }
  183. lastfileinfo.line:=-1;
  184. end;
  185. { write source }
  186. if (cs_asm_source in aktglobalswitches) and
  187. not (hp^.typ in [
  188. ait_label,
  189. ait_stabn,ait_stabs,ait_section,
  190. ait_cut,ait_align,ait_stab_function_name]) then
  191. begin
  192. if (infile<>lastinfile) and assigned(lastinfile) then
  193. begin
  194. AsmWriteLn(target_asm.comment+'['+infile^.name^+']');
  195. lastinfile^.close;
  196. end;
  197. if (hp^.fileinfo.line<>lastfileinfo.line) and
  198. (hp^.fileinfo.line<infile^.maxlinebuf) then
  199. begin
  200. if (hp^.fileinfo.line<>0) and
  201. (infile^.linebuf^[hp^.fileinfo.line]>=0) then
  202. AsmWriteLn(target_asm.comment+'['+tostr(hp^.fileinfo.line)+'] '+
  203. fixline(infile^.GetLineStr(hp^.fileinfo.line)));
  204. { set it to a negative value !
  205. to make that is has been read already !! PM }
  206. infile^.linebuf^[hp^.fileinfo.line]:=-infile^.linebuf^[hp^.fileinfo.line]-1;
  207. end;
  208. lastfileinfo:=hp^.fileinfo;
  209. lastinfile:=infile;
  210. end;
  211. end;
  212. case hp^.typ of
  213. ait_comment :
  214. Begin
  215. AsmWrite(target_asm.comment);
  216. AsmWritePChar(pai_asm_comment(hp)^.str);
  217. AsmLn;
  218. End;
  219. ait_regalloc :
  220. begin
  221. if (cs_asm_regalloc in aktglobalswitches) then
  222. AsmWriteLn(target_asm.comment+'Register '+att_reg2str[pairegalloc(hp)^.reg]+
  223. allocstr[pairegalloc(hp)^.allocation]);
  224. end;
  225. ait_tempalloc :
  226. begin
  227. if (cs_asm_tempalloc in aktglobalswitches) then
  228. AsmWriteLn(target_asm.comment+'Temp '+tostr(paitempalloc(hp)^.temppos)+','+
  229. tostr(paitempalloc(hp)^.tempsize)+allocstr[paitempalloc(hp)^.allocation]);
  230. end;
  231. ait_align :
  232. begin
  233. AsmWrite(#9'.balign '+tostr(pai_align(hp)^.aligntype));
  234. if pai_align(hp)^.use_op then
  235. AsmWrite(','+tostr(pai_align(hp)^.fillop));
  236. AsmLn;
  237. end;
  238. ait_section :
  239. begin
  240. if pai_section(hp)^.sec<>sec_none then
  241. begin
  242. AsmLn;
  243. AsmWriteLn(ait_section2str(pai_section(hp)^.sec));
  244. {$ifdef GDB}
  245. lastfileinfo.line:=-1;
  246. {$endif GDB}
  247. end;
  248. end;
  249. ait_datablock :
  250. begin
  251. if pai_datablock(hp)^.is_global then
  252. AsmWrite(#9'.comm'#9)
  253. else
  254. AsmWrite(#9'.lcomm'#9);
  255. AsmWrite(pai_datablock(hp)^.sym^.name);
  256. AsmWriteLn(','+tostr(pai_datablock(hp)^.size));
  257. end;
  258. ait_const_32bit,
  259. ait_const_16bit,
  260. ait_const_8bit :
  261. begin
  262. AsmWrite(ait_const2str[hp^.typ]+tostr(pai_const(hp)^.value));
  263. consttyp:=hp^.typ;
  264. l:=0;
  265. repeat
  266. found:=(not (Pai(hp^.next)=nil)) and (Pai(hp^.next)^.typ=consttyp);
  267. if found then
  268. begin
  269. hp:=Pai(hp^.next);
  270. s:=','+tostr(pai_const(hp)^.value);
  271. AsmWrite(s);
  272. inc(l,length(s));
  273. end;
  274. until (not found) or (l>line_length);
  275. AsmLn;
  276. end;
  277. ait_const_symbol :
  278. begin
  279. AsmWrite(#9'.long'#9+pai_const_symbol(hp)^.sym^.name);
  280. if pai_const_symbol(hp)^.offset>0 then
  281. AsmWrite('+'+tostr(pai_const_symbol(hp)^.offset))
  282. else if pai_const_symbol(hp)^.offset<0 then
  283. AsmWrite(tostr(pai_const_symbol(hp)^.offset));
  284. AsmLn;
  285. end;
  286. ait_const_rva :
  287. AsmWriteLn(#9'.rva'#9+pai_const_symbol(hp)^.sym^.name);
  288. ait_real_64bit :
  289. begin
  290. if do_line then
  291. AsmWriteLn(target_asm.comment+double2str(pai_real_64bit(hp)^.value));
  292. d:=pai_real_64bit(hp)^.value;
  293. AsmWrite(#9'.byte'#9);
  294. for i:=0 to 7 do
  295. begin
  296. if i<>0 then
  297. AsmWrite(',');
  298. AsmWrite(tostr(t64bitarray(d)[i]));
  299. end;
  300. AsmLn;
  301. end;
  302. ait_real_32bit :
  303. begin
  304. if do_line then
  305. AsmWriteLn(target_asm.comment+single2str(pai_real_32bit(hp)^.value));
  306. sin:=pai_real_32bit(hp)^.value;
  307. AsmWrite(#9'.byte'#9);
  308. for i:=0 to 3 do
  309. begin
  310. if i<>0 then
  311. AsmWrite(',');
  312. AsmWrite(tostr(t32bitarray(sin)[i]));
  313. end;
  314. AsmLn;
  315. end;
  316. ait_comp_64bit :
  317. begin
  318. if do_line then
  319. AsmWriteLn(target_asm.comment+comp2str(pai_comp_64bit(hp)^.value));
  320. AsmWrite(#9'.byte'#9);
  321. {$ifdef FPC}
  322. co:=comp(pai_comp_64bit(hp)^.value);
  323. {$else}
  324. co:=pai_comp_64bit(hp)^.value;
  325. {$endif}
  326. for i:=0 to 7 do
  327. begin
  328. if i<>0 then
  329. AsmWrite(',');
  330. AsmWrite(tostr(t64bitarray(co)[i]));
  331. end;
  332. AsmLn;
  333. end;
  334. ait_direct :
  335. begin
  336. AsmWritePChar(pai_direct(hp)^.str);
  337. AsmLn;
  338. {$IfDef GDB}
  339. if strpos(pai_direct(hp)^.str,'.data')<>nil then
  340. n_line:=n_dataline
  341. else if strpos(pai_direct(hp)^.str,'.text')<>nil then
  342. n_line:=n_textline
  343. else if strpos(pai_direct(hp)^.str,'.bss')<>nil then
  344. n_line:=n_bssline;
  345. {$endif GDB}
  346. end;
  347. ait_string :
  348. begin
  349. pos:=0;
  350. for i:=1 to pai_string(hp)^.len do
  351. begin
  352. if pos=0 then
  353. begin
  354. AsmWrite(#9'.ascii'#9'"');
  355. pos:=20;
  356. end;
  357. ch:=pai_string(hp)^.str[i-1];
  358. case ch of
  359. #0, {This can't be done by range, because a bug in FPC}
  360. #1..#31,
  361. #128..#255 : s:='\'+tostr(ord(ch) shr 6)+tostr((ord(ch) and 63) shr 3)+tostr(ord(ch) and 7);
  362. '"' : s:='\"';
  363. '\' : s:='\\';
  364. else
  365. s:=ch;
  366. end;
  367. AsmWrite(s);
  368. inc(pos,length(s));
  369. if (pos>line_length) or (i=pai_string(hp)^.len) then
  370. begin
  371. AsmWriteLn('"');
  372. pos:=0;
  373. end;
  374. end;
  375. end;
  376. ait_label :
  377. begin
  378. if (pai_label(hp)^.l^.is_used) then
  379. begin
  380. if pai_label(hp)^.l^.typ=AS_GLOBAL then
  381. AsmWriteLn('.globl'#9+pai_label(hp)^.l^.name);
  382. AsmWriteLn(pai_label(hp)^.l^.name+':');
  383. end;
  384. end;
  385. ait_symbol :
  386. begin
  387. if pai_symbol(hp)^.is_global then
  388. AsmWriteLn('.globl'#9+pai_symbol(hp)^.sym^.name);
  389. if target_info.target=target_i386_linux then
  390. begin
  391. AsmWrite(#9'.type'#9+pai_symbol(hp)^.sym^.name);
  392. if assigned(pai(hp^.next)) and
  393. (pai(hp^.next)^.typ in [ait_const_symbol,ait_const_rva,
  394. ait_const_32bit,ait_const_16bit,ait_const_8bit,ait_datablock,
  395. ait_real_32bit,ait_real_64bit,ait_real_80bit,ait_comp_64bit]) then
  396. AsmWriteLn(',@object')
  397. else
  398. AsmWriteLn(',@function');
  399. if pai_symbol(hp)^.sym^.size>0 then
  400. AsmWriteLn(#9'.size'#9+pai_symbol(hp)^.sym^.name+', '+tostr(pai_symbol(hp)^.sym^.size));
  401. end;
  402. AsmWriteLn(pai_symbol(hp)^.sym^.name+':');
  403. end;
  404. ait_symbol_end :
  405. begin
  406. if target_info.target=target_i386_linux then
  407. begin
  408. s:=target_asm.labelprefix+'e'+tostr(symendcount);
  409. inc(symendcount);
  410. AsmWriteLn(s+':');
  411. AsmWriteLn(#9'.size'#9+pai_symbol(hp)^.sym^.name+', '+s+' - '+pai_symbol(hp)^.sym^.name);
  412. end;
  413. end;
  414. ait_instruction :
  415. begin
  416. op:=paicpu(hp)^.opcode;
  417. calljmp:=is_calljmp(op);
  418. { call maybe not translated to calll }
  419. s:=#9+att_op2str[op]+cond2str[paicpu(hp)^.condition];
  420. if (not calljmp) and
  421. (not att_nosuffix[op]) and
  422. not(
  423. (paicpu(hp)^.oper[0].typ=top_reg) and
  424. (paicpu(hp)^.oper[0].reg in [R_ST..R_ST7])
  425. ) then
  426. s:=s+att_opsize2str[paicpu(hp)^.opsize];
  427. { process operands }
  428. if paicpu(hp)^.ops<>0 then
  429. begin
  430. { call and jmp need an extra handling }
  431. { this code is only called if jmp isn't a labeled instruction }
  432. if calljmp then
  433. s:=s+#9+getopstr_jmp(paicpu(hp)^.oper[0])
  434. else
  435. begin
  436. for i:=0to paicpu(hp)^.ops-1 do
  437. begin
  438. if i=0 then
  439. sep:=#9
  440. else
  441. sep:=',';
  442. s:=s+sep+getopstr(paicpu(hp)^.oper[i])
  443. end;
  444. end;
  445. end;
  446. AsmWriteLn(s);
  447. end;
  448. {$ifdef GDB}
  449. ait_stabs :
  450. begin
  451. AsmWrite(#9'.stabs ');
  452. AsmWritePChar(pai_stabs(hp)^.str);
  453. AsmLn;
  454. end;
  455. ait_stabn :
  456. begin
  457. AsmWrite(#9'.stabn ');
  458. AsmWritePChar(pai_stabn(hp)^.str);
  459. AsmLn;
  460. end;
  461. ait_force_line :
  462. stabslastfileinfo.line:=0;
  463. ait_stab_function_name:
  464. funcname:=pai_stab_function_name(hp)^.str;
  465. {$endif GDB}
  466. ait_cut :
  467. begin
  468. if SmartAsm then
  469. begin
  470. { only reset buffer if nothing has changed }
  471. if AsmSize=AsmStartSize then
  472. AsmClear
  473. else
  474. begin
  475. AsmClose;
  476. DoAssemble;
  477. if pai_cut(hp)^.EndName then
  478. IsEndFile:=true;
  479. AsmCreate;
  480. end;
  481. { avoid empty files }
  482. while assigned(hp^.next) and (pai(hp^.next)^.typ in [ait_cut,ait_section,ait_comment]) do
  483. begin
  484. if pai(hp^.next)^.typ=ait_section then
  485. lastsec:=pai_section(hp^.next)^.sec;
  486. hp:=pai(hp^.next);
  487. end;
  488. {$ifdef GDB}
  489. { force write of filename }
  490. FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
  491. includecount:=0;
  492. funcname:=nil;
  493. WriteFileLineInfo(hp^.fileinfo);
  494. {$endif GDB}
  495. if lastsec<>sec_none then
  496. AsmWriteLn(ait_section2str(lastsec));
  497. AsmStartSize:=AsmSize;
  498. end;
  499. end;
  500. ait_marker :
  501. ;
  502. else
  503. internalerror(10000);
  504. end;
  505. hp:=pai(hp^.next);
  506. end;
  507. end;
  508. procedure talphaattasmlist.WriteAsmList;
  509. var
  510. p:dirstr;
  511. n:namestr;
  512. e:extstr;
  513. {$ifdef GDB}
  514. fileinfo : tfileposinfo;
  515. {$endif GDB}
  516. begin
  517. {$ifdef EXTDEBUG}
  518. if assigned(current_module^.mainsource) then
  519. Comment(v_info,'Start writing GNU-styled assembler output for '+current_module^.mainsource^);
  520. {$endif}
  521. LastSec:=sec_none;
  522. {$ifdef GDB}
  523. FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
  524. {$endif GDB}
  525. FillChar(lastfileinfo,sizeof(lastfileinfo),0);
  526. LastInfile:=nil;
  527. if assigned(current_module^.mainsource) then
  528. fsplit(current_module^.mainsource^,p,n,e)
  529. else
  530. begin
  531. p:=inputdir;
  532. n:=inputfile;
  533. e:=inputextension;
  534. end;
  535. { to get symify to work }
  536. AsmWriteLn(#9'.file "'+FixFileName(n+e)+'"');
  537. {$ifdef GDB}
  538. n_line:=n_bssline;
  539. funcname:=nil;
  540. linecount:=1;
  541. includecount:=0;
  542. fileinfo.fileindex:=1;
  543. fileinfo.line:=1;
  544. { Write main file }
  545. WriteFileLineInfo(fileinfo);
  546. {$endif GDB}
  547. AsmStartSize:=AsmSize;
  548. symendcount:=0;
  549. countlabelref:=false;
  550. If (cs_debuginfo in aktmoduleswitches) then
  551. WriteTree(debuglist);
  552. WriteTree(codesegment);
  553. WriteTree(datasegment);
  554. WriteTree(consts);
  555. WriteTree(rttilist);
  556. Writetree(resourcestringlist);
  557. WriteTree(bsssegment);
  558. Writetree(importssection);
  559. Writetree(exportssection);
  560. Writetree(resourcesection);
  561. countlabelref:=true;
  562. AsmLn;
  563. {$ifdef EXTDEBUG}
  564. if assigned(current_module^.mainsource) then
  565. comment(v_info,'Done writing att-styled assembler output for '+current_module^.mainsource^);
  566. {$endif EXTDEBUG}
  567. end;
  568. end.
  569. {
  570. $Log$
  571. Revision 1.2 1999-08-25 12:00:22 jonas
  572. * changed pai386, paippc and paiapha (same for tai*) to paicpu (taicpu)
  573. Revision 1.1 1999/08/03 23:37:52 jonas
  574. + initial implementation for PowerPC based on the Alpha stuff
  575. }