itcpugas.pas 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit contains the PowerPC 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] = ('<none>',
  25. 'add','add.','addo','addo.','addc','addc.','addco','addco.',
  26. 'adde','adde.','addeo','addeo.','addi','addic','addic.','addis',
  27. 'addme','addme.','addmeo','addmeo.','addze','addze.','addzeo',
  28. 'addzeo.','and','and.','andc','andc.','andi.','andis.','b',
  29. 'ba','bl','bla','bc','bca','bcl','bcla','bcctr','bcctrl','bclr',
  30. 'bclrl','cmp','cmpi','cmpl','cmpli','cntlzw','cntlzw.','crand',
  31. 'crandc','creqv','crnand','crnor','cror','crorc','crxor','dcba',
  32. 'dcbf','dcbi','dcbst','dcbt','dcbtst','dcbz','divw','divw.','divwo','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','hbrx','lhz','lhzu','lhzux','lhzx','lmw',
  45. 'lswi','lswx','lwarx','lwbrx','lwz','lwzu','lwzux','lwzx','mcrf',
  46. 'mcrfs','mcrxr','lcrxe','mfcr','mffs','maffs.','mfmsr','mfspr','mfsr',
  47. 'mfsrin','mftb','mtcrf','mtfd0','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.', 'blr', 'bctr', 'blrl', 'bctrl', 'crset', 'crclr', 'crmove',
  68. 'crnot', 'mt', 'mf','nop', 'li', 'lis', 'la', 'mr','mr.','not', 'mtcr', 'mtlr', 'mflr',
  69. 'mtctr', 'mfctr');
  70. function gas_regnum_search(const s:string):Tregister;
  71. function gas_regname(r:Tregister):string;
  72. implementation
  73. uses
  74. globtype,globals,
  75. cutils,verbose, systems;
  76. const
  77. gas_regname_table : array[tregisterindex] of string[7] = (
  78. {$i rppcgas.inc}
  79. );
  80. gas_regname_short_table : array[tregisterindex] of string[7] = (
  81. {$i rppcgss.inc}
  82. );
  83. gas_regname_index : array[tregisterindex] of tregisterindex = (
  84. {$i rppcgri.inc}
  85. );
  86. function findreg_by_gasname(const s:string):tregisterindex;
  87. var
  88. i,p : tregisterindex;
  89. begin
  90. {Binary search.}
  91. p:=0;
  92. i:=regnumber_count_bsstart;
  93. repeat
  94. if (p+i<=high(tregisterindex)) and (gas_regname_table[gas_regname_index[p+i]]<=s) then
  95. p:=p+i;
  96. i:=i shr 1;
  97. until i=0;
  98. if gas_regname_table[gas_regname_index[p]]=s then
  99. findreg_by_gasname:=gas_regname_index[p]
  100. else
  101. findreg_by_gasname:=0;
  102. end;
  103. function gas_regnum_search(const s:string):Tregister;
  104. begin
  105. result:=regnumber_table[findreg_by_gasname(s)];
  106. end;
  107. function gas_regname(r:Tregister):string;
  108. var
  109. p : longint;
  110. begin
  111. p:=findreg_by_number(r);
  112. if p<>0 then
  113. if (cs_create_smart in aktmoduleswitches) and
  114. (target_info.system <> system_powerpc_darwin) then
  115. result:=gas_regname_short_table[p]
  116. else
  117. result:=gas_regname_table[p]
  118. else
  119. result:=generic_regname(r);
  120. end;
  121. end.
  122. {
  123. $Log$
  124. Revision 1.4 2004-01-04 21:18:10 jonas
  125. + as_darwin assembler type (labels start with L)
  126. * never generate register->number mappings for Darwin
  127. * always use real register names for Darwin
  128. Revision 1.3 2003/12/10 22:19:27 florian
  129. + short gas register names for smartlinking added
  130. Revision 1.2 2003/11/15 19:00:10 florian
  131. * fixed ppc assembler reader
  132. Revision 1.1 2003/11/12 16:05:40 florian
  133. * assembler readers OOPed
  134. + typed currency constants
  135. + typed 128 bit float constants if the CPU supports it
  136. Revision 1.2 2003/10/01 20:34:49 peter
  137. * procinfo unit contains tprocinfo
  138. * cginfo renamed to cgbase
  139. * moved cgmessage to verbose
  140. * fixed ppc and sparc compiles
  141. Revision 1.1 2003/09/03 19:35:24 peter
  142. * powerpc compiles again
  143. }