agppcgas.pas 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  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=SF_None;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. end;
  234. case o of
  235. A_BL,A_BLA,A_BCL,A_BCLA,A_BCCTRL,A_BCLRL: tempstr := tempstr+'l';
  236. end;
  237. case o of
  238. A_BA,A_BLA,A_BCA,A_BCLA: tempstr:=tempstr+'a';
  239. end;
  240. branchmode := tempstr;
  241. end;
  242. function cond2str(op: tasmop; c: tasmcond): string;
  243. { note: no checking is performed whether the given combination of }
  244. { conditions is valid }
  245. var
  246. tempstr: string;
  247. begin
  248. tempstr:=#9;
  249. case c.simple of
  250. false:
  251. begin
  252. cond2str := tempstr+gas_op2str[op];
  253. case c.dirhint of
  254. DH_None:;
  255. DH_Minus:
  256. cond2str:=cond2str+'-';
  257. DH_Plus:
  258. cond2str:=cond2str+'+';
  259. else
  260. internalerror(2003112901);
  261. end;
  262. cond2str:=cond2str+#9+tostr(c.bo)+','+tostr(c.bi);
  263. end;
  264. true:
  265. if (op >= A_B) and (op <= A_BCLRL) then
  266. case c.cond of
  267. { unconditional branch }
  268. C_NONE:
  269. cond2str := tempstr+gas_op2str[op];
  270. { bdnzt etc }
  271. else
  272. begin
  273. tempstr := tempstr+'b'+asmcondflag2str[c.cond]+
  274. branchmode(op);
  275. case c.dirhint of
  276. DH_None:
  277. tempstr:=tempstr+#9;
  278. DH_Minus:
  279. tempstr:=tempstr+('-'+#9);
  280. DH_Plus:
  281. tempstr:=tempstr+('+'+#9);
  282. else
  283. internalerror(2003112901);
  284. end;
  285. case c.cond of
  286. C_LT..C_NU:
  287. begin
  288. if byte(c.cr)=0 then
  289. Comment(V_error,'Wrong use of whole CR register for '+tempstr);
  290. cond2str := tempstr+gas_regname(newreg(R_SPECIALREGISTER,c.cr,R_SUBWHOLE));
  291. end;
  292. C_T,C_F,C_DNZT,C_DNZF,C_DZT,C_DZF:
  293. cond2str := tempstr+tostr(c.crbit);
  294. else
  295. cond2str := tempstr;
  296. end;
  297. end;
  298. end
  299. { we have a trap instruction }
  300. else
  301. begin
  302. internalerror(2002070601);
  303. { not yet implemented !!!!!!!!!!!!!!!!!!!!! }
  304. { case tempstr := 'tw';}
  305. end;
  306. end;
  307. end;
  308. {****************************************************************************}
  309. { PowerPC Instruction Writer }
  310. {****************************************************************************}
  311. Procedure TPPCInstrWriter.WriteInstruction(hp : tai);
  312. var op: TAsmOp;
  313. s: string;
  314. i: byte;
  315. sep: string[3];
  316. begin
  317. op:=taicpu(hp).opcode;
  318. if is_calljmp(op) then
  319. begin
  320. { direct BO/BI in op[0] and op[1] not supported, put them in condition! }
  321. case op of
  322. A_B,A_BA,A_BL,A_BLA:
  323. s:=#9+gas_op2str[op]+#9;
  324. A_BCTR,A_BCTRL,A_BLR,A_BLRL:
  325. s:=#9+gas_op2str[op]
  326. else
  327. begin
  328. s:=cond2str(op,taicpu(hp).condition);
  329. if (s[length(s)] <> #9) and
  330. (taicpu(hp).ops>0) then
  331. s := s + ',';
  332. end;
  333. end;
  334. if (taicpu(hp).ops>0) and (taicpu(hp).oper[0]^.typ<>top_none) then
  335. begin
  336. { first write the current contents of s, because the symbol }
  337. { may be 255 characters }
  338. owner.writer.AsmWrite(s);
  339. s:=getopstr_jmp(owner.asminfo,taicpu(hp).oper[0]^);
  340. end;
  341. end
  342. else
  343. { process operands }
  344. begin
  345. s:=#9+gas_op2str[op];
  346. if taicpu(hp).ops<>0 then
  347. begin
  348. {
  349. if not is_calljmp(op) then
  350. sep:=','
  351. else
  352. }
  353. sep:=#9;
  354. for i:=0 to taicpu(hp).ops-1 do
  355. begin
  356. // debug code
  357. // writeln(s);
  358. // writeln(taicpu(hp).fileinfo.line);
  359. s:=s+sep+getopstr(owner.asminfo,taicpu(hp).oper[i]^);
  360. sep:=',';
  361. end;
  362. end;
  363. end;
  364. owner.writer.AsmWriteLn(s);
  365. end;
  366. {****************************************************************************}
  367. { GNU PPC Assembler writer }
  368. {****************************************************************************}
  369. constructor TPPCGNUAssembler.CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean);
  370. begin
  371. inherited;
  372. InstrWriter := TPPCInstrWriter.create(self);
  373. end;
  374. function TPPCGNUAssembler.MakeCmdLine: TCmdStr;
  375. begin
  376. result := inherited MakeCmdLine;
  377. {$ifdef cpu64bitaddr}
  378. Replace(result,'$ARCH','-a64')
  379. {$else cpu64bitaddr}
  380. { MorphOS has an old 2.9.1 GNU AS, with a bunch of patches
  381. to support the system, and it doesn't know the -a32 argument }
  382. if target_info.system = system_powerpc_morphos then
  383. Replace(result,'$ARCH','')
  384. else
  385. Replace(result,'$ARCH','-a32');
  386. {$endif cpu64bitaddr}
  387. end;
  388. procedure TPPCGNUAssembler.WriteExtraHeader;
  389. var
  390. i : longint;
  391. begin
  392. if target_info.abi = abi_powerpc_elfv2 then
  393. writer.AsmWriteln(#9'.abiversion 2');
  394. for i:=0 to 31 do
  395. writer.AsmWriteln(#9'.set'#9'r'+tostr(i)+','+tostr(i));
  396. for i:=0 to 31 do
  397. writer.AsmWriteln(#9'.set'#9'f'+tostr(i)+','+tostr(i));
  398. end;
  399. {****************************************************************************}
  400. { GNU/Apple PPC Assembler writer }
  401. {****************************************************************************}
  402. constructor TPPCAppleGNUAssembler.CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean);
  403. begin
  404. inherited;
  405. InstrWriter := TPPCInstrWriter.create(self);
  406. end;
  407. function TPPCAppleGNUAssembler.MakeCmdLine: TCmdStr;
  408. begin
  409. result := inherited MakeCmdLine;
  410. {$ifdef cpu64bitaddr}
  411. Replace(result,'$ARCH','ppc64')
  412. {$else cpu64bitaddr}
  413. case current_settings.cputype of
  414. cpu_PPC7400:
  415. Replace(result,'$ARCH','ppc7400');
  416. cpu_PPC970:
  417. Replace(result,'$ARCH','ppc970');
  418. else
  419. Replace(result,'$ARCH','ppc')
  420. end;
  421. {$endif cpu64bitaddr}
  422. end;
  423. {****************************************************************************}
  424. { AIX PPC Assembler writer }
  425. {****************************************************************************}
  426. constructor TPPCAIXAssembler.CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean);
  427. var
  428. cur_sectype : TAsmSectionType;
  429. begin
  430. inherited;
  431. InstrWriter := TPPCInstrWriter.create(self);
  432. { Use 8-byte alignment as default for all sections }
  433. for cur_sectype:=low(TAsmSectionType) to high(TAsmSectionType) do
  434. max_alignment[cur_sectype]:=8;
  435. end;
  436. procedure TPPCAIXAssembler.WriteSection(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder;secalign:longint;
  437. secflags:TSectionFlags=SF_None;secprogbits:TSectionProgbits=SPB_None);
  438. begin
  439. secalign:=max_alignment[atype];
  440. Inherited WriteSection(atype,aname,aorder,secalign,secflags,secprogbits);
  441. end;
  442. procedure TPPCAIXAssembler.WriteAsmList;
  443. var
  444. cur_sectype : TAsmSectionType;
  445. cur_list : TAsmList;
  446. hal : tasmlisttype;
  447. hp : tai;
  448. max_al : longint;
  449. begin
  450. { Parse all asmlists to get maximum alignement used for all types }
  451. for hal:=low(TasmlistType) to high(TasmlistType) do
  452. begin
  453. if not (current_asmdata.asmlists[hal].empty) then
  454. begin
  455. cur_sectype:=sec_none;
  456. hp:=tai(current_asmdata.asmlists[hal].First);
  457. while assigned(hp) do
  458. begin
  459. case hp.typ of
  460. ait_align :
  461. begin
  462. if tai_align_abstract(hp).aligntype > max_alignment[cur_sectype] then
  463. begin
  464. max_alignment[cur_sectype]:=tai_align_abstract(hp).aligntype;
  465. current_asmdata.asmlists[hal].InsertAfter(tai_comment.Create(strpnew('Alignment put to '+tostr(tai_align_abstract(hp).aligntype))),hp);
  466. end;
  467. end;
  468. ait_section :
  469. begin
  470. cur_sectype:=tai_section(hp).sectype;
  471. if tai_section(hp).secalign > max_alignment[cur_sectype] then
  472. begin
  473. max_alignment[cur_sectype]:=tai_section(hp).secalign;
  474. current_asmdata.asmlists[hal].InsertAfter(tai_comment.Create(strpnew('Section '
  475. +sectionname(tai_section(hp).sectype,'',secorder_default)+' alignment put to '+tostr(tai_section(hp).secalign))),hp);
  476. end;
  477. end;
  478. end;
  479. hp:=tai(hp.next);
  480. end;
  481. end;
  482. end;
  483. { sec_data, sec_rodata and sec_bss all are converted into .data[RW],
  484. in WriteSection below,
  485. so we take the maximum alignment of the three }
  486. max_al:=max_alignment[sec_data];
  487. max_al:=max(max_al,max_alignment[sec_rodata]);
  488. max_al:=max(max_al,max_alignment[sec_bss]);
  489. max_alignment[sec_data]:=max_al;
  490. max_alignment[sec_rodata]:=max_al;
  491. max_alignment[sec_bss]:=max_al;
  492. Inherited WriteAsmList;
  493. end;
  494. procedure TPPCAIXAssembler.WriteExtraHeader;
  495. var
  496. i: longint;
  497. begin
  498. inherited WriteExtraHeader;
  499. { map cr registers to plain numbers }
  500. for i:=0 to 7 do
  501. writer.AsmWriteln(#9'.set'#9'cr'+tostr(i)+','+tostr(i));
  502. { Ensure .data and .rodata sections are aligned to 8-byte boundary,
  503. required for correct RTTI alignment.
  504. AIX assembler seems to only care for the first
  505. alignment value given }
  506. writer.AsmWriteln(#9'.csect .data[RW],'+sectionalignment_aix(sec_data,max_alignment[sec_data]));
  507. writer.AsmWriteln(#9'.csect _data.bss_[BS],'+sectionalignment_aix(sec_data,max_alignment[sec_data]));
  508. { .rodata is translated into .text[RO]
  509. see sectionname in aggas unit. }
  510. writer.AsmWriteln(#9'.csect .text[RO],'+sectionalignment_aix(sec_rodata_norel,max_alignment[sec_rodata_norel]));
  511. { make sure we always have a code and toc section,
  512. the linker expects that }
  513. writer.AsmWriteln(#9'.csect .text[PR],'+sectionalignment_aix(sec_code,max_alignment[sec_code]));
  514. { set _text_s, to be used by footer below }
  515. writer.AsmWriteln(#9'_text_s:');
  516. writer.AsmWriteln(#9'.toc');
  517. end;
  518. procedure TPPCAIXAssembler.WriteExtraFooter;
  519. begin
  520. inherited WriteExtraFooter;
  521. { link between data and text section }
  522. writer.AsmWriteln(#9'.csect .data[RW],3');
  523. {$ifdef cpu64bitaddr}
  524. writer.AsmWriteln('text_pos:'#9'.llong _text_s')
  525. {$else cpu64bitaddr}
  526. writer.AsmWriteln('text_pos:'#9'.long _text_s')
  527. {$endif cpu64bitaddr}
  528. end;
  529. procedure TPPCAIXAssembler.WriteDirectiveName(dir: TAsmDirective);
  530. begin
  531. case dir of
  532. asd_reference:
  533. writer.AsmWrite('.ref ');
  534. asd_weak_reference,
  535. asd_weak_definition:
  536. writer.AsmWrite('.weak ');
  537. else
  538. inherited WriteDirectiveName(dir);
  539. end;
  540. end;
  541. function TPPCAIXAssembler.sectionname(atype: TAsmSectiontype; const aname: string; aorder: TAsmSectionOrder): string;
  542. begin
  543. case atype of
  544. sec_code:
  545. result:='.csect .text[PR]';
  546. sec_data,
  547. sec_rodata,
  548. { don't use .bss[BS], causes relocation problems }
  549. sec_bss:
  550. result:='.csect .data[RW]';
  551. sec_rodata_norel:
  552. result:='.csect .text[RO]';
  553. sec_fpc:
  554. result:='.csect .fpc[RO]';
  555. sec_toc:
  556. result:='.toc';
  557. { automatically placed in the right section }
  558. sec_stab,
  559. sec_stabstr:
  560. result:='';
  561. else
  562. internalerror(2011122601);
  563. end;
  564. end;
  565. {*****************************************************************************
  566. Initialize
  567. *****************************************************************************}
  568. const
  569. as_ppc_gas_info : tasminfo =
  570. (
  571. id : as_gas;
  572. idtxt : 'AS';
  573. asmbin : 'as';
  574. {$ifdef cpu64bitaddr}
  575. asmcmd : '-a64 $ENDIAN -o $OBJ $EXTRAOPT $ASM';
  576. {$else cpu64bitaddr}
  577. asmcmd: '$ENDIAN -o $OBJ $EXTRAOPT $ARCH $ASM';
  578. {$endif cpu64bitaddr}
  579. 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];
  580. flags : [af_needar,af_smartlink_sections];
  581. labelprefix : '.L';
  582. comment : '# ';
  583. dollarsign: '$';
  584. );
  585. as_ppc_gas_legacy_info : tasminfo =
  586. (
  587. id : as_powerpc_gas_legacy;
  588. idtxt : 'AS-LEGACY';
  589. asmbin : 'as';
  590. {$ifdef cpu64bitaddr}
  591. asmcmd : '-a64 $ENDIAN -o $OBJ $EXTRAOPT $ASM';
  592. {$else cpu64bitaddr}
  593. asmcmd: '$ENDIAN -o $OBJ $EXTRAOPT $ARCH $ASM';
  594. {$endif cpu64bitaddr}
  595. supported_targets : [system_powerpc_morphos];
  596. flags : [af_needar];
  597. labelprefix : '.L';
  598. comment : '# ';
  599. dollarsign: '$';
  600. );
  601. as_ppc_gas_darwin_powerpc_info : tasminfo =
  602. (
  603. id : as_darwin;
  604. idtxt : 'AS-DARWIN';
  605. asmbin : 'as';
  606. asmcmd : '-o $OBJ $EXTRAOPT $ASM -arch $ARCH';
  607. supported_targets : [system_powerpc_darwin,system_powerpc64_darwin];
  608. flags : [af_needar,af_smartlink_sections,af_supports_dwarf,af_stabs_use_function_absolute_addresses];
  609. labelprefix : 'L';
  610. comment : '# ';
  611. dollarsign : '$';
  612. );
  613. as_ppc_aix_powerpc_info : tasminfo =
  614. (
  615. id : as_powerpc_xcoff;
  616. idtxt : 'AS-AIX';
  617. asmbin : 'as';
  618. { -u: allow using symbols before they are defined (when using native
  619. AIX assembler, ignore by GNU assembler)
  620. -mpwr5: we actually support Power3 and higher, but the AIX assembler
  621. has no parameter to select that one (only -mpwr3 and -mpwr5) }
  622. {$ifdef cpu64bitaddr}
  623. asmcmd : '-a64 -u -o $OBJ $EXTRAOPT $ASM -mpwr5';
  624. {$else cpu64bitaddr}
  625. asmcmd : '-u -o $OBJ $EXTRAOPT $ASM -mpwr5';
  626. {$endif cpu64bitaddr}
  627. supported_targets : [system_powerpc_aix,system_powerpc64_aix];
  628. flags : [af_needar,af_smartlink_sections,af_stabs_use_function_absolute_addresses];
  629. labelprefix : 'L';
  630. comment : '# ';
  631. dollarsign : '.'
  632. );
  633. as_ppc_gas_aix_powerpc_info : tasminfo =
  634. (
  635. id : as_gas_powerpc_xcoff;
  636. idtxt : 'GAS';
  637. asmbin : 'gas';
  638. { -u: allow using symbols before they are defined (when using native
  639. AIX assembler, ignore by GNU assembler)
  640. -mpwr5: we actually support Power3 and higher, but the AIX assembler
  641. has no parameter to select that one (only -mpwr3 and -mpwr5) }
  642. {$ifdef cpu64bitaddr}
  643. asmcmd : '-a64 -u -o $OBJ $EXTRAOPT $ASM -mpwr5';
  644. {$else cpu64bitaddr}
  645. asmcmd : '-a32 -u -o $OBJ $EXTRAOPT $ASM -mpwr5';
  646. {$endif cpu64bitaddr}
  647. supported_targets : [system_powerpc_aix,system_powerpc64_aix];
  648. flags : [af_needar,af_smartlink_sections,af_stabs_use_function_absolute_addresses];
  649. labelprefix : 'L';
  650. comment : '# ';
  651. dollarsign : '.'
  652. );
  653. as_ppc_clang_darwin_info : tasminfo =
  654. (
  655. id : as_clang;
  656. idtxt : 'CLANG';
  657. asmbin : 'clang';
  658. asmcmd : '-c -o $OBJ $EXTRAOPT -arch $ARCH $DARWINVERSION -x assembler $ASM';
  659. supported_targets : [system_powerpc_macos, system_powerpc_darwin, system_powerpc64_darwin];
  660. flags : [af_needar,af_smartlink_sections,af_supports_dwarf];
  661. labelprefix : 'L';
  662. comment : '# ';
  663. dollarsign: '$';
  664. );
  665. begin
  666. RegisterAssembler(as_ppc_gas_info,TPPCGNUAssembler);
  667. RegisterAssembler(as_ppc_gas_legacy_info,TPPCGNUAssembler);
  668. RegisterAssembler(as_ppc_gas_darwin_powerpc_info,TPPCAppleGNUAssembler);
  669. RegisterAssembler(as_ppc_clang_darwin_info,TPPCAppleGNUAssembler);
  670. RegisterAssembler(as_ppc_aix_powerpc_info,TPPCAIXAssembler);
  671. RegisterAssembler(as_ppc_gas_aix_powerpc_info,TPPCAIXAssembler);
  672. end.