itcpugas.pas 3.9 KB

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