1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /* SPU ELF support for BFD.
4 Copyright 2006 Free Software Foundation, Inc.
6 This file is part of GDB, GAS, and the GNU binutils.
11 /* These two enums are from rel_apu/common/spu_asm_format.h */
12 /* definition of instruction format */
27 /* These values describe assembly instruction arguments. They indicate
28 * how to encode, range checking and which relocation to use. */
30 A_T
, /* register at pos 0 */
31 A_A
, /* register at pos 7 */
32 A_B
, /* register at pos 14 */
33 A_C
, /* register at pos 21 */
34 A_S
, /* special purpose register at pos 7 */
35 A_H
, /* channel register at pos 7 */
36 A_P
, /* parenthesis, this has to separate regs from immediates */
62 #define APUOP(TAG,MACFORMAT,OPCODE,MNEMONIC,ASMFORMAT,DEP,PIPE) \
64 #define APUOPFB(TAG,MACFORMAT,OPCODE,FB,MNEMONIC,ASMFORMAT,DEP,PIPE) \
66 #include "spu-insns.h"
74 spu_iformat insn_type
;
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))
83 #define DECODE_INSN_RT(insn) (insn & 0x7f)
84 #define DECODE_INSN_RA(insn) ((insn >> 7) & 0x7f)
85 #define DECODE_INSN_RB(insn) ((insn >> 14) & 0x7f)
86 #define DECODE_INSN_RC(insn) ((insn >> 21) & 0x7f)
88 #define DECODE_INSN_I10(insn) SIGNED_EXTRACT(insn,10,14)
89 #define DECODE_INSN_U10(insn) UNSIGNED_EXTRACT(insn,10,14)
91 /* For branching, immediate loads, hbr and lqa/stqa. */
92 #define DECODE_INSN_I16(insn) SIGNED_EXTRACT(insn,16,7)
93 #define DECODE_INSN_U16(insn) UNSIGNED_EXTRACT(insn,16,7)
96 #define DECODE_INSN_U14(insn) UNSIGNED_EXTRACT(insn,14,0)
99 #define DECODE_INSN_I18(insn) SIGNED_EXTRACT(insn,18,7)
100 #define DECODE_INSN_U18(insn) UNSIGNED_EXTRACT(insn,18,7)
102 /* For rotate and shift and generate control mask */
103 #define DECODE_INSN_I7(insn) SIGNED_EXTRACT(insn,7,14)
104 #define DECODE_INSN_U7(insn) UNSIGNED_EXTRACT(insn,7,14)
106 /* For float <-> int conversion */
107 #define DECODE_INSN_I8(insn) SIGNED_EXTRACT(insn,8,14)
108 #define DECODE_INSN_U8(insn) UNSIGNED_EXTRACT(insn,8,14)
111 #define DECODE_INSN_I9a(insn) ((SIGNED_EXTRACT(insn,2,23) << 7) | UNSIGNED_EXTRACT(insn,7,0))
112 #define DECODE_INSN_I9b(insn) ((SIGNED_EXTRACT(insn,2,14) << 7) | UNSIGNED_EXTRACT(insn,7,0))
113 #define DECODE_INSN_U9a(insn) ((UNSIGNED_EXTRACT(insn,2,23) << 7) | UNSIGNED_EXTRACT(insn,7,0))
114 #define DECODE_INSN_U9b(insn) ((UNSIGNED_EXTRACT(insn,2,14) << 7) | UNSIGNED_EXTRACT(insn,7,0))