spu.h 2.9 KB

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