2
0

itcpugas.pas 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit contains the PowerPC 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. 'add', 'add.', 'addo', 'addo.', 'addc', 'addc.', 'addco', 'addco.',
  25. 'adde', 'adde.', 'addeo', 'addeo.', 'addi', 'addic', 'addic.', 'addis',
  26. 'addme', 'addme.', 'addmeo', 'addmeo.', 'addze', 'addze.', 'addzeo',
  27. 'addzeo.', 'and', 'and.', 'andc', 'andc.', 'andi.', 'andis.', 'b',
  28. 'ba', 'bl', 'bla', 'bc', 'bca', 'bcl', 'bcla', 'bcctr', 'bcctrl', 'bclr',
  29. 'bclrl', 'cmp', 'cmpi', 'cmpl', 'cmpli', 'cntlzw', 'cntlzw.', 'crand',
  30. 'crandc', 'creqv', 'crnand', 'crnor', 'cror', 'crorc', 'crxor', 'dcba',
  31. 'dcbf', 'dcbi', 'dcbst', 'dcbt', 'dcbtst', 'dcbz', 'divw', 'divw.', 'divwo',
  32. 'divwo.',
  33. 'divwu', 'divwu.', 'divwuo', 'divwuo.', 'eciwx', 'ecowx', 'eieio', 'eqv',
  34. 'eqv.', 'extsb', 'extsb.', 'extsh', 'extsh.', 'fabs', 'fabs.', 'fadd',
  35. 'fadd.', 'fadds', 'fadds.', 'fcmpo', 'fcmpu', 'fctiw', 'fctiw.', 'fctiwz',
  36. 'fctiwz.', 'fdiv', 'fdiv.', 'fdivs', 'fdivs.', 'fmadd', 'fmadd.', 'fmadds',
  37. 'fmadds.', 'fmr', 'fmsub', 'fmsub.', 'fmsubs', 'fmsubs.', 'fmul', 'fmul.',
  38. 'fmuls', 'fmuls.', 'fnabs', 'fnabs.', 'fneg', 'fneg.', 'fnmadd',
  39. 'fnmadd.', 'fnmadds', 'fnmadds.', 'fnmsub', 'fnmsub.', 'fnmsubs',
  40. 'fnmsubs.', 'fres', 'fres.', 'frsp', 'frsp.', 'frsqrte', 'frsqrte.',
  41. 'fsel', 'fsel.', 'fsqrt', 'fsqrt.', 'fsqrts', 'fsqrts.', 'fsub', 'fsub.',
  42. 'fsubs', 'fsubs.', 'icbi', 'isync', 'lbz', 'lbzu', 'lbzux', 'lbzx',
  43. 'lfd', 'lfdu', 'lfdux', 'lfdx', 'lfs', 'lfsu', 'lfsux', 'lfsx', 'lha',
  44. 'lhau', 'lhaux', 'lhax', 'lhbrx', 'lhz', 'lhzu', 'lhzux', 'lhzx', 'lmw',
  45. 'lswi', 'lswx', 'lwarx', 'lwbrx', 'lwz', 'lwzu', 'lwzux', 'lwzx', 'mcrf',
  46. 'mcrfs', 'mcrxr', 'mfcr', 'mffs', 'mffs.', 'mfmsr', 'mfspr', 'mfsr',
  47. 'mfsrin', 'mftb', 'mtcrf', 'mtfsb0', 'mtfsb1', 'mtfsf', 'mtfsf.',
  48. 'mtfsfi', 'mtfsfi.', 'mtmsr', 'mtspr', 'mtsr', 'mtsrin', 'mulhw',
  49. 'mulhw.', 'mulhwu', 'mulhwu.', 'mulli', 'mullw', 'mullw.', 'mullwo',
  50. 'mullwo.', 'nand', 'nand.', 'neg', 'neg.', 'nego', 'nego.', 'nor', 'nor.',
  51. 'or', 'or.', 'orc', 'orc.', 'ori', 'oris', 'rfi', 'rlwimi', 'rlwimi.',
  52. 'rlwinm', 'rlwinm.', 'rlwnm', 'sc', 'slw', 'slw.', 'sraw', 'sraw.',
  53. 'srawi', 'srawi.', 'srw', 'srw.', 'stb', 'stbu', 'stbux', 'stbx', 'stfd',
  54. 'stfdu', 'stfdux', 'stfdx', 'stfiwx', 'stfs', 'stfsu', 'stfsux', 'stfsx',
  55. 'sth', 'sthbrx', 'sthu', 'sthux', 'sthx', 'stmw', 'stswi', 'stswx', 'stw',
  56. 'stwbrx', 'stwcx.', 'stwu', 'stwux', 'stwx', 'subf', 'subf.', 'subfo',
  57. 'subfo.', 'subfc', 'subc.', 'subfco', 'subfco.', 'subfe', 'subfe.',
  58. 'subfeo', 'subfeo.', 'subfic', 'subfme', 'subfme.', 'subfmeo', 'subfmeo.',
  59. 'subfze', 'subfze.', 'subfzeo', 'subfzeo.', 'sync', 'tlbia', 'tlbie',
  60. 'tlbsync', 'tw', 'twi', 'xor', 'xor.', 'xori', 'xoris',
  61. { some simplified mnemonics }
  62. 'subi', 'subis', 'subic', 'subic.', 'sub', 'sub.', 'subo', 'subo.',
  63. 'subc', 'subc.', 'subco', 'subco.', 'cmpwi', 'cmpw', 'cmplwi', 'cmplw',
  64. 'extlwi', 'extlwi.', 'extrwi', 'extrwi.', 'inslwi', 'inslwi.', 'insrwi',
  65. 'insrwi.', 'rotlwi', 'rotlwi.', 'rotlw', 'rotlw.', 'slwi', 'slwi.',
  66. 'srwi', 'srwi.', 'clrlwi', 'clrlwi.', 'clrrwi', 'clrrwi.', 'clrslwi',
  67. 'clrslwi.', 'bf', 'bt', 'blr', 'bctr', 'blrl', 'bctrl', 'crset', 'crclr', 'crmove',
  68. 'crnot', 'mt', 'mf', 'nop', 'li', 'lis', 'la', 'mr', 'mr.', 'not', 'mtcr',
  69. 'mtlr', 'mflr',
  70. 'mtctr', 'mfctr',
  71. 'extsw', 'rldimi',
  72. 'std', 'stdu', 'stdx', 'stdux',
  73. 'ld', 'ldu', 'ldx', 'ldux',
  74. 'cmpd', 'cmpdi', 'cmpld', 'cmpldi',
  75. 'srdi', 'sradi',
  76. 'sldi',
  77. 'rldcl', 'rldicl',
  78. 'divdu', 'divdu.', 'divd', 'divd.', 'mulld', 'mulld.', 'mulhd', 'mulhd.', 'srad', 'sld', 'srd',
  79. 'divduo.', 'divdo.',
  80. 'lwa', 'lwax', 'lwaux',
  81. 'fcfid',
  82. 'ldarx', 'stdcx.', 'cntlzd',
  83. 'lvx', 'stvx',
  84. 'mulldo', 'mulldo.', 'mulhdu', 'mulhdu.',
  85. 'mfxer',
  86. 'fctid', 'fctid.', 'fctidz', 'fctidz.',
  87. 'extrdi', 'extrdi.', 'insrdi', 'insrdi.',
  88. 'lwsync');
  89. function gas_regnum_search(const s: string): Tregister;
  90. function gas_regname(r: Tregister): string;
  91. implementation
  92. uses
  93. globtype, globals,aasmbase,
  94. cutils, verbose, systems;
  95. const
  96. gas_regname_table: array[tregisterindex] of string[7] = (
  97. {$I rppcgas.inc}
  98. );
  99. gas_regname_short_table: array[tregisterindex] of string[7] = (
  100. {$I rppcgss.inc}
  101. );
  102. gas_regname_index: array[tregisterindex] of tregisterindex = (
  103. {$I rppcgri.inc}
  104. );
  105. function findreg_by_gasname(const s: string): tregisterindex;
  106. var
  107. i, p: tregisterindex;
  108. begin
  109. {Binary search.}
  110. p := 0;
  111. i := regnumber_count_bsstart;
  112. repeat
  113. if (p + i <= high(tregisterindex)) and (gas_regname_table[gas_regname_index[p + i]] <= s) then
  114. p := p + i;
  115. i := i shr 1;
  116. until i = 0;
  117. if gas_regname_table[gas_regname_index[p]] = s then
  118. findreg_by_gasname := gas_regname_index[p]
  119. else
  120. findreg_by_gasname := 0;
  121. end;
  122. function gas_regnum_search(const s: string): Tregister;
  123. begin
  124. result := regnumber_table[findreg_by_gasname(s)];
  125. end;
  126. function gas_regname(r: Tregister): string;
  127. var
  128. p: longint;
  129. begin
  130. p := findreg_by_number(r);
  131. if p <> 0 then
  132. if create_smartlink_library and
  133. not(target_info.system = system_powerpc64_darwin) then
  134. result := gas_regname_short_table[p]
  135. else
  136. result := gas_regname_table[p]
  137. else
  138. result := generic_regname(r);
  139. end;
  140. end.