itcpugas.pas 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit contains the Risc-V32 GAS instruction tables
  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 itcpugas;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cpubase,cgbase;
  22. const
  23. gas_op2str: array[tasmop] of string[14] = ('<none>',
  24. 'lui','auipc','jal','jalr',
  25. 'b','lb','lh','lw','lbu','lhu',
  26. 'sb','sh','sw',
  27. 'addi','slti','sltiu',
  28. 'xori','ori','andi',
  29. 'slli','srli','srai',
  30. 'add','sub','sll','slt','sltu',
  31. 'xor','srl','sra','or','and',
  32. 'fence','fence.i',
  33. 'ecall','ebreak',
  34. 'csrrw','csrrs','csrrc','csrrwi','csrrsi','csrrci',
  35. { m-extension }
  36. 'mul','mulh','mulhsu','mulhu',
  37. 'div','divu','rem','remu',
  38. { a-extension }
  39. 'lr.w','sc.w','amoswap.w','amoadd.w','amoxor.w','amoand.w',
  40. 'amoor.w','amomin.w','amomax.w','amominu.w','amomaxu.w',
  41. { f-extension }
  42. 'flw','fsw',
  43. 'fmadd.s','fmsub.s','fnmsub.s','fnmadd.s',
  44. 'fadd.s','fsub.s','fmul.s','fdiv.s',
  45. 'fsqrt.s','fsgnj.s','fsgnjn.s','fsgnjx.s',
  46. 'fmin.s','fmax.s',
  47. 'fmv.x.s','feq.s','flt.s','fle.s','fclass.s',
  48. 'fcvt.w.s','fcvt.wu.s','fcvt.s.w','fcvt.s.wu',
  49. 'fmv.s.x',
  50. 'frcsr','frrm','frflags','fscsr','fsrm',
  51. 'fsflags','fsrmi','fsflagsi',
  52. { d-extension }
  53. 'fld','fsd',
  54. 'fmadd.d','fmsub.d','fnmsub.d','fnmadd.d',
  55. 'fadd.d','fsub.d','fmul.d','fdiv.d',
  56. 'fsqrt.d','fsgnj.d','fsgnjn.d','fsgnjx.d',
  57. 'fmin.d','fmax.d',
  58. 'feq.d','flt.d','fle.d','fclass.d',
  59. 'fcvt.d.s','fcvt.s.d',
  60. 'fcvt.w.d','fcvt.wu.d','fcvt.d.w','fcvt.d.wu',
  61. { Machine mode }
  62. 'mret','hret','sret','uret',
  63. 'wfi',
  64. { Supervisor mode }
  65. 'sfence.vm'
  66. );
  67. function gas_regnum_search(const s:string):Tregister;
  68. function gas_regname(r:Tregister):string;
  69. implementation
  70. uses
  71. globtype,globals,aasmbase,
  72. cutils,verbose, systems,
  73. rgbase;
  74. const
  75. gas_regname_table : TRegNameTable = (
  76. {$i rrv32std.inc}
  77. );
  78. gas_regname_index : array[tregisterindex] of tregisterindex = (
  79. {$i rrv32sri.inc}
  80. );
  81. function findreg_by_gasname(const s:string):tregisterindex;
  82. var
  83. i,p : tregisterindex;
  84. begin
  85. {Binary search.}
  86. p:=0;
  87. i:=regnumber_count_bsstart;
  88. repeat
  89. if (p+i<=high(tregisterindex)) and (gas_regname_table[gas_regname_index[p+i]]<=s) then
  90. p:=p+i;
  91. i:=i shr 1;
  92. until i=0;
  93. if gas_regname_table[gas_regname_index[p]]=s then
  94. findreg_by_gasname:=gas_regname_index[p]
  95. else
  96. findreg_by_gasname:=0;
  97. end;
  98. function gas_regnum_search(const s:string):Tregister;
  99. begin
  100. result:=regnumber_table[findreg_by_gasname(s)];
  101. end;
  102. function gas_regname(r:Tregister):string;
  103. var
  104. p : tregisterindex;
  105. begin
  106. p:=findreg_by_number(r);
  107. if p<>0 then
  108. result:=gas_regname_table[p]
  109. else
  110. result:=generic_regname(r);
  111. end;
  112. end.