spu.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* SPU ELF support for BFD.
  2. Copyright 2006 Free Software Foundation, Inc.
  3. This file is part of GDB, GAS, and the GNU binutils.
  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 Foundation,
  14. Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
  15. /* These two enums are from rel_apu/common/spu_asm_format.h */
  16. /* definition of instruction format */
  17. typedef enum {
  18. RRR,
  19. RI18,
  20. RI16,
  21. RI10,
  22. RI8,
  23. RI7,
  24. RR,
  25. LBT,
  26. LBTI,
  27. IDATA,
  28. UNKNOWN_IFORMAT
  29. } spu_iformat;
  30. /* These values describe assembly instruction arguments. They indicate
  31. * how to encode, range checking and which relocation to use. */
  32. typedef enum {
  33. A_T, /* register at pos 0 */
  34. A_A, /* register at pos 7 */
  35. A_B, /* register at pos 14 */
  36. A_C, /* register at pos 21 */
  37. A_S, /* special purpose register at pos 7 */
  38. A_H, /* channel register at pos 7 */
  39. A_P, /* parenthesis, this has to separate regs from immediates */
  40. A_S3,
  41. A_S6,
  42. A_S7N,
  43. A_S7,
  44. A_U7A,
  45. A_U7B,
  46. A_S10B,
  47. A_S10,
  48. A_S11,
  49. A_S11I,
  50. A_S14,
  51. A_S16,
  52. A_S18,
  53. A_R18,
  54. A_U3,
  55. A_U5,
  56. A_U6,
  57. A_U7,
  58. A_U14,
  59. A_X16,
  60. A_U18,
  61. A_MAX
  62. } spu_aformat;
  63. enum spu_insns {
  64. #define APUOP(TAG,MACFORMAT,OPCODE,MNEMONIC,ASMFORMAT,DEP,PIPE) \
  65. TAG,
  66. #define APUOPFB(TAG,MACFORMAT,OPCODE,FB,MNEMONIC,ASMFORMAT,DEP,PIPE) \
  67. TAG,
  68. #include "spu-insns.h"
  69. #undef APUOP
  70. #undef APUOPFB
  71. M_SPU_MAX
  72. };
  73. struct spu_opcode
  74. {
  75. spu_iformat insn_type;
  76. unsigned int opcode;
  77. char *mnemonic;
  78. int arg[5];
  79. };
  80. #define SIGNED_EXTRACT(insn,size,pos) (((int)((insn) << (32-size-pos))) >> (32-size))
  81. #define UNSIGNED_EXTRACT(insn,size,pos) (((insn) >> pos) & ((1 << size)-1))
  82. #define DECODE_INSN_RT(insn) (insn & 0x7f)
  83. #define DECODE_INSN_RA(insn) ((insn >> 7) & 0x7f)
  84. #define DECODE_INSN_RB(insn) ((insn >> 14) & 0x7f)
  85. #define DECODE_INSN_RC(insn) ((insn >> 21) & 0x7f)
  86. #define DECODE_INSN_I10(insn) SIGNED_EXTRACT(insn,10,14)
  87. #define DECODE_INSN_U10(insn) UNSIGNED_EXTRACT(insn,10,14)
  88. /* For branching, immediate loads, hbr and lqa/stqa. */
  89. #define DECODE_INSN_I16(insn) SIGNED_EXTRACT(insn,16,7)
  90. #define DECODE_INSN_U16(insn) UNSIGNED_EXTRACT(insn,16,7)
  91. /* for stop */
  92. #define DECODE_INSN_U14(insn) UNSIGNED_EXTRACT(insn,14,0)
  93. /* For ila */
  94. #define DECODE_INSN_I18(insn) SIGNED_EXTRACT(insn,18,7)
  95. #define DECODE_INSN_U18(insn) UNSIGNED_EXTRACT(insn,18,7)
  96. /* For rotate and shift and generate control mask */
  97. #define DECODE_INSN_I7(insn) SIGNED_EXTRACT(insn,7,14)
  98. #define DECODE_INSN_U7(insn) UNSIGNED_EXTRACT(insn,7,14)
  99. /* For float <-> int conversion */
  100. #define DECODE_INSN_I8(insn) SIGNED_EXTRACT(insn,8,14)
  101. #define DECODE_INSN_U8(insn) UNSIGNED_EXTRACT(insn,8,14)
  102. /* For hbr */
  103. #define DECODE_INSN_I9a(insn) ((SIGNED_EXTRACT(insn,2,23) << 7) | UNSIGNED_EXTRACT(insn,7,0))
  104. #define DECODE_INSN_I9b(insn) ((SIGNED_EXTRACT(insn,2,14) << 7) | UNSIGNED_EXTRACT(insn,7,0))
  105. #define DECODE_INSN_U9a(insn) ((UNSIGNED_EXTRACT(insn,2,23) << 7) | UNSIGNED_EXTRACT(insn,7,0))
  106. #define DECODE_INSN_U9b(insn) ((UNSIGNED_EXTRACT(insn,2,14) << 7) | UNSIGNED_EXTRACT(insn,7,0))