1796c32c9Schristos /* TI PRU opcode list for GAS, the GNU assembler. 2*aab831ceSchristos Copyright (C) 2014-2024 Free Software Foundation, Inc. 3796c32c9Schristos Contributed by Dimitar Dimitrov <dimitar@dinux.eu> 4796c32c9Schristos 5796c32c9Schristos This file is part of the GNU opcodes library. 6796c32c9Schristos 7796c32c9Schristos GAS/GDB is free software; you can redistribute it and/or modify 8796c32c9Schristos it under the terms of the GNU General Public License as published by 9796c32c9Schristos the Free Software Foundation; either version 3, or (at your option) 10796c32c9Schristos any later version. 11796c32c9Schristos 12796c32c9Schristos GAS/GDB is distributed in the hope that it will be useful, 13796c32c9Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 14796c32c9Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15796c32c9Schristos GNU General Public License for more details. 16796c32c9Schristos 17796c32c9Schristos You should have received a copy of the GNU General Public License 18796c32c9Schristos along with GAS or GDB; see the file COPYING3. If not, write to 19796c32c9Schristos the Free Software Foundation, 51 Franklin Street - Fifth Floor, 20796c32c9Schristos Boston, MA 02110-1301, USA. */ 21796c32c9Schristos 22796c32c9Schristos #ifndef _PRU_H_ 23796c32c9Schristos #define _PRU_H_ 24796c32c9Schristos 25796c32c9Schristos #include "bfd.h" 26796c32c9Schristos 27796c32c9Schristos /**************************************************************************** 28796c32c9Schristos * This file contains structures, bit masks and shift counts used 29796c32c9Schristos * by the GNU toolchain to define the PRU instruction set and 30796c32c9Schristos * access various opcode fields. 31796c32c9Schristos ****************************************************************************/ 32796c32c9Schristos 33796c32c9Schristos /* Identify different overflow situations for error messages. */ 34796c32c9Schristos enum overflow_type 35796c32c9Schristos { 36796c32c9Schristos call_target_overflow = 0, 37796c32c9Schristos qbranch_target_overflow, 38796c32c9Schristos address_offset_overflow, 39796c32c9Schristos signed_immed16_overflow, 40796c32c9Schristos unsigned_immed32_overflow, 41796c32c9Schristos unsigned_immed16_overflow, 42796c32c9Schristos unsigned_immed8_overflow, 43796c32c9Schristos unsigned_immed5_overflow, 44796c32c9Schristos no_overflow 45796c32c9Schristos }; 46796c32c9Schristos 474b169a6bSchristos enum opcode_format_type 484b169a6bSchristos { 49796c32c9Schristos opcode_format1, 50796c32c9Schristos opcode_format2ab, 51796c32c9Schristos opcode_format2abl, 52796c32c9Schristos opcode_format2c, 53796c32c9Schristos opcode_format2de, 54796c32c9Schristos opcode_format45, 55796c32c9Schristos opcode_format6 56796c32c9Schristos }; 57796c32c9Schristos 58796c32c9Schristos /* Opcode ID listing. Used for indexing by the simulator. */ 594b169a6bSchristos enum pru_instr_type 604b169a6bSchristos { 61796c32c9Schristos prui_add, prui_adc, prui_sub, prui_suc, prui_lsl, prui_lsr, prui_rsb, 62796c32c9Schristos prui_rsc, prui_and, prui_or, prui_xor, prui_min, prui_max, prui_clr, 634b169a6bSchristos prui_set, prui_not, prui_jmp, prui_jal, prui_ldi, prui_lmbd, 644b169a6bSchristos prui_halt, prui_slp, prui_xin, prui_xout, prui_xchg, prui_sxin, 654b169a6bSchristos prui_sxout, prui_sxchg, prui_loop, prui_iloop, prui_qbgt, prui_qbge, 664b169a6bSchristos prui_qblt, prui_qble, prui_qbeq, prui_qbne, prui_qba, prui_qbbs, 674b169a6bSchristos prui_qbbc, prui_lbbo, prui_sbbo, prui_lbco, prui_sbco 68796c32c9Schristos }; 69796c32c9Schristos 70796c32c9Schristos /* This structure holds information for a particular instruction. 71796c32c9Schristos 72796c32c9Schristos The args field is a string describing the operands. The following 73796c32c9Schristos letters can appear in the args: 74796c32c9Schristos b - a 5.3-bit right source register index OR 8-bit unsigned immediate 75796c32c9Schristos B - same as 'b', but for LOOP instruction where IMM is decremented 76796c32c9Schristos c - a 5 bit unsigned immediate for constant table offset 77796c32c9Schristos d - a 5.3-bit destination register index 78796c32c9Schristos D - a 5.2-bit destination register index 79796c32c9Schristos E - for internal GAS self-tests only 80796c32c9Schristos i - a 32-bit immediate or label 81796c32c9Schristos j - a 5.3-bit right source register index OR 18-bit PC address 82796c32c9Schristos l - burst length (unsigned 7-bit immediate or r0.b[0-3]) for xLBCO 83796c32c9Schristos n - burst length (unsigned 7-bit immediate or r0.b[0-3]) for XFR 84796c32c9Schristos o - a 10-bit signed PC-relative offset 85796c32c9Schristos O - an 8-bit unsigned PC-relative offset for LOOP termination point 86796c32c9Schristos R - a 5-bit destination register index 87796c32c9Schristos s - a 5.3-bit left source register index 88796c32c9Schristos S - a 5-bit left source register index 89796c32c9Schristos w - a single bit for "WakeOnStatus" 90796c32c9Schristos W - a 16-bit unsigned immediate with IO=0 field (LDI) 91796c32c9Schristos x - an 8-bit XFR wide-bus address immediate 92796c32c9Schristos Literal ',' character may also appear in the args as delimiter. 93796c32c9Schristos 94796c32c9Schristos Most of the macro names are from [1]. 95796c32c9Schristos 96796c32c9Schristos The pinfo field is INSN_MACRO for a macro. Otherwise, it is a collection 97796c32c9Schristos of bits describing the instruction, notably any relevant hazard 98796c32c9Schristos information. 99796c32c9Schristos 100796c32c9Schristos When assembling, the match field contains the opcode template, which 101796c32c9Schristos is modified by the arguments to produce the actual opcode 102796c32c9Schristos that is emitted. If pinfo is INSN_MACRO, then this is 0. 103796c32c9Schristos 104796c32c9Schristos If pinfo is INSN_MACRO, the mask field stores the macro identifier. 105796c32c9Schristos Otherwise this is a bit mask for the relevant portions of the opcode 106796c32c9Schristos when disassembling. If the actual opcode anded with the match field 107796c32c9Schristos equals the opcode field, then we have found the correct instruction. 108796c32c9Schristos 109796c32c9Schristos [1] http://processors.wiki.ti.com/index.php/Programmable_Realtime_Unit */ 110796c32c9Schristos 111796c32c9Schristos struct pru_opcode 112796c32c9Schristos { 113796c32c9Schristos const char *name; /* The name of the instruction. */ 114796c32c9Schristos enum pru_instr_type type; /* Instruction type. Used for fast indexing 115796c32c9Schristos by the simulator. */ 116796c32c9Schristos const char *args; /* A string describing the arguments for this 117796c32c9Schristos instruction. */ 118796c32c9Schristos unsigned long match; /* The basic opcode for the instruction. */ 119796c32c9Schristos unsigned long mask; /* Mask for the opcode field of the 120796c32c9Schristos instruction. */ 121796c32c9Schristos unsigned long pinfo; /* Is this a real instruction or instruction 122796c32c9Schristos macro? */ 123796c32c9Schristos enum overflow_type overflow_msg; /* Used to generate informative 124796c32c9Schristos message when fixup overflows. */ 125796c32c9Schristos }; 126796c32c9Schristos 127796c32c9Schristos /* This value is used in the pru_opcode.pinfo field to indicate that the 128796c32c9Schristos instruction is a macro or pseudo-op. This requires special treatment by 129796c32c9Schristos the assembler, and is used by the disassembler to determine whether to 130796c32c9Schristos check for a nop. */ 131796c32c9Schristos #define PRU_INSN_MACRO 0x80000000 132796c32c9Schristos 133796c32c9Schristos /* This macro is specially handled throughout the code because it is 134796c32c9Schristos the only insn to output 2 words (64 bits). */ 135796c32c9Schristos #define PRU_INSN_LDI32 0x40000000 136796c32c9Schristos 137796c32c9Schristos /* Associates a register name with a 5-bit index and 3-bit regsel. */ 138796c32c9Schristos struct pru_reg 139796c32c9Schristos { 140796c32c9Schristos const char *name; /* Name, e.g. "r10". */ 141796c32c9Schristos const unsigned int index; /* Index, e.g. 10. */ 142796c32c9Schristos const unsigned int regsel; /* Register field selector, .e.g RSEL_31_0. */ 143796c32c9Schristos }; 144796c32c9Schristos 145796c32c9Schristos /* Macros for getting and setting an instruction field. */ 146796c32c9Schristos #define GET_INSN_FIELD(X, i) \ 147796c32c9Schristos (((i) & OP_MASK_##X) >> OP_SH_##X) 148796c32c9Schristos #define SET_INSN_FIELD(X, i, v) \ 149796c32c9Schristos ((i) = (((i) & ~OP_MASK_##X) | (((v) << OP_SH_##X) & OP_MASK_##X))) 150796c32c9Schristos 151796c32c9Schristos #define CHECK_INSN_FIELD(X, i) \ 152796c32c9Schristos (((i) & OP_MASK_##X) == OP_MATCH_##X) 153796c32c9Schristos 154796c32c9Schristos /* Masks, values, shifts and macros for accessing the various opcode fields. */ 155796c32c9Schristos 156796c32c9Schristos #define OP_SH_FMT1_OP 29 157796c32c9Schristos #define OP_MASK_FMT1_OP (0x7u << 29) 158796c32c9Schristos #define OP_MATCH_FMT1_OP (0x0u << 29) 159796c32c9Schristos 160796c32c9Schristos #define OP_SH_FMT2_OP 29 161796c32c9Schristos #define OP_MASK_FMT2_OP (0x7u << 29) 162796c32c9Schristos #define OP_MATCH_FMT2_OP (0x1u << 29) 163796c32c9Schristos 164796c32c9Schristos #define OP_SH_FMT4_OP 30 165796c32c9Schristos #define OP_MASK_FMT4_OP (0x3u << 30) 166796c32c9Schristos #define OP_MATCH_FMT4_OP (0x1u << 30) 167796c32c9Schristos 168796c32c9Schristos #define OP_SH_FMT5_OP 29 169796c32c9Schristos #define OP_MASK_FMT5_OP (0x7u << 29) 170796c32c9Schristos #define OP_MATCH_FMT5_OP (0x6u << 29) 171796c32c9Schristos 172796c32c9Schristos #define OP_SH_FMT6AB_OP 29 173796c32c9Schristos #define OP_MASK_FMT6AB_OP (0x7u << 29) 174796c32c9Schristos #define OP_MATCH_FMT6AB_OP (0x7u << 29) 175796c32c9Schristos 176796c32c9Schristos #define OP_SH_FMT6CD_OP 29 177796c32c9Schristos #define OP_MASK_FMT6CD_OP (0x7u << 29) 178796c32c9Schristos #define OP_MATCH_FMT6CD_OP (0x4u << 29) 179796c32c9Schristos 180796c32c9Schristos /* Generic fields. */ 181796c32c9Schristos #define OP_SH_SUBOP 25 182796c32c9Schristos #define OP_MASK_SUBOP (0xfu << 25) 183796c32c9Schristos 184796c32c9Schristos #define OP_SH_IO 24 185796c32c9Schristos #define OP_MASK_IO (0x1u << 24) 186796c32c9Schristos 187796c32c9Schristos #define OP_SH_RS2SEL 21 188796c32c9Schristos #define OP_MASK_RS2SEL (0x7u << 21) 189796c32c9Schristos #define OP_SH_RS2 16 190796c32c9Schristos #define OP_MASK_RS2 (0x1fu << 16) 191796c32c9Schristos #define OP_SH_RS1SEL 13 192796c32c9Schristos #define OP_MASK_RS1SEL (0x7u << 13) 193796c32c9Schristos #define OP_SH_RS1 8 194796c32c9Schristos #define OP_MASK_RS1 (0x1fu << 8) 195796c32c9Schristos #define OP_SH_RDSEL 5 196796c32c9Schristos #define OP_MASK_RDSEL (0x7u << 5) 197796c32c9Schristos #define OP_SH_RD 0 198796c32c9Schristos #define OP_MASK_RD (0x1fu << 0) 199796c32c9Schristos #define OP_SH_IMM8 16 200796c32c9Schristos #define OP_MASK_IMM8 (0xffu << 16) 201796c32c9Schristos #define OP_SH_IMM16 8 202796c32c9Schristos #define OP_MASK_IMM16 (0xffffu << 8) 203796c32c9Schristos 204796c32c9Schristos #define RSEL_7_0 0u 205796c32c9Schristos #define RSEL_15_8 1u 206796c32c9Schristos #define RSEL_23_16 2u 207796c32c9Schristos #define RSEL_31_24 3u 208796c32c9Schristos #define RSEL_15_0 4u 209796c32c9Schristos #define RSEL_23_8 5u 210796c32c9Schristos #define RSEL_31_16 6u 211796c32c9Schristos #define RSEL_31_0 7u 212796c32c9Schristos #define RSEL_NUM_ITEMS 8u 213796c32c9Schristos 214796c32c9Schristos /* Format 1 specific fields. */ 215796c32c9Schristos #define SUBOP_ADD 0u 216796c32c9Schristos #define SUBOP_ADC 1u 217796c32c9Schristos #define SUBOP_SUB 2u 218796c32c9Schristos #define SUBOP_SUC 3u 219796c32c9Schristos #define SUBOP_LSL 4u 220796c32c9Schristos #define SUBOP_LSR 5u 221796c32c9Schristos #define SUBOP_RSB 6u 222796c32c9Schristos #define SUBOP_RSC 7u 223796c32c9Schristos #define SUBOP_AND 8u 224796c32c9Schristos #define SUBOP_OR 9u 225796c32c9Schristos #define SUBOP_XOR 10u 226796c32c9Schristos #define SUBOP_NOT 11u 227796c32c9Schristos #define SUBOP_MIN 12u 228796c32c9Schristos #define SUBOP_MAX 13u 229796c32c9Schristos #define SUBOP_CLR 14u 230796c32c9Schristos #define SUBOP_SET 15u 231796c32c9Schristos 232796c32c9Schristos /* Format 2 specific fields. */ 233796c32c9Schristos #define SUBOP_JMP 0u 234796c32c9Schristos #define SUBOP_JAL 1u 235796c32c9Schristos #define SUBOP_LDI 2u 236796c32c9Schristos #define SUBOP_LMBD 3u 237796c32c9Schristos #define SUBOP_SCAN 4u 238796c32c9Schristos #define SUBOP_HALT 5u 239796c32c9Schristos #define SUBOP_RSVD_FOR_MVIx 6u 240796c32c9Schristos #define SUBOP_XFR 7u 241796c32c9Schristos #define SUBOP_LOOP 8u 242796c32c9Schristos #define SUBOP_RSVD_FOR_RFI 14u 243796c32c9Schristos #define SUBOP_SLP 15u 244796c32c9Schristos 245796c32c9Schristos #define OP_SH_WAKEONSTATUS 23 246796c32c9Schristos #define OP_MASK_WAKEONSTATUS (0x1u << 23) 247796c32c9Schristos 248796c32c9Schristos /* Format 2 XFR specific fields. */ 249796c32c9Schristos #define OP_SH_SUBOP_XFR 23 250796c32c9Schristos #define OP_MASK_SUBOP_XFR (3u << 23) 251796c32c9Schristos #define OP_SH_XFR_WBA 15 252796c32c9Schristos #define OP_MASK_XFR_WBA (0xffu << 15) 253796c32c9Schristos #define OP_SH_XFR_S 14 254796c32c9Schristos #define OP_MASK_XFR_S (1u << 14) 255796c32c9Schristos #define OP_SH_XFR_LENGTH 7 256796c32c9Schristos #define OP_MASK_XFR_LENGTH (0x7fu << 7) 257796c32c9Schristos 258796c32c9Schristos #define SUBOP_XFR_XIN 1u 259796c32c9Schristos #define SUBOP_XFR_XOUT 2u 260796c32c9Schristos #define SUBOP_XFR_XCHG 3u 261796c32c9Schristos 262796c32c9Schristos /* Format 2 LOOP specific fields. */ 263796c32c9Schristos #define OP_SH_LOOP_INTERRUPTIBLE 15 264796c32c9Schristos #define OP_MASK_LOOP_INTERRUPTIBLE (1u << 15) 265796c32c9Schristos #define OP_SH_LOOP_JMPOFFS 0 266796c32c9Schristos #define OP_MASK_LOOP_JMPOFFS (0xffu << 0) 267796c32c9Schristos 268796c32c9Schristos /* Format 4 specific fields. */ 269796c32c9Schristos #define OP_SH_BROFF98 25 270796c32c9Schristos #define OP_MASK_BROFF98 (0x3u << 25) 271796c32c9Schristos #define OP_SH_BROFF70 0 272796c32c9Schristos #define OP_MASK_BROFF70 (0xffu << 0) 273796c32c9Schristos #define OP_SH_GT 29 274796c32c9Schristos #define OP_MASK_GT (0x1u << 29) 275796c32c9Schristos #define OP_SH_EQ 28 276796c32c9Schristos #define OP_MASK_EQ (0x1u << 28) 277796c32c9Schristos #define OP_SH_LT 27 278796c32c9Schristos #define OP_MASK_LT (0x1u << 27) 279796c32c9Schristos #define OP_MASK_CMP (OP_MASK_GT | OP_MASK_EQ | OP_MASK_LT) 280796c32c9Schristos 281796c32c9Schristos 282796c32c9Schristos /* Format 5 specific fields. */ 283796c32c9Schristos #define OP_SH_BS 28 284796c32c9Schristos #define OP_MASK_BS (0x1u << 28) 285796c32c9Schristos #define OP_SH_BC 27 286796c32c9Schristos #define OP_MASK_BC (0x1u << 27) 287796c32c9Schristos #define OP_MASK_BCMP (OP_MASK_BS | OP_MASK_BC) 288796c32c9Schristos 289796c32c9Schristos /* Format 6 specific fields. */ 290796c32c9Schristos #define OP_SH_LOADSTORE 28 291796c32c9Schristos #define OP_MASK_LOADSTORE (0x1u << 28) 292796c32c9Schristos #define OP_SH_BURSTLEN64 25 293796c32c9Schristos #define OP_MASK_BURSTLEN64 (0x7u << 25) 294796c32c9Schristos #define OP_SH_BURSTLEN31 13 295796c32c9Schristos #define OP_MASK_BURSTLEN31 (0x7u << 13) 296796c32c9Schristos #define OP_SH_CB 8 297796c32c9Schristos #define OP_MASK_CB (0x1fu << 8) 298796c32c9Schristos #define OP_SH_BURSTLEN0 7 299796c32c9Schristos #define OP_MASK_BURSTLEN0 (0x1u << 7) 300796c32c9Schristos #define OP_SH_RDB 5 301796c32c9Schristos #define OP_MASK_RDB (0x3u << 5) 302796c32c9Schristos 303796c32c9Schristos #define LSSBBO_BYTECOUNT_R0_BITS7_0 124u 304796c32c9Schristos #define LSBBO_BYTECOUNT_R0_BITS15_8 125u 305796c32c9Schristos #define LSBBO_BYTECOUNT_R0_BITS23_16 126u 306796c32c9Schristos #define LSBBO_BYTECOUNT_R0_BITS31_24 127u 307796c32c9Schristos 308796c32c9Schristos /* The following macros define the opcode matches for each 309796c32c9Schristos instruction code & OP_MASK_INST == OP_MATCH_INST. */ 310796c32c9Schristos #define OP_MATCH_ADD (OP_MATCH_FMT1_OP | (SUBOP_ADD << OP_SH_SUBOP)) 311796c32c9Schristos #define OP_MATCH_ADC (OP_MATCH_FMT1_OP | (SUBOP_ADC << OP_SH_SUBOP)) 312796c32c9Schristos #define OP_MATCH_SUB (OP_MATCH_FMT1_OP | (SUBOP_SUB << OP_SH_SUBOP)) 313796c32c9Schristos #define OP_MATCH_SUC (OP_MATCH_FMT1_OP | (SUBOP_SUC << OP_SH_SUBOP)) 314796c32c9Schristos #define OP_MATCH_LSL (OP_MATCH_FMT1_OP | (SUBOP_LSL << OP_SH_SUBOP)) 315796c32c9Schristos #define OP_MATCH_LSR (OP_MATCH_FMT1_OP | (SUBOP_LSR << OP_SH_SUBOP)) 316796c32c9Schristos #define OP_MATCH_RSB (OP_MATCH_FMT1_OP | (SUBOP_RSB << OP_SH_SUBOP)) 317796c32c9Schristos #define OP_MATCH_RSC (OP_MATCH_FMT1_OP | (SUBOP_RSC << OP_SH_SUBOP)) 318796c32c9Schristos #define OP_MATCH_AND (OP_MATCH_FMT1_OP | (SUBOP_AND << OP_SH_SUBOP)) 319796c32c9Schristos #define OP_MATCH_OR (OP_MATCH_FMT1_OP | (SUBOP_OR << OP_SH_SUBOP)) 320796c32c9Schristos #define OP_MATCH_XOR (OP_MATCH_FMT1_OP | (SUBOP_XOR << OP_SH_SUBOP)) 321796c32c9Schristos #define OP_MATCH_NOT (OP_MATCH_FMT1_OP | (SUBOP_NOT << OP_SH_SUBOP)) 322796c32c9Schristos #define OP_MATCH_MIN (OP_MATCH_FMT1_OP | (SUBOP_MIN << OP_SH_SUBOP)) 323796c32c9Schristos #define OP_MATCH_MAX (OP_MATCH_FMT1_OP | (SUBOP_MAX << OP_SH_SUBOP)) 324796c32c9Schristos #define OP_MATCH_CLR (OP_MATCH_FMT1_OP | (SUBOP_CLR << OP_SH_SUBOP)) 325796c32c9Schristos #define OP_MATCH_SET (OP_MATCH_FMT1_OP | (SUBOP_SET << OP_SH_SUBOP)) 326796c32c9Schristos 327796c32c9Schristos #define OP_MATCH_JMP (OP_MATCH_FMT2_OP | (SUBOP_JMP << OP_SH_SUBOP)) 328796c32c9Schristos #define OP_MATCH_JAL (OP_MATCH_FMT2_OP | (SUBOP_JAL << OP_SH_SUBOP)) 329796c32c9Schristos #define OP_MATCH_LDI (OP_MATCH_FMT2_OP | (SUBOP_LDI << OP_SH_SUBOP)) 330796c32c9Schristos #define OP_MATCH_LMBD (OP_MATCH_FMT2_OP | (SUBOP_LMBD << OP_SH_SUBOP)) 331796c32c9Schristos #define OP_MATCH_SCAN (OP_MATCH_FMT2_OP | (SUBOP_SCAN << OP_SH_SUBOP)) 332796c32c9Schristos #define OP_MATCH_HALT (OP_MATCH_FMT2_OP | (SUBOP_HALT << OP_SH_SUBOP)) 333796c32c9Schristos #define OP_MATCH_SLP (OP_MATCH_FMT2_OP | (SUBOP_SLP << OP_SH_SUBOP)) 334796c32c9Schristos #define OP_MATCH_XFR (OP_MATCH_FMT2_OP | (SUBOP_XFR << OP_SH_SUBOP)) 335796c32c9Schristos #define OP_MATCH_SXFR (OP_MATCH_XFR | OP_MASK_XFR_S) 336796c32c9Schristos #define OP_MATCH_XIN (OP_MATCH_XFR | (SUBOP_XFR_XIN << OP_SH_SUBOP_XFR)) 337796c32c9Schristos #define OP_MATCH_XOUT (OP_MATCH_XFR | (SUBOP_XFR_XOUT << OP_SH_SUBOP_XFR)) 338796c32c9Schristos #define OP_MATCH_XCHG (OP_MATCH_XFR | (SUBOP_XFR_XCHG << OP_SH_SUBOP_XFR)) 339796c32c9Schristos #define OP_MATCH_SXIN (OP_MATCH_SXFR | (SUBOP_XFR_XIN << OP_SH_SUBOP_XFR)) 340796c32c9Schristos #define OP_MATCH_SXOUT (OP_MATCH_SXFR | (SUBOP_XFR_XOUT << OP_SH_SUBOP_XFR)) 341796c32c9Schristos #define OP_MATCH_SXCHG (OP_MATCH_SXFR | (SUBOP_XFR_XCHG << OP_SH_SUBOP_XFR)) 342796c32c9Schristos #define OP_MATCH_LOOP (OP_MATCH_FMT2_OP | (SUBOP_LOOP << OP_SH_SUBOP)) 343796c32c9Schristos #define OP_MATCH_ILOOP (OP_MATCH_FMT2_OP | (SUBOP_LOOP << OP_SH_SUBOP) \ 344796c32c9Schristos | OP_MASK_LOOP_INTERRUPTIBLE) 345796c32c9Schristos 346796c32c9Schristos #define OP_MATCH_QBGT (OP_MATCH_FMT4_OP | OP_MASK_GT) 347796c32c9Schristos #define OP_MATCH_QBGE (OP_MATCH_FMT4_OP | OP_MASK_GT | OP_MASK_EQ) 348796c32c9Schristos #define OP_MATCH_QBLT (OP_MATCH_FMT4_OP | OP_MASK_LT) 349796c32c9Schristos #define OP_MATCH_QBLE (OP_MATCH_FMT4_OP | OP_MASK_LT | OP_MASK_EQ) 350796c32c9Schristos #define OP_MATCH_QBEQ (OP_MATCH_FMT4_OP | OP_MASK_EQ) 351796c32c9Schristos #define OP_MATCH_QBNE (OP_MATCH_FMT4_OP | OP_MASK_GT | OP_MASK_LT) 352796c32c9Schristos #define OP_MATCH_QBA (OP_MATCH_FMT4_OP | OP_MASK_GT | OP_MASK_LT \ 353796c32c9Schristos | OP_MASK_EQ) 354796c32c9Schristos 355796c32c9Schristos #define OP_MATCH_QBBS (OP_MATCH_FMT5_OP | OP_MASK_BS) 356796c32c9Schristos #define OP_MATCH_QBBC (OP_MATCH_FMT5_OP | OP_MASK_BC) 357796c32c9Schristos 358796c32c9Schristos #define OP_MATCH_LBBO (OP_MATCH_FMT6AB_OP | OP_MASK_LOADSTORE) 359796c32c9Schristos #define OP_MATCH_SBBO (OP_MATCH_FMT6AB_OP) 360796c32c9Schristos #define OP_MATCH_LBCO (OP_MATCH_FMT6CD_OP | OP_MASK_LOADSTORE) 361796c32c9Schristos #define OP_MATCH_SBCO (OP_MATCH_FMT6CD_OP) 362796c32c9Schristos 363796c32c9Schristos /* Some special extractions. */ 364796c32c9Schristos #define OP_MASK_BROFF (OP_MASK_BROFF98 | OP_MASK_BROFF70) 365796c32c9Schristos 366796c32c9Schristos #define GET_BROFF_URAW(i) \ 367796c32c9Schristos ((GET_INSN_FIELD (BROFF98, i) << 8) | (GET_INSN_FIELD (BROFF70, i) << 0)) 368796c32c9Schristos 369796c32c9Schristos #define GET_BROFF_SIGNED(i) \ 370796c32c9Schristos ((long)(GET_BROFF_URAW (i) - (!!(GET_BROFF_URAW (i) & (1 << 9)) << 10))) 371796c32c9Schristos 372796c32c9Schristos #define SET_BROFF_URAW(i, v) \ 373796c32c9Schristos do { \ 374796c32c9Schristos SET_INSN_FIELD (BROFF98, (i), (v) >> 8); \ 375796c32c9Schristos SET_INSN_FIELD (BROFF70, (i), (v) & 0xff); \ 376796c32c9Schristos } while (0) 377796c32c9Schristos 378796c32c9Schristos #define GET_BURSTLEN(i) \ 379796c32c9Schristos ( (GET_INSN_FIELD (BURSTLEN64, (i)) << 4) | \ 380796c32c9Schristos (GET_INSN_FIELD (BURSTLEN31, (i)) << 1) | \ 381796c32c9Schristos (GET_INSN_FIELD (BURSTLEN0, (i)) << 0)) 382796c32c9Schristos 383796c32c9Schristos #define SET_BURSTLEN(i, v) \ 384796c32c9Schristos do { \ 385796c32c9Schristos SET_INSN_FIELD (BURSTLEN64, (i), (v) >> 4); \ 386796c32c9Schristos SET_INSN_FIELD (BURSTLEN31, (i), (v) >> 1); \ 387796c32c9Schristos SET_INSN_FIELD (BURSTLEN0, (i), (v) >> 0); \ 388796c32c9Schristos } while (0) 389796c32c9Schristos 390796c32c9Schristos /* Miscellaneous helpers. */ 391796c32c9Schristos #define OP_MASK_XFR_OP (OP_MASK_FMT2_OP | OP_MASK_SUBOP \ 392796c32c9Schristos | OP_MASK_SUBOP_XFR | OP_MASK_XFR_S) 393796c32c9Schristos 394796c32c9Schristos #define OP_MASK_LOOP_OP (OP_MASK_FMT2_OP | OP_MASK_SUBOP \ 395796c32c9Schristos | OP_MASK_LOOP_INTERRUPTIBLE) 396796c32c9Schristos 397796c32c9Schristos /* These are the data structures we use to hold the instruction information. */ 398796c32c9Schristos extern const struct pru_opcode pru_opcodes[]; 399796c32c9Schristos extern const int bfd_pru_num_opcodes; 400796c32c9Schristos 401796c32c9Schristos /* These are the data structures used to hold the register information. */ 402796c32c9Schristos extern const struct pru_reg pru_regs[]; 403796c32c9Schristos extern const int pru_num_regs; 404796c32c9Schristos 405796c32c9Schristos /* Machine-independent macro for number of opcodes. */ 406796c32c9Schristos #define NUMOPCODES bfd_pru_num_opcodes 407796c32c9Schristos #define NUMREGISTERS pru_num_regs; 408796c32c9Schristos 409796c32c9Schristos /* This is made extern so that the assembler can use it to find out 410796c32c9Schristos what instruction caused an error. */ 411796c32c9Schristos extern const struct pru_opcode *pru_find_opcode (unsigned long); 412796c32c9Schristos 413796c32c9Schristos #endif /* _PRU_H */ 414