itcpugas.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. {
  2. Copyright (c) 1998-2005 by Florian Klaempfl
  3. This unit contains the MIPS 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. { Standard opcode string table (for each tasmop enumeration). The
  24. opcode strings should conform to the names as defined by the
  25. processor manufacturer.
  26. }
  27. gas_op2str : op2strtable = (
  28. 'abs_d','abs_s','add','add_d','add_s','addi','addiu','addu',
  29. 'and','andi','bc1f','bc1fl','bc1t','bc1tl','bc2f','bc2fl',
  30. 'bc2t','bc2tl','beq','beql','bgez','bgezal','bgezall','bgezl',
  31. 'bgtz','bgtzl','blez','blezl','bltz','bltzal','bltzall','bltzl',
  32. 'bne','bnel','break','c_cond_d','c_cond_s','cache','ceil_w_d','ceil_w_s',
  33. 'cfc1','cfc2','clo','clz','cop2','ctc1','ctc2','cvt_d_s',
  34. 'cvt_d_w','cvt_s_d','cvt_s_w','cvt_w_d','cvt_w_s','div','div_d','div_s',
  35. 'divu','eret','floor_w_d','floor_w_s','j','jal','jalr','jr',
  36. 'lb','lbu','ldc1','ldc2','lh','lhu','ll','lui',
  37. 'lw','lwc1','lwc2','lwl','lwr','madd','maddu','mfc0',
  38. 'mfc1','mfc2','mfhi','mflo','mov_d','mov_s','movf','movf_d',
  39. 'movf_s','movn','movn_d','movn_s','movt','movt_d','movt_s','movz',
  40. 'movz_d','movz_s','msub','msubu','mtc0','mtc1','mtc2','mthi',
  41. 'mtlo','mul','mul_d','mul_s','mult','multu','neg_d','neg_s',
  42. 'nor','or','ori','pref','round_w_d','round_w_s','sb','sc',
  43. 'sdc1','sdc2','sh','sll','sllv','slt','slti','sltiu',
  44. 'sltu','sqrt_d','sqrt_s','sra','srav','srl','srlv','ssnop',
  45. 'sub','sub_d','sub_s','subu','sw','swc1','swc2','swl',
  46. 'swr','sync','syscall','teq','teqi','tge','tgei','tgeiu',
  47. 'tgeu','tlbp','tlbr','tlbwi','tlbwr','tlt','tlti','tltiu',
  48. 'tltu','tne','tnei','trunc_w_d','trunc_w_s','wait','xor','xori'
  49. );
  50. function gas_regnum_search(const s:string):Tregister;
  51. function gas_regname(r:Tregister):string;
  52. implementation
  53. uses
  54. cutils,verbose;
  55. const
  56. gas_regname_table : array[tregisterindex] of string[7] = (
  57. {$i rmipsgas.inc}
  58. );
  59. gas_regname_index : array[tregisterindex] of tregisterindex = (
  60. {$i rmipssri.inc}
  61. );
  62. function findreg_by_gasname(const s:string):tregisterindex;
  63. var
  64. i,p : tregisterindex;
  65. begin
  66. {Binary search.}
  67. p:=0;
  68. i:=regnumber_count_bsstart;
  69. repeat
  70. if (p+i<=high(tregisterindex)) and (gas_regname_table[gas_regname_index[p+i]]<=s) then
  71. p:=p+i;
  72. i:=i shr 1;
  73. until i=0;
  74. if gas_regname_table[gas_regname_index[p]]=s then
  75. findreg_by_gasname:=gas_regname_index[p]
  76. else
  77. findreg_by_gasname:=0;
  78. end;
  79. function gas_regnum_search(const s:string):Tregister;
  80. begin
  81. result:=regnumber_table[findreg_by_gasname(s)];
  82. end;
  83. function gas_regname(r:Tregister):string;
  84. var
  85. p : tregisterindex;
  86. begin
  87. p:=findreg_by_number(r);
  88. if p<>0 then
  89. result:=gas_regname_table[p]
  90. else
  91. result:=generic_regname(r);
  92. end;
  93. end.