itx86att.pas 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit contains the i386 AT&T 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 itx86att;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cginfo,cpubase;
  23. type
  24. TAttSuffix = (AttSufNONE,AttSufINT,AttSufFPU,AttSufFPUint);
  25. const
  26. {$ifdef x86_64}
  27. {x86att.inc contains the name for each x86-64 mnemonic}
  28. gas_op2str:op2strtable={$i x64att.inc}
  29. gas_needsuffix:array[tasmop] of TAttSuffix={$i x64atts.inc}
  30. {$else x86_64}
  31. {x86att.inc contains the name for each i386 mnemonic}
  32. gas_op2str:op2strtable={$i i386att.inc}
  33. gas_needsuffix:array[tasmop] of TAttSuffix={$i i386atts.inc}
  34. {$endif x86_64}
  35. {$ifdef x86_64}
  36. gas_opsize2str : array[topsize] of string[2] = ('',
  37. 'b','w','l','bw','bl','wl','bq','wq','lq',
  38. 's','l','q',
  39. 's','l','t','d','q','v','x',
  40. '','',''
  41. );
  42. {$else x86_64}
  43. gas_opsize2str : array[topsize] of string[2] = ('',
  44. 'b','w','l','bw','bl','wl',
  45. 's','l','q',
  46. 's','l','t','d','q','v','',
  47. '','',''
  48. );
  49. {$endif x86_64}
  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. att_regname_table : array[tregisterindex] of string[7] = (
  57. {r386att.inc contains the AT&T name of each register.}
  58. {$i r386att.inc}
  59. );
  60. att_regname_index : array[tregisterindex] of tregisterindex = (
  61. {r386ari.inc contains an index which sorts att_regname_table by
  62. ATT name.}
  63. {$i r386ari.inc}
  64. );
  65. function findreg_by_attname(const s:string):byte;
  66. var
  67. i,p : tregisterindex;
  68. begin
  69. {Binary search.}
  70. p:=0;
  71. i:=regnumber_count_bsstart;
  72. repeat
  73. if (p+i<=high(tregisterindex)) and (att_regname_table[att_regname_index[p+i]]<=s) then
  74. p:=p+i;
  75. i:=i shr 1;
  76. until i=0;
  77. if att_regname_table[att_regname_index[p]]=s then
  78. findreg_by_attname:=att_regname_index[p]
  79. else
  80. findreg_by_attname:=0;
  81. end;
  82. function gas_regnum_search(const s:string):Tregister;
  83. begin
  84. result:=regnumber_table[findreg_by_attname(s)];
  85. end;
  86. function gas_regname(r:Tregister):string;
  87. var
  88. p : tregisterindex;
  89. begin
  90. p:=findreg_by_number(r);
  91. if p<>0 then
  92. result:=att_regname_table[p]
  93. else
  94. result:='%'+generic_regname(r);
  95. end;
  96. end.
  97. {
  98. $Log$
  99. Revision 1.4 2003-09-03 15:55:02 peter
  100. * NEWRA branch merged
  101. Revision 1.3.2.6 2003/08/31 15:46:26 peter
  102. * more updates for tregister
  103. Revision 1.3.2.5 2003/08/31 13:50:16 daniel
  104. * Remove sorting and use pregenerated indexes
  105. * Some work on making things compile
  106. Revision 1.3.2.4 2003/08/29 17:29:00 peter
  107. * next batch of updates
  108. Revision 1.3.2.3 2003/08/29 09:41:25 daniel
  109. * Further mkx86reg development
  110. Revision 1.3.2.2 2003/08/28 18:35:08 peter
  111. * tregister changed to cardinal
  112. Revision 1.3.2.1 2003/08/27 19:55:54 peter
  113. * first tregister patch
  114. Revision 1.3 2003/08/18 11:49:47 daniel
  115. * Made ATT asm writer work with -sr
  116. Revision 1.2 2003/07/06 15:31:21 daniel
  117. * Fixed register allocator. *Lots* of fixes.
  118. Revision 1.1 2003/05/22 21:33:08 peter
  119. * i386 att instruction table moved to separate unit
  120. }