198b9484cSchristos /* mips.h. Mips opcode list for GDB, the GNU debugger. 2*02f41505Schristos Copyright (C) 1993-2024 Free Software Foundation, Inc. 398b9484cSchristos Contributed by Ralph Campbell and OSF 498b9484cSchristos Commented and modified by Ian Lance Taylor, Cygnus Support 598b9484cSchristos 698b9484cSchristos This file is part of GDB, GAS, and the GNU binutils. 798b9484cSchristos 898b9484cSchristos GDB, GAS, and the GNU binutils are free software; you can redistribute 998b9484cSchristos them and/or modify them under the terms of the GNU General Public 1098b9484cSchristos License as published by the Free Software Foundation; either version 3, 1198b9484cSchristos or (at your option) any later version. 1298b9484cSchristos 1398b9484cSchristos GDB, GAS, and the GNU binutils are distributed in the hope that they 1498b9484cSchristos will be useful, but WITHOUT ANY WARRANTY; without even the implied 1598b9484cSchristos warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 1698b9484cSchristos the GNU General Public License for more details. 1798b9484cSchristos 1898b9484cSchristos You should have received a copy of the GNU General Public License 1998b9484cSchristos along with this file; see the file COPYING3. If not, write to the Free 2098b9484cSchristos Software Foundation, 51 Franklin Street - Fifth Floor, Boston, 2198b9484cSchristos MA 02110-1301, USA. */ 2298b9484cSchristos 2398b9484cSchristos #ifndef _MIPS_H_ 2498b9484cSchristos #define _MIPS_H_ 2598b9484cSchristos 26a2e2270fSchristos #include "bfd.h" 27a2e2270fSchristos 28ba340e45Schristos #ifdef __cplusplus 29ba340e45Schristos extern "C" { 30ba340e45Schristos #endif 31ba340e45Schristos 3298b9484cSchristos /* These are bit masks and shift counts to use to access the various 3398b9484cSchristos fields of an instruction. To retrieve the X field of an 3498b9484cSchristos instruction, use the expression 3598b9484cSchristos (i >> OP_SH_X) & OP_MASK_X 3698b9484cSchristos To set the same field (to j), use 3798b9484cSchristos i = (i &~ (OP_MASK_X << OP_SH_X)) | (j << OP_SH_X) 3898b9484cSchristos 3998b9484cSchristos Make sure you use fields that are appropriate for the instruction, 4098b9484cSchristos of course. 4198b9484cSchristos 4298b9484cSchristos The 'i' format uses OP, RS, RT and IMMEDIATE. 4398b9484cSchristos 4498b9484cSchristos The 'j' format uses OP and TARGET. 4598b9484cSchristos 4698b9484cSchristos The 'r' format uses OP, RS, RT, RD, SHAMT and FUNCT. 4798b9484cSchristos 4898b9484cSchristos The 'b' format uses OP, RS, RT and DELTA. 4998b9484cSchristos 5098b9484cSchristos The floating point 'i' format uses OP, RS, RT and IMMEDIATE. 5198b9484cSchristos 5298b9484cSchristos The floating point 'r' format uses OP, FMT, FT, FS, FD and FUNCT. 5398b9484cSchristos 5498b9484cSchristos A breakpoint instruction uses OP, CODE and SPEC (10 bits of the 5598b9484cSchristos breakpoint instruction are not defined; Kane says the breakpoint 5698b9484cSchristos code field in BREAK is 20 bits; yet MIPS assemblers and debuggers 5798b9484cSchristos only use ten bits). An optional two-operand form of break/sdbbp 5898b9484cSchristos allows the lower ten bits to be set too, and MIPS32 and later 598dffb485Schristos architectures allow 20 bits to be set with a single operand for 608dffb485Schristos the sdbbp instruction (using CODE20). 6198b9484cSchristos 6298b9484cSchristos The syscall instruction uses CODE20. 6398b9484cSchristos 6498b9484cSchristos The general coprocessor instructions use COPZ. */ 6598b9484cSchristos 6698b9484cSchristos #define OP_MASK_OP 0x3f 6798b9484cSchristos #define OP_SH_OP 26 6898b9484cSchristos #define OP_MASK_RS 0x1f 6998b9484cSchristos #define OP_SH_RS 21 7098b9484cSchristos #define OP_MASK_FR 0x1f 7198b9484cSchristos #define OP_SH_FR 21 7298b9484cSchristos #define OP_MASK_FMT 0x1f 7398b9484cSchristos #define OP_SH_FMT 21 7498b9484cSchristos #define OP_MASK_BCC 0x7 7598b9484cSchristos #define OP_SH_BCC 18 7698b9484cSchristos #define OP_MASK_CODE 0x3ff 7798b9484cSchristos #define OP_SH_CODE 16 7898b9484cSchristos #define OP_MASK_CODE2 0x3ff 7998b9484cSchristos #define OP_SH_CODE2 6 8098b9484cSchristos #define OP_MASK_RT 0x1f 8198b9484cSchristos #define OP_SH_RT 16 8298b9484cSchristos #define OP_MASK_FT 0x1f 8398b9484cSchristos #define OP_SH_FT 16 8498b9484cSchristos #define OP_MASK_CACHE 0x1f 8598b9484cSchristos #define OP_SH_CACHE 16 8698b9484cSchristos #define OP_MASK_RD 0x1f 8798b9484cSchristos #define OP_SH_RD 11 8898b9484cSchristos #define OP_MASK_FS 0x1f 8998b9484cSchristos #define OP_SH_FS 11 9098b9484cSchristos #define OP_MASK_PREFX 0x1f 9198b9484cSchristos #define OP_SH_PREFX 11 9298b9484cSchristos #define OP_MASK_CCC 0x7 9398b9484cSchristos #define OP_SH_CCC 8 9498b9484cSchristos #define OP_MASK_CODE20 0xfffff /* 20 bit syscall/breakpoint code. */ 9598b9484cSchristos #define OP_SH_CODE20 6 9698b9484cSchristos #define OP_MASK_SHAMT 0x1f 9798b9484cSchristos #define OP_SH_SHAMT 6 98a2e2270fSchristos #define OP_MASK_EXTLSB OP_MASK_SHAMT 99a2e2270fSchristos #define OP_SH_EXTLSB OP_SH_SHAMT 100a2e2270fSchristos #define OP_MASK_STYPE OP_MASK_SHAMT 101a2e2270fSchristos #define OP_SH_STYPE OP_SH_SHAMT 10298b9484cSchristos #define OP_MASK_FD 0x1f 10398b9484cSchristos #define OP_SH_FD 6 10498b9484cSchristos #define OP_MASK_TARGET 0x3ffffff 10598b9484cSchristos #define OP_SH_TARGET 0 10698b9484cSchristos #define OP_MASK_COPZ 0x1ffffff 10798b9484cSchristos #define OP_SH_COPZ 0 10898b9484cSchristos #define OP_MASK_IMMEDIATE 0xffff 10998b9484cSchristos #define OP_SH_IMMEDIATE 0 11098b9484cSchristos #define OP_MASK_DELTA 0xffff 11198b9484cSchristos #define OP_SH_DELTA 0 11298b9484cSchristos #define OP_MASK_FUNCT 0x3f 11398b9484cSchristos #define OP_SH_FUNCT 0 11498b9484cSchristos #define OP_MASK_SPEC 0x3f 11598b9484cSchristos #define OP_SH_SPEC 0 11698b9484cSchristos #define OP_SH_LOCC 8 /* FP condition code. */ 11798b9484cSchristos #define OP_SH_HICC 18 /* FP condition code. */ 11898b9484cSchristos #define OP_MASK_CC 0x7 11998b9484cSchristos #define OP_SH_COP1NORM 25 /* Normal COP1 encoding. */ 12098b9484cSchristos #define OP_MASK_COP1NORM 0x1 /* a single bit. */ 12198b9484cSchristos #define OP_SH_COP1SPEC 21 /* COP1 encodings. */ 12298b9484cSchristos #define OP_MASK_COP1SPEC 0xf 12398b9484cSchristos #define OP_MASK_COP1SCLR 0x4 12498b9484cSchristos #define OP_MASK_COP1CMP 0x3 12598b9484cSchristos #define OP_SH_COP1CMP 4 12698b9484cSchristos #define OP_SH_FORMAT 21 /* FP short format field. */ 12798b9484cSchristos #define OP_MASK_FORMAT 0x7 12898b9484cSchristos #define OP_SH_TRUE 16 12998b9484cSchristos #define OP_MASK_TRUE 0x1 13098b9484cSchristos #define OP_SH_GE 17 13198b9484cSchristos #define OP_MASK_GE 0x01 13298b9484cSchristos #define OP_SH_UNSIGNED 16 13398b9484cSchristos #define OP_MASK_UNSIGNED 0x1 13498b9484cSchristos #define OP_SH_HINT 16 13598b9484cSchristos #define OP_MASK_HINT 0x1f 13698b9484cSchristos #define OP_SH_MMI 0 /* Multimedia (parallel) op. */ 13798b9484cSchristos #define OP_MASK_MMI 0x3f 13898b9484cSchristos #define OP_SH_MMISUB 6 13998b9484cSchristos #define OP_MASK_MMISUB 0x1f 14098b9484cSchristos #define OP_MASK_PERFREG 0x1f /* Performance monitoring. */ 14198b9484cSchristos #define OP_SH_PERFREG 1 14298b9484cSchristos #define OP_SH_SEL 0 /* Coprocessor select field. */ 14398b9484cSchristos #define OP_MASK_SEL 0x7 /* The sel field of mfcZ and mtcZ. */ 14498b9484cSchristos #define OP_SH_CODE19 6 /* 19 bit wait code. */ 14598b9484cSchristos #define OP_MASK_CODE19 0x7ffff 14698b9484cSchristos #define OP_SH_ALN 21 14798b9484cSchristos #define OP_MASK_ALN 0x7 14898b9484cSchristos #define OP_SH_VSEL 21 14998b9484cSchristos #define OP_MASK_VSEL 0x1f 15098b9484cSchristos #define OP_MASK_VECBYTE 0x7 /* Selector field is really 4 bits, 15198b9484cSchristos but 0x8-0xf don't select bytes. */ 15298b9484cSchristos #define OP_SH_VECBYTE 22 15398b9484cSchristos #define OP_MASK_VECALIGN 0x7 /* Vector byte-align (alni.ob) op. */ 15498b9484cSchristos #define OP_SH_VECALIGN 21 15598b9484cSchristos #define OP_MASK_INSMSB 0x1f /* "ins" MSB. */ 15698b9484cSchristos #define OP_SH_INSMSB 11 15798b9484cSchristos #define OP_MASK_EXTMSBD 0x1f /* "ext" MSBD. */ 15898b9484cSchristos #define OP_SH_EXTMSBD 11 15998b9484cSchristos 16098b9484cSchristos /* MIPS DSP ASE */ 16198b9484cSchristos #define OP_SH_DSPACC 11 16298b9484cSchristos #define OP_MASK_DSPACC 0x3 16398b9484cSchristos #define OP_SH_DSPACC_S 21 16498b9484cSchristos #define OP_MASK_DSPACC_S 0x3 16598b9484cSchristos #define OP_SH_DSPSFT 20 16698b9484cSchristos #define OP_MASK_DSPSFT 0x3f 16798b9484cSchristos #define OP_SH_DSPSFT_7 19 16898b9484cSchristos #define OP_MASK_DSPSFT_7 0x7f 16998b9484cSchristos #define OP_SH_SA3 21 17098b9484cSchristos #define OP_MASK_SA3 0x7 17198b9484cSchristos #define OP_SH_SA4 21 17298b9484cSchristos #define OP_MASK_SA4 0xf 17398b9484cSchristos #define OP_SH_IMM8 16 17498b9484cSchristos #define OP_MASK_IMM8 0xff 17598b9484cSchristos #define OP_SH_IMM10 16 17698b9484cSchristos #define OP_MASK_IMM10 0x3ff 17798b9484cSchristos #define OP_SH_WRDSP 11 17898b9484cSchristos #define OP_MASK_WRDSP 0x3f 17998b9484cSchristos #define OP_SH_RDDSP 16 18098b9484cSchristos #define OP_MASK_RDDSP 0x3f 18198b9484cSchristos #define OP_SH_BP 11 18298b9484cSchristos #define OP_MASK_BP 0x3 18398b9484cSchristos 18498b9484cSchristos /* MIPS MT ASE */ 18598b9484cSchristos #define OP_SH_MT_U 5 18698b9484cSchristos #define OP_MASK_MT_U 0x1 18798b9484cSchristos #define OP_SH_MT_H 4 18898b9484cSchristos #define OP_MASK_MT_H 0x1 18998b9484cSchristos #define OP_SH_MTACC_T 18 19098b9484cSchristos #define OP_MASK_MTACC_T 0x3 19198b9484cSchristos #define OP_SH_MTACC_D 13 19298b9484cSchristos #define OP_MASK_MTACC_D 0x3 19398b9484cSchristos 194a2e2270fSchristos /* MIPS MCU ASE */ 195a2e2270fSchristos #define OP_MASK_3BITPOS 0x7 196a2e2270fSchristos #define OP_SH_3BITPOS 12 197a2e2270fSchristos #define OP_MASK_OFFSET12 0xfff 198a2e2270fSchristos #define OP_SH_OFFSET12 0 199a2e2270fSchristos 20098b9484cSchristos #define OP_OP_COP0 0x10 20198b9484cSchristos #define OP_OP_COP1 0x11 20298b9484cSchristos #define OP_OP_COP2 0x12 20398b9484cSchristos #define OP_OP_COP3 0x13 20498b9484cSchristos #define OP_OP_LWC1 0x31 20598b9484cSchristos #define OP_OP_LWC2 0x32 20698b9484cSchristos #define OP_OP_LWC3 0x33 /* a.k.a. pref */ 20798b9484cSchristos #define OP_OP_LDC1 0x35 20898b9484cSchristos #define OP_OP_LDC2 0x36 20998b9484cSchristos #define OP_OP_LDC3 0x37 /* a.k.a. ld */ 21098b9484cSchristos #define OP_OP_SWC1 0x39 21198b9484cSchristos #define OP_OP_SWC2 0x3a 21298b9484cSchristos #define OP_OP_SWC3 0x3b 21398b9484cSchristos #define OP_OP_SDC1 0x3d 21498b9484cSchristos #define OP_OP_SDC2 0x3e 21598b9484cSchristos #define OP_OP_SDC3 0x3f /* a.k.a. sd */ 21698b9484cSchristos 21703467a24Schristos /* MIPS VIRT ASE */ 21803467a24Schristos #define OP_MASK_CODE10 0x3ff 21903467a24Schristos #define OP_SH_CODE10 11 22003467a24Schristos 22198b9484cSchristos /* Values in the 'VSEL' field. */ 22298b9484cSchristos #define MDMX_FMTSEL_IMM_QH 0x1d 22398b9484cSchristos #define MDMX_FMTSEL_IMM_OB 0x1e 22498b9484cSchristos #define MDMX_FMTSEL_VEC_QH 0x15 22598b9484cSchristos #define MDMX_FMTSEL_VEC_OB 0x16 22698b9484cSchristos 22798b9484cSchristos /* UDI */ 22898b9484cSchristos #define OP_SH_UDI1 6 22998b9484cSchristos #define OP_MASK_UDI1 0x1f 23098b9484cSchristos #define OP_SH_UDI2 6 23198b9484cSchristos #define OP_MASK_UDI2 0x3ff 23298b9484cSchristos #define OP_SH_UDI3 6 23398b9484cSchristos #define OP_MASK_UDI3 0x7fff 23498b9484cSchristos #define OP_SH_UDI4 6 23598b9484cSchristos #define OP_MASK_UDI4 0xfffff 23698b9484cSchristos 23798b9484cSchristos /* Octeon */ 23898b9484cSchristos #define OP_SH_BBITIND 16 23998b9484cSchristos #define OP_MASK_BBITIND 0x1f 24098b9484cSchristos #define OP_SH_CINSPOS 6 24198b9484cSchristos #define OP_MASK_CINSPOS 0x1f 24298b9484cSchristos #define OP_SH_CINSLM1 11 24398b9484cSchristos #define OP_MASK_CINSLM1 0x1f 24498b9484cSchristos #define OP_SH_SEQI 6 24598b9484cSchristos #define OP_MASK_SEQI 0x3ff 24698b9484cSchristos 24798b9484cSchristos /* Loongson */ 24898b9484cSchristos #define OP_SH_OFFSET_A 6 24998b9484cSchristos #define OP_MASK_OFFSET_A 0xff 25098b9484cSchristos #define OP_SH_OFFSET_B 3 25198b9484cSchristos #define OP_MASK_OFFSET_B 0xff 25298b9484cSchristos #define OP_SH_OFFSET_C 6 25398b9484cSchristos #define OP_MASK_OFFSET_C 0x1ff 25498b9484cSchristos #define OP_SH_RZ 0 25598b9484cSchristos #define OP_MASK_RZ 0x1f 25698b9484cSchristos #define OP_SH_FZ 0 25798b9484cSchristos #define OP_MASK_FZ 0x1f 25898b9484cSchristos 259a2e2270fSchristos /* Every MICROMIPSOP_X definition requires a corresponding OP_X 260a2e2270fSchristos definition, and vice versa. This simplifies various parts 261a2e2270fSchristos of the operand handling in GAS. The fields below only exist 262a2e2270fSchristos in the microMIPS encoding, so define each one to have an empty 263a2e2270fSchristos range. */ 264a2e2270fSchristos #define OP_MASK_TRAP 0 265a2e2270fSchristos #define OP_SH_TRAP 0 266a2e2270fSchristos #define OP_MASK_OFFSET10 0 267a2e2270fSchristos #define OP_SH_OFFSET10 0 268a2e2270fSchristos #define OP_MASK_RS3 0 269a2e2270fSchristos #define OP_SH_RS3 0 270a2e2270fSchristos #define OP_MASK_MB 0 271a2e2270fSchristos #define OP_SH_MB 0 272a2e2270fSchristos #define OP_MASK_MC 0 273a2e2270fSchristos #define OP_SH_MC 0 274a2e2270fSchristos #define OP_MASK_MD 0 275a2e2270fSchristos #define OP_SH_MD 0 276a2e2270fSchristos #define OP_MASK_ME 0 277a2e2270fSchristos #define OP_SH_ME 0 278a2e2270fSchristos #define OP_MASK_MF 0 279a2e2270fSchristos #define OP_SH_MF 0 280a2e2270fSchristos #define OP_MASK_MG 0 281a2e2270fSchristos #define OP_SH_MG 0 282a2e2270fSchristos #define OP_MASK_MH 0 283a2e2270fSchristos #define OP_SH_MH 0 284a2e2270fSchristos #define OP_MASK_MJ 0 285a2e2270fSchristos #define OP_SH_MJ 0 286a2e2270fSchristos #define OP_MASK_ML 0 287a2e2270fSchristos #define OP_SH_ML 0 288a2e2270fSchristos #define OP_MASK_MM 0 289a2e2270fSchristos #define OP_SH_MM 0 290a2e2270fSchristos #define OP_MASK_MN 0 291a2e2270fSchristos #define OP_SH_MN 0 292a2e2270fSchristos #define OP_MASK_MP 0 293a2e2270fSchristos #define OP_SH_MP 0 294a2e2270fSchristos #define OP_MASK_MQ 0 295a2e2270fSchristos #define OP_SH_MQ 0 296a2e2270fSchristos #define OP_MASK_IMMA 0 297a2e2270fSchristos #define OP_SH_IMMA 0 298a2e2270fSchristos #define OP_MASK_IMMB 0 299a2e2270fSchristos #define OP_SH_IMMB 0 300a2e2270fSchristos #define OP_MASK_IMMC 0 301a2e2270fSchristos #define OP_SH_IMMC 0 302a2e2270fSchristos #define OP_MASK_IMMF 0 303a2e2270fSchristos #define OP_SH_IMMF 0 304a2e2270fSchristos #define OP_MASK_IMMG 0 305a2e2270fSchristos #define OP_SH_IMMG 0 306a2e2270fSchristos #define OP_MASK_IMMH 0 307a2e2270fSchristos #define OP_SH_IMMH 0 308a2e2270fSchristos #define OP_MASK_IMMI 0 309a2e2270fSchristos #define OP_SH_IMMI 0 310a2e2270fSchristos #define OP_MASK_IMMJ 0 311a2e2270fSchristos #define OP_SH_IMMJ 0 312a2e2270fSchristos #define OP_MASK_IMML 0 313a2e2270fSchristos #define OP_SH_IMML 0 314a2e2270fSchristos #define OP_MASK_IMMM 0 315a2e2270fSchristos #define OP_SH_IMMM 0 316a2e2270fSchristos #define OP_MASK_IMMN 0 317a2e2270fSchristos #define OP_SH_IMMN 0 318a2e2270fSchristos #define OP_MASK_IMMO 0 319a2e2270fSchristos #define OP_SH_IMMO 0 320a2e2270fSchristos #define OP_MASK_IMMP 0 321a2e2270fSchristos #define OP_SH_IMMP 0 322a2e2270fSchristos #define OP_MASK_IMMQ 0 323a2e2270fSchristos #define OP_SH_IMMQ 0 324a2e2270fSchristos #define OP_MASK_IMMU 0 325a2e2270fSchristos #define OP_SH_IMMU 0 326a2e2270fSchristos #define OP_MASK_IMMW 0 327a2e2270fSchristos #define OP_SH_IMMW 0 328a2e2270fSchristos #define OP_MASK_IMMX 0 329a2e2270fSchristos #define OP_SH_IMMX 0 330a2e2270fSchristos #define OP_MASK_IMMY 0 331a2e2270fSchristos #define OP_SH_IMMY 0 332a2e2270fSchristos 33303467a24Schristos /* Enhanced VA Scheme */ 33403467a24Schristos #define OP_SH_EVAOFFSET 7 33503467a24Schristos #define OP_MASK_EVAOFFSET 0x1ff 33603467a24Schristos 33703467a24Schristos /* Enumerates the various types of MIPS operand. */ 33803467a24Schristos enum mips_operand_type { 33903467a24Schristos /* Described by mips_int_operand. */ 34003467a24Schristos OP_INT, 34103467a24Schristos 34203467a24Schristos /* Described by mips_mapped_int_operand. */ 34303467a24Schristos OP_MAPPED_INT, 34403467a24Schristos 34503467a24Schristos /* Described by mips_msb_operand. */ 34603467a24Schristos OP_MSB, 34703467a24Schristos 34803467a24Schristos /* Described by mips_reg_operand. */ 34903467a24Schristos OP_REG, 35003467a24Schristos 35103467a24Schristos /* Like OP_REG, but can be omitted if the register is the same as the 35203467a24Schristos previous operand. */ 35303467a24Schristos OP_OPTIONAL_REG, 35403467a24Schristos 35503467a24Schristos /* Described by mips_reg_pair_operand. */ 35603467a24Schristos OP_REG_PAIR, 35703467a24Schristos 35803467a24Schristos /* Described by mips_pcrel_operand. */ 35903467a24Schristos OP_PCREL, 36003467a24Schristos 36103467a24Schristos /* A performance register. The field is 5 bits in size, but the supported 36203467a24Schristos values are much more restricted. */ 36303467a24Schristos OP_PERF_REG, 36403467a24Schristos 36503467a24Schristos /* The final operand in a microMIPS ADDIUSP instruction. It mostly acts 36603467a24Schristos as a normal 9-bit signed offset that is multiplied by four, but there 36703467a24Schristos are four special cases: 36803467a24Schristos 36903467a24Schristos -2 * 4 => -258 * 4 37003467a24Schristos -1 * 4 => -257 * 4 37103467a24Schristos 0 * 4 => 256 * 4 37203467a24Schristos 1 * 4 => 257 * 4. */ 37303467a24Schristos OP_ADDIUSP_INT, 37403467a24Schristos 37503467a24Schristos /* The target of a (D)CLO or (D)CLZ instruction. The operand spans two 37603467a24Schristos 5-bit register fields, both of which must be set to the destination 37703467a24Schristos register. */ 37803467a24Schristos OP_CLO_CLZ_DEST, 37903467a24Schristos 38003467a24Schristos /* A register list for a microMIPS LWM or SWM instruction. The operand 38103467a24Schristos size determines whether the 16-bit or 32-bit encoding is required. */ 38203467a24Schristos OP_LWM_SWM_LIST, 38303467a24Schristos 38403467a24Schristos /* The register list for an emulated MIPS16 ENTRY or EXIT instruction. */ 38503467a24Schristos OP_ENTRY_EXIT_LIST, 38603467a24Schristos 38703467a24Schristos /* The register list and frame size for a MIPS16 SAVE or RESTORE 38803467a24Schristos instruction. */ 38903467a24Schristos OP_SAVE_RESTORE_LIST, 39003467a24Schristos 39103467a24Schristos /* A 10-bit field VVVVVNNNNN used for octobyte and quadhalf instructions: 39203467a24Schristos 39303467a24Schristos V Meaning 39403467a24Schristos ----- ------- 39503467a24Schristos 0EEE0 8 copies of $vN[E], OB format 39603467a24Schristos 0EE01 4 copies of $vN[E], QH format 39703467a24Schristos 10110 all 8 elements of $vN, OB format 39803467a24Schristos 10101 all 4 elements of $vN, QH format 39903467a24Schristos 11110 8 copies of immediate N, OB format 40003467a24Schristos 11101 4 copies of immediate N, QH format. */ 40103467a24Schristos OP_MDMX_IMM_REG, 40203467a24Schristos 40303467a24Schristos /* A register operand that must match the destination register. */ 40403467a24Schristos OP_REPEAT_DEST_REG, 40503467a24Schristos 40603467a24Schristos /* A register operand that must match the previous register. */ 40703467a24Schristos OP_REPEAT_PREV_REG, 40803467a24Schristos 40903467a24Schristos /* $pc, which has no encoding in the architectural instruction. */ 41003467a24Schristos OP_PC, 41103467a24Schristos 4124559860eSchristos /* $28, which has no encoding in the MIPS16e architectural instruction. */ 4134559860eSchristos OP_REG28, 4144559860eSchristos 41503467a24Schristos /* A 4-bit XYZW channel mask or 2-bit XYZW index; the size determines 41603467a24Schristos which. */ 41703467a24Schristos OP_VU0_SUFFIX, 41803467a24Schristos 41903467a24Schristos /* Like OP_VU0_SUFFIX, but used when the operand's value has already 42003467a24Schristos been set. Any suffix used here must match the previous value. */ 42103467a24Schristos OP_VU0_MATCH_SUFFIX, 42203467a24Schristos 42303467a24Schristos /* An index selected by an integer, e.g. [1]. */ 42403467a24Schristos OP_IMM_INDEX, 42503467a24Schristos 42603467a24Schristos /* An index selected by a register, e.g. [$2]. */ 427968cf8f2Schristos OP_REG_INDEX, 428968cf8f2Schristos 429968cf8f2Schristos /* The operand spans two 5-bit register fields, both of which must be set to 430968cf8f2Schristos the source register. */ 431968cf8f2Schristos OP_SAME_RS_RT, 432968cf8f2Schristos 433968cf8f2Schristos /* Described by mips_prev_operand. */ 434968cf8f2Schristos OP_CHECK_PREV, 435968cf8f2Schristos 436968cf8f2Schristos /* A register operand that must not be zero. */ 437968cf8f2Schristos OP_NON_ZERO_REG 43803467a24Schristos }; 43903467a24Schristos 44003467a24Schristos /* Enumerates the types of MIPS register. */ 44103467a24Schristos enum mips_reg_operand_type { 44203467a24Schristos /* General registers $0-$31. Software names like $at can also be used. */ 44303467a24Schristos OP_REG_GP, 44403467a24Schristos 44503467a24Schristos /* Floating-point registers $f0-$f31. */ 44603467a24Schristos OP_REG_FP, 44703467a24Schristos 44803467a24Schristos /* Coprocessor condition code registers $cc0-$cc7. FPU condition codes 44903467a24Schristos can also be written $fcc0-$fcc7. */ 45003467a24Schristos OP_REG_CCC, 45103467a24Schristos 45203467a24Schristos /* FPRs used in a vector capacity. They can be written $f0-$f31 45303467a24Schristos or $v0-$v31, although the latter form is not used for the VR5400 45403467a24Schristos vector instructions. */ 45503467a24Schristos OP_REG_VEC, 45603467a24Schristos 45703467a24Schristos /* DSP accumulator registers $ac0-$ac3. */ 45803467a24Schristos OP_REG_ACC, 45903467a24Schristos 46003467a24Schristos /* Coprocessor registers $0-$31. Mnemonic names like c0_cause can 46103467a24Schristos also be used in some contexts. */ 46203467a24Schristos OP_REG_COPRO, 46303467a24Schristos 4644b169a6bSchristos /* Coprocessor control registers $0-$31. Mnemonic names like c1_fcsr can 4654b169a6bSchristos also be used in some contexts. */ 4664b169a6bSchristos OP_REG_CONTROL, 4674b169a6bSchristos 46803467a24Schristos /* Hardware registers $0-$31. Mnemonic names like hwr_cpunum can 46903467a24Schristos also be used in some contexts. */ 47003467a24Schristos OP_REG_HW, 47103467a24Schristos 47203467a24Schristos /* Floating-point registers $vf0-$vf31. */ 47303467a24Schristos OP_REG_VF, 47403467a24Schristos 47503467a24Schristos /* Integer registers $vi0-$vi31. */ 47603467a24Schristos OP_REG_VI, 47703467a24Schristos 47803467a24Schristos /* R5900 VU0 registers $I, $Q, $R and $ACC. */ 47903467a24Schristos OP_REG_R5900_I, 48003467a24Schristos OP_REG_R5900_Q, 48103467a24Schristos OP_REG_R5900_R, 48203467a24Schristos OP_REG_R5900_ACC, 48303467a24Schristos 48403467a24Schristos /* MSA registers $w0-$w31. */ 48503467a24Schristos OP_REG_MSA, 48603467a24Schristos 48703467a24Schristos /* MSA control registers $0-$31. */ 48803467a24Schristos OP_REG_MSA_CTRL 48903467a24Schristos }; 49003467a24Schristos 49103467a24Schristos /* Base class for all operands. */ 49203467a24Schristos struct mips_operand 49303467a24Schristos { 49403467a24Schristos /* The type of the operand. */ 49503467a24Schristos enum mips_operand_type type; 49603467a24Schristos 49703467a24Schristos /* The operand occupies SIZE bits of the instruction, starting at LSB. */ 49803467a24Schristos unsigned short size; 49903467a24Schristos unsigned short lsb; 50003467a24Schristos }; 50103467a24Schristos 50203467a24Schristos /* Describes an integer operand with a regular encoding pattern. */ 50303467a24Schristos struct mips_int_operand 50403467a24Schristos { 50503467a24Schristos struct mips_operand root; 50603467a24Schristos 50703467a24Schristos /* The low ROOT.SIZE bits of MAX_VAL encodes (MAX_VAL + BIAS) << SHIFT. 50803467a24Schristos The cyclically previous field value encodes 1 << SHIFT less than that, 50903467a24Schristos and so on. E.g. 51003467a24Schristos 51103467a24Schristos - for { { T, 4, L }, 14, 0, 0 }, field values 0...14 encode themselves, 51203467a24Schristos but 15 encodes -1. 51303467a24Schristos 51403467a24Schristos - { { T, 8, L }, 127, 0, 2 } is a normal signed 8-bit operand that is 51503467a24Schristos shifted left two places. 51603467a24Schristos 51703467a24Schristos - { { T, 3, L }, 8, 0, 0 } is a normal unsigned 3-bit operand except 51803467a24Schristos that 0 encodes 8. 51903467a24Schristos 52003467a24Schristos - { { ... }, 0, 1, 3 } means that N encodes (N + 1) << 3. */ 52103467a24Schristos unsigned int max_val; 52203467a24Schristos int bias; 52303467a24Schristos unsigned int shift; 52403467a24Schristos 52503467a24Schristos /* True if the operand should be printed as hex rather than decimal. */ 5264b169a6bSchristos bool print_hex; 52703467a24Schristos }; 52803467a24Schristos 52903467a24Schristos /* Uses a lookup table to describe a small integer operand. */ 53003467a24Schristos struct mips_mapped_int_operand 53103467a24Schristos { 53203467a24Schristos struct mips_operand root; 53303467a24Schristos 53403467a24Schristos /* Maps each encoding value to the integer that it represents. */ 53503467a24Schristos const int *int_map; 53603467a24Schristos 53703467a24Schristos /* True if the operand should be printed as hex rather than decimal. */ 5384b169a6bSchristos bool print_hex; 53903467a24Schristos }; 54003467a24Schristos 54103467a24Schristos /* An operand that encodes the most significant bit position of a bitfield. 54203467a24Schristos Given a bitfield that spans bits [MSB, LSB], some operands of this type 54303467a24Schristos encode MSB directly while others encode MSB - LSB. Each operand of this 54403467a24Schristos type is preceded by an integer operand that specifies LSB. 54503467a24Schristos 54603467a24Schristos The assembly form varies between instructions. For some instructions, 54703467a24Schristos such as EXT, the operand is written as the bitfield size. For others, 54803467a24Schristos such as EXTS, it is written in raw MSB - LSB form. */ 54903467a24Schristos struct mips_msb_operand 55003467a24Schristos { 55103467a24Schristos struct mips_operand root; 55203467a24Schristos 55303467a24Schristos /* The assembly-level operand encoded by a field value of 0. */ 55403467a24Schristos int bias; 55503467a24Schristos 55603467a24Schristos /* True if the operand encodes MSB directly, false if it encodes 55703467a24Schristos MSB - LSB. */ 5584b169a6bSchristos bool add_lsb; 55903467a24Schristos 56003467a24Schristos /* The maximum value of MSB + 1. */ 56103467a24Schristos unsigned int opsize; 56203467a24Schristos }; 56303467a24Schristos 56403467a24Schristos /* Describes a single register operand. */ 56503467a24Schristos struct mips_reg_operand 56603467a24Schristos { 56703467a24Schristos struct mips_operand root; 56803467a24Schristos 56903467a24Schristos /* The type of register. */ 57003467a24Schristos enum mips_reg_operand_type reg_type; 57103467a24Schristos 57203467a24Schristos /* If nonnull, REG_MAP[N] gives the register associated with encoding N, 57303467a24Schristos otherwise the encoding is the same as the register number. */ 57403467a24Schristos const unsigned char *reg_map; 57503467a24Schristos }; 57603467a24Schristos 577968cf8f2Schristos /* Describes an operand that which must match a condition based on the 578968cf8f2Schristos previous operand. */ 579968cf8f2Schristos struct mips_check_prev_operand 580968cf8f2Schristos { 581968cf8f2Schristos struct mips_operand root; 582968cf8f2Schristos 5834b169a6bSchristos bool greater_than_ok; 5844b169a6bSchristos bool less_than_ok; 5854b169a6bSchristos bool equal_ok; 5864b169a6bSchristos bool zero_ok; 587968cf8f2Schristos }; 588968cf8f2Schristos 58903467a24Schristos /* Describes an operand that encodes a pair of registers. */ 59003467a24Schristos struct mips_reg_pair_operand 59103467a24Schristos { 59203467a24Schristos struct mips_operand root; 59303467a24Schristos 59403467a24Schristos /* The type of register. */ 59503467a24Schristos enum mips_reg_operand_type reg_type; 59603467a24Schristos 59703467a24Schristos /* Encoding N represents REG1_MAP[N], REG2_MAP[N]. */ 59803467a24Schristos unsigned char *reg1_map; 59903467a24Schristos unsigned char *reg2_map; 60003467a24Schristos }; 60103467a24Schristos 60203467a24Schristos /* Describes an operand that is calculated relative to a base PC. 60303467a24Schristos The base PC is usually the address of the following instruction, 60403467a24Schristos but the rules for MIPS16 instructions like ADDIUPC are more complicated. */ 60503467a24Schristos struct mips_pcrel_operand 60603467a24Schristos { 60703467a24Schristos /* Encodes the offset. */ 60803467a24Schristos struct mips_int_operand root; 60903467a24Schristos 61003467a24Schristos /* The low ALIGN_LOG2 bits of the base PC are cleared to give PC', 61103467a24Schristos which is then added to the offset encoded by ROOT. */ 61203467a24Schristos unsigned int align_log2 : 8; 61303467a24Schristos 61403467a24Schristos /* If INCLUDE_ISA_BIT, the ISA bit of the original base PC is then 61503467a24Schristos reinstated. This is true for jumps and branches and false for 61603467a24Schristos PC-relative data instructions. */ 61703467a24Schristos unsigned int include_isa_bit : 1; 61803467a24Schristos 61903467a24Schristos /* If FLIP_ISA_BIT, the ISA bit of the result is inverted. 62003467a24Schristos This is true for JALX and false otherwise. */ 62103467a24Schristos unsigned int flip_isa_bit : 1; 62203467a24Schristos }; 62303467a24Schristos 62403467a24Schristos /* Return true if the assembly syntax allows OPERAND to be omitted. */ 62503467a24Schristos 6264b169a6bSchristos static inline bool 62703467a24Schristos mips_optional_operand_p (const struct mips_operand *operand) 62803467a24Schristos { 62903467a24Schristos return (operand->type == OP_OPTIONAL_REG 63003467a24Schristos || operand->type == OP_REPEAT_PREV_REG); 63103467a24Schristos } 63203467a24Schristos 63303467a24Schristos /* Return a version of INSN in which the field specified by OPERAND 63403467a24Schristos has value UVAL. */ 63503467a24Schristos 63603467a24Schristos static inline unsigned int 63703467a24Schristos mips_insert_operand (const struct mips_operand *operand, unsigned int insn, 63803467a24Schristos unsigned int uval) 63903467a24Schristos { 64003467a24Schristos unsigned int mask; 64103467a24Schristos 64203467a24Schristos mask = (1 << operand->size) - 1; 64303467a24Schristos insn &= ~(mask << operand->lsb); 64403467a24Schristos insn |= (uval & mask) << operand->lsb; 64503467a24Schristos return insn; 64603467a24Schristos } 64703467a24Schristos 64803467a24Schristos /* Extract OPERAND from instruction INSN. */ 64903467a24Schristos 65003467a24Schristos static inline unsigned int 65103467a24Schristos mips_extract_operand (const struct mips_operand *operand, unsigned int insn) 65203467a24Schristos { 65303467a24Schristos return (insn >> operand->lsb) & ((1 << operand->size) - 1); 65403467a24Schristos } 65503467a24Schristos 65603467a24Schristos /* UVAL is the value encoded by OPERAND. Return it in signed form. */ 65703467a24Schristos 65803467a24Schristos static inline int 65903467a24Schristos mips_signed_operand (const struct mips_operand *operand, unsigned int uval) 66003467a24Schristos { 66103467a24Schristos unsigned int sign_bit, mask; 66203467a24Schristos 66303467a24Schristos mask = (1 << operand->size) - 1; 66403467a24Schristos sign_bit = 1 << (operand->size - 1); 66503467a24Schristos return ((uval + sign_bit) & mask) - sign_bit; 66603467a24Schristos } 66703467a24Schristos 66803467a24Schristos /* Return the integer that OPERAND encodes as UVAL. */ 66903467a24Schristos 67003467a24Schristos static inline int 67103467a24Schristos mips_decode_int_operand (const struct mips_int_operand *operand, 67203467a24Schristos unsigned int uval) 67303467a24Schristos { 67403467a24Schristos uval |= (operand->max_val - uval) & -(1 << operand->root.size); 67503467a24Schristos uval += operand->bias; 67603467a24Schristos uval <<= operand->shift; 67703467a24Schristos return uval; 67803467a24Schristos } 67903467a24Schristos 68003467a24Schristos /* Return the maximum value that can be encoded by OPERAND. */ 68103467a24Schristos 68203467a24Schristos static inline int 68303467a24Schristos mips_int_operand_max (const struct mips_int_operand *operand) 68403467a24Schristos { 68503467a24Schristos return (operand->max_val + operand->bias) << operand->shift; 68603467a24Schristos } 68703467a24Schristos 68803467a24Schristos /* Return the minimum value that can be encoded by OPERAND. */ 68903467a24Schristos 69003467a24Schristos static inline int 69103467a24Schristos mips_int_operand_min (const struct mips_int_operand *operand) 69203467a24Schristos { 69303467a24Schristos unsigned int mask; 69403467a24Schristos 69503467a24Schristos mask = (1 << operand->root.size) - 1; 69603467a24Schristos return mips_int_operand_max (operand) - (mask << operand->shift); 69703467a24Schristos } 69803467a24Schristos 69903467a24Schristos /* Return the register that OPERAND encodes as UVAL. */ 70003467a24Schristos 70103467a24Schristos static inline int 70203467a24Schristos mips_decode_reg_operand (const struct mips_reg_operand *operand, 70303467a24Schristos unsigned int uval) 70403467a24Schristos { 70503467a24Schristos if (operand->reg_map) 70603467a24Schristos uval = operand->reg_map[uval]; 70703467a24Schristos return uval; 70803467a24Schristos } 70903467a24Schristos 71003467a24Schristos /* PC-relative operand OPERAND has value UVAL and is relative to BASE_PC. 71103467a24Schristos Return the address that it encodes. */ 71203467a24Schristos 71303467a24Schristos static inline bfd_vma 71403467a24Schristos mips_decode_pcrel_operand (const struct mips_pcrel_operand *operand, 71503467a24Schristos bfd_vma base_pc, unsigned int uval) 71603467a24Schristos { 71703467a24Schristos bfd_vma addr; 71803467a24Schristos 71903467a24Schristos addr = base_pc & -(1 << operand->align_log2); 72003467a24Schristos addr += mips_decode_int_operand (&operand->root, uval); 72103467a24Schristos if (operand->include_isa_bit) 72203467a24Schristos addr |= base_pc & 1; 72303467a24Schristos if (operand->flip_isa_bit) 72403467a24Schristos addr ^= 1; 72503467a24Schristos return addr; 72603467a24Schristos } 72703467a24Schristos 72898b9484cSchristos /* This structure holds information for a particular instruction. */ 72998b9484cSchristos 73098b9484cSchristos struct mips_opcode 73198b9484cSchristos { 73298b9484cSchristos /* The name of the instruction. */ 73398b9484cSchristos const char *name; 73498b9484cSchristos /* A string describing the arguments for this instruction. */ 73598b9484cSchristos const char *args; 73698b9484cSchristos /* The basic opcode for the instruction. When assembling, this 73798b9484cSchristos opcode is modified by the arguments to produce the actual opcode 73898b9484cSchristos that is used. If pinfo is INSN_MACRO, then this is 0. */ 73998b9484cSchristos unsigned long match; 74098b9484cSchristos /* If pinfo is not INSN_MACRO, then this is a bit mask for the 74198b9484cSchristos relevant portions of the opcode when disassembling. If the 74298b9484cSchristos actual opcode anded with the match field equals the opcode field, 74398b9484cSchristos then we have found the correct instruction. If pinfo is 74498b9484cSchristos INSN_MACRO, then this field is the macro identifier. */ 74598b9484cSchristos unsigned long mask; 74698b9484cSchristos /* For a macro, this is INSN_MACRO. Otherwise, it is a collection 74798b9484cSchristos of bits describing the instruction, notably any relevant hazard 74898b9484cSchristos information. */ 74998b9484cSchristos unsigned long pinfo; 75098b9484cSchristos /* A collection of additional bits describing the instruction. */ 75198b9484cSchristos unsigned long pinfo2; 75298b9484cSchristos /* A collection of bits describing the instruction sets of which this 75398b9484cSchristos instruction or macro is a member. */ 75498b9484cSchristos unsigned long membership; 75503467a24Schristos /* A collection of bits describing the ASE of which this instruction 75603467a24Schristos or macro is a member. */ 75703467a24Schristos unsigned long ase; 758a2e2270fSchristos /* A collection of bits describing the instruction sets of which this 759a2e2270fSchristos instruction or macro is not a member. */ 760a2e2270fSchristos unsigned long exclusions; 76198b9484cSchristos }; 76298b9484cSchristos 763796c32c9Schristos /* Return true if MO is an instruction that requires 32-bit encoding. */ 764796c32c9Schristos 7654b169a6bSchristos static inline bool 766796c32c9Schristos mips_opcode_32bit_p (const struct mips_opcode *mo) 767796c32c9Schristos { 768796c32c9Schristos return mo->mask >> 16 != 0; 769796c32c9Schristos } 770796c32c9Schristos 77198b9484cSchristos /* These are the characters which may appear in the args field of an 77298b9484cSchristos instruction. They appear in the order in which the fields appear 77398b9484cSchristos when the instruction is used. Commas and parentheses in the args 77498b9484cSchristos string are ignored when assembling, and written into the output 77598b9484cSchristos when disassembling. 77698b9484cSchristos 77798b9484cSchristos Each of these characters corresponds to a mask field defined above. 77898b9484cSchristos 77903467a24Schristos "1" 5 bit sync type (OP_*_STYPE) 78098b9484cSchristos "<" 5 bit shift amount (OP_*_SHAMT) 78198b9484cSchristos ">" shift amount between 32 and 63, stored after subtracting 32 (OP_*_SHAMT) 78298b9484cSchristos "a" 26 bit target address (OP_*_TARGET) 78303467a24Schristos "+i" likewise, but flips bit 0 78498b9484cSchristos "b" 5 bit base register (OP_*_RS) 78598b9484cSchristos "c" 10 bit breakpoint code (OP_*_CODE) 78698b9484cSchristos "d" 5 bit destination register specifier (OP_*_RD) 78798b9484cSchristos "h" 5 bit prefx hint (OP_*_PREFX) 78898b9484cSchristos "i" 16 bit unsigned immediate (OP_*_IMMEDIATE) 78998b9484cSchristos "j" 16 bit signed immediate (OP_*_DELTA) 79098b9484cSchristos "k" 5 bit cache opcode in target register position (OP_*_CACHE) 79198b9484cSchristos "o" 16 bit signed offset (OP_*_DELTA) 79298b9484cSchristos "p" 16 bit PC relative branch target address (OP_*_DELTA) 79398b9484cSchristos "q" 10 bit extra breakpoint code (OP_*_CODE2) 79498b9484cSchristos "r" 5 bit same register used as both source and target (OP_*_RS) 79598b9484cSchristos "s" 5 bit source register specifier (OP_*_RS) 79698b9484cSchristos "t" 5 bit target register (OP_*_RT) 79798b9484cSchristos "u" 16 bit upper 16 bits of address (OP_*_IMMEDIATE) 79898b9484cSchristos "v" 5 bit same register used as both source and destination (OP_*_RS) 79998b9484cSchristos "w" 5 bit same register used as both target and destination (OP_*_RT) 80098b9484cSchristos "U" 5 bit same destination register in both OP_*_RD and OP_*_RT 80198b9484cSchristos (used by clo and clz) 80298b9484cSchristos "C" 25 bit coprocessor function code (OP_*_COPZ) 80398b9484cSchristos "B" 20 bit syscall/breakpoint function code (OP_*_CODE20) 80498b9484cSchristos "J" 19 bit wait function code (OP_*_CODE19) 80598b9484cSchristos "x" accept and ignore register name 80698b9484cSchristos "z" must be zero register 80798b9484cSchristos "K" 5 bit Hardware Register (rdhwr instruction) (OP_*_RD) 80898b9484cSchristos "+A" 5 bit ins/ext/dins/dext/dinsm/dextm position, which becomes 809a2e2270fSchristos LSB (OP_*_SHAMT; OP_*_EXTLSB or OP_*_STYPE may be used for 810a2e2270fSchristos microMIPS compatibility). 81198b9484cSchristos Enforces: 0 <= pos < 32. 81298b9484cSchristos "+B" 5 bit ins/dins size, which becomes MSB (OP_*_INSMSB). 81398b9484cSchristos Requires that "+A" or "+E" occur first to set position. 81498b9484cSchristos Enforces: 0 < (pos+size) <= 32. 81598b9484cSchristos "+C" 5 bit ext/dext size, which becomes MSBD (OP_*_EXTMSBD). 81698b9484cSchristos Requires that "+A" or "+E" occur first to set position. 81798b9484cSchristos Enforces: 0 < (pos+size) <= 32. 81898b9484cSchristos (Also used by "dext" w/ different limits, but limits for 81998b9484cSchristos that are checked by the M_DEXT macro.) 82098b9484cSchristos "+E" 5 bit dinsu/dextu position, which becomes LSB-32 (OP_*_SHAMT). 82198b9484cSchristos Enforces: 32 <= pos < 64. 82298b9484cSchristos "+F" 5 bit "dinsm/dinsu" size, which becomes MSB-32 (OP_*_INSMSB). 82398b9484cSchristos Requires that "+A" or "+E" occur first to set position. 82498b9484cSchristos Enforces: 32 < (pos+size) <= 64. 82598b9484cSchristos "+G" 5 bit "dextm" size, which becomes MSBD-32 (OP_*_EXTMSBD). 82698b9484cSchristos Requires that "+A" or "+E" occur first to set position. 82798b9484cSchristos Enforces: 32 < (pos+size) <= 64. 82898b9484cSchristos "+H" 5 bit "dextu" size, which becomes MSBD (OP_*_EXTMSBD). 82998b9484cSchristos Requires that "+A" or "+E" occur first to set position. 83098b9484cSchristos Enforces: 32 < (pos+size) <= 64. 83198b9484cSchristos 83298b9484cSchristos Floating point instructions: 83398b9484cSchristos "D" 5 bit destination register (OP_*_FD) 83498b9484cSchristos "M" 3 bit compare condition code (OP_*_CCC) (only used for mips4 and up) 83598b9484cSchristos "N" 3 bit branch condition code (OP_*_BCC) (only used for mips4 and up) 83698b9484cSchristos "S" 5 bit fs source 1 register (OP_*_FS) 83798b9484cSchristos "T" 5 bit ft source 2 register (OP_*_FT) 83898b9484cSchristos "R" 5 bit fr source 3 register (OP_*_FR) 83998b9484cSchristos "V" 5 bit same register used as floating source and destination (OP_*_FS) 84098b9484cSchristos "W" 5 bit same register used as floating target and destination (OP_*_FT) 84198b9484cSchristos 84298b9484cSchristos Coprocessor instructions: 84398b9484cSchristos "E" 5 bit target register (OP_*_RT) 84498b9484cSchristos "G" 5 bit destination register (OP_*_RD) 84598b9484cSchristos "H" 3 bit sel field for (d)mtc* and (d)mfc* (OP_*_SEL) 84698b9484cSchristos "P" 5 bit performance-monitor register (OP_*_PERFREG) 84798b9484cSchristos "e" 5 bit vector register byte specifier (OP_*_VECBYTE) 8484b169a6bSchristos "g" 5 bit control destination register (OP_*_RD) 84998b9484cSchristos "%" 3 bit immediate vr5400 vector alignment operand (OP_*_VECALIGN) 85098b9484cSchristos 85198b9484cSchristos Macro instructions: 85298b9484cSchristos "A" General 32 bit expression 85398b9484cSchristos "I" 32 bit immediate (value placed in imm_expr). 85498b9484cSchristos "F" 64 bit floating point constant in .rdata 85598b9484cSchristos "L" 64 bit floating point constant in .lit8 85698b9484cSchristos "f" 32 bit floating point constant 85798b9484cSchristos "l" 32 bit floating point constant in .lit4 85898b9484cSchristos 85903467a24Schristos MDMX and VR5400 instruction operands (note that while these use the 86003467a24Schristos FP register fields, the MDMX instructions accept both $fN and $vN names 86103467a24Schristos for the registers): 86203467a24Schristos "O" alignment offset (OP_*_ALN) 86303467a24Schristos "Q" vector/scalar/immediate source (OP_*_VSEL and OP_*_FT) 86403467a24Schristos "X" destination register (OP_*_FD) 86503467a24Schristos "Y" source register (OP_*_FS) 86603467a24Schristos "Z" source register (OP_*_FT) 86703467a24Schristos 86803467a24Schristos R5900 VU0 Macromode instructions: 86903467a24Schristos "+5" 5 bit floating point register (FD) 87003467a24Schristos "+6" 5 bit floating point register (FS) 87103467a24Schristos "+7" 5 bit floating point register (FT) 87203467a24Schristos "+8" 5 bit integer register (FD) 87303467a24Schristos "+9" 5 bit integer register (FS) 87403467a24Schristos "+0" 5 bit integer register (FT) 87503467a24Schristos "+K" match an existing 4-bit channel mask starting at bit 21 87603467a24Schristos "+L" 2-bit channel index starting at bit 21 87703467a24Schristos "+M" 2-bit channel index starting at bit 23 87803467a24Schristos "+N" match an existing 2-bit channel index starting at bit 0 87903467a24Schristos "+f" 15 bit immediate for VCALLMS 88003467a24Schristos "+g" 5 bit signed immediate for VIADDI 88103467a24Schristos "+m" $ACC register (syntax only) 88203467a24Schristos "+q" $Q register (syntax only) 88303467a24Schristos "+r" $R register (syntax only) 88403467a24Schristos "+y" $I register (syntax only) 88503467a24Schristos "#+" "++" decorator in ($reg++) sequence 88603467a24Schristos "#-" "--" decorator in (--$reg) sequence 88798b9484cSchristos 88898b9484cSchristos DSP ASE usage: 88998b9484cSchristos "2" 2 bit unsigned immediate for byte align (OP_*_BP) 89098b9484cSchristos "3" 3 bit unsigned immediate (OP_*_SA3) 89198b9484cSchristos "4" 4 bit unsigned immediate (OP_*_SA4) 89298b9484cSchristos "5" 8 bit unsigned immediate (OP_*_IMM8) 89398b9484cSchristos "6" 5 bit unsigned immediate (OP_*_RS) 89498b9484cSchristos "7" 2 bit dsp accumulator register (OP_*_DSPACC) 89598b9484cSchristos "8" 6 bit unsigned immediate (OP_*_WRDSP) 89698b9484cSchristos "9" 2 bit dsp accumulator register (OP_*_DSPACC_S) 89798b9484cSchristos "0" 6 bit signed immediate (OP_*_DSPSFT) 89898b9484cSchristos ":" 7 bit signed immediate (OP_*_DSPSFT_7) 89998b9484cSchristos "'" 6 bit unsigned immediate (OP_*_RDDSP) 90098b9484cSchristos "@" 10 bit signed immediate (OP_*_IMM10) 90198b9484cSchristos 90298b9484cSchristos MT ASE usage: 90398b9484cSchristos "!" 1 bit usermode flag (OP_*_MT_U) 90498b9484cSchristos "$" 1 bit load high flag (OP_*_MT_H) 90598b9484cSchristos "*" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_T) 90698b9484cSchristos "&" 2 bit dsp/smartmips accumulator register (OP_*_MTACC_D) 9074b169a6bSchristos "y" 5 bit control target register (OP_*_RT) 90898b9484cSchristos "+t" 5 bit coprocessor 0 destination register (OP_*_RT) 90998b9484cSchristos 910a2e2270fSchristos MCU ASE usage: 911a2e2270fSchristos "~" 12 bit offset (OP_*_OFFSET12) 912a2e2270fSchristos "\" 3 bit position for aset and aclr (OP_*_3BITPOS) 913a2e2270fSchristos 91403467a24Schristos VIRT ASE usage: 91503467a24Schristos "+J" 10-bit hypcall code (OP_*CODE10) 91603467a24Schristos 91798b9484cSchristos UDI immediates: 91898b9484cSchristos "+1" UDI immediate bits 6-10 91998b9484cSchristos "+2" UDI immediate bits 6-15 92098b9484cSchristos "+3" UDI immediate bits 6-20 92198b9484cSchristos "+4" UDI immediate bits 6-25 92298b9484cSchristos 92398b9484cSchristos Octeon: 92498b9484cSchristos "+x" Bit index field of bbit. Enforces: 0 <= index < 32. 92598b9484cSchristos "+X" Bit index field of bbit aliasing bbit32. Matches if 32 <= index < 64, 92698b9484cSchristos otherwise skips to next candidate. 92798b9484cSchristos "+p" Position field of cins/cins32/exts/exts32. Enforces 0 <= pos < 32. 92898b9484cSchristos "+P" Position field of cins/exts aliasing cins32/exts32. Matches if 92998b9484cSchristos 32 <= pos < 64, otherwise skips to next candidate. 93098b9484cSchristos "+Q" Immediate field of seqi/snei. Enforces -512 <= imm < 512. 93103467a24Schristos "+s" Length-minus-one field of cins32/exts32. Requires msb position 93203467a24Schristos of the field to be <= 31. 93303467a24Schristos "+S" Length-minus-one field of cins/exts. Requires msb position 93403467a24Schristos of the field to be <= 63. 93598b9484cSchristos 9364559860eSchristos Loongson-ext ASE: 93798b9484cSchristos "+a" 8-bit signed offset in bit 6 (OP_*_OFFSET_A) 93898b9484cSchristos "+b" 8-bit signed offset in bit 3 (OP_*_OFFSET_B) 93998b9484cSchristos "+c" 9-bit signed offset in bit 6 (OP_*_OFFSET_C) 94098b9484cSchristos "+z" 5-bit rz register (OP_*_RZ) 94198b9484cSchristos "+Z" 5-bit fz register (OP_*_FZ) 94298b9484cSchristos 9434559860eSchristos interAptiv MR2: 9444559860eSchristos "-m" register list for SAVE/RESTORE instruction 9454559860eSchristos 94603467a24Schristos Enhanced VA Scheme: 94703467a24Schristos "+j" 9-bit signed offset in bit 7 (OP_*_EVAOFFSET) 94803467a24Schristos 94903467a24Schristos MSA Extension: 95003467a24Schristos "+d" 5-bit MSA register (FD) 95103467a24Schristos "+e" 5-bit MSA register (FS) 95203467a24Schristos "+h" 5-bit MSA register (FT) 95303467a24Schristos "+k" 5-bit GPR at bit 6 95403467a24Schristos "+l" 5-bit MSA control register at bit 6 95503467a24Schristos "+n" 5-bit MSA control register at bit 11 95603467a24Schristos "+o" 4-bit vector element index at bit 16 95703467a24Schristos "+u" 3-bit vector element index at bit 16 95803467a24Schristos "+v" 2-bit vector element index at bit 16 95903467a24Schristos "+w" 1-bit vector element index at bit 16 96003467a24Schristos "+T" (-512 .. 511) << 0 at bit 16 96103467a24Schristos "+U" (-512 .. 511) << 1 at bit 16 96203467a24Schristos "+V" (-512 .. 511) << 2 at bit 16 96303467a24Schristos "+W" (-512 .. 511) << 3 at bit 16 96403467a24Schristos "+~" 2 bit LSA/DLSA shift amount from 1 to 4 at bit 6 96503467a24Schristos "+!" 3 bit unsigned bit position at bit 16 96603467a24Schristos "+@" 4 bit unsigned bit position at bit 16 96703467a24Schristos "+#" 6 bit unsigned bit position at bit 16 96803467a24Schristos "+$" 5 bit unsigned immediate at bit 16 96903467a24Schristos "+%" 5 bit signed immediate at bit 16 97003467a24Schristos "+^" 10 bit signed immediate at bit 11 97103467a24Schristos "+&" 0 vector element index 97203467a24Schristos "+*" 5-bit register vector element index at bit 16 97303467a24Schristos "+|" 8-bit mask at bit 16 97403467a24Schristos 975968cf8f2Schristos MIPS R6: 976968cf8f2Schristos "+:" 11-bit mask at bit 0 977968cf8f2Schristos "+'" 26 bit PC relative branch target address 978968cf8f2Schristos "+"" 21 bit PC relative branch target address 979968cf8f2Schristos "+;" 5 bit same register in both OP_*_RS and OP_*_RT 980968cf8f2Schristos "+I" 2bit unsigned bit position at bit 6 981968cf8f2Schristos "+O" 3bit unsigned bit position at bit 6 982968cf8f2Schristos "+R" must be program counter 983968cf8f2Schristos "-a" (-262144 .. 262143) << 2 at bit 0 984968cf8f2Schristos "-b" (-131072 .. 131071) << 3 at bit 0 985968cf8f2Schristos "-d" Same as destination register GP 986968cf8f2Schristos "-s" 5 bit source register specifier (OP_*_RS) not $0 987968cf8f2Schristos "-t" 5 bit source register specifier (OP_*_RT) not $0 988968cf8f2Schristos "-u" 5 bit source register specifier (OP_*_RT) greater than OP_*_RS 989968cf8f2Schristos "-v" 5 bit source register specifier (OP_*_RT) not $0 not OP_*_RS 990968cf8f2Schristos "-w" 5 bit source register specifier (OP_*_RT) less than or equal to OP_*_RS 991968cf8f2Schristos "-x" 5 bit source register specifier (OP_*_RT) greater than or 992968cf8f2Schristos equal to OP_*_RS 993968cf8f2Schristos "-y" 5 bit source register specifier (OP_*_RT) not $0 less than OP_*_RS 994968cf8f2Schristos "-A" symbolic offset (-262144 .. 262143) << 2 at bit 0 995968cf8f2Schristos "-B" symbolic offset (-131072 .. 131071) << 3 at bit 0 996968cf8f2Schristos 9974559860eSchristos GINV ASE usage: 9984559860eSchristos "+\" 2 bit Global TLB invalidate type at bit 8 9994559860eSchristos 100098b9484cSchristos Other: 100198b9484cSchristos "()" parens surrounding optional value 100298b9484cSchristos "," separates operands 100398b9484cSchristos "+" Start of extension sequence. 100498b9484cSchristos 100598b9484cSchristos Characters used so far, for quick reference when adding more: 100698b9484cSchristos "1234567890" 1007968cf8f2Schristos "%[]<>(),+-:'@!#$*&\~" 100898b9484cSchristos "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 10094b169a6bSchristos "abcdef hijkl opqrstuvwxyz" 101098b9484cSchristos 101198b9484cSchristos Extension character sequences used so far ("+" followed by the 101298b9484cSchristos following), for quick reference when adding more: 101303467a24Schristos "1234567890" 10144559860eSchristos "~!@#$%^&*|:'";\" 1015968cf8f2Schristos "ABCEFGHIJKLMNOPQRSTUVWXZ" 101603467a24Schristos "abcdefghijklmnopqrstuvwxyz" 1017968cf8f2Schristos 1018968cf8f2Schristos Extension character sequences used so far ("-" followed by the 1019968cf8f2Schristos following), for quick reference when adding more: 1020968cf8f2Schristos "AB" 10214559860eSchristos "abdmstuvwxy" 102298b9484cSchristos */ 102398b9484cSchristos 102498b9484cSchristos /* These are the bits which may be set in the pinfo field of an 102598b9484cSchristos instructions, if it is not equal to INSN_MACRO. */ 102698b9484cSchristos 102703467a24Schristos /* Writes to operand number N. */ 102803467a24Schristos #define INSN_WRITE_SHIFT 0 102903467a24Schristos #define INSN_WRITE_1 0x00000001 103003467a24Schristos #define INSN_WRITE_2 0x00000002 103103467a24Schristos #define INSN_WRITE_ALL 0x00000003 103203467a24Schristos /* Reads from operand number N. */ 103303467a24Schristos #define INSN_READ_SHIFT 2 103403467a24Schristos #define INSN_READ_1 0x00000004 103503467a24Schristos #define INSN_READ_2 0x00000008 103603467a24Schristos #define INSN_READ_3 0x00000010 103703467a24Schristos #define INSN_READ_4 0x00000020 103803467a24Schristos #define INSN_READ_ALL 0x0000003c 103998b9484cSchristos /* Modifies general purpose register 31. */ 104003467a24Schristos #define INSN_WRITE_GPR_31 0x00000040 104198b9484cSchristos /* Modifies coprocessor condition code. */ 104203467a24Schristos #define INSN_WRITE_COND_CODE 0x00000080 104398b9484cSchristos /* Reads coprocessor condition code. */ 104403467a24Schristos #define INSN_READ_COND_CODE 0x00000100 104598b9484cSchristos /* TLB operation. */ 104603467a24Schristos #define INSN_TLB 0x00000200 104798b9484cSchristos /* Reads coprocessor register other than floating point register. */ 104803467a24Schristos #define INSN_COP 0x00000400 104903467a24Schristos /* Instruction loads value from memory. */ 105003467a24Schristos #define INSN_LOAD_MEMORY 0x00000800 1051968cf8f2Schristos /* Instruction loads value from coprocessor, (may require delay). */ 1052968cf8f2Schristos #define INSN_LOAD_COPROC 0x00001000 105398b9484cSchristos /* Instruction has unconditional branch delay slot. */ 105403467a24Schristos #define INSN_UNCOND_BRANCH_DELAY 0x00002000 105598b9484cSchristos /* Instruction has conditional branch delay slot. */ 105603467a24Schristos #define INSN_COND_BRANCH_DELAY 0x00004000 105798b9484cSchristos /* Conditional branch likely: if branch not taken, insn nullified. */ 105803467a24Schristos #define INSN_COND_BRANCH_LIKELY 0x00008000 1059968cf8f2Schristos /* Moves to coprocessor register, (may require delay). */ 1060968cf8f2Schristos #define INSN_COPROC_MOVE 0x00010000 106198b9484cSchristos /* Loads coprocessor register from memory, requiring delay. */ 106203467a24Schristos #define INSN_COPROC_MEMORY_DELAY 0x00020000 106398b9484cSchristos /* Reads the HI register. */ 106403467a24Schristos #define INSN_READ_HI 0x00040000 106598b9484cSchristos /* Reads the LO register. */ 106603467a24Schristos #define INSN_READ_LO 0x00080000 106798b9484cSchristos /* Modifies the HI register. */ 106803467a24Schristos #define INSN_WRITE_HI 0x00100000 106998b9484cSchristos /* Modifies the LO register. */ 107003467a24Schristos #define INSN_WRITE_LO 0x00200000 1071a2e2270fSchristos /* Not to be placed in a branch delay slot, either architecturally 1072a2e2270fSchristos or for ease of handling (such as with instructions that take a trap). */ 107303467a24Schristos #define INSN_NO_DELAY_SLOT 0x00400000 107498b9484cSchristos /* Instruction stores value into memory. */ 107503467a24Schristos #define INSN_STORE_MEMORY 0x00800000 107698b9484cSchristos /* Instruction uses single precision floating point. */ 107703467a24Schristos #define FP_S 0x01000000 107898b9484cSchristos /* Instruction uses double precision floating point. */ 107903467a24Schristos #define FP_D 0x02000000 108098b9484cSchristos /* Instruction is part of the tx39's integer multiply family. */ 108103467a24Schristos #define INSN_MULT 0x04000000 108203467a24Schristos /* Reads general purpose register 24. */ 108303467a24Schristos #define INSN_READ_GPR_24 0x08000000 108403467a24Schristos /* Writes to general purpose register 24. */ 108503467a24Schristos #define INSN_WRITE_GPR_24 0x10000000 108603467a24Schristos /* A user-defined instruction. */ 108703467a24Schristos #define INSN_UDI 0x20000000 108898b9484cSchristos /* Instruction is actually a macro. It should be ignored by the 108998b9484cSchristos disassembler, and requires special treatment by the assembler. */ 109098b9484cSchristos #define INSN_MACRO 0xffffffff 109198b9484cSchristos 109298b9484cSchristos /* These are the bits which may be set in the pinfo2 field of an 109398b9484cSchristos instruction. */ 109498b9484cSchristos 109598b9484cSchristos /* Instruction is a simple alias (I.E. "move" for daddu/addu/or) */ 109698b9484cSchristos #define INSN2_ALIAS 0x00000001 109798b9484cSchristos /* Instruction reads MDMX accumulator. */ 109898b9484cSchristos #define INSN2_READ_MDMX_ACC 0x00000002 109998b9484cSchristos /* Instruction writes MDMX accumulator. */ 110098b9484cSchristos #define INSN2_WRITE_MDMX_ACC 0x00000004 110198b9484cSchristos /* Macro uses single-precision floating-point instructions. This should 110298b9484cSchristos only be set for macros. For instructions, FP_S in pinfo carries the 110398b9484cSchristos same information. */ 110498b9484cSchristos #define INSN2_M_FP_S 0x00000008 110598b9484cSchristos /* Macro uses double-precision floating-point instructions. This should 110698b9484cSchristos only be set for macros. For instructions, FP_D in pinfo carries the 110798b9484cSchristos same information. */ 110898b9484cSchristos #define INSN2_M_FP_D 0x00000010 1109a2e2270fSchristos /* Instruction has a branch delay slot that requires a 16-bit instruction. */ 111003467a24Schristos #define INSN2_BRANCH_DELAY_16BIT 0x00000020 1111a2e2270fSchristos /* Instruction has a branch delay slot that requires a 32-bit instruction. */ 111203467a24Schristos #define INSN2_BRANCH_DELAY_32BIT 0x00000040 111303467a24Schristos /* Writes to the stack pointer ($29). */ 111403467a24Schristos #define INSN2_WRITE_SP 0x00000080 111503467a24Schristos /* Reads from the stack pointer ($29). */ 111603467a24Schristos #define INSN2_READ_SP 0x00000100 1117a2e2270fSchristos /* Reads the RA ($31) register. */ 111803467a24Schristos #define INSN2_READ_GPR_31 0x00000200 1119a2e2270fSchristos /* Reads the program counter ($pc). */ 112003467a24Schristos #define INSN2_READ_PC 0x00000400 1121a2e2270fSchristos /* Is an unconditional branch insn. */ 112203467a24Schristos #define INSN2_UNCOND_BRANCH 0x00000800 1123a2e2270fSchristos /* Is a conditional branch insn. */ 112403467a24Schristos #define INSN2_COND_BRANCH 0x00001000 112503467a24Schristos /* Reads from $16. This is true of the MIPS16 0x6500 nop. */ 112603467a24Schristos #define INSN2_READ_GPR_16 0x00002000 112703467a24Schristos /* Has an "\.x?y?z?w?" suffix based on mips_vu0_channel_mask. */ 112803467a24Schristos #define INSN2_VU0_CHANNEL_SUFFIX 0x00004000 1129968cf8f2Schristos /* Instruction has a forbidden slot. */ 1130968cf8f2Schristos #define INSN2_FORBIDDEN_SLOT 0x00008000 1131796c32c9Schristos /* Opcode table entry is for a short MIPS16 form only. An extended 1132796c32c9Schristos encoding may still exist, but with a separate opcode table entry 11334559860eSchristos required. In disassembly the presence of this flag in an otherwise 11344559860eSchristos successful match against an extended instruction encoding inhibits 11354559860eSchristos matching against any subsequent short table entry even if it does 11364559860eSchristos not have this flag set. A table entry matching the full extended 11374559860eSchristos encoding is needed or otherwise the final EXTEND entry will apply, 11384559860eSchristos for the disassembly of the prefix only. */ 1139796c32c9Schristos #define INSN2_SHORT_ONLY 0x00010000 1140a2e2270fSchristos 114198b9484cSchristos /* Masks used to mark instructions to indicate which MIPS ISA level 114298b9484cSchristos they were introduced in. INSN_ISA_MASK masks an enumeration that 114398b9484cSchristos specifies the base ISA level(s). The remainder of a 32-bit 114498b9484cSchristos word constructed using these macros is a bitmask of the remaining 114598b9484cSchristos INSN_* values below. */ 114698b9484cSchristos 1147968cf8f2Schristos #define INSN_ISA_MASK 0x0000001ful 114898b9484cSchristos 114998b9484cSchristos /* We cannot start at zero due to ISA_UNKNOWN below. */ 115098b9484cSchristos #define INSN_ISA1 1 115198b9484cSchristos #define INSN_ISA2 2 115298b9484cSchristos #define INSN_ISA3 3 115398b9484cSchristos #define INSN_ISA4 4 115498b9484cSchristos #define INSN_ISA5 5 115598b9484cSchristos #define INSN_ISA32 6 115698b9484cSchristos #define INSN_ISA32R2 7 1157968cf8f2Schristos #define INSN_ISA32R3 8 1158968cf8f2Schristos #define INSN_ISA32R5 9 1159968cf8f2Schristos #define INSN_ISA32R6 10 1160968cf8f2Schristos #define INSN_ISA64 11 1161968cf8f2Schristos #define INSN_ISA64R2 12 1162968cf8f2Schristos #define INSN_ISA64R3 13 1163968cf8f2Schristos #define INSN_ISA64R5 14 1164968cf8f2Schristos #define INSN_ISA64R6 15 116598b9484cSchristos /* Below this point the INSN_* values correspond to combinations of ISAs. 116698b9484cSchristos They are only for use in the opcodes table to indicate membership of 116798b9484cSchristos a combination of ISAs that cannot be expressed using the usual inclusion 116898b9484cSchristos ordering on the above INSN_* values. */ 1169968cf8f2Schristos #define INSN_ISA3_32 16 1170968cf8f2Schristos #define INSN_ISA3_32R2 17 1171968cf8f2Schristos #define INSN_ISA4_32 18 1172968cf8f2Schristos #define INSN_ISA4_32R2 19 1173968cf8f2Schristos #define INSN_ISA5_32R2 20 117498b9484cSchristos 1175968cf8f2Schristos /* The R6 definitions shown below state that they support all previous ISAs. 1176968cf8f2Schristos This is not actually true as some instructions are removed in R6. 1177968cf8f2Schristos The problem is that the removed instructions in R6 come from different 1178968cf8f2Schristos ISAs. One approach to solve this would be to describe in the membership 1179968cf8f2Schristos field of the opcode table the different ISAs an instruction belongs to. 1180968cf8f2Schristos This would require us to create a large amount of different ISA 1181968cf8f2Schristos combinations which is hard to manage. A cleaner approach (which is 1182968cf8f2Schristos implemented here) is to say that R6 is an extension of R5 and then to 1183968cf8f2Schristos deal with the removed instructions by adding instruction exclusions 1184968cf8f2Schristos for R6 in the opcode table. */ 1185968cf8f2Schristos 1186968cf8f2Schristos /* Bit INSN_ISA<X> - 1 of INSN_UPTO<Y> is set if ISA Y includes ISA X. */ 1187968cf8f2Schristos 1188968cf8f2Schristos #define ISAF(X) (1 << (INSN_ISA##X - 1)) 1189968cf8f2Schristos #define INSN_UPTO1 ISAF(1) 1190968cf8f2Schristos #define INSN_UPTO2 INSN_UPTO1 | ISAF(2) 1191968cf8f2Schristos #define INSN_UPTO3 INSN_UPTO2 | ISAF(3) | ISAF(3_32) | ISAF(3_32R2) 1192968cf8f2Schristos #define INSN_UPTO4 INSN_UPTO3 | ISAF(4) | ISAF(4_32) | ISAF(4_32R2) 1193968cf8f2Schristos #define INSN_UPTO5 INSN_UPTO4 | ISAF(5) | ISAF(5_32R2) 1194968cf8f2Schristos #define INSN_UPTO32 INSN_UPTO2 | ISAF(32) | ISAF(3_32) | ISAF(4_32) 1195968cf8f2Schristos #define INSN_UPTO32R2 INSN_UPTO32 | ISAF(32R2) \ 1196968cf8f2Schristos | ISAF(3_32R2) | ISAF(4_32R2) | ISAF(5_32R2) 1197968cf8f2Schristos #define INSN_UPTO32R3 INSN_UPTO32R2 | ISAF(32R3) 1198968cf8f2Schristos #define INSN_UPTO32R5 INSN_UPTO32R3 | ISAF(32R5) 1199968cf8f2Schristos #define INSN_UPTO32R6 INSN_UPTO32R5 | ISAF(32R6) 1200968cf8f2Schristos #define INSN_UPTO64 INSN_UPTO5 | ISAF(64) | ISAF(32) 1201968cf8f2Schristos #define INSN_UPTO64R2 INSN_UPTO64 | ISAF(64R2) | ISAF(32R2) 1202968cf8f2Schristos #define INSN_UPTO64R3 INSN_UPTO64R2 | ISAF(64R3) | ISAF(32R3) 1203968cf8f2Schristos #define INSN_UPTO64R5 INSN_UPTO64R3 | ISAF(64R5) | ISAF(32R5) 1204968cf8f2Schristos #define INSN_UPTO64R6 INSN_UPTO64R5 | ISAF(64R6) | ISAF(32R6) 1205968cf8f2Schristos 1206968cf8f2Schristos /* The same information in table form: bit INSN_ISA<X> - 1 of index 1207968cf8f2Schristos INSN_UPTO<Y> - 1 is set if ISA Y includes ISA X. */ 1208968cf8f2Schristos static const unsigned int mips_isa_table[] = { 1209968cf8f2Schristos INSN_UPTO1, 1210968cf8f2Schristos INSN_UPTO2, 1211968cf8f2Schristos INSN_UPTO3, 1212968cf8f2Schristos INSN_UPTO4, 1213968cf8f2Schristos INSN_UPTO5, 1214968cf8f2Schristos INSN_UPTO32, 1215968cf8f2Schristos INSN_UPTO32R2, 1216968cf8f2Schristos INSN_UPTO32R3, 1217968cf8f2Schristos INSN_UPTO32R5, 1218968cf8f2Schristos INSN_UPTO32R6, 1219968cf8f2Schristos INSN_UPTO64, 1220968cf8f2Schristos INSN_UPTO64R2, 1221968cf8f2Schristos INSN_UPTO64R3, 1222968cf8f2Schristos INSN_UPTO64R5, 1223968cf8f2Schristos INSN_UPTO64R6 1224968cf8f2Schristos }; 1225968cf8f2Schristos #undef ISAF 122698b9484cSchristos 122798b9484cSchristos /* Masks used for Chip specific instructions. */ 12284559860eSchristos #define INSN_CHIP_MASK 0xc7ff4f60 122998b9484cSchristos 123098b9484cSchristos /* Cavium Networks Octeon instructions. */ 123198b9484cSchristos #define INSN_OCTEON 0x00000800 1232a2e2270fSchristos #define INSN_OCTEONP 0x00000200 1233a2e2270fSchristos #define INSN_OCTEON2 0x00000100 1234968cf8f2Schristos #define INSN_OCTEON3 0x00000040 123598b9484cSchristos 1236a2e2270fSchristos /* MIPS R5900 instruction */ 1237a2e2270fSchristos #define INSN_5900 0x00004000 123898b9484cSchristos 123998b9484cSchristos /* MIPS R4650 instruction. */ 124098b9484cSchristos #define INSN_4650 0x00010000 124198b9484cSchristos /* LSI R4010 instruction. */ 124298b9484cSchristos #define INSN_4010 0x00020000 124398b9484cSchristos /* NEC VR4100 instruction. */ 124498b9484cSchristos #define INSN_4100 0x00040000 124598b9484cSchristos /* Toshiba R3900 instruction. */ 124698b9484cSchristos #define INSN_3900 0x00080000 124798b9484cSchristos /* MIPS R10000 instruction. */ 124898b9484cSchristos #define INSN_10000 0x00100000 124998b9484cSchristos /* Broadcom SB-1 instruction. */ 125098b9484cSchristos #define INSN_SB1 0x00200000 125198b9484cSchristos /* NEC VR4111/VR4181 instruction. */ 125298b9484cSchristos #define INSN_4111 0x00400000 125398b9484cSchristos /* NEC VR4120 instruction. */ 125498b9484cSchristos #define INSN_4120 0x00800000 125598b9484cSchristos /* NEC VR5400 instruction. */ 125698b9484cSchristos #define INSN_5400 0x01000000 125798b9484cSchristos /* NEC VR5500 instruction. */ 125898b9484cSchristos #define INSN_5500 0x02000000 125998b9484cSchristos 126098b9484cSchristos /* ST Microelectronics Loongson 2E. */ 126198b9484cSchristos #define INSN_LOONGSON_2E 0x40000000 126298b9484cSchristos /* ST Microelectronics Loongson 2F. */ 126398b9484cSchristos #define INSN_LOONGSON_2F 0x80000000 126498b9484cSchristos /* RMI Xlr instruction */ 126598b9484cSchristos #define INSN_XLR 0x00000020 12664559860eSchristos /* Imagination interAptiv MR2. */ 12674559860eSchristos #define INSN_INTERAPTIV_MR2 0x04000000 1268*02f41505Schristos /* Sony PSP Allegrex instruction. */ 1269*02f41505Schristos #define INSN_ALLEGREX 0x08000000 127098b9484cSchristos 127103467a24Schristos /* DSP ASE */ 127203467a24Schristos #define ASE_DSP 0x00000001 127303467a24Schristos #define ASE_DSP64 0x00000002 127403467a24Schristos /* DSP R2 ASE */ 127503467a24Schristos #define ASE_DSPR2 0x00000004 127603467a24Schristos /* Enhanced VA Scheme */ 127703467a24Schristos #define ASE_EVA 0x00000008 1278a2e2270fSchristos /* MCU (MicroController) ASE */ 127903467a24Schristos #define ASE_MCU 0x00000010 128003467a24Schristos /* MDMX ASE */ 128103467a24Schristos #define ASE_MDMX 0x00000020 128203467a24Schristos /* MIPS-3D ASE */ 128303467a24Schristos #define ASE_MIPS3D 0x00000040 128403467a24Schristos /* MT ASE */ 128503467a24Schristos #define ASE_MT 0x00000080 128603467a24Schristos /* SmartMIPS ASE */ 128703467a24Schristos #define ASE_SMARTMIPS 0x00000100 128803467a24Schristos /* Virtualization ASE */ 128903467a24Schristos #define ASE_VIRT 0x00000200 129003467a24Schristos #define ASE_VIRT64 0x00000400 129103467a24Schristos /* MSA Extension */ 129203467a24Schristos #define ASE_MSA 0x00000800 129303467a24Schristos #define ASE_MSA64 0x00001000 1294968cf8f2Schristos /* eXtended Physical Address (XPA) Extension. */ 1295968cf8f2Schristos #define ASE_XPA 0x00002000 1296796c32c9Schristos /* DSP R3 Module. */ 1297ba340e45Schristos #define ASE_DSPR3 0x00004000 12984559860eSchristos /* MIPS16e2 ASE. */ 12994559860eSchristos #define ASE_MIPS16E2 0x00008000 13004559860eSchristos /* MIPS16e2 MT ASE instructions. */ 13014559860eSchristos #define ASE_MIPS16E2_MT 0x00010000 13024559860eSchristos /* The Virtualization ASE has eXtended Physical Addressing (XPA) 13034559860eSchristos instructions which are only valid when both ASEs are enabled. */ 13044559860eSchristos #define ASE_XPA_VIRT 0x00020000 13054559860eSchristos /* Cyclic redundancy check (CRC) ASE. */ 13064559860eSchristos #define ASE_CRC 0x00040000 13074559860eSchristos #define ASE_CRC64 0x00080000 13084559860eSchristos /* Global INValidate Extension. */ 13094559860eSchristos #define ASE_GINV 0x00100000 13104559860eSchristos /* Loongson MultiMedia extensions Instructions (MMI). */ 13114559860eSchristos #define ASE_LOONGSON_MMI 0x00200000 13124559860eSchristos /* Loongson Content Address Memory (CAM). */ 13134559860eSchristos #define ASE_LOONGSON_CAM 0x00400000 13144559860eSchristos /* Loongson EXTensions (EXT) instructions. */ 13154559860eSchristos #define ASE_LOONGSON_EXT 0x00800000 13164559860eSchristos /* Loongson EXTensions R2 (EXT2) instructions. */ 13174559860eSchristos #define ASE_LOONGSON_EXT2 0x01000000 13188dffb485Schristos /* The Enhanced VA Scheme (EVA) extension has instructions which are 13198dffb485Schristos only valid for the R6 ISA. */ 13208dffb485Schristos #define ASE_EVA_R6 0x02000000 1321a2e2270fSchristos 132298b9484cSchristos /* MIPS ISA defines, use instead of hardcoding ISA level. */ 132398b9484cSchristos 132498b9484cSchristos #define ISA_UNKNOWN 0 /* Gas internal use. */ 132598b9484cSchristos #define ISA_MIPS1 INSN_ISA1 132698b9484cSchristos #define ISA_MIPS2 INSN_ISA2 132798b9484cSchristos #define ISA_MIPS3 INSN_ISA3 132898b9484cSchristos #define ISA_MIPS4 INSN_ISA4 132998b9484cSchristos #define ISA_MIPS5 INSN_ISA5 133098b9484cSchristos 133198b9484cSchristos #define ISA_MIPS32 INSN_ISA32 133298b9484cSchristos #define ISA_MIPS64 INSN_ISA64 133398b9484cSchristos 133498b9484cSchristos #define ISA_MIPS32R2 INSN_ISA32R2 1335968cf8f2Schristos #define ISA_MIPS32R3 INSN_ISA32R3 1336968cf8f2Schristos #define ISA_MIPS32R5 INSN_ISA32R5 133798b9484cSchristos #define ISA_MIPS64R2 INSN_ISA64R2 1338968cf8f2Schristos #define ISA_MIPS64R3 INSN_ISA64R3 1339968cf8f2Schristos #define ISA_MIPS64R5 INSN_ISA64R5 134098b9484cSchristos 1341968cf8f2Schristos #define ISA_MIPS32R6 INSN_ISA32R6 1342968cf8f2Schristos #define ISA_MIPS64R6 INSN_ISA64R6 134398b9484cSchristos 134498b9484cSchristos /* CPU defines, use instead of hardcoding processor number. Keep this 134598b9484cSchristos in sync with bfd/archures.c in order for machine selection to work. */ 134698b9484cSchristos #define CPU_UNKNOWN 0 /* Gas internal use. */ 134798b9484cSchristos #define CPU_R3000 3000 134898b9484cSchristos #define CPU_R3900 3900 134998b9484cSchristos #define CPU_R4000 4000 135098b9484cSchristos #define CPU_R4010 4010 135198b9484cSchristos #define CPU_VR4100 4100 135298b9484cSchristos #define CPU_R4111 4111 135398b9484cSchristos #define CPU_VR4120 4120 135498b9484cSchristos #define CPU_R4300 4300 135598b9484cSchristos #define CPU_R4400 4400 135698b9484cSchristos #define CPU_R4600 4600 135798b9484cSchristos #define CPU_R4650 4650 135898b9484cSchristos #define CPU_R5000 5000 135998b9484cSchristos #define CPU_VR5400 5400 136098b9484cSchristos #define CPU_VR5500 5500 1361a2e2270fSchristos #define CPU_R5900 5900 136298b9484cSchristos #define CPU_R6000 6000 136398b9484cSchristos #define CPU_RM7000 7000 136498b9484cSchristos #define CPU_R8000 8000 136598b9484cSchristos #define CPU_RM9000 9000 136698b9484cSchristos #define CPU_R10000 10000 136798b9484cSchristos #define CPU_R12000 12000 136898b9484cSchristos #define CPU_R14000 14000 136998b9484cSchristos #define CPU_R16000 16000 137098b9484cSchristos #define CPU_MIPS16 16 137198b9484cSchristos #define CPU_MIPS32 32 137298b9484cSchristos #define CPU_MIPS32R2 33 1373968cf8f2Schristos #define CPU_MIPS32R3 34 1374968cf8f2Schristos #define CPU_MIPS32R5 36 1375968cf8f2Schristos #define CPU_MIPS32R6 37 137698b9484cSchristos #define CPU_MIPS5 5 137798b9484cSchristos #define CPU_MIPS64 64 137898b9484cSchristos #define CPU_MIPS64R2 65 1379968cf8f2Schristos #define CPU_MIPS64R3 66 1380968cf8f2Schristos #define CPU_MIPS64R5 68 1381968cf8f2Schristos #define CPU_MIPS64R6 69 1382*02f41505Schristos #define CPU_ALLEGREX 10111431 /* octal 'AL', 31. */ 138398b9484cSchristos #define CPU_SB1 12310201 /* octal 'SB', 01. */ 138498b9484cSchristos #define CPU_LOONGSON_2E 3001 138598b9484cSchristos #define CPU_LOONGSON_2F 3002 13864559860eSchristos #define CPU_GS464 3003 13874559860eSchristos #define CPU_GS464E 3004 13884559860eSchristos #define CPU_GS264E 3005 138998b9484cSchristos #define CPU_OCTEON 6501 1390a2e2270fSchristos #define CPU_OCTEONP 6601 1391a2e2270fSchristos #define CPU_OCTEON2 6502 1392968cf8f2Schristos #define CPU_OCTEON3 6503 139398b9484cSchristos #define CPU_XLR 887682 /* decimal 'XLR' */ 13944559860eSchristos #define CPU_INTERAPTIV_MR2 736550 /* decimal 'IA2' */ 139598b9484cSchristos 1396a2e2270fSchristos /* Return true if the given CPU is included in INSN_* mask MASK. */ 1397a2e2270fSchristos 13984b169a6bSchristos static inline bool 1399a2e2270fSchristos cpu_is_member (int cpu, unsigned int mask) 1400a2e2270fSchristos { 1401a2e2270fSchristos switch (cpu) 1402a2e2270fSchristos { 1403a2e2270fSchristos case CPU_R4650: 1404a2e2270fSchristos case CPU_RM7000: 1405a2e2270fSchristos case CPU_RM9000: 1406a2e2270fSchristos return (mask & INSN_4650) != 0; 1407a2e2270fSchristos 1408a2e2270fSchristos case CPU_R4010: 1409a2e2270fSchristos return (mask & INSN_4010) != 0; 1410a2e2270fSchristos 1411a2e2270fSchristos case CPU_VR4100: 1412a2e2270fSchristos return (mask & INSN_4100) != 0; 1413a2e2270fSchristos 1414a2e2270fSchristos case CPU_R3900: 1415a2e2270fSchristos return (mask & INSN_3900) != 0; 1416a2e2270fSchristos 1417a2e2270fSchristos case CPU_R10000: 1418a2e2270fSchristos case CPU_R12000: 1419a2e2270fSchristos case CPU_R14000: 1420a2e2270fSchristos case CPU_R16000: 1421a2e2270fSchristos return (mask & INSN_10000) != 0; 1422a2e2270fSchristos 1423a2e2270fSchristos case CPU_SB1: 1424a2e2270fSchristos return (mask & INSN_SB1) != 0; 1425a2e2270fSchristos 1426a2e2270fSchristos case CPU_R4111: 1427a2e2270fSchristos return (mask & INSN_4111) != 0; 1428a2e2270fSchristos 1429a2e2270fSchristos case CPU_VR4120: 1430a2e2270fSchristos return (mask & INSN_4120) != 0; 1431a2e2270fSchristos 1432a2e2270fSchristos case CPU_VR5400: 1433a2e2270fSchristos return (mask & INSN_5400) != 0; 1434a2e2270fSchristos 1435a2e2270fSchristos case CPU_VR5500: 1436a2e2270fSchristos return (mask & INSN_5500) != 0; 1437a2e2270fSchristos 1438a2e2270fSchristos case CPU_R5900: 1439a2e2270fSchristos return (mask & INSN_5900) != 0; 1440a2e2270fSchristos 1441a2e2270fSchristos case CPU_LOONGSON_2E: 1442a2e2270fSchristos return (mask & INSN_LOONGSON_2E) != 0; 1443a2e2270fSchristos 1444a2e2270fSchristos case CPU_LOONGSON_2F: 1445a2e2270fSchristos return (mask & INSN_LOONGSON_2F) != 0; 1446a2e2270fSchristos 1447a2e2270fSchristos case CPU_OCTEON: 1448a2e2270fSchristos return (mask & INSN_OCTEON) != 0; 1449a2e2270fSchristos 1450a2e2270fSchristos case CPU_OCTEONP: 1451a2e2270fSchristos return (mask & INSN_OCTEONP) != 0; 1452a2e2270fSchristos 1453a2e2270fSchristos case CPU_OCTEON2: 1454a2e2270fSchristos return (mask & INSN_OCTEON2) != 0; 1455a2e2270fSchristos 1456968cf8f2Schristos case CPU_OCTEON3: 1457968cf8f2Schristos return (mask & INSN_OCTEON3) != 0; 1458968cf8f2Schristos 1459a2e2270fSchristos case CPU_XLR: 1460a2e2270fSchristos return (mask & INSN_XLR) != 0; 1461a2e2270fSchristos 14624559860eSchristos case CPU_INTERAPTIV_MR2: 14634559860eSchristos return (mask & INSN_INTERAPTIV_MR2) != 0; 14644559860eSchristos 1465*02f41505Schristos case CPU_ALLEGREX: 1466*02f41505Schristos return (mask & INSN_ALLEGREX) != 0; 1467*02f41505Schristos 1468a2e2270fSchristos default: 14694b169a6bSchristos return false; 1470a2e2270fSchristos } 1471a2e2270fSchristos } 1472a2e2270fSchristos 14734b169a6bSchristos /* Return true if the given ISA is included in INSN_* mask MASK. */ 14744b169a6bSchristos 14754b169a6bSchristos static inline bool 14764b169a6bSchristos isa_is_member (int isa, unsigned int mask) 14774b169a6bSchristos { 14784b169a6bSchristos isa &= INSN_ISA_MASK; 14794b169a6bSchristos mask &= INSN_ISA_MASK; 14804b169a6bSchristos 14814b169a6bSchristos if (isa == 0) 14824b169a6bSchristos return false; 14834b169a6bSchristos 14844b169a6bSchristos if (mask == 0) 14854b169a6bSchristos return false; 14864b169a6bSchristos 14874b169a6bSchristos if (((mips_isa_table[isa - 1] >> (mask - 1)) & 1) == 0) 14884b169a6bSchristos return false; 14894b169a6bSchristos 14904b169a6bSchristos return true; 14914b169a6bSchristos } 14924b169a6bSchristos 149398b9484cSchristos /* Test for membership in an ISA including chip specific ISAs. INSN 149498b9484cSchristos is pointer to an element of the opcode table; ISA is the specified 149598b9484cSchristos ISA/ASE bitmask to test against; and CPU is the CPU specific ISA to 1496a2e2270fSchristos test, or zero if no CPU specific ISA test is desired. Return true 1497a2e2270fSchristos if instruction INSN is available to the given ISA and CPU. */ 149898b9484cSchristos 14994b169a6bSchristos static inline bool 150003467a24Schristos opcode_is_member (const struct mips_opcode *insn, int isa, int ase, int cpu) 1501a2e2270fSchristos { 15024b169a6bSchristos /* Test for ISA level exclusion. */ 15034b169a6bSchristos if (isa_is_member (isa, insn->exclusions)) 15044b169a6bSchristos return false; 15054b169a6bSchristos 15064b169a6bSchristos /* Test for processor-specific exclusion. */ 15074b169a6bSchristos if (cpu_is_member (cpu, insn->exclusions)) 15084b169a6bSchristos return false; 15094b169a6bSchristos 1510a2e2270fSchristos /* Test for ISA level compatibility. */ 15114b169a6bSchristos if (isa_is_member (isa, insn->membership)) 15124b169a6bSchristos return true; 1513a2e2270fSchristos 1514a2e2270fSchristos /* Test for ASE compatibility. */ 151503467a24Schristos if ((ase & insn->ase) != 0) 15164b169a6bSchristos return true; 1517a2e2270fSchristos 1518a2e2270fSchristos /* Test for processor-specific extensions. */ 1519a2e2270fSchristos if (cpu_is_member (cpu, insn->membership)) 15204b169a6bSchristos return true; 15214b169a6bSchristos 15224b169a6bSchristos return false; 1523a2e2270fSchristos } 152498b9484cSchristos 152598b9484cSchristos /* This is a list of macro expanded instructions. 152698b9484cSchristos 152798b9484cSchristos _I appended means immediate 152803467a24Schristos _A appended means target address of a jump 152903467a24Schristos _AB appended means address with (possibly zero) base register 153098b9484cSchristos _D appended means 64 bit floating point constant 153198b9484cSchristos _S appended means 32 bit floating point constant. */ 153298b9484cSchristos 153398b9484cSchristos enum 153498b9484cSchristos { 153598b9484cSchristos M_ABS, 1536a2e2270fSchristos M_ACLR_AB, 153798b9484cSchristos M_ADD_I, 153898b9484cSchristos M_ADDU_I, 153998b9484cSchristos M_AND_I, 1540a2e2270fSchristos M_ASET_AB, 154198b9484cSchristos M_BALIGN, 1542a2e2270fSchristos M_BC1FL, 1543a2e2270fSchristos M_BC1TL, 1544a2e2270fSchristos M_BC2FL, 1545a2e2270fSchristos M_BC2TL, 154698b9484cSchristos M_BEQ, 154798b9484cSchristos M_BEQ_I, 1548a2e2270fSchristos M_BEQL, 154998b9484cSchristos M_BEQL_I, 155098b9484cSchristos M_BGE, 155198b9484cSchristos M_BGEL, 155298b9484cSchristos M_BGE_I, 155398b9484cSchristos M_BGEL_I, 155498b9484cSchristos M_BGEU, 155598b9484cSchristos M_BGEUL, 155698b9484cSchristos M_BGEU_I, 155798b9484cSchristos M_BGEUL_I, 1558a2e2270fSchristos M_BGEZ, 1559a2e2270fSchristos M_BGEZL, 1560a2e2270fSchristos M_BGEZALL, 156198b9484cSchristos M_BGT, 156298b9484cSchristos M_BGTL, 156398b9484cSchristos M_BGT_I, 156498b9484cSchristos M_BGTL_I, 156598b9484cSchristos M_BGTU, 156698b9484cSchristos M_BGTUL, 156798b9484cSchristos M_BGTU_I, 156898b9484cSchristos M_BGTUL_I, 1569a2e2270fSchristos M_BGTZ, 1570a2e2270fSchristos M_BGTZL, 157198b9484cSchristos M_BLE, 157298b9484cSchristos M_BLEL, 157398b9484cSchristos M_BLE_I, 157498b9484cSchristos M_BLEL_I, 157598b9484cSchristos M_BLEU, 157698b9484cSchristos M_BLEUL, 157798b9484cSchristos M_BLEU_I, 157898b9484cSchristos M_BLEUL_I, 1579a2e2270fSchristos M_BLEZ, 1580a2e2270fSchristos M_BLEZL, 158198b9484cSchristos M_BLT, 158298b9484cSchristos M_BLTL, 158398b9484cSchristos M_BLT_I, 158498b9484cSchristos M_BLTL_I, 158598b9484cSchristos M_BLTU, 158698b9484cSchristos M_BLTUL, 158798b9484cSchristos M_BLTU_I, 158898b9484cSchristos M_BLTUL_I, 1589a2e2270fSchristos M_BLTZ, 1590a2e2270fSchristos M_BLTZL, 1591a2e2270fSchristos M_BLTZALL, 159298b9484cSchristos M_BNE, 1593a2e2270fSchristos M_BNEL, 159498b9484cSchristos M_BNE_I, 159598b9484cSchristos M_BNEL_I, 159698b9484cSchristos M_CACHE_AB, 159703467a24Schristos M_CACHEE_AB, 159898b9484cSchristos M_DABS, 159998b9484cSchristos M_DADD_I, 160098b9484cSchristos M_DADDU_I, 160198b9484cSchristos M_DDIV_3, 160298b9484cSchristos M_DDIV_3I, 160398b9484cSchristos M_DDIVU_3, 160498b9484cSchristos M_DDIVU_3I, 160598b9484cSchristos M_DIV_3, 160698b9484cSchristos M_DIV_3I, 160798b9484cSchristos M_DIVU_3, 160898b9484cSchristos M_DIVU_3I, 160998b9484cSchristos M_DLA_AB, 161098b9484cSchristos M_DLCA_AB, 161198b9484cSchristos M_DLI, 161298b9484cSchristos M_DMUL, 161398b9484cSchristos M_DMUL_I, 161498b9484cSchristos M_DMULO, 161598b9484cSchristos M_DMULO_I, 161698b9484cSchristos M_DMULOU, 161798b9484cSchristos M_DMULOU_I, 161898b9484cSchristos M_DREM_3, 161998b9484cSchristos M_DREM_3I, 162098b9484cSchristos M_DREMU_3, 162198b9484cSchristos M_DREMU_3I, 162298b9484cSchristos M_DSUB_I, 162398b9484cSchristos M_DSUBU_I, 162498b9484cSchristos M_DSUBU_I_2, 162598b9484cSchristos M_J_A, 162698b9484cSchristos M_JAL_1, 162798b9484cSchristos M_JAL_2, 162898b9484cSchristos M_JAL_A, 1629a2e2270fSchristos M_JALS_1, 1630a2e2270fSchristos M_JALS_2, 1631a2e2270fSchristos M_JALS_A, 163203467a24Schristos M_JRADDIUSP, 163303467a24Schristos M_JRC, 163498b9484cSchristos M_L_DAB, 163598b9484cSchristos M_LA_AB, 163698b9484cSchristos M_LB_AB, 163703467a24Schristos M_LBE_AB, 163898b9484cSchristos M_LBU_AB, 163903467a24Schristos M_LBUE_AB, 164098b9484cSchristos M_LCA_AB, 164198b9484cSchristos M_LD_AB, 164298b9484cSchristos M_LDC1_AB, 164398b9484cSchristos M_LDC2_AB, 164403467a24Schristos M_LQC2_AB, 164598b9484cSchristos M_LDC3_AB, 164698b9484cSchristos M_LDL_AB, 1647a2e2270fSchristos M_LDM_AB, 1648a2e2270fSchristos M_LDP_AB, 164998b9484cSchristos M_LDR_AB, 165098b9484cSchristos M_LH_AB, 165103467a24Schristos M_LHE_AB, 165298b9484cSchristos M_LHU_AB, 165303467a24Schristos M_LHUE_AB, 165498b9484cSchristos M_LI, 165598b9484cSchristos M_LI_D, 165698b9484cSchristos M_LI_DD, 165798b9484cSchristos M_LI_S, 165898b9484cSchristos M_LI_SS, 165998b9484cSchristos M_LL_AB, 166098b9484cSchristos M_LLD_AB, 16618dffb485Schristos M_LLDP_AB, 166203467a24Schristos M_LLE_AB, 16638dffb485Schristos M_LLWP_AB, 16648dffb485Schristos M_LLWPE_AB, 1665a2e2270fSchristos M_LQ_AB, 166698b9484cSchristos M_LW_AB, 166703467a24Schristos M_LWE_AB, 166898b9484cSchristos M_LWC0_AB, 166998b9484cSchristos M_LWC1_AB, 167098b9484cSchristos M_LWC2_AB, 167198b9484cSchristos M_LWC3_AB, 167298b9484cSchristos M_LWL_AB, 167303467a24Schristos M_LWLE_AB, 1674a2e2270fSchristos M_LWM_AB, 1675a2e2270fSchristos M_LWP_AB, 167698b9484cSchristos M_LWR_AB, 167703467a24Schristos M_LWRE_AB, 167898b9484cSchristos M_LWU_AB, 167998b9484cSchristos M_MSGSND, 168098b9484cSchristos M_MSGLD, 168198b9484cSchristos M_MSGLD_T, 168298b9484cSchristos M_MSGWAIT, 168398b9484cSchristos M_MSGWAIT_T, 168498b9484cSchristos M_MOVE, 168503467a24Schristos M_MOVEP, 168698b9484cSchristos M_MUL, 168798b9484cSchristos M_MUL_I, 168898b9484cSchristos M_MULO, 168998b9484cSchristos M_MULO_I, 169098b9484cSchristos M_MULOU, 169198b9484cSchristos M_MULOU_I, 169298b9484cSchristos M_NOR_I, 169398b9484cSchristos M_OR_I, 169498b9484cSchristos M_PREF_AB, 169503467a24Schristos M_PREFE_AB, 169698b9484cSchristos M_REM_3, 169798b9484cSchristos M_REM_3I, 169898b9484cSchristos M_REMU_3, 169998b9484cSchristos M_REMU_3I, 170098b9484cSchristos M_DROL, 170198b9484cSchristos M_ROL, 170298b9484cSchristos M_DROL_I, 170398b9484cSchristos M_ROL_I, 170498b9484cSchristos M_DROR, 170598b9484cSchristos M_ROR, 170698b9484cSchristos M_DROR_I, 170798b9484cSchristos M_ROR_I, 170898b9484cSchristos M_S_DA, 170998b9484cSchristos M_S_DAB, 171098b9484cSchristos M_S_S, 1711a2e2270fSchristos M_SAA_AB, 1712a2e2270fSchristos M_SAAD_AB, 171398b9484cSchristos M_SC_AB, 171498b9484cSchristos M_SCD_AB, 17158dffb485Schristos M_SCDP_AB, 171603467a24Schristos M_SCE_AB, 17178dffb485Schristos M_SCWP_AB, 17188dffb485Schristos M_SCWPE_AB, 171998b9484cSchristos M_SD_AB, 172098b9484cSchristos M_SDC1_AB, 172198b9484cSchristos M_SDC2_AB, 172203467a24Schristos M_SQC2_AB, 172398b9484cSchristos M_SDC3_AB, 172498b9484cSchristos M_SDL_AB, 1725a2e2270fSchristos M_SDM_AB, 1726a2e2270fSchristos M_SDP_AB, 172798b9484cSchristos M_SDR_AB, 172898b9484cSchristos M_SEQ, 172998b9484cSchristos M_SEQ_I, 173098b9484cSchristos M_SGE, 173198b9484cSchristos M_SGE_I, 173298b9484cSchristos M_SGEU, 173398b9484cSchristos M_SGEU_I, 173498b9484cSchristos M_SGT, 173598b9484cSchristos M_SGT_I, 173698b9484cSchristos M_SGTU, 173798b9484cSchristos M_SGTU_I, 173898b9484cSchristos M_SLE, 173998b9484cSchristos M_SLE_I, 174098b9484cSchristos M_SLEU, 174198b9484cSchristos M_SLEU_I, 174298b9484cSchristos M_SLT_I, 174398b9484cSchristos M_SLTU_I, 174498b9484cSchristos M_SNE, 174598b9484cSchristos M_SNE_I, 174698b9484cSchristos M_SB_AB, 174703467a24Schristos M_SBE_AB, 174898b9484cSchristos M_SH_AB, 174903467a24Schristos M_SHE_AB, 1750a2e2270fSchristos M_SQ_AB, 175198b9484cSchristos M_SW_AB, 175203467a24Schristos M_SWE_AB, 175398b9484cSchristos M_SWC0_AB, 175498b9484cSchristos M_SWC1_AB, 175598b9484cSchristos M_SWC2_AB, 175698b9484cSchristos M_SWC3_AB, 175798b9484cSchristos M_SWL_AB, 175803467a24Schristos M_SWLE_AB, 1759a2e2270fSchristos M_SWM_AB, 1760a2e2270fSchristos M_SWP_AB, 176198b9484cSchristos M_SWR_AB, 176203467a24Schristos M_SWRE_AB, 176398b9484cSchristos M_SUB_I, 176498b9484cSchristos M_SUBU_I, 176598b9484cSchristos M_SUBU_I_2, 176698b9484cSchristos M_TEQ_I, 176798b9484cSchristos M_TGE_I, 176898b9484cSchristos M_TGEU_I, 176998b9484cSchristos M_TLT_I, 177098b9484cSchristos M_TLTU_I, 177198b9484cSchristos M_TNE_I, 177298b9484cSchristos M_TRUNCWD, 177398b9484cSchristos M_TRUNCWS, 177403467a24Schristos M_ULD_AB, 177503467a24Schristos M_ULH_AB, 177603467a24Schristos M_ULHU_AB, 177703467a24Schristos M_ULW_AB, 177803467a24Schristos M_USH_AB, 177903467a24Schristos M_USW_AB, 178003467a24Schristos M_USD_AB, 178198b9484cSchristos M_XOR_I, 178298b9484cSchristos M_COP0, 178398b9484cSchristos M_COP1, 178498b9484cSchristos M_COP2, 178598b9484cSchristos M_COP3, 178698b9484cSchristos M_NUM_MACROS 178798b9484cSchristos }; 178898b9484cSchristos 178998b9484cSchristos 179098b9484cSchristos /* The order of overloaded instructions matters. Label arguments and 179198b9484cSchristos register arguments look the same. Instructions that can have either 179298b9484cSchristos for arguments must apear in the correct order in this table for the 179398b9484cSchristos assembler to pick the right one. In other words, entries with 179498b9484cSchristos immediate operands must apear after the same instruction with 179598b9484cSchristos registers. 179698b9484cSchristos 179798b9484cSchristos Many instructions are short hand for other instructions (i.e., The 179898b9484cSchristos jal <register> instruction is short for jalr <register>). */ 179998b9484cSchristos 180003467a24Schristos extern const struct mips_operand mips_vu0_channel_mask; 180103467a24Schristos extern const struct mips_operand *decode_mips_operand (const char *); 180298b9484cSchristos extern const struct mips_opcode mips_builtin_opcodes[]; 180398b9484cSchristos extern const int bfd_mips_num_builtin_opcodes; 180498b9484cSchristos extern struct mips_opcode *mips_opcodes; 180598b9484cSchristos extern int bfd_mips_num_opcodes; 180698b9484cSchristos #define NUMOPCODES bfd_mips_num_opcodes 180798b9484cSchristos 180898b9484cSchristos 180998b9484cSchristos /* The rest of this file adds definitions for the mips16 TinyRISC 181098b9484cSchristos processor. */ 181198b9484cSchristos 181298b9484cSchristos /* These are the bitmasks and shift counts used for the different 181398b9484cSchristos fields in the instruction formats. Other than OP, no masks are 181498b9484cSchristos provided for the fixed portions of an instruction, since they are 181598b9484cSchristos not needed. 181698b9484cSchristos 181798b9484cSchristos The I format uses IMM11. 181898b9484cSchristos 181998b9484cSchristos The RI format uses RX and IMM8. 182098b9484cSchristos 182198b9484cSchristos The RR format uses RX, and RY. 182298b9484cSchristos 182398b9484cSchristos The RRI format uses RX, RY, and IMM5. 182498b9484cSchristos 182598b9484cSchristos The RRR format uses RX, RY, and RZ. 182698b9484cSchristos 182798b9484cSchristos The RRI_A format uses RX, RY, and IMM4. 182898b9484cSchristos 182998b9484cSchristos The SHIFT format uses RX, RY, and SHAMT. 183098b9484cSchristos 183198b9484cSchristos The I8 format uses IMM8. 183298b9484cSchristos 183398b9484cSchristos The I8_MOVR32 format uses RY and REGR32. 183498b9484cSchristos 183598b9484cSchristos The IR_MOV32R format uses REG32R and MOV32Z. 183698b9484cSchristos 183798b9484cSchristos The I64 format uses IMM8. 183898b9484cSchristos 183998b9484cSchristos The RI64 format uses RY and IMM5. 184098b9484cSchristos */ 184198b9484cSchristos 184298b9484cSchristos #define MIPS16OP_MASK_OP 0x1f 184398b9484cSchristos #define MIPS16OP_SH_OP 11 184498b9484cSchristos #define MIPS16OP_MASK_IMM11 0x7ff 184598b9484cSchristos #define MIPS16OP_SH_IMM11 0 184698b9484cSchristos #define MIPS16OP_MASK_RX 0x7 184798b9484cSchristos #define MIPS16OP_SH_RX 8 184898b9484cSchristos #define MIPS16OP_MASK_IMM8 0xff 184998b9484cSchristos #define MIPS16OP_SH_IMM8 0 185098b9484cSchristos #define MIPS16OP_MASK_RY 0x7 185198b9484cSchristos #define MIPS16OP_SH_RY 5 185298b9484cSchristos #define MIPS16OP_MASK_IMM5 0x1f 185398b9484cSchristos #define MIPS16OP_SH_IMM5 0 185498b9484cSchristos #define MIPS16OP_MASK_RZ 0x7 185598b9484cSchristos #define MIPS16OP_SH_RZ 2 185698b9484cSchristos #define MIPS16OP_MASK_IMM4 0xf 185798b9484cSchristos #define MIPS16OP_SH_IMM4 0 185898b9484cSchristos #define MIPS16OP_MASK_REGR32 0x1f 185998b9484cSchristos #define MIPS16OP_SH_REGR32 0 186098b9484cSchristos #define MIPS16OP_MASK_REG32R 0x1f 186198b9484cSchristos #define MIPS16OP_SH_REG32R 3 186298b9484cSchristos #define MIPS16OP_EXTRACT_REG32R(i) ((((i) >> 5) & 7) | ((i) & 0x18)) 186398b9484cSchristos #define MIPS16OP_MASK_MOVE32Z 0x7 186498b9484cSchristos #define MIPS16OP_SH_MOVE32Z 0 186598b9484cSchristos #define MIPS16OP_MASK_IMM6 0x3f 186698b9484cSchristos #define MIPS16OP_SH_IMM6 5 186798b9484cSchristos 186898b9484cSchristos /* These are the characters which may appears in the args field of a MIPS16 186998b9484cSchristos instruction. They appear in the order in which the fields appear when the 187098b9484cSchristos instruction is used. Commas and parentheses in the args string are ignored 187198b9484cSchristos when assembling, and written into the output when disassembling. 187298b9484cSchristos 187398b9484cSchristos "y" 3 bit register (MIPS16OP_*_RY) 187498b9484cSchristos "x" 3 bit register (MIPS16OP_*_RX) 187598b9484cSchristos "z" 3 bit register (MIPS16OP_*_RZ) 187698b9484cSchristos "Z" 3 bit register (MIPS16OP_*_MOVE32Z) 187798b9484cSchristos "v" 3 bit same register as source and destination (MIPS16OP_*_RX) 187898b9484cSchristos "w" 3 bit same register as source and destination (MIPS16OP_*_RY) 1879796c32c9Schristos "." zero register ($0) 188098b9484cSchristos "S" stack pointer ($sp or $29) 188198b9484cSchristos "P" program counter 188298b9484cSchristos "R" return address register ($ra or $31) 188398b9484cSchristos "X" 5 bit MIPS register (MIPS16OP_*_REGR32) 188498b9484cSchristos "Y" 5 bit MIPS register (MIPS16OP_*_REG32R) 1885796c32c9Schristos "0" 5-bit ASMACRO p0 immediate 1886796c32c9Schristos "1" 3-bit ASMACRO p1 immediate 1887796c32c9Schristos "2" 3-bit ASMACRO p2 immediate 1888796c32c9Schristos "3" 5-bit ASMACRO p3 immediate 1889796c32c9Schristos "4" 3-bit ASMACRO p4 immediate 189098b9484cSchristos "6" 6 bit unsigned break code (MIPS16OP_*_IMM6) 189198b9484cSchristos "a" 26 bit jump address 189203467a24Schristos "i" likewise, but flips bit 0 189398b9484cSchristos "e" 11 bit extension value 189498b9484cSchristos "l" register list for entry instruction 189598b9484cSchristos "L" register list for exit instruction 18964559860eSchristos ">" 5-bit SYNC code 18974559860eSchristos "9" 9-bit signed immediate 18984559860eSchristos "G" global pointer ($gp or $28) 18994559860eSchristos "N" 5-bit coprocessor register 19004559860eSchristos "O" 3-bit sel field for MFC0/MTC0 19014559860eSchristos "Q" 5-bit hardware register 19024559860eSchristos "T" 5-bit CACHE opcode or PREF hint 19034559860eSchristos "b" 5-bit INS/EXT position, which becomes LSB 19044559860eSchristos Enforces: 0 <= pos < 32. 19054559860eSchristos "c" 5-bit INS size, which becomes MSB 19064559860eSchristos Requires that "b" occurs first to set position. 19074559860eSchristos Enforces: 0 < (pos+size) <= 32. 19084559860eSchristos "d" 5-bit EXT size, which becomes MSBD 19094559860eSchristos Requires that "b" occurs first to set position. 19104559860eSchristos Enforces: 0 < (pos+size) <= 32. 19114559860eSchristos "n" 2-bit immediate (1 .. 4) 19124559860eSchristos "o" 5-bit unsigned immediate * 16 19134559860eSchristos "r" 3-bit register 1914796c32c9Schristos "s" 3-bit ASMACRO select immediate 19154559860eSchristos "u" 16-bit unsigned immediate 191698b9484cSchristos 191703467a24Schristos "I" an immediate value used for macros 191803467a24Schristos 191998b9484cSchristos The remaining codes may be extended. Except as otherwise noted, 192098b9484cSchristos the full extended operand is a 16 bit signed value. 192198b9484cSchristos "<" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 5 bit unsigned) 192298b9484cSchristos "[" 3 bit unsigned shift count * 0 (MIPS16OP_*_RZ) (full 6 bit unsigned) 192398b9484cSchristos "]" 3 bit unsigned shift count * 0 (MIPS16OP_*_RX) (full 6 bit unsigned) 192498b9484cSchristos "5" 5 bit unsigned immediate * 0 (MIPS16OP_*_IMM5) 1925796c32c9Schristos "F" 4 bit signed immediate * 0 (MIPS16OP_*_IMM4) (full 15 bit signed) 192698b9484cSchristos "H" 5 bit unsigned immediate * 2 (MIPS16OP_*_IMM5) 192798b9484cSchristos "W" 5 bit unsigned immediate * 4 (MIPS16OP_*_IMM5) 192898b9484cSchristos "D" 5 bit unsigned immediate * 8 (MIPS16OP_*_IMM5) 192998b9484cSchristos "j" 5 bit signed immediate * 0 (MIPS16OP_*_IMM5) 193098b9484cSchristos "8" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) 193198b9484cSchristos "V" 8 bit unsigned immediate * 4 (MIPS16OP_*_IMM8) 193298b9484cSchristos "C" 8 bit unsigned immediate * 8 (MIPS16OP_*_IMM8) 193398b9484cSchristos "U" 8 bit unsigned immediate * 0 (MIPS16OP_*_IMM8) (full 16 bit unsigned) 193498b9484cSchristos "k" 8 bit signed immediate * 0 (MIPS16OP_*_IMM8) 193598b9484cSchristos "K" 8 bit signed immediate * 8 (MIPS16OP_*_IMM8) 193698b9484cSchristos "p" 8 bit conditional branch address (MIPS16OP_*_IMM8) 193798b9484cSchristos "q" 11 bit branch address (MIPS16OP_*_IMM11) 193898b9484cSchristos "A" 8 bit PC relative address * 4 (MIPS16OP_*_IMM8) 193998b9484cSchristos "B" 5 bit PC relative address * 8 (MIPS16OP_*_IMM5) 194098b9484cSchristos "E" 5 bit PC relative address * 4 (MIPS16OP_*_IMM5) 19414559860eSchristos "m" 7 bit register list for SAVE/RESTORE instruction (18 bit extended) 1942ba340e45Schristos 1943ba340e45Schristos Characters used so far, for quick reference when adding more: 19444559860eSchristos "0123456 89" 19454559860eSchristos ".[]<>" 19464559860eSchristos "ABCDEFGHI KL NOPQRSTUVWXYZ" 19474559860eSchristos "abcde ijklmnopqrs uvwxyz" 194898b9484cSchristos */ 194998b9484cSchristos 195098b9484cSchristos /* Save/restore encoding for the args field when all 4 registers are 195198b9484cSchristos either saved as arguments or saved/restored as statics. */ 19524559860eSchristos #define MIPS_SVRS_ALL_ARGS 0xe 19534559860eSchristos #define MIPS_SVRS_ALL_STATICS 0xb 195498b9484cSchristos 195598b9484cSchristos /* The following flags have the same value for the mips16 opcode 195698b9484cSchristos table: 1957a2e2270fSchristos 1958a2e2270fSchristos INSN_ISA3 1959a2e2270fSchristos 196098b9484cSchristos INSN_UNCOND_BRANCH_DELAY 196198b9484cSchristos INSN_COND_BRANCH_DELAY 196298b9484cSchristos INSN_COND_BRANCH_LIKELY (never used) 196398b9484cSchristos INSN_READ_HI 196498b9484cSchristos INSN_READ_LO 196598b9484cSchristos INSN_WRITE_HI 196698b9484cSchristos INSN_WRITE_LO 196798b9484cSchristos INSN_TRAP 1968a2e2270fSchristos FP_D (never used) 196998b9484cSchristos */ 197098b9484cSchristos 19714b169a6bSchristos extern const struct mips_operand *decode_mips16_operand (char, bool); 197298b9484cSchristos extern const struct mips_opcode mips16_opcodes[]; 197398b9484cSchristos extern const int bfd_mips16_num_opcodes; 197498b9484cSchristos 1975a2e2270fSchristos /* These are the bit masks and shift counts used for the different fields 1976a2e2270fSchristos in the microMIPS instruction formats. No masks are provided for the 1977a2e2270fSchristos fixed portions of an instruction, since they are not needed. */ 1978a2e2270fSchristos 1979a2e2270fSchristos #define MICROMIPSOP_MASK_IMMEDIATE 0xffff 1980a2e2270fSchristos #define MICROMIPSOP_SH_IMMEDIATE 0 1981a2e2270fSchristos #define MICROMIPSOP_MASK_DELTA 0xffff 1982a2e2270fSchristos #define MICROMIPSOP_SH_DELTA 0 1983a2e2270fSchristos #define MICROMIPSOP_MASK_CODE10 0x3ff 1984a2e2270fSchristos #define MICROMIPSOP_SH_CODE10 16 /* 10-bit wait code. */ 1985a2e2270fSchristos #define MICROMIPSOP_MASK_TRAP 0xf 1986a2e2270fSchristos #define MICROMIPSOP_SH_TRAP 12 /* 4-bit trap code. */ 1987a2e2270fSchristos #define MICROMIPSOP_MASK_SHAMT 0x1f 1988a2e2270fSchristos #define MICROMIPSOP_SH_SHAMT 11 1989a2e2270fSchristos #define MICROMIPSOP_MASK_TARGET 0x3ffffff 1990a2e2270fSchristos #define MICROMIPSOP_SH_TARGET 0 1991a2e2270fSchristos #define MICROMIPSOP_MASK_EXTLSB 0x1f /* "ext" LSB. */ 1992a2e2270fSchristos #define MICROMIPSOP_SH_EXTLSB 6 1993a2e2270fSchristos #define MICROMIPSOP_MASK_EXTMSBD 0x1f /* "ext" MSBD. */ 1994a2e2270fSchristos #define MICROMIPSOP_SH_EXTMSBD 11 1995a2e2270fSchristos #define MICROMIPSOP_MASK_INSMSB 0x1f /* "ins" MSB. */ 1996a2e2270fSchristos #define MICROMIPSOP_SH_INSMSB 11 1997a2e2270fSchristos #define MICROMIPSOP_MASK_CODE 0x3ff 1998a2e2270fSchristos #define MICROMIPSOP_SH_CODE 16 /* 10-bit higher break code. */ 1999a2e2270fSchristos #define MICROMIPSOP_MASK_CODE2 0x3ff 2000a2e2270fSchristos #define MICROMIPSOP_SH_CODE2 6 /* 10-bit lower break code. */ 2001a2e2270fSchristos #define MICROMIPSOP_MASK_CACHE 0x1f 2002a2e2270fSchristos #define MICROMIPSOP_SH_CACHE 21 /* 5-bit cache op. */ 2003a2e2270fSchristos #define MICROMIPSOP_MASK_SEL 0x7 2004a2e2270fSchristos #define MICROMIPSOP_SH_SEL 11 2005a2e2270fSchristos #define MICROMIPSOP_MASK_OFFSET12 0xfff 2006a2e2270fSchristos #define MICROMIPSOP_SH_OFFSET12 0 2007a2e2270fSchristos #define MICROMIPSOP_MASK_3BITPOS 0x7 2008a2e2270fSchristos #define MICROMIPSOP_SH_3BITPOS 21 2009a2e2270fSchristos #define MICROMIPSOP_MASK_STYPE 0x1f 2010a2e2270fSchristos #define MICROMIPSOP_SH_STYPE 16 2011a2e2270fSchristos #define MICROMIPSOP_MASK_OFFSET10 0x3ff 2012a2e2270fSchristos #define MICROMIPSOP_SH_OFFSET10 6 2013a2e2270fSchristos #define MICROMIPSOP_MASK_RS 0x1f 2014a2e2270fSchristos #define MICROMIPSOP_SH_RS 16 2015a2e2270fSchristos #define MICROMIPSOP_MASK_RT 0x1f 2016a2e2270fSchristos #define MICROMIPSOP_SH_RT 21 2017a2e2270fSchristos #define MICROMIPSOP_MASK_RD 0x1f 2018a2e2270fSchristos #define MICROMIPSOP_SH_RD 11 2019a2e2270fSchristos #define MICROMIPSOP_MASK_FS 0x1f 2020a2e2270fSchristos #define MICROMIPSOP_SH_FS 16 2021a2e2270fSchristos #define MICROMIPSOP_MASK_FT 0x1f 2022a2e2270fSchristos #define MICROMIPSOP_SH_FT 21 2023a2e2270fSchristos #define MICROMIPSOP_MASK_FD 0x1f 2024a2e2270fSchristos #define MICROMIPSOP_SH_FD 11 2025a2e2270fSchristos #define MICROMIPSOP_MASK_FR 0x1f 2026a2e2270fSchristos #define MICROMIPSOP_SH_FR 6 2027a2e2270fSchristos #define MICROMIPSOP_MASK_RS3 0x1f 2028a2e2270fSchristos #define MICROMIPSOP_SH_RS3 6 2029a2e2270fSchristos #define MICROMIPSOP_MASK_PREFX 0x1f 2030a2e2270fSchristos #define MICROMIPSOP_SH_PREFX 11 2031a2e2270fSchristos #define MICROMIPSOP_MASK_BCC 0x7 2032a2e2270fSchristos #define MICROMIPSOP_SH_BCC 18 2033a2e2270fSchristos #define MICROMIPSOP_MASK_CCC 0x7 2034a2e2270fSchristos #define MICROMIPSOP_SH_CCC 13 2035a2e2270fSchristos #define MICROMIPSOP_MASK_COPZ 0x7fffff 2036a2e2270fSchristos #define MICROMIPSOP_SH_COPZ 3 2037a2e2270fSchristos 2038a2e2270fSchristos #define MICROMIPSOP_MASK_MB 0x7 2039a2e2270fSchristos #define MICROMIPSOP_SH_MB 23 2040a2e2270fSchristos #define MICROMIPSOP_MASK_MC 0x7 2041a2e2270fSchristos #define MICROMIPSOP_SH_MC 4 2042a2e2270fSchristos #define MICROMIPSOP_MASK_MD 0x7 2043a2e2270fSchristos #define MICROMIPSOP_SH_MD 7 2044a2e2270fSchristos #define MICROMIPSOP_MASK_ME 0x7 2045a2e2270fSchristos #define MICROMIPSOP_SH_ME 1 2046a2e2270fSchristos #define MICROMIPSOP_MASK_MF 0x7 2047a2e2270fSchristos #define MICROMIPSOP_SH_MF 3 2048a2e2270fSchristos #define MICROMIPSOP_MASK_MG 0x7 2049a2e2270fSchristos #define MICROMIPSOP_SH_MG 0 2050a2e2270fSchristos #define MICROMIPSOP_MASK_MH 0x7 2051a2e2270fSchristos #define MICROMIPSOP_SH_MH 7 2052a2e2270fSchristos #define MICROMIPSOP_MASK_MJ 0x1f 2053a2e2270fSchristos #define MICROMIPSOP_SH_MJ 0 2054a2e2270fSchristos #define MICROMIPSOP_MASK_ML 0x7 2055a2e2270fSchristos #define MICROMIPSOP_SH_ML 4 2056a2e2270fSchristos #define MICROMIPSOP_MASK_MM 0x7 2057a2e2270fSchristos #define MICROMIPSOP_SH_MM 1 2058a2e2270fSchristos #define MICROMIPSOP_MASK_MN 0x7 2059a2e2270fSchristos #define MICROMIPSOP_SH_MN 4 2060a2e2270fSchristos #define MICROMIPSOP_MASK_MP 0x1f 2061a2e2270fSchristos #define MICROMIPSOP_SH_MP 5 2062a2e2270fSchristos #define MICROMIPSOP_MASK_MQ 0x7 2063a2e2270fSchristos #define MICROMIPSOP_SH_MQ 7 2064a2e2270fSchristos 2065a2e2270fSchristos #define MICROMIPSOP_MASK_IMMA 0x7f 2066a2e2270fSchristos #define MICROMIPSOP_SH_IMMA 0 2067a2e2270fSchristos #define MICROMIPSOP_MASK_IMMB 0x7 2068a2e2270fSchristos #define MICROMIPSOP_SH_IMMB 1 2069a2e2270fSchristos #define MICROMIPSOP_MASK_IMMC 0xf 2070a2e2270fSchristos #define MICROMIPSOP_SH_IMMC 0 2071a2e2270fSchristos #define MICROMIPSOP_MASK_IMMD 0x3ff 2072a2e2270fSchristos #define MICROMIPSOP_SH_IMMD 0 2073a2e2270fSchristos #define MICROMIPSOP_MASK_IMME 0x7f 2074a2e2270fSchristos #define MICROMIPSOP_SH_IMME 0 2075a2e2270fSchristos #define MICROMIPSOP_MASK_IMMF 0xf 2076a2e2270fSchristos #define MICROMIPSOP_SH_IMMF 0 2077a2e2270fSchristos #define MICROMIPSOP_MASK_IMMG 0xf 2078a2e2270fSchristos #define MICROMIPSOP_SH_IMMG 0 2079a2e2270fSchristos #define MICROMIPSOP_MASK_IMMH 0xf 2080a2e2270fSchristos #define MICROMIPSOP_SH_IMMH 0 2081a2e2270fSchristos #define MICROMIPSOP_MASK_IMMI 0x7f 2082a2e2270fSchristos #define MICROMIPSOP_SH_IMMI 0 2083a2e2270fSchristos #define MICROMIPSOP_MASK_IMMJ 0xf 2084a2e2270fSchristos #define MICROMIPSOP_SH_IMMJ 0 2085a2e2270fSchristos #define MICROMIPSOP_MASK_IMML 0xf 2086a2e2270fSchristos #define MICROMIPSOP_SH_IMML 0 2087a2e2270fSchristos #define MICROMIPSOP_MASK_IMMM 0x7 2088a2e2270fSchristos #define MICROMIPSOP_SH_IMMM 1 2089a2e2270fSchristos #define MICROMIPSOP_MASK_IMMN 0x3 2090a2e2270fSchristos #define MICROMIPSOP_SH_IMMN 4 2091a2e2270fSchristos #define MICROMIPSOP_MASK_IMMO 0xf 2092a2e2270fSchristos #define MICROMIPSOP_SH_IMMO 0 2093a2e2270fSchristos #define MICROMIPSOP_MASK_IMMP 0x1f 2094a2e2270fSchristos #define MICROMIPSOP_SH_IMMP 0 2095a2e2270fSchristos #define MICROMIPSOP_MASK_IMMQ 0x7fffff 2096a2e2270fSchristos #define MICROMIPSOP_SH_IMMQ 0 2097a2e2270fSchristos #define MICROMIPSOP_MASK_IMMU 0x1f 2098a2e2270fSchristos #define MICROMIPSOP_SH_IMMU 0 2099a2e2270fSchristos #define MICROMIPSOP_MASK_IMMW 0x3f 2100a2e2270fSchristos #define MICROMIPSOP_SH_IMMW 1 2101a2e2270fSchristos #define MICROMIPSOP_MASK_IMMX 0xf 2102a2e2270fSchristos #define MICROMIPSOP_SH_IMMX 1 2103a2e2270fSchristos #define MICROMIPSOP_MASK_IMMY 0x1ff 2104a2e2270fSchristos #define MICROMIPSOP_SH_IMMY 1 2105a2e2270fSchristos 2106a2e2270fSchristos /* MIPS DSP ASE */ 2107a2e2270fSchristos #define MICROMIPSOP_MASK_DSPACC 0x3 2108a2e2270fSchristos #define MICROMIPSOP_SH_DSPACC 14 2109a2e2270fSchristos #define MICROMIPSOP_MASK_DSPSFT 0x3f 2110a2e2270fSchristos #define MICROMIPSOP_SH_DSPSFT 16 2111a2e2270fSchristos #define MICROMIPSOP_MASK_SA3 0x7 2112a2e2270fSchristos #define MICROMIPSOP_SH_SA3 13 2113a2e2270fSchristos #define MICROMIPSOP_MASK_SA4 0xf 2114a2e2270fSchristos #define MICROMIPSOP_SH_SA4 12 2115a2e2270fSchristos #define MICROMIPSOP_MASK_IMM8 0xff 2116a2e2270fSchristos #define MICROMIPSOP_SH_IMM8 13 2117a2e2270fSchristos #define MICROMIPSOP_MASK_IMM10 0x3ff 2118a2e2270fSchristos #define MICROMIPSOP_SH_IMM10 16 2119a2e2270fSchristos #define MICROMIPSOP_MASK_WRDSP 0x3f 2120a2e2270fSchristos #define MICROMIPSOP_SH_WRDSP 14 2121a2e2270fSchristos #define MICROMIPSOP_MASK_BP 0x3 2122a2e2270fSchristos #define MICROMIPSOP_SH_BP 14 2123a2e2270fSchristos 2124a2e2270fSchristos /* Placeholders for fields that only exist in the traditional 32-bit 2125a2e2270fSchristos instruction encoding; see the comment above for details. */ 2126a2e2270fSchristos #define MICROMIPSOP_MASK_CODE20 0 2127a2e2270fSchristos #define MICROMIPSOP_SH_CODE20 0 2128a2e2270fSchristos #define MICROMIPSOP_MASK_PERFREG 0 2129a2e2270fSchristos #define MICROMIPSOP_SH_PERFREG 0 2130a2e2270fSchristos #define MICROMIPSOP_MASK_CODE19 0 2131a2e2270fSchristos #define MICROMIPSOP_SH_CODE19 0 2132a2e2270fSchristos #define MICROMIPSOP_MASK_ALN 0 2133a2e2270fSchristos #define MICROMIPSOP_SH_ALN 0 2134a2e2270fSchristos #define MICROMIPSOP_MASK_VECBYTE 0 2135a2e2270fSchristos #define MICROMIPSOP_SH_VECBYTE 0 2136a2e2270fSchristos #define MICROMIPSOP_MASK_VECALIGN 0 2137a2e2270fSchristos #define MICROMIPSOP_SH_VECALIGN 0 2138a2e2270fSchristos #define MICROMIPSOP_MASK_DSPACC_S 0 2139a2e2270fSchristos #define MICROMIPSOP_SH_DSPACC_S 0 2140a2e2270fSchristos #define MICROMIPSOP_MASK_DSPSFT_7 0 2141a2e2270fSchristos #define MICROMIPSOP_SH_DSPSFT_7 0 2142a2e2270fSchristos #define MICROMIPSOP_MASK_RDDSP 0 2143a2e2270fSchristos #define MICROMIPSOP_SH_RDDSP 0 2144a2e2270fSchristos #define MICROMIPSOP_MASK_MT_U 0 2145a2e2270fSchristos #define MICROMIPSOP_SH_MT_U 0 2146a2e2270fSchristos #define MICROMIPSOP_MASK_MT_H 0 2147a2e2270fSchristos #define MICROMIPSOP_SH_MT_H 0 2148a2e2270fSchristos #define MICROMIPSOP_MASK_MTACC_T 0 2149a2e2270fSchristos #define MICROMIPSOP_SH_MTACC_T 0 2150a2e2270fSchristos #define MICROMIPSOP_MASK_MTACC_D 0 2151a2e2270fSchristos #define MICROMIPSOP_SH_MTACC_D 0 2152a2e2270fSchristos #define MICROMIPSOP_MASK_BBITIND 0 2153a2e2270fSchristos #define MICROMIPSOP_SH_BBITIND 0 2154a2e2270fSchristos #define MICROMIPSOP_MASK_CINSPOS 0 2155a2e2270fSchristos #define MICROMIPSOP_SH_CINSPOS 0 2156a2e2270fSchristos #define MICROMIPSOP_MASK_CINSLM1 0 2157a2e2270fSchristos #define MICROMIPSOP_SH_CINSLM1 0 2158a2e2270fSchristos #define MICROMIPSOP_MASK_SEQI 0 2159a2e2270fSchristos #define MICROMIPSOP_SH_SEQI 0 2160a2e2270fSchristos #define MICROMIPSOP_SH_OFFSET_A 0 2161a2e2270fSchristos #define MICROMIPSOP_MASK_OFFSET_A 0 2162a2e2270fSchristos #define MICROMIPSOP_SH_OFFSET_B 0 2163a2e2270fSchristos #define MICROMIPSOP_MASK_OFFSET_B 0 2164a2e2270fSchristos #define MICROMIPSOP_SH_OFFSET_C 0 2165a2e2270fSchristos #define MICROMIPSOP_MASK_OFFSET_C 0 2166a2e2270fSchristos #define MICROMIPSOP_SH_RZ 0 2167a2e2270fSchristos #define MICROMIPSOP_MASK_RZ 0 2168a2e2270fSchristos #define MICROMIPSOP_SH_FZ 0 2169a2e2270fSchristos #define MICROMIPSOP_MASK_FZ 0 2170a2e2270fSchristos 217103467a24Schristos /* microMIPS Enhanced VA Scheme */ 217203467a24Schristos #define MICROMIPSOP_SH_EVAOFFSET 0 217303467a24Schristos #define MICROMIPSOP_MASK_EVAOFFSET 0x1ff 217403467a24Schristos 2175a2e2270fSchristos /* These are the characters which may appears in the args field of a microMIPS 2176a2e2270fSchristos instruction. They appear in the order in which the fields appear 2177a2e2270fSchristos when the instruction is used. Commas and parentheses in the args 2178a2e2270fSchristos string are ignored when assembling, and written into the output 2179a2e2270fSchristos when disassembling. 2180a2e2270fSchristos 2181a2e2270fSchristos The followings are for 16-bit microMIPS instructions. 2182a2e2270fSchristos 2183a2e2270fSchristos "ma" must be $28 2184a2e2270fSchristos "mc" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MC) at bit 4 2185a2e2270fSchristos The same register used as both source and target. 2186a2e2270fSchristos "md" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MD) at bit 7 2187a2e2270fSchristos "me" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_ME) at bit 1 2188a2e2270fSchristos The same register used as both source and target. 2189a2e2270fSchristos "mf" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MF) at bit 3 2190a2e2270fSchristos "mg" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MG) at bit 0 219103467a24Schristos "mh" 3-bit MIPS register pair (MICROMIPSOP_*_MH) at bit 7 2192a2e2270fSchristos "mj" 5-bit MIPS registers (MICROMIPSOP_*_MJ) at bit 0 2193a2e2270fSchristos "ml" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_ML) at bit 4 2194a2e2270fSchristos "mm" 3-bit MIPS registers 0, 2, 3, 16-20 (MICROMIPSOP_*_MM) at bit 1 2195a2e2270fSchristos "mn" 3-bit MIPS registers 0, 2, 3, 16-20 (MICROMIPSOP_*_MN) at bit 4 2196a2e2270fSchristos "mp" 5-bit MIPS registers (MICROMIPSOP_*_MP) at bit 5 2197a2e2270fSchristos "mq" 3-bit MIPS registers 0, 2-7, 17 (MICROMIPSOP_*_MQ) at bit 7 2198a2e2270fSchristos "mr" must be program counter 2199a2e2270fSchristos "ms" must be $29 2200a2e2270fSchristos "mt" must be the same as the previous register 2201a2e2270fSchristos "mx" must be the same as the destination register 2202a2e2270fSchristos "my" must be $31 2203a2e2270fSchristos "mz" must be $0 2204a2e2270fSchristos 2205a2e2270fSchristos "mA" 7-bit immediate (-64 .. 63) << 2 (MICROMIPSOP_*_IMMA) 2206a2e2270fSchristos "mB" 3-bit immediate (-1, 1, 4, 8, 12, 16, 20, 24) (MICROMIPSOP_*_IMMB) 2207a2e2270fSchristos "mC" 4-bit immediate (1, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64, 128, 255, 2208a2e2270fSchristos 32768, 65535) (MICROMIPSOP_*_IMMC) 2209a2e2270fSchristos "mD" 10-bit branch address (-512 .. 511) << 1 (MICROMIPSOP_*_IMMD) 2210a2e2270fSchristos "mE" 7-bit branch address (-64 .. 63) << 1 (MICROMIPSOP_*_IMME) 2211a2e2270fSchristos "mF" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMMF) 2212a2e2270fSchristos "mG" 4-bit immediate (-1 .. 14) (MICROMIPSOP_*_IMMG) 2213a2e2270fSchristos "mH" 4-bit immediate (0 .. 15) << 1 (MICROMIPSOP_*_IMMH) 2214a2e2270fSchristos "mI" 7-bit immediate (-1 .. 126) (MICROMIPSOP_*_IMMI) 2215a2e2270fSchristos "mJ" 4-bit immediate (0 .. 15) << 2 (MICROMIPSOP_*_IMMJ) 2216a2e2270fSchristos "mL" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMML) 2217a2e2270fSchristos "mM" 3-bit immediate (1 .. 8) (MICROMIPSOP_*_IMMM) 2218a2e2270fSchristos "mN" 2-bit immediate (0 .. 3) for register list (MICROMIPSOP_*_IMMN) 2219a2e2270fSchristos "mO" 4-bit immediate (0 .. 15) (MICROMIPSOP_*_IMML) 2220a2e2270fSchristos "mP" 5-bit immediate (0 .. 31) << 2 (MICROMIPSOP_*_IMMP) 2221a2e2270fSchristos "mU" 5-bit immediate (0 .. 31) << 2 (MICROMIPSOP_*_IMMU) 2222a2e2270fSchristos "mW" 6-bit immediate (0 .. 63) << 2 (MICROMIPSOP_*_IMMW) 2223a2e2270fSchristos "mX" 4-bit immediate (-8 .. 7) (MICROMIPSOP_*_IMMX) 2224a2e2270fSchristos "mY" 9-bit immediate (-258 .. -3, 2 .. 257) << 2 (MICROMIPSOP_*_IMMY) 2225a2e2270fSchristos "mZ" must be zero 2226a2e2270fSchristos 2227a2e2270fSchristos In most cases 32-bit microMIPS instructions use the same characters 2228a2e2270fSchristos as MIPS (with ADDIUPC being a notable exception, but there are some 2229a2e2270fSchristos others too). 2230a2e2270fSchristos 2231a2e2270fSchristos "." 10-bit signed offset/number (MICROMIPSOP_*_OFFSET10) 223203467a24Schristos "1" 5-bit sync type (MICROMIPSOP_*_STYPE) 2233a2e2270fSchristos "<" 5-bit shift amount (MICROMIPSOP_*_SHAMT) 2234a2e2270fSchristos ">" shift amount between 32 and 63, stored after subtracting 32 2235a2e2270fSchristos (MICROMIPSOP_*_SHAMT) 2236a2e2270fSchristos "\" 3-bit position for ASET and ACLR (MICROMIPSOP_*_3BITPOS) 2237a2e2270fSchristos "|" 4-bit trap code (MICROMIPSOP_*_TRAP) 2238a2e2270fSchristos "~" 12-bit signed offset (MICROMIPSOP_*_OFFSET12) 2239a2e2270fSchristos "a" 26-bit target address (MICROMIPSOP_*_TARGET) 224003467a24Schristos "+i" likewise, but flips bit 0 2241a2e2270fSchristos "b" 5-bit base register (MICROMIPSOP_*_RS) 2242a2e2270fSchristos "c" 10-bit higher breakpoint code (MICROMIPSOP_*_CODE) 2243a2e2270fSchristos "d" 5-bit destination register specifier (MICROMIPSOP_*_RD) 2244a2e2270fSchristos "h" 5-bit PREFX hint (MICROMIPSOP_*_PREFX) 2245a2e2270fSchristos "i" 16-bit unsigned immediate (MICROMIPSOP_*_IMMEDIATE) 2246a2e2270fSchristos "j" 16-bit signed immediate (MICROMIPSOP_*_DELTA) 2247a2e2270fSchristos "k" 5-bit cache opcode in target register position (MICROMIPSOP_*_CACHE) 2248a2e2270fSchristos "n" register list for 32-bit LWM/SWM instruction (MICROMIPSOP_*_RT) 2249a2e2270fSchristos "o" 16-bit signed offset (MICROMIPSOP_*_DELTA) 2250a2e2270fSchristos "p" 16-bit PC-relative branch target address (MICROMIPSOP_*_DELTA) 2251a2e2270fSchristos "q" 10-bit lower breakpoint code (MICROMIPSOP_*_CODE2) 2252a2e2270fSchristos "r" 5-bit same register used as both source and target (MICROMIPSOP_*_RS) 2253a2e2270fSchristos "s" 5-bit source register specifier (MICROMIPSOP_*_RS) 2254a2e2270fSchristos "t" 5-bit target register (MICROMIPSOP_*_RT) 2255a2e2270fSchristos "u" 16-bit upper 16 bits of address (MICROMIPSOP_*_IMMEDIATE) 2256a2e2270fSchristos "v" 5-bit same register used as both source and destination 2257a2e2270fSchristos (MICROMIPSOP_*_RS) 2258a2e2270fSchristos "w" 5-bit same register used as both target and destination 2259a2e2270fSchristos (MICROMIPSOP_*_RT) 2260a2e2270fSchristos "y" 5-bit source 3 register for ALNV.PS (MICROMIPSOP_*_RS3) 2261a2e2270fSchristos "z" must be zero register 2262a2e2270fSchristos "C" 23-bit coprocessor function code (MICROMIPSOP_*_COPZ) 2263a2e2270fSchristos "K" 5-bit Hardware Register (RDHWR instruction) (MICROMIPSOP_*_RS) 2264a2e2270fSchristos 2265a2e2270fSchristos "+A" 5-bit INS/EXT/DINS/DEXT/DINSM/DEXTM position, which becomes 2266a2e2270fSchristos LSB (MICROMIPSOP_*_EXTLSB). 2267a2e2270fSchristos Enforces: 0 <= pos < 32. 2268a2e2270fSchristos "+B" 5-bit INS/DINS size, which becomes MSB (MICROMIPSOP_*_INSMSB). 2269a2e2270fSchristos Requires that "+A" or "+E" occur first to set position. 2270a2e2270fSchristos Enforces: 0 < (pos+size) <= 32. 2271a2e2270fSchristos "+C" 5-bit EXT/DEXT size, which becomes MSBD (MICROMIPSOP_*_EXTMSBD). 2272a2e2270fSchristos Requires that "+A" or "+E" occur first to set position. 2273a2e2270fSchristos Enforces: 0 < (pos+size) <= 32. 2274a2e2270fSchristos (Also used by DEXT w/ different limits, but limits for 2275a2e2270fSchristos that are checked by the M_DEXT macro.) 2276a2e2270fSchristos "+E" 5-bit DINSU/DEXTU position, which becomes LSB-32 (MICROMIPSOP_*_EXTLSB). 2277a2e2270fSchristos Enforces: 32 <= pos < 64. 2278a2e2270fSchristos "+F" 5-bit DINSM/DINSU size, which becomes MSB-32 (MICROMIPSOP_*_INSMSB). 2279a2e2270fSchristos Requires that "+A" or "+E" occur first to set position. 2280a2e2270fSchristos Enforces: 32 < (pos+size) <= 64. 2281a2e2270fSchristos "+G" 5-bit DEXTM size, which becomes MSBD-32 (MICROMIPSOP_*_EXTMSBD). 2282a2e2270fSchristos Requires that "+A" or "+E" occur first to set position. 2283a2e2270fSchristos Enforces: 32 < (pos+size) <= 64. 2284a2e2270fSchristos "+H" 5-bit DEXTU size, which becomes MSBD (MICROMIPSOP_*_EXTMSBD). 2285a2e2270fSchristos Requires that "+A" or "+E" occur first to set position. 2286a2e2270fSchristos Enforces: 32 < (pos+size) <= 64. 2287968cf8f2Schristos "+J" 10-bit SYSCALL/WAIT/SDBBP/HYPCALL function code 2288968cf8f2Schristos (MICROMIPSOP_*_CODE10) 2289a2e2270fSchristos 2290a2e2270fSchristos PC-relative addition (ADDIUPC) instruction: 2291a2e2270fSchristos "mQ" 23-bit offset (-4194304 .. 4194303) << 2 (MICROMIPSOP_*_IMMQ) 2292a2e2270fSchristos "mb" 3-bit MIPS registers 2-7, 16, 17 (MICROMIPSOP_*_MB) at bit 23 2293a2e2270fSchristos 2294a2e2270fSchristos Floating point instructions: 2295a2e2270fSchristos "D" 5-bit destination register (MICROMIPSOP_*_FD) 2296a2e2270fSchristos "M" 3-bit compare condition code (MICROMIPSOP_*_CCC) 2297a2e2270fSchristos "N" 3-bit branch condition code (MICROMIPSOP_*_BCC) 2298a2e2270fSchristos "R" 5-bit fr source 3 register (MICROMIPSOP_*_FR) 2299a2e2270fSchristos "S" 5-bit fs source 1 register (MICROMIPSOP_*_FS) 2300a2e2270fSchristos "T" 5-bit ft source 2 register (MICROMIPSOP_*_FT) 2301a2e2270fSchristos "V" 5-bit same register used as floating source and destination or target 2302a2e2270fSchristos (MICROMIPSOP_*_FS) 2303a2e2270fSchristos 2304a2e2270fSchristos Coprocessor instructions: 2305a2e2270fSchristos "E" 5-bit target register (MICROMIPSOP_*_RT) 230603467a24Schristos "G" 5-bit source register (MICROMIPSOP_*_RS) 2307a2e2270fSchristos "H" 3-bit sel field for (D)MTC* and (D)MFC* (MICROMIPSOP_*_SEL) 23084b169a6bSchristos "g" 5-bit control source register (MICROMIPSOP_*_RS) 2309a2e2270fSchristos 2310a2e2270fSchristos Macro instructions: 2311a2e2270fSchristos "A" general 32 bit expression 2312a2e2270fSchristos "I" 32-bit immediate (value placed in imm_expr). 2313a2e2270fSchristos "F" 64-bit floating point constant in .rdata 2314a2e2270fSchristos "L" 64-bit floating point constant in .lit8 2315a2e2270fSchristos "f" 32-bit floating point constant 2316a2e2270fSchristos "l" 32-bit floating point constant in .lit4 2317a2e2270fSchristos 2318a2e2270fSchristos DSP ASE usage: 2319a2e2270fSchristos "2" 2-bit unsigned immediate for byte align (MICROMIPSOP_*_BP) 2320a2e2270fSchristos "3" 3-bit unsigned immediate (MICROMIPSOP_*_SA3) 2321a2e2270fSchristos "4" 4-bit unsigned immediate (MICROMIPSOP_*_SA4) 2322a2e2270fSchristos "5" 8-bit unsigned immediate (MICROMIPSOP_*_IMM8) 2323a2e2270fSchristos "6" 5-bit unsigned immediate (MICROMIPSOP_*_RS) 2324a2e2270fSchristos "7" 2-bit DSP accumulator register (MICROMIPSOP_*_DSPACC) 2325a2e2270fSchristos "8" 6-bit unsigned immediate (MICROMIPSOP_*_WRDSP) 2326a2e2270fSchristos "0" 6-bit signed immediate (MICROMIPSOP_*_DSPSFT) 2327a2e2270fSchristos "@" 10-bit signed immediate (MICROMIPSOP_*_IMM10) 2328a2e2270fSchristos "^" 5-bit unsigned immediate (MICROMIPSOP_*_RD) 2329a2e2270fSchristos 233003467a24Schristos microMIPS Enhanced VA Scheme: 233103467a24Schristos "+j" 9-bit signed offset in bit 0 (OP_*_EVAOFFSET) 233203467a24Schristos 233303467a24Schristos MSA Extension: 233403467a24Schristos "+d" 5-bit MSA register (FD) 233503467a24Schristos "+e" 5-bit MSA register (FS) 233603467a24Schristos "+h" 5-bit MSA register (FT) 233703467a24Schristos "+k" 5-bit GPR at bit 6 233803467a24Schristos "+l" 5-bit MSA control register at bit 6 233903467a24Schristos "+n" 5-bit MSA control register at bit 11 234003467a24Schristos "+o" 4-bit vector element index at bit 16 234103467a24Schristos "+u" 3-bit vector element index at bit 16 234203467a24Schristos "+v" 2-bit vector element index at bit 16 234303467a24Schristos "+w" 1-bit vector element index at bit 16 234403467a24Schristos "+x" 5-bit shift amount at bit 16 234503467a24Schristos "+T" (-512 .. 511) << 0 at bit 16 234603467a24Schristos "+U" (-512 .. 511) << 1 at bit 16 234703467a24Schristos "+V" (-512 .. 511) << 2 at bit 16 234803467a24Schristos "+W" (-512 .. 511) << 3 at bit 16 234903467a24Schristos "+~" 2 bit LSA/DLSA shift amount from 1 to 4 at bit 6 235003467a24Schristos "+!" 3 bit unsigned bit position at bit 16 235103467a24Schristos "+@" 4 bit unsigned bit position at bit 16 235203467a24Schristos "+#" 6 bit unsigned bit position at bit 16 235303467a24Schristos "+$" 5 bit unsigned immediate at bit 16 235403467a24Schristos "+%" 5 bit signed immediate at bit 16 235503467a24Schristos "+^" 10 bit signed immediate at bit 11 235603467a24Schristos "+&" 0 vector element index 235703467a24Schristos "+*" 5-bit register vector element index at bit 16 235803467a24Schristos "+|" 8-bit mask at bit 16 235903467a24Schristos 2360a2e2270fSchristos Other: 2361a2e2270fSchristos "()" parens surrounding optional value 2362a2e2270fSchristos "," separates operands 2363a2e2270fSchristos "+" start of extension sequence 2364a2e2270fSchristos "m" start of microMIPS extension sequence 2365a2e2270fSchristos 2366a2e2270fSchristos Characters used so far, for quick reference when adding more: 2367a2e2270fSchristos "12345678 0" 2368968cf8f2Schristos "<>(),+-.@\^|~" 2369a2e2270fSchristos "ABCDEFGHI KLMN RST V " 23704b169a6bSchristos "abcd fghijklmnopqrstuvw yz" 2371a2e2270fSchristos 2372a2e2270fSchristos Extension character sequences used so far ("+" followed by the 2373a2e2270fSchristos following), for quick reference when adding more: 2374a2e2270fSchristos "" 237503467a24Schristos "~!@#$%^&*|" 2376968cf8f2Schristos "ABCEFGHJTUVW" 237703467a24Schristos "dehijklnouvwx" 2378a2e2270fSchristos 2379a2e2270fSchristos Extension character sequences used so far ("m" followed by the 2380a2e2270fSchristos following), for quick reference when adding more: 2381a2e2270fSchristos "" 2382a2e2270fSchristos "" 2383a2e2270fSchristos " BCDEFGHIJ LMNOPQ U WXYZ" 2384a2e2270fSchristos " bcdefghij lmn pq st xyz" 2385968cf8f2Schristos 2386968cf8f2Schristos Extension character sequences used so far ("-" followed by the 2387968cf8f2Schristos following), for quick reference when adding more: 2388968cf8f2Schristos "" 2389968cf8f2Schristos "" 2390968cf8f2Schristos <none so far> 2391a2e2270fSchristos */ 2392a2e2270fSchristos 239303467a24Schristos extern const struct mips_operand *decode_micromips_operand (const char *); 2394a2e2270fSchristos extern const struct mips_opcode micromips_opcodes[]; 2395a2e2270fSchristos extern const int bfd_micromips_num_opcodes; 2396a2e2270fSchristos 239798b9484cSchristos /* A NOP insn impemented as "or at,at,zero". 239898b9484cSchristos Used to implement -mfix-loongson2f. */ 239998b9484cSchristos #define LOONGSON2F_NOP_INSN 0x00200825 240098b9484cSchristos 2401ba340e45Schristos #ifdef __cplusplus 2402ba340e45Schristos } 2403ba340e45Schristos #endif 2404ba340e45Schristos 240598b9484cSchristos #endif /* _MIPS_H_ */ 2406