agppcvasm.pas 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. {
  2. Copyright (c) 2016 by the Free Pascal development team
  3. This unit is the VASM assembler writer for PowerPC
  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 agppcvasm;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. aasmbase,systems,
  22. aasmtai,aasmdata,
  23. assemble,aggas,agppcgas,
  24. cpubase,cgutils,
  25. globtype;
  26. type
  27. tppcvasm = class(TPPCGNUassembler)
  28. protected
  29. function sectionattrs(atype:TAsmSectiontype):string; override;
  30. public
  31. constructor CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean); override;
  32. function MakeCmdLine: TCmdStr; override;
  33. procedure WriteExtraHeader; override;
  34. end;
  35. implementation
  36. uses
  37. cutils,cfileutl,globals,verbose,
  38. cgbase,
  39. cscript,
  40. itcpugas,cpuinfo,
  41. aasmcpu;
  42. {****************************************************************************}
  43. { VASM PPC Assembler writer }
  44. {****************************************************************************}
  45. constructor tppcvasm.CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean);
  46. begin
  47. inherited;
  48. InstrWriter := TPPCInstrWriter.create(self);
  49. end;
  50. function tppcvasm.sectionattrs(atype:TAsmSectiontype):string;
  51. begin
  52. case atype of
  53. sec_code, sec_fpc, sec_init, sec_fini:
  54. result:='acrx';
  55. sec_data:
  56. result:='adrw';
  57. sec_rodata, sec_rodata_norel:
  58. result:='adr';
  59. sec_bss, sec_threadvar:
  60. result:='aurw';
  61. sec_stab, sec_stabstr:
  62. result:='dr';
  63. else
  64. result:='';
  65. end;
  66. end;
  67. function tppcvasm.MakeCmdLine: TCmdStr;
  68. var
  69. objtype: string;
  70. begin
  71. result:=asminfo^.asmcmd;
  72. objtype:='-Felf';
  73. if (target_info.system in [system_powerpc_amiga, system_powerpc_morphos]) then
  74. begin
  75. Replace(result,'$ASM',maybequoted(ScriptFixFileName(Unix2AmigaPath(AsmFileName))));
  76. Replace(result,'$OBJ',maybequoted(ScriptFixFileName(Unix2AmigaPath(ObjFileName))));
  77. end
  78. else
  79. begin
  80. Replace(result,'$ASM',maybequoted(ScriptFixFileName(AsmFileName)));
  81. Replace(result,'$OBJ',maybequoted(ScriptFixFileName(ObjFileName)));
  82. end;
  83. Replace(result,'$OTYPE',objtype);
  84. Replace(result,'$EXTRAOPT',asmextraopt);
  85. end;
  86. procedure tppcvasm.WriteExtraHeader;
  87. begin
  88. { no-op, compared to the PPC GAS writer, because vasm defines
  89. the register symbols by default, so lets not redefine them }
  90. end;
  91. {*****************************************************************************
  92. Initialize
  93. *****************************************************************************}
  94. const
  95. as_powerpc_vasm_info : tasminfo =
  96. (
  97. id : as_powerpc_vasm;
  98. idtxt : 'VASM';
  99. asmbin : 'vasmppc_std';
  100. asmcmd: '-quiet $OTYPE -o $OBJ $EXTRAOPT $ASM';
  101. supported_targets : [system_powerpc_amiga,system_powerpc_morphos,system_powerpc_linux];
  102. flags : [af_needar,af_smartlink_sections];
  103. labelprefix : '.L';
  104. comment : '# ';
  105. dollarsign: '$';
  106. );
  107. begin
  108. RegisterAssembler(as_powerpc_vasm_info,tppcvasm);
  109. end.