itcpugas.pas 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit contains the RiscV64 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. { 64-bit }
  37. 'addiw','slliw','srliw','sraiw',
  38. 'addw','sllw','srlw','subw','sraw',
  39. 'ld','sd','lwu',
  40. { m-extension }
  41. 'mul','mulh','mulhsu','mulhu',
  42. 'div','divu','rem','remu',
  43. { 64-bit }
  44. 'mulw',
  45. 'divw','divuw','remw','remuw',
  46. { a-extension }
  47. 'lr.w','sc.w','amoswap.w','amoadd.w','amoxor.w','amoand.w',
  48. 'amoor.w','amomin.w','amomax.w','amominu.w','amomaxu.w',
  49. { 64-bit }
  50. 'lr.d','sc.d','amoswap.d','amoadd.d','amoxor.d','amoand.d',
  51. 'amoor.d','amomin.d','amomax.d','amominu.d','amomaxu.d',
  52. { f-extension }
  53. 'flw','fsw',
  54. 'fmadd.s','fmsub.s','fnmsub.s','fnmadd.s',
  55. 'fadd.s','fsub.s','fmul.s','fdiv.s',
  56. 'fsqrt.s','fsgnj.s','fsgnjn.s','fsgnjx.s',
  57. 'fmin.s','fmax.s',
  58. 'fmv.x.s','feq.s','flt.s','fle.s','fclass.s',
  59. 'fcvt.w.s','fcvt.wu.s','fcvt.s.w','fcvt.s.wu',
  60. 'fmv.s.x',
  61. 'frcsr','frrm','frflags','fscsr','fsrm',
  62. 'fsflags','fsrmi','fsflagsi',
  63. { 64-bit }
  64. 'fcvt.l.s','fcvt.lu.s',
  65. 'fcvt.s.l','fcvt.s.lu',
  66. { d-extension }
  67. 'fld','fsd',
  68. 'fmadd.d','fmsub.d','fnmsub.d','fnmadd.d',
  69. 'fadd.d','fsub.d','fmul.d','fdiv.d',
  70. 'fsqrt.d','fsgnj.d','fsgnjn.d','fsgnjx.d',
  71. 'fmin.d','fmax.d',
  72. 'feq.d','flt.d','fle.d','fclass.d',
  73. 'fcvt.d.s','fcvt.s.d',
  74. 'fcvt.w.d','fcvt.wu.d','fcvt.d.w','fcvt.d.wu',
  75. { 64-bit }
  76. 'fcvt.l.d','fcvt.lu.d','fmv.x.d',
  77. 'fcvt.d.l','fcvt.d.lu','fmv.d.x',
  78. { Machine mode }
  79. 'mret','hret','sret','uret',
  80. 'wfi',
  81. { Supervisor mode }
  82. 'sfence.vm'
  83. );
  84. function gas_regnum_search(const s: string): Tregister;
  85. function gas_regname(r: Tregister): string;
  86. implementation
  87. uses
  88. globtype,globals,aasmbase,
  89. cutils,verbose, systems,
  90. rgbase;
  91. const
  92. gas_regname_table : TRegNameTable = (
  93. {$i rrv32std.inc}
  94. );
  95. gas_regname_index : array[tregisterindex] of tregisterindex = (
  96. {$i rrv32sri.inc}
  97. );
  98. function findreg_by_gasname(const s:string):tregisterindex;
  99. var
  100. i,p : tregisterindex;
  101. begin
  102. {Binary search.}
  103. p:=0;
  104. i:=regnumber_count_bsstart;
  105. repeat
  106. if (p+i<=high(tregisterindex)) and (gas_regname_table[gas_regname_index[p+i]]<=s) then
  107. p:=p+i;
  108. i:=i shr 1;
  109. until i=0;
  110. if gas_regname_table[gas_regname_index[p]]=s then
  111. findreg_by_gasname:=gas_regname_index[p]
  112. else
  113. findreg_by_gasname:=0;
  114. end;
  115. function gas_regnum_search(const s:string):Tregister;
  116. begin
  117. result:=regnumber_table[findreg_by_gasname(s)];
  118. end;
  119. function gas_regname(r:Tregister):string;
  120. var
  121. p : tregisterindex;
  122. begin
  123. p:=findreg_by_number(r);
  124. if p<>0 then
  125. result:=gas_regname_table[p]
  126. else
  127. result:=generic_regname(r);
  128. end;
  129. end.