itcpugas.pas 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. {
  2. Copyright (c) 1998-2012 by Florian Klaempfl and others
  3. This unit contains the WebAssembly 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. itcpuwasm;
  23. const
  24. { Standard opcode string table (for each tasmop enumeration). The
  25. opcode strings should conform to the names as defined by the
  26. processor manufacturer.
  27. }
  28. gas_op2str : op2strtable = (
  29. '<none>',
  30. // control flow
  31. 'block', 'loop', 'br', 'br_if', 'br_table', 'if', 'else', 'end_block',
  32. 'end_loop', 'end_if', 'end_function', 'return', 'unreachable',
  33. // basic
  34. 'nop', 'drop', 'i32.const', 'i64.const', 'f32.const', 'f64.const',
  35. 'local.get', 'local.set', 'local.tee', 'global.get', 'global.set',
  36. 'select', 'call', 'call_indirect',
  37. // integer
  38. 'i32.add', 'i64.add', 'i32.sub', 'i64.sub', 'i32.mul', 'i64.mul',
  39. 'i32.div_s', 'i64.div_s', 'i32.div_u', 'i64.div_u', 'i32.rem_s', 'i64.rem_s',
  40. 'i32.rem_u', 'i64.rem_u', 'i32.and', 'i64.and', 'i32.or', 'i64.or',
  41. 'i32.xor', 'i64.xor', 'i32.shl', 'i64.shl', 'i32.shr_s', 'i64.shr_s',
  42. 'i32.shr_u', 'i64.shr_u', 'i32.rotl', 'i64.rotl', 'i32.rotr', 'i64.rotr',
  43. 'i32.clz', 'i64.clz', 'i32.ctz', 'i64.ctz', 'i32.popcnt', 'i64.popcnt',
  44. 'i32.eqz', 'i64.eqz',
  45. // floating point
  46. 'f32.add', 'f64.add', 'f32.sub', 'f64.sub', 'f32.mul', 'f64.mul',
  47. 'f32.div', 'f64.div', 'f32.sqrt', 'f64.sqrt', 'f32.min', 'f64.min',
  48. 'f32.max', 'f64.max', 'f32.ceil', 'f64.ceil', 'f32.floor', 'f64.floor',
  49. 'f32.trunc', 'f64.trunc', 'f32.nearest', 'f64.nearest', 'f32.abs', 'f64.abs',
  50. 'f32.neg', 'f64.neg', 'f32.copysign', 'f64.copysign',
  51. // integer compare
  52. 'i32.eq', 'i64.eq', 'i32.ne', 'i64.ne', 'i32.lt_s', 'i64.lt_s',
  53. 'i32.lt_u', 'i64.lt_u', 'i32.le_s', 'i64.le_s', 'i32.le_u', 'i64.le_u',
  54. 'i32.gt_s', 'i64.gt_s', 'i32.gt_u', 'i64.gt_u', 'i32.ge_s', 'i64.ge_s',
  55. 'i32.ge_u', 'i64.ge_u',
  56. // floating point compare
  57. 'f32.eq', 'f64.eq', 'f32.ne', 'f64.ne', 'f32.lt', 'f64.lt',
  58. 'f32.le', 'f64.le', 'f32.gt', 'f64.gt', 'f32.ge', 'f64.gt',
  59. // conversion
  60. 'i32.wrap_i64', 'i64.extend_i32_s', 'i64.extend_i32_u',
  61. 'i32.extend8_s','i32.extend16_s','i64.extend8_s','i64.extend16_s','i64.extend32_s',
  62. 'i32.trunc_f32_s', 'i32.trunc_f64_s', 'i64.trunc_f32_s', 'i64.trunc_f64_s',
  63. 'i32.trunc_f32_u', 'i32.trunc_f64_u', 'i64.trunc_f32_u', 'i64.trunc_f64_u',
  64. 'f32.demote_f64', 'f64.promote_f32',
  65. 'f32.convert_i32_s', 'f32.convert_i64_s', 'f64.convert_i32_s', 'f64.convert_i64_s',
  66. 'f32.convert_i32_u', 'f32.convert_i64_u', 'f64.convert_i32_u', 'f64.convert_i64_u',
  67. 'i32.reinterpret_f32', 'i64.reinterpret_f64', 'f32.reinterpret_i32', 'f64.reinterpret_i64',
  68. // load/store
  69. 'i32.load', 'i64.load', 'f32.load', 'f64.load',
  70. 'i32.store', 'i64.store', 'f32.store', 'f64.store',
  71. 'i32.load8_s', 'i32.load16_s', 'i64.load8_s', 'i64.load16_s', 'i64.load32_s',
  72. 'i32.load8_u', 'i32.load16_u', 'i64.load8_u', 'i64.load16_u', 'i64.load32_u',
  73. 'i32.store8', 'i32.store16', 'i64.store8', 'i64.store16', 'i64.store32',
  74. // additional memory
  75. 'memory.grow 0', 'memory.size 0',
  76. // bulk memory operations
  77. 'memory.copy 0,0', 'memory.fill 0',
  78. // exceptions
  79. 'try','catch','catch_all','delegate','throw','rethrow','end_try'
  80. );
  81. gas_wasm_basic_type_str : array [TWasmBasicType] of string = ('i32','i64','f32','f64');
  82. function gas_regname(r:Tregister):string;
  83. implementation
  84. function gas_regname(r:Tregister):string;
  85. begin
  86. result:=generic_regname(r);
  87. end;
  88. end.