itcpugas.pas 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Mazen NEIFER
  4. This unit contains the SPARC GAS instruction tables
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit itcpugas;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cpubase,cgbase;
  23. const
  24. gas_op2str : array[tasmop] of string[14] = ({$INCLUDE strinst.inc});
  25. function gas_regnum_search(const s:string):Tregister;
  26. function gas_regname(r:Tregister):string;
  27. implementation
  28. uses
  29. cutils,verbose;
  30. const
  31. gas_regname_table : array[tregisterindex] of string[7] = (
  32. {$i rspstd.inc}
  33. );
  34. gas_regname_index : array[tregisterindex] of tregisterindex = (
  35. {$i rspsri.inc}
  36. );
  37. function findreg_by_gasname(const s:string):tregisterindex;
  38. var
  39. i,p : tregisterindex;
  40. begin
  41. {Binary search.}
  42. p:=0;
  43. i:=regnumber_count_bsstart;
  44. repeat
  45. if (p+i<=high(tregisterindex)) and (gas_regname_table[gas_regname_index[p+i]]<=s) then
  46. p:=p+i;
  47. i:=i shr 1;
  48. until i=0;
  49. if gas_regname_table[gas_regname_index[p]]=s then
  50. findreg_by_gasname:=gas_regname_index[p]
  51. else
  52. findreg_by_gasname:=0;
  53. end;
  54. function gas_regnum_search(const s:string):Tregister;
  55. begin
  56. result:=regnumber_table[findreg_by_gasname(s)];
  57. end;
  58. function gas_regname(r:Tregister):string;
  59. var
  60. p : longint;
  61. begin
  62. { Double uses the same table as single }
  63. case getsubreg(r) of
  64. R_SUBFD:
  65. setsubreg(r,R_SUBFS);
  66. R_SUBL,R_SUBW,R_SUBD,R_SUBQ:
  67. setsubreg(r,R_SUBD);
  68. end;
  69. p:=findreg_by_number(r);
  70. if p<>0 then
  71. result:=gas_regname_table[p]
  72. else
  73. result:=generic_regname(r);
  74. end;
  75. end.
  76. {
  77. $Log$
  78. Revision 1.5 2004-09-21 17:25:13 peter
  79. * paraloc branch merged
  80. Revision 1.4.4.1 2004/09/20 20:42:37 peter
  81. * use R_SUBD for all int registers instead of R_SUBNONE
  82. Revision 1.4 2004/08/24 21:02:33 florian
  83. * fixed longbool(<int64>) on sparc
  84. Revision 1.3 2004/06/20 08:55:32 florian
  85. * logs truncated
  86. Revision 1.2 2004/01/12 16:39:41 peter
  87. * sparc updates, mostly float related
  88. }