agppcgas.pas 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit the GAS asm writers for PowerPC/PowerPC64
  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. {****************************************************************************}
  18. { Helper routines for Instruction Writer }
  19. {****************************************************************************}
  20. unit agppcgas;
  21. {$i fpcdefs.inc}
  22. interface
  23. uses
  24. systems,aasmbase,
  25. aasmtai,aasmdata,
  26. assemble,aggas,
  27. cpubase,cgutils,
  28. globtype;
  29. type
  30. TPPCInstrWriter=class(TCPUInstrWriter)
  31. procedure WriteInstruction(hp : tai);override;
  32. end;
  33. TPPCGNUAssembler=class(TGNUassembler)
  34. constructor CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean); override;
  35. function MakeCmdLine: TCmdStr; override;
  36. procedure WriteExtraHeader; override;
  37. end;
  38. TPPCAppleGNUAssembler=class(TAppleGNUassembler)
  39. constructor CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean); override;
  40. function MakeCmdLine: TCmdStr; override;
  41. end;
  42. TPPCAIXAssembler=class(TPPCGNUAssembler)
  43. max_alignment : array[TAsmSectionType] of longint;
  44. constructor CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean); override;
  45. protected
  46. function sectionname(atype: TAsmSectiontype; const aname: string; aorder: TAsmSectionOrder): string; override;
  47. procedure WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder;secalign:longint;secflags:TSectionFlags=[];secprogbits:TSectionProgbits=SPB_None); override;
  48. procedure WriteAsmList; override;
  49. procedure WriteExtraHeader; override;
  50. procedure WriteExtraFooter; override;
  51. procedure WriteDirectiveName(dir: TAsmDirective); override;
  52. end;
  53. topstr = string[4];
  54. function branchmode(o: tasmop): topstr;
  55. function cond2str(op: tasmop; c: tasmcond): string;
  56. implementation
  57. uses
  58. cutils,globals,verbose,
  59. cgbase,
  60. itcpugas,cpuinfo,
  61. aasmcpu;
  62. {$ifdef cpu64bitaddr}
  63. const
  64. refaddr2str: array[trefaddr] of string[9] = ('', '', '', '', '@l', '@h', '@higher', '@highest', '@ha', '@highera', '@highesta');
  65. verbose_refaddrs = [addr_low, addr_high, addr_higher, addr_highest, addr_higha, addr_highera, addr_highesta];
  66. refaddr2str_darwin: array[trefaddr] of string[4] = ('','','','','lo16', 'hi16', '@err', '@err', 'ha16', '@err', '@err');
  67. {$else cpu64bitaddr}
  68. const
  69. refaddr2str: array[trefaddr] of string[3] = ('','','','','@l','@h','@ha');
  70. refaddr2str_darwin: array[trefaddr] of string[4] = ('','','','','lo16','hi16','ha16');
  71. verbose_refaddrs = [addr_low,addr_high,addr_higha];
  72. {$endif cpu64bitaddr}
  73. function getreferencestring(asminfo: pasminfo; var ref : treference) : string;
  74. var
  75. s : string;
  76. begin
  77. with ref do
  78. begin
  79. if ((offset < -32768) or (offset > 32767)) and
  80. (refaddr = addr_no) then
  81. internalerror(2006052501);
  82. case refaddr of
  83. addr_no:
  84. s := '';
  85. addr_pic_no_got:
  86. begin
  87. { used for TOC-based loads }
  88. if (base<>NR_RTOC) or
  89. (index<>NR_NO) or
  90. (offset<>0) or
  91. not assigned(symbol) then
  92. internalerror(2011122701);
  93. if asminfo^.dollarsign<>'$' then
  94. getreferencestring:=ReplaceForbiddenAsmSymbolChars(symbol.name)+'('+gas_regname(NR_RTOC)+')'
  95. else
  96. getreferencestring:=symbol.name+'('+gas_regname(NR_RTOC)+')';
  97. exit;
  98. end
  99. else
  100. begin
  101. if target_info.system in [system_powerpc_darwin,system_powerpc64_darwin] then
  102. s := refaddr2str_darwin[refaddr]
  103. else
  104. s :='';
  105. s := s+'(';
  106. if assigned(symbol) then
  107. begin
  108. if asminfo^.dollarsign<>'$' then
  109. begin
  110. s:=s+ReplaceForbiddenAsmSymbolChars(symbol.name);
  111. if assigned(relsymbol) then
  112. s:=s+'-'+ReplaceForbiddenAsmSymbolChars(relsymbol.name)
  113. end
  114. else
  115. begin
  116. s:=s+symbol.name;
  117. if assigned(relsymbol) then
  118. s:=s+'-'+relsymbol.name;
  119. end;
  120. end;
  121. end;
  122. end;
  123. if offset<0 then
  124. s:=s+tostr(offset)
  125. else
  126. if (offset>0) then
  127. begin
  128. if assigned(symbol) then
  129. s:=s+'+'+tostr(offset)
  130. else
  131. s:=s+tostr(offset);
  132. end;
  133. if not(refaddr in [addr_no,addr_pic_no_got]) then
  134. begin
  135. s := s+')';
  136. if (refaddr in verbose_refaddrs) and
  137. not(target_info.system in [system_powerpc_darwin,system_powerpc64_darwin]) then
  138. s := s+refaddr2str[refaddr];
  139. end;
  140. {$ifdef cpu64bitaddr}
  141. if (refaddr=addr_pic) and
  142. (target_info.system=system_powerpc64_linux) then
  143. s := s + '@got';
  144. {$endif cpu64bitaddr}
  145. if (index=NR_NO) then
  146. begin
  147. if offset=0 then
  148. begin
  149. if not (assigned(symbol)) then
  150. s:=s+'0';
  151. end;
  152. if (base<>NR_NO) then
  153. s:=s+'('+gas_regname(base)+')'
  154. else if not assigned(symbol) and
  155. not(refaddr in verbose_refaddrs) then
  156. s:=s+'(0)';
  157. end
  158. else if (index<>NR_NO) and (base<>NR_NO) then
  159. begin
  160. if (offset=0) then
  161. s:=s+gas_regname(base)+','+gas_regname(index)
  162. else
  163. internalerror(2006052502);
  164. end;
  165. end;
  166. getreferencestring:=s;
  167. end;
  168. function getopstr_jmp(asminfo: pasminfo; const o:toper) : string;
  169. var
  170. hs : string;
  171. begin
  172. case o.typ of
  173. top_reg :
  174. getopstr_jmp:=gas_regname(o.reg);
  175. { no top_ref jumping for powerpc }
  176. top_const :
  177. getopstr_jmp:=tostr(o.val);
  178. top_ref :
  179. begin
  180. if o.ref^.refaddr<>addr_full then
  181. internalerror(200402267);
  182. hs:=o.ref^.symbol.name;
  183. if asminfo^.dollarsign<>'$' then
  184. hs:=ReplaceForbiddenAsmSymbolChars(hs);
  185. if o.ref^.offset>0 then
  186. hs:=hs+'+'+tostr(o.ref^.offset)
  187. else
  188. if o.ref^.offset<0 then
  189. hs:=hs+tostr(o.ref^.offset);
  190. getopstr_jmp:=hs;
  191. end;
  192. top_none:
  193. getopstr_jmp:='';
  194. else
  195. internalerror(2002070603);
  196. end;
  197. end;
  198. function getopstr(asminfo: pasminfo; const o:toper) : string;
  199. var
  200. hs : string;
  201. begin
  202. case o.typ of
  203. top_reg:
  204. getopstr:=gas_regname(o.reg);
  205. top_const:
  206. getopstr:=tostr(longint(o.val));
  207. top_ref:
  208. if o.ref^.refaddr=addr_full then
  209. begin
  210. hs:=o.ref^.symbol.name;
  211. if asminfo^.dollarsign<>'$' then
  212. hs:=ReplaceForbiddenAsmSymbolChars(hs);
  213. if o.ref^.offset>0 then
  214. hs:=hs+'+'+tostr(o.ref^.offset)
  215. else
  216. if o.ref^.offset<0 then
  217. hs:=hs+tostr(o.ref^.offset);
  218. getopstr:=hs;
  219. end
  220. else
  221. getopstr:=getreferencestring(asminfo,o.ref^);
  222. else
  223. internalerror(2002070604);
  224. end;
  225. end;
  226. function branchmode(o: tasmop): topstr;
  227. var tempstr: topstr;
  228. begin
  229. tempstr := '';
  230. case o of
  231. A_BCCTR,A_BCCTRL: tempstr := 'ctr';
  232. A_BCLR,A_BCLRL: tempstr := 'lr';
  233. else
  234. ;
  235. end;
  236. case o of
  237. A_BL,A_BLA,A_BCL,A_BCLA,A_BCCTRL,A_BCLRL: tempstr := tempstr+'l';
  238. else
  239. ;
  240. end;
  241. case o of
  242. A_BA,A_BLA,A_BCA,A_BCLA: tempstr:=tempstr+'a';
  243. else
  244. ;
  245. end;
  246. branchmode := tempstr;
  247. end;
  248. function cond2str(op: tasmop; c: tasmcond): string;
  249. { note: no checking is performed whether the given combination of }
  250. { conditions is valid }
  251. var
  252. tempstr: string;
  253. begin
  254. tempstr:=#9;
  255. case c.simple of
  256. false:
  257. begin
  258. cond2str := tempstr+gas_op2str[op];
  259. case c.dirhint of
  260. DH_None:;
  261. DH_Minus:
  262. cond2str:=cond2str+'-';
  263. DH_Plus:
  264. cond2str:=cond2str+'+';
  265. end;
  266. cond2str:=cond2str+#9+tostr(c.bo)+','+tostr(c.bi);
  267. end;
  268. true:
  269. if (op >= A_B) and (op <= A_BCLRL) then
  270. case c.cond of
  271. { unconditional branch }
  272. C_NONE:
  273. cond2str := tempstr+gas_op2str[op];
  274. { bdnzt etc }
  275. else
  276. begin
  277. tempstr := tempstr+'b'+asmcondflag2str[c.cond]+
  278. branchmode(op);
  279. case c.dirhint of
  280. DH_None:
  281. tempstr:=tempstr+#9;
  282. DH_Minus:
  283. tempstr:=tempstr+('-'+#9);
  284. DH_Plus:
  285. tempstr:=tempstr+('+'+#9);
  286. end;
  287. case c.cond of
  288. C_LT..C_NU:
  289. begin
  290. if byte(c.cr)=0 then
  291. Comment(V_error,'Wrong use of whole CR register for '+tempstr);
  292. cond2str := tempstr+gas_regname(newreg(R_SPECIALREGISTER,c.cr,R_SUBWHOLE));
  293. end;
  294. C_T,C_F,C_DNZT,C_DNZF,C_DZT,C_DZF:
  295. cond2str := tempstr+tostr(c.crbit);
  296. else
  297. cond2str := tempstr;
  298. end;
  299. end;
  300. end
  301. { we have a trap instruction }
  302. else
  303. begin
  304. internalerror(2002070601);
  305. { not yet implemented !!!!!!!!!!!!!!!!!!!!! }
  306. { case tempstr := 'tw';}
  307. end;
  308. end;
  309. end;
  310. {****************************************************************************}
  311. { PowerPC Instruction Writer }
  312. {****************************************************************************}
  313. Procedure TPPCInstrWriter.WriteInstruction(hp : tai);
  314. var op: TAsmOp;
  315. s: string;
  316. i: byte;
  317. sep: string[3];
  318. begin
  319. op:=taicpu(hp).opcode;
  320. if is_calljmp(op) then
  321. begin
  322. { direct BO/BI in op[0] and op[1] not supported, put them in condition! }
  323. case op of
  324. A_B,A_BA,A_BL,A_BLA:
  325. s:=#9+gas_op2str[op]+#9;
  326. A_BCTR,A_BCTRL,A_BLR,A_BLRL:
  327. s:=#9+gas_op2str[op]
  328. else
  329. begin
  330. s:=cond2str(op,taicpu(hp).condition);
  331. if (s[length(s)] <> #9) and
  332. (taicpu(hp).ops>0) then
  333. s := s + ',';
  334. end;
  335. end;
  336. if (taicpu(hp).ops>0) and (taicpu(hp).oper[0]^.typ<>top_none) then
  337. begin
  338. { first write the current contents of s, because the symbol }
  339. { may be 255 characters }
  340. owner.writer.AsmWrite(s);
  341. s:=getopstr_jmp(owner.asminfo,taicpu(hp).oper[0]^);
  342. end;
  343. end
  344. else
  345. { process operands }
  346. begin
  347. s:=#9+gas_op2str[op];
  348. if taicpu(hp).ops<>0 then
  349. begin
  350. {
  351. if not is_calljmp(op) then
  352. sep:=','
  353. else
  354. }
  355. sep:=#9;
  356. for i:=0 to taicpu(hp).ops-1 do
  357. begin
  358. // debug code
  359. // writeln(s);
  360. // writeln(taicpu(hp).fileinfo.line);
  361. s:=s+sep+getopstr(owner.asminfo,taicpu(hp).oper[i]^);
  362. sep:=',';
  363. end;
  364. end;
  365. end;
  366. owner.writer.AsmWriteLn(s);
  367. end;
  368. {****************************************************************************}
  369. { GNU PPC Assembler writer }
  370. {****************************************************************************}
  371. constructor TPPCGNUAssembler.CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean);
  372. begin
  373. inherited;
  374. InstrWriter := TPPCInstrWriter.create(self);
  375. end;
  376. function TPPCGNUAssembler.MakeCmdLine: TCmdStr;
  377. begin
  378. result := inherited MakeCmdLine;
  379. {$ifdef cpu64bitaddr}
  380. Replace(result,'$ARCH','-a64')
  381. {$else cpu64bitaddr}
  382. { MorphOS has an old 2.9.1 GNU AS, with a bunch of patches
  383. to support the system, and it doesn't know the -a32 argument }
  384. if target_info.system = system_powerpc_morphos then
  385. Replace(result,'$ARCH','')
  386. else
  387. Replace(result,'$ARCH','-a32');
  388. {$endif cpu64bitaddr}
  389. end;
  390. procedure TPPCGNUAssembler.WriteExtraHeader;
  391. var
  392. i : longint;
  393. begin
  394. if target_info.abi = abi_powerpc_elfv2 then
  395. writer.AsmWriteln(#9'.abiversion 2');
  396. for i:=0 to 31 do
  397. writer.AsmWriteln(#9'.set'#9'r'+tostr(i)+','+tostr(i));
  398. for i:=0 to 31 do
  399. writer.AsmWriteln(#9'.set'#9'f'+tostr(i)+','+tostr(i));
  400. end;
  401. {****************************************************************************}
  402. { GNU/Apple PPC Assembler writer }
  403. {****************************************************************************}
  404. constructor TPPCAppleGNUAssembler.CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean);
  405. begin
  406. inherited;
  407. InstrWriter := TPPCInstrWriter.create(self);
  408. end;
  409. function TPPCAppleGNUAssembler.MakeCmdLine: TCmdStr;
  410. begin
  411. result := inherited MakeCmdLine;
  412. {$ifdef cpu64bitaddr}
  413. Replace(result,'$ARCH','ppc64')
  414. {$else cpu64bitaddr}
  415. case current_settings.cputype of
  416. cpu_PPC7400:
  417. Replace(result,'$ARCH','ppc7400');
  418. cpu_PPC970:
  419. Replace(result,'$ARCH','ppc970');
  420. else
  421. Replace(result,'$ARCH','ppc')
  422. end;
  423. {$endif cpu64bitaddr}
  424. end;
  425. {****************************************************************************}
  426. { AIX PPC Assembler writer }
  427. {****************************************************************************}
  428. constructor TPPCAIXAssembler.CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean);
  429. var
  430. cur_sectype : TAsmSectionType;
  431. begin
  432. inherited;
  433. InstrWriter := TPPCInstrWriter.create(self);
  434. { Use 8-byte alignment as default for all sections }
  435. for cur_sectype:=low(TAsmSectionType) to high(TAsmSectionType) do
  436. max_alignment[cur_sectype]:=8;
  437. end;
  438. procedure TPPCAIXAssembler.WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder;secalign:longint;
  439. secflags:TSectionFlags=[];secprogbits:TSectionProgbits=SPB_None);
  440. begin
  441. secalign:=max_alignment[atype];
  442. Inherited WriteSection(atype,aname,aorder,secalign,secflags,secprogbits);
  443. end;
  444. procedure TPPCAIXAssembler.WriteAsmList;
  445. var
  446. cur_sectype : TAsmSectionType;
  447. cur_list : TAsmList;
  448. hal : tasmlisttype;
  449. hp : tai;
  450. max_al : longint;
  451. begin
  452. { Parse all asmlists to get maximum alignement used for all types }
  453. for hal:=low(TasmlistType) to high(TasmlistType) do
  454. begin
  455. if not (current_asmdata.asmlists[hal].empty) then
  456. begin
  457. cur_sectype:=sec_none;
  458. hp:=tai(current_asmdata.asmlists[hal].First);
  459. while assigned(hp) do
  460. begin
  461. case hp.typ of
  462. ait_align :
  463. begin
  464. if tai_align_abstract(hp).aligntype > max_alignment[cur_sectype] then
  465. begin
  466. max_alignment[cur_sectype]:=tai_align_abstract(hp).aligntype;
  467. current_asmdata.asmlists[hal].InsertAfter(tai_comment.Create(strpnew('Alignment put to '+tostr(tai_align_abstract(hp).aligntype))),hp);
  468. end;
  469. end;
  470. ait_section :
  471. begin
  472. cur_sectype:=tai_section(hp).sectype;
  473. if tai_section(hp).secalign > max_alignment[cur_sectype] then
  474. begin
  475. max_alignment[cur_sectype]:=tai_section(hp).secalign;
  476. current_asmdata.asmlists[hal].InsertAfter(tai_comment.Create(strpnew('Section '
  477. +sectionname(tai_section(hp).sectype,'',secorder_default)+' alignment put to '+tostr(tai_section(hp).secalign))),hp);
  478. end;
  479. end;
  480. else
  481. ;
  482. end;
  483. hp:=tai(hp.next);
  484. end;
  485. end;
  486. end;
  487. { sec_data, sec_rodata and sec_bss all are converted into .data[RW],
  488. in WriteSection below,
  489. so we take the maximum alignment of the three }
  490. max_al:=max_alignment[sec_data];
  491. max_al:=max(max_al,max_alignment[sec_rodata]);
  492. max_al:=max(max_al,max_alignment[sec_bss]);
  493. max_alignment[sec_data]:=max_al;
  494. max_alignment[sec_rodata]:=max_al;
  495. max_alignment[sec_bss]:=max_al;
  496. Inherited WriteAsmList;
  497. end;
  498. procedure TPPCAIXAssembler.WriteExtraHeader;
  499. var
  500. i: longint;
  501. begin
  502. inherited WriteExtraHeader;
  503. { map cr registers to plain numbers }
  504. for i:=0 to 7 do
  505. writer.AsmWriteln(#9'.set'#9'cr'+tostr(i)+','+tostr(i));
  506. { Ensure .data and .rodata sections are aligned to 8-byte boundary,
  507. required for correct RTTI alignment.
  508. AIX assembler seems to only care for the first
  509. alignment value given }
  510. writer.AsmWriteln(#9'.csect .data[RW],'+sectionalignment_aix(sec_data,max_alignment[sec_data]));
  511. writer.AsmWriteln(#9'.csect _data.bss_[BS],'+sectionalignment_aix(sec_data,max_alignment[sec_data]));
  512. { .rodata is translated into .text[RO]
  513. see sectionname in aggas unit. }
  514. writer.AsmWriteln(#9'.csect .text[RO],'+sectionalignment_aix(sec_rodata_norel,max_alignment[sec_rodata_norel]));
  515. { make sure we always have a code and toc section,
  516. the linker expects that }
  517. writer.AsmWriteln(#9'.csect .text[PR],'+sectionalignment_aix(sec_code,max_alignment[sec_code]));
  518. { set _text_s, to be used by footer below }
  519. writer.AsmWriteln(#9'_text_s:');
  520. writer.AsmWriteln(#9'.toc');
  521. end;
  522. procedure TPPCAIXAssembler.WriteExtraFooter;
  523. begin
  524. inherited WriteExtraFooter;
  525. { link between data and text section }
  526. writer.AsmWriteln(#9'.csect .data[RW],3');
  527. {$ifdef cpu64bitaddr}
  528. writer.AsmWriteln('text_pos:'#9'.llong _text_s')
  529. {$else cpu64bitaddr}
  530. writer.AsmWriteln('text_pos:'#9'.long _text_s')
  531. {$endif cpu64bitaddr}
  532. end;
  533. procedure TPPCAIXAssembler.WriteDirectiveName(dir: TAsmDirective);
  534. begin
  535. case dir of
  536. asd_reference:
  537. writer.AsmWrite('.ref ');
  538. asd_weak_reference,
  539. asd_weak_definition:
  540. writer.AsmWrite('.weak ');
  541. else
  542. inherited WriteDirectiveName(dir);
  543. end;
  544. end;
  545. function TPPCAIXAssembler.sectionname(atype: TAsmSectiontype; const aname: string; aorder: TAsmSectionOrder): string;
  546. begin
  547. case atype of
  548. sec_code:
  549. result:='.csect .text[PR]';
  550. sec_data,
  551. sec_rodata,
  552. { don't use .bss[BS], causes relocation problems }
  553. sec_bss:
  554. result:='.csect .data[RW]';
  555. sec_rodata_norel:
  556. result:='.csect .text[RO]';
  557. sec_fpc:
  558. result:='.csect .fpc[RO]';
  559. sec_toc:
  560. result:='.toc';
  561. { automatically placed in the right section }
  562. sec_stab,
  563. sec_stabstr:
  564. result:='';
  565. else
  566. internalerror(2011122601);
  567. end;
  568. end;
  569. {*****************************************************************************
  570. Initialize
  571. *****************************************************************************}
  572. const
  573. as_ppc_gas_info : tasminfo =
  574. (
  575. id : as_gas;
  576. idtxt : 'AS';
  577. asmbin : 'as';
  578. {$ifdef cpu64bitaddr}
  579. asmcmd : '-a64 $ENDIAN -o $OBJ $EXTRAOPT $ASM';
  580. {$else cpu64bitaddr}
  581. asmcmd: '$ENDIAN -o $OBJ $EXTRAOPT $ARCH $ASM';
  582. {$endif cpu64bitaddr}
  583. supported_targets : [system_powerpc_linux,system_powerpc_netbsd,system_powerpc_openbsd,system_powerpc_MorphOS,system_powerpc_Amiga,system_powerpc64_linux,system_powerpc_embedded,system_powerpc64_embedded];
  584. flags : [af_needar,af_smartlink_sections];
  585. labelprefix : '.L';
  586. comment : '# ';
  587. dollarsign: '$';
  588. );
  589. as_ppc_gas_legacy_info : tasminfo =
  590. (
  591. id : as_powerpc_gas_legacy;
  592. idtxt : 'AS-LEGACY';
  593. asmbin : 'as';
  594. {$ifdef cpu64bitaddr}
  595. asmcmd : '-a64 $ENDIAN -o $OBJ $EXTRAOPT $ASM';
  596. {$else cpu64bitaddr}
  597. asmcmd: '$ENDIAN -o $OBJ $EXTRAOPT $ARCH $ASM';
  598. {$endif cpu64bitaddr}
  599. supported_targets : [system_powerpc_morphos];
  600. flags : [af_needar];
  601. labelprefix : '.L';
  602. comment : '# ';
  603. dollarsign: '$';
  604. );
  605. as_ppc_gas_darwin_powerpc_info : tasminfo =
  606. (
  607. id : as_darwin;
  608. idtxt : 'AS-DARWIN';
  609. asmbin : 'as';
  610. asmcmd : '-o $OBJ $EXTRAOPT $ASM -arch $ARCH';
  611. supported_targets : [system_powerpc_darwin,system_powerpc64_darwin];
  612. flags : [af_needar,af_smartlink_sections,af_supports_dwarf,af_stabs_use_function_absolute_addresses];
  613. labelprefix : 'L';
  614. comment : '# ';
  615. dollarsign : '$';
  616. );
  617. as_ppc_aix_powerpc_info : tasminfo =
  618. (
  619. id : as_powerpc_xcoff;
  620. idtxt : 'AS-AIX';
  621. asmbin : 'as';
  622. { -u: allow using symbols before they are defined (when using native
  623. AIX assembler, ignore by GNU assembler)
  624. -mpwr5: we actually support Power3 and higher, but the AIX assembler
  625. has no parameter to select that one (only -mpwr3 and -mpwr5) }
  626. {$ifdef cpu64bitaddr}
  627. asmcmd : '-a64 -u -o $OBJ $EXTRAOPT $ASM -mpwr5';
  628. {$else cpu64bitaddr}
  629. asmcmd : '-u -o $OBJ $EXTRAOPT $ASM -mpwr5';
  630. {$endif cpu64bitaddr}
  631. supported_targets : [system_powerpc_aix,system_powerpc64_aix];
  632. flags : [af_needar,af_smartlink_sections,af_stabs_use_function_absolute_addresses];
  633. labelprefix : 'L';
  634. comment : '# ';
  635. dollarsign : '.'
  636. );
  637. as_ppc_gas_aix_powerpc_info : tasminfo =
  638. (
  639. id : as_gas_powerpc_xcoff;
  640. idtxt : 'GAS';
  641. asmbin : 'gas';
  642. { -u: allow using symbols before they are defined (when using native
  643. AIX assembler, ignore by GNU assembler)
  644. -mpwr5: we actually support Power3 and higher, but the AIX assembler
  645. has no parameter to select that one (only -mpwr3 and -mpwr5) }
  646. {$ifdef cpu64bitaddr}
  647. asmcmd : '-a64 -u -o $OBJ $EXTRAOPT $ASM -mpwr5';
  648. {$else cpu64bitaddr}
  649. asmcmd : '-a32 -u -o $OBJ $EXTRAOPT $ASM -mpwr5';
  650. {$endif cpu64bitaddr}
  651. supported_targets : [system_powerpc_aix,system_powerpc64_aix];
  652. flags : [af_needar,af_smartlink_sections,af_stabs_use_function_absolute_addresses];
  653. labelprefix : 'L';
  654. comment : '# ';
  655. dollarsign : '.'
  656. );
  657. as_ppc_clang_darwin_info : tasminfo =
  658. (
  659. id : as_clang;
  660. idtxt : 'CLANG';
  661. asmbin : 'clang';
  662. asmcmd : '-c -o $OBJ $EXTRAOPT -arch $ARCH $DARWINVERSION -x assembler $ASM';
  663. supported_targets : [system_powerpc_macos, system_powerpc_darwin, system_powerpc64_darwin];
  664. flags : [af_needar,af_smartlink_sections,af_supports_dwarf];
  665. labelprefix : 'L';
  666. comment : '# ';
  667. dollarsign: '$';
  668. );
  669. begin
  670. RegisterAssembler(as_ppc_gas_info,TPPCGNUAssembler);
  671. RegisterAssembler(as_ppc_gas_legacy_info,TPPCGNUAssembler);
  672. RegisterAssembler(as_ppc_gas_darwin_powerpc_info,TPPCAppleGNUAssembler);
  673. RegisterAssembler(as_ppc_clang_darwin_info,TPPCAppleGNUAssembler);
  674. RegisterAssembler(as_ppc_aix_powerpc_info,TPPCAIXAssembler);
  675. RegisterAssembler(as_ppc_gas_aix_powerpc_info,TPPCAIXAssembler);
  676. end.